{"version":3,"sources":["JavaScript/InitializeLocatorMessaging.js"],"names":["initializeLocatorMessaging","undefined","window","PubSub","Engage","Locator","Messaging","locatorMessagePrefix","messageTypes","validateZipCode","concat","zipCodeValidationResult","locationUpdate","resetSearchFrom","newQueryFilters","boundingBoxUpdate","newLocations","showLoading","advancedSearch","trackEvent","resetCustomFilters","refreshLocation","publish","messageType","payload","startsWithMessagePrefix","subscribe","subscriber","unsubscribe","setTimeout","searchStr","substr"],"mappings":"CAKM,SAASA,IACd,aAEA,QAAsBC,IAAlBC,OAAOC,OAAX,CAMAD,OAAOE,OAASF,OAAOE,QAAU,CAAC,EAKlCA,OAAOC,QAAUD,OAAOC,SAAW,CAAC,EAKpCD,OAAOC,QAAQC,UAAYF,OAAOC,QAAQC,WAAa,CAAC,EAOxD,IAAMC,EAAuB,iBA4B7BH,OAAOC,QAAQC,UAAUC,qBAAuBA,EAiBhDH,OAAOC,QAAQC,UAAUE,aAAe,CACvCC,gBAAe,GAAAC,OAAKH,EAAoB,oBACxCI,wBAAuB,GAAAD,OAAKH,EAAoB,4BAChDK,eAAc,GAAAF,OAAKH,EAAoB,mBACvCM,gBAAe,GAAAH,OAAKH,EAAoB,oBACxCO,gBAAe,GAAAJ,OAAKH,EAAoB,oBACxCQ,kBAAiB,GAAAL,OAAKH,EAAoB,sBAC1CS,aAAY,GAAAN,OAAKH,EAAoB,iBACrCU,YAAW,GAAAP,OAAKH,EAAoB,gBACpCW,eAAc,GAAAR,OAAKH,EAAoB,mBACvCY,WAAU,GAAAT,OAAKH,EAAoB,eACnCa,mBAAkB,GAAAV,OAAKH,EAAoB,uBAC3Cc,gBAAe,GAAAX,OAAKH,EAAoB,qBAazCH,OAAOC,QAAQC,UAAUgB,QAAU,SAACC,EAAaC,GAC3CC,EAAwBF,IAI7BpB,OAAOmB,QAAQC,EAAaC,EAC7B,EA0BApB,OAAOC,QAAQC,UAAUoB,UAAY,SAACH,EAAaI,GAC7CF,EAAwBF,IAI7BpB,OAAOuB,UAAUH,EAAaI,EAC/B,EAEAvB,OAAOC,QAAQC,UAAUsB,YAAczB,OAAOyB,WAjI9C,KAJA,CAECC,WAAW7B,EADQ,GAGpB,CAmCA,SAASyB,EAAwBK,GAChC,OACCA,EAAUC,OAAO,EAAGxB,MACpBA,CAEF,CA0FD,CAzIM","file":"JavaScript\\InitializeLocatorMessaging.min.js","sourcesContent":["/* global Engage, PubSub */\r\n\r\n/**\r\n * @description Initializes the core messaging library for the Engage Locator.\r\n */\r\nvoid (function initializeLocatorMessaging() {\r\n\t'use strict';\r\n\r\n\tif (window.PubSub === undefined) {\r\n\t\tconst retryDelay = 20;\r\n\t\tsetTimeout(initializeLocatorMessaging, retryDelay);\r\n\t\treturn;\r\n\t}\r\n\r\n\twindow.Engage = window.Engage || {};\r\n\r\n\t/**\r\n\t * @namespace Window.Engage.Locator\r\n\t */\r\n\tEngage.Locator = Engage.Locator || {};\r\n\r\n\t/**\r\n\t * @namespace Window.Engage.Locator.Messaging\r\n\t */\r\n\tEngage.Locator.Messaging = Engage.Locator.Messaging || {};\r\n\r\n\t/**\r\n\t * @private\r\n\t * @constant {string} locatorMessagePrefix - Defines the root prefix for all messages inside the Engage Locator.\r\n\t * @memberof Window.Engage.Locator.Messaging\r\n\t */\r\n\tconst locatorMessagePrefix = 'Engage.Locator';\r\n\r\n\t/**\r\n\t * @private\r\n\t * @function startsWithMessagePrefix\r\n\t * @description Searched the provided string to see if it begins with the Engage Locator messaging prefix.\r\n\t * @memberof Window.Engage.Locator.Messaging\r\n\t * @example\r\n\t * // Returns True\r\n\t * startsWithMessagePrefix('Engage.Locator.ValidateZipCode');\r\n\t * @example\r\n\t * // Returns False\r\n\t * startsWithMessagePrefix('Publish.Invalid.Events');\r\n\t * @param {string} searchStr - The string to be searched.\r\n\t * @returns {bool} True if the provided string is prefixed with the Engage Locator messaging prefix; otherwise, False.\r\n\t */\r\n\tfunction startsWithMessagePrefix(searchStr) {\r\n\t\treturn (\r\n\t\t\tsearchStr.substr(0, locatorMessagePrefix.length) ===\r\n\t\t\tlocatorMessagePrefix\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * @name locatorMessagePrefix\r\n\t * @description Defines the root prefix for all messages inside the Engage Locator.\r\n\t * @memberof Window.Engage.Locator.Messaging\r\n\t */\r\n\tEngage.Locator.Messaging.locatorMessagePrefix = locatorMessagePrefix;\r\n\r\n\t/**\r\n\t * @name messageTypes\r\n\t * @memberof Window.Engage.Locator.Messaging\r\n\t * @description Defines the names of the messages being sent throughout the Engage Locator.\r\n\t * @property {string} validateZipCode - Requests Geocoding of address for validation.\r\n\t * @property {string} zipCodeValidationResult - Response to {validateZipCode} geocode request.\r\n\t * @property {string} locationUpdate - Inform all components of a new location for a radius search.\r\n\t * @property {string} resetSearchFrom - Inform all components the search filters have been reset.\r\n\t * @property {string} newQueryFilters - Inform all components of new search query filters.\r\n\t * @property {string} boundingBoxUpdate - Inform all components the map was moved and provide the bound box.\r\n\t * @property {string} newLocations - Inform all components of a new list of locations.\r\n\t * @property {string} showLoading - Inform all components that they should be displaying a loading indicator.\r\n\t * @property {string} advancedSearch - Inform all components that a new advanced search is being started.\r\n\t * @property {string} trackEvent - Inform all components that an event should be tracked.\r\n\t */\r\n\tEngage.Locator.Messaging.messageTypes = {\r\n\t\tvalidateZipCode: `${locatorMessagePrefix}.ValidateZipCode`,\r\n\t\tzipCodeValidationResult: `${locatorMessagePrefix}.ZipCodeValidationResult`, // eslint-disable-line max-len\r\n\t\tlocationUpdate: `${locatorMessagePrefix}.LocationUpdate`,\r\n\t\tresetSearchFrom: `${locatorMessagePrefix}.ResetSearchForm`,\r\n\t\tnewQueryFilters: `${locatorMessagePrefix}.NewQueryFilters`,\r\n\t\tboundingBoxUpdate: `${locatorMessagePrefix}.BoundingBoxUpdate`,\r\n\t\tnewLocations: `${locatorMessagePrefix}.NewLocations`,\r\n\t\tshowLoading: `${locatorMessagePrefix}.ShowLoading`,\r\n\t\tadvancedSearch: `${locatorMessagePrefix}.AdvancedSearch`,\r\n\t\ttrackEvent: `${locatorMessagePrefix}.TrackEvent`,\r\n\t\tresetCustomFilters: `${locatorMessagePrefix}.ResetCustomFilters`,\r\n\t\trefreshLocation: `${locatorMessagePrefix}.RefreshLocation`,\r\n\t};\r\n\r\n\t/**\r\n\t * @function publish\r\n\t * @memberof Window.Engage.Locator.Messaging\r\n\t * @description Publishs the message only if the message type is an Engage Locator message.\r\n\t * @example\r\n\t * const messaging = window.Engage.Locator.Messaging;\r\n\t * messaging.publish(messaging.messageTypes.validateZipCode, { address: 'St. Louis, MO 63131', });\r\n\t * @param {string} messageType - The type of message requesting publish.\r\n\t * @param {Object} payload - The object payload for the message requesting publish.\r\n\t */\r\n\tEngage.Locator.Messaging.publish = (messageType, payload) => {\r\n\t\tif (!startsWithMessagePrefix(messageType)) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tPubSub.publish(messageType, payload);\r\n\t};\r\n\r\n\t/**\r\n\t * @global\r\n\t * @description Defines the structure of the callback for all Engage Locator messaging subscriptions.\r\n\t * @callback subscriptionCallback\r\n\t * @param {string} messageType - The type of message requesting publish.\r\n\t * @param {Object} payload - The object payload for the message requesting publish.\r\n\t */\r\n\r\n\t/**\r\n\t * @function subscribe\r\n\t * @memberof Window.Engage.Locator.Messaging\r\n\t * @description Subscribes to all messages of type {messageType} if the message type is an Engage Locator message.\r\n\t * @example\r\n\t * const messaging = window.Engage.Locator.Messaging;\r\n\t * messaging.subscribe(messaging.messageTypes.validateZipCode, (messageType, { address, }) => {\r\n\t * if (messageType !== messaging.messageTypes.validateZipCode || !address) {\r\n\t * return;\r\n\t * }\r\n\t *\r\n\t * // Do what you need.\r\n\t * });\r\n\t * @param {string} messageType - The type of message requesting subscriptions.\r\n\t * @param {subscriptionCallback} subscriber - The callback that handles the response to messages being published.\r\n\t */\r\n\tEngage.Locator.Messaging.subscribe = (messageType, subscriber) => {\r\n\t\tif (!startsWithMessagePrefix(messageType)) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tPubSub.subscribe(messageType, subscriber);\r\n\t};\r\n\r\n\tEngage.Locator.Messaging.unsubscribe = PubSub.unsubscribe;\r\n})();\r\n"]}