import { defineExtension, safeCast, shallowMergeConfig } from "lexical";
const BylineToolbarExtension = defineExtension({
    name: '@byline/richtext-lexical/Toolbar',
    config: safeCast({
        items: []
    }),
    mergeConfig (a, b) {
        const merged = shallowMergeConfig(a, b);
        if (b.items && b.items.length > 0) merged.items = [
            ...a.items,
            ...b.items
        ];
        return merged;
    }
});
function selectToolbarItems(items, placement) {
    return items.filter((item)=>item.placement === placement).slice().sort((a, b)=>(a.order ?? 0) - (b.order ?? 0));
}
export { BylineToolbarExtension, selectToolbarItems };
