"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__, {
    AtomicInsightUserActionsSession: ()=>AtomicInsightUserActionsSession
});
const external_dayjs_namespaceObject = require("dayjs");
var external_dayjs_default = /*#__PURE__*/ __webpack_require__.n(external_dayjs_namespaceObject);
const external_lit_namespaceObject = require("lit");
const decorators_js_namespaceObject = require("lit/decorators.js");
const when_js_namespaceObject = require("lit/directives/when.js");
const button_cjs_namespaceObject = require("../../common/button.cjs");
const binding_guard_cjs_namespaceObject = require("../../../decorators/binding-guard.cjs");
const bindings_cjs_namespaceObject = require("../../../decorators/bindings.cjs");
const with_tailwind_styles_cjs_namespaceObject = require("../../../decorators/with-tailwind-styles.cjs");
const flag_cjs_namespaceObject = require("../../../images/flag.cjs");
var flag_cjs_default = /*#__PURE__*/ __webpack_require__.n(flag_cjs_namespaceObject);
const three_dots_cjs_namespaceObject = require("../../../images/three-dots.cjs");
var three_dots_cjs_default = /*#__PURE__*/ __webpack_require__.n(three_dots_cjs_namespaceObject);
const external_user_action_cjs_namespaceObject = require("./user-action.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 AtomicInsightUserActionsSession extends external_lit_namespaceObject.LitElement {
    get caseCreationIndex() {
        return this.userActions.findIndex(({ actionType })=>'TICKET_CREATION' === actionType);
    }
    get isCaseCreationSession() {
        return -1 !== this.caseCreationIndex;
    }
    initialize() {}
    connectedCallback() {
        super.connectedCallback();
        this.prepareUserActionsToDisplay();
    }
    willUpdate(changedProperties) {
        if (changedProperties.has('userActions')) this.prepareUserActionsToDisplay();
    }
    prepareUserActionsToDisplay() {
        if (this.isCaseCreationSession) {
            this.userActionsToDisplay = this.userActions.slice(this.caseCreationIndex);
            this.userActionsAfterCaseCreation = this.userActions.slice(0, this.caseCreationIndex);
        } else {
            this.userActionsToDisplay = this.userActions;
            this.userActionsAfterCaseCreation = [];
        }
    }
    showActionsAfterCaseCreation() {
        this.areActionsAfterCaseCreationVisible = true;
    }
    renderSessionStartDate() {
        const date = external_dayjs_default()(this.startTimestamp);
        const formatedStartDate = date.format('ddd. MMMM D, YYYY');
        return (0, external_lit_namespaceObject.html)`
      <div
        data-testid="session-start-date-container"
        class="flex items-center px-2 pb-3"
      >
        ${(0, when_js_namespaceObject.when)(this.isCaseCreationSession, ()=>(0, external_lit_namespaceObject.html)`
            <div
              part="session-start-icon__container"
              class="session-start-icon__container mr-2 flex h-5 w-5 items-center justify-center rounded-full"
            >
              <atomic-icon icon=${flag_cjs_default()} class="h-3 w-3"></atomic-icon>
            </div>
          `)}
        <div class="flex-1 font-semibold">${formatedStartDate}</div>
      </div>
    `;
    }
    renderActions(actions) {
        return (0, external_lit_namespaceObject.html)`
      <ol class="px-3">
        ${actions?.map((action)=>(0, external_user_action_cjs_namespaceObject.renderUserAction)({
                props: {
                    action,
                    bindings: this.bindings
                }
            }))}
      </ol>
    `;
    }
    renderShowMoreActionsButton() {
        const btnClasses = 'flex items-center p-1 max-w-full';
        const label = this.bindings.i18n.t('more-actions-in-session', {
            count: this.userActionsAfterCaseCreation.length
        });
        return (0, external_lit_namespaceObject.html)`
      <div
        data-testid="show-more-actions-button"
        class="flex items-center px-3 pb-3"
      >
        <div class="flex justify-center pr-2">
          <atomic-icon icon=${three_dots_cjs_default()} class="h-3 w-3"></atomic-icon>
        </div>
        <div class="flex-1">
          ${(0, button_cjs_namespaceObject.renderButton)({
            props: {
                style: 'text-primary',
                part: 'show-more-actions-button',
                class: btnClasses,
                ariaLabel: label,
                onClick: this.showActionsAfterCaseCreation.bind(this)
            }
        })((0, external_lit_namespaceObject.html)`<span class="truncate text-xs font-light">${label}</span>`)}
        </div>
      </div>
    `;
    }
    render() {
        const isShowMoreActionsButtonVisible = !this.areActionsAfterCaseCreationVisible && !!this.userActionsAfterCaseCreation.length;
        return (0, external_lit_namespaceObject.html)`
      <div>
        ${this.renderSessionStartDate()}
        ${(0, when_js_namespaceObject.when)(this.areActionsAfterCaseCreationVisible, ()=>(0, external_lit_namespaceObject.html)`
            <div data-testid="more-actions-section">
              ${this.renderActions(this.userActionsAfterCaseCreation)}
            </div>
          `)}
        ${(0, when_js_namespaceObject.when)(isShowMoreActionsButtonVisible, ()=>this.renderShowMoreActionsButton())}
        ${this.renderActions(this.userActionsToDisplay)}
      </div>
    `;
    }
    constructor(...args){
        super(...args), this.userActions = [], this.userActionsToDisplay = [], this.userActionsAfterCaseCreation = [], this.areActionsAfterCaseCreationVisible = false;
    }
}
AtomicInsightUserActionsSession.styles = (0, external_lit_namespaceObject.css)`
    @reference '../../../utils/tailwind.global.tw.css';

    .session-start-icon__container {
      background-color: #fbb439;
    }

    .user-action__separator {
      @apply bg-neutral;
    }

    .ticket-creation-action__text {
      @apply text-success;
    }

    .text-xxs {
      font-size: 0.625rem;
    }
  `;
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof InsightBindings ? Object : InsightBindings)
], AtomicInsightUserActionsSession.prototype, "bindings", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicInsightUserActionsSession.prototype, "error", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Number,
        attribute: 'start-timestamp'
    }),
    _ts_metadata("design:type", Number)
], AtomicInsightUserActionsSession.prototype, "startTimestamp", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Array,
        attribute: 'user-actions'
    }),
    _ts_metadata("design:type", "u" < typeof Array ? Object : Array)
], AtomicInsightUserActionsSession.prototype, "userActions", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Array ? Object : Array)
], AtomicInsightUserActionsSession.prototype, "userActionsToDisplay", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Array ? Object : Array)
], AtomicInsightUserActionsSession.prototype, "userActionsAfterCaseCreation", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)()
], AtomicInsightUserActionsSession.prototype, "areActionsAfterCaseCreationVisible", void 0);
_ts_decorate([
    (0, binding_guard_cjs_namespaceObject.bindingGuard)(),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicInsightUserActionsSession.prototype, "render", null);
AtomicInsightUserActionsSession = _ts_decorate([
    (0, decorators_js_namespaceObject.customElement)('atomic-insight-user-actions-session'),
    (0, bindings_cjs_namespaceObject.bindings)(),
    with_tailwind_styles_cjs_namespaceObject.withTailwindStyles
], AtomicInsightUserActionsSession);
exports.AtomicInsightUserActionsSession = __webpack_exports__.AtomicInsightUserActionsSession;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AtomicInsightUserActionsSession"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
