/*!
 * Custom elements for Nanopore-Digital Web applications
 */
'use strict';

var index = require('./index-DGttnXif.js');
var algoliaData = require('./algolia-data-BqpBVN89.js');

const AlgoliaPagination = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.nanoPageChanged = index.createEvent(this, "nanoPageChanged", 7);
    }
    get el() { return index.getElement(this); }
    outputEle;
    outputSlot;
    outputTo;
    templateStr;
    templateSlot;
    currentPage = null;
    canGoPrev = false;
    canGoNext = false;
    show = true;
    tplRenderFn;
    indexResults = null;
    infiniteScroll = false;
    /** Max number of page numbers to show */
    maxToShow = null;
    /**
     * Emitted when the page number changes
     */
    nanoPageChanged;
    currentPageChange() { }
    infiniteScrollChange() {
        this.show = !this.infiniteScroll;
    }
    /** Go to next page from current */
    async nextPage() { }
    /** Go to previous page from current */
    async prevPage() { }
    /** Go to a particular page */
    async goToPage(page) {
        console.info(page);
    }
    updateContent() {
        this.outputTo = this.outputSlot || this.outputEle;
        if (!this.templateStr || !this.outputTo || !this.indexResults) {
            this.show = false;
            return;
        }
    }
    componentWillLoad() {
        this.templateSlot = this.el.querySelector('[slot="filter-template"]');
        this.outputSlot = this.el.querySelector('[slot="output"]');
        if (this.templateSlot)
            this.templateStr = this.templateSlot.innerHTML;
    }
    componentDidLoad() {
        this.updateContent();
    }
    render() {
        return (index.h(index.Host, { key: '488332e371953208f90e754ebdceff321795177c', class: {
                'show-pagination': this.show,
            } }, index.h("div", { key: '9f24519df07b4f022297a5e6f1ace601efc71e2b', ref: (div) => (this.outputEle = div) }, index.h("slot", { key: '363d87eb251ba2db6e6c3346e32f5dcb8b8d3a0c', name: "output" }))));
    }
    static get watchers() { return {
        "currentPage": ["currentPageChange"],
        "infiniteScroll": ["infiniteScrollChange"]
    }; }
};
// Use the injectProps method to pass from the tunnel as props to the component
algoliaData.Wormhole(AlgoliaPagination, [
    'indexResults',
    'filterChanged',
    'tplRenderFn',
]);

exports.nano_algolia_pagination = AlgoliaPagination;
