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B,KAAI,SAAAT,GAAG,OAAIA,EAAIU,QAAQ,mB,2BAGhC,SAAcC,GACV,IAAKA,EAAM,OAAO,EAElB,IAAMC,EAAWxB,MAAMC,KAAKsB,EAAKC,UAC5BL,QAAO,SAAAM,GAAK,MAAuB,UAAnBA,EAAMC,UAChBD,EAAME,UAAUC,cAAcxC,SAAS,yBAElD,OAAOoC,GAAYA,EAAS5B,OAAS,I,gCAGzC,SAAmBW,GACf,QAASA,EAAOL,iBAAiB,uBAAuBN,UAAYW,EAAOL,iBAAiB,eAAeN,S,4BAG/G,SAAegB,GACX,GAAIA,EAAK,CACLA,EAAIe,UAAY,GAEhBf,EAAIiB,YAAYpH,SAASqH,cAAc,OAEvC,IAAIC,EAAetH,SAASqH,cAAc,OAC1CC,EAAaC,MAAMC,OAAS,IAC5BF,EAAaC,MAAME,QAAU,gBAC7BH,EAAaI,UAAY,4BAEzB,IAAIC,EAAU3H,SAASqH,cAAc,QACrCM,EAAQC,YAAc,oEACtBN,EAAaF,YAAYO,GAEzB,IAAIE,EAAO7H,SAASqH,cAAc,KAClCQ,EAAKC,KAAO,qDACZD,EAAKpH,OAAS,SACdoH,EAAKD,YAAc,aACnBC,EAAKE,UAAY,aACjBT,EAAaF,YAAYS,GAEzB,IAAIG,EAAWhI,SAASqH,cAAc,QACtCW,EAASJ,YAAc,gEACvBN,EAAaF,YAAYY,GAEzB7B,EAAIiB,YAAYE,Q,EA9ZtBxJ,G","sources":["webpack://umms-html/./FrontEndSrc/modules/macro/fad/fad.js"],"sourcesContent":["import { Loader } from '@googlemaps/js-api-loader';\r\n\r\nclass FAD {\r\n    component;\r\n    location;\r\n    lat;\r\n    long;\r\n    sortHandle;\r\n    sortForm;\r\n\r\n    ui;\r\n    disableEnter = true;\r\n\r\n    loaderPromise;\r\n    loaderStatus;\r\n    geocoder;\r\n    userPosition;\r\n    userLocation;\r\n    GOOGLE_API_KEY;\r\n    locationBounds;\r\n    placesService;\r\n    userGeolocationActive = false;\r\n\r\n    sortChanged = false;\r\n\r\n    constructor(element) {\r\n        this.component = $(element);\r\n        this.location = this.component.find('.js-fad-location');\r\n        this.lat = this.component.find('.js-fad-lat');\r\n        this.long = this.component.find('.js-fad-long');\r\n        this.sortHandle = $('.js-fad-sort-handle');\r\n        this.sortForm = $('.search-sort-form')\r\n\r\n        this.ui = {\r\n            form: $(element).find('form.search-bar'),\r\n            keyword: $(element).find('.search-bar__cell-keyword input'),\r\n            location: $(element).find('.search-bar__cell-location input'),\r\n            options: $(element).find('.search-bar__cell-additional input'),\r\n            validation: $(element).find('.search-bar__cell-validation'),\r\n            geolocate: $(element).find('.js-fad-geolocate'),\r\n            submit: $(element).find('.search-bar__cell-submit button'),\r\n            hiddenInputs: {\r\n                lat: $('.js-fad-lat'),\r\n                long: $('.js-fad-long'),\r\n                address: $('.js-fad-address')\r\n            }\r\n        };\r\n\r\n        if (new URL(window.location).hostname === 'localhost') {\r\n            this.GOOGLE_API_KEY = 'AIzaSyAe1RfKCz5J2qHj7KOjKyRawTbhPgtONM0';\r\n        }\r\n        else {\r\n            this.GOOGLE_API_KEY = this.component.data('google-api');\r\n        }\r\n\r\n        this.PlacesAutocomplete();\r\n        this.formValidate(false, false);\r\n\r\n        this.ui.geolocate.on('click', () => {\r\n            this.userGeolocationActive = false;\r\n            this.GetUserCurrentLocation();\r\n        });\r\n\r\n        this.ui.form.on('submit', e => {\r\n            e.preventDefault();\r\n            this.formValidate(true);\r\n        });\r\n\r\n        this.ui.keyword.on('input', () => {\r\n            this.formValidate();\r\n        });\r\n\r\n        this.ui.location.on('input', e => {\r\n            this.userGeolocationActive = false;\r\n            this.formValidate();\r\n        });\r\n\r\n        this.ui.options.one('change', () => {\r\n            this.formValidate();\r\n        });\r\n\r\n        this.sortHandle.on('change', e => {\r\n            this.SortHandle(e);\r\n        });\r\n\r\n        $(document).ready(function () {\r\n            $('[id^=\"search-results__embed-container-\"]').each(function () {\r\n                const $p = $('<p>').text('New Patient Visits');\r\n                $(this).before($p);\r\n            });\r\n        });\r\n\r\n        // Implement hide-iframe from https://berndtgroup.atlassian.net/browse/UMMRET-1935\r\n        window.addEventListener(\"load\", this.checkEpicIframes());\r\n    }\r\n\r\n    SortHandle(e) {\r\n        const val = $(e.target).val();\r\n        this.sortChanged = true;\r\n\r\n        $('.js-fad-sort').val(val);\r\n\r\n        this.sortForm.trigger('submit');\r\n\r\n        // if (val.length && val === 'Distance' ) {\r\n        //     this.ui.form.trigger('submit');\r\n        // } else {\r\n        //     $('.js-fad-sort').closest('form').trigger('submit');\r\n        // }\r\n    }\r\n\r\n    async formValidate(trigger = false, showMessage = true) {\r\n        if (!this.ui.keyword.val()) {\r\n            if (showMessage) {\r\n                this.ui.validation\r\n                    .addClass('is-active')\r\n                    .removeAttr('aria-hidden');\r\n\r\n                this.ui.keyword\r\n                    .attr('aria-describedby', 'site-search__validation');\r\n            }\r\n\r\n            this.ui.submit\r\n                .attr('disabled', 'disabled');\r\n        }\r\n        else {\r\n            this.ui.validation\r\n                .removeClass('is-active')\r\n                .attr('aria-hidden', 'true');\r\n\r\n            this.ui.keyword\r\n                .removeAttr('aria-describedby');\r\n\r\n            this.ui.submit\r\n                .removeAttr('disabled');\r\n\r\n            if (trigger) {\r\n                const locationQuery = this.ui.location.val();\r\n                if (locationQuery) {\r\n                    if (!this.userGeolocationActive) {\r\n                        await this.GetCoordinatesFromAddress(locationQuery);\r\n                    }\r\n                } else {\r\n                    // Clear hidden location inputs if user cleared location input\r\n                    this.ui.hiddenInputs.lat.val('');\r\n                    this.ui.hiddenInputs.long.val('');\r\n                    this.ui.hiddenInputs.address.val('');\r\n                }\r\n\r\n                // console.log('lat', this.ui.hiddenInputs.lat.val());\r\n                // console.log('lng', this.ui.hiddenInputs.long.val());\r\n                // console.log('location', $('.js-fad-location').val());\r\n                // console.log('address', this.ui.hiddenInputs.address.val());\r\n                // console.log('sort', $('.js-fad-sort').val());\r\n                this.ui.form.off();\r\n                this.ui.form.trigger('submit');\r\n            }\r\n        }\r\n    }\r\n\r\n    async LoadMapsAPI() {\r\n        if (!this.loaderPromise || this.loaderStatus === 'fail') {\r\n            this.loaderPromise = window.UMMS && window.UMMS.mapsLoader ? window.UMMS.mapsLoader : new Loader({\r\n                apiKey: this.GOOGLE_API_KEY,\r\n                libraries: ['geometry', 'places']\r\n            }).load();\r\n\r\n            window.UMMS = window.UMMS || {};\r\n            window.UMMS.mapsLoader = this.loaderPromise;\r\n\r\n            this.loaderPromise\r\n                .then(() => {\r\n                    // console.log('Google Maps API successfully loaded.')\r\n\r\n                    this.loaderStatus = 'success';\r\n\r\n                    if (this.geocoder) {\r\n                        return;\r\n                    }\r\n\r\n                    this.geocoder = window.UMMS.mapsGeocoder || new google.maps.Geocoder();\r\n                    window.UMMS.mapsGeocoder = this.geocoder;\r\n                    const sw = new google.maps.LatLng(39.141032, -76.7175347, 13.46);\r\n                    const ne = new google.maps.LatLng(39.3671101, -76.381562);\r\n                    this.locationBounds = new google.maps.LatLngBounds(sw, ne)\r\n                })\r\n                .catch(err => {\r\n                    console.error('Maps API error:', err);\r\n                    this.loaderStatus = 'fail';\r\n                });\r\n        }\r\n\r\n        return this.loaderPromise;\r\n    }\r\n\r\n    async PlacesAutocomplete() {\r\n        if (!this.geocoder) {\r\n            await this.LoadMapsAPI();\r\n        }\r\n\r\n        let autocomplete;\r\n\r\n        const $input = this.location;\r\n\r\n        if (!$input.data('autocomplete-initialized')) {\r\n            autocomplete = new google.maps.places.Autocomplete($input.get(0), {\r\n                types: ['(regions)'],\r\n                bounds: this.locationBounds,\r\n                componentRestrictions: { country: 'us' },\r\n                fields: ['formatted_address']\r\n            });\r\n\r\n            $input.attr('data-autocomplete-initialized', 'true');\r\n        }\r\n\r\n        $input.on('keypress', e => {\r\n            if (event.keyCode === 13 && this.disableEnter) {\r\n                e.preventDefault();\r\n            }\r\n        });\r\n\r\n        $input.on('input', () => {\r\n            this.disableEnter = true;\r\n        });\r\n\r\n        return autocomplete;\r\n    }\r\n\r\n    async TryUserGeolocation() {\r\n        if (navigator.geolocation) {\r\n            return new Promise((resolve, reject) => {\r\n                navigator.geolocation.getCurrentPosition(resolve, reject);\r\n            });\r\n        } else {\r\n            // console.error('No browser geolocation support.');\r\n            return false;\r\n        }\r\n    }\r\n\r\n    async GetUserCurrentLocation() {\r\n        if (this.userLocation) {\r\n            return this.userLocation;\r\n        }\r\n\r\n        if (!this.userPosition) {\r\n            this.userPosition = await this.TryUserGeolocation();\r\n        }\r\n\r\n        const location = {\r\n            lat: this.userPosition.coords.latitude,\r\n            lng: this.userPosition.coords.longitude\r\n        };\r\n\r\n        if (!location.lat || !location.lng) {\r\n            // console.error('Error retrieving user location');\r\n            return;\r\n        }\r\n\r\n        // console.log(`Geocoding user location: `, {location});\r\n\r\n        if (!this.geocoder) {\r\n            await this.LoadMapsAPI();\r\n        }\r\n\r\n        // console.time('Geocode user location')\r\n\r\n        return await this.geocoder.geocode({ location }).then(geocodedAddresses => {\r\n            // console.timeEnd('Geocode user location')\r\n\r\n            const addressComponents = geocodedAddresses.results[0].address_components,\r\n                cityComponent = addressComponents.find(component => component.types.includes('locality')),\r\n                city = cityComponent ? cityComponent.short_name : undefined,\r\n                stateComponent = addressComponents.find(component => component.types.includes('administrative_area_level_1')),\r\n                state = stateComponent ? stateComponent.short_name : undefined;\r\n\r\n            let name = city || state;\r\n\r\n            if (city && state) {\r\n                name += `, ${state}`;\r\n            }\r\n\r\n            this.userLocation = {\r\n                name,\r\n                location,\r\n                isCurrentLocation: true\r\n            };\r\n\r\n            this.ui.hiddenInputs.lat.val(location.lat);\r\n            this.ui.hiddenInputs.long.val(location.lng);\r\n            this.ui.hiddenInputs.address.val(name);\r\n            $('.js-fad-location').val(name);\r\n            if (!this.sortChanged) {\r\n                $('.js-fad-sort').val('Distance');\r\n            }\r\n\r\n            this.userGeolocationActive = true;\r\n            this.disableEnter = false;\r\n\r\n            return this.userLocation;\r\n        });\r\n    }\r\n\r\n    async GetCoordinatesFromAddress(address) {\r\n        if (!address.length) {\r\n            console.error({ address });\r\n            return\r\n        }\r\n\r\n        if (!this.geocoder) {\r\n            await this.LoadMapsAPI();\r\n        }\r\n\r\n        // console.time('Reverse geocode address')\r\n\r\n        return this.geocoder.geocode({ address, bounds: this.locationBounds }).then(async results => {\r\n            // console.log({address, results})\r\n            const location = {\r\n                lat: results.results[0].geometry.location.lat(),\r\n                lng: results.results[0].geometry.location.lng(),\r\n                address: results.results[0].formatted_address\r\n            };\r\n\r\n            this.ui.hiddenInputs.lat.val(location.lat);\r\n            this.ui.hiddenInputs.long.val(location.lng);\r\n            this.ui.hiddenInputs.address.val(location.address);\r\n            if (!this.sortChanged) {\r\n                $('.js-fad-sort').val('Distance');\r\n            }\r\n        });\r\n    }\r\n\r\n    // Implement hide-iframe from https://berndtgroup.atlassian.net/browse/UMMRET-1935\r\n    checkEpicIframes() {\r\n        const epicIframeContainers = Array.from(document.querySelectorAll(\"[id^='search-results__embed-container']\"))\r\n        // console.log({epicIframeContainers})\r\n        if (!epicIframeContainers.length) return\r\n\r\n        let iframesUpdated = 0\r\n        const interval = setInterval(() => {\r\n            epicIframeContainers.forEach(iframe => {\r\n                // Only check iframes that haven't already been corrected\r\n                if (!iframe.classList.contains('updated')) {\r\n                    const elementsToReplace = this.getElementsToReplace(iframe)\r\n                    // console.log({iframe, elementsToReplace})\r\n                    elementsToReplace.forEach((ele) => {\r\n                        this.replaceContent(ele);\r\n                    });\r\n\r\n                    // After replacing elements, or if the iframe loaded properly - add class to indicate that iframe is updated\r\n                    if (elementsToReplace.length || this.checkIframeSuccess(iframe)) {\r\n                        iframe.classList.add('updated')\r\n                        iframesUpdated += 1\r\n                    }\r\n                }\r\n            })\r\n\r\n            // Stop interval loop if we've corrected all iframes on the page\r\n            if (iframesUpdated === epicIframeContainers.length) clearInterval(interval)\r\n        }, 1000);\r\n    }\r\n\r\n    getElementsToReplace(iframe) {\r\n        return [...this.getNoData(iframe), ...this.getNotFound(iframe)];\r\n    }\r\n\r\n    getNotFound(iframe) {\r\n        return Array.from(iframe.querySelectorAll(\".myc_osSimpleWidget\"))\r\n            .filter(ele => this.checkNotFound(ele))\r\n            .map(ele => ele.closest(\".grid-cell\"));\r\n    }\r\n\r\n    getNoData(iframe) {\r\n        return Array.from(iframe.querySelectorAll(\".myc_noData\"))\r\n            .map(ele => ele.closest(\".grid-cell\"));\r\n    }\r\n\r\n    checkNotFound(cell) {\r\n        if (!cell) return false;\r\n\r\n        const children = Array.from(cell.children)\r\n            .filter(child => child.nodeName === 'TITLE'\r\n                && child.innerHTML.toLowerCase().includes('500 - server error'));\r\n\r\n        return children && children.length > 0;\r\n    }\r\n\r\n    checkIframeSuccess(iframe) {\r\n        return !!iframe.querySelectorAll('.myc_slotsContainer').length || !!iframe.querySelectorAll('.myc_button').length\r\n    }\r\n\r\n    replaceContent(ele) {\r\n        if (ele) {\r\n            ele.innerHTML = \"\";\r\n\r\n            ele.appendChild(document.createElement(\"hr\"));\r\n\r\n            var newContainer = document.createElement(\"div\");\r\n            newContainer.style.margin = \"0\";\r\n            newContainer.style.padding = \"1rem 0 1rem 0\";\r\n            newContainer.className = \"no_appointments_container\";\r\n\r\n            var newSpan = document.createElement(\"span\");\r\n            newSpan.textContent = \"This provider does not have available appointments at this time. \"\r\n            newContainer.appendChild(newSpan);\r\n\r\n            var link = document.createElement(\"a\");\r\n            link.href = \"https://myportfolio.umm.edu/MyChart/openscheduling\";\r\n            link.target = \"_blank\";\r\n            link.textContent = \"Click here\";\r\n            link.ariaLabel = \"click here\"\r\n            newContainer.appendChild(link);\r\n\r\n            var nextSpan = document.createElement(\"span\");\r\n            nextSpan.textContent = \" to make a new patient appointment with a different provider.\"\r\n            newContainer.appendChild(nextSpan);\r\n\r\n            ele.appendChild(newContainer);\r\n        }\r\n    }\r\n}\r\n\r\nexport default FAD;\r\n"],"names":["FAD","element","this","component","$","location","find","lat","sortHandle","sortForm","ui","form","keyword","options","validation","geolocate","submit","hiddenInputs","long","address","URL","window","hostname","GOOGLE_API_KEY","data","PlacesAutocomplete","formValidate","on","userGeolocationActive","GetUserCurrentLocation","e","preventDefault","one","SortHandle","document","ready","each","$p","text","before","addEventListener","checkEpicIframes","val","target","sortChanged","trigger","showMessage","addClass","removeAttr","attr","removeClass","locationQuery","GetCoordinatesFromAddress","off","loaderPromise","loaderStatus","UMMS","mapsLoader","Loader","apiKey","libraries","load","then","geocoder","mapsGeocoder","google","maps","Geocoder","sw","LatLng","ne","locationBounds","LatLngBounds","err","console","error","LoadMapsAPI","$input","autocomplete","places","Autocomplete","get","types","bounds","componentRestrictions","country","fields","event","keyCode","disableEnter","navigator","geolocation","Promise","resolve","reject","getCurrentPosition","userLocation","userPosition","TryUserGeolocation","coords","latitude","lng","longitude","geocode","geocodedAddresses","addressComponents","results","address_components","cityComponent","includes","city","short_name","undefined","stateComponent","state","name","isCurrentLocation","length","geometry","formatted_address","epicIframeContainers","Array","from","querySelectorAll","iframesUpdated","interval","setInterval","forEach","iframe","classList","contains","elementsToReplace","getElementsToReplace","ele","replaceContent","checkIframeSuccess","add","clearInterval","getNoData","getNotFound","filter","checkNotFound","map","closest","cell","children","child","nodeName","innerHTML","toLowerCase","appendChild","createElement","newContainer","style","margin","padding","className","newSpan","textContent","link","href","ariaLabel","nextSpan"],"sourceRoot":""}