import { h, Host } from "@stencil/core";
export class SpwBox {
    constructor() {
        /** Permet d'appliquer un border-radius sur la box */
        this.hasRadius = false;
        /** Permet d'appliquer un box-shadow sur la box */
        this.hasShadow = false;
        /** Permet de rendre la box sticky */
        this.isSticky = false;
        /** Définit le padding de la box */
        this.padding = 'none';
        /** Permet de rendre le contenu de la box collapsible sur un breakpoint donné */
        this.isCollapsible = false;
        /** Définit le breakpoint en dessous duquel la box est collapsible (sm: 460px, md: 768px, lg: 1024px, xl: 1350px,
        xxl: 1770px, always: toujours collapsible) */
        this.collapsibleBreakpoint = 'md';
        this.isOpen = false;
        this.toggle = () => {
            if (!this.isCollapsibleActive)
                return;
            this.isOpen = !this.isOpen;
        };
    }
    get isCollapsibleActive() {
        if (!this.isCollapsible)
            return false;
        if (this.collapsibleBreakpoint === 'always')
            return true;
        const breakpoints = { sm: 460, md: 768, lg: 1024, xl: 1350, xxl: 1770 };
        return window.innerWidth <= breakpoints[this.collapsibleBreakpoint];
    }
    get hostClass() {
        return {
            'spw-box--is-sticky': this.isSticky,
            [`spw-box--collapsible-${this.collapsibleBreakpoint}`]: this.isCollapsible,
        };
    }
    get elementClass() {
        return {
            'spw-box': true,
            'spw-box--has-radius': this.hasRadius,
            'spw-box--has-shadow': this.hasShadow,
            [`spw-box--padding-${this.padding}`]: this.padding !== 'none',
        };
    }
    render() {
        var _a, _b;
        const hostStyle = this.stickyTop ? { '--spw-box-sticky-top': this.stickyTop } : undefined;
        const contentStyle = this.isCollapsible ? { height: this.isOpen || !this.isCollapsibleActive ? `${(_b = (_a = this.contentRef) === null || _a === void 0 ? void 0 : _a.scrollHeight) !== null && _b !== void 0 ? _b : 0}px` : '0px' } : undefined;
        return (h(Host, { key: '71f0ca883b24d20c68e415905b9a7adfe4817268', class: this.hostClass, style: hostStyle }, h("div", { key: '370a502d2df32122bb1dbddd1e77fbb809f503e3', class: this.elementClass }, h("div", { key: '8fce2c39ca9fb109f5b76583c84afe17d53f7a99', class: { 'spw-box__header': true, 'spw-box__header--collapsible': this.isCollapsible }, onClick: this.toggle }, h("slot", { key: '838b378e976f8f567e31bca92190581356d6e6ba', name: "header" }), this.isCollapsible && (h("spw-icon", { key: '4bd92026ce4f1dcd353f7ccd75f23c958a1ff6ae', icon: "fa-chevron-down", class: { 'spw-box__header-icon--open': this.isOpen } }))), h("div", { key: '08d4138fcc99855e95c27d99d1aadeb33f5aa836', class: { 'spw-box__content': true, 'spw-box__content--collapsed': this.isCollapsible }, style: contentStyle, ref: el => (this.contentRef = el) }, h("slot", { key: 'f8990c3198f4058bf836f4496aac3af4bf8fe005' })))));
    }
    static get is() { return "spw-box"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["spw-box.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["spw-box.css"]
        };
    }
    static get properties() {
        return {
            "hasRadius": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Permet d'appliquer un border-radius sur la box"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "has-radius",
                "defaultValue": "false"
            },
            "hasShadow": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Permet d'appliquer un box-shadow sur la box"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "has-shadow",
                "defaultValue": "false"
            },
            "isSticky": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Permet de rendre la box sticky"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "is-sticky",
                "defaultValue": "false"
            },
            "stickyTop": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit la position top de la box sticky (ex: '32px', '80px', '2vh',...)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "sticky-top"
            },
            "padding": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'none' | 'small' | 'medium' | 'large'",
                    "resolved": "\"large\" | \"medium\" | \"none\" | \"small\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit le padding de la box"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "padding",
                "defaultValue": "'none'"
            },
            "isCollapsible": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Permet de rendre le contenu de la box collapsible sur un breakpoint donn\u00E9"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "is-collapsible",
                "defaultValue": "false"
            },
            "collapsibleBreakpoint": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'always'",
                    "resolved": "\"always\" | \"lg\" | \"md\" | \"sm\" | \"xl\" | \"xxl\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit le breakpoint en dessous duquel la box est collapsible (sm: 460px, md: 768px, lg: 1024px, xl: 1350px,\nxxl: 1770px, always: toujours collapsible)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "collapsible-breakpoint",
                "defaultValue": "'md'"
            }
        };
    }
    static get states() {
        return {
            "isOpen": {}
        };
    }
    static get elementRef() { return "el"; }
}
