import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
import { a as IC_DEVICE_SIZES } from './constants.js';
import { l as getBrandForegroundAppearance, q as getCurrentDeviceSize, c as checkResizeObserver, f as renderDynamicChildSlots, i as isSlotUsed, I as IcBrandForegroundEnum, J as hasClassificationBanner } from './helpers.js';
import { d as defineCustomElement$3 } from './ic-section-container2.js';
import { d as defineCustomElement$2 } from './ic-typography2.js';

const icFooterCss = "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%;}body{margin:0}main{display:block}h1{font-size:2em;margin:0.67em 0}hr{box-sizing:content-box;height:0;overflow:visible;}pre{font-family:monospace, monospace;font-size:1em;}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace, monospace;font-size:1em;}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}button,input{overflow:visible}button,select{text-transform:none}button,[type=\"button\"],[type=\"reset\"],[type=\"submit\"]{-webkit-appearance:button}button::-moz-focus-inner,[type=\"button\"]::-moz-focus-inner,[type=\"reset\"]::-moz-focus-inner,[type=\"submit\"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=\"button\"]:-moz-focusring,[type=\"reset\"]:-moz-focusring,[type=\"submit\"]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}progress{vertical-align:baseline}textarea{overflow:auto}[type=\"checkbox\"],[type=\"radio\"]{box-sizing:border-box;padding:0;}[type=\"number\"]::-webkit-inner-spin-button,[type=\"number\"]::-webkit-outer-spin-button{height:auto}[type=\"search\"]{-webkit-appearance:textfield;outline-offset:-2px;}[type=\"search\"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font-style:inherit;vertical-align:baseline}:host{display:block;--footer-compliance-padding:1rem 0}:host(.ic-footer-sparse){--footer-links-padding:1.5rem 0;--footer-logo-margin-bottom:calc(var(--ic-space-md) + var(--ic-space-xxs));--footer-link-inner-flex-direction:row}:host(.ic-footer-small){--footer-links-padding:0 0;--footer-logo-margin-bottom:var(--ic-space-md);--footer-link-inner-flex-direction:column}:host(.ic-footer-foreground-dark){--ic-footer-background:var(--ic-brand-color-secondary-light);--ic-footer-bottom-background:var(--ic-brand-color-tertiary-light);--ic-footer-keyline:var(--ic-state-layer-darken-20);--ic-footer-text:var(--ic-color-text-primary-light);--ic-footer-link:var(--ic-color-text-primary-light);--ic-footer-icon:var(--ic-color-icon-neutral);--ic-footer-chevron-icon:var(--ic-color-icon-neutral);--ic-footer-logo:var(--ic-color-icon-neutral);--ic-footer-hover:var(--ic-architectural-700-state-layer-10);--ic-footer-pressed:var(--ic-architectural-700-state-layer-20)}:host(.ic-footer-small.ic-footer-ungrouped){--footer-links-padding:var(--ic-space-md) 0 0 0}footer{display:flex;flex-direction:column;width:100%}.footer-description{background-color:var(--ic-footer-background);color:var(--ic-footer-text);--ic-typography-color:var(--ic-footer-text);border-bottom:var(--ic-space-1px) solid var(--ic-footer-keyline)}.footer-description-inner{padding:1rem 0}.footer-links{padding:var(--footer-links-padding);background-color:var(--ic-footer-background);color:var(--ic-footer-link);--ic-typography-color:var(--ic-footer-link)}.footer-links-inner{display:flex;flex-direction:var(--footer-link-inner-flex-direction)}.footer-compliance{background-color:var(--ic-footer-bottom-background);color:var(--ic-footer-text);--ic-typography-color:var(--ic-footer-text)}.footer-compliance-inner{padding:var(--footer-compliance-padding)}.footer-logo{margin-bottom:var(--footer-logo-margin-bottom);display:flex;gap:var(--ic-space-xxl)}.footer-logo>::slotted(){margin-right:var(--ic-space-md)}.footer-caption{margin-bottom:var(--ic-space-md)}.classification-spacing{margin-bottom:var(--ic-space-lg)}@media (forced-colors: active){footer{border-top:var(--ic-border-hc)}}";
const IcFooterStyle0 = icFooterCss;

const Footer = /*@__PURE__*/ proxyCustomElement(class Footer extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.footerResized = createEvent(this, "footerResized", 7);
        this.resizeObserver = null;
        this.hostMutationObserver = null;
        this.deviceSize = IC_DEVICE_SIZES.XL;
        this.foregroundColor = getBrandForegroundAppearance();
        /**
         * The alignment of the section containers used within the footer.
         */
        this.aligned = "left";
        /**
         * The screen size breakpoint at which to switch to the small layout.
         */
        this.breakpoint = "medium";
        /**
         * If `true`, the footer will display the crown copyright at the bottom.
         */
        this.copyright = true;
        /**
         * The text displayed for the copyright notice if `copyright` is `true`.
         */
        this.copyrightText = "© Crown Copyright";
        /**
         * If `true`, the footer will be set up to handle link groups instead of standalone links.
         */
        this.groupLinks = false;
        this.resizeObserverCallback = (currSize) => {
            if (currSize !== this.deviceSize) {
                this.deviceSize = currSize;
            }
            this.footerResized.emit();
        };
        this.runResizeObserver = () => {
            if (this.footerEl) {
                this.resizeObserver = new ResizeObserver(() => {
                    const currSize = getCurrentDeviceSize();
                    this.resizeObserverCallback(currSize);
                });
                this.resizeObserver.observe(this.footerEl);
            }
        };
    }
    disconnectedCallback() {
        var _a;
        if (this.resizeObserver !== null) {
            this.resizeObserver.disconnect();
        }
        (_a = this.hostMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
    }
    componentWillLoad() {
        this.deviceSize = getCurrentDeviceSize();
    }
    componentDidLoad() {
        checkResizeObserver(this.runResizeObserver);
        this.hostMutationObserver = new MutationObserver((mutationList) => {
            return renderDynamicChildSlots(mutationList, "link", this);
        });
        this.hostMutationObserver.observe(this.el, {
            childList: true,
        });
    }
    brandChangeHandler(ev) {
        this.foregroundColor = ev.detail.mode;
    }
    isSmall() {
        const bp = this.breakpoint;
        return bp === "extra small"
            ? this.deviceSize < IC_DEVICE_SIZES.XS
            : bp === "small"
                ? this.deviceSize < IC_DEVICE_SIZES.S
                : bp === "medium"
                    ? this.deviceSize < IC_DEVICE_SIZES.M
                    : bp === "large"
                        ? this.deviceSize < IC_DEVICE_SIZES.L
                        : bp === "extra large"
                            ? this.deviceSize < IC_DEVICE_SIZES.XL
                            : false;
    }
    render() {
        const { aligned, caption, copyright, copyrightText, description, deviceSize, el, foregroundColor, groupLinks, } = this;
        const small = this.isSmall();
        const showComplianceSection = isSlotUsed(el, "logo") ||
            isSlotUsed(el, "caption") ||
            caption ||
            copyright;
        return (h(Host, { key: '998f2d4e2efe145b4b83e389d35aa5441493c665', class: {
                ["ic-footer"]: true,
                [`ic-footer-${small ? "small" : "sparse"}`]: true,
                [`ic-footer-${groupLinks ? "grouped" : "ungrouped"}`]: true,
                [`ic-footer-foreground-${foregroundColor}`]: true,
                // Slots will be able to infer their own color
                [`ic-footer-${IcBrandForegroundEnum.Dark}`]: foregroundColor === IcBrandForegroundEnum.Dark,
                [`ic-footer-${IcBrandForegroundEnum.Light}`]: foregroundColor === IcBrandForegroundEnum.Light,
            } }, h("footer", { key: 'c87d22d28a01bda8c3ee2b9cac46be2887713a29', ref: (el) => (this.footerEl = el) }, (isSlotUsed(el, "description") || description) && (h("div", { key: 'f308a06d6f0659a0cfce9bbf83c83a5b7002888c', class: "footer-description" }, h("ic-section-container", { key: 'b37d8391f9d6976ab470ee313cffde02fb44379e', aligned: aligned, fullHeight: true }, h("div", { key: '577f163c461029ff87860d22e5f6d8727f2700f2', class: "footer-description-inner" }, h("ic-typography", { key: 'd5511f1010de1c5e474d7a4ca300c3c65524b848', variant: "body" }, h("slot", { key: 'ee7cbda304a95acf11208bf01779669d2ae80e5b', name: "description" }, description)))))), isSlotUsed(el, "link") && (h("div", { key: 'a2c16d41f279a1241ceeacb61ab6891e1caa02b4', class: "footer-links" }, groupLinks && small ? (h("div", { class: "footer-links-inner", role: "list" }, h("slot", { name: "link" }))) : (h("ic-section-container", { fullHeight: true, aligned: aligned }, h("div", { class: "footer-links-inner", role: "list" }, h("slot", { name: "link" })))))), showComplianceSection && (h("div", { key: '612fef7b2098beeb005bca7c8c6a770073d18a84', class: "footer-compliance" }, h("ic-section-container", { key: 'c69ae2ee035e470340f5a5f23b446d0e496053cb', aligned: aligned, fullHeight: true }, h("div", { key: 'f9dbd6a02403a60af427c31d872895f55fb93d4b', class: "footer-compliance-inner" }, isSlotUsed(el, "logo") && (h("div", { key: '2f3303d4ec7608da07f229d012d28fde289088b4', class: "footer-logo" }, h("slot", { key: '4447941f54b6276e088fa3f7facc0fa938dbbd95', name: "logo" }))), (isSlotUsed(el, "caption") || caption) && (h("div", { key: '7b1d062760f15d92a97fd5edd5bd367e61a03ac6', class: "footer-caption" }, h("ic-typography", { key: 'fd22c635085c468676125e4283b59661a2092c83', variant: deviceSize <= IC_DEVICE_SIZES.M ? "caption" : "body" }, h("slot", { key: '026d7f0837f3dfa21ca81ce23e44c4a0526e6b6d', name: "caption" }, caption)))), copyright && (h("div", { key: '75c74053fbc359a6a05600f532f2c6dab5cae23b', class: {
                ["footer-copyright"]: true,
                ["classification-spacing"]: hasClassificationBanner(),
            } }, h("ic-typography", { key: '91f098b1ea0a5f0aa87e6430ad5c043c6a5fd10f', variant: deviceSize <= IC_DEVICE_SIZES.M
                ? "caption-uppercase"
                : "label-uppercase" }, copyrightText))))))))));
    }
    get el() { return this; }
    static get style() { return IcFooterStyle0; }
}, [1, "ic-footer", {
        "aligned": [1],
        "breakpoint": [1],
        "caption": [1],
        "copyright": [4],
        "copyrightText": [1, "copyright-text"],
        "description": [1],
        "groupLinks": [4, "group-links"],
        "deviceSize": [32],
        "foregroundColor": [32]
    }, [[4, "brandChange", "brandChangeHandler"]]]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["ic-footer", "ic-section-container", "ic-typography"];
    components.forEach(tagName => { switch (tagName) {
        case "ic-footer":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, Footer);
            }
            break;
        case "ic-section-container":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "ic-typography":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}

const IcFooter = Footer;
const defineCustomElement = defineCustomElement$1;

export { IcFooter, defineCustomElement };

//# sourceMappingURL=ic-footer.js.map