'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-d337cd8a.js');
const helpers = require('./helpers-fc4016d2.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 = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.footerResized = index.createEvent(this, "footerResized", 7);
        this.resizeObserver = null;
        this.hostMutationObserver = null;
        this.deviceSize = helpers.IC_DEVICE_SIZES.XL;
        this.foregroundColor = helpers.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;
        /**
         * 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 = helpers.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 = helpers.getCurrentDeviceSize();
    }
    componentDidLoad() {
        helpers.checkResizeObserver(this.runResizeObserver);
        this.hostMutationObserver = new MutationObserver((mutationList) => {
            return helpers.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 < helpers.IC_DEVICE_SIZES.XS
            : bp === "small"
                ? this.deviceSize < helpers.IC_DEVICE_SIZES.S
                : bp === "medium"
                    ? this.deviceSize < helpers.IC_DEVICE_SIZES.M
                    : bp === "large"
                        ? this.deviceSize < helpers.IC_DEVICE_SIZES.L
                        : bp === "extra large"
                            ? this.deviceSize < helpers.IC_DEVICE_SIZES.XL
                            : false;
    }
    render() {
        const { aligned, caption, copyright, description, deviceSize, el, foregroundColor, groupLinks, } = this;
        const small = this.isSmall();
        const showComplianceSection = helpers.isSlotUsed(el, "logo") ||
            helpers.isSlotUsed(el, "caption") ||
            caption ||
            copyright;
        return (index.h(index.Host, { key: 'b25023d5362ca9baca9c01a319c038eb4540e97a', 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-${helpers.IcBrandForegroundEnum.Dark}`]: foregroundColor === helpers.IcBrandForegroundEnum.Dark,
                [`ic-footer-${helpers.IcBrandForegroundEnum.Light}`]: foregroundColor === helpers.IcBrandForegroundEnum.Light,
            } }, index.h("footer", { key: '053aafbd7016c4a74230cb3f4bd15ff1bd331761', ref: (el) => (this.footerEl = el) }, (helpers.isSlotUsed(el, "description") || description) && (index.h("div", { key: 'c963c42c0f4d0a19d8fe9c133ca3cf9261398d70', class: "footer-description" }, index.h("ic-section-container", { key: '0dd1fd94781722a494368e146f2a0b8417e1849d', aligned: aligned, fullHeight: true }, index.h("div", { key: '61a25339f136d624ef39c3f72ff920735eac3656', class: "footer-description-inner" }, index.h("ic-typography", { key: '4655d70fa69d5cc7ed44e352d37646a93b95067a', variant: "body" }, index.h("slot", { key: '3a04c622d16c8fbad42bde6e5a62b94a7cc0dbfc', name: "description" }, description)))))), helpers.isSlotUsed(el, "link") && (index.h("div", { key: '9a98191b7712a906aafa5295786586cdca8fdd63', class: "footer-links" }, groupLinks && small ? (index.h("div", { class: "footer-links-inner", role: "list" }, index.h("slot", { name: "link" }))) : (index.h("ic-section-container", { fullHeight: true, aligned: aligned }, index.h("div", { class: "footer-links-inner", role: "list" }, index.h("slot", { name: "link" })))))), showComplianceSection && (index.h("div", { key: '26f71e1feac14df4ffd9a5f945823e7d8a334f87', class: "footer-compliance" }, index.h("ic-section-container", { key: 'd4b53cd4e8b1170b629f6493188f48438c1edd00', aligned: aligned, fullHeight: true }, index.h("div", { key: '50b07020da89a9ebe53d6fd035b7139ac8ca2282', class: "footer-compliance-inner" }, helpers.isSlotUsed(el, "logo") && (index.h("div", { key: '2ea27171f29498639b56426d4d21fbf4afc98798', class: "footer-logo" }, index.h("slot", { key: 'b09b28173314c1b0a63ce1ecdf60822d7497ed80', name: "logo" }))), (helpers.isSlotUsed(el, "caption") || caption) && (index.h("div", { key: 'b4ce260f52b3216ec3c73430311b7659e651a544', class: "footer-caption" }, index.h("ic-typography", { key: 'f83868bac58237dcd8586d4d161db7677f0b2b16', variant: deviceSize <= helpers.IC_DEVICE_SIZES.M ? "caption" : "body" }, index.h("slot", { key: '3da3e317b1f62be124bbabc9283e08258dc57141', name: "caption" }, caption)))), copyright && (index.h("div", { key: '63b18007efa190d038048a1d57223dc0547a64ad', class: {
                ["footer-copyright"]: true,
                ["classification-spacing"]: helpers.hasClassificationBanner(),
            } }, index.h("ic-typography", { key: '0dc6200bfb89a7b34743c442f9c61829cd4b9374', variant: deviceSize <= helpers.IC_DEVICE_SIZES.M
                ? "caption-uppercase"
                : "label-uppercase" }, "\u00A9 Crown Copyright"))))))))));
    }
    get el() { return index.getElement(this); }
};
Footer.style = IcFooterStyle0;

exports.ic_footer = Footer;

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