import * as __WEBPACK_EXTERNAL_MODULE__Sidebar_mjs__ from "./Sidebar.mjs";
import * as __WEBPACK_EXTERNAL_MODULE_react_icons_md__ from "react-icons/md";
import * as __WEBPACK_EXTERNAL_MODULE__storybook_test__ from "@storybook/test";
import * as __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__ from "@chakra-ui/react";
import * as __WEBPACK_EXTERNAL_MODULE_react_router_dom__ from "react-router-dom";
const sidebarDefaultItems = [
    {
        title: 'Internal 1',
        to: '/1',
        icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdSearch
    },
    {
        title: 'Internal 2',
        to: '/2',
        icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdHelpOutline
    },
    {
        title: 'Internal 3',
        to: '/3',
        icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdFavoriteBorder
    },
    {
        title: 'External',
        to: 'https://redpanda.com',
        icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdPayment,
        isExternal: true
    },
    {
        title: 'Disabled',
        to: '/4',
        icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdPersonOutline,
        isDisabled: true,
        disabledText: 'Reason link is disabled'
    }
];
const sideBarDefaultFooterItems = [
    {
        title: 'Settings',
        to: '/settings',
        icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdOutlineSettings
    },
    {
        title: 'Account',
        to: '/account',
        icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdPersonOutline
    }
];
const sideBarMultiHeadingGroups = [
    {
        heading: 'Menu heading 1',
        items: [
            {
                title: 'Internal 1',
                to: '/1',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdSearch
            },
            {
                title: 'Internal 2',
                to: '/2',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdHelpOutline
            },
            {
                title: 'Internal 3',
                to: '/3',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdFavoriteBorder
            },
            {
                title: 'External 1',
                to: 'https://redpanda.com',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdPayment,
                isExternal: true
            }
        ]
    },
    {
        heading: 'Menu heading 2',
        items: [
            {
                title: 'Settings',
                to: '/settings',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdOutlineSettings
            },
            {
                title: 'Account',
                to: '/account',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdPersonOutline
            }
        ]
    }
];
const meta = {
    title: 'Components/Sidebar',
    component: __WEBPACK_EXTERNAL_MODULE__Sidebar_mjs__["default"],
    argTypes: {
        status: {
            options: [
                'success',
                'loading',
                'error'
            ],
            control: {
                type: 'select'
            }
        },
        items: {
            control: false
        },
        groups: {
            control: false
        },
        footerItems: {
            control: false
        },
        children: {
            control: false
        },
        isCollapsible: {
            control: false
        },
        isCollapsed: {
            control: false
        },
        logoOverrides: {
            control: false
        }
    },
    parameters: {
        design: {
            type: 'figma',
            url: 'https://www.figma.com/file/bJcVrZNilxa06jYuVCGWYd/Redpanda-Design-System-2023?type=design&node-id=23-479&mode=design'
        }
    }
};
/* ESM default export */ const Sidebar_stories_rslib_entry_ = meta;
const Default = {
    args: {
        items: sidebarDefaultItems
    }
};
const WithFooterChildren = {
    args: {
        items: sidebarDefaultItems,
        footerChildren: /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Box, {
            maxW: "161px",
            maxH: "161px",
            p: "18px",
            borderRadius: "6px",
            color: "white"
        }, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Text, null, "Footer Child 1"), /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Text, null, "Footer Child 2"), /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Text, null, "Footer Child 3")),
        footerItems: sideBarDefaultFooterItems
    }
};
const GoBackConditionally = {
    args: {
        items: sidebarDefaultItems
    },
    render: (props)=>{
        const location = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useLocation)();
        const previousItem = {
            title: 'Go back',
            to: '/1',
            icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdKeyboardBackspace
        };
        return /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Sidebar_mjs__["default"], {
            ...props,
            previousItem: '/2' === location.pathname ? previousItem : void 0
        });
    },
    play: async ({ canvasElement, step })=>{
        const canvas = (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.within)(canvasElement);
        await step('Check there is no back button', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-previous')).not.toBeInTheDocument();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-icon-Go back')).not.toBeInTheDocument();
        });
        await step('Check link #2', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-Internal 2')).toHaveTextContent('Internal 2');
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-icon-Internal 2')).toBeVisible();
            await __WEBPACK_EXTERNAL_MODULE__storybook_test__.userEvent.click(canvas.getByText('Internal 2'));
        });
        await step('Check the back button appears', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-previous')).toHaveTextContent('Go back');
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-icon-Go back')).toBeVisible();
        });
        await step('Check the back button disappears upon redirect and the right link is active', async ()=>{
            await __WEBPACK_EXTERNAL_MODULE__storybook_test__.userEvent.click(canvas.getByText('Go back'));
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-previous')).not.toBeInTheDocument();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-icon-Go back')).not.toBeInTheDocument();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-Internal 1').parentElement?.parentElement).toHaveAttribute('aria-current', 'page');
        });
    }
};
const GoBackConditionallyGroup = {
    args: {
        groups: sideBarMultiHeadingGroups
    },
    render: (props)=>{
        const location = (0, __WEBPACK_EXTERNAL_MODULE_react_router_dom__.useLocation)();
        const previousItem = {
            title: 'Go back',
            to: '/1',
            icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdKeyboardBackspace
        };
        return /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Sidebar_mjs__["default"], {
            ...props,
            previousItem: '/2' === location.pathname ? previousItem : void 0
        });
    }
};
const MultiHeadingNav = {
    args: {
        groups: sideBarMultiHeadingGroups
    },
    play: async ({ canvasElement, step })=>{
        const canvas = (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.within)(canvasElement);
        await step('Check headings', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-heading-Menu heading 1')).toBeVisible();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-heading-Menu heading 2')).toBeVisible();
        });
    }
};
const FooterItems = {
    args: {
        items: [
            {
                title: 'Internal 1',
                to: '/1',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdSearch
            },
            {
                title: 'Internal 2',
                to: '/2',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdHelpOutline
            },
            {
                title: 'Internal 3',
                to: '/3',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdFavoriteBorder
            },
            {
                title: 'External',
                to: 'https://redpanda.com',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdPayment,
                isExternal: true
            },
            {
                title: 'Disabled',
                to: '/4',
                icon: __WEBPACK_EXTERNAL_MODULE_react_icons_md__.MdPersonOutline,
                isDisabled: true,
                disabledText: 'Reason link is disabled'
            }
        ],
        footerItems: sideBarDefaultFooterItems
    },
    play: async ({ canvasElement, step })=>{
        const canvas = (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.within)(canvasElement);
        await step('Check link #1', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-Internal 1')).toHaveTextContent('Internal 1');
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-icon-Internal 1')).toBeVisible();
            await __WEBPACK_EXTERNAL_MODULE__storybook_test__.userEvent.click(canvas.getByText('Internal 1'));
        });
        await step('Check link #2', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-Internal 2')).toHaveTextContent('Internal 2');
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-icon-Internal 2')).toBeVisible();
            await __WEBPACK_EXTERNAL_MODULE__storybook_test__.userEvent.click(canvas.getByText('Internal 2'));
        });
        await step('Check link #3', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-Internal 3')).toHaveTextContent('Internal 3');
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-icon-Internal 3')).toBeVisible();
            await __WEBPACK_EXTERNAL_MODULE__storybook_test__.userEvent.click(canvas.getByText('Internal 3'));
        });
        await step('Check external', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-External')).toHaveTextContent('External');
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-icon-External')).toBeVisible();
        });
        await step('Check disabled', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-icon-Disabled')).toBeVisible();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-Disabled')).toHaveTextContent('Disabled');
        });
        await step('Check "Settings"', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-Settings')).toHaveTextContent('Settings');
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-icon-Settings')).toBeVisible();
            await __WEBPACK_EXTERNAL_MODULE__storybook_test__.userEvent.click(canvas.getByText('Settings'));
        });
        await step('Check "Account"', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-Account')).toHaveTextContent('Account');
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-icon-Account')).toBeVisible();
            await __WEBPACK_EXTERNAL_MODULE__storybook_test__.userEvent.click(canvas.getByText('Account'));
        });
        await step('Collapse sidebar', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-icon-Expand sidebar')).not.toBeInTheDocument();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-icon-Collapse sidebar')).toBeVisible();
            await __WEBPACK_EXTERNAL_MODULE__storybook_test__.userEvent.click(canvas.getByTestId('nav-link-icon-Collapse sidebar'));
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-Internal 1')).not.toBeInTheDocument();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-Internal 2')).not.toBeInTheDocument();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-Internal 3')).not.toBeInTheDocument();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-External')).not.toBeInTheDocument();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-Disabled')).not.toBeInTheDocument();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-Settings')).not.toBeInTheDocument();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-Account')).not.toBeInTheDocument();
        });
        await step('Expand sidebar', async ()=>{
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.getByTestId('nav-link-icon-Expand sidebar')).toBeVisible();
            (0, __WEBPACK_EXTERNAL_MODULE__storybook_test__.expect)(canvas.queryByTestId('nav-link-icon-Collapse sidebar')).not.toBeInTheDocument();
            await __WEBPACK_EXTERNAL_MODULE__storybook_test__.userEvent.click(canvas.getByTestId('nav-link-icon-Expand sidebar'));
        });
    }
};
export { Default, FooterItems, GoBackConditionally, GoBackConditionallyGroup, MultiHeadingNav, WithFooterChildren, Sidebar_stories_rslib_entry_ as default };
