'use strict';

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

const lit = require('lit');
const decorators_js = require('lit/decorators.js');
const tailwindVariants = require('tailwind-variants');
const core = require('@lukso/core');
const index = require('../../chunks/index-BBPgtFEP.js');
require('../../chunks/index-Bm2Lo_3c.js');

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result) __defProp(target, key, result);
  return result;
};
exports.LuksoModal = class LuksoModal extends core.withTheme(index.TailwindElement) {
  constructor() {
    super(...arguments);
    this.isOpen = false;
    this.disableAnimations = false;
    this.size = "small";
    this.hasBottomPadding = false;
    this.styles = tailwindVariants.tv({
      slots: {
        wrapper: "opacity-0 fixed z-[1011] transition-opacity inset-0 w-screen h-screen overflow-y-auto overscroll-none scrolling-touch touch-pan-y",
        inner: "min-h-screen flex items-center justify-center px-6 pt-6 w-full",
        overlay: "bg-[rgba(196,202,206,0.6)] backdrop-blur-sm fixed inset-0 w-[100vw] h-[100vh] z-[1010] dark:bg-[rgba(196,202,206,0.1)]",
        dialog: "bg-neutral-98 rounded-12 shadow-neutral-shadow-round-3xl z-[1012] mx-auto dark:bg-neutral-10"
      },
      variants: {
        isOpen: {
          true: {
            wrapper: "opacity-100 visible w-[100vw] h-[100vh]"
          },
          false: {
            wrapper: "hidden"
          }
        },
        size: {
          small: {
            dialog: "w-[352px]"
          },
          medium: {
            dialog: "w-[849px]"
          },
          full: {
            dialog: "w-full"
          },
          auto: {}
        },
        disableAnimations: {
          false: {
            wrapper: "animation-duration-300 delay-300",
            overlay: "animation-duration-300"
          }
        },
        hasBottomPadding: {
          true: {
            inner: "pb-[120px]"
          },
          false: {
            inner: "pb-6"
          }
        }
      },
      compoundVariants: [
        {
          disableAnimations: false,
          isOpen: true,
          class: {
            wrapper: "animate-fade-in",
            overlay: "animate-fade-in"
          }
        }
      ]
    });
  }
  close() {
    this.isOpen = false;
  }
  async handleBackdropClick() {
    await this.updateComplete;
    const clickEvent = new CustomEvent("on-backdrop-click", {
      bubbles: true,
      composed: true
    });
    this.dispatchEvent(clickEvent);
  }
  render() {
    const { wrapper, overlay, dialog, inner } = this.styles({
      isOpen: this.isOpen,
      size: this.size,
      disableAnimations: this.disableAnimations,
      hasBottomPadding: this.hasBottomPadding
    });
    return lit.html`
      <div data-testid="modal" class=${wrapper()}>
        <div class=${inner()}>
          <div class=${overlay()} @click=${this.handleBackdropClick}></div>
          <div class=${dialog()}>
            <slot></slot>
          </div>
        </div>
      </div>
    `;
  }
};
__decorateClass([
  decorators_js.property({ type: Boolean, attribute: "is-open" })
], exports.LuksoModal.prototype, "isOpen", 2);
__decorateClass([
  decorators_js.property({ type: Boolean, attribute: "disable-animations" })
], exports.LuksoModal.prototype, "disableAnimations", 2);
__decorateClass([
  decorators_js.property({ type: String })
], exports.LuksoModal.prototype, "size", 2);
__decorateClass([
  decorators_js.property({ type: Boolean, attribute: "has-bottom-padding" })
], exports.LuksoModal.prototype, "hasBottomPadding", 2);
exports.LuksoModal = __decorateClass([
  index.safeCustomElement("lukso-modal")
], exports.LuksoModal);
