import { r as registerInstance, c as createEvent, h, H as Host } from './index-BIwHMk6j.js';

const orderByItemCss = () => `*{box-sizing:border-box}:host(limebb-lime-query-order-by-item){box-sizing:border-box;display:flex;flex-direction:row;align-items:flex-start;gap:0.5rem;width:100%}limebb-property-selector{flex-grow:1}.control-buttons{flex-shrink:0;display:flex;align-items:center;gap:0.25rem}`;

const OrderByItemComponent = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.itemChange = createEvent(this, "itemChange");
        this.handlePathChange = (event) => {
            event.stopPropagation();
            const newPath = event.detail;
            if (!newPath) {
                // If path is cleared, keep the current item but with empty path
                const currentDirection = this.item[Object.keys(this.item)[0]] || 'ASC';
                this.itemChange.emit({ '': currentDirection });
                return;
            }
            // Get current direction
            const currentPath = Object.keys(this.item)[0];
            const currentDirection = this.item[currentPath] || 'ASC';
            // Create new item with new path but same direction
            const newItem = { [newPath]: currentDirection };
            this.itemChange.emit(newItem);
        };
        this.handleToggleDirection = () => {
            const propertyPath = Object.keys(this.item)[0] || '';
            const currentDirection = this.item[propertyPath] || 'ASC';
            const newDirection = currentDirection === 'ASC' ? 'DESC' : 'ASC';
            const newItem = { [propertyPath]: newDirection };
            this.itemChange.emit(newItem);
        };
        this.handleRemove = () => {
            this.itemChange.emit(null);
        };
    }
    render() {
        const propertyPath = Object.keys(this.item)[0] || '';
        const direction = this.item[propertyPath] || 'ASC';
        return (h(Host, { key: 'f8b1d7505feec325eae8668672afe3768a4892aa' }, h("limebb-property-selector", { key: '03f71edd8692c6a46612f87a9df21aabd2bf71eb', platform: this.platform, context: this.context, limetype: this.limetype, label: "Property", value: propertyPath, required: true, onChange: this.handlePathChange }), h("div", { key: 'a1a6db7060f8dc862d7acfb5750861293e2411d3', class: "control-buttons" }, h("limel-icon-button", { key: '76703911899c38d71f116dc8256d00cb7c937971', icon: direction === 'ASC'
                ? 'sort_ascending'
                : 'sort_descending', label: direction === 'ASC' ? 'Ascending' : 'Descending', onClick: this.handleToggleDirection }), h("limel-icon-button", { key: '91a3370d5c6151370b96e7b67d59f226ad526f21', icon: "trash", label: "Remove", onClick: this.handleRemove }))));
    }
};
OrderByItemComponent.style = orderByItemCss();

export { OrderByItemComponent as limebb_lime_query_order_by_item };
