"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    AtomicSmartSnippetCollapseWrapper: ()=>AtomicSmartSnippetCollapseWrapper
});
const external_lit_namespaceObject = require("lit");
const decorators_js_namespaceObject = require("lit/decorators.js");
const when_js_namespaceObject = require("lit/directives/when.js");
const binding_guard_cjs_namespaceObject = require("../../../decorators/binding-guard.cjs");
const bindings_cjs_namespaceObject = require("../../../decorators/bindings.cjs");
const error_guard_cjs_namespaceObject = require("../../../decorators/error-guard.cjs");
const with_tailwind_styles_cjs_namespaceObject = require("../../../decorators/with-tailwind-styles.cjs");
const multi_class_map_cjs_namespaceObject = require("../../../directives/multi-class-map.cjs");
const bindings_mixin_cjs_namespaceObject = require("../../../mixins/bindings-mixin.cjs");
const arrow_down_cjs_namespaceObject = require("../../../images/arrow-down.cjs");
var arrow_down_cjs_default = /*#__PURE__*/ __webpack_require__.n(arrow_down_cjs_namespaceObject);
require("../atomic-icon/atomic-icon.cjs");
function _ts_decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
    else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function _ts_metadata(k, v) {
    if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
}
class AtomicSmartSnippetCollapseWrapper extends (0, bindings_mixin_cjs_namespaceObject.InitializeBindingsMixin)(external_lit_namespaceObject.LitElement) {
    connectedCallback() {
        super.connectedCallback();
        this.shouldRenderButton = !!this.maximumHeight;
        if (this.shouldRenderButton) this.classList.add('invisible');
    }
    initialize() {
        this.validateProps();
    }
    validateProps() {
        if (this.maximumHeight && (!this.collapsedHeight || this.maximumHeight < this.collapsedHeight)) throw new Error('snippetMaximumHeight must be equal or greater than snippetCollapsedHeight');
    }
    initializeFullHeight() {
        this.fullHeight = this.getBoundingClientRect().height;
        this.showButton = this.fullHeight > this.maximumHeight;
        this.isExpanded = !this.showButton;
        this.style.setProperty('--collapsed-size', `${this.collapsedHeight}px`);
    }
    toggleExpanded() {
        this.isExpanded = !this.isExpanded;
    }
    renderButton() {
        if (!this.showButton) return external_lit_namespaceObject.nothing;
        return (0, external_lit_namespaceObject.html)`
      <button
        @click=${this.toggleExpanded}
        class=${(0, multi_class_map_cjs_namespaceObject.multiClassMap)((0, multi_class_map_cjs_namespaceObject.tw)({
            'text-primary mb-4 hover:underline': true
        }))}
        part=${this.isExpanded ? 'show-less-button' : 'show-more-button'}
      >
        ${this.bindings.i18n.t(this.isExpanded ? 'show-less' : 'show-more')}
        <atomic-icon
          .icon=${arrow_down_cjs_default()}
          class=${(0, multi_class_map_cjs_namespaceObject.multiClassMap)((0, multi_class_map_cjs_namespaceObject.tw)({
            'ml-2 w-3 align-baseline': true
        }))}
        ></atomic-icon>
      </button>
    `;
    }
    updated(changedProperties) {
        super.updated(changedProperties);
        if (void 0 === this.fullHeight && this.shouldRenderButton) this.initializeFullHeight();
        const isExpanded = this.isExpanded && (!!this.fullHeight || !this.shouldRenderButton);
        const isInvisible = !this.fullHeight && this.shouldRenderButton;
        this.classList.toggle('expanded', isExpanded);
        this.classList.toggle('invisible', isInvisible);
    }
    render() {
        return (0, external_lit_namespaceObject.html)`
      <div
        part="smart-snippet-collapse-wrapper"
        class="block overflow-hidden text-lg text-on-background smart-snippet-content"
      >
        <slot></slot>
      </div>
      ${(0, when_js_namespaceObject.when)(this.shouldRenderButton, ()=>this.renderButton())}
    `;
    }
    constructor(...args){
        super(...args), this.isExpanded = true, this.showButton = true, this.shouldRenderButton = false;
    }
}
AtomicSmartSnippetCollapseWrapper.styles = (0, external_lit_namespaceObject.css)`
    :host {
      display: block;
    }

    :host(.invisible) {
      visibility: hidden;
    }

    .smart-snippet-content {
      height: auto;
      max-height: var(--collapsed-size);
      transition: max-height 2s cubic-bezier(0, 1, 0.16, 1) -1.82s;

      --gradient-start: var(
        --atomic-smart-snippet-gradient-start,
        calc(
          max(
            var(--collapsed-size) - (var(--line-height) * 1.5),
            var(--collapsed-size) * 0.5
          )
        )
      );

      mask-image: linear-gradient(
        black,
        black var(--gradient-start),
        transparent 100%
      );
    }

    :host(.expanded) .smart-snippet-content {
      height: auto;
      max-height: 9999999px;
      transition: max-height 2s cubic-bezier(1, 0, 1, 0) 0s;
      mask-image: none;
    }

    :host(.expanded) button atomic-icon {
      transform: scaleY(-1);
    }
  `;
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Bindings ? Object : Bindings)
], AtomicSmartSnippetCollapseWrapper.prototype, "bindings", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicSmartSnippetCollapseWrapper.prototype, "error", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Number,
        reflect: true,
        attribute: 'maximum-height'
    }),
    _ts_metadata("design:type", Number)
], AtomicSmartSnippetCollapseWrapper.prototype, "maximumHeight", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Number,
        reflect: true,
        attribute: 'collapsed-height'
    }),
    _ts_metadata("design:type", Number)
], AtomicSmartSnippetCollapseWrapper.prototype, "collapsedHeight", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)()
], AtomicSmartSnippetCollapseWrapper.prototype, "isExpanded", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)()
], AtomicSmartSnippetCollapseWrapper.prototype, "showButton", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", Number)
], AtomicSmartSnippetCollapseWrapper.prototype, "fullHeight", void 0);
_ts_decorate([
    (0, error_guard_cjs_namespaceObject.errorGuard)(),
    (0, binding_guard_cjs_namespaceObject.bindingGuard)(),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicSmartSnippetCollapseWrapper.prototype, "render", null);
AtomicSmartSnippetCollapseWrapper = _ts_decorate([
    (0, decorators_js_namespaceObject.customElement)('atomic-smart-snippet-collapse-wrapper'),
    (0, bindings_cjs_namespaceObject.bindings)(),
    with_tailwind_styles_cjs_namespaceObject.withTailwindStyles
], AtomicSmartSnippetCollapseWrapper);
exports.AtomicSmartSnippetCollapseWrapper = __webpack_exports__.AtomicSmartSnippetCollapseWrapper;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AtomicSmartSnippetCollapseWrapper"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
