/*!
 * Custom elements for Nanopore-Digital Web applications
 */
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
import { W as Wormhole } from './algolia-data.js';

const AlgoliaPagination = /*@__PURE__*/ proxyCustomElement(class AlgoliaPagination extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.nanoPageChanged = createEvent(this, "nanoPageChanged", 7);
    }
    get el() { return 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 (h(Host, { key: '488332e371953208f90e754ebdceff321795177c', class: {
                'show-pagination': this.show,
            } }, h("div", { key: '9f24519df07b4f022297a5e6f1ace601efc71e2b', ref: (div) => (this.outputEle = div) }, h("slot", { key: '363d87eb251ba2db6e6c3346e32f5dcb8b8d3a0c', name: "output" }))));
    }
    static get watchers() { return {
        "currentPage": ["currentPageChange"],
        "infiniteScroll": ["infiniteScrollChange"]
    }; }
}, [257, "nano-algolia-pagination", {
        "maxToShow": [2, "max-to-show"],
        "currentPage": [32],
        "canGoPrev": [32],
        "canGoNext": [32],
        "show": [32],
        "tplRenderFn": [32],
        "indexResults": [32],
        "infiniteScroll": [32],
        "nextPage": [64],
        "prevPage": [64],
        "goToPage": [64]
    }, undefined, {
        "currentPage": ["currentPageChange"],
        "infiniteScroll": ["infiniteScrollChange"]
    }]);
// Use the injectProps method to pass from the tunnel as props to the component
Wormhole(AlgoliaPagination, [
    'indexResults',
    'filterChanged',
    'tplRenderFn',
]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["nano-algolia-pagination"];
    components.forEach(tagName => { switch (tagName) {
        case "nano-algolia-pagination":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, AlgoliaPagination);
            }
            break;
    } });
}

const NanoAlgoliaPagination = AlgoliaPagination;
const defineCustomElement = defineCustomElement$1;

export { NanoAlgoliaPagination, defineCustomElement };
