UNPKG

@smartrep/web-widget

Version:

Client side library to load the web widget

2 lines 33.1 kB
/*! For license information please see 602.index.js.LICENSE.txt */ "use strict";(self.webpackChunkWebChat=self.webpackChunkWebChat||[]).push([[602],{3602:(e,t,r)=>{r.r(t),r.d(t,{InnerWidgetMap:()=>G,default:()=>R});var n=r(6540),o=r(4550);function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,t,r){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}const s=function(){var e,t,r=(e=(0,n.useState)({lat:null,lng:null,location:null,error:null,loading:!0}),t=2,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],c=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=r[0],a=r[1];return(0,n.useEffect)((function(){navigator.geolocation?navigator.geolocation.getCurrentPosition((function(e){var t=e.coords.latitude,r=e.coords.longitude;a({lat:t,lng:r,location:{lat:t,lng:r},error:null,loading:!1})}),(function(e){var t;switch(e.code){case e.PERMISSION_DENIED:t="User denied the request for geolocation";break;case e.POSITION_UNAVAILABLE:t="Location information is unavailable";break;case e.TIMEOUT:t="The request to get user location timed out";break;default:t="An unknown error occurred"}a((function(e){return l(l({},e),{},{error:t,loading:!1})}))}),{enableHighAccuracy:!0}):a((function(e){return l(l({},e),{},{error:"Geolocation is not supported by this browser",loading:!1})}))}),[]),o};function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){g(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function g(e,t,r){return(t=function(e){var t=function(e){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==p(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],c=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},y.apply(null,arguments)}function h(e){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h(e)}function v(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var c=n&&n.prototype instanceof l?n:l,u=Object.create(c.prototype);return w(u,"_invoke",function(r,n,o){var a,l,c,u=0,s=o||[],p=!1,f={p:0,n:0,v:e,a:m,f:m.bind(e,4),d:function(t,r){return a=t,l=0,c=e,f.n=r,i}};function m(r,n){for(l=r,c=n,t=0;!p&&u&&!o&&t<s.length;t++){var o,a=s[t],m=f.p,g=a[2];r>3?(o=g===n)&&(l=a[4]||3,c=a[5]===e?a[3]:a[5],a[4]=3,a[5]=e):a[0]<=m&&((o=r<2&&m<a[1])?(l=0,f.v=n,f.n=a[1]):m<g&&(o=r<3||a[0]>n||n>g)&&(a[4]=r,a[5]=n,f.n=g,l=0))}if(o||r>1)return i;throw p=!0,n}return function(o,s,g){if(u>1)throw TypeError("Generator is already running");for(p&&1===s&&m(s,g),l=s,c=g;(t=l<2?e:c)||!p;){a||(l?l<3?(l>1&&(f.n=-1),m(l,c)):f.n=c:f.v=c);try{if(u=2,a){if(l||(o="next"),t=a[o]){if(!(t=t.call(a,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,l<2&&(l=0)}else 1===l&&(t=a.return)&&t.call(a),l<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),l=1);a=e}else if((t=(p=f.n<0)?c:r.call(n,f))!==i)break}catch(t){a=e,l=1,c=t}finally{u=1}}return{value:t,done:p}}}(r,o,a),!0),u}var i={};function l(){}function c(){}function u(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(w(t={},n,(function(){return this})),t),p=u.prototype=l.prototype=Object.create(s);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,w(e,o,"GeneratorFunction")),e.prototype=Object.create(p),e}return c.prototype=u,w(p,"constructor",u),w(u,"constructor",c),c.displayName="GeneratorFunction",w(u,o,"GeneratorFunction"),w(p),w(p,o,"Generator"),w(p,n,(function(){return this})),w(p,"toString",(function(){return"[object Generator]"})),(v=function(){return{w:a,m:f}})()}function w(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}w=function(e,t,r,n){if(t)o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r;else{var a=function(t,r){w(e,t,(function(e){return this._invoke(t,r,e)}))};a("next",0),a("throw",1),a("return",2)}},w(e,t,r,n)}function k(e,t,r,n,o,a,i){try{var l=e[a](i),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,o)}function x(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){k(a,n,o,i,l,"next",e)}function l(e){k(a,n,o,i,l,"throw",e)}i(void 0)}))}}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],c=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}(e,t)||A(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){if(e){if("string"==typeof e)return S(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(e,t):void 0}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var O=function(e){var t=e.value,r=e.onChange,a=e.onPlaceSelect,i=e.inputProps,l=void 0===i?{}:i,c=e.searchLabel,u=e.details,s=void 0===u?{}:u,p=e.suggestions,f=void 0===p?{}:p,g=(0,o.ST)("places"),b=E((0,n.useState)(-1),2),w=b[0],k=b[1],O=E((0,n.useState)(!0),2),j=O[0],C=O[1],P=E((0,n.useState)(!0),2),N=P[0],L=P[1],T=(0,n.useRef)(!1),I=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=(0,o.ST)("places"),i=(0,n.useRef)(null),l=d((0,n.useState)([]),2),c=l[0],u=l[1],s=d((0,n.useState)(!1),2),p=s[0],f=s[1];return(0,n.useEffect)((function(){if(a)if(r){var n=a.AutocompleteSessionToken,o=a.AutocompleteSuggestion;i.current||(i.current=new n);var l=m(m({},t),{},{input:e,sessionToken:i.current});""!==e?(f(!0),o.fetchAutocompleteSuggestions(l).then((function(e){u(e.suggestions),f(!1)}))):c.length>0&&u([])}else c.length>0&&u([])}),[a,e,r]),{suggestions:c,isLoading:p,resetSession:function(){i.current=null,u([])}}}(t,f,j),D=I.suggestions,U=I.resetSession,_=(0,n.useMemo)((function(){return N?D:[]}),[N,D]);(0,n.useEffect)((function(){k(-1)}),[_]);var M=(0,n.useCallback)((function(e){T.current||(C(!0),L(!0)),r(e.target.value)}),[r]),B=(0,n.useCallback)((function(e){T.current=!0,C(!1),L(!1),r(e),setTimeout((function(){T.current&&(C(!0),T.current=!1)}),300)}),[r]),z=(0,n.useCallback)(function(){var e=x(v().m((function e(t){var n;return v().w((function(e){for(;;)switch(e.n){case 0:if(g){e.n=1;break}return e.a(2);case 1:if(t.placePrediction){e.n=2;break}return e.a(2);case 2:return L(!1),C(!1),k(-1),U(),T.current=!0,r(t.placePrediction.text.text),n=t.placePrediction.toPlace(),e.n=3,n.fetchFields({fields:[].concat((o=s.fields,function(e){if(Array.isArray(e))return S(e)}(o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||A(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),["types"])});case 3:a(n,t.placePrediction.text.text),setTimeout((function(){T.current=!1,C(!0)}),300);case 4:return e.a(2)}var o}),e)})));return function(t){return e.apply(this,arguments)}}(),[g,a,r,U]),H=(0,n.useCallback)((function(e){if(0!==_.length)switch(e.key){case"ArrowDown":e.preventDefault(),k((function(e){return e<_.length-1?e+1:0}));break;case"ArrowUp":e.preventDefault(),k((function(e){return e>0?e-1:_.length-1}));break;case"Enter":w>=0&&w<_.length&&(e.preventDefault(),z(_[w]));break;case"Escape":k(-1),L(!1),setTimeout((function(){return L(!0)}),100)}}),[_,w,z]),F=(0,n.useCallback)(function(){var e=x(v().m((function e(t){var r;return v().w((function(e){for(;;)switch(e.n){case 0:if(t.preventDefault(),!(r=_[0])){e.n=1;break}return e.n=1,z(r);case 1:return e.a(2)}}),e)})));return function(t){return e.apply(this,arguments)}}(),[_,z]);return(0,n.useEffect)((function(){l.ref&&"object"===h(l.ref)&&(l.ref.current={updateValueProgrammatically:B})}),[B,l.ref]),n.createElement("div",{className:"gplaces-container"},n.createElement("form",{className:"gplaces-input",onSubmit:F},n.createElement("input",y({value:t,onInput:function(e){return M(e)},onKeyDown:H,className:"gplaces-input__input"},l)),n.createElement("button",{type:"submit",onClick:F,className:"gplaces-input__button"},c)),_.length>0&&n.createElement(n.Fragment,null,n.createElement("ul",{className:"gplaces-list"},_.map((function(e,t){var r;return n.createElement("button",{key:t,className:"gplaces-list__item ".concat(t===w?"gplaces-list__item--selected":""),onClick:function(){return z(e)},onKeyDown:function(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),z(e))},style:{borderBottom:t===_.length-1?"none":""}},null===(r=e.placePrediction)||void 0===r?void 0:r.text.text)})),n.createElement("footer",{className:"gplaces-footer"},n.createElement("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAOCAYAAADkH9g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=r(3861);function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function T(e){var t,r,o=e.marker,a=e.isOpen,i=e.onClose,l=e.containerClassName,c=e.selectMarker,u=(t=(0,n.useState)(null),r=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],c=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}(t,r)||function(e,t){if(e){if("string"==typeof e)return L(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(e,t):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=u[0],p=u[1];if((0,n.useEffect)((function(){var e=document.querySelector(".".concat(l));e?("static"===window.getComputedStyle(e).position&&(e.style.position="relative"),p(e)):N.A.info('Container with class "'.concat(l,'" not found'))}),[l]),(0,n.useEffect)((function(){var e=function(e){"Escape"===e.key&&a&&i()};if(a&&s){document.addEventListener("keydown",e),document.body.style.overflow="hidden";var t=s.style.overflow;s.style.overflow="hidden",s._originalOverflow=t}return function(){document.removeEventListener("keydown",e),document.body.style.overflow="",s&&void 0!==s._originalOverflow&&(s.style.overflow=s._originalOverflow,delete s._originalOverflow)}}),[a,i,s]),!a||!o||!s)return null;if(!o.popup)return null;var f=n.createElement("div",{className:"marker-popup-overlay"},n.createElement("div",{className:"marker-popup-backdrop",onClick:i,onKeyDown:function(e){return"Escape"===e.key&&i()},tabIndex:0,role:"button","aria-label":"Close popup"}),n.createElement("div",{className:"marker-popup-content"},n.createElement("div",{className:"marker-popup-cover ".concat(o.popup.cover?"":"marker-popup-cover--no-cover"),style:o.popup.cover?{}:{height:60}},o.popup.cover&&n.createElement("img",{src:o.popup.cover,alt:o.storeDescription,onError:function(e){e.target.style.display="none"}}),n.createElement("button",{className:"marker-popup-close-btn",onClick:i},"×")),n.createElement("div",{className:"marker-popup-header"},n.createElement("h1",{className:"marker-popup-title"},o.popup.title),n.createElement("button",{className:"marker-popup-select-btn",onClick:function(){c(o.popup.buttonPayload,o.popup.title)}},o.popup.button)),n.createElement("div",{className:"marker-popup-body ".concat(o.coverPhotoUrl?"marker-popup-body--with-cover":"marker-popup-body--no-cover")},n.createElement("div",{className:"marker-popup-details"},o.popup.rows.map((function(e){return n.createElement("div",{className:"marker-detail-item",key:e.label},n.createElement("span",{className:"marker-detail-icon",dangerouslySetInnerHTML:{__html:P.A.sanitize(e.icon)}}),n.createElement("span",{className:"marker-detail-text",dangerouslySetInnerHTML:{__html:P.A.sanitize(e.label,{ADD_ATTR:["target"]})}}))}))))));return(0,C.createPortal)(f,s)}var I=r(9689),D=r(5072),U=r.n(D),_=r(9809);function M(){return M=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},M.apply(null,arguments)}function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],c=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return z(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?z(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function H(e){var t=e.id,r=e.label,o=e.icon;return n.createElement("div",{id:t,className:"map-header-icon"},n.createElement("img",{src:o,alt:r,className:"map-header-icon__icon"}),n.createElement("span",{className:"map-header-icon__label"},r))}function F(e){var t=e.legend,r=e.myLocation,o=e.handleMyLocationClick,a=e.geolocationIsLoading,i=e.geolocationError,l=r&&!i&&!a;return n.createElement("header",{className:"map-header"},t.length&&n.createElement("div",{className:"map-header__icons"},t.map((function(e){return n.createElement(H,{key:e.id,id:e.id,label:e.label,icon:e.icon})}))),l&&n.createElement("button",{type:"button",onClick:o,className:"map-header__my-location-button"},n.createElement(H,{id:"my-location",label:r.label,icon:r.src})))}function Y(e){var t=e.popupConfig,r=(e.markersConfig,e.selectMarker),a=e.markers,i=(e.markersLoading,e.markersError,e.zoom),l=e.markersUrl,c=e.gmapsLogsUrl,u=B((0,n.useState)([]),2),s=u[0],p=u[1],f=B((0,n.useState)(null),2),m=f[0],g=f[1],d=B((0,n.useState)(!1),2),b=d[0],y=d[1],h=(0,o.ko)(),v=(0,n.useRef)(new window.Map),w=(0,n.useRef)(null),k=(0,n.useRef)(null),x=(0,n.useCallback)((function(e,t){if(!t)return!0;var r=parseFloat(e.latitude),n=parseFloat(e.longtitude),o=t.getNorthEast(),a=t.getSouthWest(),i=.5*(o.lat()-a.lat())/2,l=.5*(o.lng()-a.lng())/2,c=o.lat()+i,u=o.lng()+l,s=a.lat()-i,p=a.lng()-l;return r>=s&&r<=c&&n>=p&&n<=u}),[]),E=(0,n.useCallback)((function(){if(h&&a.length){var e,t,r=h.getBounds(),n=a.filter((function(e){return x(e,r)}));c&&(e={bounds:r,zoom:i,totalMarkers:a.length,visibleMarkers:n.length,markersUrl:l},t=new Blob([JSON.stringify(e)],{type:"text/plain"}),navigator.sendBeacon(c,t)),p(n)}}),[h,a,x,c,i,l]),A=(0,n.useCallback)((function(){k.current&&clearTimeout(k.current),k.current=setTimeout((function(){E()}),300)}),[E]);(0,n.useEffect)((function(){if(h){E();var e=h.addListener("bounds_changed",A);return function(){var t;k.current&&clearTimeout(k.current),e&&null!==(t=window.google)&&void 0!==t&&null!==(t=t.maps)&&void 0!==t&&t.event&&window.google.maps.event.removeListener(e)}}}),[h,E,A]);var S=(0,n.useCallback)((function(e){g(e),y(!0)}),[]),O=(0,n.useCallback)((function(){y(!1),g(null)}),[]);(0,n.useEffect)((function(){if(h){var e=setTimeout((function(){w.current&&(w.current.clearMarkers(),w.current=null);var e=Array.from(v.current.values()).filter(Boolean);if(0!==e.length)try{var t=new j.w1({markers:e,map:h,renderer:{render:function(e){var t=e.count,r=e.position,n=document.createElement("div");return n.className="gplaces-result-cluster",n.textContent=t.toString(),new window.google.maps.marker.AdvancedMarkerElement({position:r,content:n,zIndex:1e3})}}});w.current=t}catch(e){console.error("Error creating clusterer:",e)}}),100);return function(){clearTimeout(e),w.current&&w.current.clearMarkers()}}}),[h,s]);var C=(0,n.useCallback)((function(e,t){t?v.current.set(e,t):v.current.delete(e)}),[]);return n.createElement(n.Fragment,null,s.map((function(e){var t=function(e){return"".concat(e.latitude,"-").concat(e.longtitude,"-").concat(e.storeDescription)}(e),r=parseFloat(e.latitude),a=parseFloat(e.longtitude);return isNaN(r)||isNaN(a)?null:n.createElement(o.J8,{key:t,ref:function(e){return C(t,e)},position:{lat:r,lng:a},onClick:function(){return S(e)},title:e.storeDescription},n.createElement("img",{src:e.markerUrl,alt:e.storeDescription,width:30,style:{cursor:"pointer"}}))})),n.createElement(T,{marker:m,isOpen:b,onClose:O,containerClassName:t.containerClassName,selectMarker:r}))}function K(e){var t=e.options,r=void 0===t?{}:t,a=e.currentLocation,i=e.currentCenter,l=e.setCurrentCenter,c=e.zoom,u=e.setZoom,s=e.selectMarker,p=e.markers,f=e.markersLoading,m=e.markersError,g=e.markersUrl,d=e.gmapsLogsUrl,b=r.map.config||{};return n.createElement(n.Fragment,null,n.createElement(o.T5,M({mapId:r.id,className:"rw-gmaps-map",center:i,zoom:c,onCameraChanged:function(e){var t=e.detail,r=t.center,n=t.zoom;l(r),u(n)},gestureHandling:"greedy"},b.map),a&&n.createElement(o.J8,{position:a},n.createElement("img",{src:r.header.myLocation.src,alt:r.header.myLocation.label,className:"location-marker_icon"})),n.createElement(Y,{currentLocation:a,popupConfig:r.popup,markersConfig:r.results,selectMarker:s,markers:p,markersLoading:f,markersError:m,zoom:c,markersUrl:g,gmapsLogsUrl:d})))}function G(e){var t=e.options,r=e.selectMarker,a=e.markers,i=e.markersLoading,l=e.markersError,c=e.markersUrl,u=e.gmapsLogsUrl,p=(0,n.useMemo)((function(){return{lat:parseFloat(t.map.defaultCenter.lat),lng:parseFloat(t.map.defaultCenter.lng)}}),[t.map.defaultCenter]),f=s(),m=f.location,g=f.error,d=f.loading,b=B((0,n.useState)(null),2),y=b[0],h=b[1],v=B((0,n.useState)(p),2),w=v[0],k=v[1],x=B((0,n.useState)(t.map.zoom),2),E=x[0],A=x[1],S=B((0,n.useState)(""),2),j=S[0],C=S[1],P=(0,n.useRef)(null),L=(0,n.useRef)(null),T=(0,o.ko)();return(0,n.useEffect)((function(){d||g||setTimeout((function(){h(m),k(m)}),100)}),[d,g,m]),(0,n.useLayoutEffect)((function(){setTimeout((function(){if(P.current){var e=document.getElementById("rw-messages");if(e){var t=P.current.getBoundingClientRect(),r=e.getBoundingClientRect(),n=e.scrollTop+(t.top-r.top);e.scrollTop=n}}}),100)}),[]),n.createElement("div",{ref:P,className:"rw-gmaps"},n.createElement(F,{handleMyLocationClick:function(){d||(navigator.geolocation?(navigator.geolocation.getCurrentPosition((function(e){!function(e){h(e),k(e)}({lat:e.coords.latitude,lng:e.coords.longitude})}),(function(e){N.A.info("Error getting location:",e)}),{enableHighAccuracy:!0}),k(m),C("")):N.A.info("Geolocation is not supported by this browser"))},legend:t.header.legend,myLocation:t.header.myLocation,geolocationIsLoading:d,geolocationError:g}),n.createElement(O,{value:j,onChange:C,onPlaceSelect:function(e){if(window.google&&window.google.maps){var r={lat:e.location.lat(),lng:e.location.lng()};if(e.types.includes("locality")){var n=e.viewport.getNorthEast().lat(),o=e.viewport.getSouthWest().lat(),a=e.viewport.getSouthWest().lng(),i=e.viewport.getNorthEast().lng();if(o&&a&&n&&i){var l=new window.google.maps.LatLngBounds(new window.google.maps.LatLng(o,a),new window.google.maps.LatLng(n,i));T.fitBounds(l)}}else k(r),A(t.map.zoom)}else console.warn("Google Maps API not available for place selection")},inputProps:{placeholder:t.autocomplete.placeholder,ref:L},searchLabel:t.autocomplete.searchLabel,suggestions:t.autocomplete.options.suggestions,details:t.autocomplete.options.details}),n.createElement("div",{id:"map-wrapper",className:"map-wrapper"},n.createElement(K,{options:t,currentLocation:y,currentCenter:w,setCurrentCenter:k,zoom:E,setZoom:A,selectMarker:r,markers:a,markersLoading:i,markersError:l,markersUrl:c,gmapsLogsUrl:u})))}U()(_.A,{insert:"head",singleton:!1}),_.A.locals;const R=(0,r(1225).Ng)((function(e,t){var r=e.messages,n=r.get(t.id+2),o=r.get(t.id),a=o?o.get("markers"):null,i=!!o&&o.get("markersLoading"),l=o?o.get("markersError"):null;return{isDisabled:!!n&&"client"===n.get("sender"),markers:a?a.toJS():[],markersLoading:i,markersError:l}}),(function(e){return{selectMarker:function(t,r){e((0,I.GB)(r)),e((0,I.cR)(t))}}}))((function(e){var t=e.message,r=e.selectMarker,a=e.isDisabled,i=e.markers,l=e.markersLoading,c=e.markersError,u=e.gmapsApiKey,s=e.gmapsLogsUrl,p=n.useMemo((function(){var e,r,n,o=t.toJS(),a=null!==(e=null==o||null===(r=o.config)||void 0===r||null===(r=r.results)||void 0===r?void 0:r.url)&&void 0!==e?e:null;return{options:null!==(n=o.config)&&void 0!==n?n:null,markersUrl:a}}),[t]),f=p.options,m=p.markersUrl;return a?null:f?n.createElement(o.c4,{apiKey:u?atob(u):f.apiKey,language:f.map.locale},n.createElement(G,{options:f,selectMarker:r,markers:i,markersLoading:l,markersError:c,markersUrl:m,gmapsLogsUrl:s})):null}))},9809:(e,t,r)=>{r.d(t,{A:()=>l});var n=r(1601),o=r.n(n),a=r(6314),i=r.n(a)()(o());i.push([e.id,"@import url(https://fonts.googleapis.com/css?family=Inter:400,500,700&display=swap);"]),i.push([e.id,".rw-gmaps{width:100%;display:flex;flex-direction:column;position:relative}.rw-gmaps .map-wrapper{position:relative;flex:1;background-color:#f5f5f5}.rw-gmaps .map-header{width:100%;display:flex;justify-content:space-between;align-items:center;margin-bottom:5px}.rw-gmaps .map-header__icons{display:flex;gap:4px}.rw-gmaps .map-header-icon{display:flex;align-items:center;gap:2px}.rw-gmaps .map-header-icon__label{font-size:11px;line-height:1.15;user-select:none;text-align:left}.rw-gmaps .map-header-icon__icon{width:24px}.rw-gmaps .map-header__my-location-button{background-color:rgba(0,0,0,0);border:none;cursor:pointer;transition:background-color .3s ease;font-weight:600}.rw-gmaps .map-header__my-location-button:hover{background-color:#f5f5f5}.rw-gmaps .gplaces-container{width:100%;position:relative;margin-bottom:6px}.rw-gmaps .gplaces-input{display:flex;justify-content:space-between;gap:2px}.rw-gmaps .gplaces-input__input{width:100%;padding:8px;font-size:12px;flex:1;border:1px solid #ccc;outline:none}.rw-gmaps .gplaces-input__button{background-color:#666;color:#fff;border:none;font-size:12px;padding:8px}.rw-gmaps .gplaces-list{position:absolute;top:100%;left:0;width:100%;background-color:#fff;border:1px solid #ccc;list-style:none;padding:0 !important;margin:0;margin-top:4px;z-index:1}.rw-gmaps .gplaces-list__item{width:100%;padding:5px;cursor:pointer;border-bottom:1px solid #ccc;background-color:#fff;font-size:12px;border:none;text-align:left}.rw-gmaps .gplaces-list__item:hover{background-color:#f5f5f5}.rw-gmaps .gplaces-list__item--selected{background-color:#e3f2fd;font-weight:bold}.rw-gmaps .gplaces-footer{display:flex;justify-content:flex-end;padding:2px 5px}.rw-gmaps .gplaces-footer .gplaces-logo{width:100px}.rw-gmaps .loading-indicator{width:100%;height:3px;background-color:#f0f0f0;overflow:hidden;position:relative}.rw-gmaps .loading-indicator__bar{width:100%;height:100%;background-color:#e0e0e0;position:relative}.rw-gmaps .loading-indicator__progress{position:absolute;top:0;left:0;height:100%;width:30%;background:linear-gradient(90deg, #4152a3, #6173b4, #8194c5, #a1b5d6);animation:loading-slide 2s infinite ease-in-out}@keyframes loading-slide{0%{left:-30%}50%{left:100%}100%{left:-30%}}.rw-gmaps .rw-gmaps-map{width:100%;height:275px;background-color:#f5f5f5}@media screen and (max-width: 800px){.rw-gmaps .rw-gmaps-map{height:350px}}.rw-gmaps .gplaces-result-cluster{display:flex;align-items:center;justify-content:center;background-color:#666;border:1px solid #fff;border-radius:50%;color:#fff;font-size:10px;font-weight:bold;text-align:center;line-height:1;width:30px;height:30px;cursor:pointer}.location-marker_icon{width:24px;height:24px}.marker-popup-overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:10000;display:flex;align-items:center;justify-content:center;overflow:hidden}.marker-popup-backdrop{position:absolute;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.6)}.marker-popup-content{position:relative;width:90%;max-width:400px;background:#fff;border-radius:12px;overflow:hidden;box-shadow:0 10px 40px rgba(0,0,0,.2);animation:popupSlideIn .3s ease-out;max-height:85%;display:flex;flex-direction:column}.marker-popup-cover{position:relative;width:100%;height:120px;overflow:hidden;flex-shrink:0;background-color:#f5f5f5}.marker-popup-cover img{width:100%;height:100%;object-fit:cover;object-position:center}.marker-popup-close-btn{position:absolute;top:12px;right:12px;width:32px;height:32px;border:none;background:hsla(0,0%,100%,.9);border-radius:50%;font-size:20px;font-weight:bold;color:#333;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .2s ease;backdrop-filter:blur(4px);z-index:10}.marker-popup-close-btn:hover{background:#fff;transform:scale(1.1)}.marker-popup-close-btn--no-cover{position:static;width:24px;height:24px;background:rgba(0,0,0,.1);font-size:16px;color:#666;flex-shrink:0}.marker-popup-header{padding:8px;display:flex;justify-content:space-between;align-items:center;gap:12px}.marker-popup-header--no-cover{position:static;padding:20px 20px 16px 20px;display:flex;justify-content:space-between;align-items:flex-start;gap:12px}.marker-popup-title{font-size:18px;font-weight:700;color:#333;margin:0;line-height:1.3;flex:1}.marker-popup-select-btn{background:#666;color:#fff;border:none;border-radius:6px;padding:8px 16px;font-size:14px;font-weight:600;cursor:pointer;transition:all .2s ease;flex-shrink:0}.marker-popup-select-btn:hover{background:#444}.marker-popup-body{flex:1;padding:10px;overflow-y:auto;min-height:0}.marker-popup-body--with-cover{padding-top:10px}.marker-popup-body--no-cover{padding-top:0}.marker-popup-details{margin-bottom:20px;display:flex;flex-direction:column;gap:8px}.marker-detail-item{display:flex;align-items:flex-start;gap:8px}.marker-detail-icon{line-height:1;padding-top:2px}.marker-detail-text{color:#333;white-space:pre-wrap}@media(max-width: 800px){.marker-popup-cover{height:180px}.marker-popup__body{padding:16px}.marker-popup__title{font-size:16px}}",""]);const l=i}}]);