import { createOptionBuilder, pushMaybeRefArrayValue, spliceMaybeRefArray, setMaybeRefValue, isPromise, findIndexOfMaybeRefArray, extendMaybeRefArrayValue, extendMaybeRefObject, hasOwnProperty, hasNormalizedSlot, normalizeSlot, merge, applyPluginBaseOptions } from '@vue-layout/core';
import { unref, h, isRef, mergeProps } from 'vue';

/*
 * Copyright (c) 2022.
 * Author Peter Placzek (tada5hi)
 * For the full copyright and license information,
 * view the LICENSE file that was distributed with this source code.
 */ var Component;
(function(Component) {
    Component["List"] = 'list';
    Component["ListFooter"] = 'listFooter';
    Component["ListHeader"] = 'listHeader';
    Component["ListItem"] = 'listItem';
    Component["ListBody"] = 'listBody';
    Component["ListLoading"] = 'listLoading';
    Component["ListNoMore"] = 'listNoMore';
    Component["ListTitle"] = 'listTitle';
    Component["ItemActionToggle"] = 'itemActionToggle';
})(Component || (Component = {}));
var SlotName;
(function(SlotName) {
    SlotName["DEFAULT"] = 'default';
    SlotName["FOOTER"] = 'footer';
    SlotName["HEADER"] = 'header';
    SlotName["HEADER_TITLE"] = 'headerTitle';
    SlotName["BODY"] = 'body';
    SlotName["LOADING"] = 'loading';
    SlotName["NO_MORE"] = 'noMore';
    SlotName["ITEM"] = 'item';
    SlotName["ITEM_ACTIONS"] = 'itemActions';
    SlotName["ITEM_ACTIONS_EXTRA"] = 'itemActionsExtra';
})(SlotName || (SlotName = {}));

function buildItemActionToggleOptions(options) {
    const { buildOrFail } = createOptionBuilder(Component.ItemActionToggle);
    return {
        ...options,
        type: buildOrFail({
            key: 'type',
            value: options.type,
            alt: 'button'
        }),
        class: buildOrFail({
            key: 'class',
            value: options.class,
            alt: []
        }),
        disabledClass: buildOrFail({
            key: 'disabledClass',
            value: options.disabledClass,
            alt: []
        }),
        enabledClass: buildOrFail({
            key: 'enabledClass',
            value: options.enabledClass,
            alt: []
        }),
        childType: buildOrFail({
            key: 'childType',
            value: options.childType,
            alt: 'i'
        }),
        childDisabledContent: buildOrFail({
            key: 'childDisabledContent',
            value: options.childDisabledContent,
            alt: []
        }),
        childDisabledClass: buildOrFail({
            key: 'childDisabledClass',
            value: options.childDisabledClass,
            alt: []
        }),
        childEnabledContent: buildOrFail({
            key: 'childEnabledContent',
            value: options.childEnabledContent,
            alt: []
        }),
        childEnabledClass: buildOrFail({
            key: 'childEnabledClass',
            value: options.childEnabledClass,
            alt: []
        }),
        busy: options.busy ?? false
    };
}
function buildItemActionToggle(input) {
    const options = buildItemActionToggleOptions(input);
    const { busy } = options;
    const currentValue = unref(options.currentValue);
    const value = unref(options.value);
    let children = [];
    const childClass = currentValue === value ? options.childEnabledClass : options.childDisabledClass;
    const childContent = currentValue === value ? options.childEnabledContent : options.childDisabledContent;
    if (childClass || childContent) {
        children = [
            h(options.childType, {
                class: childClass
            }, [
                childContent
            ])
        ];
    }
    return h(options.type, {
        ...options.type === 'button' ? {
            type: 'button'
        } : {},
        disabled: busy,
        class: [
            ...options.class ? [
                options.class
            ] : [],
            ...options.disabledClass && currentValue !== value ? [
                options.disabledClass
            ] : [],
            ...options.enabledClass && currentValue === value ? [
                options.enabledClass
            ] : []
        ],
        onClick ($event) {
            $event.preventDefault();
            if (Array.isArray(currentValue)) {
                const index = currentValue.indexOf(value);
                if (index === -1) {
                    pushMaybeRefArrayValue(options.currentValue, value);
                } else {
                    spliceMaybeRefArray(options.currentValue, index, 1);
                }
                if (options.currentValue && options.onChange) {
                    options.onChange(options.currentValue);
                }
                return;
            }
            const setValue = (v)=>{
                options.currentValue = setMaybeRefValue(options.currentValue, v);
                if (options.onChange) {
                    options.onChange(v);
                }
            };
            if (value === currentValue) {
                setValue(null);
                return;
            }
            setValue(value);
        }
    }, [
        children
    ]);
}

function buildListBaseOptions(options, component, defaults) {
    defaults = defaults || {};
    const { buildOrFail } = createOptionBuilder(component);
    return {
        slotItems: options.slotItems || {},
        slotProps: buildOrFail({
            key: 'slotProps',
            value: options.slotProps,
            alt: defaults.slotProps || {}
        }),
        slotPropsBuilt: options.slotPropsBuilt,
        tag: buildOrFail({
            key: 'tag',
            value: options.tag,
            alt: defaults.tag || 'div'
        }),
        class: buildOrFail({
            key: 'class',
            value: options.class,
            alt: defaults.class || []
        }),
        props: buildOrFail({
            key: 'props',
            value: options.props,
            alt: defaults.props || {}
        }),
        load: options.load,
        meta: options.meta || {},
        busy: options.busy,
        itemId: options.itemId,
        itemKey: options.itemKey,
        onCreated: options.onCreated,
        onUpdated: options.onUpdated,
        onDeleted: options.onDeleted
    };
}
const buildFilterFn = (item, itemId, itemKey)=>{
    let filterFn;
    if (itemId) {
        filterFn = (el)=>itemId(el) === itemId(item);
    }
    if (itemKey) {
        filterFn = (el)=>{
            if (typeof itemKey === 'function') {
                return el[itemKey(el)] === item[itemKey(item)];
            }
            return el[itemKey] === item[itemKey];
        };
    }
    if (!filterFn && hasOwnProperty(item, 'id')) {
        filterFn = (el)=>el['id'] === item['id'];
    }
    return filterFn;
};
function buildListBaseSlotProps(ctx) {
    const props = {};
    if (typeof ctx.busy !== 'undefined') {
        props.busy = unref(ctx.busy);
    }
    if (typeof ctx.meta !== 'undefined') {
        props.meta = ctx.meta;
    }
    if (typeof ctx.load === 'function') {
        props.load = (meta)=>{
            if (!isRef(ctx.busy)) {
                return ctx.load(meta);
            }
            ctx.busy.value = true;
            const output = ctx.load(meta);
            if (isPromise(output)) {
                return output.finally(()=>{
                    if (isRef(ctx.busy)) {
                        ctx.busy.value = false;
                    }
                });
            }
            ctx.busy.value = false;
            return output;
        };
    }
    props.created = (item)=>{
        if (ctx.meta && typeof ctx.meta.total === 'number') {
            ctx.meta.total++;
        }
        if (typeof ctx.data === 'undefined') {
            if (ctx.onCreated) {
                ctx.onCreated(item);
            }
        }
        const data = unref(ctx.data);
        if (Array.isArray(data)) {
            const filterFn = buildFilterFn(item, ctx.itemId, ctx.itemKey);
            if (filterFn) {
                const index = findIndexOfMaybeRefArray(ctx.data, filterFn);
                if (index === -1) {
                    pushMaybeRefArrayValue(ctx.data, item);
                }
            }
        }
        if (typeof ctx.onCreated === 'function') {
            ctx.onCreated(item);
        }
    };
    props.deleted = (item)=>{
        if (ctx.meta && typeof ctx.meta.total === 'number') {
            ctx.meta.total--;
        }
        if (typeof ctx.data === 'undefined') {
            if (ctx.onDeleted && typeof item !== 'undefined') {
                ctx.onDeleted(item);
            }
            return;
        }
        const data = unref(ctx.data);
        if (Array.isArray(data) && item) {
            const filterFn = buildFilterFn(item, ctx.itemId, ctx.itemKey);
            if (filterFn) {
                const index = findIndexOfMaybeRefArray(ctx.data, filterFn);
                if (index !== -1) {
                    spliceMaybeRefArray(ctx.data, index, 1);
                }
            }
        }
        if (typeof ctx.onDeleted === 'function') {
            if (typeof item !== 'undefined') {
                ctx.onDeleted(item);
                return;
            }
            if (isRef(ctx.data)) {
                if (!Array.isArray(ctx.data.value)) {
                    ctx.onDeleted(ctx.data.value);
                }
            } else if (!Array.isArray(ctx.data)) {
                ctx.onDeleted(ctx.data);
            }
        }
    };
    props.updated = (item)=>{
        if (typeof ctx.data === 'undefined') {
            if (ctx.onUpdated) {
                ctx.onUpdated(item);
            }
            return;
        }
        const data = unref(ctx.data);
        if (Array.isArray(data)) {
            const filterFn = buildFilterFn(item, ctx.itemId, ctx.itemKey);
            if (filterFn) {
                const index = findIndexOfMaybeRefArray(ctx.data, filterFn);
                if (index !== -1) {
                    extendMaybeRefArrayValue(ctx.data, index, item);
                }
            }
            if (typeof ctx.onUpdated === 'function') {
                ctx.onUpdated(item);
            }
        } else {
            extendMaybeRefObject(ctx.data, item);
            if (typeof ctx.onUpdated === 'function') {
                ctx.onUpdated(data);
            }
        }
    };
    return props;
}

function buildListFooterOptions(input) {
    const options = buildListBaseOptions(input, Component.ListFooter, {
        class: 'list-footer'
    });
    const { buildOrFail } = createOptionBuilder(Component.ListHeader);
    return {
        ...options,
        content: buildOrFail({
            key: 'content',
            value: input.content,
            alt: []
        })
    };
}
function buildListFooter(input) {
    input = input || {};
    const options = buildListFooterOptions(input);
    let slotProps;
    if (options.slotPropsBuilt) {
        slotProps = options.slotProps;
    } else {
        slotProps = {
            ...buildListBaseSlotProps(options),
            ...options.slotProps
        };
    }
    let children;
    if (hasNormalizedSlot(SlotName.FOOTER, options.slotItems)) {
        children = [
            normalizeSlot(SlotName.FOOTER, slotProps, options.slotItems)
        ];
    } else if (options.content) {
        if (typeof options.content === 'function') {
            children = [
                options.content(slotProps)
            ];
        } else {
            children = [
                options.content
            ];
        }
    }
    if (children) {
        return h(options.tag, mergeProps({
            class: options.class
        }, options.props), [
            children
        ]);
    }
    return [];
}

function buildListHeaderOptions(input) {
    const options = buildListBaseOptions(input, Component.ListHeader, {
        class: 'list-header'
    });
    const { buildOrFail } = createOptionBuilder(Component.ListHeader);
    return {
        ...options,
        content: buildOrFail({
            key: 'content',
            value: input.content,
            alt: []
        })
    };
}
function buildListHeader(input) {
    input = input || {};
    const options = buildListHeaderOptions(input);
    let slotProps;
    if (options.slotPropsBuilt) {
        slotProps = options.slotProps;
    } else {
        slotProps = {
            ...buildListBaseSlotProps(options),
            ...options.slotProps
        };
    }
    let content;
    if (hasNormalizedSlot(SlotName.HEADER, options.slotItems)) {
        content = normalizeSlot(SlotName.HEADER, slotProps, options.slotItems);
    } else if (options.content) {
        if (typeof options.content === 'function') {
            content = [
                options.content(slotProps)
            ];
        } else {
            content = [
                options.content
            ];
        }
    }
    if (content) {
        return h(options.tag, mergeProps({
            class: options.class
        }, options.props), [
            content
        ]);
    }
    return [];
}

function buildListItemOptions(input) {
    const options = buildListBaseOptions(input, Component.ListItem, {
        class: 'list-item',
        tag: 'li'
    });
    const { buildOrFail } = createOptionBuilder(Component.ListItem);
    return {
        ...options,
        data: input.data,
        content: input.content,
        index: input.index,
        icon: buildOrFail({
            key: 'icon',
            value: input.icon,
            alt: true
        }),
        iconTag: buildOrFail({
            key: 'iconTag',
            value: input.iconTag,
            alt: 'i'
        }),
        iconClass: buildOrFail({
            key: 'iconClass',
            value: input.iconClass,
            alt: []
        }),
        iconProps: input.iconProps || {},
        iconWrapper: buildOrFail({
            key: 'iconWrapper',
            value: input.iconWrapper,
            alt: true
        }),
        iconWrapperClass: buildOrFail({
            key: 'iconWrapperClass',
            value: input.iconWrapperClass,
            alt: []
        }),
        iconWrapperTag: buildOrFail({
            key: 'iconWrapperTag',
            value: input.iconWrapperTag,
            alt: 'div'
        }),
        text: buildOrFail({
            key: 'text',
            value: input.text,
            alt: true
        }),
        textContent: input.textContent,
        textPropName: buildOrFail({
            key: 'textPropName',
            value: input.textPropName,
            alt: 'name'
        }),
        textWrapper: buildOrFail({
            key: 'textWrapper',
            value: input.textWrapper,
            alt: true
        }),
        textWrapperClass: buildOrFail({
            key: 'textWrapperClass',
            value: input.textWrapperClass,
            alt: []
        }),
        textWrapperTag: buildOrFail({
            key: 'textWrapperTag',
            value: input.textWrapperTag,
            alt: 'div'
        }),
        actions: buildOrFail({
            key: 'actions',
            value: input.actions,
            alt: true
        }),
        actionsContent: buildOrFail({
            key: 'actionsContent',
            value: input.actionsContent,
            alt: []
        }),
        actionsWrapper: buildOrFail({
            key: 'actionsWrapper',
            value: input.actionsWrapper,
            alt: true
        }),
        actionsWrapperClass: buildOrFail({
            key: 'actionsWrapperClass',
            value: input.actionsWrapperClass,
            alt: []
        }),
        actionsWrapperTag: buildOrFail({
            key: 'actionsWrapperTag',
            value: input.actionsWrapperTag,
            alt: 'div'
        })
    };
}
function maybeWrapContent(input, ctx) {
    if (!ctx.wrap) {
        return input;
    }
    return h(ctx.tag, {
        class: ctx.class
    }, [
        input
    ]);
}
function buildListItem(input) {
    const options = buildListItemOptions(input);
    const data = unref(options.data);
    const overrideUpdatedFn = (fn, item)=>{
        options.data = setMaybeRefValue(options.data, merge(item || {}, data));
        return fn(unref(options.data));
    };
    let slotProps;
    if (options.slotPropsBuilt) {
        const { updated, deleted, ...original } = options.slotProps;
        slotProps = {
            ...original,
            data,
            index: options.index
        };
        if (updated) {
            slotProps.updated = (item)=>overrideUpdatedFn(updated, item);
        }
        if (deleted) {
            slotProps.deleted = (item)=>deleted(item || data);
        }
    } else {
        const { updated, deleted, ...original } = buildListBaseSlotProps({
            ...options,
            data: options.data
        });
        slotProps = {
            ...original,
            data,
            index: options.index
        };
        if (updated) {
            slotProps.updated = (item)=>overrideUpdatedFn(updated, item);
        }
        if (deleted) {
            slotProps.deleted = (item)=>deleted(item || data);
        }
    }
    const renderContent = (content)=>h(options.tag, mergeProps({
            key: options.index
        }, {
            class: options.class
        }, options.props), [
            content || []
        ]);
    const children = {};
    if (hasNormalizedSlot(SlotName.ITEM, options.slotItems)) {
        children.slot = normalizeSlot(SlotName.ITEM, slotProps, options.slotItems);
    } else {
        if (options.icon) {
            children.icon = maybeWrapContent(h(options.iconTag, mergeProps({
                class: options.iconClass
            }, options.iconProps)), {
                wrap: options.iconWrapper,
                tag: options.iconWrapperTag,
                class: options.iconWrapperClass
            });
        }
        if (options.text) {
            let text;
            if (options.textContent) {
                if (typeof options.textContent === 'function') {
                    text = options.textContent(data);
                } else {
                    text = options.textContent;
                }
            } else if (options.textPropName && hasOwnProperty(data, options.textPropName)) {
                text = data[options.textPropName];
            }
            if (text) {
                children.text = maybeWrapContent(text, {
                    wrap: options.textWrapper,
                    tag: options.textWrapperTag,
                    class: options.textWrapperClass
                });
            }
        }
        let actions;
        if (options.actions) {
            if (hasNormalizedSlot(SlotName.ITEM_ACTIONS, options.slotItems)) {
                actions = [
                    normalizeSlot(SlotName.ITEM_ACTIONS, slotProps, options.slotItems)
                ];
            } else if (options.actionsContent) {
                actions = options.actionsContent;
            }
            if (hasNormalizedSlot(SlotName.ITEM_ACTIONS_EXTRA, options.slotItems)) {
                actions = [
                    actions,
                    normalizeSlot(SlotName.ITEM_ACTIONS_EXTRA, slotProps, options.slotItems)
                ];
            }
        }
        if (actions) {
            children.actions = maybeWrapContent(actions, {
                wrap: options.actionsWrapper,
                tag: options.actionsWrapperTag,
                class: options.actionsWrapperClass
            });
        }
    }
    if (options.content) {
        if (typeof options.content === 'function') {
            return renderContent(options.content(data, slotProps, children));
        }
        return renderContent(options.content);
    }
    if (children.slot) {
        return renderContent(children.slot);
    }
    const content = [
        ...children.icon ? [
            children.icon
        ] : [],
        ...children.text ? [
            children.text
        ] : [],
        ...children.actions ? [
            children.actions
        ] : []
    ];
    return renderContent(content);
}

function buildListBodyOptions(input) {
    const options = buildListBaseOptions(input, Component.ListBody, {
        class: 'list-body',
        tag: 'ul'
    });
    return {
        ...options,
        data: input.data || [],
        item: input.item
    };
}
function buildListBody(input) {
    input = input || {};
    const options = buildListBodyOptions(input);
    let slotProps;
    if (options.slotPropsBuilt) {
        slotProps = {
            data: unref(options.data),
            ...options.slotProps
        };
    } else {
        slotProps = {
            ...buildListBaseSlotProps(options),
            data: unref(options.data),
            ...options.slotProps
        };
    }
    if (hasNormalizedSlot(SlotName.BODY, options.slotItems)) {
        return h(options.tag, mergeProps({
            class: options.class
        }, options.props), normalizeSlot(SlotName.BODY, slotProps, options.slotItems));
    }
    // ----------------------------------------------------------------------
    return h(options.tag, mergeProps({
        class: options.class
    }, options.props), unref(options.data).map((item, index)=>buildListItem({
            slotProps,
            slotPropsBuilt: true,
            slotItems: options.slotItems,
            ...options.item,
            data: item,
            index,
            busy: options.busy
        })));
}

function buildListLoadingOptions(input) {
    const options = buildListBaseOptions(input, Component.ListLoading, {
        class: 'list-loading'
    });
    return {
        ...options
    };
}
function buildListLoading(input) {
    input = input || {};
    const options = buildListLoadingOptions(input);
    let slotProps;
    if (options.slotPropsBuilt) {
        slotProps = options.slotProps;
    } else {
        slotProps = {
            ...buildListBaseSlotProps(options),
            ...options.slotProps
        };
    }
    if (!options.busy) {
        return [];
    }
    let content;
    if (hasNormalizedSlot(SlotName.LOADING, options.slotItems)) {
        content = normalizeSlot(SlotName.LOADING, slotProps, options.slotItems);
    }
    if (options.content) {
        if (typeof options.content === 'function') {
            content = [
                options.content(slotProps)
            ];
        } else {
            content = [
                options.content
            ];
        }
    }
    if (content) {
        return h(options.tag, mergeProps({
            class: options.class
        }, options.props), [
            content
        ]);
    }
    return [];
}

function buildListNoMoreOptions(input) {
    const options = buildListBaseOptions(input, Component.ListNoMore, {
        class: 'list-no-more'
    });
    const { buildOrFail } = createOptionBuilder(Component.ListNoMore);
    return {
        ...options,
        content: buildOrFail({
            key: 'content',
            value: input.content,
            alt: 'No more items available...'
        })
    };
}
function buildListNoMore(input) {
    input = input || {};
    const options = buildListNoMoreOptions(input);
    const busy = unref(options.busy);
    const { meta } = options;
    if (busy) {
        return [];
    }
    if (typeof meta.total === 'number' && meta.total > 0) {
        return [];
    }
    let slotProps;
    if (options.slotPropsBuilt) {
        slotProps = options.slotProps;
    } else {
        slotProps = {
            ...buildListBaseSlotProps(options),
            ...options.slotProps
        };
    }
    const renderContent = (content)=>h(options.tag, mergeProps({
            class: options.class
        }, options.props), [
            content
        ]);
    if (hasNormalizedSlot(SlotName.NO_MORE, options.slotItems)) {
        return renderContent(normalizeSlot(SlotName.NO_MORE, slotProps, options.slotItems));
    }
    if (typeof options.content === 'function') {
        return renderContent(options.content(slotProps));
    }
    return renderContent(options.content);
}

function buildListOptions(input) {
    const options = buildListBaseOptions(input, Component.List, {
        class: 'list'
    });
    return {
        ...options,
        data: input.data ?? [],
        header: input.header ?? true,
        footer: input.footer ?? true,
        body: input.body ?? true,
        loading: input.loading ?? true,
        noMore: input.noMore ?? true
    };
}
function buildList(input) {
    const options = buildListOptions(input);
    if (typeof options.meta.total === 'undefined') {
        options.meta.total = unref(options.data).length;
    }
    const busy = unref(options.busy);
    const buildSlotProps = (props)=>({
            ...props,
            ...buildListBaseSlotProps(options)
        });
    const children = [];
    if (options.header) {
        const childOptions = typeof options.header === 'boolean' ? {} : options.header;
        childOptions.slotItems = options.slotItems;
        childOptions.slotProps = buildSlotProps(options.slotProps);
        childOptions.slotPropsBuilt = true;
        childOptions.meta = options.meta;
        children.push(buildListHeader(childOptions));
    }
    if (options.body) {
        let childOptions;
        if (typeof options.body === 'boolean') {
            childOptions = {
                data: options.data,
                busy
            };
        } else {
            childOptions = options.body;
            childOptions.data = options.data;
            childOptions.busy = busy;
        }
        childOptions.slotItems = options.slotItems;
        childOptions.slotProps = buildSlotProps(options.slotProps);
        childOptions.slotPropsBuilt = true;
        childOptions.meta = options.meta;
        children.push(buildListBody(childOptions));
    }
    if (options.loading) {
        let childOptions;
        if (typeof options.loading === 'boolean') {
            childOptions = {};
        } else {
            childOptions = options.loading;
        }
        childOptions.slotItems = options.slotItems;
        childOptions.slotProps = buildSlotProps(options.slotProps);
        childOptions.slotPropsBuilt = true;
        childOptions.meta = options.meta;
        childOptions.busy = busy;
        children.push(buildListLoading(childOptions));
    }
    if (options.noMore) {
        const childOptions = typeof options.noMore === 'boolean' ? {} : options.noMore;
        childOptions.slotItems = options.slotItems;
        childOptions.slotProps = buildSlotProps(options.slotProps);
        childOptions.slotPropsBuilt = true;
        childOptions.meta = options.meta;
        childOptions.busy = busy;
        children.push(buildListNoMore(childOptions));
    }
    if (options.footer) {
        const childOptions = typeof options.footer === 'boolean' ? {} : options.footer;
        childOptions.slotItems = options.slotItems;
        childOptions.slotProps = buildSlotProps(options.slotProps);
        childOptions.slotPropsBuilt = true;
        childOptions.meta = options.meta;
        children.push(buildListFooter(childOptions));
    }
    return h(options.tag, mergeProps({
        class: options.class
    }, options.props), children);
}

function buildListTitleOptions(input) {
    const options = buildListBaseOptions(input, Component.ListTitle, {
        class: 'list-title'
    });
    const { buildOrFail } = createOptionBuilder(Component.ListTitle);
    return {
        ...options,
        text: buildOrFail({
            key: 'text',
            value: input.text,
            alt: true
        }),
        textClass: buildOrFail({
            key: 'textClass',
            value: input.textClass,
            alt: []
        }),
        textType: buildOrFail({
            key: 'textType',
            value: input.textType,
            alt: 'h4'
        }),
        textProps: buildOrFail({
            key: 'textProps',
            value: input.textProps,
            alt: {}
        }),
        textContent: buildOrFail({
            key: 'textContent',
            value: input.textContent,
            alt: 'List'
        }),
        icon: buildOrFail({
            key: 'icon',
            value: input.icon,
            alt: true
        }),
        iconClass: buildOrFail({
            key: 'iconClass',
            value: input.iconClass,
            alt: []
        }),
        iconProps: buildOrFail({
            key: 'iconProps',
            value: input.iconProps,
            alt: {}
        })
    };
}
function buildListTitle(input) {
    const options = buildListTitleOptions(input);
    const renderContent = (content)=>h(options.tag, mergeProps({
            class: options.class
        }, options.props), content);
    if (hasNormalizedSlot(SlotName.HEADER_TITLE, options.slotItems)) {
        return renderContent(normalizeSlot(SlotName.HEADER_TITLE, {}, options.slotItems));
    }
    let children = [];
    if (options.icon) {
        children.push(h('i', mergeProps({
            class: options.iconClass
        }, options.iconProps)));
    }
    if (options.text) {
        if (options.icon && typeof options.textContent === 'string') {
            children.push(' ');
        }
        children = [
            h(options.textType, mergeProps({
                class: options.textClass
            }, options.textProps), [
                ...children,
                options.textContent
            ])
        ];
    }
    return renderContent(children);
}

function install(instance, options) {
    options ?? (options = {});
    applyPluginBaseOptions(options);
}
var index = {
    install
};

export { Component, SlotName, buildItemActionToggle, buildItemActionToggleOptions, buildList, buildListBaseOptions, buildListBaseSlotProps, buildListBody, buildListBodyOptions, buildListFooter, buildListFooterOptions, buildListHeader, buildListHeaderOptions, buildListItem, buildListItemOptions, buildListLoading, buildListLoadingOptions, buildListNoMore, buildListNoMoreOptions, buildListOptions, buildListTitle, buildListTitleOptions, index as default, install };
//# sourceMappingURL=index.mjs.map
