function PageMenu(arguments) {
    let data = {
        menuitem: null,
        page: null,
    };
    for (let key in arguments){
        data[key] = arguments[key];
    };
    function button_common() {
        if (data.menuitem===null) {
            return {tag: '<', children: '<div class="btn btn-primary me-2"><i class="fa fa-bars"></i></div>'};
        } else {
            return m(m.route.Link, {class: "btn btn-outline-secondary me-2 text-decoration-none", href: `/page/${data.page.id}`, title: data.page.title}, m('i', {class: 'fa fa-bars'}))
        }
    };
    function button_briefcases() {
        if (data.menuitem==='briefcases') {
            return {tag: '<', children: '<div class="btn btn-primary me-2">Портфели</div>'};
        } else {
            return m(m.route.Link, {class: "btn btn-outline-secondary me-2 text-decoration-none", href: `/page/${data.page.id}/briefcases`}, 'Портфели')
        }
    };
    function button_attachments() {
        if (data.menuitem==='attachments') {
            return {tag: '<', children: '<div class="btn btn-primary me-2">Связи</div>'};
        } else {
            return m(m.route.Link, {class: "btn btn-outline-secondary me-2 text-decoration-none", href: `/page/${data.page.id}/attachments`}, 'Связи')
        }
    };
    function button_properties() {
        if (data.menuitem==='properties') {
            return {tag: '<', children: '<div class="btn btn-primary me-2">Свойства</div>'};
        } else {
            return m(m.route.Link, {class: "btn btn-outline-secondary me-2 text-decoration-none", href: `/page/${data.page.id}/properties`}, 'Свойства')
        }
    };
    function button_details() {
        if (data.menuitem==='details') {
            return {tag: '<', children: '<div class="btn btn-primary me-2">Сведения</div>'};
        } else {
            return m(m.route.Link, {class: "btn btn-outline-secondary me-2 text-decoration-none", href: `/page/${data.page.id}/details`}, 'Сведения')
        }
    };
    return {
        oninit: function(vnode) {
            console.log('PageMenu.oninit');
            for (let key in vnode.attrs){
                data[key] = vnode.attrs[key];
            };
        },
        view: function(vnode) {
            console.log('PageMenu.view');
            return m('div', {class: 'row'},
                m('div', {class: 'col py-2'}, [
                    button_common(),
                    button_briefcases(),
                    button_attachments(),
                    button_properties(),
                    button_details(),
                ])
            )
        }
    }
};
