
    const thisScript = document.currentScript;

    ! function() {
        insertWidgetHtml();
    }();

    function insertWidgetHtml() {
        let html =
            `<style>.IDX-yelp-bussineses-wrapper {
    display: flex !important;
    position: relative;
    max-width: 100%;
    margin-right: auto;
    margin-left: auto;
    flex-direction: column;
    font-family: sans-serif;
    margin-top: 20px;
    margin-bottom: 20px;
}

@media (min-width: 600px) {
    .IDX-yelp-bussineses-wrapper {
        flex-wrap: wrap;
    }
}

.IDX-yelp-cards-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.IDX-filter-container {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 15px;
}

@media (min-width: 600px) {
    .IDX-filter-container {
        width: 100%;
        flex-wrap: nowrap;
    }
}

.IDX-yelp-search {
    margin-right: 10px !important;
    border-style: solid;
    border-width: 1px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 8px;
    border-radius: 0.375rem;
    border-color: rgb(209 213 219);
    padding-top: 0.5rem;
    padding-right: 0.75rem;
    padding-bottom: 0.5rem;
    padding-left: 0.75rem;
    margin-right: 15px;
}

@media (max-width: 600px) {
    .IDX-yelp-search {
        width: 100%;
        margin-bottom: 10px;
    }
}

.IDX-yelp-card {
    display: flex;
    position: relative;
    border: 1px solid rgb(203 213 225);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    width: 100%;
    height: 289px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    flex-direction: column;
    justify-content: flex-end;
    isolation: isolate;
}

@media (min-width: 768px) {
    .IDX-yelp-card {
        width: calc(50% - 10px);
    }
}

@media (min-width: 1024px) {
    .IDX-yelp-card {
        width: calc(33.33% - 10px);
    }
}
.IDX-yelp-image {
    inset: 0;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    position: absolute;
    z-index: -1;
}
.IDX-yelp-info {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    padding: 10px 15px;
    background: linear-gradient(
        0deg,
        rgba(0, 0, 0, 1) 10%,
        rgba(0, 0, 0, 0) 100%
    );
}

.IDX-yelp-info a {
    display: block;
    font-size: 15px;
    text-decoration: none;
    font-weight: bold;
    margin-top: 0px;
    margin-bottom: 3px;
}

.IDX-yelp-info a:hover {
    text-decoration: underline;
}

.IDX-yelp-info span {
    font-size: 13px;
    color: rgb(55 65 81);
    font-weight: light;
}

.IDX-yelp-info p {
    font-size: 12px;
    font-weight: light;
    margin-top: 0;
    margin-bottom: 0px;
    color: #f7f7f7;
}

.IDX-yelp-info-stars-logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.yelp-stars-5 {
    background-position: 0 -500px;
    height: 20px;
    width: 108px;
}

.yelp-stars-4\\.5 {
    background-position: 0 -460px;
    height: 20px;
    width: 108px;
}

.yelp-stars-4 {
    background-position: 0 -480px;
    height: 20px;
    width: 108px;
}

.yelp-stars-3\\.5 {
    background-position: 0 -420px;
    height: 20px;
    width: 108px;
}

.yelp-stars-3 {
    background-position: 0 -440px;
    height: 20px;
    width: 108px;
}

.yelp-stars-2\\.5 {
    background-position: 0 -380px;
    height: 20px;
    width: 108px;
}

.yelp-stars-2 {
    background-position: 0 -400px;
    height: 20px;
    width: 108px;
}

.yelp-stars-1\\.5 {
    background-position: 0 -340px;
    height: 20px;
    width: 108px;
}

.yelp-stars-1 {
    background-position: 0 -360px;
    height: 20px;
    width: 108px;
}

.IDX-category {
    display: inline-flex;
    justify-content: center;
    color: #898989;
    background-color: #f7f7f7;
    gap: 5px;
    padding: 14px 16px;
    min-width: fit-content;
    flex-basis: 95px;
    border: 1px solid rgba(200, 201, 202, 1);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.7;
    vertical-align: baseline;
    transition: background-color 0.4s, border-color 0.4s, color 0.4s,
        clip-path 0.45s, transform 0.4s;
    cursor: pointer;
    white-space: nowrap;
}

.IDX-category svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.IDX-category:hover {
    background-color: rgb(226, 226, 230);
}

.IDX-category.selected {
    background-color: #898989;
    color: white !important;
}

.IDX-yelp-skeleton-cards-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.IDX-yelp-skeleton-info {
    width: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.IDX-skeleton-shine {
    background: linear-gradient(to right, #e7e5e7, #fff, #e7e5e7 20%);
    background-size: 300%;
    animation: IDX-pulse 1.5s linear infinite;
}

.IDX-yelp-skeleton-content {
    width: 100%;
    height: 20px;
}
.IDX-categories-wrapper {
    overflow: hidden;
    width: 100%;
    position: relative;
    padding-bottom: 24px;
}
.IDX-categories-container {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.IDX-categories-container::-webkit-scrollbar {
    display: none;
}
@keyframes IDX-pulse {
    0% {
        background-position: 150% 50%;
    }
    100% {
        background-position: 0 50%;
    }
}
</style>
            <section class="IDX-yelp-bussineses-wrapper">
                    <div class="IDX-categories-wrapper">
                        <div class="IDX-categories-container"></div>
                    </div>
                <div class="IDX-yelp-skeleton-cards-container"></div>
                <div class="IDX-yelp-cards-container"></div>
            </section>
            `;

        thisScript.insertAdjacentHTML('afterend', html);


        initYelpWidget();
    }

    function initYelpWidget() {
        // Configuration
        const API_URL = `https://idxapps.com/api/widget/yelp/businesses?app_id=33&`;

        function roundDownToNearest(num, multiple) {
            return Math.floor(num / multiple) * multiple;
        }
        const userOptions = {
            location: "Miami, florida",
            categories: ["food","parks","elementaryschools"],
            limit: "9",
        };

        let currentCategory = userOptions.categories[0].replace(/\s/g, '').toLowerCase();
        const businessesOptions = {
            location: userOptions.location,
            category: currentCategory.replace(/\s/g, '').toLowerCase(),
            limit: userOptions.limit
        };
        const businessesData = [];

        // DOM Elements

        // Select section
        const section = document.querySelector(".IDX-yelp-bussineses-wrapper");

        // Select filter container
        const categoriesWrapper = document.querySelector(".IDX-categories-wrapper");
        const categoriesContainer = document.querySelector(".IDX-categories-container");

        // Select skeleton cards container
        const skeletonCardsContainer = document.querySelector('.IDX-yelp-skeleton-cards-container');
        // Select cards container
        const cardsContainer = document.querySelector('.IDX-yelp-cards-container');
        // Select category links
        const categoryElements = document.querySelectorAll('.IDX-category');
        // Select search input


        // Functions

        //Fetch bussinesses
        const getBusinesses = async (options) => {
            const {
                category,
                location,
                limit
            } = options;
            loadingObserver(true);
            try {
                const response = await fetch(
                    `${API_URL}location=${location}&categories=${category}&limit=${limit}`
                );
                const result = await response.json();
                return result;
            } catch (error) {
                console.error("Error in getBusinesses:", error.message);
                return {
                    businesses: ["Error trying to get the businesses"]
                };
            } finally {
                loadingObserver(false);
            }
        };

        //This funcions create html elements, first param tag name, second object with attributes, and third the element inside of it.
        const createElement = (tagName, attributes = {}, ...children) => {
            const element = document.createElement(tagName);
            for (const key in attributes) {
                element.setAttribute(key, attributes[key])
            }
            children.forEach(child => {
                if (typeof child === 'string') {
                    element.appendChild(document.createTextNode(child))
                } else {
                    element.appendChild(child)
                }
            })
            return element;
        };

        // Create Category links function
        const createCategoryLinks = () => {
            userOptions.categories.forEach(category => {
                // Remove spaces from category names
                const sanitizedCategory = category.replace(/\s/g, '').toLowerCase();

                let categories = {
                    restaurants: 'Dine',
                    parks: 'Parks',
                    pets: 'Wag',
                    museums: 'Museums',
                    elementaryschools: 'Elementary Schools',
                    shoppingcenters: 'Shopping Centers',
                    bars: 'Drink',
                    shopping: 'Shop',
                    coffee: 'Perk',
                    fitness: 'Sweat',
                    hair: 'Groom',
                    'food': 'Food',
                };

                let icons = {
                    restaurants: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M416 0C400 0 288 32 288 176V288c0 35.3 28.7 64 64 64h32V480c0 17.7 14.3 32 32 32s32-14.3 32-32V352 240 32c0-17.7-14.3-32-32-32zM64 16C64 7.8 57.9 1 49.7 .1S34.2 4.6 32.4 12.5L2.1 148.8C.7 155.1 0 161.5 0 167.9c0 45.9 35.1 83.6 80 87.7V480c0 17.7 14.3 32 32 32s32-14.3 32-32V255.6c44.9-4.1 80-41.8 80-87.7c0-6.4-.7-12.8-2.1-19.1L191.6 12.5c-1.8-8-9.3-13.3-17.4-12.4S160 7.8 160 16V150.2c0 5.4-4.4 9.8-9.8 9.8c-5.1 0-9.3-3.9-9.8-9L127.9 14.6C127.2 6.3 120.3 0 112 0s-15.2 6.3-15.9 14.6L83.7 151c-.5 5.1-4.7 9-9.8 9c-5.4 0-9.8-4.4-9.8-9.8V16zm48.3 152l-.3 0-.3 0 .3-.7 .3 .7z"/></svg>`,
                    parks: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M210.6 5.9L62 169.4c-3.9 4.2-6 9.8-6 15.5C56 197.7 66.3 208 79.1 208H104L30.6 281.4c-4.2 4.2-6.6 10-6.6 16C24 309.9 34.1 320 46.6 320H80L5.4 409.5C1.9 413.7 0 419 0 424.5c0 13 10.5 23.5 23.5 23.5H192v32c0 17.7 14.3 32 32 32s32-14.3 32-32V448H424.5c13 0 23.5-10.5 23.5-23.5c0-5.5-1.9-10.8-5.4-15L368 320h33.4c12.5 0 22.6-10.1 22.6-22.6c0-6-2.4-11.8-6.6-16L344 208h24.9c12.7 0 23.1-10.3 23.1-23.1c0-5.7-2.1-11.3-6-15.5L237.4 5.9C234 2.1 229.1 0 224 0s-10 2.1-13.4 5.9z"/></svg>`,
                    pets: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M309.6 158.5L332.7 19.8C334.6 8.4 344.5 0 356.1 0c7.5 0 14.5 3.5 19 9.5L392 32h52.1c12.7 0 24.9 5.1 33.9 14.1L496 64h56c13.3 0 24 10.7 24 24v24c0 44.2-35.8 80-80 80H464 448 426.7l-5.1 30.5-112-64zM416 256.1L416 480c0 17.7-14.3 32-32 32H352c-17.7 0-32-14.3-32-32V364.8c-24 12.3-51.2 19.2-80 19.2s-56-6.9-80-19.2V480c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V249.8c-28.8-10.9-51.4-35.3-59.2-66.5L1 167.8c-4.3-17.1 6.1-34.5 23.3-38.8s34.5 6.1 38.8 23.3l3.9 15.5C70.5 182 83.3 192 98 192h30 16H303.8L416 256.1zM464 80a16 16 0 1 0 -32 0 16 16 0 1 0 32 0z"/></svg>`,
                    museums: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M512 256c0 .9 0 1.8 0 2.7c-.4 36.5-33.6 61.3-70.1 61.3H344c-26.5 0-48 21.5-48 48c0 3.4 .4 6.7 1 9.9c2.1 10.2 6.5 20 10.8 29.9c6.1 13.8 12.1 27.5 12.1 42c0 31.8-21.6 60.7-53.4 62c-3.5 .1-7 .2-10.6 .2C114.6 512 0 397.4 0 256S114.6 0 256 0S512 114.6 512 256zM128 288a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zm0-96a32 32 0 1 0 0-64 32 32 0 1 0 0 64zM288 96a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zm96 96a32 32 0 1 0 0-64 32 32 0 1 0 0 64z"/></svg>`,
                    shoppingcenters: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M547.6 103.8L490.3 13.1C485.2 5 476.1 0 466.4 0H109.6C99.9 0 90.8 5 85.7 13.1L28.3 103.8c-29.6 46.8-3.4 111.9 51.9 119.4c4 .5 8.1 .8 12.1 .8c26.1 0 49.3-11.4 65.2-29c15.9 17.6 39.1 29 65.2 29c26.1 0 49.3-11.4 65.2-29c15.9 17.6 39.1 29 65.2 29c26.2 0 49.3-11.4 65.2-29c16 17.6 39.1 29 65.2 29c4.1 0 8.1-.3 12.1-.8c55.5-7.4 81.8-72.5 52.1-119.4zM499.7 254.9l-.1 0c-5.3 .7-10.7 1.1-16.2 1.1c-12.4 0-24.3-1.9-35.4-5.3V384H128V250.6c-11.2 3.5-23.2 5.4-35.6 5.4c-5.5 0-11-.4-16.3-1.1l-.1 0c-4.1-.6-8.1-1.3-12-2.3V384v64c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V384 252.6c-4 1-8 1.8-12.3 2.3z"/></svg>`,
                    bars: `
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M32 0C19.1 0 7.4 7.8 2.4 19.8s-2.2 25.7 6.9 34.9L224 269.3V448H160c-17.7 0-32 14.3-32 32s14.3 32 32 32h96 96c17.7 0 32-14.3 32-32s-14.3-32-32-32H288V269.3L502.6 54.6c9.2-9.2 11.9-22.9 6.9-34.9S492.9 0 480 0H32zM173.3 128l-64-64H402.7l-64 64H173.3z"/></svg>
        `,
                    shopping: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M160 112c0-35.3 28.7-64 64-64s64 28.7 64 64v48H160V112zm-48 48H48c-26.5 0-48 21.5-48 48V416c0 53 43 96 96 96H352c53 0 96-43 96-96V208c0-26.5-21.5-48-48-48H336V112C336 50.1 285.9 0 224 0S112 50.1 112 112v48zm24 48a24 24 0 1 1 0 48 24 24 0 1 1 0-48zm152 24a24 24 0 1 1 48 0 24 24 0 1 1 -48 0z"/></svg>`,
                    coffee: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M88 0C74.7 0 64 10.7 64 24c0 38.9 23.4 59.4 39.1 73.1l1.1 1C120.5 112.3 128 119.9 128 136c0 13.3 10.7 24 24 24s24-10.7 24-24c0-38.9-23.4-59.4-39.1-73.1l-1.1-1C119.5 47.7 112 40.1 112 24c0-13.3-10.7-24-24-24zM32 192c-17.7 0-32 14.3-32 32V416c0 53 43 96 96 96H288c53 0 96-43 96-96h16c61.9 0 112-50.1 112-112s-50.1-112-112-112H352 32zm352 64h16c26.5 0 48 21.5 48 48s-21.5 48-48 48H384V256zM224 24c0-13.3-10.7-24-24-24s-24 10.7-24 24c0 38.9 23.4 59.4 39.1 73.1l1.1 1C232.5 112.3 240 119.9 240 136c0 13.3 10.7 24 24 24s24-10.7 24-24c0-38.9-23.4-59.4-39.1-73.1l-1.1-1C231.5 47.7 224 40.1 224 24z"/></svg>`,
                    fitness: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M96 64c0-17.7 14.3-32 32-32h32c17.7 0 32 14.3 32 32V224v64V448c0 17.7-14.3 32-32 32H128c-17.7 0-32-14.3-32-32V384H64c-17.7 0-32-14.3-32-32V288c-17.7 0-32-14.3-32-32s14.3-32 32-32V160c0-17.7 14.3-32 32-32H96V64zm448 0v64h32c17.7 0 32 14.3 32 32v64c17.7 0 32 14.3 32 32s-14.3 32-32 32v64c0 17.7-14.3 32-32 32H544v64c0 17.7-14.3 32-32 32H480c-17.7 0-32-14.3-32-32V288 224 64c0-17.7 14.3-32 32-32h32c17.7 0 32 14.3 32 32zM416 224v64H224V224H416z"/></svg>`,
                    hair: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M256 192l-39.5-39.5c4.9-12.6 7.5-26.2 7.5-40.5C224 50.1 173.9 0 112 0S0 50.1 0 112s50.1 112 112 112c14.3 0 27.9-2.7 40.5-7.5L192 256l-39.5 39.5c-12.6-4.9-26.2-7.5-40.5-7.5C50.1 288 0 338.1 0 400s50.1 112 112 112s112-50.1 112-112c0-14.3-2.7-27.9-7.5-40.5L499.2 76.8c7.1-7.1 7.1-18.5 0-25.6c-28.3-28.3-74.1-28.3-102.4 0L256 192zm22.6 150.6L396.8 460.8c28.3 28.3 74.1 28.3 102.4 0c7.1-7.1 7.1-18.5 0-25.6L342.6 278.6l-64 64zM64 112a48 48 0 1 1 96 0 48 48 0 1 1 -96 0zm48 240a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"/></svg>`,
                    food: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M416 0C400 0 288 32 288 176V288c0 35.3 28.7 64 64 64h32V480c0 17.7 14.3 32 32 32s32-14.3 32-32V352 240 32c0-17.7-14.3-32-32-32zM64 16C64 7.8 57.9 1 49.7 .1S34.2 4.6 32.4 12.5L2.1 148.8C.7 155.1 0 161.5 0 167.9c0 45.9 35.1 83.6 80 87.7V480c0 17.7 14.3 32 32 32s32-14.3 32-32V255.6c44.9-4.1 80-41.8 80-87.7c0-6.4-.7-12.8-2.1-19.1L191.6 12.5c-1.8-8-9.3-13.3-17.4-12.4S160 7.8 160 16V150.2c0 5.4-4.4 9.8-9.8 9.8c-5.1 0-9.3-3.9-9.8-9L127.9 14.6C127.2 6.3 120.3 0 112 0s-15.2 6.3-15.9 14.6L83.7 151c-.5 5.1-4.7 9-9.8 9c-5.4 0-9.8-4.4-9.8-9.8V16zm48.3 152l-.3 0-.3 0 .3-.7 .3 .7z"/></svg>`,
                    elementaryschools: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.6.0 by @fontawesome  - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M96 0C43 0 0 43 0 96L0 416c0 53 43 96 96 96l288 0 32 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l0-64c17.7 0 32-14.3 32-32l0-320c0-17.7-14.3-32-32-32L384 0 96 0zm0 384l256 0 0 64L96 448c-17.7 0-32-14.3-32-32s14.3-32 32-32zm32-240c0-8.8 7.2-16 16-16l192 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-192 0c-8.8 0-16-7.2-16-16zm16 48l192 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-192 0c-8.8 0-16-7.2-16-16s7.2-16 16-16z"/></svg>`,
                };

                const categoryLabel = categories[sanitizedCategory] || category;
                const icon = icons[sanitizedCategory] || '';

                const link = createElement('a', {
                    'data-category': sanitizedCategory,
                    'class': `IDX-category ${sanitizedCategory === currentCategory ? 'selected' : ''}`,
                });

                link.innerHTML = `${icon} ${categoryLabel}`;
                categoriesContainer.appendChild(link);
            });

            const categoryElements = document.querySelectorAll('.IDX-category');
            categoryElements.forEach(categoryElement => {
                categoryElement.addEventListener('click', () => {
                    categoryElements.forEach(element => element.classList.remove('selected'));
                    categoryElement.classList.add('selected');
                    const newCategory = categoryElement.getAttribute('data-category');
                    categoryObserver(newCategory, currentCategory);
                    currentCategory = newCategory;
                });
            });
        };

        // // Create skeleton cards function
        const createSkeletonCards = () => {
            for (let i = 0; i < userOptions.limit; i++) {
                const card = createElement('div', {
                    class: 'IDX-yelp-card IDX-skeleton-shine'
                });

                skeletonCardsContainer.appendChild(card);
            }
        }

        const createCards = (businesses) => {
            if (businesses.length === 0) {
                const message = createElement("span", {}, "there are no results.");
                cardsContainer.appendChild(message);
            } else {
                businesses.forEach(business => {
                    const card = createElement('div', {
                        class: 'IDX-yelp-card',
                    });

                    const image = createElement('a', {
                        href: business.url,
                        target: "_blank",
                        class: 'IDX-yelp-image',
                        style: `background-image: url(${business.image_url})`
                    });

                    const info = createElement('div', {
                        class: 'IDX-yelp-info'
                    });

                    const leftInfo = createElement('div', {
                        class: 'IDX-yelp-info-left'
                    });

                    const rightInfo = createElement('div', {
                        class: 'IDX-yelp-info-right'
                    });

                    const name = createElement('a', {
                        href: business.url,
                        target: "_blank",
                        class: 'IDX-yelp-name',
                    }, business.name);

                    const starsLogoContainer = createElement('div', {
                        class: 'IDX-yelp-info-stars-logo-container'
                    });

                    const stars = createElement('div', {
                        class: `yelp-stars-${roundDownToNearest(business.rating, 0.5)}`,
                        role: 'img',
                        style: "background-image: url('https://s3-media0.fl.yelpcdn.com/assets/public/stars_v2.yji-59bbc2cf8e3d4be04fcc.png')"
                    });

                    const yelpLogoLink = createElement('a', {
                        href: "https://business.yelp.com/",
                        target: "_blank",
                        class: 'IDX-yelp-logo-link'
                    });

                    const reviews = createElement('p', {},
                        `${business.review_count} Reviews`);

                    // Building card structure
                    leftInfo.appendChild(name);

                    starsLogoContainer.appendChild(stars);
                    yelpLogoLink.innerHTML = `<svg width="70" height="70" viewBox="0 0 1000 385" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M806.495 227.151L822.764 223.392C823.106 223.313 823.671 223.183 824.361 222.961C828.85 221.753 832.697 218.85 835.091 214.862C837.485 210.874 838.241 206.113 837.198 201.582C837.175 201.483 837.153 201.388 837.13 201.289C836.596 199.117 835.66 197.065 834.37 195.239C832.547 192.926 830.291 190.991 827.728 189.542C824.711 187.821 821.553 186.358 818.289 185.171L800.452 178.659C790.441 174.937 780.432 171.309 770.328 167.771C763.776 165.439 758.224 163.394 753.4 161.901C752.49 161.62 751.485 161.34 750.669 161.058C744.837 159.271 740.739 158.53 737.272 158.506C734.956 158.421 732.649 158.841 730.511 159.738C728.283 160.699 726.282 162.12 724.639 163.906C723.822 164.835 723.054 165.806 722.337 166.815C721.665 167.843 721.049 168.907 720.491 170.001C719.876 171.175 719.348 172.392 718.911 173.642C715.6 183.428 713.951 193.7 714.032 204.029C714.091 213.368 714.342 225.354 719.475 233.479C720.712 235.564 722.372 237.366 724.348 238.769C728.004 241.295 731.7 241.627 735.544 241.904C741.289 242.316 746.855 240.905 752.403 239.623L806.45 227.136L806.495 227.151Z" fill="white"/>
<path d="M987.995 140.779C983.553 131.457 977.581 122.947 970.328 115.601C969.39 114.669 968.385 113.806 967.321 113.02C966.339 112.283 965.318 111.598 964.264 110.967C963.18 110.373 962.065 109.837 960.924 109.362C958.668 108.476 956.25 108.077 953.829 108.19C951.513 108.322 949.254 108.956 947.207 110.049C944.105 111.592 940.748 114.07 936.283 118.221C935.666 118.834 934.891 119.525 934.195 120.177C930.511 123.641 926.413 127.911 921.536 132.883C914.002 140.497 906.583 148.152 899.21 155.89L886.017 169.571C883.601 172.071 881.401 174.771 879.441 177.643C877.771 180.07 876.59 182.799 875.963 185.678C875.6 187.886 875.653 190.142 876.12 192.33C876.143 192.429 876.164 192.523 876.187 192.622C877.229 197.154 879.988 201.103 883.883 203.637C887.778 206.172 892.505 207.095 897.068 206.211C897.791 206.106 898.352 205.982 898.693 205.898L969.033 189.646C974.576 188.365 980.202 187.191 985.182 184.3C988.522 182.363 991.699 180.443 993.878 176.57C995.043 174.442 995.748 172.093 995.948 169.675C997.027 160.089 992.021 149.202 987.995 140.779Z" fill="white"/>
<path d="M862.1 170.358C867.197 163.955 867.184 154.41 867.64 146.607C869.174 120.536 870.79 94.4619 872.07 68.3766C872.56 58.4963 873.624 48.7498 873.036 38.7945C872.552 30.5816 872.492 21.1521 867.307 14.4122C858.154 2.52691 838.636 3.50374 825.319 5.34735C821.239 5.91362 817.153 6.67493 813.099 7.6481C809.045 8.62127 805.033 9.68413 801.108 10.9413C788.329 15.127 770.365 22.8103 767.323 37.5342C765.608 45.858 769.672 54.3727 772.824 61.9691C776.645 71.1774 781.865 79.4721 786.622 88.1401C799.198 111.024 812.008 133.765 824.782 156.53C828.597 163.326 832.755 171.933 840.135 175.454C840.623 175.667 841.121 175.856 841.628 176.019C844.937 177.272 848.545 177.513 851.993 176.712C852.201 176.664 852.405 176.617 852.608 176.57C855.792 175.704 858.675 173.973 860.937 171.568C861.345 171.185 861.734 170.782 862.1 170.358Z" fill="white"/>
<path d="M855.998 240.155C854.009 237.356 851.185 235.258 847.932 234.162C844.678 233.065 841.161 233.027 837.882 234.052C837.112 234.307 836.362 234.619 835.637 234.983C834.516 235.554 833.446 236.221 832.44 236.976C829.508 239.148 827.04 241.971 824.792 244.8C824.222 245.522 823.701 246.483 823.023 247.1L811.709 262.663C805.296 271.382 798.972 280.123 792.701 289.003C788.609 294.735 785.069 299.576 782.274 303.859C781.744 304.666 781.194 305.567 780.69 306.284C777.339 311.469 775.442 315.252 774.468 318.623C773.736 320.862 773.504 323.234 773.789 325.573C774.101 328.008 774.921 330.35 776.196 332.447C776.874 333.499 777.605 334.517 778.386 335.495C779.197 336.436 780.059 337.332 780.967 338.18C781.937 339.105 782.974 339.957 784.071 340.729C791.88 346.162 800.429 350.066 809.421 353.083C816.905 355.567 824.683 357.054 832.556 357.504C833.895 357.572 835.238 357.543 836.573 357.417C837.81 357.309 839.041 357.137 840.261 356.9C841.48 356.615 842.682 356.266 843.864 355.853C846.163 354.993 848.256 353.66 850.009 351.941C851.668 350.279 852.945 348.276 853.75 346.07C855.058 342.81 855.918 338.671 856.484 332.526C856.533 331.652 856.658 330.604 856.745 329.644C857.191 324.545 857.396 318.556 857.724 311.515C858.277 300.685 858.711 289.903 859.054 279.091C859.054 279.091 859.783 259.875 859.781 259.865C859.947 255.437 859.811 250.53 858.583 246.121C858.043 244.008 857.171 241.994 855.998 240.155V240.155Z" fill="white"/>
<path d="M983.707 270.24C981.346 267.651 978 265.069 972.722 261.878C971.961 261.453 971.068 260.886 970.244 260.392C965.85 257.749 960.557 254.969 954.374 251.611C944.876 246.396 935.372 241.312 925.778 236.271L908.825 227.28C907.946 227.024 907.053 226.389 906.225 225.99C902.968 224.432 899.516 222.978 895.932 222.311C894.697 222.074 893.444 221.944 892.186 221.923C891.375 221.913 890.565 221.962 889.761 222.07C886.371 222.595 883.234 224.178 880.795 226.592C878.356 229.005 876.74 232.128 876.178 235.514C875.919 237.667 875.998 239.847 876.411 241.976C877.24 246.487 879.254 250.95 881.338 254.858L890.391 271.824C895.428 281.394 900.526 290.907 905.752 300.391C909.123 306.578 911.929 311.872 914.557 316.26C915.055 317.085 915.62 317.974 916.046 318.738C919.245 324.013 921.815 327.333 924.421 329.715C926.109 331.345 928.132 332.586 930.349 333.352C932.68 334.124 935.146 334.398 937.59 334.156C938.832 334.008 940.066 333.795 941.286 333.516C942.488 333.193 943.672 332.808 944.833 332.362C946.087 331.89 947.305 331.327 948.478 330.678C955.36 326.82 961.703 322.07 967.345 316.552C974.112 309.894 980.093 302.633 984.745 294.321C985.392 293.145 985.952 291.924 986.422 290.667C986.86 289.504 987.24 288.319 987.558 287.118C987.834 285.896 988.045 284.662 988.191 283.418C988.422 280.977 988.138 278.514 987.358 276.19C986.591 273.963 985.345 271.932 983.707 270.24V270.24Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M400.03 105.19C400.03 91.2089 411.42 79.7877 425.167 79.7877C438.717 79.7877 449.714 91.2089 450.303 105.387V303.682C450.303 317.663 438.913 329.084 425.167 329.084C411.027 329.084 400.03 317.663 400.03 303.682V105.19ZM376.657 227.672C376.461 231.61 375.479 238.896 370.373 244.213C364.874 249.923 357.412 251.302 353.092 251.302C335.123 251.4 317.155 251.449 299.187 251.499C281.218 251.548 263.248 251.597 245.279 251.696C246.85 256.619 249.992 264.101 257.062 270.993C261.382 275.129 265.506 277.492 267.273 278.476C269.434 279.855 276.896 283.793 286.126 283.793C295.945 283.793 304.586 280.642 313.03 276.31L313.736 275.945C319.604 272.904 325.66 269.766 332.079 268.63C338.363 267.646 345.04 268.827 349.949 273.16C355.841 278.279 358.197 285.762 356.037 293.442C353.484 302.106 346.218 309.589 338.559 314.118C334.239 316.678 329.526 318.844 324.813 320.616C318.725 322.783 312.441 324.358 306.157 325.342C299.872 326.327 293.392 326.721 286.911 326.524H286.911C283.769 326.524 280.431 326.524 277.092 326.13C273.558 325.736 270.023 324.949 266.684 324.161C261.186 322.979 256.08 321.207 250.974 318.844C246.064 316.678 241.155 313.921 236.638 310.771C232.121 307.62 227.997 303.879 224.07 299.94C220.338 296.002 216.804 291.67 213.662 286.944C203.057 270.797 198.147 250.908 199.129 231.61C199.915 212.706 206.199 193.802 217.589 178.443C218.823 176.519 220.247 174.882 221.596 173.333C222.18 172.662 222.75 172.008 223.284 171.354C237.35 154.158 256.142 148.716 263.894 146.471L264.328 146.345C286.519 140.044 304.978 144.179 312.441 146.345C316.172 147.33 337.185 153.828 353.484 171.354C354.27 172.141 356.43 174.701 359.179 178.443C369.505 192.508 373.066 205.605 374.272 210.042L374.301 210.146C375.479 214.478 376.657 220.386 376.657 227.672ZM261.382 195.18C249.992 204.436 246.85 216.251 246.064 219.992H331.686C330.901 216.447 327.562 204.436 316.172 195.18C304.586 185.925 292.41 185.335 288.679 185.335C284.948 185.335 272.772 185.925 261.382 195.18ZM586.98 142.998C564.593 142.998 544.169 153.04 529.637 169.385V168.794C529.048 155.6 518.05 144.967 504.696 144.967C490.753 144.967 479.56 156.191 479.56 170.172V359.409C479.56 373.39 490.753 384.615 504.696 384.615C518.64 384.615 529.833 373.39 529.833 359.409V352.123V300.334C544.365 316.482 564.593 326.721 587.176 326.721C632.147 326.721 668.674 285.959 668.674 235.155C668.478 184.35 631.951 142.998 586.98 142.998ZM575.983 285.566C550.453 285.566 529.637 263.314 529.637 235.549C529.637 207.586 550.257 185.335 575.983 185.335C601.512 185.335 622.328 207.586 622.328 235.549C622.132 263.314 601.512 285.566 575.983 285.566ZM161.425 248.348L153.177 266.464C149.446 274.341 145.715 282.415 142.18 290.488C141.052 292.966 139.916 295.494 138.764 298.057C123.068 332.981 104.44 374.43 63.8242 383.236C44.1861 387.568 14.5327 381.661 3.5354 363.151C-7.4619 344.443 8.83767 322.979 29.8504 327.902C33.1646 328.641 36.4235 330.266 39.7101 331.904C45.187 334.635 50.7406 337.404 56.7545 336.173C62.4495 335.188 65.9844 331.053 70.5011 325.736C76.7853 318.45 79.5346 310.771 80.7129 306.242C80.6147 306.045 80.5165 305.799 80.4183 305.552C80.3201 305.306 80.2219 305.06 80.1237 304.863C75.0117 295.326 70.5473 286.8 66.8178 279.677C64.3868 275.034 62.2681 270.987 60.4857 267.646C56.8287 260.714 54.0662 255.473 51.918 251.398C45.6449 239.497 44.609 237.532 41.8296 232.398C35.7418 220.78 29.2612 209.555 22.5843 198.331C15.3182 186.122 7.85577 172.535 13.9436 158.16C18.8531 146.542 31.4214 140.634 43.4006 144.376C56.0403 148.212 61.6377 160.239 66.8724 171.487C67.8188 173.52 68.7534 175.528 69.7156 177.458C78.16 194.196 86.4079 210.934 94.6559 227.672C95.382 229.336 96.4917 231.605 97.8402 234.362C99.0447 236.824 100.44 239.676 101.922 242.834C102.697 244.475 103.434 246.002 104.101 247.382C104.954 249.149 105.691 250.676 106.242 251.892C110.072 242.342 113.95 232.841 117.829 223.34C121.707 213.839 125.586 204.337 129.415 194.787C129.522 194.253 130.436 192.216 131.813 189.145C132.977 186.549 134.473 183.215 136.092 179.427C136.64 178.133 137.191 176.79 137.755 175.417C142.856 162.995 148.988 148.06 162.604 143.982C172.423 141.028 183.42 144.967 189.115 153.237C192.061 157.372 193.239 162.098 193.435 166.824C193.593 177.275 188.545 188.491 184.212 198.115C183.157 200.459 182.144 202.708 181.26 204.829C181.219 204.91 181.048 205.296 180.739 205.988C179.541 208.679 176.278 216.005 170.655 228.066C168.626 232.389 166.679 236.713 164.707 241.09C163.626 243.491 162.538 245.907 161.425 248.348Z" fill="white"/>
<path d="M687.728 310.153H689.549C690.447 310.153 691.167 309.923 691.706 309.462C692.256 308.991 692.532 308.395 692.532 307.676C692.532 306.833 692.29 306.232 691.807 305.873C691.324 305.502 690.56 305.316 689.515 305.316H687.728V310.153ZM695.043 307.608C695.043 308.507 694.801 309.305 694.318 310.002C693.846 310.687 693.178 311.198 692.313 311.535L696.324 318.193H693.492L690.004 312.226H687.728V318.193H685.234V303.176H689.633C691.498 303.176 692.863 303.541 693.728 304.271C694.605 305.002 695.043 306.114 695.043 307.608ZM677.228 310.676C677.228 308.429 677.79 306.322 678.914 304.356C680.037 302.389 681.582 300.839 683.549 299.704C685.515 298.569 687.633 298.002 689.902 298.002C692.15 298.002 694.256 298.564 696.223 299.687C698.189 300.811 699.74 302.356 700.874 304.322C702.009 306.288 702.577 308.406 702.577 310.676C702.577 312.889 702.032 314.968 700.942 316.912C699.852 318.856 698.324 320.412 696.358 321.58C694.391 322.749 692.24 323.333 689.902 323.333C687.577 323.333 685.431 322.755 683.464 321.597C681.498 320.429 679.964 318.873 678.863 316.929C677.773 314.985 677.228 312.901 677.228 310.676ZM678.998 310.676C678.998 312.62 679.487 314.44 680.464 316.137C681.442 317.822 682.773 319.153 684.459 320.131C686.155 321.097 687.97 321.58 689.902 321.58C691.858 321.58 693.672 321.092 695.346 320.114C697.02 319.137 698.346 317.816 699.324 316.153C700.313 314.479 700.807 312.653 700.807 310.676C700.807 308.721 700.318 306.906 699.341 305.232C698.363 303.558 697.037 302.232 695.363 301.255C693.7 300.266 691.88 299.771 689.902 299.771C687.947 299.771 686.133 300.26 684.459 301.238C682.785 302.215 681.453 303.541 680.464 305.215C679.487 306.878 678.998 308.698 678.998 310.676Z" fill="white"/>
</svg>
`;

                    leftInfo.appendChild(starsLogoContainer);
                    leftInfo.appendChild(reviews);

                    rightInfo.appendChild(yelpLogoLink);

                    info.appendChild(leftInfo);
                    info.appendChild(rightInfo);

                    card.appendChild(info);
                    card.appendChild(image);

                    // adding card to the container
                    cardsContainer.appendChild(card);
                });
            }
        };

        const loadingObserver = (isLoading) => {
            skeletonCardsContainer.style.display = isLoading ? 'flex' : 'none';
            cardsContainer.innerHTML = '';
        };

        const categoryObserver = async (newCategory, currentCategory) => {
            if (newCategory !== currentCategory) {
                const newOptions = {
                    ...businessesOptions,
                    category: newCategory
                };
                try {
                    const businesses = await getBusinesses(newOptions);
                    businessesData.length = 0; // Clear existing data array
                    Array.prototype.push.apply(businessesData, businesses.businesses);
                    createCards(businessesData);
                } catch (error) {
                    console.error("Error getting businesses:", error.message);
                } finally {
                    currentCategory = newCategory;
                }
            }
        };

        // Event Listeners
        document.addEventListener('DOMContentLoaded', async () => {
            createCategoryLinks(); // Create category links
            createSkeletonCards(); // Create skeleton cards
            try {
                const businesses = await getBusinesses(businessesOptions);
                Array.prototype.push.apply(businessesData, businesses.businesses);
                createCards(businessesData);
            } catch (error) {
                console.error("Error getting businesses:", error.message);
            }
        });

    }

