{"version":3,"file":"mapsLoadingScript.min.js","names":["ils","loadMapScripts","callbackFunction","googleMapsScript","document","createElement","markerClustererScript","infoBoxScript","showcaseMapsScript","src","googleMapsSrc","async","setAttribute","markerClustererSrc","infoBoxSrc","showcaseMapSrc","onload","globalThis","mapsAreInitialized","initMapScripts","callbackCheckPromise","Promise","resolve","setTimeout","querySelector","addEventListener","drawingHelpElement","style","display","body","appendChild","onGoogleMapsLoaded","initialItems","length","showcaseListings","viewModel","TotalRowCount","Listings","polygonCoordinates","polygontimeout","isInitialLoad","LazyLoadedListings","PageNumber","LoadNextSet","LoadNewSet","clearTimeout","initializeMap","map","fitBounds","bounds","setMapZoomTimeout","setMapZoom","loadingMaps"],"sources":["core/showcase/mapsLoadingScript.js"],"mappings":"AAAA,IAAIA,KACJ,SAAWA,GA+CP,GADAA,EAAIC,eA7CJ,SAAwBC,GACpB,IAAIC,EAAmBC,SAASC,cAAc,UAC1CC,EAAwBF,SAASC,cAAc,UAC/CE,EAAgBH,SAASC,cAAc,UACvCG,EAAqBJ,SAASC,cAAc,UAChDF,EAAiBM,IAAM,GAAGT,EAAIU,4CAC9BP,EAAiBQ,OAAQ,EACzBL,EAAsBM,aAAa,MAAOZ,EAAIa,oBAC9CN,EAAcK,aAAa,MAAOZ,EAAIc,YACtCN,EAAmBI,aAAa,MAAOZ,EAAIe,gBAC3CP,EAAmBQ,OAASL,iBACxB,IAAKM,WAAWC,mBAAoB,CAChCC,IACA,MAAMC,EAAuB,IAAIC,SAASC,IACtCC,YAAWZ,UACHT,SACMA,IAEVoB,GAAS,GACV,GAAG,UAEJF,CACV,CACAhB,SAASoB,cAAc,4BAA4BC,iBAAiB,SAAS,WACzE,IAAIC,EAAqBtB,SAASoB,cAAc,4BAEhD,OADAE,EAAmBC,MAAMC,QAA+C,SAArCF,EAAmBC,MAAMC,QAAqB,GAAK,QAC/E,CACX,GACJ,EACAtB,EAAsBU,OAAS,WAC3BZ,SAASyB,KAAKC,YAAYvB,EAC9B,EACAA,EAAcS,OAAS,WACnBZ,SAASyB,KAAKC,YAAYtB,EAC9B,EAKAS,WAAWc,mBAAqB,WAC5B3B,SAASyB,KAAKC,YAAYxB,EAC9B,EAEAF,SAASyB,KAAKC,YAAY3B,EAC9B,EAEIc,WAAWe,cAAgBf,WAAWe,aAAaC,OAAS,IAC5DjC,EAAIkC,iBAAiBC,UAAUC,cAAcnB,WAAWe,aAAa,GAAGI,eACxEpC,EAAIkC,iBAAiBC,UAAUE,SAASpB,WAAWe,cAC/CM,oBAIA,IAAIC,EAAiBhB,YAAWZ,iBAE5B,KAAOM,WAAWuB,eAAiBxC,EAAIkC,iBAAiBC,UAAUM,qBAAqBR,OAAS,SACtF,IAAIZ,SAASC,GAAYC,WAAWD,EAAS,OAGvDtB,EAAIkC,iBAAiBC,UAAUM,mBAAmB,IAClDzC,EAAIkC,iBAAiBC,UAAUO,WAAW,SAEpC1C,EAAIkC,iBAAiBS,cAG3B1B,WAAWe,aAAehC,EAAIkC,iBAAiBC,UAAUE,WAGzDpB,WAAWuB,eAAgB,QAErBxC,EAAIkC,iBAAiBU,aAC3BC,aAAaN,EACjB,GAAG,KAGX,SAASpB,IACLnB,EAAIkC,iBAAiBY,gBACrB9C,EAAIkC,iBAAiBa,IAAIC,UAAUhD,EAAIkC,iBAAiBe,QACxD,IAAIC,EAAoB3B,YAAW,WAC/BvB,EAAIkC,iBAAiBiB,WAAW,IAChCN,aAAaK,EACjB,GAAG,IACHjC,WAAWC,oBAAqB,EAChCD,WAAWmC,aAAc,CAC7B,CACApD,EAAImB,eAAiBA,CACxB,CAvFD,CAuFGnB,MAAQA,IAAM,CAAC","sourcesContent":["var ils;\n(function (ils) {\n function loadMapScripts(callbackFunction) {\n var googleMapsScript = document.createElement('script');\n var markerClustererScript = document.createElement('script');\n var infoBoxScript = document.createElement('script');\n var showcaseMapsScript = document.createElement('script');\n googleMapsScript.src = `${ils.googleMapsSrc}&callback=onGoogleMapsLoaded`;\n googleMapsScript.async = true;\n markerClustererScript.setAttribute(\"src\", ils.markerClustererSrc);\n infoBoxScript.setAttribute(\"src\", ils.infoBoxSrc);\n showcaseMapsScript.setAttribute(\"src\", ils.showcaseMapSrc);\n showcaseMapsScript.onload = async function () {\n if (!globalThis.mapsAreInitialized) {\n initMapScripts();\n const callbackCheckPromise = new Promise((resolve) => {\n setTimeout(async () => {\n if (callbackFunction) {\n await callbackFunction();\n }\n resolve();\n }, 50);\n });\n await callbackCheckPromise;\n }\n document.querySelector(\".map-tools .instructions\").addEventListener('click', function () {\n var drawingHelpElement = document.querySelector(\".map-tools .drawing-help\");\n drawingHelpElement.style.display = drawingHelpElement.style.display === \"none\" ? \"\" : \"none\";\n return false;\n });\n };\n markerClustererScript.onload = function () {\n document.body.appendChild(infoBoxScript);\n };\n infoBoxScript.onload = function () {\n document.body.appendChild(showcaseMapsScript);\n };\n /**\n * Callback function for when Google Maps is loaded. This is defined in the script tag\n * src attribute as a query parameter.\n */\n globalThis.onGoogleMapsLoaded = function () {\n document.body.appendChild(markerClustererScript);\n };\n // Append the Google Maps script tag to the body so we trigger the download of the script\n document.body.appendChild(googleMapsScript);\n }\n ils.loadMapScripts = loadMapScripts;\n if (globalThis.initialItems && globalThis.initialItems.length > 0) {\n ils.showcaseListings.viewModel.TotalRowCount(globalThis.initialItems[0].TotalRowCount);\n ils.showcaseListings.viewModel.Listings(globalThis.initialItems);\n if (polygonCoordinates) {\n // Since polygon coordinates can only be decoded by the browser (using Google maps javascript sdk), the \n // initial server load will not be able to apply that filter. For that reason, we need to load a new\n // set of items after the initial load is done.\n var polygontimeout = setTimeout(async function () {\n // Wait for the initial load to finish.\n while (globalThis.isInitialLoad || ils.showcaseListings.viewModel.LazyLoadedListings().length > 0) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n // Reset the lazy loaded listings and page number to 1 so that we can start fresh\n ils.showcaseListings.viewModel.LazyLoadedListings([]);\n ils.showcaseListings.viewModel.PageNumber(1);\n // Load a new first page of items by calling LoadNextSet\n await ils.showcaseListings.LoadNextSet();\n // Set the initialItems value to the new set of items. We do this because we're basically\n // starting the page load over again.\n globalThis.initialItems = ils.showcaseListings.viewModel.Listings();\n // Set the isInitialLoad flag to true so that the next time we load a new set of items, we don't \n // go to the server, but instead use the initialItems value.\n globalThis.isInitialLoad = true;\n // Kick off a LoadNewSet call so that we can run through the pages of results\n await ils.showcaseListings.LoadNewSet();\n clearTimeout(polygontimeout);\n }, 500);\n }\n }\n function initMapScripts() {\n ils.showcaseListings.initializeMap();\n ils.showcaseListings.map.fitBounds(ils.showcaseListings.bounds);\n var setMapZoomTimeout = setTimeout(function () {\n ils.showcaseListings.setMapZoom(17);\n clearTimeout(setMapZoomTimeout);\n }, 10);\n globalThis.mapsAreInitialized = true;\n globalThis.loadingMaps = false;\n }\n ils.initMapScripts = initMapScripts;\n})(ils || (ils = {}));\n"]}