/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { attachShadowTemplate, CustomElement, FoundationProperty, coerceBoolean } from '@tylertech/forge-core';
import { BaseComponent } from '../core/base/base-component';
import { WithDefaultAria } from '../core/mixins/internals/with-default-aria';
import { WithElementInternals } from '../core/mixins/internals/with-element-internals';
import { DialogComponent } from '../dialog/dialog';
import { BottomSheetAdapter } from './bottom-sheet-adapter';
import { BOTTOM_SHEET_CONSTANTS } from './bottom-sheet-constants';
import { BottomSheetFoundation } from './bottom-sheet-foundation';
const template = '<template><forge-dialog class=\"dialog\" mode=\"nonmodal\" preset=\"bottom-sheet\" exportparts=\"surface\" role=\"presentation\"><div class=\"surface\" part=\"root\"><slot></slot></div></forge-dialog></template>';
const styles = '@-webkit-keyframes zoom-in{from{opacity:var(--_dialog-zoom-opacity);scale:var(--_dialog-zoom-scale)}to{opacity:1;scale:1}}@keyframes zoom-in{from{opacity:var(--_dialog-zoom-opacity);scale:var(--_dialog-zoom-scale)}to{opacity:1;scale:1}}@-webkit-keyframes zoom-out{from{opacity:1;scale:1}to{opacity:var(--_dialog-zoom-opacity);scale:var(--_dialog-zoom-scale)}}@keyframes zoom-out{from{opacity:1;scale:1}to{opacity:var(--_dialog-zoom-opacity);scale:var(--_dialog-zoom-scale)}}@-webkit-keyframes fade-in{from{opacity:var(--_dialog-fade-opacity)}to{opacity:1}}@keyframes fade-in{from{opacity:var(--_dialog-fade-opacity)}to{opacity:1}}@-webkit-keyframes fade-out{from{opacity:1}to{opacity:var(--_dialog-fade-opacity)}}@keyframes fade-out{from{opacity:1}to{opacity:var(--_dialog-fade-opacity)}}@-webkit-keyframes slide-in{from{opacity:var(--_dialog-slide-opacity);translate:var(--_dialog-slide-translate)}to{opacity:1;translate:0 0}}@keyframes slide-in{from{opacity:var(--_dialog-slide-opacity);translate:var(--_dialog-slide-translate)}to{opacity:1;translate:0 0}}@-webkit-keyframes slide-out{from{opacity:1;translate:0 0}to{opacity:var(--_dialog-slide-opacity);translate:var(--_dialog-slide-translate)}}@keyframes slide-out{from{opacity:1;translate:0 0}to{opacity:var(--_dialog-slide-opacity);translate:var(--_dialog-slide-translate)}}:host{display:contents}:host([hidden]){display:none}.dialog{--_bottom-sheet-desktop-max-width:var(--forge-bottom-sheet-desktop-max-width, 50%);--_bottom-sheet-desktop-max-height:var(--forge-bottom-sheet-desktop-max-height, 50%);--_bottom-sheet-animation-duration:var(--forge-bottom-sheet-animation-duration, var(--forge-animation-duration-medium1, 250ms));--_bottom-sheet-animation-timing:var(--forge-bottom-sheet-animation-timing, var(--forge-animation-easing-standard, cubic-bezier(0.2, 0, 0, 1)))}.surface{width:100%;display:-webkit-inline-box;display:inline-flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column}.dialog.dragging::part(surface){-webkit-transition:none;transition:none}:host([open]) forge-dialog.fullscreen{--forge-dialog-max-height:100%}:host([open]) forge-dialog.fullscreen::part(surface){-webkit-transition:max-height var(--_bottom-sheet-animation-duration) var(--_bottom-sheet-animation-timing);transition:max-height var(--_bottom-sheet-animation-duration) var(--_bottom-sheet-animation-timing)}forge-dialog{--forge-dialog-width:var(--_bottom-sheet-desktop-max-width);--forge-dialog-max-height:var(--_bottom-sheet-desktop-max-height)}@media (max-width:600px){forge-dialog{--forge-dialog-shape:0;--forge-dialog-max-width:100vw;--forge-dialog-width:100vw}}';
const BaseClass = WithElementInternals(WithDefaultAria(BaseComponent));
/**
 * @tag forge-bottom-sheet
 *
 * @summary Bottom sheets slide up from the bottom of the screen to reveal more content and/or actions that the user can take.
 *
 * @property {boolean} open - Whether the bottom sheet is open.
 * @property {BottomSheetMode} mode - The mode of the bottom sheet. Defaults to non-modal.
 * @property {boolean} persistent - Whether the bottom sheet is persistent.
 * @property {boolean} fullscreen - Whether the bottom sheet is fullscreen.
 *
 * @attribute {boolean} open - Whether the bottom sheet is open.
 * @attribute {BottomSheetMode} mode - The mode of the bottom sheet. Defaults to non-modal.
 * @attribute {boolean} persistent - Whether the bottom sheet is persistent.
 * @attribute {boolean} fullscreen - Whether the bottom sheet is fullscreen.
 *
 * @event {CustomEvent<void>} forge-bottom-sheet-before-close - Fires before the bottom sheet closes.
 * @event {CustomEvent<void>} forge-bottom-sheet-close - Fires after the bottom sheet closes.
 * @event {CustomEvent<void>} forge-bottom-sheet-open - Fires after the bottom sheet opens.
 * @event {CustomEvent<IBottomSheetDragStartEventData>} forge-bottom-sheet-drag-start - Fires when the bottom sheet starts to be dragged.
 * @event {CustomEvent<IBottomSheetDragEventData>} forge-bottom-sheet-dragged - Fires when the bottom sheet is dragged.
 * @event {CustomEvent<void>} forge-bottom-sheet-drag-end - Fires when the bottom sheet drag ends.
 * @event {CustomEvent<void>} forge-bottom-sheet-drag-cancel - Fires when the bottom sheet drag is cancelled.
 * @event {CustomEvent<boolean>} forge-bottom-sheet-fullscreen - Fires when the bottom sheet is toggled to fullscreen.
 *
 * @cssproperty --forge-bottom-sheet-desktop-max-width - The maximum width of the bottom sheet on desktop.
 * @cssproperty --forge-bottom-sheet-desktop-min-width - The minimum width of the bottom sheet on desktop.
 * @cssproperty --forge-bottom-sheet-animation-duration - The duration of the bottom sheet animation to fullscreen.
 * @cssproperty --forge-bottom-sheet-animation-timing - The timing function of the bottom sheet animation to fullscreen.
 *
 * @csspart root - The root element of the bottom sheet.
 * @csspart surface - The surface element of the bottom sheet within th dialog.
 *
 * @slot - The content of the bottom sheet. This is a passthrough slot to the dialog surface.
 */
let BottomSheetComponent = class BottomSheetComponent extends BaseClass {
    static get observedAttributes() {
        return Object.values(BOTTOM_SHEET_CONSTANTS.observedAttributes);
    }
    constructor() {
        super();
        attachShadowTemplate(this, template, styles);
        this._foundation = new BottomSheetFoundation(new BottomSheetAdapter(this));
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    attributeChangedCallback(name, _oldValue, newValue) {
        switch (name) {
            case BOTTOM_SHEET_CONSTANTS.attributes.OPEN:
                this.open = coerceBoolean(newValue);
                break;
            case BOTTOM_SHEET_CONSTANTS.attributes.MODE:
                this.mode = newValue;
                break;
            case BOTTOM_SHEET_CONSTANTS.observedAttributes.PERSISTENT:
                this.persistent = coerceBoolean(newValue);
                break;
            case BOTTOM_SHEET_CONSTANTS.attributes.FULLSCREEN:
                this.fullscreen = coerceBoolean(newValue);
                break;
        }
    }
};
__decorate([
    FoundationProperty()
], BottomSheetComponent.prototype, "open", void 0);
__decorate([
    FoundationProperty()
], BottomSheetComponent.prototype, "mode", void 0);
__decorate([
    FoundationProperty()
], BottomSheetComponent.prototype, "persistent", void 0);
__decorate([
    FoundationProperty()
], BottomSheetComponent.prototype, "fullscreen", void 0);
BottomSheetComponent = __decorate([
    CustomElement({
        name: BOTTOM_SHEET_CONSTANTS.elementName,
        dependencies: [
            DialogComponent
        ]
    })
], BottomSheetComponent);
export { BottomSheetComponent };
