<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
if (!window.hasOwnProperty("PlatformRouter"))
{
    window.PlatformRouter = new (function () {
        let instance = this;
        this.listeners = {
            onRoute: []
        };
        this.onRoute = function (pathname, callback) {
            const listener = {
                pathname: addSlashToPathname(pathname),
                callback
            };
            instance.listeners.onRoute.push(listener);
        }
        this.route = function (pathname) {
            const url = new URL(addSlashToPathname(pathname), location.origin);
            if (url.origin === location.origin)
            {
                for (const {pathname, callback} of instance.listeners.onRoute)
                {
                    if (pathname === url.pathname) {
                        callback();
                    }
                }
            }
        };
        const addSlashToPathname = function (pathname) {
            return pathname.startsWith("/") ? pathname : "/" + pathname;
        };
        const __initialize = function () {
            $("body").on("click", "a", function (event) {
                const eventHref = $(this).attr("href");
                const url = new URL(eventHref, location.origin);
                if (url.origin === location.origin)
                {
                    for (const {pathname, callback} of instance.listeners.onRoute)
                    {
                        if (pathname === url.pathname) {
                            callback(event);
                        }
                    }
                }
            });
        };

        $(document).ready(__initialize);
    });
}


if (!window.hasOwnProperty("ModalSectionsManager"))
{
    window.ModalSectionsManager = new (function () {

        let instance = this;

        const selectors = {
            container: "#modal-sections",
            headBlock: "body &gt; div.head-block:first",
        };

        this.opened = new Map();
        this.previousStyles = {
            body: {
                overflow: "",
                paddingRight: "",
            },
            headBlock: {
                width: ""
            }
        };

        this.scrollWidth = 0;

        const getScrollWidth = function () {
            let div = document.createElement('div');
            div.style.overflowY = 'scroll';
            div.style.width = '50px';
            div.style.height = '50px';
            document.body.append(div);
            let scrollWidth = div.offsetWidth - div.clientWidth;
            div.remove();
            return scrollWidth;
        }

        this.sections = [];

        this.close = function (section_id) {
            if (instance.opened.has(+section_id))
            {
               const section = instance.sections.find(section =&gt; section.id === +section_id);
               section.close();
            }
        };

        this.toggleAnimation = function (toggle, $backdrop)
        {
            const toggleSpeed = 350;
            const position_type = $backdrop.attr("data-section-type");
            const behindScreen = ["left", "right", "top", "bottom"].includes(position_type);

            let $modal =  $backdrop.find("&gt; .modal-section:first");

            if (toggle === "show")
            {
                let animate = {opacity: "show"};
                if (behindScreen) animate[position_type] = "0";

                let initCss = {opacity: "0"};
                initCss[position_type] = "-100%";

                $backdrop.animate({opacity: "show"}, toggleSpeed);
                $modal.animate(animate, toggleSpeed);
            }
            else
            {
                let animate = {opacity: "hide"};
                if (behindScreen) animate[position_type] = "-100%";

                $backdrop.animate({opacity: "hide"}, toggleSpeed);
                $modal.animate(animate, toggleSpeed);
            }
        };

        const __initializeSections = function () {
            instance.sections = [];

            $(selectors.container).find(".modal-section-backdrop").each(function () {
                let $backdrop = $(this);
                let section_id = +$backdrop.attr("data-section-id");
                let section_url = $backdrop.attr("data-section-url");
                let position_type = $backdrop.attr("data-section-type");

                if (position_type === "sub-head-menu") $backdrop.appendTo(selectors.headBlock);

                const close = function () {
                    instance.toggleAnimation("hide", $backdrop);
                    instance.opened.delete(section_id);
                    if (!instance.opened.size)
                    {
                        $("body")
                            .css("overflow", instance.previousStyles.body.overflow)
                            .css("padding-right", instance.previousStyles.body.paddingRight);

                        $(selectors.headBlock).css("width", instance.previousStyles.headBlock.width);
                    }
                };

                $backdrop
                    .on("click", function (event) {
                        if ($(event.target).hasClass("modal-section-backdrop")) close();
                    })
                    .on("click", ".modal-section-btn-close", close);

                const section = {
                    id: section_id,
                    elements: {
                        backdrop: $backdrop
                    },
                    url: section_url,
                    close: close
                };

                instance.sections.push(section);

                PlatformRouter.onRoute(section_url, function (event = null) {
                    if (event) event.preventDefault();

                    const countOpened = instance.opened.size;

                    if (position_type === "sub-head-menu")
                    {
                        if (countOpened &amp;&amp; instance.opened.has(section_id))
                        {
                            close();
                            return;
                        }

                        for (let [_id, _type] of instance.opened.entries()) {
                            if (_type === "sub-head-menu")
                            {
                                instance.close(_id);
                            }
                        }

                        $backdrop.css("top", $(selectors.headBlock).height() + "px");
                    }
                    
                    if (!countOpened)
                    {
                        let $body = $("body");
                        let $headBlock = $(selectors.headBlock);

                        instance.previousStyles.body.overflow = $body.css("overflow");
                        instance.previousStyles.body.paddingRight = $body.css("padding-right");
                        instance.previousStyles.headBlock.width = $headBlock[0].style.width ?? $headBlock.css("width");

                        $body.css("overflow", "hidden");
                        $body.css("padding-right", `${instance.scrollWidth}px`);

                        let newHeadBlockWidth = $headBlock.width() - instance.scrollWidth
                        $headBlock.css("width", `${newHeadBlockWidth}px`);
                    }

                    instance.opened.set(section_id, position_type);

                    instance.toggleAnimation("show", $backdrop);
                });
            });
        };

        $(document).ready(function () {
            instance.scrollWidth = getScrollWidth();
            __initializeSections();
        });

    })();
}















</pre></body></html>