\n )\n }\n}\n\nexport default GoogleMap\n","function asyncGeneratorStep(n, t, e, r, o, a, c) {\n try {\n var i = n[a](c),\n u = i.value;\n } catch (n) {\n return void e(n);\n }\n i.done ? t(u) : Promise.resolve(u).then(r, o);\n}\nfunction _asyncToGenerator(n) {\n return function () {\n var t = this,\n e = arguments;\n return new Promise(function (r, o) {\n var a = n.apply(t, e);\n function _next(n) {\n asyncGeneratorStep(a, r, o, _next, _throw, \"next\", n);\n }\n function _throw(n) {\n asyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n);\n }\n _next(void 0);\n });\n };\n}\nexport { _asyncToGenerator as default };","import type { Library } from '@googlemaps/js-api-loader'\nimport invariant from 'invariant'\n\nexport type Libraries = Library[]\n\nexport type LoadScriptUrlOptions = {\n googleMapsApiKey: string | ''\n googleMapsClientId?: string | undefined\n version?: string | undefined\n language?: string | undefined\n region?: string | undefined\n libraries?: Libraries | undefined\n channel?: string | undefined\n mapIds?: string[] | undefined\n authReferrerPolicy?: 'origin' | undefined\n}\n\nexport function makeLoadScriptUrl({\n googleMapsApiKey,\n googleMapsClientId,\n version = 'weekly',\n language,\n region,\n libraries,\n channel,\n mapIds,\n authReferrerPolicy,\n}: LoadScriptUrlOptions): string {\n const params = []\n\n invariant(\n (googleMapsApiKey && googleMapsClientId) ||\n !(googleMapsApiKey && googleMapsClientId),\n 'You need to specify either googleMapsApiKey or googleMapsClientId for @react-google-maps/api load script to work. You cannot use both at the same time.'\n )\n\n if (googleMapsApiKey) {\n params.push(`key=${googleMapsApiKey}`)\n } else if (googleMapsClientId) {\n params.push(`client=${googleMapsClientId}`)\n }\n\n if (version) {\n params.push(`v=${version}`)\n }\n\n if (language) {\n params.push(`language=${language}`)\n }\n\n if (region) {\n params.push(`region=${region}`)\n }\n\n if (libraries && libraries.length) {\n params.push(`libraries=${libraries.sort().join(',')}`)\n }\n\n if (channel) {\n params.push(`channel=${channel}`)\n }\n\n if (mapIds && mapIds.length) {\n params.push(`map_ids=${mapIds.join(',')}`)\n }\n\n if (authReferrerPolicy) {\n params.push(`auth_referrer_policy=${authReferrerPolicy}`)\n }\n\n params.push('loading=async')\n params.push('callback=initMap')\n\n return `https://maps.googleapis.com/maps/api/js?${params.join('&')}`\n}\n","export const isBrowser: boolean = typeof document !== 'undefined'\n","import { isBrowser } from './isbrowser.js'\n\ntype WindowWithGoogleMap = Window & {\n initMap?: (() => void) | undefined\n}\n\ntype InjectScriptArg = {\n url: string\n id: string\n nonce?: string | undefined\n}\n\nexport function injectScript({\n url,\n id,\n nonce,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n}: InjectScriptArg): Promise {\n if (!isBrowser) {\n return Promise.reject(new Error('document is undefined'))\n }\n\n return new Promise(function injectScriptCallback(resolve, reject) {\n const existingScript = document.getElementById(id) as\n | HTMLScriptElement\n | undefined\n\n const windowWithGoogleMap: WindowWithGoogleMap = window\n\n if (existingScript) {\n // Same script id/url: keep same script\n const dataStateAttribute = existingScript.getAttribute('data-state')\n\n if (existingScript.src === url && dataStateAttribute !== 'error') {\n if (dataStateAttribute === 'ready') {\n return resolve(id)\n } else {\n const originalInitMap = windowWithGoogleMap.initMap\n\n const originalErrorCallback = existingScript.onerror\n\n windowWithGoogleMap.initMap = function initMap(): void {\n if (originalInitMap) {\n originalInitMap()\n }\n resolve(id)\n }\n\n existingScript.onerror = function (err): void {\n if (originalErrorCallback) {\n originalErrorCallback(err)\n }\n reject(err)\n }\n\n return\n }\n }\n // Same script id, but either\n // 1. requested URL is different\n // 2. script failed to load\n else {\n existingScript.remove()\n }\n }\n\n const script = document.createElement('script')\n\n script.type = 'text/javascript'\n script.src = url\n script.id = id\n script.async = true\n script.nonce = nonce || ''\n script.onerror = function onerror(err): void {\n script.setAttribute('data-state', 'error')\n\n reject(err)\n }\n\n windowWithGoogleMap.initMap = function onload(): void {\n script.setAttribute('data-state', 'ready')\n\n resolve(id)\n }\n\n document.head.appendChild(script)\n }).catch((err) => {\n console.error('injectScript error: ', err)\n\n throw err\n })\n}\n","function isGoogleFontStyle(element: Node): boolean {\n // 'Roboto' or 'Google Sans Text' font download\n const href = (element as HTMLLinkElement).href;\n if (\n href && (\n href.indexOf('https://fonts.googleapis.com/css?family=Roboto') === 0 ||\n href.indexOf('https://fonts.googleapis.com/css?family=Google+Sans+Text') === 0\n )\n ) {\n return true\n }\n // font style elements\n if (\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n element.tagName.toLowerCase() === 'style' &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n element.styleSheet &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n element.styleSheet.cssText &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n element.styleSheet.cssText.replace('\\r\\n', '').indexOf('.gm-style') === 0\n ) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n element.styleSheet.cssText = ''\n return true\n }\n // font style elements for other browsers\n if (\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n element.tagName.toLowerCase() === 'style' &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n element.innerHTML &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n element.innerHTML.replace('\\r\\n', '').indexOf('.gm-style') === 0\n ) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n element.innerHTML = ''\n return true\n }\n // when google tries to add empty style\n if (\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n element.tagName.toLowerCase() === 'style' &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n !element.styleSheet &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n !element.innerHTML\n ) {\n return true\n }\n\n return false\n}\n\n// Preventing the Google Maps library from downloading an extra font\nexport function preventGoogleFonts (): void {\n // we override these methods only for one particular head element\n // default methods for other elements are not affected\n const head = document.getElementsByTagName('head')[0]\n\n if (head) {\n const trueInsertBefore = head.insertBefore.bind(head)\n\n // TODO: adding return before reflect solves the TS issue\n\n head.insertBefore = function insertBefore(\n newElement: T,\n referenceElement: HTMLElement\n ): T {\n if (!isGoogleFontStyle(newElement)) {\n Reflect.apply(trueInsertBefore, head, [newElement, referenceElement])\n }\n\n return newElement\n }\n\n const trueAppend = head.appendChild.bind(head)\n\n // TODO: adding return before reflect solves the TS issue\n\n head.appendChild = function appendChild(textNode: T): T {\n if (!isGoogleFontStyle(textNode)) {\n Reflect.apply(trueAppend, head, [textNode])\n }\n\n return textNode\n }\n }\n\n}\n","import { type JSX, PureComponent, type ReactNode } from 'react'\nimport invariant from 'invariant'\n\nimport {\n makeLoadScriptUrl,\n type LoadScriptUrlOptions,\n} from './utils/make-load-script-url.js'\nimport { isBrowser } from './utils/isbrowser.js'\nimport { injectScript } from './utils/injectscript.js'\nimport { preventGoogleFonts } from './utils/prevent-google-fonts.js'\n\nlet cleaningUp = false\n\ntype LoadScriptState = {\n loaded: boolean\n}\n\nexport type LoadScriptProps = LoadScriptUrlOptions & {\n children?: ReactNode | undefined\n id: string\n nonce?: string | undefined\n loadingElement?: ReactNode\n onLoad?: () => void\n onError?: (error: Error) => void\n onUnmount?: () => void\n preventGoogleFontsLoading?: boolean\n}\n\nexport function DefaultLoadingElement(): JSX.Element {\n return
{`Loading...`}
\n}\n\nexport const defaultLoadScriptProps = {\n id: 'script-loader',\n version: 'weekly',\n}\n\nclass LoadScript extends PureComponent {\n public static defaultProps = defaultLoadScriptProps\n\n check: HTMLDivElement | null = null\n\n override state = {\n loaded: false,\n }\n\n cleanupCallback = (): void => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n delete window.google.maps\n\n this.injectScript()\n }\n\n override componentDidMount(): void {\n if (isBrowser) {\n if (window.google && window.google.maps && !cleaningUp) {\n console.error('google api is already presented')\n\n return\n }\n\n this.isCleaningUp()\n .then(this.injectScript)\n .catch(function error(err) {\n console.error('Error at injecting script after cleaning up: ', err)\n })\n }\n }\n\n override componentDidUpdate(prevProps: LoadScriptProps): void {\n if (this.props.libraries !== prevProps.libraries) {\n console.warn(\n 'Performance warning! LoadScript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as static class property for Components and PureComponents, or just a const variable outside of component, or somewhere in config files or ENV variables'\n )\n }\n\n if (isBrowser && prevProps.language !== this.props.language) {\n this.cleanup()\n // TODO: refactor to use gDSFP maybe... wait for hooks refactoring.\n this.setState(function setLoaded() {\n return {\n loaded: false,\n }\n }, this.cleanupCallback)\n }\n }\n\n override componentWillUnmount(): void {\n if (isBrowser) {\n this.cleanup()\n\n const timeoutCallback = (): void => {\n if (!this.check) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n delete window.google\n cleaningUp = false\n }\n }\n\n window.setTimeout(timeoutCallback, 1)\n\n if (this.props.onUnmount) {\n this.props.onUnmount()\n }\n }\n }\n\n isCleaningUp = async (): Promise => {\n function promiseCallback(resolve: () => void): void {\n if (!cleaningUp) {\n resolve()\n } else {\n if (isBrowser) {\n const timer = window.setInterval(function interval() {\n if (!cleaningUp) {\n window.clearInterval(timer)\n\n resolve()\n }\n }, 1)\n }\n }\n\n return\n }\n\n return new Promise(promiseCallback)\n }\n\n cleanup = (): void => {\n cleaningUp = true\n const script = document.getElementById(this.props.id)\n\n if (script && script.parentNode) {\n script.parentNode.removeChild(script)\n }\n\n Array.prototype.slice\n .call(document.getElementsByTagName('script'))\n .filter(function filter(script: HTMLScriptElement): boolean {\n return (\n typeof script.src === 'string' &&\n script.src.includes('maps.googleapis')\n )\n })\n .forEach(function forEach(script: HTMLScriptElement): void {\n if (script.parentNode) {\n script.parentNode.removeChild(script)\n }\n })\n\n Array.prototype.slice\n .call(document.getElementsByTagName('link'))\n .filter(function filter(link: HTMLLinkElement): boolean {\n return (\n link.href ===\n 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Google+Sans'\n )\n })\n .forEach(function forEach(link: HTMLLinkElement) {\n if (link.parentNode) {\n link.parentNode.removeChild(link)\n }\n })\n\n Array.prototype.slice\n .call(document.getElementsByTagName('style'))\n .filter(function filter(style: HTMLStyleElement): boolean {\n return (\n style.innerText !== undefined &&\n style.innerText.length > 0 &&\n style.innerText.includes('.gm-')\n )\n })\n .forEach(function forEach(style: HTMLStyleElement) {\n if (style.parentNode) {\n style.parentNode.removeChild(style)\n }\n })\n }\n\n injectScript = (): void => {\n if (this.props.preventGoogleFontsLoading) {\n preventGoogleFonts()\n }\n\n invariant(\n !!this.props.id,\n 'LoadScript requires \"id\" prop to be a string: %s',\n this.props.id\n )\n\n const injectScriptOptions = {\n id: this.props.id,\n nonce: this.props.nonce,\n url: makeLoadScriptUrl(this.props),\n }\n\n injectScript(injectScriptOptions)\n .then(() => {\n if (this.props.onLoad) {\n this.props.onLoad()\n }\n\n this.setState(function setLoaded() {\n return {\n loaded: true,\n }\n })\n\n return\n })\n .catch((err) => {\n if (this.props.onError) {\n this.props.onError(err)\n }\n\n console.error(`\n There has been an Error with loading Google Maps API script, please check that you provided correct google API key (${\n this.props.googleMapsApiKey || '-'\n }) or Client ID (${\n this.props.googleMapsClientId || '-'\n }) to \n Otherwise it is a Network issue.\n `)\n })\n }\n\n getRef = (el: HTMLDivElement | null): void => {\n this.check = el\n }\n\n override render(): ReactNode {\n return (\n <>\n \n\n {this.state.loaded\n ? this.props.children\n : this.props.loadingElement || }\n >\n )\n }\n}\n\nexport default LoadScript\n","/* eslint-disable filenames/match-regex */\nimport { useEffect, useRef, useState } from 'react'\nimport invariant from 'invariant'\n\nimport { isBrowser } from './utils/isbrowser.js'\nimport { injectScript } from './utils/injectscript.js'\nimport { preventGoogleFonts } from './utils/prevent-google-fonts.js'\nimport {\n makeLoadScriptUrl,\n type LoadScriptUrlOptions,\n} from './utils/make-load-script-url.js'\n\nimport { defaultLoadScriptProps } from './LoadScript.js'\n\nexport type UseLoadScriptOptions = LoadScriptUrlOptions & {\n id?: string | undefined\n nonce?: string | undefined\n preventGoogleFontsLoading?: boolean | undefined\n}\n\nlet previouslyLoadedUrl: string\n\nexport function useLoadScript({\n id = defaultLoadScriptProps.id,\n version = defaultLoadScriptProps.version,\n nonce,\n googleMapsApiKey,\n googleMapsClientId,\n language,\n region,\n libraries,\n preventGoogleFontsLoading,\n channel,\n mapIds,\n authReferrerPolicy,\n}: UseLoadScriptOptions): {\n isLoaded: boolean\n loadError: Error | undefined\n url: string\n} {\n const isMounted = useRef(false)\n const [isLoaded, setLoaded] = useState(false)\n const [loadError, setLoadError] = useState(undefined)\n\n useEffect(function trackMountedState() {\n isMounted.current = true\n return (): void => {\n isMounted.current = false\n }\n }, [])\n\n useEffect(\n function applyPreventGoogleFonts() {\n if (isBrowser && preventGoogleFontsLoading) {\n preventGoogleFonts()\n }\n },\n [preventGoogleFontsLoading]\n )\n\n useEffect(\n function validateLoadedState() {\n if (isLoaded) {\n invariant(\n !!window.google,\n 'useLoadScript was marked as loaded, but window.google is not present. Something went wrong.'\n )\n }\n },\n [isLoaded]\n )\n\n const url = makeLoadScriptUrl({\n version,\n googleMapsApiKey,\n googleMapsClientId,\n language,\n region,\n libraries,\n channel,\n mapIds,\n authReferrerPolicy,\n })\n\n useEffect(\n function loadScriptAndModifyLoadedState() {\n if (!isBrowser) {\n return\n }\n\n function setLoadedIfMounted(): void {\n if (isMounted.current) {\n setLoaded(true)\n previouslyLoadedUrl = url\n }\n }\n\n if (window.google && window.google.maps && previouslyLoadedUrl === url) {\n setLoadedIfMounted()\n return\n }\n\n injectScript({ id, url, nonce })\n .then(setLoadedIfMounted)\n .catch(function handleInjectError(err) {\n if (isMounted.current) {\n setLoadError(err)\n }\n console.warn(`\n There has been an Error with loading Google Maps API script, please check that you provided correct google API key (${\n googleMapsApiKey || '-'\n }) or Client ID (${googleMapsClientId || '-'})\n Otherwise it is a Network issue.\n `)\n console.error(err)\n })\n },\n [id, url, nonce]\n )\n\n const prevLibraries = useRef(undefined)\n\n useEffect(\n function checkPerformance() {\n if (prevLibraries.current && libraries !== prevLibraries.current) {\n console.warn(\n 'Performance warning! LoadScript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as static class property for Components and PureComponents, or just a const variable outside of component, or somewhere in config files or ENV variables'\n )\n }\n prevLibraries.current = libraries\n },\n [libraries]\n )\n\n return { isLoaded, loadError, url }\n}\n","import objectWithoutPropertiesLoose from \"./objectWithoutPropertiesLoose.js\";\nfunction _objectWithoutProperties(e, t) {\n if (null == e) return {};\n var o,\n r,\n i = objectWithoutPropertiesLoose(e, t);\n if (Object.getOwnPropertySymbols) {\n var s = Object.getOwnPropertySymbols(e);\n for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);\n }\n return i;\n}\nexport { _objectWithoutProperties as default };","function _objectWithoutPropertiesLoose(r, e) {\n if (null == r) return {};\n var t = {};\n for (var n in r) if ({}.hasOwnProperty.call(r, n)) {\n if (e.includes(n)) continue;\n t[n] = r[n];\n }\n return t;\n}\nexport { _objectWithoutPropertiesLoose as default };","import { memo, type ReactElement, useEffect, type JSX } from 'react'\n\nimport { DefaultLoadingElement } from './LoadScript.js'\nimport { useLoadScript, type UseLoadScriptOptions } from './useLoadScript.js'\n\nexport type LoadScriptNextProps = UseLoadScriptOptions & {\n loadingElement?: ReactElement | undefined\n onLoad?: (() => void) | undefined\n onError?: ((error: Error) => void) | undefined\n onUnmount?: (() => void) | undefined\n children: ReactElement\n}\n\nconst defaultLoadingElement = \n\nfunction LoadScriptNext({\n loadingElement,\n onLoad,\n onError,\n onUnmount,\n children,\n ...hookOptions\n}: LoadScriptNextProps): JSX.Element {\n const { isLoaded, loadError } = useLoadScript(hookOptions)\n\n useEffect(\n function handleOnLoad() {\n if (isLoaded && typeof onLoad === 'function') {\n onLoad()\n }\n },\n [isLoaded, onLoad]\n )\n\n useEffect(\n function handleOnError() {\n if (loadError && typeof onError === 'function') {\n onError(loadError)\n }\n },\n [loadError, onError]\n )\n\n useEffect(\n function handleOnUnmount() {\n return () => {\n if (onUnmount) {\n onUnmount()\n }\n }\n },\n [onUnmount]\n )\n\n return isLoaded ? children : loadingElement || defaultLoadingElement\n}\n\nexport default memo(LoadScriptNext)\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\n\r\nfunction __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\ntypeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\n// do not edit .js files directly - edit src/index.jst\n\n\n\nvar fastDeepEqual = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n\nvar isEqual = /*@__PURE__*/getDefaultExportFromCjs(fastDeepEqual);\n\n/**\n * Copyright 2019 Google LLC. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at.\n *\n * Http://www.apache.org/licenses/LICENSE-2.0.\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconst DEFAULT_ID = \"__googleMapsScriptId\";\n/**\n * The status of the [[Loader]].\n */\nvar LoaderStatus;\n(function (LoaderStatus) {\n LoaderStatus[LoaderStatus[\"INITIALIZED\"] = 0] = \"INITIALIZED\";\n LoaderStatus[LoaderStatus[\"LOADING\"] = 1] = \"LOADING\";\n LoaderStatus[LoaderStatus[\"SUCCESS\"] = 2] = \"SUCCESS\";\n LoaderStatus[LoaderStatus[\"FAILURE\"] = 3] = \"FAILURE\";\n})(LoaderStatus || (LoaderStatus = {}));\n/**\n * [[Loader]] makes it easier to add Google Maps JavaScript API to your application\n * dynamically using\n * [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).\n * It works by dynamically creating and appending a script node to the the\n * document head and wrapping the callback function so as to return a promise.\n *\n * ```\n * const loader = new Loader({\n * apiKey: \"\",\n * version: \"weekly\",\n * libraries: [\"places\"]\n * });\n *\n * loader.load().then((google) => {\n * const map = new google.maps.Map(...)\n * })\n * ```\n */\nclass Loader {\n /**\n * Creates an instance of Loader using [[LoaderOptions]]. No defaults are set\n * using this library, instead the defaults are set by the Google Maps\n * JavaScript API server.\n *\n * ```\n * const loader = Loader({apiKey, version: 'weekly', libraries: ['places']});\n * ```\n */\n constructor({ apiKey, authReferrerPolicy, channel, client, id = DEFAULT_ID, language, libraries = [], mapIds, nonce, region, retries = 3, url = \"https://maps.googleapis.com/maps/api/js\", version, }) {\n this.callbacks = [];\n this.done = false;\n this.loading = false;\n this.errors = [];\n this.apiKey = apiKey;\n this.authReferrerPolicy = authReferrerPolicy;\n this.channel = channel;\n this.client = client;\n this.id = id || DEFAULT_ID; // Do not allow empty string\n this.language = language;\n this.libraries = libraries;\n this.mapIds = mapIds;\n this.nonce = nonce;\n this.region = region;\n this.retries = retries;\n this.url = url;\n this.version = version;\n if (Loader.instance) {\n if (!isEqual(this.options, Loader.instance.options)) {\n throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(Loader.instance.options)}`);\n }\n return Loader.instance;\n }\n Loader.instance = this;\n }\n get options() {\n return {\n version: this.version,\n apiKey: this.apiKey,\n channel: this.channel,\n client: this.client,\n id: this.id,\n libraries: this.libraries,\n language: this.language,\n region: this.region,\n mapIds: this.mapIds,\n nonce: this.nonce,\n url: this.url,\n authReferrerPolicy: this.authReferrerPolicy,\n };\n }\n get status() {\n if (this.errors.length) {\n return LoaderStatus.FAILURE;\n }\n if (this.done) {\n return LoaderStatus.SUCCESS;\n }\n if (this.loading) {\n return LoaderStatus.LOADING;\n }\n return LoaderStatus.INITIALIZED;\n }\n get failed() {\n return this.done && !this.loading && this.errors.length >= this.retries + 1;\n }\n /**\n * CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].\n *\n * @ignore\n * @deprecated\n */\n createUrl() {\n let url = this.url;\n url += `?callback=__googleMapsCallback&loading=async`;\n if (this.apiKey) {\n url += `&key=${this.apiKey}`;\n }\n if (this.channel) {\n url += `&channel=${this.channel}`;\n }\n if (this.client) {\n url += `&client=${this.client}`;\n }\n if (this.libraries.length > 0) {\n url += `&libraries=${this.libraries.join(\",\")}`;\n }\n if (this.language) {\n url += `&language=${this.language}`;\n }\n if (this.region) {\n url += `®ion=${this.region}`;\n }\n if (this.version) {\n url += `&v=${this.version}`;\n }\n if (this.mapIds) {\n url += `&map_ids=${this.mapIds.join(\",\")}`;\n }\n if (this.authReferrerPolicy) {\n url += `&auth_referrer_policy=${this.authReferrerPolicy}`;\n }\n return url;\n }\n deleteScript() {\n const script = document.getElementById(this.id);\n if (script) {\n script.remove();\n }\n }\n /**\n * Load the Google Maps JavaScript API script and return a Promise.\n * @deprecated, use importLibrary() instead.\n */\n load() {\n return this.loadPromise();\n }\n /**\n * Load the Google Maps JavaScript API script and return a Promise.\n *\n * @ignore\n * @deprecated, use importLibrary() instead.\n */\n loadPromise() {\n return new Promise((resolve, reject) => {\n this.loadCallback((err) => {\n if (!err) {\n resolve(window.google);\n }\n else {\n reject(err.error);\n }\n });\n });\n }\n importLibrary(name) {\n this.execute();\n return google.maps.importLibrary(name);\n }\n /**\n * Load the Google Maps JavaScript API script with a callback.\n * @deprecated, use importLibrary() instead.\n */\n loadCallback(fn) {\n this.callbacks.push(fn);\n this.execute();\n }\n /**\n * Set the script on document.\n */\n setScript() {\n var _a, _b;\n if (document.getElementById(this.id)) {\n // TODO wrap onerror callback for cases where the script was loaded elsewhere\n this.callback();\n return;\n }\n const params = {\n key: this.apiKey,\n channel: this.channel,\n client: this.client,\n libraries: this.libraries.length && this.libraries,\n v: this.version,\n mapIds: this.mapIds,\n language: this.language,\n region: this.region,\n authReferrerPolicy: this.authReferrerPolicy,\n };\n // keep the URL minimal:\n Object.keys(params).forEach(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (key) => !params[key] && delete params[key]);\n if (!((_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.importLibrary)) {\n // tweaked copy of https://developers.google.com/maps/documentation/javascript/load-maps-js-api#dynamic-library-import\n // which also sets the base url, the id, and the nonce\n /* eslint-disable */\n ((g) => {\n // @ts-ignore\n let h, a, k, p = \"The Google Maps JavaScript API\", c = \"google\", l = \"importLibrary\", q = \"__ib__\", m = document, b = window;\n // @ts-ignore\n b = b[c] || (b[c] = {});\n // @ts-ignore\n const d = b.maps || (b.maps = {}), r = new Set(), e = new URLSearchParams(), u = () => \n // @ts-ignore\n h || (h = new Promise((f, n) => __awaiter(this, void 0, void 0, function* () {\n var _a;\n yield (a = m.createElement(\"script\"));\n a.id = this.id;\n e.set(\"libraries\", [...r] + \"\");\n // @ts-ignore\n for (k in g)\n e.set(k.replace(/[A-Z]/g, (t) => \"_\" + t[0].toLowerCase()), g[k]);\n e.set(\"callback\", c + \".maps.\" + q);\n a.src = this.url + `?` + e;\n d[q] = f;\n a.onerror = () => (h = n(Error(p + \" could not load.\")));\n // @ts-ignore\n a.nonce = this.nonce || ((_a = m.querySelector(\"script[nonce]\")) === null || _a === void 0 ? void 0 : _a.nonce) || \"\";\n m.head.append(a);\n })));\n // @ts-ignore\n d[l] ? console.warn(p + \" only loads once. Ignoring:\", g) : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n)));\n })(params);\n /* eslint-enable */\n }\n // While most libraries populate the global namespace when loaded via bootstrap params,\n // this is not the case for \"marker\" when used with the inline bootstrap loader\n // (and maybe others in the future). So ensure there is an importLibrary for each:\n const libraryPromises = this.libraries.map((library) => this.importLibrary(library));\n // ensure at least one library, to kick off loading...\n if (!libraryPromises.length) {\n libraryPromises.push(this.importLibrary(\"core\"));\n }\n Promise.all(libraryPromises).then(() => this.callback(), (error) => {\n const event = new ErrorEvent(\"error\", { error }); // for backwards compat\n this.loadErrorCallback(event);\n });\n }\n /**\n * Reset the loader state.\n */\n reset() {\n this.deleteScript();\n this.done = false;\n this.loading = false;\n this.errors = [];\n this.onerrorEvent = null;\n }\n resetIfRetryingFailed() {\n if (this.failed) {\n this.reset();\n }\n }\n loadErrorCallback(e) {\n this.errors.push(e);\n if (this.errors.length <= this.retries) {\n const delay = this.errors.length * Math.pow(2, this.errors.length);\n console.error(`Failed to load Google Maps script, retrying in ${delay} ms.`);\n setTimeout(() => {\n this.deleteScript();\n this.setScript();\n }, delay);\n }\n else {\n this.onerrorEvent = e;\n this.callback();\n }\n }\n callback() {\n this.done = true;\n this.loading = false;\n this.callbacks.forEach((cb) => {\n cb(this.onerrorEvent);\n });\n this.callbacks = [];\n }\n execute() {\n this.resetIfRetryingFailed();\n if (this.loading) {\n // do nothing but wait\n return;\n }\n if (this.done) {\n this.callback();\n }\n else {\n // short circuit and warn if google.maps is already loaded\n if (window.google && window.google.maps && window.google.maps.version) {\n console.warn(\"Google Maps already loaded outside @googlemaps/js-api-loader. \" +\n \"This may result in undesirable behavior as options and script parameters may not match.\");\n this.callback();\n return;\n }\n this.loading = true;\n this.setScript();\n }\n }\n}\n\nexport { DEFAULT_ID, Loader, LoaderStatus };\n//# sourceMappingURL=index.mjs.map\n","import {\n memo,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\n\nimport {\n applyUpdatersToPropsAndRegisterEvents,\n unregisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {}\n\nconst updaterMap = {\n options(\n instance: google.maps.TrafficLayer,\n options: google.maps.TrafficLayerOptions\n ): void {\n instance.setOptions(options)\n },\n}\n\ntype TrafficLayerState = {\n trafficLayer: google.maps.TrafficLayer | null\n}\n\nexport type TrafficLayerProps = {\n options?: google.maps.TrafficLayerOptions | undefined\n /** This callback is called when the trafficLayer instance has loaded. It is called with the trafficLayer instance. */\n onLoad?: ((trafficLayer: google.maps.TrafficLayer) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the trafficLayer instance. */\n onUnmount?: ((trafficLayer: google.maps.TrafficLayer) => void) | undefined\n}\n\nfunction TrafficLayerFunctional({\n options,\n onLoad,\n onUnmount,\n}: TrafficLayerProps): null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(\n null\n )\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n if (options && instance !== null) {\n instance.setOptions(options)\n }\n }, [instance, options])\n\n useEffect(() => {\n const trafficLayer = new google.maps.TrafficLayer({\n ...options,\n map,\n })\n\n setInstance(trafficLayer)\n\n if (onLoad) {\n onLoad(trafficLayer)\n }\n\n return () => {\n if (instance !== null) {\n if (onUnmount) {\n onUnmount(instance)\n }\n\n instance.setMap(null)\n }\n }\n }, [])\n\n return null\n}\n\nexport const TrafficLayerF = memo(TrafficLayerFunctional)\n\nexport class TrafficLayer extends PureComponent<\n TrafficLayerProps,\n TrafficLayerState\n> {\n static override contextType = MapContext\n declare context: ContextType\n\n override state: TrafficLayerState = {\n trafficLayer: null,\n }\n\n setTrafficLayerCallback = () => {\n if (this.state.trafficLayer !== null && this.props.onLoad) {\n this.props.onLoad(this.state.trafficLayer)\n }\n }\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override componentDidMount(): void {\n const trafficLayer = new google.maps.TrafficLayer({\n ...this.props.options,\n map: this.context,\n })\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: trafficLayer,\n })\n\n this.setState(function setTrafficLayer() {\n return {\n trafficLayer,\n }\n }, this.setTrafficLayerCallback)\n }\n\n override componentDidUpdate(prevProps: TrafficLayerProps): void {\n if (this.state.trafficLayer !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.trafficLayer,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.trafficLayer !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.trafficLayer)\n }\n\n unregisterEvents(this.registeredEvents)\n\n this.state.trafficLayer.setMap(null)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default TrafficLayer\n","import {\n memo,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\n\nimport MapContext from '../../map-context.js'\n\ntype BicyclingLayerState = {\n bicyclingLayer: google.maps.BicyclingLayer | null\n}\n\nexport type BicyclingLayerProps = {\n /** This callback is called when the bicyclingLayer instance has loaded. It is called with the bicyclingLayer instance. */\n onLoad?: ((bicyclingLayer: google.maps.BicyclingLayer) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the bicyclingLayer instance. */\n onUnmount?: ((bicyclingLayer: google.maps.BicyclingLayer) => void) | undefined\n}\n\nfunction BicyclingLayerFunctional({\n onLoad,\n onUnmount,\n}: BicyclingLayerProps): null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(\n null\n )\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n const bicyclingLayer = new google.maps.BicyclingLayer()\n\n setInstance(bicyclingLayer)\n\n bicyclingLayer.setMap(map)\n\n if (onLoad) {\n onLoad(bicyclingLayer)\n }\n\n return () => {\n if (bicyclingLayer !== null) {\n if (onUnmount) {\n onUnmount(bicyclingLayer)\n }\n\n bicyclingLayer.setMap(null)\n }\n }\n }, [])\n\n return null\n}\n\nexport const BicyclingLayerF = memo(BicyclingLayerFunctional)\n\nexport class BicyclingLayer extends PureComponent<\n BicyclingLayerProps,\n BicyclingLayerState\n> {\n static override contextType = MapContext\n declare context: ContextType\n\n override state: BicyclingLayerState = {\n bicyclingLayer: null,\n }\n\n override componentDidMount(): void {\n const bicyclingLayer = new google.maps.BicyclingLayer()\n\n this.setState(() => {\n return {\n bicyclingLayer,\n }\n }, this.setBicyclingLayerCallback)\n }\n\n override componentWillUnmount(): void {\n if (this.state.bicyclingLayer !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.bicyclingLayer)\n }\n\n this.state.bicyclingLayer.setMap(null)\n }\n }\n\n setBicyclingLayerCallback = (): void => {\n if (this.state.bicyclingLayer !== null) {\n this.state.bicyclingLayer.setMap(this.context)\n\n if (this.props.onLoad) {\n this.props.onLoad(this.state.bicyclingLayer)\n }\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default BicyclingLayer\n","import {\n memo,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\n\nimport MapContext from '../../map-context.js'\n\ntype TransitLayerState = {\n transitLayer: google.maps.TransitLayer | null\n}\n\nexport type TransitLayerProps = {\n /** This callback is called when the transitLayer instance has loaded. It is called with the transitLayer instance. */\n onLoad?: ((transitLayer: google.maps.TransitLayer) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the transitLayer instance. */\n onUnmount?: ((transitLayer: google.maps.TransitLayer) => void) | undefined\n}\n\nfunction TransitLayerFunctional({\n onLoad,\n onUnmount,\n}: TransitLayerProps): null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(\n null\n )\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n const transitLayer = new google.maps.TransitLayer()\n\n setInstance(transitLayer)\n\n transitLayer.setMap(map)\n\n if (onLoad) {\n onLoad(transitLayer)\n }\n\n return () => {\n if (instance !== null) {\n if (onUnmount) {\n onUnmount(instance)\n }\n\n instance.setMap(null)\n }\n }\n }, [])\n\n return null\n}\n\nexport const TransitLayerF = memo(TransitLayerFunctional)\n\nexport class TransitLayer extends PureComponent<\n TransitLayerProps,\n TransitLayerState\n> {\n static override contextType = MapContext\n declare context: ContextType\n\n override state: TransitLayerState = {\n transitLayer: null,\n }\n\n setTransitLayerCallback = (): void => {\n if (this.state.transitLayer !== null) {\n this.state.transitLayer.setMap(this.context)\n\n if (this.props.onLoad) {\n this.props.onLoad(this.state.transitLayer)\n }\n }\n }\n\n override componentDidMount(): void {\n const transitLayer = new google.maps.TransitLayer()\n\n this.setState(function setTransitLayer() {\n return {\n transitLayer,\n }\n }, this.setTransitLayerCallback)\n }\n\n override componentWillUnmount(): void {\n if (this.state.transitLayer !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.transitLayer)\n }\n\n this.state.transitLayer.setMap(null)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default TransitLayer\n","/* globals google */\nimport {\n memo,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\n\nimport invariant from 'invariant'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onCircleComplete: 'circlecomplete',\n onMarkerComplete: 'markercomplete',\n onOverlayComplete: 'overlaycomplete',\n onPolygonComplete: 'polygoncomplete',\n onPolylineComplete: 'polylinecomplete',\n onRectangleComplete: 'rectanglecomplete',\n}\n\nconst updaterMap = {\n drawingMode(\n instance: google.maps.drawing.DrawingManager,\n drawingMode: google.maps.drawing.OverlayType | null\n ): void {\n instance.setDrawingMode(drawingMode)\n },\n options(\n instance: google.maps.drawing.DrawingManager,\n options: google.maps.drawing.DrawingManagerOptions\n ): void {\n instance.setOptions(options)\n },\n}\n\ntype DrawingManagerState = {\n drawingManager: google.maps.drawing.DrawingManager | null\n}\n\nexport type DrawingManagerProps = {\n options?: google.maps.drawing.DrawingManagerOptions | undefined\n /** Changes the DrawingManager's drawing mode, which defines the type of overlay to be added on the map. Accepted values are 'marker', 'polygon', 'polyline', 'rectangle', 'circle', or null. A drawing mode of null means that the user can interact with the map as normal, and clicks do not draw anything. */\n drawingMode?: google.maps.drawing.OverlayType | null | undefined\n /** This event is fired when the user has finished drawing a circle. */\n onCircleComplete?: ((circle: google.maps.Circle) => void) | undefined\n /** This event is fired when the user has finished drawing a marker. */\n onMarkerComplete?: ((marker: google.maps.Marker) => void) | undefined\n /** This event is fired when the user has finished drawing an overlay of any type. */\n onOverlayComplete?:\n | ((e: google.maps.drawing.OverlayCompleteEvent) => void)\n | undefined\n /** This event is fired when the user has finished drawing a polygon. */\n onPolygonComplete?: ((polygon: google.maps.Polygon) => void) | undefined\n /** This event is fired when the user has finished drawing a polyline. */\n onPolylineComplete?: ((polyline: google.maps.Polyline) => void) | undefined\n /** This event is fired when the user has finished drawing a rectangle. */\n onRectangleComplete?: ((rectangle: google.maps.Rectangle) => void) | undefined\n /** This callback is called when the drawingManager instance has loaded. It is called with the drawingManager instance. */\n onLoad?:\n | ((drawingManager: google.maps.drawing.DrawingManager) => void)\n | undefined\n /** This callback is called when the component unmounts. It is called with the drawingManager instance. */\n onUnmount?:\n | ((drawingManager: google.maps.drawing.DrawingManager) => void)\n | undefined\n}\n\nfunction DrawingManagerFunctional({\n options,\n drawingMode,\n onCircleComplete,\n onMarkerComplete,\n onOverlayComplete,\n onPolygonComplete,\n onPolylineComplete,\n onRectangleComplete,\n onLoad,\n onUnmount,\n}: DrawingManagerProps): null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] =\n useState(null)\n\n const [circlecompleteListener, setCircleCompleteListener] =\n useState(null)\n const [markercompleteListener, setMarkerCompleteListener] =\n useState(null)\n const [overlaycompleteListener, setOverlayCompleteListener] =\n useState(null)\n const [polygoncompleteListener, setPolygonCompleteListener] =\n useState(null)\n const [polylinecompleteListener, setPolylineCompleteListener] =\n useState(null)\n const [rectanglecompleteListener, setRectangleCompleteListener] =\n useState(null)\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n if (options && instance !== null) {\n instance.setOptions(options)\n }\n }, [instance, options])\n\n useEffect(() => {\n if (instance !== null) {\n instance.setDrawingMode(drawingMode ?? null)\n }\n }, [instance, drawingMode])\n\n useEffect(() => {\n if (instance && onCircleComplete) {\n if (circlecompleteListener !== null) {\n google.maps.event.removeListener(circlecompleteListener)\n }\n\n setCircleCompleteListener(\n google.maps.event.addListener(\n instance,\n 'circlecomplete',\n onCircleComplete\n )\n )\n }\n }, [instance, onCircleComplete])\n\n useEffect(() => {\n if (instance && onMarkerComplete) {\n if (markercompleteListener !== null) {\n google.maps.event.removeListener(markercompleteListener)\n }\n\n setMarkerCompleteListener(\n google.maps.event.addListener(\n instance,\n 'markercomplete',\n onMarkerComplete\n )\n )\n }\n }, [instance, onMarkerComplete])\n\n useEffect(() => {\n if (instance && onOverlayComplete) {\n if (overlaycompleteListener !== null) {\n google.maps.event.removeListener(overlaycompleteListener)\n }\n\n setOverlayCompleteListener(\n google.maps.event.addListener(\n instance,\n 'overlaycomplete',\n onOverlayComplete\n )\n )\n }\n }, [instance, onOverlayComplete])\n\n useEffect(() => {\n if (instance && onPolygonComplete) {\n if (polygoncompleteListener !== null) {\n google.maps.event.removeListener(polygoncompleteListener)\n }\n\n setPolygonCompleteListener(\n google.maps.event.addListener(\n instance,\n 'polygoncomplete',\n onPolygonComplete\n )\n )\n }\n }, [instance, onPolygonComplete])\n\n useEffect(() => {\n if (instance && onPolylineComplete) {\n if (polylinecompleteListener !== null) {\n google.maps.event.removeListener(polylinecompleteListener)\n }\n\n setPolylineCompleteListener(\n google.maps.event.addListener(\n instance,\n 'polylinecomplete',\n onPolylineComplete\n )\n )\n }\n }, [instance, onPolylineComplete])\n\n useEffect(() => {\n if (instance && onRectangleComplete) {\n if (rectanglecompleteListener !== null) {\n google.maps.event.removeListener(rectanglecompleteListener)\n }\n\n setRectangleCompleteListener(\n google.maps.event.addListener(\n instance,\n 'rectanglecomplete',\n onRectangleComplete\n )\n )\n }\n }, [instance, onRectangleComplete])\n\n useEffect(() => {\n invariant(\n !!google.maps.drawing,\n `Did you include prop libraries={['drawing']} in the URL? %s`,\n google.maps.drawing\n )\n\n const drawingManager = new google.maps.drawing.DrawingManager({\n ...options,\n map,\n })\n\n if (drawingMode) {\n drawingManager.setDrawingMode(drawingMode)\n }\n\n if (onCircleComplete) {\n setCircleCompleteListener(\n google.maps.event.addListener(\n drawingManager,\n 'circlecomplete',\n onCircleComplete\n )\n )\n }\n\n if (onMarkerComplete) {\n setMarkerCompleteListener(\n google.maps.event.addListener(\n drawingManager,\n 'markercomplete',\n onMarkerComplete\n )\n )\n }\n\n if (onOverlayComplete) {\n setOverlayCompleteListener(\n google.maps.event.addListener(\n drawingManager,\n 'overlaycomplete',\n onOverlayComplete\n )\n )\n }\n\n if (onPolygonComplete) {\n setPolygonCompleteListener(\n google.maps.event.addListener(\n drawingManager,\n 'polygoncomplete',\n onPolygonComplete\n )\n )\n }\n\n if (onPolylineComplete) {\n setPolylineCompleteListener(\n google.maps.event.addListener(\n drawingManager,\n 'polylinecomplete',\n onPolylineComplete\n )\n )\n }\n\n if (onRectangleComplete) {\n setRectangleCompleteListener(\n google.maps.event.addListener(\n drawingManager,\n 'rectanglecomplete',\n onRectangleComplete\n )\n )\n }\n\n setInstance(drawingManager)\n\n if (onLoad) {\n onLoad(drawingManager)\n }\n\n return () => {\n if (instance !== null) {\n if (circlecompleteListener) {\n google.maps.event.removeListener(circlecompleteListener)\n }\n\n if (markercompleteListener) {\n google.maps.event.removeListener(markercompleteListener)\n }\n\n if (overlaycompleteListener) {\n google.maps.event.removeListener(overlaycompleteListener)\n }\n\n if (polygoncompleteListener) {\n google.maps.event.removeListener(polygoncompleteListener)\n }\n\n if (polylinecompleteListener) {\n google.maps.event.removeListener(polylinecompleteListener)\n }\n\n if (rectanglecompleteListener) {\n google.maps.event.removeListener(rectanglecompleteListener)\n }\n\n if (onUnmount) {\n onUnmount(instance)\n }\n\n instance.setMap(null)\n }\n }\n }, [])\n\n return null\n}\n\nexport const DrawingManagerF = memo(DrawingManagerFunctional)\n\nexport class DrawingManager extends PureComponent<\n DrawingManagerProps,\n DrawingManagerState\n> {\n static override contextType = MapContext\n\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: DrawingManagerState = {\n drawingManager: null,\n }\n\n constructor(props: DrawingManagerProps) {\n super(props)\n\n invariant(\n !!google.maps.drawing,\n `Did you include prop libraries={['drawing']} in the URL? %s`,\n google.maps.drawing\n )\n }\n\n setDrawingManagerCallback = (): void => {\n if (this.state.drawingManager !== null && this.props.onLoad) {\n this.props.onLoad(this.state.drawingManager)\n }\n }\n\n override componentDidMount(): void {\n const drawingManager = new google.maps.drawing.DrawingManager({\n ...this.props.options,\n map: this.context,\n })\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: drawingManager,\n })\n\n this.setState(function setDrawingManager() {\n return {\n drawingManager,\n }\n }, this.setDrawingManagerCallback)\n }\n\n override componentDidUpdate(prevProps: DrawingManagerProps): void {\n if (this.state.drawingManager !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.drawingManager,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.drawingManager !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.drawingManager)\n }\n\n unregisterEvents(this.registeredEvents)\n\n this.state.drawingManager.setMap(null)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default DrawingManager\n","import {\n memo,\n useMemo,\n Children,\n useState,\n type JSX,\n useEffect,\n useContext,\n cloneElement,\n PureComponent,\n isValidElement,\n type ReactNode,\n type ContextType,\n type ReactElement,\n} from 'react'\nimport type { Clusterer } from '@react-google-maps/marker-clusterer'\nimport type { MarkerClusterer as GoogleClusterer } from '@googlemaps/markerclusterer'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\nimport type { HasMarkerAnchor } from '../../types.js'\n\nconst eventMap = {\n onAnimationChanged: 'animation_changed',\n onClick: 'click',\n onClickableChanged: 'clickable_changed',\n onCursorChanged: 'cursor_changed',\n onDblClick: 'dblclick',\n onDrag: 'drag',\n onDragEnd: 'dragend',\n onDraggableChanged: 'draggable_changed',\n onDragStart: 'dragstart',\n onFlatChanged: 'flat_changed',\n onIconChanged: 'icon_changed',\n onMouseDown: 'mousedown',\n onMouseOut: 'mouseout',\n onMouseOver: 'mouseover',\n onMouseUp: 'mouseup',\n onPositionChanged: 'position_changed',\n onRightClick: 'rightclick',\n onShapeChanged: 'shape_changed',\n onTitleChanged: 'title_changed',\n onVisibleChanged: 'visible_changed',\n onZindexChanged: 'zindex_changed',\n}\n\nconst updaterMap = {\n animation(\n instance: google.maps.Marker,\n animation: google.maps.Animation\n ): void {\n instance.setAnimation(animation)\n },\n clickable(instance: google.maps.Marker, clickable: boolean): void {\n instance.setClickable(clickable)\n },\n cursor(instance: google.maps.Marker, cursor: string): void {\n instance.setCursor(cursor)\n },\n draggable(instance: google.maps.Marker, draggable: boolean): void {\n instance.setDraggable(draggable)\n },\n icon(\n instance: google.maps.Marker,\n icon: string | google.maps.Icon | google.maps.Symbol\n ): void {\n instance.setIcon(icon)\n },\n label(\n instance: google.maps.Marker,\n label: string | google.maps.MarkerLabel\n ): void {\n instance.setLabel(label)\n },\n map(instance: google.maps.Marker, map: google.maps.Map): void {\n instance.setMap(map)\n },\n opacity(instance: google.maps.Marker, opacity: number): void {\n instance.setOpacity(opacity)\n },\n options(\n instance: google.maps.Marker,\n options: google.maps.MarkerOptions\n ): void {\n instance.setOptions(options)\n },\n position(\n instance: google.maps.Marker,\n position: google.maps.LatLng | google.maps.LatLngLiteral\n ): void {\n instance.setPosition(position)\n },\n shape(instance: google.maps.Marker, shape: google.maps.MarkerShape): void {\n instance.setShape(shape)\n },\n title(instance: google.maps.Marker, title: string): void {\n instance.setTitle(title)\n },\n visible(instance: google.maps.Marker, visible: boolean): void {\n instance.setVisible(visible)\n },\n zIndex(instance: google.maps.Marker, zIndex: number): void {\n instance.setZIndex(zIndex)\n },\n}\n\nexport type MarkerProps = {\n // required\n /** Marker position. */\n position: google.maps.LatLng | google.maps.LatLngLiteral\n\n children?: ReactNode | undefined\n options?: google.maps.MarkerOptions | undefined\n /** Start an animation. Any ongoing animation will be cancelled. Currently supported animations are: BOUNCE, DROP. Passing in null will cause any animation to stop. */\n animation?: google.maps.Animation | undefined\n /** If true, the marker receives mouse and touch events. Default value is true. */\n clickable?: boolean | undefined\n /** Mouse cursor to show on hover */\n cursor?: string | undefined\n /** If true, the marker can be dragged. Default value is false. */\n draggable?: boolean | undefined\n /** Icon for the foreground. If a string is provided, it is treated as though it were an Icon with the string as url. */\n icon?: string | google.maps.Icon | google.maps.Symbol | undefined\n /** Adds a label to the marker. The label can either be a string, or a MarkerLabel object. */\n label?: string | google.maps.MarkerLabel | undefined\n /** The marker's opacity between 0.0 and 1.0. */\n opacity?: number | undefined\n\n /** Image map region definition used for drag/click. */\n shape?: google.maps.MarkerShape | undefined\n /** Rollover text */\n title?: string | undefined\n /** If true, the marker is visible */\n visible?: boolean | undefined\n /** All markers are displayed on the map in order of their zIndex, with higher values displaying in front of markers with lower values. By default, markers are displayed according to their vertical position on screen, with lower markers appearing in front of markers further up the screen. */\n zIndex?: number | undefined\n /** Render prop that handles clustering markers */\n clusterer?: Clusterer | GoogleClusterer | undefined\n /** Clusters are redrawn when a Marker is added unless noClustererRedraw? is set to true. */\n noClustererRedraw?: boolean | undefined\n /** This event is fired when the marker icon was clicked. */\n onClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the marker's clickable property changes. */\n onClickableChanged?: (() => void) | undefined\n /** This event is fired when the marker's cursor property changes. */\n onCursorChanged?: (() => void) | undefined\n /** This event is fired when the marker's animation property changes. */\n onAnimationChanged?: (() => void) | undefined\n /** This event is fired when the marker icon was double clicked. */\n onDblClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is repeatedly fired while the user drags the marker. */\n onDrag?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the user stops dragging the marker. */\n onDragEnd?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the marker's draggable property changes. */\n onDraggableChanged?: (() => void) | undefined\n /** This event is fired when the user starts dragging the marker. */\n onDragStart?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the marker's flat property changes. */\n onFlatChanged?: (() => void) | undefined\n /** This event is fired when the marker icon property changes. */\n onIconChanged?: (() => void) | undefined\n /** This event is fired for a mousedown on the marker. */\n onMouseDown?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the mouse leaves the area of the marker icon. */\n onMouseOut?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the mouse enters the area of the marker icon. */\n onMouseOver?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired for a mouseup on the marker. */\n onMouseUp?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the marker position property changes. */\n onPositionChanged?: (() => void) | undefined\n /** This event is fired for a rightclick on the marker. */\n onRightClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the marker's shape property changes. */\n onShapeChanged?: (() => void) | undefined\n /** This event is fired when the marker title property changes. */\n onTitleChanged?: (() => void) | undefined\n /** This event is fired when the marker's visible property changes. */\n onVisibleChanged?: (() => void) | undefined\n /** This event is fired when the marker's zIndex property changes. */\n onZindexChanged?: (() => void) | undefined\n /** This callback is called when the marker instance has loaded. It is called with the marker instance. */\n onLoad?: ((marker: google.maps.Marker) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the marker instance. */\n onUnmount?: ((marker: google.maps.Marker) => void) | undefined\n}\n\nconst defaultOptions = {}\n\nfunction MarkerFunctional({\n position,\n options,\n clusterer,\n noClustererRedraw,\n\n children,\n\n draggable,\n visible,\n animation,\n clickable,\n cursor,\n icon,\n label,\n opacity,\n shape,\n title,\n zIndex,\n onClick,\n onDblClick,\n onDrag,\n onDragEnd,\n onDragStart,\n onMouseOut,\n onMouseOver,\n onMouseUp,\n onMouseDown,\n onRightClick,\n onClickableChanged,\n onCursorChanged,\n onAnimationChanged,\n onDraggableChanged,\n onFlatChanged,\n onIconChanged,\n onPositionChanged,\n onShapeChanged,\n onTitleChanged,\n onVisibleChanged,\n onZindexChanged,\n onLoad,\n onUnmount,\n}: MarkerProps): JSX.Element | null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(null)\n\n const [dblclickListener, setDblclickListener] =\n useState(null)\n const [dragendListener, setDragendListener] =\n useState(null)\n const [dragstartListener, setDragstartListener] =\n useState(null)\n const [mousedownListener, setMousedownListener] =\n useState(null)\n const [mouseoutListener, setMouseoutListener] =\n useState(null)\n const [mouseoverListener, setMouseoverListener] =\n useState(null)\n const [mouseupListener, setMouseupListener] =\n useState(null)\n const [rightclickListener, setRightclickListener] =\n useState(null)\n const [clickListener, setClickListener] =\n useState(null)\n const [dragListener, setDragListener] =\n useState(null)\n\n const [clickableChangedListener, setClickableChangedListener] =\n useState(null)\n const [cursorChangedListener, setCursorChangedListener] =\n useState(null)\n const [animationChangedListener, setAnimationChangedListener] =\n useState(null)\n const [draggableChangedListener, setDraggableChangedListener] =\n useState(null)\n const [flatChangedListener, setFlatChangedListener] =\n useState(null)\n const [iconChangedListener, setIconChangedListener] =\n useState(null)\n const [positionChangedListener, setPositionChangedListener] =\n useState(null)\n const [shapeChangedListener, setShapeChangedListener] =\n useState(null)\n const [titleChangedListener, setTitleChangedListener] =\n useState(null)\n const [visibleChangedListener, setVisibleChangedListener] =\n useState(null)\n const [zIndexChangedListener, setZindexChangedListener] =\n useState(null)\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n if (typeof options !== 'undefined' && instance !== null) {\n instance.setOptions(options)\n }\n }, [instance, options])\n\n useEffect(() => {\n if (typeof draggable !== 'undefined' && instance !== null) {\n instance.setDraggable(draggable)\n }\n }, [instance, draggable])\n\n useEffect(() => {\n if (position && instance !== null) {\n instance.setPosition(position)\n }\n }, [instance, position])\n\n useEffect(() => {\n if (typeof visible !== 'undefined' && instance !== null) {\n instance.setVisible(visible)\n }\n }, [instance, visible])\n\n useEffect(() => {\n instance?.setAnimation(animation)\n }, [instance, animation])\n\n useEffect(() => {\n if (instance && clickable !== undefined) {\n instance.setClickable(clickable)\n }\n }, [instance, clickable])\n\n useEffect(() => {\n if (instance && cursor !== undefined) {\n instance.setCursor(cursor)\n }\n }, [instance, cursor])\n\n useEffect(() => {\n if (instance && icon !== undefined) {\n instance.setIcon(icon)\n }\n }, [instance, icon])\n\n useEffect(() => {\n if (instance && label !== undefined) {\n instance.setLabel(label)\n }\n }, [instance, label])\n\n useEffect(() => {\n if (instance && opacity !== undefined) {\n instance.setOpacity(opacity)\n }\n }, [instance, opacity])\n\n useEffect(() => {\n if (instance && shape !== undefined) {\n instance.setShape(shape)\n }\n }, [instance, shape])\n\n useEffect(() => {\n if (instance && title !== undefined) {\n instance.setTitle(title)\n }\n }, [instance, title])\n\n useEffect(() => {\n if (instance && zIndex !== undefined) {\n instance.setZIndex(zIndex)\n }\n }, [instance, zIndex])\n\n useEffect(() => {\n if (instance && onDblClick) {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n setDblclickListener(\n google.maps.event.addListener(instance, 'dblclick', onDblClick)\n )\n }\n }, [onDblClick])\n\n useEffect(() => {\n if (instance && onDragEnd) {\n if (dragendListener !== null) {\n google.maps.event.removeListener(dragendListener)\n }\n\n setDragendListener(\n google.maps.event.addListener(instance, 'dragend', onDragEnd)\n )\n }\n }, [onDragEnd])\n\n useEffect(() => {\n if (instance && onDragStart) {\n if (dragstartListener !== null) {\n google.maps.event.removeListener(dragstartListener)\n }\n\n setDragstartListener(\n google.maps.event.addListener(instance, 'dragstart', onDragStart)\n )\n }\n }, [onDragStart])\n\n useEffect(() => {\n if (instance && onMouseDown) {\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n setMousedownListener(\n google.maps.event.addListener(instance, 'mousedown', onMouseDown)\n )\n }\n }, [onMouseDown])\n\n useEffect(() => {\n if (instance && onMouseOut) {\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n setMouseoutListener(\n google.maps.event.addListener(instance, 'mouseout', onMouseOut)\n )\n }\n }, [onMouseOut])\n\n useEffect(() => {\n if (instance && onMouseOver) {\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n setMouseoverListener(\n google.maps.event.addListener(instance, 'mouseover', onMouseOver)\n )\n }\n }, [onMouseOver])\n\n useEffect(() => {\n if (instance && onMouseUp) {\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n setMouseupListener(\n google.maps.event.addListener(instance, 'mouseup', onMouseUp)\n )\n }\n }, [onMouseUp])\n\n useEffect(() => {\n if (instance && onRightClick) {\n if (rightclickListener !== null) {\n google.maps.event.removeListener(rightclickListener)\n }\n\n setRightclickListener(\n google.maps.event.addListener(instance, 'rightclick', onRightClick)\n )\n }\n }, [onRightClick])\n\n useEffect(() => {\n if (instance && onClick) {\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n setClickListener(\n google.maps.event.addListener(instance, 'click', onClick)\n )\n }\n }, [onClick])\n\n useEffect(() => {\n if (instance && onDrag) {\n if (dragListener !== null) {\n google.maps.event.removeListener(dragListener)\n }\n\n setDragListener(google.maps.event.addListener(instance, 'drag', onDrag))\n }\n }, [onDrag])\n\n useEffect(() => {\n if (instance && onClickableChanged) {\n if (clickableChangedListener !== null) {\n google.maps.event.removeListener(clickableChangedListener)\n }\n\n setClickableChangedListener(\n google.maps.event.addListener(\n instance,\n 'clickable_changed',\n onClickableChanged\n )\n )\n }\n }, [onClickableChanged])\n\n useEffect(() => {\n if (instance && onCursorChanged) {\n if (cursorChangedListener !== null) {\n google.maps.event.removeListener(cursorChangedListener)\n }\n\n setCursorChangedListener(\n google.maps.event.addListener(\n instance,\n 'cursor_changed',\n onCursorChanged\n )\n )\n }\n }, [onCursorChanged])\n\n useEffect(() => {\n if (instance && onAnimationChanged) {\n if (animationChangedListener !== null) {\n google.maps.event.removeListener(animationChangedListener)\n }\n\n setAnimationChangedListener(\n google.maps.event.addListener(\n instance,\n 'animation_changed',\n onAnimationChanged\n )\n )\n }\n }, [onAnimationChanged])\n\n useEffect(() => {\n if (instance && onDraggableChanged) {\n if (draggableChangedListener !== null) {\n google.maps.event.removeListener(draggableChangedListener)\n }\n\n setDraggableChangedListener(\n google.maps.event.addListener(\n instance,\n 'draggable_changed',\n onDraggableChanged\n )\n )\n }\n }, [onDraggableChanged])\n\n useEffect(() => {\n if (instance && onFlatChanged) {\n if (flatChangedListener !== null) {\n google.maps.event.removeListener(flatChangedListener)\n }\n\n setFlatChangedListener(\n google.maps.event.addListener(instance, 'flat_changed', onFlatChanged)\n )\n }\n }, [onFlatChanged])\n\n useEffect(() => {\n if (instance && onIconChanged) {\n if (iconChangedListener !== null) {\n google.maps.event.removeListener(iconChangedListener)\n }\n\n setIconChangedListener(\n google.maps.event.addListener(instance, 'icon_changed', onIconChanged)\n )\n }\n }, [onIconChanged])\n\n useEffect(() => {\n if (instance && onPositionChanged) {\n if (positionChangedListener !== null) {\n google.maps.event.removeListener(positionChangedListener)\n }\n\n setPositionChangedListener(\n google.maps.event.addListener(\n instance,\n 'position_changed',\n onPositionChanged\n )\n )\n }\n }, [onPositionChanged])\n\n useEffect(() => {\n if (instance && onShapeChanged) {\n if (shapeChangedListener !== null) {\n google.maps.event.removeListener(shapeChangedListener)\n }\n\n setShapeChangedListener(\n google.maps.event.addListener(instance, 'shape_changed', onShapeChanged)\n )\n }\n }, [onShapeChanged])\n\n useEffect(() => {\n if (instance && onTitleChanged) {\n if (titleChangedListener !== null) {\n google.maps.event.removeListener(titleChangedListener)\n }\n\n setTitleChangedListener(\n google.maps.event.addListener(instance, 'title_changed', onTitleChanged)\n )\n }\n }, [onTitleChanged])\n\n useEffect(() => {\n if (instance && onVisibleChanged) {\n if (visibleChangedListener !== null) {\n google.maps.event.removeListener(visibleChangedListener)\n }\n\n setVisibleChangedListener(\n google.maps.event.addListener(\n instance,\n 'visible_changed',\n onVisibleChanged\n )\n )\n }\n }, [onVisibleChanged])\n\n useEffect(() => {\n if (instance && onZindexChanged) {\n if (zIndexChangedListener !== null) {\n google.maps.event.removeListener(zIndexChangedListener)\n }\n\n setZindexChangedListener(\n google.maps.event.addListener(\n instance,\n 'zindex_changed',\n onZindexChanged\n )\n )\n }\n }, [onZindexChanged])\n\n useEffect(() => {\n const markerOptions = {\n ...(options || defaultOptions),\n ...(clusterer ? defaultOptions : { map }),\n position,\n }\n\n const marker = new google.maps.Marker(markerOptions)\n\n if (clusterer) {\n clusterer.addMarker(marker, !!noClustererRedraw)\n } else {\n marker.setMap(map)\n }\n\n if (position) {\n marker.setPosition(position)\n }\n\n if (typeof visible !== 'undefined') {\n marker.setVisible(visible)\n }\n\n if (typeof draggable !== 'undefined') {\n marker.setDraggable(draggable)\n }\n\n if (typeof clickable !== 'undefined') {\n marker.setClickable(clickable)\n }\n\n if (typeof cursor === 'string') {\n marker.setCursor(cursor)\n }\n\n if (icon) {\n marker.setIcon(icon)\n }\n\n if (typeof label !== 'undefined') {\n marker.setLabel(label)\n }\n\n if (typeof opacity !== 'undefined') {\n marker.setOpacity(opacity)\n }\n\n if (shape) {\n marker.setShape(shape)\n }\n\n if (typeof title === 'string') {\n marker.setTitle(title)\n }\n\n if (typeof zIndex === 'number') {\n marker.setZIndex(zIndex)\n }\n\n if (onDblClick) {\n setDblclickListener(\n google.maps.event.addListener(marker, 'dblclick', onDblClick)\n )\n }\n\n if (onDragEnd) {\n setDragendListener(\n google.maps.event.addListener(marker, 'dragend', onDragEnd)\n )\n }\n\n if (onDragStart) {\n setDragstartListener(\n google.maps.event.addListener(marker, 'dragstart', onDragStart)\n )\n }\n\n if (onMouseDown) {\n setMousedownListener(\n google.maps.event.addListener(marker, 'mousedown', onMouseDown)\n )\n }\n\n if (onMouseOut) {\n setMouseoutListener(\n google.maps.event.addListener(marker, 'mouseout', onMouseOut)\n )\n }\n\n if (onMouseOver) {\n setMouseoverListener(\n google.maps.event.addListener(marker, 'mouseover', onMouseOver)\n )\n }\n\n if (onMouseUp) {\n setMouseupListener(\n google.maps.event.addListener(marker, 'mouseup', onMouseUp)\n )\n }\n\n if (onRightClick) {\n setRightclickListener(\n google.maps.event.addListener(marker, 'rightclick', onRightClick)\n )\n }\n\n if (onClick) {\n setClickListener(google.maps.event.addListener(marker, 'click', onClick))\n }\n\n if (onDrag) {\n setDragListener(google.maps.event.addListener(marker, 'drag', onDrag))\n }\n\n if (onClickableChanged) {\n setClickableChangedListener(\n google.maps.event.addListener(\n marker,\n 'clickable_changed',\n onClickableChanged\n )\n )\n }\n\n if (onCursorChanged) {\n setCursorChangedListener(\n google.maps.event.addListener(marker, 'cursor_changed', onCursorChanged)\n )\n }\n\n if (onAnimationChanged) {\n setAnimationChangedListener(\n google.maps.event.addListener(\n marker,\n 'animation_changed',\n onAnimationChanged\n )\n )\n }\n\n if (onDraggableChanged) {\n setDraggableChangedListener(\n google.maps.event.addListener(\n marker,\n 'draggable_changed',\n onDraggableChanged\n )\n )\n }\n\n if (onFlatChanged) {\n setFlatChangedListener(\n google.maps.event.addListener(marker, 'flat_changed', onFlatChanged)\n )\n }\n\n if (onIconChanged) {\n setIconChangedListener(\n google.maps.event.addListener(marker, 'icon_changed', onIconChanged)\n )\n }\n\n if (onPositionChanged) {\n setPositionChangedListener(\n google.maps.event.addListener(\n marker,\n 'position_changed',\n onPositionChanged\n )\n )\n }\n\n if (onShapeChanged) {\n setShapeChangedListener(\n google.maps.event.addListener(marker, 'shape_changed', onShapeChanged)\n )\n }\n\n if (onTitleChanged) {\n setTitleChangedListener(\n google.maps.event.addListener(marker, 'title_changed', onTitleChanged)\n )\n }\n\n if (onVisibleChanged) {\n setVisibleChangedListener(\n google.maps.event.addListener(\n marker,\n 'visible_changed',\n onVisibleChanged\n )\n )\n }\n\n if (onZindexChanged) {\n setZindexChangedListener(\n google.maps.event.addListener(marker, 'zindex_changed', onZindexChanged)\n )\n }\n\n setInstance(marker)\n\n if (onLoad) {\n onLoad(marker)\n }\n\n return () => {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n if (dragendListener !== null) {\n google.maps.event.removeListener(dragendListener)\n }\n\n if (dragstartListener !== null) {\n google.maps.event.removeListener(dragstartListener)\n }\n\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n if (rightclickListener !== null) {\n google.maps.event.removeListener(rightclickListener)\n }\n\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n if (clickableChangedListener !== null) {\n google.maps.event.removeListener(clickableChangedListener)\n }\n\n if (cursorChangedListener !== null) {\n google.maps.event.removeListener(cursorChangedListener)\n }\n\n if (animationChangedListener !== null) {\n google.maps.event.removeListener(animationChangedListener)\n }\n\n if (draggableChangedListener !== null) {\n google.maps.event.removeListener(draggableChangedListener)\n }\n\n if (flatChangedListener !== null) {\n google.maps.event.removeListener(flatChangedListener)\n }\n\n if (iconChangedListener !== null) {\n google.maps.event.removeListener(iconChangedListener)\n }\n\n if (positionChangedListener !== null) {\n google.maps.event.removeListener(positionChangedListener)\n }\n\n if (titleChangedListener !== null) {\n google.maps.event.removeListener(titleChangedListener)\n }\n\n if (visibleChangedListener !== null) {\n google.maps.event.removeListener(visibleChangedListener)\n }\n\n if (zIndexChangedListener !== null) {\n google.maps.event.removeListener(zIndexChangedListener)\n }\n\n if (onUnmount) {\n onUnmount(marker)\n }\n\n if (clusterer) {\n clusterer.removeMarker(marker, !!noClustererRedraw)\n } else if (marker) {\n marker.setMap(null)\n }\n }\n }, [])\n\n const chx = useMemo(() => {\n return children\n ? Children.map(children, (child) => {\n if (!isValidElement(child)) {\n return child\n }\n\n const elementChild: ReactElement = child\n\n return cloneElement(elementChild, { anchor: instance })\n })\n : null\n }, [children, instance])\n\n return <>{chx}> || null\n}\n\nexport const MarkerF = memo(MarkerFunctional)\n\nexport class Marker extends PureComponent {\n static override contextType = MapContext\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n marker: google.maps.Marker | undefined\n\n override async componentDidMount(): Promise {\n const markerOptions = {\n ...(this.props.options || defaultOptions),\n ...(this.props.clusterer ? defaultOptions : { map: this.context }),\n position: this.props.position,\n }\n\n // Unfortunately we can't just do this in the contstructor, because the\n // `MapContext` might not be filled in yet.\n this.marker = new google.maps.Marker(markerOptions)\n\n if (this.props.clusterer) {\n this.props.clusterer.addMarker(\n this.marker,\n !!this.props.noClustererRedraw\n )\n } else {\n this.marker.setMap(this.context)\n }\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: this.marker,\n })\n\n if (this.props.onLoad) {\n this.props.onLoad(this.marker)\n }\n }\n\n override componentDidUpdate(prevProps: MarkerProps): void {\n if (this.marker) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.marker,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (!this.marker) {\n return\n }\n\n if (this.props.onUnmount) {\n this.props.onUnmount(this.marker)\n }\n\n unregisterEvents(this.registeredEvents)\n\n if (this.props.clusterer) {\n this.props.clusterer.removeMarker(\n this.marker,\n !!this.props.noClustererRedraw\n )\n } else if (this.marker) {\n this.marker.setMap(null)\n }\n }\n\n override render(): ReactNode {\n const children: ReactNode | null = this.props.children\n ? Children.map(this.props.children, (child) => {\n if (!isValidElement(child)) {\n return child\n }\n\n const elementChild: ReactElement = child\n\n return cloneElement(elementChild, { anchor: this.marker })\n })\n : null\n\n return children || null\n }\n}\n\nexport default Marker\n","var ClusterIcon = /** @class */ (function () {\n function ClusterIcon(cluster, styles) {\n cluster.getClusterer().extend(ClusterIcon, google.maps.OverlayView);\n this.cluster = cluster;\n this.clusterClassName = this.cluster.getClusterer().getClusterClass();\n this.className = this.clusterClassName;\n this.styles = styles;\n this.center = undefined;\n this.div = null;\n this.sums = null;\n this.visible = false;\n this.boundsChangedListener = null;\n this.url = '';\n this.height = 0;\n this.width = 0;\n this.anchorText = [0, 0];\n this.anchorIcon = [0, 0];\n this.textColor = 'black';\n this.textSize = 11;\n this.textDecoration = 'none';\n this.fontWeight = 'bold';\n this.fontStyle = 'normal';\n this.fontFamily = 'Arial,sans-serif';\n this.backgroundPosition = '0 0';\n this.cMouseDownInCluster = null;\n this.cDraggingMapByCluster = null;\n this.timeOut = null;\n this.setMap(cluster.getMap()); // Note: this causes onAdd to be called\n this.onBoundsChanged = this.onBoundsChanged.bind(this);\n this.onMouseDown = this.onMouseDown.bind(this);\n this.onClick = this.onClick.bind(this);\n this.onMouseOver = this.onMouseOver.bind(this);\n this.onMouseOut = this.onMouseOut.bind(this);\n this.onAdd = this.onAdd.bind(this);\n this.onRemove = this.onRemove.bind(this);\n this.draw = this.draw.bind(this);\n this.hide = this.hide.bind(this);\n this.show = this.show.bind(this);\n this.useStyle = this.useStyle.bind(this);\n this.setCenter = this.setCenter.bind(this);\n this.getPosFromLatLng = this.getPosFromLatLng.bind(this);\n }\n ClusterIcon.prototype.onBoundsChanged = function () {\n this.cDraggingMapByCluster = this.cMouseDownInCluster;\n };\n ClusterIcon.prototype.onMouseDown = function () {\n this.cMouseDownInCluster = true;\n this.cDraggingMapByCluster = false;\n };\n ClusterIcon.prototype.onClick = function (event) {\n this.cMouseDownInCluster = false;\n if (!this.cDraggingMapByCluster) {\n var markerClusterer_1 = this.cluster.getClusterer();\n /**\n * This event is fired when a cluster marker is clicked.\n * @name MarkerClusterer#click\n * @param {Cluster} c The cluster that was clicked.\n * @event\n */\n google.maps.event.trigger(markerClusterer_1, 'click', this.cluster);\n google.maps.event.trigger(markerClusterer_1, 'clusterclick', this.cluster); // deprecated name\n // The default click handler follows. Disable it by setting\n // the zoomOnClick property to false.\n if (markerClusterer_1.getZoomOnClick()) {\n // Zoom into the cluster.\n var maxZoom_1 = markerClusterer_1.getMaxZoom();\n var bounds_1 = this.cluster.getBounds();\n var map = markerClusterer_1.getMap();\n if (map !== null && 'fitBounds' in map) {\n map.fitBounds(bounds_1);\n }\n // There is a fix for Issue 170 here:\n this.timeOut = window.setTimeout(function () {\n var map = markerClusterer_1.getMap();\n if (map !== null) {\n if ('fitBounds' in map) {\n map.fitBounds(bounds_1);\n }\n var zoom = map.getZoom() || 0;\n // Don't zoom beyond the max zoom level\n if (maxZoom_1 !== null &&\n zoom > maxZoom_1) {\n map.setZoom(maxZoom_1 + 1);\n }\n }\n }, 100);\n }\n // Prevent event propagation to the map:\n event.cancelBubble = true;\n if (event.stopPropagation) {\n event.stopPropagation();\n }\n }\n };\n ClusterIcon.prototype.onMouseOver = function () {\n /**\n * This event is fired when the mouse moves over a cluster marker.\n * @name MarkerClusterer#mouseover\n * @param {Cluster} c The cluster that the mouse moved over.\n * @event\n */\n google.maps.event.trigger(this.cluster.getClusterer(), 'mouseover', this.cluster);\n };\n ClusterIcon.prototype.onMouseOut = function () {\n /**\n * This event is fired when the mouse moves out of a cluster marker.\n * @name MarkerClusterer#mouseout\n * @param {Cluster} c The cluster that the mouse moved out of.\n * @event\n */\n google.maps.event.trigger(this.cluster.getClusterer(), 'mouseout', this.cluster);\n };\n ClusterIcon.prototype.onAdd = function () {\n var _a;\n this.div = document.createElement('div');\n this.div.className = this.className;\n if (this.visible) {\n this.show();\n }\n (_a = this.getPanes()) === null || _a === void 0 ? void 0 : _a.overlayMouseTarget.appendChild(this.div);\n var map = this.getMap();\n if (map !== null) {\n // Fix for Issue 157\n this.boundsChangedListener = google.maps.event.addListener(map, 'bounds_changed', this.onBoundsChanged);\n this.div.addEventListener('mousedown', this.onMouseDown);\n this.div.addEventListener('click', this.onClick);\n this.div.addEventListener('mouseover', this.onMouseOver);\n this.div.addEventListener('mouseout', this.onMouseOut);\n }\n };\n ClusterIcon.prototype.onRemove = function () {\n if (this.div && this.div.parentNode) {\n this.hide();\n if (this.boundsChangedListener !== null) {\n google.maps.event.removeListener(this.boundsChangedListener);\n }\n this.div.removeEventListener('mousedown', this.onMouseDown);\n this.div.removeEventListener('click', this.onClick);\n this.div.removeEventListener('mouseover', this.onMouseOver);\n this.div.removeEventListener('mouseout', this.onMouseOut);\n this.div.parentNode.removeChild(this.div);\n if (this.timeOut !== null) {\n window.clearTimeout(this.timeOut);\n this.timeOut = null;\n }\n this.div = null;\n }\n };\n ClusterIcon.prototype.draw = function () {\n if (this.visible && this.div !== null && this.center) {\n var pos = this.getPosFromLatLng(this.center);\n this.div.style.top = pos !== null ? \"\".concat(pos.y, \"px\") : '0';\n this.div.style.left = pos !== null ? \"\".concat(pos.x, \"px\") : '0';\n }\n };\n ClusterIcon.prototype.hide = function () {\n if (this.div) {\n this.div.style.display = 'none';\n }\n this.visible = false;\n };\n ClusterIcon.prototype.show = function () {\n var _a, _b, _c, _d, _e, _f;\n if (this.div && this.center) {\n var divTitle = this.sums === null ||\n typeof this.sums.title === 'undefined' ||\n this.sums.title === '' ? this.cluster.getClusterer().getTitle() : this.sums.title;\n // NOTE: values must be specified in px units\n var bp = this.backgroundPosition.split(' ');\n var spriteH = parseInt(((_a = bp[0]) === null || _a === void 0 ? void 0 : _a.replace(/^\\s+|\\s+$/g, '')) || '0', 10);\n var spriteV = parseInt(((_b = bp[1]) === null || _b === void 0 ? void 0 : _b.replace(/^\\s+|\\s+$/g, '')) || '0', 10);\n var pos = this.getPosFromLatLng(this.center);\n this.div.className = this.className;\n this.div.setAttribute('style', \"cursor: pointer; position: absolute; top: \".concat(pos !== null ? \"\".concat(pos.y, \"px\") : '0', \"; left: \").concat(pos !== null ? \"\".concat(pos.x, \"px\") : '0', \"; width: \").concat(this.width, \"px; height: \").concat(this.height, \"px; \"));\n var img = document.createElement('img');\n img.alt = divTitle;\n img.src = this.url;\n img.width = this.width;\n img.height = this.height;\n img.setAttribute('style', \"position: absolute; top: \".concat(spriteV, \"px; left: \").concat(spriteH, \"px\"));\n if (!this.cluster.getClusterer().enableRetinaIcons) {\n img.style.clip = \"rect(-\".concat(spriteV, \"px, -\").concat(spriteH + this.width, \"px, -\").concat(spriteV + this.height, \", -\").concat(spriteH, \")\");\n }\n var textElm = document.createElement('div');\n textElm.setAttribute('style', \"position: absolute; top: \".concat(this.anchorText[0], \"px; left: \").concat(this.anchorText[1], \"px; color: \").concat(this.textColor, \"; font-size: \").concat(this.textSize, \"px; font-family: \").concat(this.fontFamily, \"; font-weight: \").concat(this.fontWeight, \"; fontStyle: \").concat(this.fontStyle, \"; text-decoration: \").concat(this.textDecoration, \"; text-align: center; width: \").concat(this.width, \"px; line-height: \").concat(this.height, \"px\"));\n if ((_c = this.sums) === null || _c === void 0 ? void 0 : _c.text)\n textElm.innerText = \"\".concat((_d = this.sums) === null || _d === void 0 ? void 0 : _d.text);\n if ((_e = this.sums) === null || _e === void 0 ? void 0 : _e.html)\n textElm.innerHTML = \"\".concat((_f = this.sums) === null || _f === void 0 ? void 0 : _f.html);\n this.div.innerHTML = '';\n this.div.appendChild(img);\n this.div.appendChild(textElm);\n this.div.title = divTitle;\n this.div.style.display = '';\n }\n this.visible = true;\n };\n ClusterIcon.prototype.useStyle = function (sums) {\n this.sums = sums;\n var styles = this.cluster.getClusterer().getStyles();\n var style = styles[Math.min(styles.length - 1, Math.max(0, sums.index - 1))];\n if (style) {\n this.url = style.url;\n this.height = style.height;\n this.width = style.width;\n if (style.className) {\n this.className = \"\".concat(this.clusterClassName, \" \").concat(style.className);\n }\n this.anchorText = style.anchorText || [0, 0];\n this.anchorIcon = style.anchorIcon || [this.height / 2, this.width / 2];\n this.textColor = style.textColor || 'black';\n this.textSize = style.textSize || 11;\n this.textDecoration = style.textDecoration || 'none';\n this.fontWeight = style.fontWeight || 'bold';\n this.fontStyle = style.fontStyle || 'normal';\n this.fontFamily = style.fontFamily || 'Arial,sans-serif';\n this.backgroundPosition = style.backgroundPosition || '0 0';\n }\n };\n ClusterIcon.prototype.setCenter = function (center) {\n this.center = center;\n };\n ClusterIcon.prototype.getPosFromLatLng = function (latlng) {\n var pos = this.getProjection().fromLatLngToDivPixel(latlng);\n if (pos !== null) {\n pos.x -= this.anchorIcon[1];\n pos.y -= this.anchorIcon[0];\n }\n return pos;\n };\n return ClusterIcon;\n}());\n\n/* global google */\nvar Cluster = /** @class */ (function () {\n function Cluster(markerClusterer) {\n this.markerClusterer = markerClusterer;\n this.map = this.markerClusterer.getMap();\n this.gridSize = this.markerClusterer.getGridSize();\n this.minClusterSize = this.markerClusterer.getMinimumClusterSize();\n this.averageCenter = this.markerClusterer.getAverageCenter();\n this.markers = [];\n this.center = undefined;\n this.bounds = null;\n this.clusterIcon = new ClusterIcon(this, this.markerClusterer.getStyles());\n this.getSize = this.getSize.bind(this);\n this.getMarkers = this.getMarkers.bind(this);\n this.getCenter = this.getCenter.bind(this);\n this.getMap = this.getMap.bind(this);\n this.getClusterer = this.getClusterer.bind(this);\n this.getBounds = this.getBounds.bind(this);\n this.remove = this.remove.bind(this);\n this.addMarker = this.addMarker.bind(this);\n this.isMarkerInClusterBounds = this.isMarkerInClusterBounds.bind(this);\n this.calculateBounds = this.calculateBounds.bind(this);\n this.updateIcon = this.updateIcon.bind(this);\n this.isMarkerAlreadyAdded = this.isMarkerAlreadyAdded.bind(this);\n }\n Cluster.prototype.getSize = function () {\n return this.markers.length;\n };\n Cluster.prototype.getMarkers = function () {\n return this.markers;\n };\n Cluster.prototype.getCenter = function () {\n return this.center;\n };\n Cluster.prototype.getMap = function () {\n return this.map;\n };\n Cluster.prototype.getClusterer = function () {\n return this.markerClusterer;\n };\n Cluster.prototype.getBounds = function () {\n var bounds = new google.maps.LatLngBounds(this.center, this.center);\n var markers = this.getMarkers();\n for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {\n var marker = markers_1[_i];\n var position = marker.getPosition();\n if (position) {\n bounds.extend(position);\n }\n }\n return bounds;\n };\n Cluster.prototype.remove = function () {\n this.clusterIcon.setMap(null);\n this.markers = [];\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n delete this.markers;\n };\n Cluster.prototype.addMarker = function (marker) {\n var _a;\n if (this.isMarkerAlreadyAdded(marker)) {\n return false;\n }\n if (!this.center) {\n var position = marker.getPosition();\n if (position) {\n this.center = position;\n this.calculateBounds();\n }\n }\n else {\n if (this.averageCenter) {\n var position = marker.getPosition();\n if (position) {\n var length_1 = this.markers.length + 1;\n this.center = new google.maps.LatLng((this.center.lat() * (length_1 - 1) + position.lat()) / length_1, (this.center.lng() * (length_1 - 1) + position.lng()) / length_1);\n this.calculateBounds();\n }\n }\n }\n marker.isAdded = true;\n this.markers.push(marker);\n var mCount = this.markers.length;\n var maxZoom = this.markerClusterer.getMaxZoom();\n var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom();\n if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) {\n // Zoomed in past max zoom, so show the marker.\n if (marker.getMap() !== this.map) {\n marker.setMap(this.map);\n }\n }\n else if (mCount < this.minClusterSize) {\n // Min cluster size not reached so show the marker.\n if (marker.getMap() !== this.map) {\n marker.setMap(this.map);\n }\n }\n else if (mCount === this.minClusterSize) {\n // Hide the markers that were showing.\n for (var _i = 0, _b = this.markers; _i < _b.length; _i++) {\n var markerElement = _b[_i];\n markerElement.setMap(null);\n }\n }\n else {\n marker.setMap(null);\n }\n return true;\n };\n Cluster.prototype.isMarkerInClusterBounds = function (marker) {\n if (this.bounds !== null) {\n var position = marker.getPosition();\n if (position) {\n return this.bounds.contains(position);\n }\n }\n return false;\n };\n Cluster.prototype.calculateBounds = function () {\n this.bounds = this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center, this.center));\n };\n Cluster.prototype.updateIcon = function () {\n var _a;\n var mCount = this.markers.length;\n var maxZoom = this.markerClusterer.getMaxZoom();\n var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom();\n if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) {\n this.clusterIcon.hide();\n return;\n }\n if (mCount < this.minClusterSize) {\n // Min cluster size not yet reached.\n this.clusterIcon.hide();\n return;\n }\n if (this.center) {\n this.clusterIcon.setCenter(this.center);\n }\n this.clusterIcon.useStyle(this.markerClusterer.getCalculator()(this.markers, this.markerClusterer.getStyles().length));\n this.clusterIcon.show();\n };\n Cluster.prototype.isMarkerAlreadyAdded = function (marker) {\n if (this.markers.includes) {\n return this.markers.includes(marker);\n }\n for (var i = 0; i < this.markers.length; i++) {\n if (marker === this.markers[i]) {\n return true;\n }\n }\n return false;\n };\n return Cluster;\n}());\n\n/* global google */\n/* eslint-disable filenames/match-regex */\n/**\n * Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers\n * which is not a problem as max array length is 4294967296 (2**32)\n */\nfunction CALCULATOR(markers, numStyles) {\n var count = markers.length;\n var numberOfDigits = count.toString().length;\n var index = Math.min(numberOfDigits, numStyles);\n return {\n text: count.toString(),\n index: index,\n title: '',\n };\n}\nvar BATCH_SIZE = 2000;\nvar BATCH_SIZE_IE = 500;\nvar IMAGE_PATH = 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m';\nvar IMAGE_EXTENSION = 'png';\nvar IMAGE_SIZES = [53, 56, 66, 78, 90];\nvar CLUSTERER_CLASS = 'cluster';\nvar Clusterer = /** @class */ (function () {\n function Clusterer(map, optMarkers, optOptions) {\n if (optMarkers === void 0) { optMarkers = []; }\n if (optOptions === void 0) { optOptions = {}; }\n this.getMinimumClusterSize = this.getMinimumClusterSize.bind(this);\n this.setMinimumClusterSize = this.setMinimumClusterSize.bind(this);\n this.getEnableRetinaIcons = this.getEnableRetinaIcons.bind(this);\n this.setEnableRetinaIcons = this.setEnableRetinaIcons.bind(this);\n this.addToClosestCluster = this.addToClosestCluster.bind(this);\n this.getImageExtension = this.getImageExtension.bind(this);\n this.setImageExtension = this.setImageExtension.bind(this);\n this.getExtendedBounds = this.getExtendedBounds.bind(this);\n this.getAverageCenter = this.getAverageCenter.bind(this);\n this.setAverageCenter = this.setAverageCenter.bind(this);\n this.getTotalClusters = this.getTotalClusters.bind(this);\n this.fitMapToMarkers = this.fitMapToMarkers.bind(this);\n this.getIgnoreHidden = this.getIgnoreHidden.bind(this);\n this.setIgnoreHidden = this.setIgnoreHidden.bind(this);\n this.getClusterClass = this.getClusterClass.bind(this);\n this.setClusterClass = this.setClusterClass.bind(this);\n this.getTotalMarkers = this.getTotalMarkers.bind(this);\n this.getZoomOnClick = this.getZoomOnClick.bind(this);\n this.setZoomOnClick = this.setZoomOnClick.bind(this);\n this.getBatchSizeIE = this.getBatchSizeIE.bind(this);\n this.setBatchSizeIE = this.setBatchSizeIE.bind(this);\n this.createClusters = this.createClusters.bind(this);\n this.onZoomChanged = this.onZoomChanged.bind(this);\n this.getImageSizes = this.getImageSizes.bind(this);\n this.setImageSizes = this.setImageSizes.bind(this);\n this.getCalculator = this.getCalculator.bind(this);\n this.setCalculator = this.setCalculator.bind(this);\n this.removeMarkers = this.removeMarkers.bind(this);\n this.resetViewport = this.resetViewport.bind(this);\n this.getImagePath = this.getImagePath.bind(this);\n this.setImagePath = this.setImagePath.bind(this);\n this.pushMarkerTo = this.pushMarkerTo.bind(this);\n this.removeMarker = this.removeMarker.bind(this);\n this.clearMarkers = this.clearMarkers.bind(this);\n this.setupStyles = this.setupStyles.bind(this);\n this.getGridSize = this.getGridSize.bind(this);\n this.setGridSize = this.setGridSize.bind(this);\n this.getClusters = this.getClusters.bind(this);\n this.getMaxZoom = this.getMaxZoom.bind(this);\n this.setMaxZoom = this.setMaxZoom.bind(this);\n this.getMarkers = this.getMarkers.bind(this);\n this.addMarkers = this.addMarkers.bind(this);\n this.getStyles = this.getStyles.bind(this);\n this.setStyles = this.setStyles.bind(this);\n this.addMarker = this.addMarker.bind(this);\n this.onRemove = this.onRemove.bind(this);\n this.getTitle = this.getTitle.bind(this);\n this.setTitle = this.setTitle.bind(this);\n this.repaint = this.repaint.bind(this);\n this.onIdle = this.onIdle.bind(this);\n this.redraw = this.redraw.bind(this);\n this.onAdd = this.onAdd.bind(this);\n this.draw = this.draw.bind(this);\n this.extend = this.extend.bind(this);\n this.extend(Clusterer, google.maps.OverlayView);\n this.markers = [];\n this.clusters = [];\n this.listeners = [];\n this.activeMap = null;\n this.ready = false;\n this.gridSize = optOptions.gridSize || 60;\n this.minClusterSize = optOptions.minimumClusterSize || 2;\n this.maxZoom = optOptions.maxZoom || null;\n this.styles = optOptions.styles || [];\n this.title = optOptions.title || '';\n this.zoomOnClick = true;\n if (optOptions.zoomOnClick !== undefined) {\n this.zoomOnClick = optOptions.zoomOnClick;\n }\n this.averageCenter = false;\n if (optOptions.averageCenter !== undefined) {\n this.averageCenter = optOptions.averageCenter;\n }\n this.ignoreHidden = false;\n if (optOptions.ignoreHidden !== undefined) {\n this.ignoreHidden = optOptions.ignoreHidden;\n }\n this.enableRetinaIcons = false;\n if (optOptions.enableRetinaIcons !== undefined) {\n this.enableRetinaIcons = optOptions.enableRetinaIcons;\n }\n this.imagePath = optOptions.imagePath || IMAGE_PATH;\n this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION;\n this.imageSizes = optOptions.imageSizes || IMAGE_SIZES;\n this.calculator = optOptions.calculator || CALCULATOR;\n this.batchSize = optOptions.batchSize || BATCH_SIZE;\n this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE;\n this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS;\n if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {\n // Try to avoid IE timeout when processing a huge number of markers:\n this.batchSize = this.batchSizeIE;\n }\n this.timerRefStatic = null;\n this.setupStyles();\n this.addMarkers(optMarkers, true);\n this.setMap(map); // Note: this causes onAdd to be called\n }\n Clusterer.prototype.onZoomChanged = function () {\n var _a, _b;\n this.resetViewport(false);\n // Workaround for this Google bug: when map is at level 0 and \"-\" of\n // zoom slider is clicked, a \"zoom_changed\" event is fired even though\n // the map doesn't zoom out any further. In this situation, no \"idle\"\n // event is triggered so the cluster markers that have been removed\n // do not get redrawn. Same goes for a zoom in at maxZoom.\n if (((_a = this.getMap()) === null || _a === void 0 ? void 0 : _a.getZoom()) === (this.get('minZoom') || 0) ||\n ((_b = this.getMap()) === null || _b === void 0 ? void 0 : _b.getZoom()) === this.get('maxZoom')) {\n google.maps.event.trigger(this, 'idle');\n }\n };\n Clusterer.prototype.onIdle = function () {\n this.redraw();\n };\n Clusterer.prototype.onAdd = function () {\n var map = this.getMap();\n this.activeMap = map;\n this.ready = true;\n this.repaint();\n if (map !== null) {\n // Add the map event listeners\n this.listeners = [\n google.maps.event.addListener(map, 'zoom_changed', this.onZoomChanged),\n google.maps.event.addListener(map, 'idle', this.onIdle),\n ];\n }\n };\n Clusterer.prototype.onRemove = function () {\n // Put all the managed markers back on the map:\n for (var _i = 0, _a = this.markers; _i < _a.length; _i++) {\n var marker = _a[_i];\n if (marker.getMap() !== this.activeMap) {\n marker.setMap(this.activeMap);\n }\n }\n // Remove all clusters:\n for (var _b = 0, _c = this.clusters; _b < _c.length; _b++) {\n var cluster = _c[_b];\n cluster.remove();\n }\n this.clusters = [];\n // Remove map event listeners:\n for (var _d = 0, _e = this.listeners; _d < _e.length; _d++) {\n var listener = _e[_d];\n google.maps.event.removeListener(listener);\n }\n this.listeners = [];\n this.activeMap = null;\n this.ready = false;\n };\n Clusterer.prototype.draw = function () { return; };\n Clusterer.prototype.getMap = function () { return null; };\n Clusterer.prototype.getPanes = function () { return null; };\n Clusterer.prototype.getProjection = function () {\n return {\n fromContainerPixelToLatLng: function () { return null; },\n fromDivPixelToLatLng: function () { return null; },\n fromLatLngToContainerPixel: function () { return null; },\n fromLatLngToDivPixel: function () { return null; },\n getVisibleRegion: function () { return null; },\n getWorldWidth: function () { return 0; }\n };\n };\n Clusterer.prototype.setMap = function () { return; };\n Clusterer.prototype.addListener = function () {\n return {\n remove: function () { return; }\n };\n };\n Clusterer.prototype.bindTo = function () { return; };\n Clusterer.prototype.get = function () { return; };\n Clusterer.prototype.notify = function () { return; };\n Clusterer.prototype.set = function () { return; };\n Clusterer.prototype.setValues = function () { return; };\n Clusterer.prototype.unbind = function () { return; };\n Clusterer.prototype.unbindAll = function () { return; };\n Clusterer.prototype.setupStyles = function () {\n if (this.styles.length > 0) {\n return;\n }\n for (var i = 0; i < this.imageSizes.length; i++) {\n this.styles.push({\n url: \"\".concat(this.imagePath + (i + 1), \".\").concat(this.imageExtension),\n height: this.imageSizes[i] || 0,\n width: this.imageSizes[i] || 0,\n });\n }\n };\n Clusterer.prototype.fitMapToMarkers = function () {\n var markers = this.getMarkers();\n var bounds = new google.maps.LatLngBounds();\n for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {\n var marker = markers_1[_i];\n var position = marker.getPosition();\n if (position) {\n bounds.extend(position);\n }\n }\n var map = this.getMap();\n if (map !== null && 'fitBounds' in map) {\n map.fitBounds(bounds);\n }\n };\n Clusterer.prototype.getGridSize = function () {\n return this.gridSize;\n };\n Clusterer.prototype.setGridSize = function (gridSize) {\n this.gridSize = gridSize;\n };\n Clusterer.prototype.getMinimumClusterSize = function () {\n return this.minClusterSize;\n };\n Clusterer.prototype.setMinimumClusterSize = function (minimumClusterSize) {\n this.minClusterSize = minimumClusterSize;\n };\n Clusterer.prototype.getMaxZoom = function () {\n return this.maxZoom;\n };\n Clusterer.prototype.setMaxZoom = function (maxZoom) {\n this.maxZoom = maxZoom;\n };\n Clusterer.prototype.getStyles = function () {\n return this.styles;\n };\n Clusterer.prototype.setStyles = function (styles) {\n this.styles = styles;\n };\n Clusterer.prototype.getTitle = function () {\n return this.title;\n };\n Clusterer.prototype.setTitle = function (title) {\n this.title = title;\n };\n Clusterer.prototype.getZoomOnClick = function () {\n return this.zoomOnClick;\n };\n Clusterer.prototype.setZoomOnClick = function (zoomOnClick) {\n this.zoomOnClick = zoomOnClick;\n };\n Clusterer.prototype.getAverageCenter = function () {\n return this.averageCenter;\n };\n Clusterer.prototype.setAverageCenter = function (averageCenter) {\n this.averageCenter = averageCenter;\n };\n Clusterer.prototype.getIgnoreHidden = function () {\n return this.ignoreHidden;\n };\n Clusterer.prototype.setIgnoreHidden = function (ignoreHidden) {\n this.ignoreHidden = ignoreHidden;\n };\n Clusterer.prototype.getEnableRetinaIcons = function () {\n return this.enableRetinaIcons;\n };\n Clusterer.prototype.setEnableRetinaIcons = function (enableRetinaIcons) {\n this.enableRetinaIcons = enableRetinaIcons;\n };\n Clusterer.prototype.getImageExtension = function () {\n return this.imageExtension;\n };\n Clusterer.prototype.setImageExtension = function (imageExtension) {\n this.imageExtension = imageExtension;\n };\n Clusterer.prototype.getImagePath = function () {\n return this.imagePath;\n };\n Clusterer.prototype.setImagePath = function (imagePath) {\n this.imagePath = imagePath;\n };\n Clusterer.prototype.getImageSizes = function () {\n return this.imageSizes;\n };\n Clusterer.prototype.setImageSizes = function (imageSizes) {\n this.imageSizes = imageSizes;\n };\n Clusterer.prototype.getCalculator = function () {\n return this.calculator;\n };\n Clusterer.prototype.setCalculator = function (calculator) {\n this.calculator = calculator;\n };\n Clusterer.prototype.getBatchSizeIE = function () {\n return this.batchSizeIE;\n };\n Clusterer.prototype.setBatchSizeIE = function (batchSizeIE) {\n this.batchSizeIE = batchSizeIE;\n };\n Clusterer.prototype.getClusterClass = function () {\n return this.clusterClass;\n };\n Clusterer.prototype.setClusterClass = function (clusterClass) {\n this.clusterClass = clusterClass;\n };\n Clusterer.prototype.getMarkers = function () {\n return this.markers;\n };\n Clusterer.prototype.getTotalMarkers = function () {\n return this.markers.length;\n };\n Clusterer.prototype.getClusters = function () {\n return this.clusters;\n };\n Clusterer.prototype.getTotalClusters = function () {\n return this.clusters.length;\n };\n Clusterer.prototype.addMarker = function (marker, optNoDraw) {\n this.pushMarkerTo(marker);\n if (!optNoDraw) {\n this.redraw();\n }\n };\n Clusterer.prototype.addMarkers = function (markers, optNoDraw) {\n for (var key in markers) {\n if (Object.prototype.hasOwnProperty.call(markers, key)) {\n var marker = markers[key];\n if (marker) {\n this.pushMarkerTo(marker);\n }\n }\n }\n if (!optNoDraw) {\n this.redraw();\n }\n };\n Clusterer.prototype.pushMarkerTo = function (marker) {\n var _this = this;\n // If the marker is draggable add a listener so we can update the clusters on the dragend:\n if (marker.getDraggable()) {\n google.maps.event.addListener(marker, 'dragend', function () {\n if (_this.ready) {\n marker.isAdded = false;\n _this.repaint();\n }\n });\n }\n marker.isAdded = false;\n this.markers.push(marker);\n };\n Clusterer.prototype.removeMarker_ = function (marker) {\n var index = -1;\n if (this.markers.indexOf) {\n index = this.markers.indexOf(marker);\n }\n else {\n for (var i = 0; i < this.markers.length; i++) {\n if (marker === this.markers[i]) {\n index = i;\n break;\n }\n }\n }\n if (index === -1) {\n // Marker is not in our list of markers, so do nothing:\n return false;\n }\n marker.setMap(null);\n this.markers.splice(index, 1); // Remove the marker from the list of managed markers\n return true;\n };\n Clusterer.prototype.removeMarker = function (marker, optNoDraw) {\n var removed = this.removeMarker_(marker);\n if (!optNoDraw && removed) {\n this.repaint();\n }\n return removed;\n };\n Clusterer.prototype.removeMarkers = function (markers, optNoDraw) {\n var removed = false;\n for (var _i = 0, markers_2 = markers; _i < markers_2.length; _i++) {\n var marker = markers_2[_i];\n removed = removed || this.removeMarker_(marker);\n }\n if (!optNoDraw && removed) {\n this.repaint();\n }\n return removed;\n };\n Clusterer.prototype.clearMarkers = function () {\n this.resetViewport(true);\n this.markers = [];\n };\n Clusterer.prototype.repaint = function () {\n var oldClusters = this.clusters.slice();\n this.clusters = [];\n this.resetViewport(false);\n this.redraw();\n // Remove the old clusters.\n // Do it in a timeout to prevent blinking effect.\n setTimeout(function timeout() {\n for (var _i = 0, oldClusters_1 = oldClusters; _i < oldClusters_1.length; _i++) {\n var oldCluster = oldClusters_1[_i];\n oldCluster.remove();\n }\n }, 0);\n };\n Clusterer.prototype.getExtendedBounds = function (bounds) {\n var projection = this.getProjection();\n // Convert the points to pixels and the extend out by the grid size.\n var trPix = projection.fromLatLngToDivPixel(\n // Turn the bounds into latlng.\n new google.maps.LatLng(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()));\n if (trPix !== null) {\n trPix.x += this.gridSize;\n trPix.y -= this.gridSize;\n }\n var blPix = projection.fromLatLngToDivPixel(\n // Turn the bounds into latlng.\n new google.maps.LatLng(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()));\n if (blPix !== null) {\n blPix.x -= this.gridSize;\n blPix.y += this.gridSize;\n }\n // Extend the bounds to contain the new bounds.\n if (trPix !== null) {\n // Convert the pixel points back to LatLng nw\n var point1 = projection.fromDivPixelToLatLng(trPix);\n if (point1 !== null) {\n bounds.extend(point1);\n }\n }\n if (blPix !== null) {\n // Convert the pixel points back to LatLng sw\n var point2 = projection.fromDivPixelToLatLng(blPix);\n if (point2 !== null) {\n bounds.extend(point2);\n }\n }\n return bounds;\n };\n Clusterer.prototype.redraw = function () {\n // Redraws all the clusters.\n this.createClusters(0);\n };\n Clusterer.prototype.resetViewport = function (optHide) {\n // Remove all the clusters\n for (var _i = 0, _a = this.clusters; _i < _a.length; _i++) {\n var cluster = _a[_i];\n cluster.remove();\n }\n this.clusters = [];\n // Reset the markers to not be added and to be removed from the map.\n for (var _b = 0, _c = this.markers; _b < _c.length; _b++) {\n var marker = _c[_b];\n marker.isAdded = false;\n if (optHide) {\n marker.setMap(null);\n }\n }\n };\n Clusterer.prototype.distanceBetweenPoints = function (p1, p2) {\n var R = 6371; // Radius of the Earth in km\n var dLat = ((p2.lat() - p1.lat()) * Math.PI) / 180;\n var dLon = ((p2.lng() - p1.lng()) * Math.PI) / 180;\n var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n Math.cos((p1.lat() * Math.PI) / 180) *\n Math.cos((p2.lat() * Math.PI) / 180) *\n Math.sin(dLon / 2) *\n Math.sin(dLon / 2);\n return R * (2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));\n };\n Clusterer.prototype.isMarkerInBounds = function (marker, bounds) {\n var position = marker.getPosition();\n if (position) {\n return bounds.contains(position);\n }\n return false;\n };\n Clusterer.prototype.addToClosestCluster = function (marker) {\n var cluster;\n var distance = 40000; // Some large number\n var clusterToAddTo = null;\n for (var _i = 0, _a = this.clusters; _i < _a.length; _i++) {\n var clusterElement = _a[_i];\n cluster = clusterElement;\n var center = cluster.getCenter();\n var position = marker.getPosition();\n if (center && position) {\n var d = this.distanceBetweenPoints(center, position);\n if (d < distance) {\n distance = d;\n clusterToAddTo = cluster;\n }\n }\n }\n if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) {\n clusterToAddTo.addMarker(marker);\n }\n else {\n cluster = new Cluster(this);\n cluster.addMarker(marker);\n this.clusters.push(cluster);\n }\n };\n Clusterer.prototype.createClusters = function (iFirst) {\n var _this = this;\n if (!this.ready) {\n return;\n }\n // Cancel previous batch processing if we're working on the first batch:\n if (iFirst === 0) {\n /**\n * This event is fired when the Clusterer begins\n * clustering markers.\n * @name Clusterer#clusteringbegin\n * @param {Clusterer} mc The Clusterer whose markers are being clustered.\n * @event\n */\n google.maps.event.trigger(this, 'clusteringbegin', this);\n if (this.timerRefStatic !== null) {\n window.clearTimeout(this.timerRefStatic);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n delete this.timerRefStatic;\n }\n }\n var map = this.getMap();\n var bounds = map !== null && 'getBounds' in map ? map.getBounds() : null;\n var zoom = (map === null || map === void 0 ? void 0 : map.getZoom()) || 0;\n // Get our current map view bounds.\n // Create a new bounds object so we don't affect the map.\n //\n // See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:\n var mapBounds = zoom > 3\n ? new google.maps.LatLngBounds(bounds === null || bounds === void 0 ? void 0 : bounds.getSouthWest(), bounds === null || bounds === void 0 ? void 0 : bounds.getNorthEast())\n : new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625));\n var extendedMapBounds = this.getExtendedBounds(mapBounds);\n var iLast = Math.min(iFirst + this.batchSize, this.markers.length);\n for (var i = iFirst; i < iLast; i++) {\n var marker = this.markers[i];\n if (marker && !marker.isAdded && this.isMarkerInBounds(marker, extendedMapBounds) && (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible()))) {\n this.addToClosestCluster(marker);\n }\n }\n if (iLast < this.markers.length) {\n this.timerRefStatic = window.setTimeout(function () {\n _this.createClusters(iLast);\n }, 0);\n }\n else {\n this.timerRefStatic = null;\n /**\n * This event is fired when the Clusterer stops\n * clustering markers.\n * @name Clusterer#clusteringend\n * @param {Clusterer} mc The Clusterer whose markers are being clustered.\n * @event\n */\n google.maps.event.trigger(this, 'clusteringend', this);\n for (var _i = 0, _a = this.clusters; _i < _a.length; _i++) {\n var cluster = _a[_i];\n cluster.updateIcon();\n }\n }\n };\n Clusterer.prototype.extend = function (obj1, obj2) {\n return function applyExtend(object) {\n for (var property in object.prototype) {\n // eslint-disable-next-line @typescript-eslint/ban-types\n var prop = property;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.prototype[prop] = object.prototype[prop];\n }\n return this;\n }.apply(obj1, [obj2]);\n };\n return Clusterer;\n}());\n\nexport { Cluster, ClusterIcon, Clusterer };\n//# sourceMappingURL=esm.js.map\n","import {\n memo,\n useState,\n type JSX,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\nimport {\n Cluster,\n Clusterer,\n type TCalculator,\n type ClusterIconStyle,\n type ClustererOptions,\n} from '@react-google-maps/marker-clusterer'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onClick: 'click',\n onClusteringBegin: 'clusteringbegin',\n onClusteringEnd: 'clusteringend',\n onMouseOut: 'mouseout',\n onMouseOver: 'mouseover',\n}\n\nconst updaterMap = {\n averageCenter(instance: Clusterer, averageCenter: boolean): void {\n instance.setAverageCenter(averageCenter)\n },\n\n batchSizeIE(instance: Clusterer, batchSizeIE: number): void {\n instance.setBatchSizeIE(batchSizeIE)\n },\n\n calculator(instance: Clusterer, calculator: TCalculator): void {\n instance.setCalculator(calculator)\n },\n\n clusterClass(instance: Clusterer, clusterClass: string): void {\n instance.setClusterClass(clusterClass)\n },\n\n enableRetinaIcons(instance: Clusterer, enableRetinaIcons: boolean): void {\n instance.setEnableRetinaIcons(enableRetinaIcons)\n },\n\n gridSize(instance: Clusterer, gridSize: number): void {\n instance.setGridSize(gridSize)\n },\n\n ignoreHidden(instance: Clusterer, ignoreHidden: boolean): void {\n instance.setIgnoreHidden(ignoreHidden)\n },\n\n imageExtension(instance: Clusterer, imageExtension: string): void {\n instance.setImageExtension(imageExtension)\n },\n\n imagePath(instance: Clusterer, imagePath: string): void {\n instance.setImagePath(imagePath)\n },\n\n imageSizes(instance: Clusterer, imageSizes: number[]): void {\n instance.setImageSizes(imageSizes)\n },\n\n maxZoom(instance: Clusterer, maxZoom: number): void {\n instance.setMaxZoom(maxZoom)\n },\n\n minimumClusterSize(instance: Clusterer, minimumClusterSize: number): void {\n instance.setMinimumClusterSize(minimumClusterSize)\n },\n\n styles(instance: Clusterer, styles: ClusterIconStyle[]): void {\n instance.setStyles(styles)\n },\n\n title(instance: Clusterer, title: string): void {\n instance.setTitle(title)\n },\n\n zoomOnClick(instance: Clusterer, zoomOnClick: boolean): void {\n instance.setZoomOnClick(zoomOnClick)\n },\n}\n\ntype ClustererState = {\n markerClusterer: Clusterer | null\n}\n\nconst defaultOptions = {}\n\nexport type MarkerClustererProps = {\n // required\n children: (markerClusterer: Clusterer) => JSX.Element\n\n options?: ClustererOptions | undefined\n /** Whether the position of a cluster marker should be the average position of all markers in the cluster. If set to false, the cluster marker is positioned at the location of the first marker added to the cluster. The default value is false. */\n averageCenter?: boolean | undefined\n /** When Internet Explorer is being used, markers are processed in several batches with a small delay inserted between each batch in an attempt to avoid Javascript timeout errors. Set this property to the number of markers to be processed in a single batch; select as high a number as you can without causing a timeout error in the browser. This number might need to be as low as 100 if 15,000 markers are being managed, for example. The default value is MarkerClusterer.BATCH_SIZE_IE. */\n batchSizeIE?: number | undefined\n /** The function used to determine the text to be displayed on a cluster marker and the index indicating which style to use for the cluster marker. The input parameters for the function are (1) the array of markers represented by a cluster marker and (2) the number of cluster icon styles. It returns a ClusterIconInfo object. The default calculator returns a text property which is the number of markers in the cluster and an index property which is one higher than the lowest integer such that 10^i exceeds the number of markers in the cluster, or the size of the styles array, whichever is less. The styles array element used has an index of index minus 1. For example, the default calculator returns a text value of \"125\" and an index of 3 for a cluster icon representing 125 markers so the element used in the styles array is 2. A calculator may also return a title property that contains the text of the tooltip to be used for the cluster marker. If title is not defined, the tooltip is set to the value of the title property for the MarkerClusterer. The default value is MarkerClusterer.CALCULATOR. */\n calculator?: TCalculator | undefined\n /** The name of the CSS class defining general styles for the cluster markers. Use this class to define CSS styles that are not set up by the code that processes the styles array. The default value is \"cluster\". */\n clusterClass?: string | undefined\n /** Whether to allow the use of cluster icons that have sizes that are some multiple (typically double) of their actual display size. Icons such as these look better when viewed on high-resolution monitors such as Apple's Retina displays. Note: if this property is true, sprites cannot be used as cluster icons. The default value is false. */\n enableRetinaIcons?: boolean | undefined\n /** The grid size of a cluster in pixels. The grid is a square. The default value is 60. */\n gridSize?: number | undefined\n /** Whether to ignore hidden markers in clusters. You may want to set this to true to ensure that hidden markers are not included in the marker count that appears on a cluster marker (this count is the value of the text property of the result returned by the default calculator). If set to true and you change the visibility of a marker being clustered, be sure to also call MarkerClusterer.repaint(). The default value is false. */\n ignoreHidden?: boolean | undefined\n /** The extension name for the cluster icon image files (e.g., \"png\" or \"jpg\"). The default value is MarkerClusterer.IMAGE_EXTENSION. */\n imageExtension?: string | undefined\n /** The full URL of the root name of the group of image files to use for cluster icons. The complete file name is of the form imagePath.imageExtension where n is the image file number (1, 2, etc.). The default value is MarkerClusterer.IMAGE_PATH. */\n imagePath?: string | undefined\n /** An array of numbers containing the widths of the group of imagePath.imageExtension image files. (The images are assumed to be square.) The default value is MarkerClusterer.IMAGE_SIZES. */\n imageSizes?: number[] | undefined\n /** The maximum zoom level at which clustering is enabled or null if clustering is to be enabled at all zoom levels. The default value is null. */\n maxZoom?: number | undefined\n /** The minimum number of markers needed in a cluster before the markers are hidden and a cluster marker appears. The default value is 2. */\n minimumClusterSize?: number | undefined\n /** An array of ClusterIconStyle elements defining the styles of the cluster markers to be used. The element to be used to style a given cluster marker is determined by the function defined by the calculator property. The default is an array of ClusterIconStyle elements whose properties are derived from the values for imagePath, imageExtension, and imageSizes. */\n styles?: ClusterIconStyle[] | undefined\n /** The tooltip to display when the mouse moves over a cluster marker. (Alternatively, you can use a custom calculator function to specify a different tooltip for each cluster marker.) The default value is \"\". */\n title?: string | undefined\n /** Whether to zoom the map when a cluster marker is clicked. You may want to set this to false if you have installed a handler for the click event and it deals with zooming on its own. The default value is true. */\n zoomOnClick?: boolean | undefined\n /** This event is fired when a cluster marker is clicked. */\n onClick?: ((cluster: Cluster) => void) | undefined\n /** This event is fired when the MarkerClusterer begins clustering markers. */\n onClusteringBegin?: ((markerClusterer: Clusterer) => void) | undefined\n /** This event is fired when the MarkerClusterer stops clustering markers. */\n onClusteringEnd?: ((markerClusterer: Clusterer) => void) | undefined\n /** \tThis event is fired when the mouse moves over a cluster marker. */\n onMouseOver?: (cluster: Cluster) => void | undefined\n /** This event is fired when the mouse moves out of a cluster marker. */\n onMouseOut?: (cluster: Cluster) => void | undefined\n /** This callback is called when the markerClusterer instance has loaded. It is called with the markerClusterer instance. */\n onLoad?: ((markerClusterer: Clusterer) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the markerClusterer instance. */\n onUnmount?: ((markerClusterer: Clusterer) => void) | undefined\n}\n\nfunction MarkerClustererFunctional(\n props: MarkerClustererProps\n): JSX.Element | null {\n const {\n children,\n options,\n averageCenter,\n batchSizeIE,\n calculator,\n clusterClass,\n enableRetinaIcons,\n gridSize,\n ignoreHidden,\n imageExtension,\n imagePath,\n imageSizes,\n maxZoom,\n minimumClusterSize,\n styles,\n title,\n zoomOnClick,\n onClick,\n onClusteringBegin,\n onClusteringEnd,\n onMouseOver,\n onMouseOut,\n onLoad,\n onUnmount,\n } = props\n const [instance, setInstance] = useState(null)\n const map = useContext(MapContext)\n\n const [clickListener, setClickListener] =\n useState(null)\n const [clusteringBeginListener, setClusteringBeginListener] =\n useState(null)\n const [clusteringEndListener, setClusteringEndListener] =\n useState(null)\n const [mouseoutListener, setMouseoutListener] =\n useState(null)\n const [mouseoverListener, setMouseoverListener] =\n useState(null)\n\n useEffect(() => {\n if (instance && onMouseOut) {\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n setMouseoutListener(\n google.maps.event.addListener(instance, eventMap.onMouseOut, onMouseOut)\n )\n }\n }, [onMouseOut])\n\n useEffect(() => {\n if (instance && onMouseOver) {\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n setMouseoverListener(\n google.maps.event.addListener(\n instance,\n eventMap.onMouseOver,\n onMouseOver\n )\n )\n }\n }, [onMouseOver])\n\n useEffect(() => {\n if (instance && onClick) {\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n setClickListener(\n google.maps.event.addListener(instance, eventMap.onClick, onClick)\n )\n }\n }, [onClick])\n\n useEffect(() => {\n if (instance && onClusteringBegin) {\n if (clusteringBeginListener !== null) {\n google.maps.event.removeListener(clusteringBeginListener)\n }\n\n setClusteringBeginListener(\n google.maps.event.addListener(\n instance,\n eventMap.onClusteringBegin,\n onClusteringBegin\n )\n )\n }\n }, [onClusteringBegin])\n\n useEffect(() => {\n if (instance && onClusteringEnd) {\n if (clusteringEndListener !== null) {\n google.maps.event.removeListener(clusteringEndListener)\n }\n\n setClusteringBeginListener(\n google.maps.event.addListener(\n instance,\n eventMap.onClusteringEnd,\n onClusteringEnd\n )\n )\n }\n }, [onClusteringEnd])\n\n useEffect(() => {\n if (typeof averageCenter !== 'undefined' && instance !== null) {\n updaterMap.averageCenter(instance, averageCenter)\n }\n }, [instance, averageCenter])\n\n useEffect(() => {\n if (typeof batchSizeIE !== 'undefined' && instance !== null) {\n updaterMap.batchSizeIE(instance, batchSizeIE)\n }\n }, [instance, batchSizeIE])\n\n useEffect(() => {\n if (typeof calculator !== 'undefined' && instance !== null) {\n updaterMap.calculator(instance, calculator)\n }\n }, [instance, calculator])\n\n useEffect(() => {\n if (typeof clusterClass !== 'undefined' && instance !== null) {\n updaterMap.clusterClass(instance, clusterClass)\n }\n }, [instance, clusterClass])\n\n useEffect(() => {\n if (typeof enableRetinaIcons !== 'undefined' && instance !== null) {\n updaterMap.enableRetinaIcons(instance, enableRetinaIcons)\n }\n }, [instance, enableRetinaIcons])\n\n useEffect(() => {\n if (typeof gridSize !== 'undefined' && instance !== null) {\n updaterMap.gridSize(instance, gridSize)\n }\n }, [instance, gridSize])\n\n useEffect(() => {\n if (typeof ignoreHidden !== 'undefined' && instance !== null) {\n updaterMap.ignoreHidden(instance, ignoreHidden)\n }\n }, [instance, ignoreHidden])\n\n useEffect(() => {\n if (typeof imageExtension !== 'undefined' && instance !== null) {\n updaterMap.imageExtension(instance, imageExtension)\n }\n }, [instance, imageExtension])\n\n useEffect(() => {\n if (typeof imagePath !== 'undefined' && instance !== null) {\n updaterMap.imagePath(instance, imagePath)\n }\n }, [instance, imagePath])\n\n useEffect(() => {\n if (typeof imageSizes !== 'undefined' && instance !== null) {\n updaterMap.imageSizes(instance, imageSizes)\n }\n }, [instance, imageSizes])\n\n useEffect(() => {\n if (typeof maxZoom !== 'undefined' && instance !== null) {\n updaterMap.maxZoom(instance, maxZoom)\n }\n }, [instance, maxZoom])\n\n useEffect(() => {\n if (typeof minimumClusterSize !== 'undefined' && instance !== null) {\n updaterMap.minimumClusterSize(instance, minimumClusterSize)\n }\n }, [instance, minimumClusterSize])\n\n useEffect(() => {\n if (typeof styles !== 'undefined' && instance !== null) {\n updaterMap.styles(instance, styles)\n }\n }, [instance, styles])\n\n useEffect(() => {\n if (typeof title !== 'undefined' && instance !== null) {\n updaterMap.title(instance, title)\n }\n }, [instance, title])\n\n useEffect(() => {\n if (typeof zoomOnClick !== 'undefined' && instance !== null) {\n updaterMap.zoomOnClick(instance, zoomOnClick)\n }\n }, [instance, zoomOnClick])\n\n useEffect(() => {\n if (!map) return\n\n const clustererOptions = {\n ...(options || defaultOptions),\n }\n\n const clusterer = new Clusterer(map, [], clustererOptions)\n\n if (averageCenter) {\n updaterMap.averageCenter(clusterer, averageCenter)\n }\n\n if (batchSizeIE) {\n updaterMap.batchSizeIE(clusterer, batchSizeIE)\n }\n\n if (calculator) {\n updaterMap.calculator(clusterer, calculator)\n }\n\n if (clusterClass) {\n updaterMap.clusterClass(clusterer, clusterClass)\n }\n\n if (enableRetinaIcons) {\n updaterMap.enableRetinaIcons(clusterer, enableRetinaIcons)\n }\n\n if (gridSize) {\n updaterMap.gridSize(clusterer, gridSize)\n }\n\n if (ignoreHidden) {\n updaterMap.ignoreHidden(clusterer, ignoreHidden)\n }\n\n if (imageExtension) {\n updaterMap.imageExtension(clusterer, imageExtension)\n }\n\n if (imagePath) {\n updaterMap.imagePath(clusterer, imagePath)\n }\n\n if (imageSizes) {\n updaterMap.imageSizes(clusterer, imageSizes)\n }\n\n if (maxZoom) {\n updaterMap.maxZoom(clusterer, maxZoom)\n }\n\n if (minimumClusterSize) {\n updaterMap.minimumClusterSize(clusterer, minimumClusterSize)\n }\n\n if (styles) {\n updaterMap.styles(clusterer, styles)\n }\n\n if (title) {\n updaterMap.title(clusterer, title)\n }\n\n if (zoomOnClick) {\n updaterMap.zoomOnClick(clusterer, zoomOnClick)\n }\n\n if (onMouseOut) {\n setMouseoutListener(\n google.maps.event.addListener(\n clusterer,\n eventMap.onMouseOut,\n onMouseOut\n )\n )\n }\n\n if (onMouseOver) {\n setMouseoverListener(\n google.maps.event.addListener(\n clusterer,\n eventMap.onMouseOver,\n onMouseOver\n )\n )\n }\n\n if (onClick) {\n setClickListener(\n google.maps.event.addListener(clusterer, eventMap.onClick, onClick)\n )\n }\n\n if (onClusteringBegin) {\n setClusteringBeginListener(\n google.maps.event.addListener(\n clusterer,\n eventMap.onClusteringBegin,\n onClusteringBegin\n )\n )\n }\n\n if (onClusteringEnd) {\n setClusteringEndListener(\n google.maps.event.addListener(\n clusterer,\n eventMap.onClusteringEnd,\n onClusteringEnd\n )\n )\n }\n\n setInstance(clusterer)\n\n if (onLoad) {\n onLoad(clusterer)\n }\n\n return () => {\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n if (clusteringBeginListener !== null) {\n google.maps.event.removeListener(clusteringBeginListener)\n }\n\n if (clusteringEndListener !== null) {\n google.maps.event.removeListener(clusteringEndListener)\n }\n\n if (onUnmount) {\n onUnmount(clusterer)\n }\n }\n }, [])\n\n return instance !== null ? children(instance) || null : null\n}\n\nexport const MarkerClustererF = memo(MarkerClustererFunctional)\n\nexport class ClustererComponent extends PureComponent<\n MarkerClustererProps,\n ClustererState\n> {\n static override contextType = MapContext\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: ClustererState = {\n markerClusterer: null,\n }\n\n setClustererCallback = (): void => {\n if (this.state.markerClusterer !== null && this.props.onLoad) {\n this.props.onLoad(this.state.markerClusterer)\n }\n }\n\n override componentDidMount(): void {\n if (this.context) {\n const markerClusterer = new Clusterer(\n this.context,\n [],\n this.props.options\n )\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: markerClusterer,\n })\n\n this.setState((): ClustererState => {\n return {\n markerClusterer,\n }\n }, this.setClustererCallback)\n }\n }\n\n override componentDidUpdate(prevProps: MarkerClustererProps): void {\n if (this.state.markerClusterer) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.markerClusterer,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.markerClusterer !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.markerClusterer)\n }\n\n unregisterEvents(this.registeredEvents)\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.state.markerClusterer.setMap(null)\n }\n }\n\n override render(): JSX.Element | null {\n return this.state.markerClusterer !== null\n ? this.props.children(this.state.markerClusterer)\n : null\n }\n}\n\nexport default ClustererComponent\n","// This handler prevents an event in the InfoBox from being passed on to the map.\nfunction cancelHandler(event) {\n event.cancelBubble = true;\n if (event.stopPropagation) {\n event.stopPropagation();\n }\n}\nvar InfoBox = /** @class */ (function () {\n function InfoBox(options) {\n if (options === void 0) { options = {}; }\n this.getCloseClickHandler = this.getCloseClickHandler.bind(this);\n this.closeClickHandler = this.closeClickHandler.bind(this);\n this.createInfoBoxDiv = this.createInfoBoxDiv.bind(this);\n this.addClickHandler = this.addClickHandler.bind(this);\n this.getCloseBoxImg = this.getCloseBoxImg.bind(this);\n this.getBoxWidths = this.getBoxWidths.bind(this);\n this.setBoxStyle = this.setBoxStyle.bind(this);\n this.setPosition = this.setPosition.bind(this);\n this.getPosition = this.getPosition.bind(this);\n this.setOptions = this.setOptions.bind(this);\n this.setContent = this.setContent.bind(this);\n this.setVisible = this.setVisible.bind(this);\n this.getContent = this.getContent.bind(this);\n this.getVisible = this.getVisible.bind(this);\n this.setZIndex = this.setZIndex.bind(this);\n this.getZIndex = this.getZIndex.bind(this);\n this.onRemove = this.onRemove.bind(this);\n this.panBox = this.panBox.bind(this);\n this.extend = this.extend.bind(this);\n this.close = this.close.bind(this);\n this.draw = this.draw.bind(this);\n this.show = this.show.bind(this);\n this.hide = this.hide.bind(this);\n this.open = this.open.bind(this);\n this.extend(InfoBox, google.maps.OverlayView);\n // Standard options (in common with google.maps.InfoWindow):\n this.content = options.content || '';\n this.disableAutoPan = options.disableAutoPan || false;\n this.maxWidth = options.maxWidth || 0;\n this.pixelOffset = options.pixelOffset || new google.maps.Size(0, 0);\n this.position = options.position || new google.maps.LatLng(0, 0);\n this.zIndex = options.zIndex || null;\n // Additional options (unique to InfoBox):\n this.boxClass = options.boxClass || 'infoBox';\n this.boxStyle = options.boxStyle || {};\n this.closeBoxMargin = options.closeBoxMargin || '2px';\n this.closeBoxURL = options.closeBoxURL || 'http://www.google.com/intl/en_us/mapfiles/close.gif';\n if (options.closeBoxURL === '') {\n this.closeBoxURL = '';\n }\n this.infoBoxClearance = options.infoBoxClearance || new google.maps.Size(1, 1);\n if (typeof options.visible === 'undefined') {\n if (typeof options.isHidden === 'undefined') {\n options.visible = true;\n }\n else {\n options.visible = !options.isHidden;\n }\n }\n this.isHidden = !options.visible;\n this.alignBottom = options.alignBottom || false;\n this.pane = options.pane || 'floatPane';\n this.enableEventPropagation = options.enableEventPropagation || false;\n this.div = null;\n this.closeListener = null;\n this.moveListener = null;\n this.mapListener = null;\n this.contextListener = null;\n this.eventListeners = null;\n this.fixedWidthSet = null;\n }\n InfoBox.prototype.createInfoBoxDiv = function () {\n var _this = this;\n // This handler ignores the current event in the InfoBox and conditionally prevents\n // the event from being passed on to the map. It is used for the contextmenu event.\n var ignoreHandler = function (event) {\n event.returnValue = false;\n if (event.preventDefault) {\n event.preventDefault();\n }\n if (!_this.enableEventPropagation) {\n cancelHandler(event);\n }\n };\n if (!this.div) {\n this.div = document.createElement('div');\n this.setBoxStyle();\n if (typeof this.content === 'string') {\n this.div.innerHTML = this.getCloseBoxImg() + this.content;\n }\n else {\n this.div.innerHTML = this.getCloseBoxImg();\n this.div.appendChild(this.content);\n }\n var panes = this.getPanes();\n if (panes !== null) {\n panes[this.pane].appendChild(this.div); // Add the InfoBox div to the DOM\n }\n this.addClickHandler();\n if (this.div.style.width) {\n this.fixedWidthSet = true;\n }\n else {\n if (this.maxWidth !== 0 && this.div.offsetWidth > this.maxWidth) {\n this.div.style.width = this.maxWidth + 'px';\n this.fixedWidthSet = true;\n }\n else {\n // The following code is needed to overcome problems with MSIE\n var bw = this.getBoxWidths();\n this.div.style.width = this.div.offsetWidth - bw.left - bw.right + 'px';\n this.fixedWidthSet = false;\n }\n }\n this.panBox(this.disableAutoPan);\n if (!this.enableEventPropagation) {\n this.eventListeners = [];\n // Cancel event propagation.\n // Note: mousemove not included (to resolve Issue 152)\n var events = [\n 'mousedown',\n 'mouseover',\n 'mouseout',\n 'mouseup',\n 'click',\n 'dblclick',\n 'touchstart',\n 'touchend',\n 'touchmove',\n ];\n for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {\n var event_1 = events_1[_i];\n this.eventListeners.push(google.maps.event.addListener(this.div, event_1, cancelHandler));\n }\n // Workaround for Google bug that causes the cursor to change to a pointer\n // when the mouse moves over a marker underneath InfoBox.\n this.eventListeners.push(google.maps.event.addListener(this.div, 'mouseover', function () {\n if (_this.div) {\n _this.div.style.cursor = 'default';\n }\n }));\n }\n this.contextListener = google.maps.event.addListener(this.div, 'contextmenu', ignoreHandler);\n /**\n * This event is fired when the DIV containing the InfoBox's content is attached to the DOM.\n * @name InfoBox#domready\n * @event\n */\n google.maps.event.trigger(this, 'domready');\n }\n };\n InfoBox.prototype.getCloseBoxImg = function () {\n var img = '';\n if (this.closeBoxURL !== '') {\n img = '\";\n }\n return img;\n };\n InfoBox.prototype.addClickHandler = function () {\n this.closeListener = this.div && this.div.firstChild && this.closeBoxURL !== ''\n ? google.maps.event.addListener(this.div.firstChild, 'click', this.getCloseClickHandler())\n : null;\n };\n InfoBox.prototype.closeClickHandler = function (event) {\n // 1.0.3 fix: Always prevent propagation of a close box click to the map:\n event.cancelBubble = true;\n if (event.stopPropagation) {\n event.stopPropagation();\n }\n /**\n * This event is fired when the InfoBox's close box is clicked.\n * @name InfoBox#closeclick\n * @event\n */\n google.maps.event.trigger(this, 'closeclick');\n this.close();\n };\n InfoBox.prototype.getCloseClickHandler = function () {\n return this.closeClickHandler;\n };\n InfoBox.prototype.panBox = function (disablePan) {\n if (this.div && !disablePan) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n var map = this.getMap();\n // Only pan if attached to map, not panorama\n if (map instanceof google.maps.Map) {\n var xOffset = 0;\n var yOffset = 0;\n var bounds = map.getBounds();\n if (bounds && !bounds.contains(this.position)) {\n // Marker not in visible area of map, so set center\n // of map to the marker position first.\n map.setCenter(this.position);\n }\n var mapDiv = map.getDiv();\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n var mapWidth = mapDiv.offsetWidth;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n var mapHeight = mapDiv.offsetHeight;\n var iwOffsetX = this.pixelOffset.width;\n var iwOffsetY = this.pixelOffset.height;\n var iwWidth = this.div.offsetWidth;\n var iwHeight = this.div.offsetHeight;\n var padX = this.infoBoxClearance.width;\n var padY = this.infoBoxClearance.height;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n var projection = this.getProjection();\n var pixPosition = projection.fromLatLngToContainerPixel(this.position);\n if (pixPosition !== null) {\n if (pixPosition.x < -iwOffsetX + padX) {\n xOffset = pixPosition.x + iwOffsetX - padX;\n }\n else if (pixPosition.x + iwWidth + iwOffsetX + padX > mapWidth) {\n xOffset = pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth;\n }\n if (this.alignBottom) {\n if (pixPosition.y < -iwOffsetY + padY + iwHeight) {\n yOffset = pixPosition.y + iwOffsetY - padY - iwHeight;\n }\n else if (pixPosition.y + iwOffsetY + padY > mapHeight) {\n yOffset = pixPosition.y + iwOffsetY + padY - mapHeight;\n }\n }\n else {\n if (pixPosition.y < -iwOffsetY + padY) {\n yOffset = pixPosition.y + iwOffsetY - padY;\n }\n else if (pixPosition.y + iwHeight + iwOffsetY + padY > mapHeight) {\n yOffset = pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight;\n }\n }\n }\n if (!(xOffset === 0 && yOffset === 0)) {\n // Move the map to the shifted center.\n map.panBy(xOffset, yOffset);\n }\n }\n }\n };\n InfoBox.prototype.setBoxStyle = function () {\n if (this.div) {\n // Apply style values from the style sheet defined in the boxClass parameter:\n this.div.className = this.boxClass;\n // Clear existing inline style values:\n this.div.style.cssText = '';\n // Apply style values defined in the boxStyle parameter:\n var boxStyle = this.boxStyle;\n for (var i in boxStyle) {\n if (Object.prototype.hasOwnProperty.call(boxStyle, i)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.div.style[i] = boxStyle[i];\n }\n }\n // Fix for iOS disappearing InfoBox problem\n // See http://stackoverflow.com/questions/9229535/google-maps-markers-disappear-at-certain-zoom-level-only-on-iphone-ipad\n this.div.style.webkitTransform = 'translateZ(0)';\n // Fix up opacity style for benefit of MSIE\n if (typeof this.div.style.opacity !== 'undefined' && this.div.style.opacity !== '') {\n // See http://www.quirksmode.org/css/opacity.html\n var opacity = parseFloat(this.div.style.opacity || '');\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.div.style.msFilter =\n '\"progid:DXImageTransform.Microsoft.Alpha(Opacity=' + opacity * 100 + ')\"';\n this.div.style.filter = 'alpha(opacity=' + opacity * 100 + ')';\n }\n // Apply required styles\n this.div.style.position = 'absolute';\n this.div.style.visibility = 'hidden';\n if (this.zIndex !== null) {\n this.div.style.zIndex = this.zIndex + '';\n }\n if (!this.div.style.overflow) {\n this.div.style.overflow = 'auto';\n }\n }\n };\n InfoBox.prototype.getBoxWidths = function () {\n var bw = { top: 0, bottom: 0, left: 0, right: 0 };\n if (!this.div) {\n return bw;\n }\n if (document.defaultView) {\n var ownerDocument = this.div.ownerDocument;\n var computedStyle = ownerDocument && ownerDocument.defaultView\n ? ownerDocument.defaultView.getComputedStyle(this.div, '')\n : null;\n if (computedStyle) {\n // The computed styles are always in pixel units (good!)\n bw.top = parseInt(computedStyle.borderTopWidth || '', 10) || 0;\n bw.bottom = parseInt(computedStyle.borderBottomWidth || '', 10) || 0;\n bw.left = parseInt(computedStyle.borderLeftWidth || '', 10) || 0;\n bw.right = parseInt(computedStyle.borderRightWidth || '', 10) || 0;\n }\n }\n else if (\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n document.documentElement.currentStyle // MSIE\n ) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n var currentStyle = this.div.currentStyle;\n if (currentStyle) {\n // The current styles may not be in pixel units, but assume they are (bad!)\n bw.top = parseInt(currentStyle.borderTopWidth || '', 10) || 0;\n bw.bottom = parseInt(currentStyle.borderBottomWidth || '', 10) || 0;\n bw.left = parseInt(currentStyle.borderLeftWidth || '', 10) || 0;\n bw.right = parseInt(currentStyle.borderRightWidth || '', 10) || 0;\n }\n }\n return bw;\n };\n InfoBox.prototype.onRemove = function () {\n if (this.div && this.div.parentNode) {\n this.div.parentNode.removeChild(this.div);\n this.div = null;\n }\n };\n InfoBox.prototype.draw = function () {\n this.createInfoBoxDiv();\n if (this.div) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n var projection = this.getProjection();\n var pixPosition = projection.fromLatLngToDivPixel(this.position);\n if (pixPosition !== null) {\n this.div.style.left = pixPosition.x + this.pixelOffset.width + 'px';\n if (this.alignBottom) {\n this.div.style.bottom = -(pixPosition.y + this.pixelOffset.height) + 'px';\n }\n else {\n this.div.style.top = pixPosition.y + this.pixelOffset.height + 'px';\n }\n }\n if (this.isHidden) {\n this.div.style.visibility = 'hidden';\n }\n else {\n this.div.style.visibility = 'visible';\n }\n }\n };\n InfoBox.prototype.setOptions = function (options) {\n if (options === void 0) { options = {}; }\n if (typeof options.boxClass !== 'undefined') {\n // Must be first\n this.boxClass = options.boxClass;\n this.setBoxStyle();\n }\n if (typeof options.boxStyle !== 'undefined') {\n // Must be second\n this.boxStyle = options.boxStyle;\n this.setBoxStyle();\n }\n if (typeof options.content !== 'undefined') {\n this.setContent(options.content);\n }\n if (typeof options.disableAutoPan !== 'undefined') {\n this.disableAutoPan = options.disableAutoPan;\n }\n if (typeof options.maxWidth !== 'undefined') {\n this.maxWidth = options.maxWidth;\n }\n if (typeof options.pixelOffset !== 'undefined') {\n this.pixelOffset = options.pixelOffset;\n }\n if (typeof options.alignBottom !== 'undefined') {\n this.alignBottom = options.alignBottom;\n }\n if (typeof options.position !== 'undefined') {\n this.setPosition(options.position);\n }\n if (typeof options.zIndex !== 'undefined') {\n this.setZIndex(options.zIndex);\n }\n if (typeof options.closeBoxMargin !== 'undefined') {\n this.closeBoxMargin = options.closeBoxMargin;\n }\n if (typeof options.closeBoxURL !== 'undefined') {\n this.closeBoxURL = options.closeBoxURL;\n }\n if (typeof options.infoBoxClearance !== 'undefined') {\n this.infoBoxClearance = options.infoBoxClearance;\n }\n if (typeof options.isHidden !== 'undefined') {\n this.isHidden = options.isHidden;\n }\n if (typeof options.visible !== 'undefined') {\n this.isHidden = !options.visible;\n }\n if (typeof options.enableEventPropagation !== 'undefined') {\n this.enableEventPropagation = options.enableEventPropagation;\n }\n if (this.div) {\n this.draw();\n }\n };\n InfoBox.prototype.setContent = function (content) {\n this.content = content;\n if (this.div) {\n if (this.closeListener) {\n google.maps.event.removeListener(this.closeListener);\n this.closeListener = null;\n }\n // Odd code required to make things work with MSIE.\n if (!this.fixedWidthSet) {\n this.div.style.width = '';\n }\n if (typeof content === 'string') {\n this.div.innerHTML = this.getCloseBoxImg() + content;\n }\n else {\n this.div.innerHTML = this.getCloseBoxImg();\n this.div.appendChild(content);\n }\n // Perverse code required to make things work with MSIE.\n // (Ensures the close box does, in fact, float to the right.)\n if (!this.fixedWidthSet) {\n this.div.style.width = this.div.offsetWidth + 'px';\n if (typeof content === 'string') {\n this.div.innerHTML = this.getCloseBoxImg() + content;\n }\n else {\n this.div.innerHTML = this.getCloseBoxImg();\n this.div.appendChild(content);\n }\n }\n this.addClickHandler();\n }\n /**\n * This event is fired when the content of the InfoBox changes.\n * @name InfoBox#content_changed\n * @event\n */\n google.maps.event.trigger(this, 'content_changed');\n };\n InfoBox.prototype.setPosition = function (latLng) {\n this.position = latLng;\n if (this.div) {\n this.draw();\n }\n /**\n * This event is fired when the position of the InfoBox changes.\n * @name InfoBox#position_changed\n * @event\n */\n google.maps.event.trigger(this, 'position_changed');\n };\n InfoBox.prototype.setVisible = function (isVisible) {\n this.isHidden = !isVisible;\n if (this.div) {\n this.div.style.visibility = this.isHidden ? 'hidden' : 'visible';\n }\n };\n InfoBox.prototype.setZIndex = function (index) {\n this.zIndex = index;\n if (this.div) {\n this.div.style.zIndex = index + '';\n }\n /**\n * This event is fired when the zIndex of the InfoBox changes.\n * @name InfoBox#zindex_changed\n * @event\n */\n google.maps.event.trigger(this, 'zindex_changed');\n };\n InfoBox.prototype.getContent = function () {\n return this.content;\n };\n InfoBox.prototype.getPosition = function () {\n return this.position;\n };\n InfoBox.prototype.getZIndex = function () {\n return this.zIndex;\n };\n InfoBox.prototype.getVisible = function () {\n var map = this.getMap();\n return typeof map === 'undefined' || map === null ? false : !this.isHidden;\n };\n InfoBox.prototype.show = function () {\n this.isHidden = false;\n if (this.div) {\n this.div.style.visibility = 'visible';\n }\n };\n InfoBox.prototype.hide = function () {\n this.isHidden = true;\n if (this.div) {\n this.div.style.visibility = 'hidden';\n }\n };\n InfoBox.prototype.open = function (map, anchor) {\n var _this = this;\n if (anchor) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.position = anchor.getPosition();\n this.moveListener = google.maps.event.addListener(anchor, 'position_changed', function () {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n var position = anchor.getPosition();\n _this.setPosition(position);\n });\n this.mapListener = google.maps.event.addListener(anchor, 'map_changed', function () {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n _this.setMap(anchor.map);\n });\n }\n this.setMap(map);\n if (this.div) {\n this.panBox();\n }\n };\n InfoBox.prototype.close = function () {\n if (this.closeListener) {\n google.maps.event.removeListener(this.closeListener);\n this.closeListener = null;\n }\n if (this.eventListeners) {\n for (var _i = 0, _a = this.eventListeners; _i < _a.length; _i++) {\n var eventListener = _a[_i];\n google.maps.event.removeListener(eventListener);\n }\n this.eventListeners = null;\n }\n if (this.moveListener) {\n google.maps.event.removeListener(this.moveListener);\n this.moveListener = null;\n }\n if (this.mapListener) {\n google.maps.event.removeListener(this.mapListener);\n this.mapListener = null;\n }\n if (this.contextListener) {\n google.maps.event.removeListener(this.contextListener);\n this.contextListener = null;\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.setMap(null);\n };\n InfoBox.prototype.extend = function (obj1, obj2) {\n return function applyExtend(object) {\n for (var property in object.prototype) {\n if (!Object.prototype.hasOwnProperty.call(this, property)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.prototype[property] = object.prototype[property];\n }\n }\n return this;\n }.apply(obj1, [obj2]);\n };\n return InfoBox;\n}());\n\nexport { InfoBox };\n//# sourceMappingURL=esm.js.map\n","/* global google */\nimport {\n memo,\n useRef,\n Children,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ReactNode,\n type ReactPortal,\n type ContextType,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport invariant from 'invariant'\nimport {\n InfoBox as GoogleMapsInfoBox,\n type InfoBoxOptions,\n} from '@react-google-maps/infobox'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onCloseClick: 'closeclick',\n onContentChanged: 'content_changed',\n onDomReady: 'domready',\n onPositionChanged: 'position_changed',\n onZindexChanged: 'zindex_changed',\n}\n\nconst updaterMap = {\n options(instance: GoogleMapsInfoBox, options: InfoBoxOptions): void {\n instance.setOptions(options)\n },\n position(\n instance: GoogleMapsInfoBox,\n position: google.maps.LatLng | google.maps.LatLngLiteral\n ): void {\n if (position instanceof google.maps.LatLng) {\n instance.setPosition(position)\n } else {\n instance.setPosition(new google.maps.LatLng(position.lat, position.lng))\n }\n },\n visible(instance: GoogleMapsInfoBox, visible: boolean): void {\n instance.setVisible(visible)\n },\n zIndex(instance: GoogleMapsInfoBox, zIndex: number): void {\n instance.setZIndex(zIndex)\n },\n}\n\ntype InfoBoxState = {\n infoBox: GoogleMapsInfoBox | null\n}\n\nexport type InfoBoxProps = {\n children?: ReactNode | undefined\n /** Can be any MVCObject that exposes a LatLng position property and optionally a Point anchorPoint property for calculating the pixelOffset. The anchorPoint is the offset from the anchor's position to the tip of the InfoBox. */\n anchor?: google.maps.MVCObject | undefined\n options?: InfoBoxOptions | undefined\n /** The LatLng at which to display this InfoBox. If the InfoBox is opened with an anchor, the anchor's position will be used instead. */\n position?: google.maps.LatLng | undefined\n /** All InfoBoxes are displayed on the map in order of their zIndex, with higher values displaying in front of InfoBoxes with lower values. By default, InfoBoxes are displayed according to their latitude, with InfoBoxes of lower latitudes appearing in front of InfoBoxes at higher latitudes. InfoBoxes are always displayed in front of markers. */\n zIndex?: number | undefined\n /** This event is fired when the close button was clicked. */\n onCloseClick?: (() => void) | undefined\n /** This event is fired when the
containing the InfoBox's content is attached to the DOM. You may wish to monitor this event if you are building out your info window content dynamically. */\n onDomReady?: (() => void) | undefined\n /** This event is fired when the content property changes. */\n onContentChanged?: (() => void) | undefined\n /** This event is fired when the position property changes. */\n onPositionChanged?: (() => void) | undefined\n /** This event is fired when the InfoBox's zIndex changes. */\n onZindexChanged?: (() => void) | undefined\n /** This callback is called when the infoBox instance has loaded. It is called with the infoBox instance. */\n onLoad?: ((infoBox: GoogleMapsInfoBox) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the infoBox instance. */\n onUnmount?: ((infoBox: GoogleMapsInfoBox) => void) | undefined\n}\n\nconst defaultOptions: InfoBoxOptions = {}\n\nfunction InfoBoxFunctional({\n children,\n anchor,\n options,\n position,\n zIndex,\n onCloseClick,\n onDomReady,\n onContentChanged,\n onPositionChanged,\n onZindexChanged,\n onLoad,\n onUnmount,\n}: InfoBoxProps): ReactPortal | null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(null)\n\n const [closeClickListener, setCloseClickListener] =\n useState(null)\n const [domReadyClickListener, setDomReadyClickListener] =\n useState(null)\n const [contentChangedClickListener, setContentChangedClickListener] =\n useState(null)\n const [positionChangedClickListener, setPositionChangedClickListener] =\n useState(null)\n const [zIndexChangedClickListener, setZindexChangedClickListener] =\n useState(null)\n\n const containerElementRef = useRef(null)\n\n // Order does matter\n useEffect(() => {\n if (map && instance !== null) {\n instance.close()\n\n if (anchor) {\n instance.open(map, anchor)\n } else if (instance.getPosition()) {\n instance.open(map)\n }\n }\n }, [map, instance, anchor])\n\n useEffect(() => {\n if (options && instance !== null) {\n instance.setOptions(options)\n }\n }, [instance, options])\n\n useEffect(() => {\n if (position && instance !== null) {\n const positionLatLng =\n position instanceof google.maps.LatLng\n ? position\n : // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n new google.maps.LatLng(position.lat, position.lng)\n\n instance.setPosition(positionLatLng)\n }\n }, [position])\n\n useEffect(() => {\n if (typeof zIndex === 'number' && instance !== null) {\n instance.setZIndex(zIndex)\n }\n }, [zIndex])\n\n useEffect(() => {\n if (instance && onCloseClick) {\n if (closeClickListener !== null) {\n google.maps.event.removeListener(closeClickListener)\n }\n\n setCloseClickListener(\n google.maps.event.addListener(instance, 'closeclick', onCloseClick)\n )\n }\n }, [onCloseClick])\n\n useEffect(() => {\n if (instance && onDomReady) {\n if (domReadyClickListener !== null) {\n google.maps.event.removeListener(domReadyClickListener)\n }\n\n setDomReadyClickListener(\n google.maps.event.addListener(instance, 'domready', onDomReady)\n )\n }\n }, [onDomReady])\n\n useEffect(() => {\n if (instance && onContentChanged) {\n if (contentChangedClickListener !== null) {\n google.maps.event.removeListener(contentChangedClickListener)\n }\n\n setContentChangedClickListener(\n google.maps.event.addListener(\n instance,\n 'content_changed',\n onContentChanged\n )\n )\n }\n }, [onContentChanged])\n\n useEffect(() => {\n if (instance && onPositionChanged) {\n if (positionChangedClickListener !== null) {\n google.maps.event.removeListener(positionChangedClickListener)\n }\n\n setPositionChangedClickListener(\n google.maps.event.addListener(\n instance,\n 'position_changed',\n onPositionChanged\n )\n )\n }\n }, [onPositionChanged])\n\n useEffect(() => {\n if (instance && onZindexChanged) {\n if (zIndexChangedClickListener !== null) {\n google.maps.event.removeListener(zIndexChangedClickListener)\n }\n\n setZindexChangedClickListener(\n google.maps.event.addListener(\n instance,\n 'zindex_changed',\n onZindexChanged\n )\n )\n }\n }, [onZindexChanged])\n\n useEffect(() => {\n if (map) {\n const { position, ...infoBoxOptions }: InfoBoxOptions =\n options || defaultOptions\n\n let positionLatLng: google.maps.LatLng | undefined\n\n if (position && !(position instanceof google.maps.LatLng)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n positionLatLng = new google.maps.LatLng(position.lat, position.lng)\n }\n\n const infoBox = new GoogleMapsInfoBox({\n ...infoBoxOptions,\n ...(positionLatLng ? { position: positionLatLng } : {}),\n })\n\n containerElementRef.current = document.createElement('div')\n\n setInstance(infoBox)\n\n if (onCloseClick) {\n setCloseClickListener(\n google.maps.event.addListener(infoBox, 'closeclick', onCloseClick)\n )\n }\n\n if (onDomReady) {\n setDomReadyClickListener(\n google.maps.event.addListener(infoBox, 'domready', onDomReady)\n )\n }\n\n if (onContentChanged) {\n setContentChangedClickListener(\n google.maps.event.addListener(\n infoBox,\n 'content_changed',\n onContentChanged\n )\n )\n }\n\n if (onPositionChanged) {\n setPositionChangedClickListener(\n google.maps.event.addListener(\n infoBox,\n 'position_changed',\n onPositionChanged\n )\n )\n }\n\n if (onZindexChanged) {\n setZindexChangedClickListener(\n google.maps.event.addListener(\n infoBox,\n 'zindex_changed',\n onZindexChanged\n )\n )\n }\n\n infoBox.setContent(containerElementRef.current)\n\n if (anchor) {\n infoBox.open(map, anchor)\n } else if (infoBox.getPosition()) {\n infoBox.open(map)\n } else {\n invariant(\n false,\n 'You must provide either an anchor or a position prop for .'\n )\n }\n\n if (onLoad) {\n onLoad(infoBox)\n }\n }\n\n return () => {\n if (instance !== null) {\n if (closeClickListener) {\n google.maps.event.removeListener(closeClickListener)\n }\n\n if (contentChangedClickListener) {\n google.maps.event.removeListener(contentChangedClickListener)\n }\n\n if (domReadyClickListener) {\n google.maps.event.removeListener(domReadyClickListener)\n }\n\n if (positionChangedClickListener) {\n google.maps.event.removeListener(positionChangedClickListener)\n }\n\n if (zIndexChangedClickListener) {\n google.maps.event.removeListener(zIndexChangedClickListener)\n }\n\n if (onUnmount) {\n onUnmount(instance)\n }\n\n instance.close()\n }\n }\n }, [])\n\n return containerElementRef.current\n ? createPortal(Children.only(children), containerElementRef.current)\n : null\n}\n\nexport const InfoBoxF = memo(InfoBoxFunctional)\n\nexport class InfoBoxComponent extends PureComponent<\n InfoBoxProps,\n InfoBoxState\n> {\n static override contextType = MapContext\n\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n containerElement: HTMLElement | null = null\n\n override state: InfoBoxState = {\n infoBox: null,\n }\n\n open = (infoBox: GoogleMapsInfoBox, anchor?: google.maps.MVCObject): void => {\n if (anchor) {\n if (this.context !== null) {\n infoBox.open(this.context, anchor)\n }\n } else if (infoBox.getPosition()) {\n if (this.context !== null) {\n infoBox.open(this.context)\n }\n } else {\n invariant(\n false,\n 'You must provide either an anchor or a position prop for .'\n )\n }\n }\n\n setInfoBoxCallback = (): void => {\n if (this.state.infoBox !== null && this.containerElement !== null) {\n this.state.infoBox.setContent(this.containerElement)\n\n this.open(this.state.infoBox, this.props.anchor)\n\n if (this.props.onLoad) {\n this.props.onLoad(this.state.infoBox)\n }\n }\n }\n\n override componentDidMount(): void {\n const { position, ...infoBoxOptions }: InfoBoxOptions =\n this.props.options || {}\n\n let positionLatLng: google.maps.LatLng | undefined\n\n if (position && !(position instanceof google.maps.LatLng)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n positionLatLng = new google.maps.LatLng(position.lat, position.lng)\n }\n\n const infoBox = new GoogleMapsInfoBox({\n ...infoBoxOptions,\n ...(positionLatLng ? { position: positionLatLng } : {}),\n })\n\n this.containerElement = document.createElement('div')\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: infoBox,\n })\n\n this.setState({ infoBox }, this.setInfoBoxCallback)\n }\n\n override componentDidUpdate(prevProps: InfoBoxProps): void {\n const { infoBox } = this.state\n\n if (infoBox !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: infoBox,\n })\n }\n }\n\n override componentWillUnmount(): void {\n const { onUnmount } = this.props\n const { infoBox } = this.state\n\n if (infoBox !== null) {\n if (onUnmount) {\n onUnmount(infoBox)\n }\n\n unregisterEvents(this.registeredEvents)\n infoBox.close()\n }\n }\n\n override render(): ReactPortal | null {\n return this.containerElement\n ? createPortal(Children.only(this.props.children), this.containerElement)\n : null\n }\n}\n\nexport default InfoBoxComponent\n","'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n","\nconst ARRAY_TYPES = [\n Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array,\n Int32Array, Uint32Array, Float32Array, Float64Array\n];\n\n/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */\n\nconst VERSION = 1; // serialized format version\nconst HEADER_SIZE = 8;\n\nexport default class KDBush {\n\n /**\n * Creates an index from raw `ArrayBuffer` data.\n * @param {ArrayBuffer} data\n */\n static from(data) {\n if (!(data instanceof ArrayBuffer)) {\n throw new Error('Data must be an instance of ArrayBuffer.');\n }\n const [magic, versionAndType] = new Uint8Array(data, 0, 2);\n if (magic !== 0xdb) {\n throw new Error('Data does not appear to be in a KDBush format.');\n }\n const version = versionAndType >> 4;\n if (version !== VERSION) {\n throw new Error(`Got v${version} data when expected v${VERSION}.`);\n }\n const ArrayType = ARRAY_TYPES[versionAndType & 0x0f];\n if (!ArrayType) {\n throw new Error('Unrecognized array type.');\n }\n const [nodeSize] = new Uint16Array(data, 2, 1);\n const [numItems] = new Uint32Array(data, 4, 1);\n\n return new KDBush(numItems, nodeSize, ArrayType, data);\n }\n\n /**\n * Creates an index that will hold a given number of items.\n * @param {number} numItems\n * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).\n * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).\n * @param {ArrayBuffer} [data] (For internal use only)\n */\n constructor(numItems, nodeSize = 64, ArrayType = Float64Array, data) {\n if (isNaN(numItems) || numItems < 0) throw new Error(`Unpexpected numItems value: ${numItems}.`);\n\n this.numItems = +numItems;\n this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);\n this.ArrayType = ArrayType;\n this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array;\n\n const arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType);\n const coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT;\n const idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT;\n const padCoords = (8 - idsByteSize % 8) % 8;\n\n if (arrayTypeIndex < 0) {\n throw new Error(`Unexpected typed array class: ${ArrayType}.`);\n }\n\n if (data && (data instanceof ArrayBuffer)) { // reconstruct an index from a buffer\n this.data = data;\n this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);\n this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = numItems * 2;\n this._finished = true;\n } else { // initialize a new index\n this.data = new ArrayBuffer(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords);\n this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);\n this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);\n this._pos = 0;\n this._finished = false;\n\n // set header\n new Uint8Array(this.data, 0, 2).set([0xdb, (VERSION << 4) + arrayTypeIndex]);\n new Uint16Array(this.data, 2, 1)[0] = nodeSize;\n new Uint32Array(this.data, 4, 1)[0] = numItems;\n }\n }\n\n /**\n * Add a point to the index.\n * @param {number} x\n * @param {number} y\n * @returns {number} An incremental index associated with the added item (starting from `0`).\n */\n add(x, y) {\n const index = this._pos >> 1;\n this.ids[index] = index;\n this.coords[this._pos++] = x;\n this.coords[this._pos++] = y;\n return index;\n }\n\n /**\n * Perform indexing of the added points.\n */\n finish() {\n const numAdded = this._pos >> 1;\n if (numAdded !== this.numItems) {\n throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`);\n }\n // kd-sort both arrays for efficient search\n sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0);\n\n this._finished = true;\n return this;\n }\n\n /**\n * Search the index for items within a given bounding box.\n * @param {number} minX\n * @param {number} minY\n * @param {number} maxX\n * @param {number} maxY\n * @returns {number[]} An array of indices correponding to the found items.\n */\n range(minX, minY, maxX, maxY) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n const stack = [0, ids.length - 1, 0];\n const result = [];\n\n // recursively search for items in range in the kd-sorted arrays\n while (stack.length) {\n const axis = stack.pop() || 0;\n const right = stack.pop() || 0;\n const left = stack.pop() || 0;\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n const x = coords[2 * i];\n const y = coords[2 * i + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? minX <= x : minY <= y) {\n stack.push(left);\n stack.push(m - 1);\n stack.push(1 - axis);\n }\n if (axis === 0 ? maxX >= x : maxY >= y) {\n stack.push(m + 1);\n stack.push(right);\n stack.push(1 - axis);\n }\n }\n\n return result;\n }\n\n /**\n * Search the index for items within a given radius.\n * @param {number} qx\n * @param {number} qy\n * @param {number} r Query radius.\n * @returns {number[]} An array of indices correponding to the found items.\n */\n within(qx, qy, r) {\n if (!this._finished) throw new Error('Data not yet indexed - call index.finish().');\n\n const {ids, coords, nodeSize} = this;\n const stack = [0, ids.length - 1, 0];\n const result = [];\n const r2 = r * r;\n\n // recursively search for items within radius in the kd-sorted arrays\n while (stack.length) {\n const axis = stack.pop() || 0;\n const right = stack.pop() || 0;\n const left = stack.pop() || 0;\n\n // if we reached \"tree node\", search linearly\n if (right - left <= nodeSize) {\n for (let i = left; i <= right; i++) {\n if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) result.push(ids[i]);\n }\n continue;\n }\n\n // otherwise find the middle index\n const m = (left + right) >> 1;\n\n // include the middle item if it's in range\n const x = coords[2 * m];\n const y = coords[2 * m + 1];\n if (sqDist(x, y, qx, qy) <= r2) result.push(ids[m]);\n\n // queue search in halves that intersect the query\n if (axis === 0 ? qx - r <= x : qy - r <= y) {\n stack.push(left);\n stack.push(m - 1);\n stack.push(1 - axis);\n }\n if (axis === 0 ? qx + r >= x : qy + r >= y) {\n stack.push(m + 1);\n stack.push(right);\n stack.push(1 - axis);\n }\n }\n\n return result;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} nodeSize\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction sort(ids, coords, nodeSize, left, right, axis) {\n if (right - left <= nodeSize) return;\n\n const m = (left + right) >> 1; // middle index\n\n // sort ids and coords around the middle index so that the halves lie\n // either left/right or top/bottom correspondingly (taking turns)\n select(ids, coords, m, left, right, axis);\n\n // recursively kd-sort first half and second half on the opposite axis\n sort(ids, coords, nodeSize, left, m - 1, 1 - axis);\n sort(ids, coords, nodeSize, m + 1, right, 1 - axis);\n}\n\n/**\n * Custom Floyd-Rivest selection algorithm: sort ids and coords so that\n * [left..k-1] items are smaller than k-th item (on either x or y axis)\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} k\n * @param {number} left\n * @param {number} right\n * @param {number} axis\n */\nfunction select(ids, coords, k, left, right, axis) {\n\n while (right > left) {\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp(2 * z / 3);\n const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n select(ids, coords, k, newLeft, newRight, axis);\n }\n\n const t = coords[2 * k + axis];\n let i = left;\n let j = right;\n\n swapItem(ids, coords, left, k);\n if (coords[2 * right + axis] > t) swapItem(ids, coords, left, right);\n\n while (i < j) {\n swapItem(ids, coords, i, j);\n i++;\n j--;\n while (coords[2 * i + axis] < t) i++;\n while (coords[2 * j + axis] > t) j--;\n }\n\n if (coords[2 * left + axis] === t) swapItem(ids, coords, left, j);\n else {\n j++;\n swapItem(ids, coords, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\n/**\n * @param {Uint16Array | Uint32Array} ids\n * @param {InstanceType} coords\n * @param {number} i\n * @param {number} j\n */\nfunction swapItem(ids, coords, i, j) {\n swap(ids, i, j);\n swap(coords, 2 * i, 2 * j);\n swap(coords, 2 * i + 1, 2 * j + 1);\n}\n\n/**\n * @param {InstanceType} arr\n * @param {number} i\n * @param {number} j\n */\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\n/**\n * @param {number} ax\n * @param {number} ay\n * @param {number} bx\n * @param {number} by\n */\nfunction sqDist(ax, ay, bx, by) {\n const dx = ax - bx;\n const dy = ay - by;\n return dx * dx + dy * dy;\n}\n","\nimport KDBush from 'kdbush';\n\nconst defaultOptions = {\n minZoom: 0, // min zoom to generate clusters on\n maxZoom: 16, // max zoom level to cluster the points on\n minPoints: 2, // minimum points to form a cluster\n radius: 40, // cluster radius in pixels\n extent: 512, // tile extent (radius is calculated relative to it)\n nodeSize: 64, // size of the KD-tree leaf node, affects performance\n log: false, // whether to log timing info\n\n // whether to generate numeric ids for input features (in vector tiles)\n generateId: false,\n\n // a reduce function for calculating custom cluster properties\n reduce: null, // (accumulated, props) => { accumulated.sum += props.sum; }\n\n // properties to use for individual points when running the reducer\n map: props => props // props => ({sum: props.my_value})\n};\n\nconst fround = Math.fround || (tmp => ((x) => { tmp[0] = +x; return tmp[0]; }))(new Float32Array(1));\n\nconst OFFSET_ZOOM = 2;\nconst OFFSET_ID = 3;\nconst OFFSET_PARENT = 4;\nconst OFFSET_NUM = 5;\nconst OFFSET_PROP = 6;\n\nexport default class Supercluster {\n constructor(options) {\n this.options = Object.assign(Object.create(defaultOptions), options);\n this.trees = new Array(this.options.maxZoom + 1);\n this.stride = this.options.reduce ? 7 : 6;\n this.clusterProps = [];\n }\n\n load(points) {\n const {log, minZoom, maxZoom} = this.options;\n\n if (log) console.time('total time');\n\n const timerId = `prepare ${ points.length } points`;\n if (log) console.time(timerId);\n\n this.points = points;\n\n // generate a cluster object for each point and index input points into a KD-tree\n const data = [];\n\n for (let i = 0; i < points.length; i++) {\n const p = points[i];\n if (!p.geometry) continue;\n\n const [lng, lat] = p.geometry.coordinates;\n const x = fround(lngX(lng));\n const y = fround(latY(lat));\n // store internal point/cluster data in flat numeric arrays for performance\n data.push(\n x, y, // projected point coordinates\n Infinity, // the last zoom the point was processed at\n i, // index of the source feature in the original input array\n -1, // parent cluster id\n 1 // number of points in a cluster\n );\n if (this.options.reduce) data.push(0); // noop\n }\n let tree = this.trees[maxZoom + 1] = this._createTree(data);\n\n if (log) console.timeEnd(timerId);\n\n // cluster points on max zoom, then cluster the results on previous zoom, etc.;\n // results in a cluster hierarchy across zoom levels\n for (let z = maxZoom; z >= minZoom; z--) {\n const now = +Date.now();\n\n // create a new set of clusters for the zoom and index them with a KD-tree\n tree = this.trees[z] = this._createTree(this._cluster(tree, z));\n\n if (log) console.log('z%d: %d clusters in %dms', z, tree.numItems, +Date.now() - now);\n }\n\n if (log) console.timeEnd('total time');\n\n return this;\n }\n\n getClusters(bbox, zoom) {\n let minLng = ((bbox[0] + 180) % 360 + 360) % 360 - 180;\n const minLat = Math.max(-90, Math.min(90, bbox[1]));\n let maxLng = bbox[2] === 180 ? 180 : ((bbox[2] + 180) % 360 + 360) % 360 - 180;\n const maxLat = Math.max(-90, Math.min(90, bbox[3]));\n\n if (bbox[2] - bbox[0] >= 360) {\n minLng = -180;\n maxLng = 180;\n } else if (minLng > maxLng) {\n const easternHem = this.getClusters([minLng, minLat, 180, maxLat], zoom);\n const westernHem = this.getClusters([-180, minLat, maxLng, maxLat], zoom);\n return easternHem.concat(westernHem);\n }\n\n const tree = this.trees[this._limitZoom(zoom)];\n const ids = tree.range(lngX(minLng), latY(maxLat), lngX(maxLng), latY(minLat));\n const data = tree.data;\n const clusters = [];\n for (const id of ids) {\n const k = this.stride * id;\n clusters.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]);\n }\n return clusters;\n }\n\n getChildren(clusterId) {\n const originId = this._getOriginId(clusterId);\n const originZoom = this._getOriginZoom(clusterId);\n const errorMsg = 'No cluster with the specified id.';\n\n const tree = this.trees[originZoom];\n if (!tree) throw new Error(errorMsg);\n\n const data = tree.data;\n if (originId * this.stride >= data.length) throw new Error(errorMsg);\n\n const r = this.options.radius / (this.options.extent * Math.pow(2, originZoom - 1));\n const x = data[originId * this.stride];\n const y = data[originId * this.stride + 1];\n const ids = tree.within(x, y, r);\n const children = [];\n for (const id of ids) {\n const k = id * this.stride;\n if (data[k + OFFSET_PARENT] === clusterId) {\n children.push(data[k + OFFSET_NUM] > 1 ? getClusterJSON(data, k, this.clusterProps) : this.points[data[k + OFFSET_ID]]);\n }\n }\n\n if (children.length === 0) throw new Error(errorMsg);\n\n return children;\n }\n\n getLeaves(clusterId, limit, offset) {\n limit = limit || 10;\n offset = offset || 0;\n\n const leaves = [];\n this._appendLeaves(leaves, clusterId, limit, offset, 0);\n\n return leaves;\n }\n\n getTile(z, x, y) {\n const tree = this.trees[this._limitZoom(z)];\n const z2 = Math.pow(2, z);\n const {extent, radius} = this.options;\n const p = radius / extent;\n const top = (y - p) / z2;\n const bottom = (y + 1 + p) / z2;\n\n const tile = {\n features: []\n };\n\n this._addTileFeatures(\n tree.range((x - p) / z2, top, (x + 1 + p) / z2, bottom),\n tree.data, x, y, z2, tile);\n\n if (x === 0) {\n this._addTileFeatures(\n tree.range(1 - p / z2, top, 1, bottom),\n tree.data, z2, y, z2, tile);\n }\n if (x === z2 - 1) {\n this._addTileFeatures(\n tree.range(0, top, p / z2, bottom),\n tree.data, -1, y, z2, tile);\n }\n\n return tile.features.length ? tile : null;\n }\n\n getClusterExpansionZoom(clusterId) {\n let expansionZoom = this._getOriginZoom(clusterId) - 1;\n while (expansionZoom <= this.options.maxZoom) {\n const children = this.getChildren(clusterId);\n expansionZoom++;\n if (children.length !== 1) break;\n clusterId = children[0].properties.cluster_id;\n }\n return expansionZoom;\n }\n\n _appendLeaves(result, clusterId, limit, offset, skipped) {\n const children = this.getChildren(clusterId);\n\n for (const child of children) {\n const props = child.properties;\n\n if (props && props.cluster) {\n if (skipped + props.point_count <= offset) {\n // skip the whole cluster\n skipped += props.point_count;\n } else {\n // enter the cluster\n skipped = this._appendLeaves(result, props.cluster_id, limit, offset, skipped);\n // exit the cluster\n }\n } else if (skipped < offset) {\n // skip a single point\n skipped++;\n } else {\n // add a single point\n result.push(child);\n }\n if (result.length === limit) break;\n }\n\n return skipped;\n }\n\n _createTree(data) {\n const tree = new KDBush(data.length / this.stride | 0, this.options.nodeSize, Float32Array);\n for (let i = 0; i < data.length; i += this.stride) tree.add(data[i], data[i + 1]);\n tree.finish();\n tree.data = data;\n return tree;\n }\n\n _addTileFeatures(ids, data, x, y, z2, tile) {\n for (const i of ids) {\n const k = i * this.stride;\n const isCluster = data[k + OFFSET_NUM] > 1;\n\n let tags, px, py;\n if (isCluster) {\n tags = getClusterProperties(data, k, this.clusterProps);\n px = data[k];\n py = data[k + 1];\n } else {\n const p = this.points[data[k + OFFSET_ID]];\n tags = p.properties;\n const [lng, lat] = p.geometry.coordinates;\n px = lngX(lng);\n py = latY(lat);\n }\n\n const f = {\n type: 1,\n geometry: [[\n Math.round(this.options.extent * (px * z2 - x)),\n Math.round(this.options.extent * (py * z2 - y))\n ]],\n tags\n };\n\n // assign id\n let id;\n if (isCluster || this.options.generateId) {\n // optionally generate id for points\n id = data[k + OFFSET_ID];\n } else {\n // keep id if already assigned\n id = this.points[data[k + OFFSET_ID]].id;\n }\n\n if (id !== undefined) f.id = id;\n\n tile.features.push(f);\n }\n }\n\n _limitZoom(z) {\n return Math.max(this.options.minZoom, Math.min(Math.floor(+z), this.options.maxZoom + 1));\n }\n\n _cluster(tree, zoom) {\n const {radius, extent, reduce, minPoints} = this.options;\n const r = radius / (extent * Math.pow(2, zoom));\n const data = tree.data;\n const nextData = [];\n const stride = this.stride;\n\n // loop through each point\n for (let i = 0; i < data.length; i += stride) {\n // if we've already visited the point at this zoom level, skip it\n if (data[i + OFFSET_ZOOM] <= zoom) continue;\n data[i + OFFSET_ZOOM] = zoom;\n\n // find all nearby points\n const x = data[i];\n const y = data[i + 1];\n const neighborIds = tree.within(data[i], data[i + 1], r);\n\n const numPointsOrigin = data[i + OFFSET_NUM];\n let numPoints = numPointsOrigin;\n\n // count the number of points in a potential cluster\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n // filter out neighbors that are already processed\n if (data[k + OFFSET_ZOOM] > zoom) numPoints += data[k + OFFSET_NUM];\n }\n\n // if there were neighbors to merge, and there are enough points to form a cluster\n if (numPoints > numPointsOrigin && numPoints >= minPoints) {\n let wx = x * numPointsOrigin;\n let wy = y * numPointsOrigin;\n\n let clusterProperties;\n let clusterPropIndex = -1;\n\n // encode both zoom and point index on which the cluster originated -- offset by total length of features\n const id = ((i / stride | 0) << 5) + (zoom + 1) + this.points.length;\n\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n\n if (data[k + OFFSET_ZOOM] <= zoom) continue;\n data[k + OFFSET_ZOOM] = zoom; // save the zoom (so it doesn't get processed twice)\n\n const numPoints2 = data[k + OFFSET_NUM];\n wx += data[k] * numPoints2; // accumulate coordinates for calculating weighted center\n wy += data[k + 1] * numPoints2;\n\n data[k + OFFSET_PARENT] = id;\n\n if (reduce) {\n if (!clusterProperties) {\n clusterProperties = this._map(data, i, true);\n clusterPropIndex = this.clusterProps.length;\n this.clusterProps.push(clusterProperties);\n }\n reduce(clusterProperties, this._map(data, k));\n }\n }\n\n data[i + OFFSET_PARENT] = id;\n nextData.push(wx / numPoints, wy / numPoints, Infinity, id, -1, numPoints);\n if (reduce) nextData.push(clusterPropIndex);\n\n } else { // left points as unclustered\n for (let j = 0; j < stride; j++) nextData.push(data[i + j]);\n\n if (numPoints > 1) {\n for (const neighborId of neighborIds) {\n const k = neighborId * stride;\n if (data[k + OFFSET_ZOOM] <= zoom) continue;\n data[k + OFFSET_ZOOM] = zoom;\n for (let j = 0; j < stride; j++) nextData.push(data[k + j]);\n }\n }\n }\n }\n\n return nextData;\n }\n\n // get index of the point from which the cluster originated\n _getOriginId(clusterId) {\n return (clusterId - this.points.length) >> 5;\n }\n\n // get zoom of the point from which the cluster originated\n _getOriginZoom(clusterId) {\n return (clusterId - this.points.length) % 32;\n }\n\n _map(data, i, clone) {\n if (data[i + OFFSET_NUM] > 1) {\n const props = this.clusterProps[data[i + OFFSET_PROP]];\n return clone ? Object.assign({}, props) : props;\n }\n const original = this.points[data[i + OFFSET_ID]].properties;\n const result = this.options.map(original);\n return clone && result === original ? Object.assign({}, result) : result;\n }\n}\n\nfunction getClusterJSON(data, i, clusterProps) {\n return {\n type: 'Feature',\n id: data[i + OFFSET_ID],\n properties: getClusterProperties(data, i, clusterProps),\n geometry: {\n type: 'Point',\n coordinates: [xLng(data[i]), yLat(data[i + 1])]\n }\n };\n}\n\nfunction getClusterProperties(data, i, clusterProps) {\n const count = data[i + OFFSET_NUM];\n const abbrev =\n count >= 10000 ? `${Math.round(count / 1000) }k` :\n count >= 1000 ? `${Math.round(count / 100) / 10 }k` : count;\n const propIndex = data[i + OFFSET_PROP];\n const properties = propIndex === -1 ? {} : Object.assign({}, clusterProps[propIndex]);\n return Object.assign(properties, {\n cluster: true,\n cluster_id: data[i + OFFSET_ID],\n point_count: count,\n point_count_abbreviated: abbrev\n });\n}\n\n// longitude/latitude to spherical mercator in [0..1] range\nfunction lngX(lng) {\n return lng / 360 + 0.5;\n}\nfunction latY(lat) {\n const sin = Math.sin(lat * Math.PI / 180);\n const y = (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI);\n return y < 0 ? 0 : y > 1 ? 1 : y;\n}\n\n// spherical mercator to longitude/latitude\nfunction xLng(x) {\n return (x - 0.5) * 360;\n}\nfunction yLat(y) {\n const y2 = (180 - y * 360) * Math.PI / 180;\n return 360 * Math.atan(Math.exp(y2)) / Math.PI - 90;\n}\n","import equal from 'fast-deep-equal';\nimport SuperCluster from 'supercluster';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n\r\nfunction __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\n\n/**\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * util class that creates a common set of convenience functions to wrap\n * shared behavior of Advanced Markers and Markers.\n */\nclass MarkerUtils {\n static isAdvancedMarkerAvailable(map) {\n return (google.maps.marker &&\n map.getMapCapabilities().isAdvancedMarkersAvailable === true);\n }\n static isAdvancedMarker(marker) {\n return (google.maps.marker &&\n marker instanceof google.maps.marker.AdvancedMarkerElement);\n }\n static setMap(marker, map) {\n if (this.isAdvancedMarker(marker)) {\n marker.map = map;\n }\n else {\n marker.setMap(map);\n }\n }\n static getPosition(marker) {\n // SuperClusterAlgorithm.calculate expects a LatLng instance so we fake it for Adv Markers\n if (this.isAdvancedMarker(marker)) {\n if (marker.position) {\n if (marker.position instanceof google.maps.LatLng) {\n return marker.position;\n }\n // since we can't cast to LatLngLiteral for reasons =(\n if (marker.position.lat && marker.position.lng) {\n return new google.maps.LatLng(marker.position.lat, marker.position.lng);\n }\n }\n return new google.maps.LatLng(null);\n }\n return marker.getPosition();\n }\n static getVisible(marker) {\n if (this.isAdvancedMarker(marker)) {\n /**\n * Always return true for Advanced Markers because the clusterer\n * uses getVisible as a way to count legacy markers not as an actual\n * indicator of visibility for some reason. Even when markers are hidden\n * Marker.getVisible returns `true` and this is used to set the marker count\n * on the cluster. See the behavior of Cluster.count\n */\n return true;\n }\n return marker.getVisible();\n }\n}\n\n/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nclass Cluster {\n constructor({ markers, position }) {\n this.markers = markers;\n if (position) {\n if (position instanceof google.maps.LatLng) {\n this._position = position;\n }\n else {\n this._position = new google.maps.LatLng(position);\n }\n }\n }\n get bounds() {\n if (this.markers.length === 0 && !this._position) {\n return;\n }\n const bounds = new google.maps.LatLngBounds(this._position, this._position);\n for (const marker of this.markers) {\n bounds.extend(MarkerUtils.getPosition(marker));\n }\n return bounds;\n }\n get position() {\n return this._position || this.bounds.getCenter();\n }\n /**\n * Get the count of **visible** markers.\n */\n get count() {\n return this.markers.filter((m) => MarkerUtils.getVisible(m)).length;\n }\n /**\n * Add a marker to the cluster.\n */\n push(marker) {\n this.markers.push(marker);\n }\n /**\n * Cleanup references and remove marker from map.\n */\n delete() {\n if (this.marker) {\n MarkerUtils.setMap(this.marker, null);\n this.marker = undefined;\n }\n this.markers.length = 0;\n }\n}\n\n/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Returns the markers visible in a padded map viewport\n *\n * @param map\n * @param mapCanvasProjection\n * @param markers The list of marker to filter\n * @param viewportPaddingPixels The padding in pixel\n * @returns The list of markers in the padded viewport\n */\nconst filterMarkersToPaddedViewport = (map, mapCanvasProjection, markers, viewportPaddingPixels) => {\n const extendedMapBounds = extendBoundsToPaddedViewport(map.getBounds(), mapCanvasProjection, viewportPaddingPixels);\n return markers.filter((marker) => extendedMapBounds.contains(MarkerUtils.getPosition(marker)));\n};\n/**\n * Extends a bounds by a number of pixels in each direction\n */\nconst extendBoundsToPaddedViewport = (bounds, projection, numPixels) => {\n const { northEast, southWest } = latLngBoundsToPixelBounds(bounds, projection);\n const extendedPixelBounds = extendPixelBounds({ northEast, southWest }, numPixels);\n return pixelBoundsToLatLngBounds(extendedPixelBounds, projection);\n};\n/**\n * Gets the extended bounds as a bbox [westLng, southLat, eastLng, northLat]\n */\nconst getPaddedViewport = (bounds, projection, pixels) => {\n const extended = extendBoundsToPaddedViewport(bounds, projection, pixels);\n const ne = extended.getNorthEast();\n const sw = extended.getSouthWest();\n return [sw.lng(), sw.lat(), ne.lng(), ne.lat()];\n};\n/**\n * Returns the distance between 2 positions.\n *\n * @hidden\n */\nconst distanceBetweenPoints = (p1, p2) => {\n const R = 6371; // Radius of the Earth in km\n const dLat = ((p2.lat - p1.lat) * Math.PI) / 180;\n const dLon = ((p2.lng - p1.lng) * Math.PI) / 180;\n const sinDLat = Math.sin(dLat / 2);\n const sinDLon = Math.sin(dLon / 2);\n const a = sinDLat * sinDLat +\n Math.cos((p1.lat * Math.PI) / 180) *\n Math.cos((p2.lat * Math.PI) / 180) *\n sinDLon *\n sinDLon;\n const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n return R * c;\n};\n/**\n * Converts a LatLng bound to pixels.\n *\n * @hidden\n */\nconst latLngBoundsToPixelBounds = (bounds, projection) => {\n return {\n northEast: projection.fromLatLngToDivPixel(bounds.getNorthEast()),\n southWest: projection.fromLatLngToDivPixel(bounds.getSouthWest()),\n };\n};\n/**\n * Extends a pixel bounds by numPixels in all directions.\n *\n * @hidden\n */\nconst extendPixelBounds = ({ northEast, southWest }, numPixels) => {\n northEast.x += numPixels;\n northEast.y -= numPixels;\n southWest.x -= numPixels;\n southWest.y += numPixels;\n return { northEast, southWest };\n};\n/**\n * @hidden\n */\nconst pixelBoundsToLatLngBounds = ({ northEast, southWest }, projection) => {\n const sw = projection.fromDivPixelToLatLng(southWest);\n const ne = projection.fromDivPixelToLatLng(northEast);\n return new google.maps.LatLngBounds(sw, ne);\n};\n\n/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @hidden\n */\nclass AbstractAlgorithm {\n constructor({ maxZoom = 16 }) {\n this.maxZoom = maxZoom;\n }\n /**\n * Helper function to bypass clustering based upon some map state such as\n * zoom, number of markers, etc.\n *\n * ```typescript\n * cluster({markers, map}: AlgorithmInput): Cluster[] {\n * if (shouldBypassClustering(map)) {\n * return this.noop({markers})\n * }\n * }\n * ```\n */\n noop({ markers, }) {\n return noop(markers);\n }\n}\n/**\n * Abstract viewport algorithm proves a class to filter markers by a padded\n * viewport. This is a common optimization.\n *\n * @hidden\n */\nclass AbstractViewportAlgorithm extends AbstractAlgorithm {\n constructor(_a) {\n var { viewportPadding = 60 } = _a, options = __rest(_a, [\"viewportPadding\"]);\n super(options);\n this.viewportPadding = 60;\n this.viewportPadding = viewportPadding;\n }\n calculate({ markers, map, mapCanvasProjection, }) {\n if (map.getZoom() >= this.maxZoom) {\n return {\n clusters: this.noop({\n markers,\n }),\n changed: false,\n };\n }\n return {\n clusters: this.cluster({\n markers: filterMarkersToPaddedViewport(map, mapCanvasProjection, markers, this.viewportPadding),\n map,\n mapCanvasProjection,\n }),\n };\n }\n}\n/**\n * @hidden\n */\nconst noop = (markers) => {\n const clusters = markers.map((marker) => new Cluster({\n position: MarkerUtils.getPosition(marker),\n markers: [marker],\n }));\n return clusters;\n};\n\n/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * The default Grid algorithm historically used in Google Maps marker\n * clustering.\n *\n * The Grid algorithm does not implement caching and markers may flash as the\n * viewport changes. Instead use {@link SuperClusterAlgorithm}.\n */\nclass GridAlgorithm extends AbstractViewportAlgorithm {\n constructor(_a) {\n var { maxDistance = 40000, gridSize = 40 } = _a, options = __rest(_a, [\"maxDistance\", \"gridSize\"]);\n super(options);\n this.clusters = [];\n this.state = { zoom: -1 };\n this.maxDistance = maxDistance;\n this.gridSize = gridSize;\n }\n calculate({ markers, map, mapCanvasProjection, }) {\n const state = { zoom: map.getZoom() };\n let changed = false;\n if (this.state.zoom >= this.maxZoom && state.zoom >= this.maxZoom) ;\n else {\n changed = !equal(this.state, state);\n }\n this.state = state;\n if (map.getZoom() >= this.maxZoom) {\n return {\n clusters: this.noop({\n markers,\n }),\n changed,\n };\n }\n return {\n clusters: this.cluster({\n markers: filterMarkersToPaddedViewport(map, mapCanvasProjection, markers, this.viewportPadding),\n map,\n mapCanvasProjection,\n }),\n };\n }\n cluster({ markers, map, mapCanvasProjection, }) {\n this.clusters = [];\n markers.forEach((marker) => {\n this.addToClosestCluster(marker, map, mapCanvasProjection);\n });\n return this.clusters;\n }\n addToClosestCluster(marker, map, projection) {\n let maxDistance = this.maxDistance; // Some large number\n let cluster = null;\n for (let i = 0; i < this.clusters.length; i++) {\n const candidate = this.clusters[i];\n const distance = distanceBetweenPoints(candidate.bounds.getCenter().toJSON(), MarkerUtils.getPosition(marker).toJSON());\n if (distance < maxDistance) {\n maxDistance = distance;\n cluster = candidate;\n }\n }\n if (cluster &&\n extendBoundsToPaddedViewport(cluster.bounds, projection, this.gridSize).contains(MarkerUtils.getPosition(marker))) {\n cluster.push(marker);\n }\n else {\n const cluster = new Cluster({ markers: [marker] });\n this.clusters.push(cluster);\n }\n }\n}\n\n/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Noop algorithm does not generate any clusters or filter markers by the an extended viewport.\n */\nclass NoopAlgorithm extends AbstractAlgorithm {\n constructor(_a) {\n var options = __rest(_a, []);\n super(options);\n }\n calculate({ markers, map, mapCanvasProjection, }) {\n return {\n clusters: this.cluster({ markers, map, mapCanvasProjection }),\n changed: false,\n };\n }\n cluster(input) {\n return this.noop(input);\n }\n}\n\n/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * A very fast JavaScript algorithm for geospatial point clustering using KD trees.\n *\n * @see https://www.npmjs.com/package/supercluster for more information on options.\n */\nclass SuperClusterAlgorithm extends AbstractAlgorithm {\n constructor(_a) {\n var { maxZoom, radius = 60 } = _a, options = __rest(_a, [\"maxZoom\", \"radius\"]);\n super({ maxZoom });\n this.state = { zoom: -1 };\n this.superCluster = new SuperCluster(Object.assign({ maxZoom: this.maxZoom, radius }, options));\n }\n calculate(input) {\n let changed = false;\n const state = { zoom: input.map.getZoom() };\n if (!equal(input.markers, this.markers)) {\n changed = true;\n // TODO use proxy to avoid copy?\n this.markers = [...input.markers];\n const points = this.markers.map((marker) => {\n const position = MarkerUtils.getPosition(marker);\n const coordinates = [position.lng(), position.lat()];\n return {\n type: \"Feature\",\n geometry: {\n type: \"Point\",\n coordinates,\n },\n properties: { marker },\n };\n });\n this.superCluster.load(points);\n }\n if (!changed) {\n if (this.state.zoom <= this.maxZoom || state.zoom <= this.maxZoom) {\n changed = !equal(this.state, state);\n }\n }\n this.state = state;\n if (changed) {\n this.clusters = this.cluster(input);\n }\n return { clusters: this.clusters, changed };\n }\n cluster({ map }) {\n return this.superCluster\n .getClusters([-180, -90, 180, 90], Math.round(map.getZoom()))\n .map((feature) => this.transformCluster(feature));\n }\n transformCluster({ geometry: { coordinates: [lng, lat], }, properties, }) {\n if (properties.cluster) {\n return new Cluster({\n markers: this.superCluster\n .getLeaves(properties.cluster_id, Infinity)\n .map((leaf) => leaf.properties.marker),\n position: { lat, lng },\n });\n }\n const marker = properties.marker;\n return new Cluster({\n markers: [marker],\n position: MarkerUtils.getPosition(marker),\n });\n }\n}\n\n/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * A very fast JavaScript algorithm for geospatial point clustering using KD trees.\n *\n * @see https://www.npmjs.com/package/supercluster for more information on options.\n */\nclass SuperClusterViewportAlgorithm extends AbstractViewportAlgorithm {\n constructor(_a) {\n var { maxZoom, radius = 60, viewportPadding = 60 } = _a, options = __rest(_a, [\"maxZoom\", \"radius\", \"viewportPadding\"]);\n super({ maxZoom, viewportPadding });\n this.superCluster = new SuperCluster(Object.assign({ maxZoom: this.maxZoom, radius }, options));\n this.state = { zoom: -1, view: [0, 0, 0, 0] };\n }\n calculate(input) {\n const state = {\n zoom: Math.round(input.map.getZoom()),\n view: getPaddedViewport(input.map.getBounds(), input.mapCanvasProjection, this.viewportPadding),\n };\n let changed = !equal(this.state, state);\n if (!equal(input.markers, this.markers)) {\n changed = true;\n // TODO use proxy to avoid copy?\n this.markers = [...input.markers];\n const points = this.markers.map((marker) => {\n const position = MarkerUtils.getPosition(marker);\n const coordinates = [position.lng(), position.lat()];\n return {\n type: \"Feature\",\n geometry: {\n type: \"Point\",\n coordinates,\n },\n properties: { marker },\n };\n });\n this.superCluster.load(points);\n }\n if (changed) {\n this.clusters = this.cluster(input);\n this.state = state;\n }\n return { clusters: this.clusters, changed };\n }\n cluster({ map, mapCanvasProjection }) {\n /* recalculate new state because we can't use the cached version. */\n const state = {\n zoom: Math.round(map.getZoom()),\n view: getPaddedViewport(map.getBounds(), mapCanvasProjection, this.viewportPadding),\n };\n return this.superCluster\n .getClusters(state.view, state.zoom)\n .map((feature) => this.transformCluster(feature));\n }\n transformCluster({ geometry: { coordinates: [lng, lat], }, properties, }) {\n if (properties.cluster) {\n return new Cluster({\n markers: this.superCluster\n .getLeaves(properties.cluster_id, Infinity)\n .map((leaf) => leaf.properties.marker),\n position: { lat, lng },\n });\n }\n const marker = properties.marker;\n return new Cluster({\n markers: [marker],\n position: MarkerUtils.getPosition(marker),\n });\n }\n}\n\n/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Provides statistics on all clusters in the current render cycle for use in {@link Renderer.render}.\n */\nclass ClusterStats {\n constructor(markers, clusters) {\n this.markers = { sum: markers.length };\n const clusterMarkerCounts = clusters.map((a) => a.count);\n const clusterMarkerSum = clusterMarkerCounts.reduce((a, b) => a + b, 0);\n this.clusters = {\n count: clusters.length,\n markers: {\n mean: clusterMarkerSum / clusters.length,\n sum: clusterMarkerSum,\n min: Math.min(...clusterMarkerCounts),\n max: Math.max(...clusterMarkerCounts),\n },\n };\n }\n}\nclass DefaultRenderer {\n /**\n * The default render function for the library used by {@link MarkerClusterer}.\n *\n * Currently set to use the following:\n *\n * ```typescript\n * // change color if this cluster has more markers than the mean cluster\n * const color =\n * count > Math.max(10, stats.clusters.markers.mean)\n * ? \"#ff0000\"\n * : \"#0000ff\";\n *\n * // create svg url with fill color\n * const svg = window.btoa(`\n * `);\n *\n * // create marker using svg icon\n * return new google.maps.Marker({\n * position,\n * icon: {\n * url: `data:image/svg+xml;base64,${svg}`,\n * scaledSize: new google.maps.Size(45, 45),\n * },\n * label: {\n * text: String(count),\n * color: \"rgba(255,255,255,0.9)\",\n * fontSize: \"12px\",\n * },\n * // adjust zIndex to be above other markers\n * zIndex: 1000 + count,\n * });\n * ```\n */\n render({ count, position }, stats, map) {\n // change color if this cluster has more markers than the mean cluster\n const color = count > Math.max(10, stats.clusters.markers.mean) ? \"#ff0000\" : \"#0000ff\";\n // create svg literal with fill color\n const svg = ``;\n const title = `Cluster of ${count} markers`, \n // adjust zIndex to be above other markers\n zIndex = Number(google.maps.Marker.MAX_ZINDEX) + count;\n if (MarkerUtils.isAdvancedMarkerAvailable(map)) {\n // create cluster SVG element\n const parser = new DOMParser();\n const svgEl = parser.parseFromString(svg, \"image/svg+xml\").documentElement;\n svgEl.setAttribute(\"transform\", \"translate(0 25)\");\n const clusterOptions = {\n map,\n position,\n zIndex,\n title,\n content: svgEl,\n };\n return new google.maps.marker.AdvancedMarkerElement(clusterOptions);\n }\n const clusterOptions = {\n position,\n zIndex,\n title,\n icon: {\n url: `data:image/svg+xml;base64,${btoa(svg)}`,\n anchor: new google.maps.Point(25, 25),\n },\n };\n return new google.maps.Marker(clusterOptions);\n }\n}\n\n/**\n * Copyright 2019 Google LLC. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Extends an object's prototype by another's.\n *\n * @param type1 The Type to be extended.\n * @param type2 The Type to extend with.\n * @ignore\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction extend(type1, type2) {\n /* istanbul ignore next */\n // eslint-disable-next-line prefer-const\n for (let property in type2.prototype) {\n type1.prototype[property] = type2.prototype[property];\n }\n}\n/**\n * @ignore\n */\nclass OverlayViewSafe {\n constructor() {\n // MarkerClusterer implements google.maps.OverlayView interface. We use the\n // extend function to extend MarkerClusterer with google.maps.OverlayView\n // because it might not always be available when the code is defined so we\n // look for it at the last possible moment. If it doesn't exist now then\n // there is no point going ahead :)\n extend(OverlayViewSafe, google.maps.OverlayView);\n }\n}\n\n/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nvar MarkerClustererEvents;\n(function (MarkerClustererEvents) {\n MarkerClustererEvents[\"CLUSTERING_BEGIN\"] = \"clusteringbegin\";\n MarkerClustererEvents[\"CLUSTERING_END\"] = \"clusteringend\";\n MarkerClustererEvents[\"CLUSTER_CLICK\"] = \"click\";\n})(MarkerClustererEvents || (MarkerClustererEvents = {}));\nconst defaultOnClusterClickHandler = (_, cluster, map) => {\n map.fitBounds(cluster.bounds);\n};\n/**\n * MarkerClusterer creates and manages per-zoom-level clusters for large amounts\n * of markers. See {@link MarkerClustererOptions} for more details.\n *\n */\nclass MarkerClusterer extends OverlayViewSafe {\n constructor({ map, markers = [], algorithmOptions = {}, algorithm = new SuperClusterAlgorithm(algorithmOptions), renderer = new DefaultRenderer(), onClusterClick = defaultOnClusterClickHandler, }) {\n super();\n this.markers = [...markers];\n this.clusters = [];\n this.algorithm = algorithm;\n this.renderer = renderer;\n this.onClusterClick = onClusterClick;\n if (map) {\n this.setMap(map);\n }\n }\n addMarker(marker, noDraw) {\n if (this.markers.includes(marker)) {\n return;\n }\n this.markers.push(marker);\n if (!noDraw) {\n this.render();\n }\n }\n addMarkers(markers, noDraw) {\n markers.forEach((marker) => {\n this.addMarker(marker, true);\n });\n if (!noDraw) {\n this.render();\n }\n }\n removeMarker(marker, noDraw) {\n const index = this.markers.indexOf(marker);\n if (index === -1) {\n // Marker is not in our list of markers, so do nothing:\n return false;\n }\n MarkerUtils.setMap(marker, null);\n this.markers.splice(index, 1); // Remove the marker from the list of managed markers\n if (!noDraw) {\n this.render();\n }\n return true;\n }\n removeMarkers(markers, noDraw) {\n let removed = false;\n markers.forEach((marker) => {\n removed = this.removeMarker(marker, true) || removed;\n });\n if (removed && !noDraw) {\n this.render();\n }\n return removed;\n }\n clearMarkers(noDraw) {\n this.markers.length = 0;\n if (!noDraw) {\n this.render();\n }\n }\n /**\n * Recalculates and draws all the marker clusters.\n */\n render() {\n const map = this.getMap();\n if (map instanceof google.maps.Map && map.getProjection()) {\n google.maps.event.trigger(this, MarkerClustererEvents.CLUSTERING_BEGIN, this);\n const { clusters, changed } = this.algorithm.calculate({\n markers: this.markers,\n map,\n mapCanvasProjection: this.getProjection(),\n });\n // Allow algorithms to return flag on whether the clusters/markers have changed.\n if (changed || changed == undefined) {\n // Accumulate the markers of the clusters composed of a single marker.\n // Those clusters directly use the marker.\n // Clusters with more than one markers use a group marker generated by a renderer.\n const singleMarker = new Set();\n for (const cluster of clusters) {\n if (cluster.markers.length == 1) {\n singleMarker.add(cluster.markers[0]);\n }\n }\n const groupMarkers = [];\n // Iterate the clusters that are currently rendered.\n for (const cluster of this.clusters) {\n if (cluster.marker == null) {\n continue;\n }\n if (cluster.markers.length == 1) {\n if (!singleMarker.has(cluster.marker)) {\n // The marker:\n // - was previously rendered because it is from a cluster with 1 marker,\n // - should no more be rendered as it is not in singleMarker.\n MarkerUtils.setMap(cluster.marker, null);\n }\n }\n else {\n // Delay the removal of old group markers to avoid flickering.\n groupMarkers.push(cluster.marker);\n }\n }\n this.clusters = clusters;\n this.renderClusters();\n // Delayed removal of the markers of the former groups.\n requestAnimationFrame(() => groupMarkers.forEach((marker) => MarkerUtils.setMap(marker, null)));\n }\n google.maps.event.trigger(this, MarkerClustererEvents.CLUSTERING_END, this);\n }\n }\n onAdd() {\n this.idleListener = this.getMap().addListener(\"idle\", this.render.bind(this));\n this.render();\n }\n onRemove() {\n google.maps.event.removeListener(this.idleListener);\n this.reset();\n }\n reset() {\n this.markers.forEach((marker) => MarkerUtils.setMap(marker, null));\n this.clusters.forEach((cluster) => cluster.delete());\n this.clusters = [];\n }\n renderClusters() {\n // Generate stats to pass to renderers.\n const stats = new ClusterStats(this.markers, this.clusters);\n const map = this.getMap();\n this.clusters.forEach((cluster) => {\n if (cluster.markers.length === 1) {\n cluster.marker = cluster.markers[0];\n }\n else {\n // Generate the marker to represent the group.\n cluster.marker = this.renderer.render(cluster, stats, map);\n // Make sure all individual markers are removed from the map.\n cluster.markers.forEach((marker) => MarkerUtils.setMap(marker, null));\n if (this.onClusterClick) {\n cluster.marker.addListener(\"click\", \n /* istanbul ignore next */\n (event) => {\n google.maps.event.trigger(this, MarkerClustererEvents.CLUSTER_CLICK, cluster);\n this.onClusterClick(event, cluster, map);\n });\n }\n }\n MarkerUtils.setMap(cluster.marker, map);\n });\n }\n}\n\nexport { AbstractAlgorithm, AbstractViewportAlgorithm, Cluster, ClusterStats, DefaultRenderer, GridAlgorithm, MarkerClusterer, MarkerClustererEvents, MarkerUtils, NoopAlgorithm, SuperClusterAlgorithm, SuperClusterViewportAlgorithm, defaultOnClusterClickHandler, distanceBetweenPoints, extendBoundsToPaddedViewport, extendPixelBounds, filterMarkersToPaddedViewport, getPaddedViewport, noop, pixelBoundsToLatLngBounds };\n//# sourceMappingURL=index.esm.js.map\n","import { useState, useEffect, memo, type ReactElement } from 'react'\nimport {\n MarkerClusterer,\n type MarkerClustererOptions,\n} from '@googlemaps/markerclusterer'\n\nimport { useGoogleMap } from '../../map-context.js'\n\nexport type MarkerClustererOptionsSubset = Omit<\n MarkerClustererOptions,\n 'map' | 'markers'\n>\n\nexport type GoogleMarkerClustererProps = {\n /** Render prop that exposes marker clusterer to children components\n *\n * The callback function should return a list of Marker components.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n children: (markerClusterer: MarkerClusterer) => ReactElement\n /** Subset of {@link MarkerClustererOptions} options\n *\n * ```\n * {\n * algorithm?: Algorithm;\n * renderer?: Renderer;\n * onClusterClick?: onClusterClickHandler;\n * }\n * ```\n */\n options: MarkerClustererOptionsSubset\n}\n\nexport function useGoogleMarkerClusterer(\n options: MarkerClustererOptionsSubset\n): MarkerClusterer | null {\n const map = useGoogleMap()\n\n const [markerClusterer, setMarkerClusterer] =\n useState(null)\n\n useEffect(() => {\n if (map && markerClusterer === null) {\n const markerCluster = new MarkerClusterer({ ...options, map })\n\n setMarkerClusterer(markerCluster)\n }\n }, [map])\n\n return markerClusterer\n}\n\n/** Wrapper around [@googlemaps/markerclusterer](https://github.com/googlemaps/js-markerclusterer)\n *\n * Accepts {@link MarkerClustererOptionsSubset} which is a subset of {@link MarkerClustererOptions}\n */\nfunction GoogleMarkerClusterer({\n children,\n options,\n}: GoogleMarkerClustererProps) {\n const markerClusterer = useGoogleMarkerClusterer(options)\n\n return markerClusterer !== null ? children(markerClusterer) : null\n}\n\nexport default memo(GoogleMarkerClusterer)\n","/* global google */\nimport {\n memo,\n useRef,\n Children,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ReactNode,\n type ReactPortal,\n type ContextType,\n} from 'react'\nimport invariant from 'invariant'\nimport { createPortal } from 'react-dom'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onCloseClick: 'closeclick',\n onContentChanged: 'content_changed',\n onDomReady: 'domready',\n onPositionChanged: 'position_changed',\n onZindexChanged: 'zindex_changed',\n}\n\nconst updaterMap = {\n options(\n instance: google.maps.InfoWindow,\n options: google.maps.InfoWindowOptions\n ): void {\n instance.setOptions(options)\n },\n position(\n instance: google.maps.InfoWindow,\n position: google.maps.LatLng | google.maps.LatLngLiteral\n ): void {\n instance.setPosition(position)\n },\n zIndex(instance: google.maps.InfoWindow, zIndex: number): void {\n instance.setZIndex(zIndex)\n },\n}\n\ntype InfoWindowState = {\n infoWindow: google.maps.InfoWindow | null\n}\n\nexport type InfoWindowProps = {\n children?: ReactNode | undefined\n /** Can be any MVCObject that exposes a LatLng position property and optionally a Point anchorPoint property for calculating the pixelOffset. The anchorPoint is the offset from the anchor's position to the tip of the InfoWindow. */\n anchor?: google.maps.MVCObject | undefined\n options?: google.maps.InfoWindowOptions | undefined\n /** The LatLng at which to display this InfoWindow. If the InfoWindow is opened with an anchor, the anchor's position will be used instead. */\n position?: google.maps.LatLng | google.maps.LatLngLiteral | undefined\n /** All InfoWindows are displayed on the map in order of their zIndex, with higher values displaying in front of InfoWindows with lower values. By default, InfoWindows are displayed according to their latitude, with InfoWindows of lower latitudes appearing in front of InfoWindows at higher latitudes. InfoWindows are always displayed in front of markers. */\n zIndex?: number | undefined\n /** This event is fired when the close button was clicked. */\n onCloseClick?: (() => void) | undefined\n /** This event is fired when the
containing the InfoWindow's content is attached to the DOM. You may wish to monitor this event if you are building out your info window content dynamically. */\n onDomReady?: (() => void) | undefined\n /** This event is fired when the content property changes. */\n onContentChanged?: (() => void) | undefined\n /** This event is fired when the position property changes. */\n onPositionChanged?: (() => void) | undefined\n /** This event is fired when the InfoWindow's zIndex changes. */\n onZindexChanged?: (() => void) | undefined\n /** This callback is called when the infoWindow instance has loaded. It is called with the infoWindow instance. */\n onLoad?: ((infoWindow: google.maps.InfoWindow) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the infoWindow instance. */\n onUnmount?: ((infoWindow: google.maps.InfoWindow) => void) | undefined\n}\n\nfunction InfoWindowFunctional({\n children,\n anchor,\n options,\n position,\n zIndex,\n onCloseClick,\n onDomReady,\n onContentChanged,\n onPositionChanged,\n onZindexChanged,\n onLoad,\n onUnmount,\n}: InfoWindowProps): ReactPortal | null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(null)\n\n const [closeclickListener, setCloseClickListener] =\n useState(null)\n const [domreadyclickListener, setDomReadyClickListener] =\n useState(null)\n const [contentchangedclickListener, setContentChangedClickListener] =\n useState(null)\n const [positionchangedclickListener, setPositionChangedClickListener] =\n useState(null)\n const [zindexchangedclickListener, setZindexChangedClickListener] =\n useState(null)\n\n const containerElementRef = useRef(null)\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.close()\n\n if (anchor) {\n instance.open(map, anchor)\n } else if (instance.getPosition()) {\n instance.open(map)\n }\n }\n }, [map, instance, anchor])\n\n useEffect(() => {\n if (options && instance !== null) {\n instance.setOptions(options)\n }\n }, [instance, options])\n\n useEffect(() => {\n if (position && instance !== null) {\n instance.setPosition(position)\n }\n }, [position])\n\n useEffect(() => {\n if (typeof zIndex === 'number' && instance !== null) {\n instance.setZIndex(zIndex)\n }\n }, [zIndex])\n\n useEffect(() => {\n if (instance && onCloseClick) {\n if (closeclickListener !== null) {\n google.maps.event.removeListener(closeclickListener)\n }\n\n setCloseClickListener(\n google.maps.event.addListener(instance, 'closeclick', onCloseClick)\n )\n }\n }, [onCloseClick])\n\n useEffect(() => {\n if (instance && onDomReady) {\n if (domreadyclickListener !== null) {\n google.maps.event.removeListener(domreadyclickListener)\n }\n\n setDomReadyClickListener(\n google.maps.event.addListener(instance, 'domready', onDomReady)\n )\n }\n }, [onDomReady])\n\n useEffect(() => {\n if (instance && onContentChanged) {\n if (contentchangedclickListener !== null) {\n google.maps.event.removeListener(contentchangedclickListener)\n }\n\n setContentChangedClickListener(\n google.maps.event.addListener(\n instance,\n 'content_changed',\n onContentChanged\n )\n )\n }\n }, [onContentChanged])\n\n useEffect(() => {\n if (instance && onPositionChanged) {\n if (positionchangedclickListener !== null) {\n google.maps.event.removeListener(positionchangedclickListener)\n }\n\n setPositionChangedClickListener(\n google.maps.event.addListener(\n instance,\n 'position_changed',\n onPositionChanged\n )\n )\n }\n }, [onPositionChanged])\n\n useEffect(() => {\n if (instance && onZindexChanged) {\n if (zindexchangedclickListener !== null) {\n google.maps.event.removeListener(zindexchangedclickListener)\n }\n\n setZindexChangedClickListener(\n google.maps.event.addListener(\n instance,\n 'zindex_changed',\n onZindexChanged\n )\n )\n }\n }, [onZindexChanged])\n\n useEffect(() => {\n const infoWindow = new google.maps.InfoWindow(options)\n\n setInstance(infoWindow)\n\n containerElementRef.current = document.createElement('div')\n\n if (onCloseClick) {\n setCloseClickListener(\n google.maps.event.addListener(infoWindow, 'closeclick', onCloseClick)\n )\n }\n\n if (onDomReady) {\n setDomReadyClickListener(\n google.maps.event.addListener(infoWindow, 'domready', onDomReady)\n )\n }\n\n if (onContentChanged) {\n setContentChangedClickListener(\n google.maps.event.addListener(\n infoWindow,\n 'content_changed',\n onContentChanged\n )\n )\n }\n\n if (onPositionChanged) {\n setPositionChangedClickListener(\n google.maps.event.addListener(\n infoWindow,\n 'position_changed',\n onPositionChanged\n )\n )\n }\n\n if (onZindexChanged) {\n setZindexChangedClickListener(\n google.maps.event.addListener(\n infoWindow,\n 'zindex_changed',\n onZindexChanged\n )\n )\n }\n\n infoWindow.setContent(containerElementRef.current)\n\n if (position) {\n infoWindow.setPosition(position)\n }\n\n if (zIndex) {\n infoWindow.setZIndex(zIndex)\n }\n\n if (anchor) {\n infoWindow.open(map, anchor)\n } else if (infoWindow.getPosition()) {\n infoWindow.open(map)\n } else {\n invariant(\n false,\n `You must provide either an anchor (typically render it inside a ) or a position props for .`\n )\n }\n\n if (onLoad) {\n onLoad(infoWindow)\n }\n\n return () => {\n if (closeclickListener) {\n google.maps.event.removeListener(closeclickListener)\n }\n\n if (contentchangedclickListener) {\n google.maps.event.removeListener(contentchangedclickListener)\n }\n\n if (domreadyclickListener) {\n google.maps.event.removeListener(domreadyclickListener)\n }\n\n if (positionchangedclickListener) {\n google.maps.event.removeListener(positionchangedclickListener)\n }\n\n if (zindexchangedclickListener) {\n google.maps.event.removeListener(zindexchangedclickListener)\n }\n\n if (onUnmount) {\n onUnmount(infoWindow)\n }\n\n infoWindow.close()\n }\n }, [])\n\n return containerElementRef.current\n ? createPortal(Children.only(children), containerElementRef.current)\n : null\n}\n\nexport const InfoWindowF = memo(InfoWindowFunctional)\n\nexport class InfoWindow extends PureComponent<\n InfoWindowProps,\n InfoWindowState\n> {\n static override contextType = MapContext\n\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n containerElement: HTMLElement | null = null\n\n override state: InfoWindowState = {\n infoWindow: null,\n }\n\n open = (\n infoWindow: google.maps.InfoWindow,\n anchor?: google.maps.MVCObject | undefined\n ): void => {\n if (anchor) {\n infoWindow.open(this.context, anchor)\n } else if (infoWindow.getPosition()) {\n infoWindow.open(this.context)\n } else {\n invariant(\n false,\n `You must provide either an anchor (typically render it inside a ) or a position props for .`\n )\n }\n }\n\n setInfoWindowCallback = (): void => {\n if (this.state.infoWindow !== null && this.containerElement !== null) {\n this.state.infoWindow.setContent(this.containerElement)\n\n this.open(this.state.infoWindow, this.props.anchor)\n\n if (this.props.onLoad) {\n this.props.onLoad(this.state.infoWindow)\n }\n }\n }\n\n override componentDidMount(): void {\n const infoWindow = new google.maps.InfoWindow(this.props.options)\n\n this.containerElement = document.createElement('div')\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: infoWindow,\n })\n\n this.setState(() => {\n return {\n infoWindow,\n }\n }, this.setInfoWindowCallback)\n }\n\n override componentDidUpdate(prevProps: InfoWindowProps): void {\n if (this.state.infoWindow !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.infoWindow,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.infoWindow !== null) {\n unregisterEvents(this.registeredEvents)\n\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.infoWindow)\n }\n\n this.state.infoWindow.close()\n }\n }\n\n override render(): ReactPortal | null {\n return this.containerElement\n ? createPortal(Children.only(this.props.children), this.containerElement)\n : null\n }\n}\n\nexport default InfoWindow\n","import {\n memo,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onClick: 'click',\n onDblClick: 'dblclick',\n onDrag: 'drag',\n onDragEnd: 'dragend',\n onDragStart: 'dragstart',\n onMouseDown: 'mousedown',\n onMouseMove: 'mousemove',\n onMouseOut: 'mouseout',\n onMouseOver: 'mouseover',\n onMouseUp: 'mouseup',\n onRightClick: 'rightclick',\n}\n\nconst updaterMap = {\n draggable(instance: google.maps.Polyline, draggable: boolean): void {\n instance.setDraggable(draggable)\n },\n editable(instance: google.maps.Polyline, editable: boolean): void {\n instance.setEditable(editable)\n },\n map(instance: google.maps.Polyline, map: google.maps.Map): void {\n instance.setMap(map)\n },\n options(\n instance: google.maps.Polyline,\n options: google.maps.PolylineOptions\n ): void {\n instance.setOptions(options)\n },\n path(\n instance: google.maps.Polyline,\n path:\n | google.maps.MVCArray\n | google.maps.LatLng[]\n | google.maps.LatLngLiteral[]\n ): void {\n instance.setPath(path)\n },\n visible(instance: google.maps.Polyline, visible: boolean): void {\n instance.setVisible(visible)\n },\n}\n\ntype PolylineState = {\n polyline: google.maps.Polyline | null\n}\n\nexport type PolylineProps = {\n options?: google.maps.PolylineOptions | undefined\n /** If set to true, the user can drag this shape over the map. The geodesic property defines the mode of dragging. */\n draggable?: boolean | undefined\n /** If set to true, the user can edit this shape by dragging the control points shown at the vertices and on each segment. */\n editable?: boolean | undefined\n /** Hides this poly if set to false. */\n visible?: boolean | undefined\n /** Sets the path. The ordered sequence of coordinates of the Polyline. This path may be specified using either a simple array of LatLngs, or an MVCArray of LatLngs. Note that if you pass a simple array, it will be converted to an MVCArray Inserting or removing LatLngs in the MVCArray will automatically update the polyline on the map. */\n path?:\n | google.maps.MVCArray\n | google.maps.LatLng[]\n | google.maps.LatLngLiteral[]\n | undefined\n /** This event is fired when the DOM dblclick event is fired on the Polyline. */\n onDblClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the user stops dragging the polyline. */\n onDragEnd?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the user starts dragging the polyline. */\n onDragStart?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mousedown event is fired on the Polyline. */\n onMouseDown?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mousemove event is fired on the Polyline. */\n onMouseMove?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired on Polyline mouseout. */\n onMouseOut?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired on Polyline mouseover. */\n onMouseOver?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mouseup event is fired on the Polyline. */\n onMouseUp?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the Polyline is right-clicked on. */\n onRightClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM click event is fired on the Polyline. */\n onClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is repeatedly fired while the user drags the polyline. */\n onDrag?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This callback is called when the polyline instance has loaded. It is called with the polyline instance. */\n onLoad?: ((polyline: google.maps.Polyline) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the polyline instance. */\n onUnmount?: ((polyline: google.maps.Polyline) => void) | undefined\n}\n\nconst defaultOptions = {}\n\nfunction PolylineFunctional({\n options,\n draggable,\n editable,\n visible,\n path,\n onDblClick,\n onDragEnd,\n onDragStart,\n onMouseDown,\n onMouseMove,\n onMouseOut,\n onMouseOver,\n onMouseUp,\n onRightClick,\n onClick,\n onDrag,\n onLoad,\n onUnmount,\n}: PolylineProps): null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(null)\n\n const [dblclickListener, setDblclickListener] =\n useState(null)\n const [dragendListener, setDragendListener] =\n useState(null)\n const [dragstartListener, setDragstartListener] =\n useState(null)\n const [mousedownListener, setMousedownListener] =\n useState(null)\n const [mousemoveListener, setMousemoveListener] =\n useState(null)\n const [mouseoutListener, setMouseoutListener] =\n useState(null)\n const [mouseoverListener, setMouseoverListener] =\n useState(null)\n const [mouseupListener, setMouseupListener] =\n useState(null)\n const [rightclickListener, setRightclickListener] =\n useState(null)\n const [clickListener, setClickListener] =\n useState(null)\n const [dragListener, setDragListener] =\n useState(null)\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n if (typeof options !== 'undefined' && instance !== null) {\n instance.setOptions(options)\n }\n }, [instance, options])\n\n useEffect(() => {\n if (typeof draggable !== 'undefined' && instance !== null) {\n instance.setDraggable(draggable)\n }\n }, [instance, draggable])\n\n useEffect(() => {\n if (typeof editable !== 'undefined' && instance !== null) {\n instance.setEditable(editable)\n }\n }, [instance, editable])\n\n useEffect(() => {\n if (typeof visible !== 'undefined' && instance !== null) {\n instance.setVisible(visible)\n }\n }, [instance, visible])\n\n useEffect(() => {\n if (typeof path !== 'undefined' && instance !== null) {\n instance.setPath(path)\n }\n }, [instance, path])\n\n useEffect(() => {\n if (instance && onDblClick) {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n setDblclickListener(\n google.maps.event.addListener(instance, 'dblclick', onDblClick)\n )\n }\n }, [onDblClick])\n\n useEffect(() => {\n if (instance && onDragEnd) {\n if (dragendListener !== null) {\n google.maps.event.removeListener(dragendListener)\n }\n\n setDragendListener(\n google.maps.event.addListener(instance, 'dragend', onDragEnd)\n )\n }\n }, [onDragEnd])\n\n useEffect(() => {\n if (instance && onDragStart) {\n if (dragstartListener !== null) {\n google.maps.event.removeListener(dragstartListener)\n }\n\n setDragstartListener(\n google.maps.event.addListener(instance, 'dragstart', onDragStart)\n )\n }\n }, [onDragStart])\n\n useEffect(() => {\n if (instance && onMouseDown) {\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n setMousedownListener(\n google.maps.event.addListener(instance, 'mousedown', onMouseDown)\n )\n }\n }, [onMouseDown])\n\n useEffect(() => {\n if (instance && onMouseMove) {\n if (mousemoveListener !== null) {\n google.maps.event.removeListener(mousemoveListener)\n }\n\n setMousemoveListener(\n google.maps.event.addListener(instance, 'mousemove', onMouseMove)\n )\n }\n }, [onMouseMove])\n\n useEffect(() => {\n if (instance && onMouseOut) {\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n setMouseoutListener(\n google.maps.event.addListener(instance, 'mouseout', onMouseOut)\n )\n }\n }, [onMouseOut])\n\n useEffect(() => {\n if (instance && onMouseOver) {\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n setMouseoverListener(\n google.maps.event.addListener(instance, 'mouseover', onMouseOver)\n )\n }\n }, [onMouseOver])\n\n useEffect(() => {\n if (instance && onMouseUp) {\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n setMouseupListener(\n google.maps.event.addListener(instance, 'mouseup', onMouseUp)\n )\n }\n }, [onMouseUp])\n\n useEffect(() => {\n if (instance && onRightClick) {\n if (rightclickListener !== null) {\n google.maps.event.removeListener(rightclickListener)\n }\n\n setRightclickListener(\n google.maps.event.addListener(instance, 'rightclick', onRightClick)\n )\n }\n }, [onRightClick])\n\n useEffect(() => {\n if (instance && onClick) {\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n setClickListener(\n google.maps.event.addListener(instance, 'click', onClick)\n )\n }\n }, [onClick])\n\n useEffect(() => {\n if (instance && onDrag) {\n if (dragListener !== null) {\n google.maps.event.removeListener(dragListener)\n }\n\n setDragListener(google.maps.event.addListener(instance, 'drag', onDrag))\n }\n }, [onDrag])\n\n useEffect(() => {\n const polyline = new google.maps.Polyline({\n ...(options || defaultOptions),\n map,\n })\n\n if (path) {\n polyline.setPath(path)\n }\n\n if (typeof visible !== 'undefined') {\n polyline.setVisible(visible)\n }\n\n if (typeof editable !== 'undefined') {\n polyline.setEditable(editable)\n }\n\n if (typeof draggable !== 'undefined') {\n polyline.setDraggable(draggable)\n }\n\n if (onDblClick) {\n setDblclickListener(\n google.maps.event.addListener(polyline, 'dblclick', onDblClick)\n )\n }\n\n if (onDragEnd) {\n setDragendListener(\n google.maps.event.addListener(polyline, 'dragend', onDragEnd)\n )\n }\n\n if (onDragStart) {\n setDragstartListener(\n google.maps.event.addListener(polyline, 'dragstart', onDragStart)\n )\n }\n\n if (onMouseDown) {\n setMousedownListener(\n google.maps.event.addListener(polyline, 'mousedown', onMouseDown)\n )\n }\n\n if (onMouseMove) {\n setMousemoveListener(\n google.maps.event.addListener(polyline, 'mousemove', onMouseMove)\n )\n }\n\n if (onMouseOut) {\n setMouseoutListener(\n google.maps.event.addListener(polyline, 'mouseout', onMouseOut)\n )\n }\n\n if (onMouseOver) {\n setMouseoverListener(\n google.maps.event.addListener(polyline, 'mouseover', onMouseOver)\n )\n }\n\n if (onMouseUp) {\n setMouseupListener(\n google.maps.event.addListener(polyline, 'mouseup', onMouseUp)\n )\n }\n\n if (onRightClick) {\n setRightclickListener(\n google.maps.event.addListener(polyline, 'rightclick', onRightClick)\n )\n }\n\n if (onClick) {\n setClickListener(\n google.maps.event.addListener(polyline, 'click', onClick)\n )\n }\n\n if (onDrag) {\n setDragListener(google.maps.event.addListener(polyline, 'drag', onDrag))\n }\n\n setInstance(polyline)\n\n if (onLoad) {\n onLoad(polyline)\n }\n\n return () => {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n if (dragendListener !== null) {\n google.maps.event.removeListener(dragendListener)\n }\n\n if (dragstartListener !== null) {\n google.maps.event.removeListener(dragstartListener)\n }\n\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n if (mousemoveListener !== null) {\n google.maps.event.removeListener(mousemoveListener)\n }\n\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n if (rightclickListener !== null) {\n google.maps.event.removeListener(rightclickListener)\n }\n\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n if (onUnmount) {\n onUnmount(polyline)\n }\n\n polyline.setMap(null)\n }\n }, [])\n\n return null\n}\n\nexport const PolylineF = memo(PolylineFunctional)\n\nexport class Polyline extends PureComponent {\n static override contextType = MapContext\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: PolylineState = {\n polyline: null,\n }\n\n setPolylineCallback = (): void => {\n if (this.state.polyline !== null && this.props.onLoad) {\n this.props.onLoad(this.state.polyline)\n }\n }\n\n override componentDidMount(): void {\n const polyline = new google.maps.Polyline({\n ...this.props.options,\n map: this.context,\n })\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: polyline,\n })\n\n this.setState(function setPolyline() {\n return {\n polyline,\n }\n }, this.setPolylineCallback)\n }\n\n override componentDidUpdate(prevProps: PolylineProps): void {\n if (this.state.polyline !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.polyline,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.polyline === null) {\n return\n }\n\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.polyline)\n }\n\n unregisterEvents(this.registeredEvents)\n\n this.state.polyline.setMap(null)\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default Polyline\n","/* global google */\nimport {\n memo,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onClick: 'click',\n onDblClick: 'dblclick',\n onDrag: 'drag',\n onDragEnd: 'dragend',\n onDragStart: 'dragstart',\n onMouseDown: 'mousedown',\n onMouseMove: 'mousemove',\n onMouseOut: 'mouseout',\n onMouseOver: 'mouseover',\n onMouseUp: 'mouseup',\n onRightClick: 'rightclick',\n}\n\nconst updaterMap = {\n draggable(instance: google.maps.Polygon, draggable: boolean): void {\n instance.setDraggable(draggable)\n },\n editable(instance: google.maps.Polygon, editable: boolean): void {\n instance.setEditable(editable)\n },\n map(instance: google.maps.Polygon, map: google.maps.Map): void {\n instance.setMap(map)\n },\n options(\n instance: google.maps.Polygon,\n options: google.maps.PolygonOptions\n ): void {\n instance.setOptions(options)\n },\n path(\n instance: google.maps.Polygon,\n path:\n | google.maps.MVCArray\n | google.maps.LatLng[]\n | google.maps.LatLngLiteral[]\n ): void {\n instance.setPath(path)\n },\n\n paths(\n instance: google.maps.Polygon,\n paths:\n | google.maps.MVCArray\n | google.maps.MVCArray>\n | google.maps.LatLng[]\n | google.maps.LatLng[][]\n | google.maps.LatLngLiteral[]\n | google.maps.LatLngLiteral[][]\n ): void {\n instance.setPaths(paths)\n },\n\n visible(instance: google.maps.Polygon, visible: boolean): void {\n instance.setVisible(visible)\n },\n}\n\nexport type PolygonProps = {\n options?: google.maps.PolygonOptions | undefined\n /** If set to true, the user can drag this shape over the map. The geodesic property defines the mode of dragging. */\n draggable?: boolean | undefined\n /** If set to true, the user can edit this shape by dragging the control points shown at the vertices and on each segment. */\n editable?: boolean | undefined\n /** Hides this poly if set to false. */\n visible?: boolean | undefined\n /** Sets the first path. See Paths for more details. */\n path?:\n | google.maps.MVCArray\n | google.maps.LatLng[]\n | google.maps.LatLngLiteral[]\n | undefined\n /** Sets the path for this polygon. The ordered sequence of coordinates that designates a closed loop. Unlike polylines, a polygon may consist of one or more paths. As a result, the paths property may specify one or more arrays of LatLng coordinates. Paths are closed automatically; do not repeat the first vertex of the path as the last vertex. Simple polygons may be defined using a single array of LatLngs. More complex polygons may specify an array of arrays. Any simple arrays are converted into MVCArrays. Inserting or removing LatLngs from the MVCArray will automatically update the polygon on the map. */\n paths?:\n | google.maps.MVCArray\n | google.maps.MVCArray>\n | google.maps.LatLng[]\n | google.maps.LatLng[][]\n | google.maps.LatLngLiteral[]\n | google.maps.LatLngLiteral[][]\n | undefined\n /** This event is fired when the DOM dblclick event is fired on the Polygon. */\n onDblClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the user stops dragging the polygon. */\n onDragEnd?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the user starts dragging the polygon. */\n onDragStart?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mousedown event is fired on the Polygon. */\n onMouseDown?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mousemove event is fired on the Polygon. */\n onMouseMove?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired on Polygon mouseout. */\n onMouseOut?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired on Polygon mouseover. */\n onMouseOver?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mouseup event is fired on the Polygon. */\n onMouseUp?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the Polygon is right-clicked on. */\n onRightClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM click event is fired on the Polygon. */\n onClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is repeatedly fired while the user drags the polygon. */\n onDrag?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This callback is called when the polygon instance has loaded. It is called with the polygon instance. */\n onLoad?: ((polygon: google.maps.Polygon) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the polygon instance. */\n onUnmount?: ((polygon: google.maps.Polygon) => void) | undefined\n /** This callback is called when the components editing is finished */\n onEdit?: ((polygon: google.maps.Polygon) => void) | undefined\n}\n\nfunction PolygonFunctional({\n options,\n draggable,\n editable,\n visible,\n path,\n paths,\n onDblClick,\n onDragEnd,\n onDragStart,\n onMouseDown,\n onMouseMove,\n onMouseOut,\n onMouseOver,\n onMouseUp,\n onRightClick,\n onClick,\n onDrag,\n onLoad,\n onUnmount,\n onEdit,\n}: PolygonProps): null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(null)\n\n const [dblclickListener, setDblclickListener] =\n useState(null)\n const [dragendListener, setDragendListener] =\n useState(null)\n const [dragstartListener, setDragstartListener] =\n useState(null)\n const [mousedownListener, setMousedownListener] =\n useState(null)\n const [mousemoveListener, setMousemoveListener] =\n useState(null)\n const [mouseoutListener, setMouseoutListener] =\n useState(null)\n const [mouseoverListener, setMouseoverListener] =\n useState(null)\n const [mouseupListener, setMouseupListener] =\n useState(null)\n const [rightclickListener, setRightclickListener] =\n useState(null)\n const [clickListener, setClickListener] =\n useState(null)\n const [dragListener, setDragListener] =\n useState(null)\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n if (typeof options !== 'undefined' && instance !== null) {\n instance.setOptions(options)\n }\n }, [instance, options])\n\n useEffect(() => {\n if (typeof draggable !== 'undefined' && instance !== null) {\n instance.setDraggable(draggable)\n }\n }, [instance, draggable])\n\n useEffect(() => {\n if (typeof editable !== 'undefined' && instance !== null) {\n instance.setEditable(editable)\n }\n }, [instance, editable])\n\n useEffect(() => {\n if (typeof visible !== 'undefined' && instance !== null) {\n instance.setVisible(visible)\n }\n }, [instance, visible])\n\n useEffect(() => {\n if (typeof path !== 'undefined' && instance !== null) {\n instance.setPath(path)\n }\n }, [instance, path])\n\n useEffect(() => {\n if (typeof paths !== 'undefined' && instance !== null) {\n instance.setPaths(paths)\n }\n }, [instance, paths])\n\n useEffect(() => {\n if (instance && typeof onDblClick === 'function') {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n setDblclickListener(\n google.maps.event.addListener(instance, 'dblclick', onDblClick)\n )\n }\n }, [onDblClick])\n\n useEffect(() => {\n if (!instance) {\n return\n }\n\n google.maps.event.addListener(instance.getPath(), 'insert_at', () => {\n onEdit?.(instance)\n })\n\n google.maps.event.addListener(instance.getPath(), 'set_at', () => {\n onEdit?.(instance)\n })\n\n google.maps.event.addListener(instance.getPath(), 'remove_at', () => {\n onEdit?.(instance)\n })\n }, [instance, onEdit])\n\n useEffect(() => {\n if (instance && typeof onDragEnd === 'function') {\n if (dragendListener !== null) {\n google.maps.event.removeListener(dragendListener)\n }\n\n setDragendListener(\n google.maps.event.addListener(instance, 'dragend', onDragEnd)\n )\n }\n }, [onDragEnd])\n\n useEffect(() => {\n if (instance && typeof onDragStart === 'function') {\n if (dragstartListener !== null) {\n google.maps.event.removeListener(dragstartListener)\n }\n\n setDragstartListener(\n google.maps.event.addListener(instance, 'dragstart', onDragStart)\n )\n }\n }, [onDragStart])\n\n useEffect(() => {\n if (instance && typeof onMouseDown === 'function') {\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n setMousedownListener(\n google.maps.event.addListener(instance, 'mousedown', onMouseDown)\n )\n }\n }, [onMouseDown])\n\n useEffect(() => {\n if (instance && typeof onMouseMove === 'function') {\n if (mousemoveListener !== null) {\n google.maps.event.removeListener(mousemoveListener)\n }\n\n setMousemoveListener(\n google.maps.event.addListener(instance, 'mousemove', onMouseMove)\n )\n }\n }, [onMouseMove])\n\n useEffect(() => {\n if (instance && typeof onMouseOut === 'function') {\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n setMouseoutListener(\n google.maps.event.addListener(instance, 'mouseout', onMouseOut)\n )\n }\n }, [onMouseOut])\n\n useEffect(() => {\n if (instance && typeof onMouseOver === 'function') {\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n setMouseoverListener(\n google.maps.event.addListener(instance, 'mouseover', onMouseOver)\n )\n }\n }, [onMouseOver])\n\n useEffect(() => {\n if (instance && typeof onMouseUp === 'function') {\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n setMouseupListener(\n google.maps.event.addListener(instance, 'mouseup', onMouseUp)\n )\n }\n }, [onMouseUp])\n\n useEffect(() => {\n if (instance && typeof onRightClick === 'function') {\n if (rightclickListener !== null) {\n google.maps.event.removeListener(rightclickListener)\n }\n\n setRightclickListener(\n google.maps.event.addListener(instance, 'rightclick', onRightClick)\n )\n }\n }, [onRightClick])\n\n useEffect(() => {\n if (instance && typeof onClick === 'function') {\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n setClickListener(\n google.maps.event.addListener(instance, 'click', onClick)\n )\n }\n }, [onClick])\n\n useEffect(() => {\n if (instance && typeof onDrag === 'function') {\n if (dragListener !== null) {\n google.maps.event.removeListener(dragListener)\n }\n\n setDragListener(google.maps.event.addListener(instance, 'drag', onDrag))\n }\n }, [onDrag])\n\n useEffect(() => {\n const polygon = new google.maps.Polygon({\n ...options,\n map,\n })\n\n if (path) {\n polygon.setPath(path)\n }\n\n if (paths) {\n polygon.setPaths(paths)\n }\n\n if (typeof visible !== 'undefined') {\n polygon.setVisible(visible)\n }\n\n if (typeof editable !== 'undefined') {\n polygon.setEditable(editable)\n }\n\n if (typeof draggable !== 'undefined') {\n polygon.setDraggable(draggable)\n }\n\n if (onDblClick) {\n setDblclickListener(\n google.maps.event.addListener(polygon, 'dblclick', onDblClick)\n )\n }\n\n if (onDragEnd) {\n setDragendListener(\n google.maps.event.addListener(polygon, 'dragend', onDragEnd)\n )\n }\n\n if (onDragStart) {\n setDragstartListener(\n google.maps.event.addListener(polygon, 'dragstart', onDragStart)\n )\n }\n\n if (onMouseDown) {\n setMousedownListener(\n google.maps.event.addListener(polygon, 'mousedown', onMouseDown)\n )\n }\n\n if (onMouseMove) {\n setMousemoveListener(\n google.maps.event.addListener(polygon, 'mousemove', onMouseMove)\n )\n }\n\n if (onMouseOut) {\n setMouseoutListener(\n google.maps.event.addListener(polygon, 'mouseout', onMouseOut)\n )\n }\n\n if (onMouseOver) {\n setMouseoverListener(\n google.maps.event.addListener(polygon, 'mouseover', onMouseOver)\n )\n }\n\n if (onMouseUp) {\n setMouseupListener(\n google.maps.event.addListener(polygon, 'mouseup', onMouseUp)\n )\n }\n\n if (onRightClick) {\n setRightclickListener(\n google.maps.event.addListener(polygon, 'rightclick', onRightClick)\n )\n }\n\n if (onClick) {\n setClickListener(google.maps.event.addListener(polygon, 'click', onClick))\n }\n\n if (onDrag) {\n setDragListener(google.maps.event.addListener(polygon, 'drag', onDrag))\n }\n\n setInstance(polygon)\n\n if (onLoad) {\n onLoad(polygon)\n }\n\n return () => {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n if (dragendListener !== null) {\n google.maps.event.removeListener(dragendListener)\n }\n\n if (dragstartListener !== null) {\n google.maps.event.removeListener(dragstartListener)\n }\n\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n if (mousemoveListener !== null) {\n google.maps.event.removeListener(mousemoveListener)\n }\n\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n if (rightclickListener !== null) {\n google.maps.event.removeListener(rightclickListener)\n }\n\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n if (onUnmount) {\n onUnmount(polygon)\n }\n\n polygon.setMap(null)\n }\n }, [])\n\n return null\n}\n\nexport const PolygonF = memo(PolygonFunctional)\n\nexport class Polygon extends PureComponent {\n static override contextType = MapContext\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n polygon: google.maps.Polygon | undefined\n\n override componentDidMount(): void {\n const polygonOptions = this.props.options || {}\n\n this.polygon = new google.maps.Polygon(polygonOptions)\n\n this.polygon.setMap(this.context)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: this.polygon,\n })\n\n if (this.props.onLoad) {\n this.props.onLoad(this.polygon)\n }\n }\n\n override componentDidUpdate(prevProps: PolygonProps): void {\n if (this.polygon) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.polygon,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.polygon) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.polygon)\n }\n\n unregisterEvents(this.registeredEvents)\n\n if (this.polygon) {\n this.polygon.setMap(null)\n }\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default Polygon\n","import {\n memo,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onBoundsChanged: 'bounds_changed',\n onClick: 'click',\n onDblClick: 'dblclick',\n onDrag: 'drag',\n onDragEnd: 'dragend',\n onDragStart: 'dragstart',\n onMouseDown: 'mousedown',\n onMouseMove: 'mousemove',\n onMouseOut: 'mouseout',\n onMouseOver: 'mouseover',\n onMouseUp: 'mouseup',\n onRightClick: 'rightclick',\n}\n\nconst updaterMap = {\n bounds(\n instance: google.maps.Rectangle,\n bounds: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral\n ): void {\n instance.setBounds(bounds)\n },\n draggable(instance: google.maps.Rectangle, draggable: boolean): void {\n instance.setDraggable(draggable)\n },\n editable(instance: google.maps.Rectangle, editable: boolean): void {\n instance.setEditable(editable)\n },\n map(instance: google.maps.Rectangle, map: google.maps.Map): void {\n instance.setMap(map)\n },\n options(\n instance: google.maps.Rectangle,\n options: google.maps.RectangleOptions\n ): void {\n instance.setOptions(options)\n },\n visible(instance: google.maps.Rectangle, visible: boolean): void {\n instance.setVisible(visible)\n },\n}\n\ntype RectangleState = {\n rectangle: google.maps.Rectangle | null\n}\n\nexport type RectangleProps = {\n options?: google.maps.RectangleOptions | undefined\n /** Sets the bounds of this rectangle. */\n bounds?:\n | google.maps.LatLngBounds\n | google.maps.LatLngBoundsLiteral\n | undefined\n /** If set to true, the user can drag this rectangle over the map. */\n draggable?: boolean | undefined\n /** If set to true, the user can edit this rectangle by dragging the control points shown at the corners and on each edge. */\n editable?: boolean | undefined\n /** Hides this rectangle if set to false. */\n visible?: boolean | undefined\n /** @deprecated Indicates whether this Rectangle handles mouse events. Defaults to true. Does not exist on RectangleF component. In google-maps-api types it belongs to options! update options.clickable instead! */\n clickable?: boolean | undefined\n /** This event is fired when the DOM dblclick event is fired on the rectangle. */\n onDblClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the user stops dragging the rectangle. */\n onDragEnd?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the user starts dragging the rectangle. */\n onDragStart?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mousedown event is fired on the rectangle. */\n onMouseDown?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mousemove event is fired on the rectangle. */\n onMouseMove?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired on rectangle mouseout. */\n onMouseOut?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired on rectangle mouseover. */\n onMouseOver?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mouseup event is fired on the rectangle. */\n onMouseUp?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the rectangle is right-clicked on. */\n onRightClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM click event is fired on the rectangle. */\n onClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is repeatedly fired while the user drags the rectangle. */\n onDrag?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the rectangle's bounds are changed. */\n onBoundsChanged?: (() => void) | undefined\n /** This callback is called when the rectangle instance has loaded. It is called with the rectangle instance. */\n onLoad?: ((rectangle: google.maps.Rectangle) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the rectangle instance. */\n onUnmount?: ((rectangle: google.maps.Rectangle) => void) | undefined\n}\n\nfunction RectangleFunctional({\n options,\n bounds,\n draggable,\n editable,\n visible,\n onDblClick,\n onDragEnd,\n onDragStart,\n onMouseDown,\n onMouseMove,\n onMouseOut,\n onMouseOver,\n onMouseUp,\n onRightClick,\n onClick,\n onDrag,\n onBoundsChanged,\n onLoad,\n onUnmount,\n}: RectangleProps): null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(null)\n\n const [dblclickListener, setDblclickListener] =\n useState(null)\n const [dragendListener, setDragendListener] =\n useState(null)\n const [dragstartListener, setDragstartListener] =\n useState(null)\n const [mousedownListener, setMousedownListener] =\n useState(null)\n const [mousemoveListener, setMousemoveListener] =\n useState(null)\n const [mouseoutListener, setMouseoutListener] =\n useState(null)\n const [mouseoverListener, setMouseoverListener] =\n useState(null)\n const [mouseupListener, setMouseupListener] =\n useState(null)\n const [rightClickListener, setRightClickListener] =\n useState(null)\n const [clickListener, setClickListener] =\n useState(null)\n const [dragListener, setDragListener] =\n useState(null)\n const [boundsChangedListener, setBoundsChangedListener] =\n useState(null)\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n if (typeof options !== 'undefined' && instance !== null) {\n instance.setOptions(options)\n }\n }, [instance, options])\n\n useEffect(() => {\n if (typeof draggable !== 'undefined' && instance !== null) {\n instance.setDraggable(draggable)\n }\n }, [instance, draggable])\n\n useEffect(() => {\n if (typeof editable !== 'undefined' && instance !== null) {\n instance.setEditable(editable)\n }\n }, [instance, editable])\n\n useEffect(() => {\n if (typeof visible !== 'undefined' && instance !== null) {\n instance.setVisible(visible)\n }\n }, [instance, visible])\n\n useEffect(() => {\n if (typeof bounds !== 'undefined' && instance !== null) {\n instance.setBounds(bounds)\n }\n }, [instance, bounds])\n\n useEffect(() => {\n if (instance && onDblClick) {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n setDblclickListener(\n google.maps.event.addListener(instance, 'dblclick', onDblClick)\n )\n }\n }, [onDblClick])\n\n useEffect(() => {\n if (instance && onDragEnd) {\n if (dragendListener !== null) {\n google.maps.event.removeListener(dragendListener)\n }\n\n setDragendListener(\n google.maps.event.addListener(instance, 'dragend', onDragEnd)\n )\n }\n }, [onDragEnd])\n\n useEffect(() => {\n if (instance && onDragStart) {\n if (dragstartListener !== null) {\n google.maps.event.removeListener(dragstartListener)\n }\n\n setDragstartListener(\n google.maps.event.addListener(instance, 'dragstart', onDragStart)\n )\n }\n }, [onDragStart])\n\n useEffect(() => {\n if (instance && onMouseDown) {\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n setMousedownListener(\n google.maps.event.addListener(instance, 'mousedown', onMouseDown)\n )\n }\n }, [onMouseDown])\n\n useEffect(() => {\n if (instance && onMouseMove) {\n if (mousemoveListener !== null) {\n google.maps.event.removeListener(mousemoveListener)\n }\n\n setMousemoveListener(\n google.maps.event.addListener(instance, 'mousemove', onMouseMove)\n )\n }\n }, [onMouseMove])\n\n useEffect(() => {\n if (instance && onMouseOut) {\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n setMouseoutListener(\n google.maps.event.addListener(instance, 'mouseout', onMouseOut)\n )\n }\n }, [onMouseOut])\n\n useEffect(() => {\n if (instance && onMouseOver) {\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n setMouseoverListener(\n google.maps.event.addListener(instance, 'mouseover', onMouseOver)\n )\n }\n }, [onMouseOver])\n\n useEffect(() => {\n if (instance && onMouseUp) {\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n setMouseupListener(\n google.maps.event.addListener(instance, 'mouseup', onMouseUp)\n )\n }\n }, [onMouseUp])\n\n useEffect(() => {\n if (instance && onRightClick) {\n if (rightClickListener !== null) {\n google.maps.event.removeListener(rightClickListener)\n }\n\n setRightClickListener(\n google.maps.event.addListener(instance, 'rightclick', onRightClick)\n )\n }\n }, [onRightClick])\n\n useEffect(() => {\n if (instance && onClick) {\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n setClickListener(\n google.maps.event.addListener(instance, 'click', onClick)\n )\n }\n }, [onClick])\n\n useEffect(() => {\n if (instance && onDrag) {\n if (dragListener !== null) {\n google.maps.event.removeListener(dragListener)\n }\n\n setDragListener(google.maps.event.addListener(instance, 'drag', onDrag))\n }\n }, [onDrag])\n\n useEffect(() => {\n if (instance && onBoundsChanged) {\n if (boundsChangedListener !== null) {\n google.maps.event.removeListener(boundsChangedListener)\n }\n\n setBoundsChangedListener(\n google.maps.event.addListener(\n instance,\n 'bounds_changed',\n onBoundsChanged\n )\n )\n }\n }, [onBoundsChanged])\n\n useEffect(() => {\n const rectangle = new google.maps.Rectangle({\n ...options,\n map,\n })\n\n if (typeof visible !== 'undefined') {\n rectangle.setVisible(visible)\n }\n\n if (typeof editable !== 'undefined') {\n rectangle.setEditable(editable)\n }\n\n if (typeof draggable !== 'undefined') {\n rectangle.setDraggable(draggable)\n }\n\n if (typeof bounds !== 'undefined') {\n rectangle.setBounds(bounds)\n }\n\n if (onDblClick) {\n setDblclickListener(\n google.maps.event.addListener(rectangle, 'dblclick', onDblClick)\n )\n }\n\n if (onDragEnd) {\n setDragendListener(\n google.maps.event.addListener(rectangle, 'dragend', onDragEnd)\n )\n }\n\n if (onDragStart) {\n setDragstartListener(\n google.maps.event.addListener(rectangle, 'dragstart', onDragStart)\n )\n }\n\n if (onMouseDown) {\n setMousedownListener(\n google.maps.event.addListener(rectangle, 'mousedown', onMouseDown)\n )\n }\n\n if (onMouseMove) {\n setMousemoveListener(\n google.maps.event.addListener(rectangle, 'mousemove', onMouseMove)\n )\n }\n\n if (onMouseOut) {\n setMouseoutListener(\n google.maps.event.addListener(rectangle, 'mouseout', onMouseOut)\n )\n }\n\n if (onMouseOver) {\n setMouseoverListener(\n google.maps.event.addListener(rectangle, 'mouseover', onMouseOver)\n )\n }\n\n if (onMouseUp) {\n setMouseupListener(\n google.maps.event.addListener(rectangle, 'mouseup', onMouseUp)\n )\n }\n\n if (onRightClick) {\n setRightClickListener(\n google.maps.event.addListener(rectangle, 'rightclick', onRightClick)\n )\n }\n\n if (onClick) {\n setClickListener(\n google.maps.event.addListener(rectangle, 'click', onClick)\n )\n }\n\n if (onDrag) {\n setDragListener(google.maps.event.addListener(rectangle, 'drag', onDrag))\n }\n\n if (onBoundsChanged) {\n setBoundsChangedListener(\n google.maps.event.addListener(\n rectangle,\n 'bounds_changed',\n onBoundsChanged\n )\n )\n }\n\n setInstance(rectangle)\n\n if (onLoad) {\n onLoad(rectangle)\n }\n\n return () => {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n if (dragendListener !== null) {\n google.maps.event.removeListener(dragendListener)\n }\n\n if (dragstartListener !== null) {\n google.maps.event.removeListener(dragstartListener)\n }\n\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n if (mousemoveListener !== null) {\n google.maps.event.removeListener(mousemoveListener)\n }\n\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n if (rightClickListener !== null) {\n google.maps.event.removeListener(rightClickListener)\n }\n\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n if (dragListener !== null) {\n google.maps.event.removeListener(dragListener)\n }\n\n if (boundsChangedListener !== null) {\n google.maps.event.removeListener(boundsChangedListener)\n }\n\n if (onUnmount) {\n onUnmount(rectangle)\n }\n\n rectangle.setMap(null)\n }\n }, [])\n\n return null\n}\n\nexport const RectangleF = memo(RectangleFunctional)\n\nexport class Rectangle extends PureComponent {\n static override contextType = MapContext\n\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: RectangleState = {\n rectangle: null,\n }\n\n setRectangleCallback = (): void => {\n if (this.state.rectangle !== null && this.props.onLoad) {\n this.props.onLoad(this.state.rectangle)\n }\n }\n\n override componentDidMount(): void {\n const rectangle = new google.maps.Rectangle({\n ...this.props.options,\n map: this.context,\n })\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: rectangle,\n })\n\n this.setState(function setRectangle() {\n return {\n rectangle,\n }\n }, this.setRectangleCallback)\n }\n\n override componentDidUpdate(prevProps: RectangleProps): void {\n if (this.state.rectangle !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.rectangle,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.rectangle !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.rectangle)\n }\n\n unregisterEvents(this.registeredEvents)\n\n this.state.rectangle.setMap(null)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default Rectangle\n","import {\n memo,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onCenterChanged: 'center_changed',\n onRadiusChanged: 'radius_changed',\n onClick: 'click',\n onDblClick: 'dblclick',\n onDrag: 'drag',\n onDragEnd: 'dragend',\n onDragStart: 'dragstart',\n onMouseDown: 'mousedown',\n onMouseMove: 'mousemove',\n onMouseOut: 'mouseout',\n onMouseOver: 'mouseover',\n onMouseUp: 'mouseup',\n onRightClick: 'rightclick',\n}\n\nconst updaterMap = {\n center(instance: google.maps.Circle, center: google.maps.LatLng): void {\n instance.setCenter(center)\n },\n draggable(instance: google.maps.Circle, draggable: boolean): void {\n instance.setDraggable(draggable)\n },\n editable(instance: google.maps.Circle, editable: boolean): void {\n instance.setEditable(editable)\n },\n map(instance: google.maps.Circle, map: google.maps.Map): void {\n instance.setMap(map)\n },\n options(\n instance: google.maps.Circle,\n options: google.maps.CircleOptions\n ): void {\n instance.setOptions(options)\n },\n radius(instance: google.maps.Circle, radius: number): void {\n instance.setRadius(radius)\n },\n visible(instance: google.maps.Circle, visible: boolean): void {\n instance.setVisible(visible)\n },\n}\n\ntype CircleState = {\n circle: google.maps.Circle | null\n}\n\nexport type CircleProps = {\n options?: google.maps.CircleOptions | undefined\n\n /** sets the center of the circle */\n center?: google.maps.LatLng | google.maps.LatLngLiteral | undefined\n\n // required\n /** Sets the radius of this circle (in meters) */\n radius?: number | undefined\n /** If set to true, the user can drag this circle over the map */\n draggable?: boolean | undefined\n /** If set to true, the user can edit this circle by dragging the control points shown at the center and around the circumference of the circle. */\n editable?: boolean | undefined\n /** Hides this circle if set to false. */\n visible?: boolean | undefined\n /** This event is fired when the DOM dblclick event is fired on the circle. */\n onDblClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the user stops dragging the circle. */\n onDragEnd?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the user starts dragging the circle. */\n onDragStart?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mousedown event is fired on the circle. */\n onMouseDown?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mousemove event is fired on the circle. */\n onMouseMove?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired on circle mouseout. */\n onMouseOut?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired on circle mouseover. */\n onMouseOver?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM mouseup event is fired on the circle. */\n onMouseUp?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the circle is right-clicked on. */\n onRightClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM click event is fired on the circle. */\n onClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is repeatedly fired while the user drags the circle. */\n onDrag?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the circle's center is changed. */\n onCenterChanged?: (() => void) | undefined\n /** This event is fired when the circle's radius is changed. */\n onRadiusChanged?: (() => void) | undefined\n /** This callback is called when the circle instance has loaded. It is called with the circle instance. */\n onLoad?: ((circle: google.maps.Circle) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the circle instance. */\n onUnmount?: ((circle: google.maps.Circle) => void) | undefined\n}\n\nconst defaultOptions = {}\n\nfunction CircleFunctional({\n options,\n center,\n radius,\n draggable,\n editable,\n visible,\n onDblClick,\n onDragEnd,\n onDragStart,\n onMouseDown,\n onMouseMove,\n onMouseOut,\n onMouseOver,\n onMouseUp,\n onRightClick,\n onClick,\n onDrag,\n onCenterChanged,\n onRadiusChanged,\n onLoad,\n onUnmount,\n}: CircleProps): null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(null)\n\n const [dblclickListener, setDblclickListener] =\n useState(null)\n const [dragendListener, setDragendListener] =\n useState(null)\n const [dragstartListener, setDragstartListener] =\n useState(null)\n const [mousedownListener, setMousedownListener] =\n useState(null)\n const [mousemoveListener, setMousemoveListener] =\n useState(null)\n const [mouseoutListener, setMouseoutListener] =\n useState(null)\n const [mouseoverListener, setMouseoverListener] =\n useState(null)\n const [mouseupListener, setMouseupListener] =\n useState(null)\n const [rightclickListener, setRightclickListener] =\n useState(null)\n const [clickListener, setClickListener] =\n useState(null)\n const [dragListener, setDragListener] =\n useState(null)\n const [centerChangedListener, setCenterChangedListener] =\n useState(null)\n const [radiusChangedListener, setRadiusChangedListener] =\n useState(null)\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n if (typeof options !== 'undefined' && instance !== null) {\n instance.setOptions(options)\n }\n }, [instance, options])\n\n useEffect(() => {\n if (typeof draggable !== 'undefined' && instance !== null) {\n instance.setDraggable(draggable)\n }\n }, [instance, draggable])\n\n useEffect(() => {\n if (typeof editable !== 'undefined' && instance !== null) {\n instance.setEditable(editable)\n }\n }, [instance, editable])\n\n useEffect(() => {\n if (typeof visible !== 'undefined' && instance !== null) {\n instance.setVisible(visible)\n }\n }, [instance, visible])\n\n useEffect(() => {\n if (typeof radius === 'number' && instance !== null) {\n instance.setRadius(radius)\n }\n }, [instance, radius])\n\n useEffect(() => {\n if (typeof center !== 'undefined' && instance !== null) {\n instance.setCenter(center)\n }\n }, [instance, center])\n\n useEffect(() => {\n if (instance && onDblClick) {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n setDblclickListener(\n google.maps.event.addListener(instance, 'dblclick', onDblClick)\n )\n }\n }, [onDblClick])\n\n useEffect(() => {\n if (instance && onDragEnd) {\n if (dragendListener !== null) {\n google.maps.event.removeListener(dragendListener)\n }\n\n setDragendListener(\n google.maps.event.addListener(instance, 'dragend', onDragEnd)\n )\n }\n }, [onDragEnd])\n\n useEffect(() => {\n if (instance && onDragStart) {\n if (dragstartListener !== null) {\n google.maps.event.removeListener(dragstartListener)\n }\n\n setDragstartListener(\n google.maps.event.addListener(instance, 'dragstart', onDragStart)\n )\n }\n }, [onDragStart])\n\n useEffect(() => {\n if (instance && onMouseDown) {\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n setMousedownListener(\n google.maps.event.addListener(instance, 'mousedown', onMouseDown)\n )\n }\n }, [onMouseDown])\n\n useEffect(() => {\n if (instance && onMouseMove) {\n if (mousemoveListener !== null) {\n google.maps.event.removeListener(mousemoveListener)\n }\n\n setMousemoveListener(\n google.maps.event.addListener(instance, 'mousemove', onMouseMove)\n )\n }\n }, [onMouseMove])\n\n useEffect(() => {\n if (instance && onMouseOut) {\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n setMouseoutListener(\n google.maps.event.addListener(instance, 'mouseout', onMouseOut)\n )\n }\n }, [onMouseOut])\n\n useEffect(() => {\n if (instance && onMouseOver) {\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n setMouseoverListener(\n google.maps.event.addListener(instance, 'mouseover', onMouseOver)\n )\n }\n }, [onMouseOver])\n\n useEffect(() => {\n if (instance && onMouseUp) {\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n setMouseupListener(\n google.maps.event.addListener(instance, 'mouseup', onMouseUp)\n )\n }\n }, [onMouseUp])\n\n useEffect(() => {\n if (instance && onRightClick) {\n if (rightclickListener !== null) {\n google.maps.event.removeListener(rightclickListener)\n }\n\n setRightclickListener(\n google.maps.event.addListener(instance, 'rightclick', onRightClick)\n )\n }\n }, [onRightClick])\n\n useEffect(() => {\n if (instance && onClick) {\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n setClickListener(\n google.maps.event.addListener(instance, 'click', onClick)\n )\n }\n }, [onClick])\n\n useEffect(() => {\n if (instance && onDrag) {\n if (dragListener !== null) {\n google.maps.event.removeListener(dragListener)\n }\n\n setDragListener(google.maps.event.addListener(instance, 'drag', onDrag))\n }\n }, [onDrag])\n\n useEffect(() => {\n if (instance && onCenterChanged) {\n if (centerChangedListener !== null) {\n google.maps.event.removeListener(centerChangedListener)\n }\n\n setCenterChangedListener(\n google.maps.event.addListener(\n instance,\n 'center_changed',\n onCenterChanged\n )\n )\n }\n }, [onClick])\n\n useEffect(() => {\n if (instance && onRadiusChanged) {\n if (radiusChangedListener !== null) {\n google.maps.event.removeListener(radiusChangedListener)\n }\n\n setRadiusChangedListener(\n google.maps.event.addListener(\n instance,\n 'radius_changed',\n onRadiusChanged\n )\n )\n }\n }, [onRadiusChanged])\n\n useEffect(() => {\n const circle = new google.maps.Circle({\n ...(options || defaultOptions),\n map,\n })\n\n if (typeof radius === 'number') {\n circle.setRadius(radius)\n }\n\n if (typeof center !== 'undefined') {\n circle.setCenter(center)\n }\n\n if (typeof radius === 'number') {\n circle.setRadius(radius)\n }\n\n if (typeof visible !== 'undefined') {\n circle.setVisible(visible)\n }\n\n if (typeof editable !== 'undefined') {\n circle.setEditable(editable)\n }\n\n if (typeof draggable !== 'undefined') {\n circle.setDraggable(draggable)\n }\n\n if (onDblClick) {\n setDblclickListener(\n google.maps.event.addListener(circle, 'dblclick', onDblClick)\n )\n }\n\n if (onDragEnd) {\n setDragendListener(\n google.maps.event.addListener(circle, 'dragend', onDragEnd)\n )\n }\n\n if (onDragStart) {\n setDragstartListener(\n google.maps.event.addListener(circle, 'dragstart', onDragStart)\n )\n }\n\n if (onMouseDown) {\n setMousedownListener(\n google.maps.event.addListener(circle, 'mousedown', onMouseDown)\n )\n }\n\n if (onMouseMove) {\n setMousemoveListener(\n google.maps.event.addListener(circle, 'mousemove', onMouseMove)\n )\n }\n\n if (onMouseOut) {\n setMouseoutListener(\n google.maps.event.addListener(circle, 'mouseout', onMouseOut)\n )\n }\n\n if (onMouseOver) {\n setMouseoverListener(\n google.maps.event.addListener(circle, 'mouseover', onMouseOver)\n )\n }\n\n if (onMouseUp) {\n setMouseupListener(\n google.maps.event.addListener(circle, 'mouseup', onMouseUp)\n )\n }\n\n if (onRightClick) {\n setRightclickListener(\n google.maps.event.addListener(circle, 'rightclick', onRightClick)\n )\n }\n\n if (onClick) {\n setClickListener(google.maps.event.addListener(circle, 'click', onClick))\n }\n\n if (onDrag) {\n setDragListener(google.maps.event.addListener(circle, 'drag', onDrag))\n }\n\n if (onCenterChanged) {\n setCenterChangedListener(\n google.maps.event.addListener(circle, 'center_changed', onCenterChanged)\n )\n }\n\n if (onRadiusChanged) {\n setRadiusChangedListener(\n google.maps.event.addListener(circle, 'radius_changed', onRadiusChanged)\n )\n }\n\n setInstance(circle)\n\n if (onLoad) {\n onLoad(circle)\n }\n\n return () => {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n if (dragendListener !== null) {\n google.maps.event.removeListener(dragendListener)\n }\n\n if (dragstartListener !== null) {\n google.maps.event.removeListener(dragstartListener)\n }\n\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n if (mousemoveListener !== null) {\n google.maps.event.removeListener(mousemoveListener)\n }\n\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n if (rightclickListener !== null) {\n google.maps.event.removeListener(rightclickListener)\n }\n\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n if (centerChangedListener !== null) {\n google.maps.event.removeListener(centerChangedListener)\n }\n\n if (radiusChangedListener !== null) {\n google.maps.event.removeListener(radiusChangedListener)\n }\n\n if (onUnmount) {\n onUnmount(circle)\n }\n\n circle.setMap(null)\n }\n }, [])\n\n return null\n}\n\nexport const CircleF = memo(CircleFunctional)\n\nexport class Circle extends PureComponent {\n static override contextType = MapContext\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: CircleState = {\n circle: null,\n }\n\n setCircleCallback = (): void => {\n if (this.state.circle !== null && this.props.onLoad) {\n this.props.onLoad(this.state.circle)\n }\n }\n\n override componentDidMount(): void {\n const circle = new google.maps.Circle({\n ...this.props.options,\n map: this.context,\n })\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: circle,\n })\n\n this.setState(function setCircle() {\n return {\n circle,\n }\n }, this.setCircleCallback)\n }\n\n override componentDidUpdate(prevProps: CircleProps): void {\n if (this.state.circle !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.circle,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.circle !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.circle)\n }\n\n unregisterEvents(this.registeredEvents)\n\n this.state.circle?.setMap(null)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default Circle\n","import {\n memo,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onClick: 'click',\n onDblClick: 'dblclick',\n onMouseDown: 'mousedown',\n onMouseOut: 'mouseout',\n onMouseOver: 'mouseover',\n onMouseUp: 'mouseup',\n onRightClick: 'rightclick',\n onAddFeature: 'addfeature',\n onRemoveFeature: 'removefeature',\n onRemoveProperty: 'removeproperty',\n onSetGeometry: 'setgeometry',\n onSetProperty: 'setproperty',\n}\n\nconst updaterMap = {\n add(\n instance: google.maps.Data,\n feature: google.maps.Data.Feature | google.maps.Data.FeatureOptions\n ): void {\n instance.add(feature)\n },\n addgeojson(\n instance: google.maps.Data,\n geojson: object,\n options?: google.maps.Data.GeoJsonOptions | undefined\n ): void {\n instance.addGeoJson(geojson, options)\n },\n contains(\n instance: google.maps.Data,\n feature: google.maps.Data.Feature\n ): void {\n instance.contains(feature)\n },\n foreach(\n instance: google.maps.Data,\n callback: (feature: google.maps.Data.Feature) => void\n ): void {\n instance.forEach(callback)\n },\n loadgeojson(\n instance: google.maps.Data,\n url: string,\n options: google.maps.Data.GeoJsonOptions,\n callback: (features: google.maps.Data.Feature[]) => void\n ): void {\n instance.loadGeoJson(url, options, callback)\n },\n overridestyle(\n instance: google.maps.Data,\n feature: google.maps.Data.Feature,\n style: google.maps.Data.StyleOptions\n ): void {\n instance.overrideStyle(feature, style)\n },\n remove(instance: google.maps.Data, feature: google.maps.Data.Feature): void {\n instance.remove(feature)\n },\n revertstyle(\n instance: google.maps.Data,\n feature: google.maps.Data.Feature\n ): void {\n instance.revertStyle(feature)\n },\n controlposition(\n instance: google.maps.Data,\n controlPosition: google.maps.ControlPosition\n ): void {\n instance.setControlPosition(controlPosition)\n },\n controls(instance: google.maps.Data, controls: string[] | null): void {\n instance.setControls(controls)\n },\n drawingmode(instance: google.maps.Data, mode: string | null): void {\n instance.setDrawingMode(mode)\n },\n map(instance: google.maps.Data, map: google.maps.Map): void {\n instance.setMap(map)\n },\n style(\n instance: google.maps.Data,\n style: google.maps.Data.StylingFunction | google.maps.Data.StyleOptions\n ): void {\n instance.setStyle(style)\n },\n togeojson(\n instance: google.maps.Data,\n callback: (feature: object) => void\n ): void {\n instance.toGeoJson(callback)\n },\n}\n\ntype DataState = {\n data: google.maps.Data | null\n}\n\nexport type DataProps = {\n options?: google.maps.Data.DataOptions | undefined\n /** This event is fired for a click on the geometry. */\n onClick?: ((e: google.maps.Data.MouseEvent) => void) | undefined\n /** This event is fired for a double click on the geometry. */\n onDblClick?: ((e: google.maps.Data.MouseEvent) => void) | undefined\n /** This event is fired for a mousedown on the geometry. */\n onMouseDown?: ((e: google.maps.Data.MouseEvent) => void) | undefined\n /** This event is fired when the DOM mousemove event is fired on the rectangle. */\n onMouseMove?: ((e: google.maps.Data.MouseEvent) => void) | undefined\n /** This event is fired when the mouse leaves the area of the geometry. */\n onMouseOut?: ((e: google.maps.Data.MouseEvent) => void) | undefined\n /** This event is fired when the mouse enters the area of the geometry. */\n onMouseOver?: ((e: google.maps.Data.MouseEvent) => void) | undefined\n /** This event is fired for a mouseup on the geometry. */\n onMouseUp?: ((e: google.maps.Data.MouseEvent) => void) | undefined\n /** This event is fired for a rightclick on the geometry. */\n onRightClick?: ((e: google.maps.Data.MouseEvent) => void) | undefined\n /** This event is fired when a feature is added to the collection. */\n onAddFeature?: ((e: google.maps.Data.AddFeatureEvent) => void) | undefined\n /** This event is fired when a feature is removed from the collection. */\n onRemoveFeature?:\n | ((e: google.maps.Data.RemoveFeatureEvent) => void)\n | undefined\n /** This event is fired when a feature's property is removed. */\n onRemoveProperty?:\n | ((e: google.maps.Data.RemovePropertyEvent) => void)\n | undefined\n /** This event is fired when a feature's geometry is set. */\n onSetGeometry?: ((e: google.maps.Data.SetGeometryEvent) => void) | undefined\n /** This event is fired when a feature's property is set. */\n onSetProperty?: ((e: google.maps.Data.SetPropertyEvent) => void) | undefined\n /** This callback is called when the data instance has loaded. It is called with the data instance. */\n onLoad?: ((data: google.maps.Data) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the data instance. */\n onUnmount?: ((data: google.maps.Data) => void) | undefined\n}\n\nfunction DataFunctional({\n options,\n onClick,\n onDblClick,\n onMouseDown,\n onMouseMove,\n onMouseOut,\n onMouseOver,\n onMouseUp,\n onRightClick,\n onAddFeature,\n onRemoveFeature,\n onRemoveProperty,\n onSetGeometry,\n onSetProperty,\n onLoad,\n onUnmount,\n}: DataProps): null {\n const map = useContext(MapContext)\n\n const [instance, setInstance] = useState(null)\n\n const [dblclickListener, setDblclickListener] =\n useState(null)\n const [mousedownListener, setMousedownListener] =\n useState(null)\n const [mousemoveListener, setMousemoveListener] =\n useState(null)\n const [mouseoutListener, setMouseoutListener] =\n useState(null)\n const [mouseoverListener, setMouseoverListener] =\n useState(null)\n const [mouseupListener, setMouseupListener] =\n useState(null)\n const [rightclickListener, setRightclickListener] =\n useState(null)\n const [clickListener, setClickListener] =\n useState(null)\n\n const [addFeatureListener, setAddFeatureListener] =\n useState(null)\n const [removeFeatureListener, setRemoveFeatureListener] =\n useState(null)\n const [removePropertyListener, setRemovePropertyListener] =\n useState(null)\n const [setGeometryListener, setSetGeometryListener] =\n useState(null)\n const [setPropertyListener, setSetPropertyListener] =\n useState(null)\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n if (instance && onDblClick) {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n setDblclickListener(\n google.maps.event.addListener(instance, 'dblclick', onDblClick)\n )\n }\n }, [onDblClick])\n\n useEffect(() => {\n if (instance && onMouseDown) {\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n setMousedownListener(\n google.maps.event.addListener(instance, 'mousedown', onMouseDown)\n )\n }\n }, [onMouseDown])\n\n useEffect(() => {\n if (instance && onMouseMove) {\n if (mousemoveListener !== null) {\n google.maps.event.removeListener(mousemoveListener)\n }\n\n setMousemoveListener(\n google.maps.event.addListener(instance, 'mousemove', onMouseMove)\n )\n }\n }, [onMouseMove])\n\n useEffect(() => {\n if (instance && onMouseOut) {\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n setMouseoutListener(\n google.maps.event.addListener(instance, 'mouseout', onMouseOut)\n )\n }\n }, [onMouseOut])\n\n useEffect(() => {\n if (instance && onMouseOver) {\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n setMouseoverListener(\n google.maps.event.addListener(instance, 'mouseover', onMouseOver)\n )\n }\n }, [onMouseOver])\n\n useEffect(() => {\n if (instance && onMouseUp) {\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n setMouseupListener(\n google.maps.event.addListener(instance, 'mouseup', onMouseUp)\n )\n }\n }, [onMouseUp])\n\n useEffect(() => {\n if (instance && onRightClick) {\n if (rightclickListener !== null) {\n google.maps.event.removeListener(rightclickListener)\n }\n\n setRightclickListener(\n google.maps.event.addListener(instance, 'rightclick', onRightClick)\n )\n }\n }, [onRightClick])\n\n useEffect(() => {\n if (instance && onClick) {\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n setClickListener(\n google.maps.event.addListener(instance, 'click', onClick)\n )\n }\n }, [onClick])\n\n useEffect(() => {\n if (instance && onAddFeature) {\n if (addFeatureListener !== null) {\n google.maps.event.removeListener(addFeatureListener)\n }\n\n setAddFeatureListener(\n google.maps.event.addListener(instance, 'addfeature', onAddFeature)\n )\n }\n }, [onAddFeature])\n\n useEffect(() => {\n if (instance && onRemoveFeature) {\n if (removeFeatureListener !== null) {\n google.maps.event.removeListener(removeFeatureListener)\n }\n\n setRemoveFeatureListener(\n google.maps.event.addListener(\n instance,\n 'removefeature',\n onRemoveFeature\n )\n )\n }\n }, [onRemoveFeature])\n\n useEffect(() => {\n if (instance && onRemoveProperty) {\n if (removePropertyListener !== null) {\n google.maps.event.removeListener(removePropertyListener)\n }\n\n setRemovePropertyListener(\n google.maps.event.addListener(\n instance,\n 'removeproperty',\n onRemoveProperty\n )\n )\n }\n }, [onRemoveProperty])\n\n useEffect(() => {\n if (instance && onSetGeometry) {\n if (setGeometryListener !== null) {\n google.maps.event.removeListener(setGeometryListener)\n }\n\n setSetGeometryListener(\n google.maps.event.addListener(instance, 'setgeometry', onSetGeometry)\n )\n }\n }, [onSetGeometry])\n\n useEffect(() => {\n if (instance && onSetProperty) {\n if (setPropertyListener !== null) {\n google.maps.event.removeListener(setPropertyListener)\n }\n\n setSetPropertyListener(\n google.maps.event.addListener(instance, 'setproperty', onSetProperty)\n )\n }\n }, [onSetProperty])\n\n useEffect(() => {\n if (map !== null) {\n const data = new google.maps.Data({\n ...options,\n map,\n })\n\n if (onDblClick) {\n setDblclickListener(\n google.maps.event.addListener(data, 'dblclick', onDblClick)\n )\n }\n\n if (onMouseDown) {\n setMousedownListener(\n google.maps.event.addListener(data, 'mousedown', onMouseDown)\n )\n }\n\n if (onMouseMove) {\n setMousemoveListener(\n google.maps.event.addListener(data, 'mousemove', onMouseMove)\n )\n }\n\n if (onMouseOut) {\n setMouseoutListener(\n google.maps.event.addListener(data, 'mouseout', onMouseOut)\n )\n }\n\n if (onMouseOver) {\n setMouseoverListener(\n google.maps.event.addListener(data, 'mouseover', onMouseOver)\n )\n }\n\n if (onMouseUp) {\n setMouseupListener(\n google.maps.event.addListener(data, 'mouseup', onMouseUp)\n )\n }\n\n if (onRightClick) {\n setRightclickListener(\n google.maps.event.addListener(data, 'rightclick', onRightClick)\n )\n }\n\n if (onClick) {\n setClickListener(google.maps.event.addListener(data, 'click', onClick))\n }\n\n if (onAddFeature) {\n setAddFeatureListener(\n google.maps.event.addListener(data, 'addfeature', onAddFeature)\n )\n }\n\n if (onRemoveFeature) {\n setRemoveFeatureListener(\n google.maps.event.addListener(data, 'removefeature', onRemoveFeature)\n )\n }\n\n if (onRemoveProperty) {\n setRemovePropertyListener(\n google.maps.event.addListener(\n data,\n 'removeproperty',\n onRemoveProperty\n )\n )\n }\n\n if (onSetGeometry) {\n setSetGeometryListener(\n google.maps.event.addListener(data, 'setgeometry', onSetGeometry)\n )\n }\n\n if (onSetProperty) {\n setSetPropertyListener(\n google.maps.event.addListener(data, 'setproperty', onSetProperty)\n )\n }\n\n setInstance(data)\n\n if (onLoad) {\n onLoad(data)\n }\n }\n\n return () => {\n if (instance) {\n if (dblclickListener !== null) {\n google.maps.event.removeListener(dblclickListener)\n }\n\n if (mousedownListener !== null) {\n google.maps.event.removeListener(mousedownListener)\n }\n\n if (mousemoveListener !== null) {\n google.maps.event.removeListener(mousemoveListener)\n }\n\n if (mouseoutListener !== null) {\n google.maps.event.removeListener(mouseoutListener)\n }\n\n if (mouseoverListener !== null) {\n google.maps.event.removeListener(mouseoverListener)\n }\n\n if (mouseupListener !== null) {\n google.maps.event.removeListener(mouseupListener)\n }\n\n if (rightclickListener !== null) {\n google.maps.event.removeListener(rightclickListener)\n }\n\n if (clickListener !== null) {\n google.maps.event.removeListener(clickListener)\n }\n\n if (addFeatureListener !== null) {\n google.maps.event.removeListener(addFeatureListener)\n }\n\n if (removeFeatureListener !== null) {\n google.maps.event.removeListener(removeFeatureListener)\n }\n\n if (removePropertyListener !== null) {\n google.maps.event.removeListener(removePropertyListener)\n }\n\n if (setGeometryListener !== null) {\n google.maps.event.removeListener(setGeometryListener)\n }\n\n if (setPropertyListener !== null) {\n google.maps.event.removeListener(setPropertyListener)\n }\n\n if (onUnmount) {\n onUnmount(instance)\n }\n\n instance.setMap(null)\n }\n }\n }, [])\n\n return null\n}\n\nexport const DataF = memo(DataFunctional)\n\nexport class Data extends PureComponent {\n static override contextType = MapContext\n\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: DataState = {\n data: null,\n }\n\n setDataCallback = (): void => {\n if (this.state.data !== null && this.props.onLoad) {\n this.props.onLoad(this.state.data)\n }\n }\n\n override componentDidMount(): void {\n if (this.context !== null) {\n const data = new google.maps.Data({\n ...this.props.options,\n map: this.context,\n })\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: data,\n })\n\n this.setState(() => {\n return {\n data,\n }\n }, this.setDataCallback)\n }\n }\n\n override componentDidUpdate(prevProps: DataProps): void {\n if (this.state.data !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.data,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.data !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.data)\n }\n\n unregisterEvents(this.registeredEvents)\n\n if (this.state.data) {\n this.state.data.setMap(null)\n }\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default Data\n","import { type ContextType, PureComponent } from 'react'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onClick: 'click',\n onDefaultViewportChanged: 'defaultviewport_changed',\n onStatusChanged: 'status_changed',\n}\n\nconst updaterMap = {\n options(\n instance: google.maps.KmlLayer,\n options: google.maps.KmlLayerOptions\n ): void {\n instance.setOptions(options)\n },\n url(instance: google.maps.KmlLayer, url: string): void {\n instance.setUrl(url)\n },\n zIndex(instance: google.maps.KmlLayer, zIndex: number): void {\n instance.setZIndex(zIndex)\n },\n}\n\ntype KmlLayerState = {\n kmlLayer: google.maps.KmlLayer | null\n}\n\nexport type KmlLayerProps = {\n options?: google.maps.KmlLayerOptions | undefined\n /** The URL of the KML document to display. */\n url?: string | undefined\n /** The z-index of the layer. */\n zIndex?: number | undefined\n /** This event is fired when a feature in the layer is clicked. */\n onClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the KML layers default viewport has changed. */\n onDefaultViewportChanged?: (() => void) | undefined | undefined\n /** This event is fired when the KML layer has finished loading. At this point it is safe to read the status property to determine if the layer loaded successfully. */\n onStatusChanged?: (() => void) | undefined | undefined\n /** This callback is called when the kmlLayer instance has loaded. It is called with the kmlLayer instance. */\n onLoad?: ((kmlLayer: google.maps.KmlLayer) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the kmlLayer instance. */\n onUnmount?: ((kmlLayer: google.maps.KmlLayer) => void) | undefined\n}\n\nexport class KmlLayer extends PureComponent {\n static override contextType = MapContext\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: KmlLayerState = {\n kmlLayer: null,\n }\n\n setKmlLayerCallback = (): void => {\n if (this.state.kmlLayer !== null && this.props.onLoad) {\n this.props.onLoad(this.state.kmlLayer)\n }\n }\n\n override componentDidMount(): void {\n const kmlLayer = new google.maps.KmlLayer({\n ...this.props.options,\n map: this.context,\n })\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: kmlLayer,\n })\n\n this.setState(function setLmlLayer() {\n return {\n kmlLayer,\n }\n }, this.setKmlLayerCallback)\n }\n\n override componentDidUpdate(prevProps: KmlLayerProps): void {\n if (this.state.kmlLayer !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.kmlLayer,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.kmlLayer !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.kmlLayer)\n }\n\n unregisterEvents(this.registeredEvents)\n\n this.state.kmlLayer.setMap(null)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default KmlLayer\n","import type { PositionDrawProps } from \"../../types\"\n\nexport function getOffsetOverride(\n containerElement: HTMLElement,\n getPixelPositionOffset?:( (offsetWidth: number, offsetHeight: number) => { x: number; y: number }) | undefined\n): { x: number; y: number } {\n return typeof getPixelPositionOffset === 'function'\n ? getPixelPositionOffset(containerElement.offsetWidth, containerElement.offsetHeight)\n : {\n x: 0,\n y: 0,\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction createLatLng(inst: any, Type: any): any { return new Type(inst.lat, inst.lng) }\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction createLatLngBounds(inst: any, Type: any): any {\n return new Type(\n new google.maps.LatLng(inst.ne.lat, inst.ne.lng),\n new google.maps.LatLng(inst.sw.lat, inst.sw.lng)\n )\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction ensureOfType(\n inst: google.maps.LatLng | google.maps.LatLngLiteral | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n factory: (inst: google.maps.LatLng | google.maps.LatLngLiteral | undefined, type: any) => any\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n return inst instanceof type ? inst : factory(inst, type)\n}\n\nfunction ensureOfTypeBounds(\n inst: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n factory: (inst: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral, type: any) => any\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n return inst instanceof type ? inst : factory(inst, type)\n}\n\nfunction getLayoutStylesByBounds(\n mapCanvasProjection: google.maps.MapCanvasProjection,\n offset: { x: number; y: number },\n bounds: google.maps.LatLngBounds\n): { left: string; top: string; width: string; height: string } | { left: string; top: string } {\n const ne = mapCanvasProjection && mapCanvasProjection.fromLatLngToDivPixel(bounds.getNorthEast())\n\n const sw = mapCanvasProjection && mapCanvasProjection.fromLatLngToDivPixel(bounds.getSouthWest())\n\n if (ne && sw) {\n return {\n left: `${sw.x + offset.x}px`,\n top: `${ne.y + offset.y}px`,\n width: `${ne.x - sw.x - offset.x}px`,\n height: `${sw.y - ne.y - offset.y}px`,\n }\n }\n\n return {\n left: '-9999px',\n top: '-9999px',\n }\n}\n\nfunction getLayoutStylesByPosition (\n mapCanvasProjection: google.maps.MapCanvasProjection,\n offset: { x: number; y: number },\n position: google.maps.LatLng\n): { left: string; top: string } {\n const point = mapCanvasProjection && mapCanvasProjection.fromLatLngToDivPixel(position)\n\n if (point) {\n const { x, y } = point\n\n return {\n left: `${x + offset.x}px`,\n top: `${y + offset.y}px`,\n }\n }\n\n return {\n left: '-9999px',\n top: '-9999px',\n }\n}\n\nexport function getLayoutStyles (\n mapCanvasProjection: google.maps.MapCanvasProjection,\n offset: { x: number; y: number },\n bounds?: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral | undefined,\n position?: google.maps.LatLng | google.maps.LatLngLiteral | undefined\n): PositionDrawProps {\n return bounds !== undefined\n ? getLayoutStylesByBounds(\n mapCanvasProjection,\n offset,\n ensureOfTypeBounds(bounds, google.maps.LatLngBounds, createLatLngBounds)\n )\n : getLayoutStylesByPosition(\n mapCanvasProjection,\n offset,\n ensureOfType(position, google.maps.LatLng, createLatLng)\n )\n}\n\nexport function arePositionsEqual (\n currentPosition: PositionDrawProps,\n previousPosition: PositionDrawProps\n): boolean {\n return currentPosition.left === previousPosition.left\n && currentPosition.top === previousPosition.top\n && currentPosition.width === previousPosition.height\n && currentPosition.height === previousPosition.height;\n}\n","import { getOffsetOverride, getLayoutStyles } from './dom-helper.js'\n\ntype fnPixelPositionOffset = (\n offsetWidth: number,\n offsetHeight: number\n) => { x: number; y: number }\n\nexport function createOverlay(\n container: HTMLElement,\n pane: keyof google.maps.MapPanes,\n position?: google.maps.LatLng | google.maps.LatLngLiteral | undefined,\n bounds?:\n | google.maps.LatLngBounds\n | google.maps.LatLngBoundsLiteral\n | undefined,\n getPixelPositionOffset?: fnPixelPositionOffset | undefined\n) {\n class Overlay extends google.maps.OverlayView {\n container: HTMLElement\n pane: keyof google.maps.MapPanes\n position: google.maps.LatLng | google.maps.LatLngLiteral | undefined\n bounds:\n | google.maps.LatLngBounds\n | google.maps.LatLngBoundsLiteral\n | undefined\n\n constructor(\n container: HTMLElement,\n pane: keyof google.maps.MapPanes,\n position?: google.maps.LatLng | google.maps.LatLngLiteral,\n bounds?: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral\n ) {\n super()\n this.container = container\n this.pane = pane\n this.position = position\n this.bounds = bounds\n }\n\n override onAdd(): void {\n const pane = this.getPanes()?.[this.pane]\n pane?.appendChild(this.container)\n }\n\n override draw(): void {\n const projection = this.getProjection()\n const offset = {\n ...(this.container\n ? getOffsetOverride(this.container, getPixelPositionOffset)\n : {\n x: 0,\n y: 0,\n }),\n }\n\n const layoutStyles = getLayoutStyles(\n projection,\n offset,\n this.bounds,\n this.position\n )\n\n for (const [key, value] of Object.entries(layoutStyles)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.container.style[key] = value\n }\n }\n\n override onRemove(): void {\n if (this.container.parentNode !== null) {\n this.container.parentNode.removeChild(this.container)\n }\n }\n }\n\n return new Overlay(container, pane, position, bounds)\n}\n","import {\n memo,\n useMemo,\n Children,\n createRef,\n useEffect,\n useContext,\n PureComponent,\n type ReactNode,\n type RefObject,\n type ContextType,\n type ReactPortal,\n type CSSProperties,\n} from 'react'\nimport invariant from 'invariant'\nimport * as ReactDOM from 'react-dom'\n\nimport MapContext from '../../map-context.js'\n\nimport {\n getLayoutStyles,\n arePositionsEqual,\n getOffsetOverride,\n} from './dom-helper.js'\n\nimport { createOverlay } from './Overlay.js'\n\ntype OverlayViewState = {\n paneEl: Element | null\n containerStyle: CSSProperties\n}\n\nfunction convertToLatLngString(\n latLngLike?: google.maps.LatLng | google.maps.LatLngLiteral | null | undefined\n) {\n if (!latLngLike) {\n return ''\n }\n\n const latLng =\n latLngLike instanceof google.maps.LatLng\n ? latLngLike\n : new google.maps.LatLng(latLngLike.lat, latLngLike.lng)\n\n return latLng + ''\n}\n\nfunction convertToLatLngBoundsString(\n latLngBoundsLike?:\n | google.maps.LatLngBounds\n | google.maps.LatLngBoundsLiteral\n | null\n | undefined\n) {\n if (!latLngBoundsLike) {\n return ''\n }\n\n const latLngBounds =\n latLngBoundsLike instanceof google.maps.LatLngBounds\n ? latLngBoundsLike\n : new google.maps.LatLngBounds(\n new google.maps.LatLng(latLngBoundsLike.south, latLngBoundsLike.east),\n new google.maps.LatLng(latLngBoundsLike.north, latLngBoundsLike.west)\n )\n\n return latLngBounds + ''\n}\n\nexport type PaneNames = keyof google.maps.MapPanes\n\nexport type OverlayViewProps = {\n children?: ReactNode | undefined\n // required\n mapPaneName: PaneNames\n position?: google.maps.LatLng | google.maps.LatLngLiteral | undefined\n getPixelPositionOffset?:\n | ((offsetWidth: number, offsetHeight: number) => { x: number; y: number })\n | undefined\n bounds?:\n | google.maps.LatLngBounds\n | google.maps.LatLngBoundsLiteral\n | undefined\n zIndex?: number | undefined\n onLoad?: ((overlayView: google.maps.OverlayView) => void) | undefined\n onUnmount?: ((overlayView: google.maps.OverlayView) => void) | undefined\n}\n\nexport const FLOAT_PANE: PaneNames = `floatPane`\nexport const MAP_PANE: PaneNames = `mapPane`\nexport const MARKER_LAYER: PaneNames = `markerLayer`\nexport const OVERLAY_LAYER: PaneNames = `overlayLayer`\nexport const OVERLAY_MOUSE_TARGET: PaneNames = `overlayMouseTarget`\n\nfunction OverlayViewFunctional({\n position,\n bounds,\n mapPaneName,\n zIndex,\n onLoad,\n onUnmount,\n getPixelPositionOffset,\n children,\n}: OverlayViewProps) {\n const map = useContext(MapContext)\n const container = useMemo(() => {\n const div = document.createElement('div')\n div.style.position = 'absolute'\n return div\n }, [])\n\n const overlay = useMemo(() => {\n return createOverlay(\n container,\n mapPaneName,\n position,\n bounds,\n getPixelPositionOffset\n )\n }, [container, mapPaneName, position, bounds])\n\n useEffect(() => {\n onLoad?.(overlay)\n overlay?.setMap(map)\n return () => {\n onUnmount?.(overlay)\n overlay?.setMap(null)\n }\n }, [map, overlay])\n\n // to move the container to the foreground and background\n useEffect(() => {\n container.style.zIndex = `${zIndex}`\n }, [zIndex, container])\n\n return ReactDOM.createPortal(children, container)\n}\n\nexport const OverlayViewF = memo(OverlayViewFunctional)\n\nexport class OverlayView extends PureComponent<\n OverlayViewProps,\n OverlayViewState\n> {\n static FLOAT_PANE: PaneNames = `floatPane`\n static MAP_PANE: PaneNames = `mapPane`\n static MARKER_LAYER: PaneNames = `markerLayer`\n static OVERLAY_LAYER: PaneNames = `overlayLayer`\n static OVERLAY_MOUSE_TARGET: PaneNames = `overlayMouseTarget`\n\n static override contextType = MapContext\n\n declare context: ContextType\n\n override state: OverlayViewState = {\n paneEl: null,\n containerStyle: {\n // set initial position\n position: 'absolute',\n },\n }\n\n overlayView: google.maps.OverlayView\n containerRef: RefObject\n\n updatePane = (): void => {\n const mapPaneName = this.props.mapPaneName\n\n // https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapPanes\n const mapPanes = this.overlayView.getPanes()\n invariant(\n !!mapPaneName,\n `OverlayView requires props.mapPaneName but got %s`,\n mapPaneName\n )\n\n if (mapPanes) {\n this.setState({\n paneEl: mapPanes[mapPaneName],\n })\n } else {\n this.setState({\n paneEl: null,\n })\n }\n }\n\n onAdd = (): void => {\n this.updatePane()\n this.props.onLoad?.(this.overlayView)\n }\n\n onPositionElement = (): void => {\n const mapCanvasProjection = this.overlayView.getProjection()\n\n const offset = {\n x: 0,\n y: 0,\n ...(this.containerRef.current\n ? getOffsetOverride(\n this.containerRef.current,\n this.props.getPixelPositionOffset\n )\n : {}),\n }\n\n const layoutStyles = getLayoutStyles(\n mapCanvasProjection,\n offset,\n this.props.bounds,\n this.props.position\n )\n\n if (\n !arePositionsEqual(layoutStyles, {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n left: this.state.containerStyle.left,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n top: this.state.containerStyle.top,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n width: this.state.containerStyle.width,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n height: this.state.containerStyle.height,\n })\n ) {\n this.setState({\n containerStyle: {\n top: layoutStyles.top ?? 0,\n left: layoutStyles.left ?? 0,\n width: layoutStyles.width ?? 0,\n height: layoutStyles.height ?? 0,\n position: 'absolute',\n },\n })\n }\n }\n\n draw = (): void => {\n this.onPositionElement()\n }\n\n onRemove = (): void => {\n this.setState(() => ({\n paneEl: null,\n }))\n\n this.props.onUnmount?.(this.overlayView)\n }\n\n constructor(props: OverlayViewProps) {\n super(props)\n\n this.containerRef = createRef()\n // You must implement three methods: onAdd(), draw(), and onRemove().\n const overlayView = new google.maps.OverlayView()\n overlayView.onAdd = this.onAdd\n overlayView.draw = this.draw\n overlayView.onRemove = this.onRemove\n this.overlayView = overlayView\n }\n\n override componentDidMount(): void {\n this.overlayView.setMap(this.context)\n }\n\n override componentDidUpdate(prevProps: OverlayViewProps): void {\n const prevPositionString = convertToLatLngString(prevProps.position)\n const positionString = convertToLatLngString(this.props.position)\n const prevBoundsString = convertToLatLngBoundsString(prevProps.bounds)\n const boundsString = convertToLatLngBoundsString(this.props.bounds)\n\n if (\n prevPositionString !== positionString ||\n prevBoundsString !== boundsString\n ) {\n this.overlayView.draw()\n }\n if (prevProps.mapPaneName !== this.props.mapPaneName) {\n this.updatePane()\n }\n }\n\n override componentWillUnmount(): void {\n this.overlayView.setMap(null)\n }\n\n override render(): ReactPortal | ReactNode {\n const paneEl = this.state.paneEl\n if (paneEl) {\n return ReactDOM.createPortal(\n
\n {Children.only(this.props.children)}\n
,\n paneEl\n )\n } else {\n return null\n }\n }\n}\n\nexport default OverlayView\n","import {\n memo,\n useMemo,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\nimport invariant from 'invariant'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport { noop } from '../../utils/noop.js'\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onDblClick: 'dblclick',\n onClick: 'click',\n}\n\nconst updaterMap = {\n opacity(instance: google.maps.GroundOverlay, opacity: number): void {\n instance.setOpacity(opacity)\n },\n}\n\ntype GroundOverlayState = {\n groundOverlay: google.maps.GroundOverlay | null\n}\n\nexport type GroundOverlayProps = {\n options?: google.maps.GroundOverlayOptions | undefined\n /** The opacity of the overlay, expressed as a number between 0 and 1. Optional. Defaults to 1. */\n opacity?: number | undefined\n /** This event is fired when the DOM dblclick event is fired on the GroundOverlay. */\n onDblClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the DOM click event is fired on the GroundOverlay. */\n onClick?: ((e: google.maps.MapMouseEvent) => void) | undefined\n /** The url of the projected image */\n url: string\n /** The bounds that the image will be scaled to fit */\n bounds: google.maps.LatLngBoundsLiteral\n /** This callback is called when the groundOverlay instance has loaded. It is called with the groundOverlay instance. */\n onLoad?: ((groundOverlay: google.maps.GroundOverlay) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the groundOverlay instance. */\n onUnmount?: ((groundOverlay: google.maps.GroundOverlay) => void) | undefined\n visible?: boolean\n}\n\nfunction GroundOverlayFunctional({\n url,\n bounds,\n options,\n visible,\n}: GroundOverlayProps) {\n const map = useContext(MapContext)\n\n const imageBounds = new google.maps.LatLngBounds(\n new google.maps.LatLng(bounds.south, bounds.west),\n new google.maps.LatLng(bounds.north, bounds.east)\n )\n\n const groundOverlay = useMemo(() => {\n return new google.maps.GroundOverlay(url, imageBounds, options)\n }, [])\n\n useEffect(() => {\n if (groundOverlay !== null) {\n groundOverlay.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n if (typeof url !== 'undefined' && groundOverlay !== null) {\n groundOverlay.set('url', url)\n groundOverlay.setMap(map)\n }\n }, [groundOverlay, url])\n\n useEffect(() => {\n if (typeof visible !== 'undefined' && groundOverlay !== null) {\n groundOverlay.setOpacity(visible ? 1 : 0)\n }\n }, [groundOverlay, visible])\n\n useEffect(() => {\n const newBounds = new google.maps.LatLngBounds(\n new google.maps.LatLng(bounds.south, bounds.west),\n new google.maps.LatLng(bounds.north, bounds.east)\n )\n\n if (typeof bounds !== 'undefined' && groundOverlay !== null) {\n groundOverlay.set('bounds', newBounds)\n groundOverlay.setMap(map)\n }\n }, [groundOverlay, bounds])\n\n return null\n}\n\nexport const GroundOverlayF = memo(GroundOverlayFunctional)\n\nexport class GroundOverlay extends PureComponent<\n GroundOverlayProps,\n GroundOverlayState\n> {\n public static defaultProps = {\n onLoad: noop,\n }\n\n static override contextType = MapContext\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: GroundOverlayState = {\n groundOverlay: null,\n }\n\n setGroundOverlayCallback = (): void => {\n if (this.state.groundOverlay !== null && this.props.onLoad) {\n this.props.onLoad(this.state.groundOverlay)\n }\n }\n\n override componentDidMount(): void {\n invariant(\n !!this.props.url || !!this.props.bounds,\n `For GroundOverlay, url and bounds are passed in to constructor and are immutable after instantiated. This is the behavior of Google Maps JavaScript API v3 ( See https://developers.google.com/maps/documentation/javascript/reference#GroundOverlay) Hence, use the corresponding two props provided by \\`react-google-maps-api\\`, url and bounds. In some cases, you'll need the GroundOverlay component to reflect the changes of url and bounds. You can leverage the React's key property to remount the component. Typically, just \\`key={url}\\` would serve your need. See https://github.com/tomchentw/react-google-maps/issues/655`\n )\n\n const groundOverlay = new google.maps.GroundOverlay(\n this.props.url,\n this.props.bounds,\n {\n ...this.props.options,\n map: this.context,\n }\n )\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: groundOverlay,\n })\n\n this.setState(function setGroundOverlay() {\n return {\n groundOverlay,\n }\n }, this.setGroundOverlayCallback)\n }\n\n override componentDidUpdate(prevProps: GroundOverlayProps): void {\n if (this.state.groundOverlay !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.groundOverlay,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.groundOverlay) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.groundOverlay)\n }\n\n this.state.groundOverlay.setMap(null)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default GroundOverlay\n","export function noop(): void { return }\n","import invariant from 'invariant'\nimport {\n memo,\n useState,\n useEffect,\n useContext,\n PureComponent,\n type ContextType,\n} from 'react'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {}\n\nconst updaterMap = {\n data(\n instance: google.maps.visualization.HeatmapLayer,\n data:\n | google.maps.MVCArray<\n google.maps.LatLng | google.maps.visualization.WeightedLocation\n >\n | google.maps.LatLng[]\n | google.maps.visualization.WeightedLocation[]\n ): void {\n instance.setData(data)\n },\n map(\n instance: google.maps.visualization.HeatmapLayer,\n map: google.maps.Map\n ): void {\n instance.setMap(map)\n },\n options(\n instance: google.maps.visualization.HeatmapLayer,\n options: google.maps.visualization.HeatmapLayerOptions\n ): void {\n instance.setOptions(options)\n },\n}\n\ntype HeatmapLayerState = {\n heatmapLayer: google.maps.visualization.HeatmapLayer | null\n}\n\nexport type HeatmapLayerProps = {\n // required\n /** The data points to display. Required. */\n data:\n | google.maps.MVCArray<\n google.maps.LatLng | google.maps.visualization.WeightedLocation\n >\n | google.maps.LatLng[]\n | google.maps.visualization.WeightedLocation[]\n options?: google.maps.visualization.HeatmapLayerOptions | undefined\n /** This callback is called when the heatmapLayer instance has loaded. It is called with the heatmapLayer instance. */\n onLoad?:\n | ((heatmapLayer: google.maps.visualization.HeatmapLayer) => void)\n | undefined\n /** This callback is called when the component unmounts. It is called with the heatmapLayer instance. */\n onUnmount?:\n | ((heatmapLayer: google.maps.visualization.HeatmapLayer) => void)\n | undefined\n}\n\nfunction HeatmapLayerFunctional({\n data,\n onLoad,\n onUnmount,\n options,\n}: HeatmapLayerProps) {\n const map = useContext(MapContext)\n const [instance, setInstance] =\n useState(null)\n\n useEffect(() => {\n if (!google.maps.visualization) {\n invariant(\n !!google.maps.visualization,\n 'Did you include prop libraries={[\"visualization\"]} in useJsApiScript? %s',\n google.maps.visualization\n )\n }\n }, [])\n\n useEffect(() => {\n invariant(!!data, 'data property is required in HeatmapLayer %s', data)\n }, [data])\n\n // Order does matter\n useEffect(() => {\n if (instance !== null) {\n instance.setMap(map)\n }\n }, [map])\n\n useEffect(() => {\n if (options && instance !== null) {\n instance.setOptions(options)\n }\n }, [instance, options])\n\n useEffect(() => {\n const heatmapLayer = new google.maps.visualization.HeatmapLayer({\n ...options,\n data,\n map,\n })\n\n setInstance(heatmapLayer)\n\n if (onLoad) {\n onLoad(heatmapLayer)\n }\n\n return () => {\n if (instance !== null) {\n if (onUnmount) {\n onUnmount(instance)\n }\n\n instance.setMap(null)\n }\n }\n }, [])\n\n return null\n}\n\nexport const HeatmapLayerF = memo(HeatmapLayerFunctional)\n\nexport class HeatmapLayer extends PureComponent<\n HeatmapLayerProps,\n HeatmapLayerState\n> {\n static override contextType = MapContext\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: HeatmapLayerState = {\n heatmapLayer: null,\n }\n\n setHeatmapLayerCallback = (): void => {\n if (this.state.heatmapLayer !== null && this.props.onLoad) {\n this.props.onLoad(this.state.heatmapLayer)\n }\n }\n\n override componentDidMount(): void {\n invariant(\n !!google.maps.visualization,\n 'Did you include prop libraries={[\"visualization\"]} to ? %s',\n google.maps.visualization\n )\n\n invariant(\n !!this.props.data,\n 'data property is required in HeatmapLayer %s',\n this.props.data\n )\n\n const heatmapLayer = new google.maps.visualization.HeatmapLayer({\n ...this.props.options,\n data: this.props.data,\n map: this.context,\n })\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: heatmapLayer,\n })\n\n this.setState(function setHeatmapLayer() {\n return {\n heatmapLayer,\n }\n }, this.setHeatmapLayerCallback)\n }\n\n override componentDidUpdate(prevProps: HeatmapLayerProps): void {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.heatmapLayer,\n })\n }\n\n override componentWillUnmount(): void {\n if (this.state.heatmapLayer !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.heatmapLayer)\n }\n\n unregisterEvents(this.registeredEvents)\n\n this.state.heatmapLayer.setMap(null)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default HeatmapLayer\n","import { type ContextType, PureComponent } from 'react'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onCloseClick: 'closeclick',\n onPanoChanged: 'pano_changed',\n onPositionChanged: 'position_changed',\n onPovChanged: 'pov_changed',\n onResize: 'resize',\n onStatusChanged: 'status_changed',\n onVisibleChanged: 'visible_changed',\n onZoomChanged: 'zoom_changed',\n}\n\nconst updaterMap = {\n register(\n instance: google.maps.StreetViewPanorama,\n provider: (input: string) => google.maps.StreetViewPanoramaData,\n options: google.maps.PanoProviderOptions\n ): void {\n instance.registerPanoProvider(provider, options)\n },\n links(\n instance: google.maps.StreetViewPanorama,\n links: google.maps.StreetViewLink[]\n ): void {\n instance.setLinks(links)\n },\n motionTracking(\n instance: google.maps.StreetViewPanorama,\n motionTracking: boolean\n ): void {\n instance.setMotionTracking(motionTracking)\n },\n options(\n instance: google.maps.StreetViewPanorama,\n options: google.maps.StreetViewPanoramaOptions\n ): void {\n instance.setOptions(options)\n },\n pano(instance: google.maps.StreetViewPanorama, pano: string): void {\n instance.setPano(pano)\n },\n position(\n instance: google.maps.StreetViewPanorama,\n position: google.maps.LatLng | google.maps.LatLngLiteral\n ): void {\n instance.setPosition(position)\n },\n pov(\n instance: google.maps.StreetViewPanorama,\n pov: google.maps.StreetViewPov\n ): void {\n instance.setPov(pov)\n },\n visible(instance: google.maps.StreetViewPanorama, visible: boolean): void {\n instance.setVisible(visible)\n },\n zoom(instance: google.maps.StreetViewPanorama, zoom: number): void {\n instance.setZoom(zoom)\n },\n}\n\ntype StreetViewPanoramaState = {\n streetViewPanorama: google.maps.StreetViewPanorama | null\n}\n\nexport type StreetViewPanoramaProps = {\n options?: google.maps.StreetViewPanoramaOptions | undefined\n /** This event is fired when the close button is clicked. */\n onCloseclick?: ((event: google.maps.MapMouseEvent) => void) | undefined\n /** This event is fired when the panorama's pano id changes. The pano may change as the user navigates through the panorama or the position is manually set. Note that not all position changes trigger a pano_changed. */\n onPanoChanged?: (() => void) | undefined\n /** This event is fired when the panorama's position changes. The position changes as the user navigates through the panorama or the position is set manually. */\n onPositionChanged?: (() => void) | undefined\n /** This event is fired when the panorama's point-of-view changes. The point of view changes as the pitch, zoom, or heading changes. */\n onPovChanged?: (() => void) | undefined\n /** Developers should trigger this event on the panorama when its div changes size: google.maps.event.trigger(panorama, 'resize'). */\n onResize?: (() => void) | undefined\n /** This event is fired after every panorama lookup by id or location, via setPosition() or setPano(). */\n onStatusChanged?: (() => void) | undefined\n /** This event is fired when the panorama's visibility changes. The visibility is changed when the Pegman is dragged onto the map, the close button is clicked, or setVisible() is called. */\n onVisibleChanged?: (() => void) | undefined\n /** This event is fired when the panorama's zoom level changes. */\n onZoomChange?: (() => void) | undefined\n /** This callback is called when the streetViewPanorama instance has loaded. It is called with the streetViewPanorama instance. */\n onLoad?:\n | ((streetViewPanorama: google.maps.StreetViewPanorama) => void)\n | undefined\n /** This callback is called when the component unmounts. It is called with the streetViewPanorama instance. */\n onUnmount?:\n | ((streetViewPanorama: google.maps.StreetViewPanorama) => void)\n | undefined\n}\n\nexport class StreetViewPanorama extends PureComponent<\n StreetViewPanoramaProps,\n StreetViewPanoramaState\n> {\n static override contextType = MapContext\n\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: StreetViewPanoramaState = {\n streetViewPanorama: null,\n }\n\n setStreetViewPanoramaCallback = (): void => {\n if (this.state.streetViewPanorama !== null && this.props.onLoad) {\n this.props.onLoad(this.state.streetViewPanorama)\n }\n }\n\n override componentDidMount(): void {\n const streetViewPanorama = this.context?.getStreetView() ?? null\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: streetViewPanorama,\n })\n\n this.setState(() => {\n return {\n streetViewPanorama,\n }\n }, this.setStreetViewPanoramaCallback)\n }\n\n override componentDidUpdate(prevProps: StreetViewPanoramaProps): void {\n if (this.state.streetViewPanorama !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.streetViewPanorama,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.streetViewPanorama !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.streetViewPanorama)\n }\n\n unregisterEvents(this.registeredEvents)\n\n this.state.streetViewPanorama.setVisible(false)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default StreetViewPanorama\n","import { PureComponent } from 'react'\n\nimport MapContext from '../../map-context.js'\n\nexport type StreetViewServiceProps = {\n /** This callback is called when the streetViewService instance has loaded. It is called with the streetViewService instance. */\n onLoad?:\n | ((streetViewService: google.maps.StreetViewService | null) => void)\n | undefined\n /** This callback is called when the component unmounts. It is called with the streetViewService instance. */\n onUnmount?:\n | ((streetViewService: google.maps.StreetViewService | null) => void)\n | undefined\n}\n\ntype StreetViewServiceState = {\n streetViewService: google.maps.StreetViewService | null\n}\n\nexport class StreetViewService extends PureComponent<\n StreetViewServiceProps,\n StreetViewServiceState\n> {\n static override contextType = MapContext\n\n declare context: React.ContextType\n\n override state = {\n streetViewService: null,\n }\n\n setStreetViewServiceCallback = (): void => {\n if (this.state.streetViewService !== null && this.props.onLoad) {\n this.props.onLoad(this.state.streetViewService)\n }\n }\n\n override componentDidMount(): void {\n const streetViewService = new google.maps.StreetViewService()\n\n this.setState(function setStreetViewService() {\n return {\n streetViewService,\n }\n }, this.setStreetViewServiceCallback)\n }\n\n override componentWillUnmount(): void {\n if (this.state.streetViewService !== null && this.props.onUnmount) {\n this.props.onUnmount(this.state.streetViewService)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default StreetViewService\n","import { PureComponent } from 'react'\nimport invariant from 'invariant'\n\ntype DirectionsServiceState = {\n directionsService: google.maps.DirectionsService | null\n}\n\nexport type DirectionsServiceProps = {\n // required for default functionality\n options: google.maps.DirectionsRequest\n\n // required for default functionality\n callback: (\n // required\n /** The directions response retrieved from the directions server. You can render these using a DirectionsRenderer or parse this object and render it yourself. You must display the warnings and copyrights as noted in the Google Maps Platform Terms of Service. Note that though this result is \"JSON-like,\" it is not strictly JSON, as it indirectly includes LatLng objects */\n result: google.maps.DirectionsResult | null,\n // required\n /** The status returned by the DirectionsService on the completion of a call to route(). Specify these by value, or by using the constant's name. For example, 'OK' or google.maps.DirectionsStatus.OK */\n status: google.maps.DirectionsStatus\n ) => void\n /** This callback is called when the directionsService instance has loaded. It is called with the directionsService instance. */\n onLoad?:\n | ((directionsService: google.maps.DirectionsService) => void)\n | undefined\n /** This callback is called when the component unmounts. It is called with the directionsService instance. */\n onUnmount?:\n | ((directionsService: google.maps.DirectionsService) => void)\n | undefined\n}\n\nexport class DirectionsService extends PureComponent<\n DirectionsServiceProps,\n DirectionsServiceState\n> {\n override state: DirectionsServiceState = {\n directionsService: null,\n }\n\n setDirectionsServiceCallback = (): void => {\n if (this.state.directionsService !== null && this.props.onLoad) {\n this.props.onLoad(this.state.directionsService)\n }\n }\n\n override componentDidMount(): void {\n invariant(\n !!this.props.options,\n 'DirectionsService expected options object as parameter, but got %s',\n this.props.options\n )\n\n const directionsService = new google.maps.DirectionsService()\n\n this.setState(function setDirectionsService() {\n return {\n directionsService,\n }\n }, this.setDirectionsServiceCallback)\n }\n\n override componentDidUpdate(): void {\n if (this.state.directionsService !== null) {\n this.state.directionsService.route(\n this.props.options,\n this.props.callback\n )\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.directionsService !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.directionsService)\n }\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default DirectionsService\n","import { type ContextType, PureComponent } from 'react'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onDirectionsChanged: 'directions_changed',\n}\n\nconst updaterMap = {\n directions(\n instance: google.maps.DirectionsRenderer,\n directions: google.maps.DirectionsResult\n ): void {\n instance.setDirections(directions)\n },\n map(instance: google.maps.DirectionsRenderer, map: google.maps.Map): void {\n instance.setMap(map)\n },\n options(\n instance: google.maps.DirectionsRenderer,\n options: google.maps.DirectionsRendererOptions\n ): void {\n instance.setOptions(options)\n },\n panel(instance: google.maps.DirectionsRenderer, panel: HTMLElement): void {\n instance.setPanel(panel)\n },\n routeIndex(\n instance: google.maps.DirectionsRenderer,\n routeIndex: number\n ): void {\n instance.setRouteIndex(routeIndex)\n },\n}\n\ntype DirectionsRendererState = {\n directionsRenderer: google.maps.DirectionsRenderer | null\n}\n\nexport type DirectionsRendererProps = {\n options?: google.maps.DirectionsRendererOptions | undefined\n /** The directions to display on the map and/or in a
panel, retrieved as a DirectionsResult object from DirectionsService. */\n directions?: google.maps.DirectionsResult | undefined\n /** The
in which to display the directions steps. */\n panel?: HTMLElement | undefined\n /** The index of the route within the DirectionsResult object. The default value is 0. */\n routeIndex?: number | undefined\n /** This event is fired when the rendered directions change, either when a new DirectionsResult is set or when the user finishes dragging a change to the directions path. */\n onDirectionsChanged?: (() => void) | undefined\n /** This callback is called when the directionsRenderer instance has loaded. It is called with the directionsRenderer instance. */\n onLoad?:\n | ((directionsRenderer: google.maps.DirectionsRenderer) => void)\n | undefined\n /** This callback is called when the component unmounts. It is called with the directionsRenderer instance. */\n onUnmount?:\n | ((directionsRenderer: google.maps.DirectionsRenderer) => void)\n | undefined\n}\n\nexport class DirectionsRenderer extends PureComponent<\n DirectionsRendererProps,\n DirectionsRendererState\n> {\n static override contextType = MapContext\n\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n override state: DirectionsRendererState = {\n directionsRenderer: null,\n }\n\n setDirectionsRendererCallback = (): void => {\n if (this.state.directionsRenderer !== null) {\n this.state.directionsRenderer.setMap(this.context)\n\n if (this.props.onLoad) {\n this.props.onLoad(this.state.directionsRenderer)\n }\n }\n }\n\n override componentDidMount(): void {\n const directionsRenderer = new google.maps.DirectionsRenderer(\n this.props.options\n )\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: directionsRenderer,\n })\n\n this.setState(function setDirectionsRenderer() {\n return {\n directionsRenderer,\n }\n }, this.setDirectionsRendererCallback)\n }\n\n override componentDidUpdate(prevProps: DirectionsRendererProps): void {\n if (this.state.directionsRenderer !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.directionsRenderer,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.directionsRenderer !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.directionsRenderer)\n }\n\n unregisterEvents(this.registeredEvents)\n\n if (this.state.directionsRenderer) {\n this.state.directionsRenderer.setMap(null)\n }\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default DirectionsRenderer\n","import { PureComponent } from 'react'\n\nimport invariant from 'invariant'\n\ntype DistanceMatrixServiceState = {\n distanceMatrixService: google.maps.DistanceMatrixService | null\n}\n\nexport type DistanceMatrixServiceProps = {\n // required for default functionality\n options: google.maps.DistanceMatrixRequest\n\n // required for default functionality\n callback: (\n // required\n /** The response to a DistanceMatrixService request, consisting of the formatted origin and destination addresses, and a sequence of DistanceMatrixResponseRows, one for each corresponding origin address. */\n response: google.maps.DistanceMatrixResponse | null,\n // required\n /** The top-level status about the request in general returned by the DistanceMatrixService upon completion of a distance matrix request. Specify these by value, or by using the constant's name. For example, 'OK' or google.maps.DistanceMatrixStatus.OK. */\n status: google.maps.DistanceMatrixStatus\n ) => void\n /** This callback is called when the distanceMatrixService instance has loaded. It is called with the distanceMatrixService instance. */\n onLoad?:\n | ((distanceMatrixService: google.maps.DistanceMatrixService) => void)\n | undefined\n /** This callback is called when the component unmounts. It is called with the distanceMatrixService instance. */\n onUnmount?:\n | ((distanceMatrixService: google.maps.DistanceMatrixService) => void)\n | undefined\n}\n\nexport class DistanceMatrixService extends PureComponent<\n DistanceMatrixServiceProps,\n DistanceMatrixServiceState\n> {\n override state: DistanceMatrixServiceState = {\n distanceMatrixService: null,\n }\n\n setDistanceMatrixServiceCallback = (): void => {\n if (this.state.distanceMatrixService !== null && this.props.onLoad) {\n this.props.onLoad(this.state.distanceMatrixService)\n }\n }\n\n override componentDidMount(): void {\n invariant(\n !!this.props.options,\n 'DistanceMatrixService expected options object as parameter, but go %s',\n this.props.options\n )\n\n const distanceMatrixService = new google.maps.DistanceMatrixService()\n\n this.setState(function setDistanceMatrixService() {\n return {\n distanceMatrixService,\n }\n }, this.setDistanceMatrixServiceCallback)\n }\n\n override componentDidUpdate(): void {\n if (this.state.distanceMatrixService !== null) {\n this.state.distanceMatrixService.getDistanceMatrix(\n this.props.options,\n this.props.callback\n )\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.distanceMatrixService !== null && this.props.onUnmount) {\n this.props.onUnmount(this.state.distanceMatrixService)\n }\n }\n\n override render(): null {\n return null\n }\n}\n\nexport default DistanceMatrixService\n","import {\n Children,\n type JSX,\n createRef,\n PureComponent,\n type ReactNode,\n type RefObject,\n type ContextType,\n} from 'react'\nimport invariant from 'invariant'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onPlacesChanged: 'places_changed',\n}\n\nconst updaterMap = {\n bounds(\n instance: google.maps.places.SearchBox,\n bounds: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral\n ): void {\n instance.setBounds(bounds)\n },\n}\n\ntype StandaloneSearchBoxState = {\n searchBox: google.maps.places.SearchBox | null\n}\n\nexport type StandaloneSearchBoxProps = {\n children?: ReactNode | undefined\n /** The area towards which to bias query predictions. Predictions are biased towards, but not restricted to, queries targeting these bounds. */\n bounds?:\n | google.maps.LatLngBounds\n | google.maps.LatLngBoundsLiteral\n | undefined\n options?: google.maps.places.SearchBoxOptions | undefined\n /** This event is fired when the user selects a query, getPlaces should be used to get new places. */\n onPlacesChanged?: (() => void) | undefined\n /** This callback is called when the searchBox instance has loaded. It is called with the searchBox instance. */\n onLoad?: ((searchBox: google.maps.places.SearchBox) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the searchBox instance. */\n onUnmount?: ((searchBox: google.maps.places.SearchBox) => void) | undefined\n}\n\nclass StandaloneSearchBox extends PureComponent<\n StandaloneSearchBoxProps,\n StandaloneSearchBoxState\n> {\n static override contextType = MapContext\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n\n containerElement: RefObject = createRef()\n\n override state: StandaloneSearchBoxState = {\n searchBox: null,\n }\n\n setSearchBoxCallback = (): void => {\n if (this.state.searchBox !== null && this.props.onLoad) {\n this.props.onLoad(this.state.searchBox)\n }\n }\n\n override componentDidMount(): void {\n invariant(\n !!google.maps.places,\n 'You need to provide libraries={[\"places\"]} prop to component %s',\n google.maps.places\n )\n\n if (\n this.containerElement !== null &&\n this.containerElement.current !== null\n ) {\n const input = this.containerElement.current.querySelector('input')\n\n if (input !== null) {\n const searchBox = new google.maps.places.SearchBox(\n input,\n this.props.options\n )\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: searchBox,\n })\n\n this.setState(function setSearchBox() {\n return {\n searchBox,\n }\n }, this.setSearchBoxCallback)\n }\n }\n }\n\n override componentDidUpdate(prevProps: StandaloneSearchBoxProps): void {\n if (this.state.searchBox !== null) {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.searchBox,\n })\n }\n }\n\n override componentWillUnmount(): void {\n if (this.state.searchBox !== null) {\n if (this.props.onUnmount) {\n this.props.onUnmount(this.state.searchBox)\n }\n\n unregisterEvents(this.registeredEvents)\n }\n }\n\n override render(): JSX.Element {\n return (\n
\n {Children.only(this.props.children)}\n
\n )\n }\n}\n\nexport default StandaloneSearchBox\n","import {\n type JSX,\n Children,\n createRef,\n PureComponent,\n type ReactNode,\n type RefObject,\n type ContextType,\n} from 'react'\nimport invariant from 'invariant'\n\nimport {\n unregisterEvents,\n applyUpdatersToPropsAndRegisterEvents,\n} from '../../utils/helper.js'\n\nimport MapContext from '../../map-context.js'\n\nconst eventMap = {\n onPlaceChanged: 'place_changed',\n}\n\nconst updaterMap = {\n bounds(\n instance: google.maps.places.Autocomplete,\n bounds: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral\n ): void {\n instance.setBounds(bounds)\n },\n restrictions(\n instance: google.maps.places.Autocomplete,\n restrictions: google.maps.places.ComponentRestrictions\n ): void {\n instance.setComponentRestrictions(restrictions)\n },\n fields(instance: google.maps.places.Autocomplete, fields: string[]): void {\n instance.setFields(fields)\n },\n options(\n instance: google.maps.places.Autocomplete,\n options: google.maps.places.AutocompleteOptions\n ): void {\n instance.setOptions(options)\n },\n types(instance: google.maps.places.Autocomplete, types: string[]): void {\n instance.setTypes(types)\n },\n}\n\ntype AutocompleteState = {\n autocomplete: google.maps.places.Autocomplete | null\n}\n\nexport type AutocompleteProps = {\n // required\n children: ReactNode\n /** The area in which to search for places. */\n bounds?:\n | google.maps.LatLngBounds\n | google.maps.LatLngBoundsLiteral\n | undefined\n /** The component restrictions. Component restrictions are used to restrict predictions to only those within the parent component. For example, the country. */\n restrictions?: google.maps.places.ComponentRestrictions | undefined\n /** Fields to be included for the Place in the details response when the details are successfully retrieved. For a list of fields see PlaceResult. Nested fields can be specified with dot-paths (for example, \"geometry.location\"). */\n fields?: string[] | undefined\n options?: google.maps.places.AutocompleteOptions | undefined\n /** The types of predictions to be returned. For a list of supported types, see the developer's guide. If nothing is specified, all types are returned. In general only a single type is allowed. The exception is that you can safely mix the 'geocode' and 'establishment' types, but note that this will have the same effect as specifying no types. */\n types?: string[] | undefined\n /** This event is fired when a PlaceResult is made available for a Place the user has selected. If the user enters the name of a Place that was not suggested by the control and presses the Enter key, or if a Place Details request fails, the PlaceResult contains the user input in the name property, with no other properties defined. */\n onPlaceChanged?: (() => void) | undefined\n /** This callback is called when the autocomplete instance has loaded. It is called with the autocomplete instance. */\n onLoad?: ((autocomplete: google.maps.places.Autocomplete) => void) | undefined\n /** This callback is called when the component unmounts. It is called with the autocomplete instance. */\n onUnmount?:\n | ((autocomplete: google.maps.places.Autocomplete) => void)\n | undefined\n className?: string | undefined\n}\n\nexport class Autocomplete extends PureComponent<\n AutocompleteProps,\n AutocompleteState\n> {\n static defaultProps = {\n className: '',\n }\n\n static override contextType = MapContext\n declare context: ContextType\n\n registeredEvents: google.maps.MapsEventListener[] = []\n containerElement: RefObject = createRef()\n\n override state: AutocompleteState = {\n autocomplete: null,\n }\n\n setAutocompleteCallback = (): void => {\n if (this.state.autocomplete !== null && this.props.onLoad) {\n this.props.onLoad(this.state.autocomplete)\n }\n }\n\n override componentDidMount(): void {\n invariant(\n !!google.maps.places,\n 'You need to provide libraries={[\"places\"]} prop to component %s',\n google.maps.places\n )\n\n // TODO: why current could be equal null?\n\n const input = this.containerElement.current?.querySelector('input')\n\n if (input) {\n const autocomplete = new google.maps.places.Autocomplete(\n input,\n this.props.options\n )\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps: {},\n nextProps: this.props,\n instance: autocomplete,\n })\n\n this.setState(() => {\n return {\n autocomplete,\n }\n }, this.setAutocompleteCallback)\n }\n }\n\n override componentDidUpdate(prevProps: AutocompleteProps): void {\n unregisterEvents(this.registeredEvents)\n\n this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({\n updaterMap,\n eventMap,\n prevProps,\n nextProps: this.props,\n instance: this.state.autocomplete,\n })\n }\n\n override componentWillUnmount(): void {\n if (this.state.autocomplete !== null) {\n unregisterEvents(this.registeredEvents)\n }\n }\n\n override render(): JSX.Element {\n return (\n
\n {Children.only(this.props.children)}\n
\n )\n }\n}\n\nexport default Autocomplete\n","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) {\n if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n }\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n/* eslint-disable react/button-has-type */\n\n\nimport * as React from 'react';\nimport * as PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { polyfill } from 'react-lifecycles-compat';\nimport omit from 'omit.js';\nimport Icon from '../icon';\nimport { ConfigConsumer } from '../config-provider';\nimport Wave from '../_util/wave';\nimport { tuple } from '../_util/type';\nvar rxTwoCNChar = /^[\\u4e00-\\u9fa5]{2}$/;\nvar isTwoCNChar = rxTwoCNChar.test.bind(rxTwoCNChar);\n\nfunction isString(str) {\n return typeof str === 'string';\n} // Insert one space between two chinese characters automatically.\n\n\nfunction insertSpace(child, needInserted) {\n // Check the child if is undefined or null.\n if (child == null) {\n return;\n }\n\n var SPACE = needInserted ? ' ' : ''; // strictNullChecks oops.\n\n if (typeof child !== 'string' && typeof child !== 'number' && isString(child.type) && isTwoCNChar(child.props.children)) {\n return /*#__PURE__*/React.cloneElement(child, {}, child.props.children.split('').join(SPACE));\n }\n\n if (typeof child === 'string') {\n if (isTwoCNChar(child)) {\n child = child.split('').join(SPACE);\n }\n\n return /*#__PURE__*/React.createElement(\"span\", null, child);\n }\n\n return child;\n}\n\nfunction spaceChildren(children, needInserted) {\n var isPrevChildPure = false;\n var childList = [];\n React.Children.forEach(children, function (child) {\n var type = _typeof(child);\n\n var isCurrentChildPure = type === 'string' || type === 'number';\n\n if (isPrevChildPure && isCurrentChildPure) {\n var lastIndex = childList.length - 1;\n var lastChild = childList[lastIndex];\n childList[lastIndex] = \"\".concat(lastChild).concat(child);\n } else {\n childList.push(child);\n }\n\n isPrevChildPure = isCurrentChildPure;\n }); // Pass to React.Children.map to auto fill key\n\n return React.Children.map(childList, function (child) {\n return insertSpace(child, needInserted);\n });\n}\n\nvar ButtonTypes = tuple('default', 'primary', 'ghost', 'dashed', 'danger', 'link');\nvar ButtonShapes = tuple('circle', 'circle-outline', 'round');\nvar ButtonSizes = tuple('large', 'default', 'small');\nvar ButtonHTMLTypes = tuple('submit', 'button', 'reset');\n\nvar Button = /*#__PURE__*/function (_React$Component) {\n _inherits(Button, _React$Component);\n\n var _super = _createSuper(Button);\n\n function Button(props) {\n var _this;\n\n _classCallCheck(this, Button);\n\n _this = _super.call(this, props);\n\n _this.saveButtonRef = function (node) {\n _this.buttonNode = node;\n };\n\n _this.handleClick = function (e) {\n var loading = _this.state.loading;\n var onClick = _this.props.onClick;\n\n if (loading) {\n return;\n }\n\n if (onClick) {\n onClick(e);\n }\n };\n\n _this.renderButton = function (_ref) {\n var _classNames;\n\n var getPrefixCls = _ref.getPrefixCls,\n autoInsertSpaceInButton = _ref.autoInsertSpaceInButton;\n\n var _a = _this.props,\n customizePrefixCls = _a.prefixCls,\n type = _a.type,\n shape = _a.shape,\n size = _a.size,\n className = _a.className,\n children = _a.children,\n icon = _a.icon,\n ghost = _a.ghost,\n block = _a.block,\n rest = __rest(_a, [\"prefixCls\", \"type\", \"shape\", \"size\", \"className\", \"children\", \"icon\", \"ghost\", \"block\"]);\n\n var _this$state = _this.state,\n loading = _this$state.loading,\n hasTwoCNChar = _this$state.hasTwoCNChar;\n var prefixCls = getPrefixCls('btn', customizePrefixCls);\n var autoInsertSpace = autoInsertSpaceInButton !== false; // large => lg\n // small => sm\n\n var sizeCls = '';\n\n switch (size) {\n case 'large':\n sizeCls = 'lg';\n break;\n\n case 'small':\n sizeCls = 'sm';\n break;\n\n default:\n break;\n }\n\n var iconType = loading ? 'loading' : icon;\n var classes = classNames(prefixCls, className, (_classNames = {}, _defineProperty(_classNames, \"\".concat(prefixCls, \"-\").concat(type), type), _defineProperty(_classNames, \"\".concat(prefixCls, \"-\").concat(shape), shape), _defineProperty(_classNames, \"\".concat(prefixCls, \"-\").concat(sizeCls), sizeCls), _defineProperty(_classNames, \"\".concat(prefixCls, \"-icon-only\"), !children && children !== 0 && iconType), _defineProperty(_classNames, \"\".concat(prefixCls, \"-loading\"), !!loading), _defineProperty(_classNames, \"\".concat(prefixCls, \"-background-ghost\"), ghost), _defineProperty(_classNames, \"\".concat(prefixCls, \"-two-chinese-chars\"), hasTwoCNChar && autoInsertSpace), _defineProperty(_classNames, \"\".concat(prefixCls, \"-block\"), block), _classNames));\n var iconNode = iconType ? /*#__PURE__*/React.createElement(Icon, {\n type: iconType\n }) : null;\n var kids = children || children === 0 ? spaceChildren(children, _this.isNeedInserted() && autoInsertSpace) : null;\n var linkButtonRestProps = omit(rest, ['htmlType', 'loading']);\n\n if (linkButtonRestProps.href !== undefined) {\n return /*#__PURE__*/React.createElement(\"a\", _extends({}, linkButtonRestProps, {\n className: classes,\n onClick: _this.handleClick,\n ref: _this.saveButtonRef\n }), iconNode, kids);\n } // React does not recognize the `htmlType` prop on a DOM element. Here we pick it out of `rest`.\n\n\n var _b = rest,\n htmlType = _b.htmlType,\n otherProps = __rest(_b, [\"htmlType\"]);\n\n var buttonNode = /*#__PURE__*/React.createElement(\"button\", _extends({}, omit(otherProps, ['loading']), {\n type: htmlType,\n className: classes,\n onClick: _this.handleClick,\n ref: _this.saveButtonRef\n }), iconNode, kids);\n\n if (type === 'link') {\n return buttonNode;\n }\n\n return /*#__PURE__*/React.createElement(Wave, null, buttonNode);\n };\n\n _this.state = {\n loading: props.loading,\n hasTwoCNChar: false\n };\n return _this;\n }\n\n _createClass(Button, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.fixTwoCNChar();\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate(prevProps) {\n var _this2 = this;\n\n this.fixTwoCNChar();\n\n if (prevProps.loading && typeof prevProps.loading !== 'boolean') {\n clearTimeout(this.delayTimeout);\n }\n\n var loading = this.props.loading;\n\n if (loading && typeof loading !== 'boolean' && loading.delay) {\n this.delayTimeout = window.setTimeout(function () {\n _this2.setState({\n loading: loading\n });\n }, loading.delay);\n } else if (prevProps.loading !== loading) {\n // eslint-disable-next-line react/no-did-update-set-state\n this.setState({\n loading: loading\n });\n }\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n if (this.delayTimeout) {\n clearTimeout(this.delayTimeout);\n }\n }\n }, {\n key: \"fixTwoCNChar\",\n value: function fixTwoCNChar() {\n // Fix for HOC usage like \n if (!this.buttonNode) {\n return;\n }\n\n var buttonText = this.buttonNode.textContent;\n\n if (this.isNeedInserted() && isTwoCNChar(buttonText)) {\n if (!this.state.hasTwoCNChar) {\n this.setState({\n hasTwoCNChar: true\n });\n }\n } else if (this.state.hasTwoCNChar) {\n this.setState({\n hasTwoCNChar: false\n });\n }\n }\n }, {\n key: \"isNeedInserted\",\n value: function isNeedInserted() {\n var _this$props = this.props,\n icon = _this$props.icon,\n children = _this$props.children,\n type = _this$props.type;\n return React.Children.count(children) === 1 && !icon && type !== 'link';\n }\n }, {\n key: \"render\",\n value: function render() {\n return /*#__PURE__*/React.createElement(ConfigConsumer, null, this.renderButton);\n }\n }]);\n\n return Button;\n}(React.Component);\n\nButton.__ANT_BUTTON = true;\nButton.defaultProps = {\n loading: false,\n ghost: false,\n block: false,\n htmlType: 'button'\n};\nButton.propTypes = {\n type: PropTypes.string,\n shape: PropTypes.oneOf(ButtonShapes),\n size: PropTypes.oneOf(ButtonSizes),\n htmlType: PropTypes.oneOf(ButtonHTMLTypes),\n onClick: PropTypes.func,\n loading: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),\n className: PropTypes.string,\n icon: PropTypes.string,\n block: PropTypes.bool,\n title: PropTypes.string\n};\npolyfill(Button);\nexport default Button;","function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) {\n if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n }\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { ConfigConsumer } from '../config-provider';\n\nvar ButtonGroup = function ButtonGroup(props) {\n return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (_ref) {\n var getPrefixCls = _ref.getPrefixCls;\n\n var customizePrefixCls = props.prefixCls,\n size = props.size,\n className = props.className,\n others = __rest(props, [\"prefixCls\", \"size\", \"className\"]);\n\n var prefixCls = getPrefixCls('btn-group', customizePrefixCls); // large => lg\n // small => sm\n\n var sizeCls = '';\n\n switch (size) {\n case 'large':\n sizeCls = 'lg';\n break;\n\n case 'small':\n sizeCls = 'sm';\n break;\n\n default:\n break;\n }\n\n var classes = classNames(prefixCls, _defineProperty({}, \"\".concat(prefixCls, \"-\").concat(sizeCls), sizeCls), className);\n return /*#__PURE__*/React.createElement(\"div\", _extends({}, others, {\n className: classes\n }));\n });\n};\n\nexport default ButtonGroup;","import Button from './button';\nimport ButtonGroup from './button-group';\nButton.Group = ButtonGroup;\nexport default Button;","function isAbsolute(pathname) {\n return pathname.charAt(0) === '/';\n}\n\n// About 1.5x faster than the two-arg version of Array#splice()\nfunction spliceOne(list, index) {\n for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {\n list[i] = list[k];\n }\n\n list.pop();\n}\n\n// This implementation is based heavily on node's url.parse\nfunction resolvePathname(to, from) {\n if (from === undefined) from = '';\n\n var toParts = (to && to.split('/')) || [];\n var fromParts = (from && from.split('/')) || [];\n\n var isToAbs = to && isAbsolute(to);\n var isFromAbs = from && isAbsolute(from);\n var mustEndAbs = isToAbs || isFromAbs;\n\n if (to && isAbsolute(to)) {\n // to is absolute\n fromParts = toParts;\n } else if (toParts.length) {\n // to is relative, drop the filename\n fromParts.pop();\n fromParts = fromParts.concat(toParts);\n }\n\n if (!fromParts.length) return '/';\n\n var hasTrailingSlash;\n if (fromParts.length) {\n var last = fromParts[fromParts.length - 1];\n hasTrailingSlash = last === '.' || last === '..' || last === '';\n } else {\n hasTrailingSlash = false;\n }\n\n var up = 0;\n for (var i = fromParts.length; i >= 0; i--) {\n var part = fromParts[i];\n\n if (part === '.') {\n spliceOne(fromParts, i);\n } else if (part === '..') {\n spliceOne(fromParts, i);\n up++;\n } else if (up) {\n spliceOne(fromParts, i);\n up--;\n }\n }\n\n if (!mustEndAbs) for (; up--; up) fromParts.unshift('..');\n\n if (\n mustEndAbs &&\n fromParts[0] !== '' &&\n (!fromParts[0] || !isAbsolute(fromParts[0]))\n )\n fromParts.unshift('');\n\n var result = fromParts.join('/');\n\n if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';\n\n return result;\n}\n\nexport default resolvePathname;\n","function valueOf(obj) {\n return obj.valueOf ? obj.valueOf() : Object.prototype.valueOf.call(obj);\n}\n\nfunction valueEqual(a, b) {\n // Test for strict equality first.\n if (a === b) return true;\n\n // Otherwise, if either of them == null they are not equal.\n if (a == null || b == null) return false;\n\n if (Array.isArray(a)) {\n return (\n Array.isArray(b) &&\n a.length === b.length &&\n a.every(function(item, index) {\n return valueEqual(item, b[index]);\n })\n );\n }\n\n if (typeof a === 'object' || typeof b === 'object') {\n var aValue = valueOf(a);\n var bValue = valueOf(b);\n\n if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue);\n\n return Object.keys(Object.assign({}, a, b)).every(function(key) {\n return valueEqual(a[key], b[key]);\n });\n }\n\n return false;\n}\n\nexport default valueEqual;\n","import _extends from '@babel/runtime/helpers/esm/extends';\nimport resolvePathname from 'resolve-pathname';\nimport valueEqual from 'value-equal';\nimport warning from 'tiny-warning';\nimport invariant from 'tiny-invariant';\n\nfunction addLeadingSlash(path) {\n return path.charAt(0) === '/' ? path : '/' + path;\n}\nfunction stripLeadingSlash(path) {\n return path.charAt(0) === '/' ? path.substr(1) : path;\n}\nfunction hasBasename(path, prefix) {\n return path.toLowerCase().indexOf(prefix.toLowerCase()) === 0 && '/?#'.indexOf(path.charAt(prefix.length)) !== -1;\n}\nfunction stripBasename(path, prefix) {\n return hasBasename(path, prefix) ? path.substr(prefix.length) : path;\n}\nfunction stripTrailingSlash(path) {\n return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;\n}\nfunction parsePath(path) {\n var pathname = path || '/';\n var search = '';\n var hash = '';\n var hashIndex = pathname.indexOf('#');\n\n if (hashIndex !== -1) {\n hash = pathname.substr(hashIndex);\n pathname = pathname.substr(0, hashIndex);\n }\n\n var searchIndex = pathname.indexOf('?');\n\n if (searchIndex !== -1) {\n search = pathname.substr(searchIndex);\n pathname = pathname.substr(0, searchIndex);\n }\n\n return {\n pathname: pathname,\n search: search === '?' ? '' : search,\n hash: hash === '#' ? '' : hash\n };\n}\nfunction createPath(location) {\n var pathname = location.pathname,\n search = location.search,\n hash = location.hash;\n var path = pathname || '/';\n if (search && search !== '?') path += search.charAt(0) === '?' ? search : \"?\" + search;\n if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : \"#\" + hash;\n return path;\n}\n\nfunction createLocation(path, state, key, currentLocation) {\n var location;\n\n if (typeof path === 'string') {\n // Two-arg form: push(path, state)\n location = parsePath(path);\n location.state = state;\n } else {\n // One-arg form: push(location)\n location = _extends({}, path);\n if (location.pathname === undefined) location.pathname = '';\n\n if (location.search) {\n if (location.search.charAt(0) !== '?') location.search = '?' + location.search;\n } else {\n location.search = '';\n }\n\n if (location.hash) {\n if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;\n } else {\n location.hash = '';\n }\n\n if (state !== undefined && location.state === undefined) location.state = state;\n }\n\n try {\n location.pathname = decodeURI(location.pathname);\n } catch (e) {\n if (e instanceof URIError) {\n throw new URIError('Pathname \"' + location.pathname + '\" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');\n } else {\n throw e;\n }\n }\n\n if (key) location.key = key;\n\n if (currentLocation) {\n // Resolve incomplete/relative pathname relative to current location.\n if (!location.pathname) {\n location.pathname = currentLocation.pathname;\n } else if (location.pathname.charAt(0) !== '/') {\n location.pathname = resolvePathname(location.pathname, currentLocation.pathname);\n }\n } else {\n // When there is no prior location and pathname is empty, set it to /\n if (!location.pathname) {\n location.pathname = '/';\n }\n }\n\n return location;\n}\nfunction locationsAreEqual(a, b) {\n return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual(a.state, b.state);\n}\n\nfunction createTransitionManager() {\n var prompt = null;\n\n function setPrompt(nextPrompt) {\n process.env.NODE_ENV !== \"production\" ? warning(prompt == null, 'A history supports only one prompt at a time') : void 0;\n prompt = nextPrompt;\n return function () {\n if (prompt === nextPrompt) prompt = null;\n };\n }\n\n function confirmTransitionTo(location, action, getUserConfirmation, callback) {\n // TODO: If another transition starts while we're still confirming\n // the previous one, we may end up in a weird state. Figure out the\n // best way to handle this.\n if (prompt != null) {\n var result = typeof prompt === 'function' ? prompt(location, action) : prompt;\n\n if (typeof result === 'string') {\n if (typeof getUserConfirmation === 'function') {\n getUserConfirmation(result, callback);\n } else {\n process.env.NODE_ENV !== \"production\" ? warning(false, 'A history needs a getUserConfirmation function in order to use a prompt message') : void 0;\n callback(true);\n }\n } else {\n // Return false from a transition hook to cancel the transition.\n callback(result !== false);\n }\n } else {\n callback(true);\n }\n }\n\n var listeners = [];\n\n function appendListener(fn) {\n var isActive = true;\n\n function listener() {\n if (isActive) fn.apply(void 0, arguments);\n }\n\n listeners.push(listener);\n return function () {\n isActive = false;\n listeners = listeners.filter(function (item) {\n return item !== listener;\n });\n };\n }\n\n function notifyListeners() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n listeners.forEach(function (listener) {\n return listener.apply(void 0, args);\n });\n }\n\n return {\n setPrompt: setPrompt,\n confirmTransitionTo: confirmTransitionTo,\n appendListener: appendListener,\n notifyListeners: notifyListeners\n };\n}\n\nvar canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);\nfunction getConfirmation(message, callback) {\n callback(window.confirm(message)); // eslint-disable-line no-alert\n}\n/**\n * Returns true if the HTML5 history API is supported. Taken from Modernizr.\n *\n * https://github.com/Modernizr/Modernizr/blob/master/LICENSE\n * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js\n * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586\n */\n\nfunction supportsHistory() {\n var ua = window.navigator.userAgent;\n if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false;\n return window.history && 'pushState' in window.history;\n}\n/**\n * Returns true if browser fires popstate on hash change.\n * IE10 and IE11 do not.\n */\n\nfunction supportsPopStateOnHashChange() {\n return window.navigator.userAgent.indexOf('Trident') === -1;\n}\n/**\n * Returns false if using go(n) with hash history causes a full page reload.\n */\n\nfunction supportsGoWithoutReloadUsingHash() {\n return window.navigator.userAgent.indexOf('Firefox') === -1;\n}\n/**\n * Returns true if a given popstate event is an extraneous WebKit event.\n * Accounts for the fact that Chrome on iOS fires real popstate events\n * containing undefined state when pressing the back button.\n */\n\nfunction isExtraneousPopstateEvent(event) {\n return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;\n}\n\nvar PopStateEvent = 'popstate';\nvar HashChangeEvent = 'hashchange';\n\nfunction getHistoryState() {\n try {\n return window.history.state || {};\n } catch (e) {\n // IE 11 sometimes throws when accessing window.history.state\n // See https://github.com/ReactTraining/history/pull/289\n return {};\n }\n}\n/**\n * Creates a history object that uses the HTML5 history API including\n * pushState, replaceState, and the popstate event.\n */\n\n\nfunction createBrowserHistory(props) {\n if (props === void 0) {\n props = {};\n }\n\n !canUseDOM ? process.env.NODE_ENV !== \"production\" ? invariant(false, 'Browser history needs a DOM') : invariant(false) : void 0;\n var globalHistory = window.history;\n var canUseHistory = supportsHistory();\n var needsHashChangeListener = !supportsPopStateOnHashChange();\n var _props = props,\n _props$forceRefresh = _props.forceRefresh,\n forceRefresh = _props$forceRefresh === void 0 ? false : _props$forceRefresh,\n _props$getUserConfirm = _props.getUserConfirmation,\n getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,\n _props$keyLength = _props.keyLength,\n keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;\n var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';\n\n function getDOMLocation(historyState) {\n var _ref = historyState || {},\n key = _ref.key,\n state = _ref.state;\n\n var _window$location = window.location,\n pathname = _window$location.pathname,\n search = _window$location.search,\n hash = _window$location.hash;\n var path = pathname + search + hash;\n process.env.NODE_ENV !== \"production\" ? warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path \"' + path + '\" to begin with \"' + basename + '\".') : void 0;\n if (basename) path = stripBasename(path, basename);\n return createLocation(path, state, key);\n }\n\n function createKey() {\n return Math.random().toString(36).substr(2, keyLength);\n }\n\n var transitionManager = createTransitionManager();\n\n function setState(nextState) {\n _extends(history, nextState);\n\n history.length = globalHistory.length;\n transitionManager.notifyListeners(history.location, history.action);\n }\n\n function handlePopState(event) {\n // Ignore extraneous popstate events in WebKit.\n if (isExtraneousPopstateEvent(event)) return;\n handlePop(getDOMLocation(event.state));\n }\n\n function handleHashChange() {\n handlePop(getDOMLocation(getHistoryState()));\n }\n\n var forceNextPop = false;\n\n function handlePop(location) {\n if (forceNextPop) {\n forceNextPop = false;\n setState();\n } else {\n var action = 'POP';\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (ok) {\n setState({\n action: action,\n location: location\n });\n } else {\n revertPop(location);\n }\n });\n }\n }\n\n function revertPop(fromLocation) {\n var toLocation = history.location; // TODO: We could probably make this more reliable by\n // keeping a list of keys we've seen in sessionStorage.\n // Instead, we just default to 0 for keys we don't know.\n\n var toIndex = allKeys.indexOf(toLocation.key);\n if (toIndex === -1) toIndex = 0;\n var fromIndex = allKeys.indexOf(fromLocation.key);\n if (fromIndex === -1) fromIndex = 0;\n var delta = toIndex - fromIndex;\n\n if (delta) {\n forceNextPop = true;\n go(delta);\n }\n }\n\n var initialLocation = getDOMLocation(getHistoryState());\n var allKeys = [initialLocation.key]; // Public interface\n\n function createHref(location) {\n return basename + createPath(location);\n }\n\n function push(path, state) {\n process.env.NODE_ENV !== \"production\" ? warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;\n var action = 'PUSH';\n var location = createLocation(path, state, createKey(), history.location);\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n var href = createHref(location);\n var key = location.key,\n state = location.state;\n\n if (canUseHistory) {\n globalHistory.pushState({\n key: key,\n state: state\n }, null, href);\n\n if (forceRefresh) {\n window.location.href = href;\n } else {\n var prevIndex = allKeys.indexOf(history.location.key);\n var nextKeys = allKeys.slice(0, prevIndex + 1);\n nextKeys.push(location.key);\n allKeys = nextKeys;\n setState({\n action: action,\n location: location\n });\n }\n } else {\n process.env.NODE_ENV !== \"production\" ? warning(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history') : void 0;\n window.location.href = href;\n }\n });\n }\n\n function replace(path, state) {\n process.env.NODE_ENV !== \"production\" ? warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;\n var action = 'REPLACE';\n var location = createLocation(path, state, createKey(), history.location);\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n var href = createHref(location);\n var key = location.key,\n state = location.state;\n\n if (canUseHistory) {\n globalHistory.replaceState({\n key: key,\n state: state\n }, null, href);\n\n if (forceRefresh) {\n window.location.replace(href);\n } else {\n var prevIndex = allKeys.indexOf(history.location.key);\n if (prevIndex !== -1) allKeys[prevIndex] = location.key;\n setState({\n action: action,\n location: location\n });\n }\n } else {\n process.env.NODE_ENV !== \"production\" ? warning(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history') : void 0;\n window.location.replace(href);\n }\n });\n }\n\n function go(n) {\n globalHistory.go(n);\n }\n\n function goBack() {\n go(-1);\n }\n\n function goForward() {\n go(1);\n }\n\n var listenerCount = 0;\n\n function checkDOMListeners(delta) {\n listenerCount += delta;\n\n if (listenerCount === 1 && delta === 1) {\n window.addEventListener(PopStateEvent, handlePopState);\n if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange);\n } else if (listenerCount === 0) {\n window.removeEventListener(PopStateEvent, handlePopState);\n if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange);\n }\n }\n\n var isBlocked = false;\n\n function block(prompt) {\n if (prompt === void 0) {\n prompt = false;\n }\n\n var unblock = transitionManager.setPrompt(prompt);\n\n if (!isBlocked) {\n checkDOMListeners(1);\n isBlocked = true;\n }\n\n return function () {\n if (isBlocked) {\n isBlocked = false;\n checkDOMListeners(-1);\n }\n\n return unblock();\n };\n }\n\n function listen(listener) {\n var unlisten = transitionManager.appendListener(listener);\n checkDOMListeners(1);\n return function () {\n checkDOMListeners(-1);\n unlisten();\n };\n }\n\n var history = {\n length: globalHistory.length,\n action: 'POP',\n location: initialLocation,\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n goBack: goBack,\n goForward: goForward,\n block: block,\n listen: listen\n };\n return history;\n}\n\nvar HashChangeEvent$1 = 'hashchange';\nvar HashPathCoders = {\n hashbang: {\n encodePath: function encodePath(path) {\n return path.charAt(0) === '!' ? path : '!/' + stripLeadingSlash(path);\n },\n decodePath: function decodePath(path) {\n return path.charAt(0) === '!' ? path.substr(1) : path;\n }\n },\n noslash: {\n encodePath: stripLeadingSlash,\n decodePath: addLeadingSlash\n },\n slash: {\n encodePath: addLeadingSlash,\n decodePath: addLeadingSlash\n }\n};\n\nfunction stripHash(url) {\n var hashIndex = url.indexOf('#');\n return hashIndex === -1 ? url : url.slice(0, hashIndex);\n}\n\nfunction getHashPath() {\n // We can't use window.location.hash here because it's not\n // consistent across browsers - Firefox will pre-decode it!\n var href = window.location.href;\n var hashIndex = href.indexOf('#');\n return hashIndex === -1 ? '' : href.substring(hashIndex + 1);\n}\n\nfunction pushHashPath(path) {\n window.location.hash = path;\n}\n\nfunction replaceHashPath(path) {\n window.location.replace(stripHash(window.location.href) + '#' + path);\n}\n\nfunction createHashHistory(props) {\n if (props === void 0) {\n props = {};\n }\n\n !canUseDOM ? process.env.NODE_ENV !== \"production\" ? invariant(false, 'Hash history needs a DOM') : invariant(false) : void 0;\n var globalHistory = window.history;\n var canGoWithoutReload = supportsGoWithoutReloadUsingHash();\n var _props = props,\n _props$getUserConfirm = _props.getUserConfirmation,\n getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,\n _props$hashType = _props.hashType,\n hashType = _props$hashType === void 0 ? 'slash' : _props$hashType;\n var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';\n var _HashPathCoders$hashT = HashPathCoders[hashType],\n encodePath = _HashPathCoders$hashT.encodePath,\n decodePath = _HashPathCoders$hashT.decodePath;\n\n function getDOMLocation() {\n var path = decodePath(getHashPath());\n process.env.NODE_ENV !== \"production\" ? warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path \"' + path + '\" to begin with \"' + basename + '\".') : void 0;\n if (basename) path = stripBasename(path, basename);\n return createLocation(path);\n }\n\n var transitionManager = createTransitionManager();\n\n function setState(nextState) {\n _extends(history, nextState);\n\n history.length = globalHistory.length;\n transitionManager.notifyListeners(history.location, history.action);\n }\n\n var forceNextPop = false;\n var ignorePath = null;\n\n function locationsAreEqual$$1(a, b) {\n return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash;\n }\n\n function handleHashChange() {\n var path = getHashPath();\n var encodedPath = encodePath(path);\n\n if (path !== encodedPath) {\n // Ensure we always have a properly-encoded hash.\n replaceHashPath(encodedPath);\n } else {\n var location = getDOMLocation();\n var prevLocation = history.location;\n if (!forceNextPop && locationsAreEqual$$1(prevLocation, location)) return; // A hashchange doesn't always == location change.\n\n if (ignorePath === createPath(location)) return; // Ignore this change; we already setState in push/replace.\n\n ignorePath = null;\n handlePop(location);\n }\n }\n\n function handlePop(location) {\n if (forceNextPop) {\n forceNextPop = false;\n setState();\n } else {\n var action = 'POP';\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (ok) {\n setState({\n action: action,\n location: location\n });\n } else {\n revertPop(location);\n }\n });\n }\n }\n\n function revertPop(fromLocation) {\n var toLocation = history.location; // TODO: We could probably make this more reliable by\n // keeping a list of paths we've seen in sessionStorage.\n // Instead, we just default to 0 for paths we don't know.\n\n var toIndex = allPaths.lastIndexOf(createPath(toLocation));\n if (toIndex === -1) toIndex = 0;\n var fromIndex = allPaths.lastIndexOf(createPath(fromLocation));\n if (fromIndex === -1) fromIndex = 0;\n var delta = toIndex - fromIndex;\n\n if (delta) {\n forceNextPop = true;\n go(delta);\n }\n } // Ensure the hash is encoded properly before doing anything else.\n\n\n var path = getHashPath();\n var encodedPath = encodePath(path);\n if (path !== encodedPath) replaceHashPath(encodedPath);\n var initialLocation = getDOMLocation();\n var allPaths = [createPath(initialLocation)]; // Public interface\n\n function createHref(location) {\n var baseTag = document.querySelector('base');\n var href = '';\n\n if (baseTag && baseTag.getAttribute('href')) {\n href = stripHash(window.location.href);\n }\n\n return href + '#' + encodePath(basename + createPath(location));\n }\n\n function push(path, state) {\n process.env.NODE_ENV !== \"production\" ? warning(state === undefined, 'Hash history cannot push state; it is ignored') : void 0;\n var action = 'PUSH';\n var location = createLocation(path, undefined, undefined, history.location);\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n var path = createPath(location);\n var encodedPath = encodePath(basename + path);\n var hashChanged = getHashPath() !== encodedPath;\n\n if (hashChanged) {\n // We cannot tell if a hashchange was caused by a PUSH, so we'd\n // rather setState here and ignore the hashchange. The caveat here\n // is that other hash histories in the page will consider it a POP.\n ignorePath = path;\n pushHashPath(encodedPath);\n var prevIndex = allPaths.lastIndexOf(createPath(history.location));\n var nextPaths = allPaths.slice(0, prevIndex + 1);\n nextPaths.push(path);\n allPaths = nextPaths;\n setState({\n action: action,\n location: location\n });\n } else {\n process.env.NODE_ENV !== \"production\" ? warning(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack') : void 0;\n setState();\n }\n });\n }\n\n function replace(path, state) {\n process.env.NODE_ENV !== \"production\" ? warning(state === undefined, 'Hash history cannot replace state; it is ignored') : void 0;\n var action = 'REPLACE';\n var location = createLocation(path, undefined, undefined, history.location);\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n var path = createPath(location);\n var encodedPath = encodePath(basename + path);\n var hashChanged = getHashPath() !== encodedPath;\n\n if (hashChanged) {\n // We cannot tell if a hashchange was caused by a REPLACE, so we'd\n // rather setState here and ignore the hashchange. The caveat here\n // is that other hash histories in the page will consider it a POP.\n ignorePath = path;\n replaceHashPath(encodedPath);\n }\n\n var prevIndex = allPaths.indexOf(createPath(history.location));\n if (prevIndex !== -1) allPaths[prevIndex] = path;\n setState({\n action: action,\n location: location\n });\n });\n }\n\n function go(n) {\n process.env.NODE_ENV !== \"production\" ? warning(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser') : void 0;\n globalHistory.go(n);\n }\n\n function goBack() {\n go(-1);\n }\n\n function goForward() {\n go(1);\n }\n\n var listenerCount = 0;\n\n function checkDOMListeners(delta) {\n listenerCount += delta;\n\n if (listenerCount === 1 && delta === 1) {\n window.addEventListener(HashChangeEvent$1, handleHashChange);\n } else if (listenerCount === 0) {\n window.removeEventListener(HashChangeEvent$1, handleHashChange);\n }\n }\n\n var isBlocked = false;\n\n function block(prompt) {\n if (prompt === void 0) {\n prompt = false;\n }\n\n var unblock = transitionManager.setPrompt(prompt);\n\n if (!isBlocked) {\n checkDOMListeners(1);\n isBlocked = true;\n }\n\n return function () {\n if (isBlocked) {\n isBlocked = false;\n checkDOMListeners(-1);\n }\n\n return unblock();\n };\n }\n\n function listen(listener) {\n var unlisten = transitionManager.appendListener(listener);\n checkDOMListeners(1);\n return function () {\n checkDOMListeners(-1);\n unlisten();\n };\n }\n\n var history = {\n length: globalHistory.length,\n action: 'POP',\n location: initialLocation,\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n goBack: goBack,\n goForward: goForward,\n block: block,\n listen: listen\n };\n return history;\n}\n\nfunction clamp(n, lowerBound, upperBound) {\n return Math.min(Math.max(n, lowerBound), upperBound);\n}\n/**\n * Creates a history object that stores locations in memory.\n */\n\n\nfunction createMemoryHistory(props) {\n if (props === void 0) {\n props = {};\n }\n\n var _props = props,\n getUserConfirmation = _props.getUserConfirmation,\n _props$initialEntries = _props.initialEntries,\n initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries,\n _props$initialIndex = _props.initialIndex,\n initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex,\n _props$keyLength = _props.keyLength,\n keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;\n var transitionManager = createTransitionManager();\n\n function setState(nextState) {\n _extends(history, nextState);\n\n history.length = history.entries.length;\n transitionManager.notifyListeners(history.location, history.action);\n }\n\n function createKey() {\n return Math.random().toString(36).substr(2, keyLength);\n }\n\n var index = clamp(initialIndex, 0, initialEntries.length - 1);\n var entries = initialEntries.map(function (entry) {\n return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey());\n }); // Public interface\n\n var createHref = createPath;\n\n function push(path, state) {\n process.env.NODE_ENV !== \"production\" ? warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;\n var action = 'PUSH';\n var location = createLocation(path, state, createKey(), history.location);\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n var prevIndex = history.index;\n var nextIndex = prevIndex + 1;\n var nextEntries = history.entries.slice(0);\n\n if (nextEntries.length > nextIndex) {\n nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);\n } else {\n nextEntries.push(location);\n }\n\n setState({\n action: action,\n location: location,\n index: nextIndex,\n entries: nextEntries\n });\n });\n }\n\n function replace(path, state) {\n process.env.NODE_ENV !== \"production\" ? warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;\n var action = 'REPLACE';\n var location = createLocation(path, state, createKey(), history.location);\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n history.entries[history.index] = location;\n setState({\n action: action,\n location: location\n });\n });\n }\n\n function go(n) {\n var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);\n var action = 'POP';\n var location = history.entries[nextIndex];\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (ok) {\n setState({\n action: action,\n location: location,\n index: nextIndex\n });\n } else {\n // Mimic the behavior of DOM histories by\n // causing a render after a cancelled POP.\n setState();\n }\n });\n }\n\n function goBack() {\n go(-1);\n }\n\n function goForward() {\n go(1);\n }\n\n function canGo(n) {\n var nextIndex = history.index + n;\n return nextIndex >= 0 && nextIndex < history.entries.length;\n }\n\n function block(prompt) {\n if (prompt === void 0) {\n prompt = false;\n }\n\n return transitionManager.setPrompt(prompt);\n }\n\n function listen(listener) {\n return transitionManager.appendListener(listener);\n }\n\n var history = {\n length: entries.length,\n action: 'POP',\n location: entries[index],\n index: index,\n entries: entries,\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n goBack: goBack,\n goForward: goForward,\n canGo: canGo,\n block: block,\n listen: listen\n };\n return history;\n}\n\nexport { createBrowserHistory, createHashHistory, createMemoryHistory, createLocation, locationsAreEqual, parsePath, createPath };\n","'use strict';\n\nvar bind = require('./helpers/bind');\n\n// utils is a library of generic helper functions non-specific to axios\n\nvar toString = Object.prototype.toString;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n\n/**\n * Determine if a value is a Buffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Buffer, otherwise false\n */\nfunction isBuffer(val) {\n return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)\n && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nfunction isFormData(val) {\n return (typeof FormData !== 'undefined') && (val instanceof FormData);\n}\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n var result;\n if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n result = ArrayBuffer.isView(val);\n } else {\n result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n }\n return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\nfunction isString(val) {\n return typeof val === 'string';\n}\n\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\nfunction isObject(val) {\n return val !== null && typeof val === 'object';\n}\n\n/**\n * Determine if a value is a plain Object\n *\n * @param {Object} val The value to test\n * @return {boolean} True if value is a plain Object, otherwise false\n */\nfunction isPlainObject(val) {\n if (toString.call(val) !== '[object Object]') {\n return false;\n }\n\n var prototype = Object.getPrototypeOf(val);\n return prototype === null || prototype === Object.prototype;\n}\n\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n\n/**\n * Determine if a value is a Function\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Function, otherwise false\n */\nfunction isFunction(val) {\n return toString.call(val) === '[object Function]';\n}\n\n/**\n * Determine if a value is a Stream\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Stream, otherwise false\n */\nfunction isStream(val) {\n return isObject(val) && isFunction(val.pipe);\n}\n\n/**\n * Determine if a value is a URLSearchParams object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n */\nfunction isURLSearchParams(val) {\n return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n}\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\nfunction trim(str) {\n return str.trim ? str.trim() : str.replace(/^\\s+|\\s+$/g, '');\n}\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * navigator.product -> 'ReactNative'\n * nativescript\n * navigator.product -> 'NativeScript' or 'NS'\n */\nfunction isStandardBrowserEnv() {\n if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||\n navigator.product === 'NativeScript' ||\n navigator.product === 'NS')) {\n return false;\n }\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined'\n );\n}\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n }\n\n // Force an array if not already something iterable\n if (typeof obj !== 'object') {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n var result = {};\n function assignValue(val, key) {\n if (isPlainObject(result[key]) && isPlainObject(val)) {\n result[key] = merge(result[key], val);\n } else if (isPlainObject(val)) {\n result[key] = merge({}, val);\n } else if (isArray(val)) {\n result[key] = val.slice();\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n return result;\n}\n\n/**\n * Extends object a by mutably adding to it the properties of object b.\n *\n * @param {Object} a The object to be extended\n * @param {Object} b The object to copy properties from\n * @param {Object} thisArg The object to bind function to\n * @return {Object} The resulting value of object a\n */\nfunction extend(a, b, thisArg) {\n forEach(b, function assignValue(val, key) {\n if (thisArg && typeof val === 'function') {\n a[key] = bind(val, thisArg);\n } else {\n a[key] = val;\n }\n });\n return a;\n}\n\n/**\n * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)\n *\n * @param {string} content with BOM\n * @return {string} content value without BOM\n */\nfunction stripBOM(content) {\n if (content.charCodeAt(0) === 0xFEFF) {\n content = content.slice(1);\n }\n return content;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isBuffer: isBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isPlainObject: isPlainObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isFunction: isFunction,\n isStream: isStream,\n isURLSearchParams: isURLSearchParams,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n extend: extend,\n trim: trim,\n stripBOM: stripBOM\n};\n","var core = module.exports = { version: '2.6.12' };\nif (typeof __e == 'number') __e = core; // eslint-disable-line no-undef\n","var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? prefix + \": \" + provided : prefix;\n throw new Error(value);\n}\n\nexport { invariant as default };\n","var baseSet = require('./_baseSet');\n\n/**\n * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,\n * it's created. Arrays are created for missing index properties while objects\n * are created for all other missing properties. Use `_.setWith` to customize\n * `path` creation.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.set(object, 'a[0].b.c', 4);\n * console.log(object.a[0].b.c);\n * // => 4\n *\n * _.set(object, ['x', '0', 'y', 'z'], 5);\n * console.log(object.x[0].y.z);\n * // => 5\n */\nfunction set(object, path, value) {\n return object == null ? object : baseSet(object, path, value);\n}\n\nmodule.exports = set;\n","import unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nexport default function _createForOfIteratorHelper(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n\n if (!it) {\n if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n var i = 0;\n\n var F = function F() {};\n\n return {\n s: F,\n n: function n() {\n if (i >= o.length) return {\n done: true\n };\n return {\n done: false,\n value: o[i++]\n };\n },\n e: function e(_e) {\n throw _e;\n },\n f: F\n };\n }\n\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n }\n\n var normalCompletion = true,\n didErr = false,\n err;\n return {\n s: function s() {\n it = it.call(o);\n },\n n: function n() {\n var step = it.next();\n normalCompletion = step.done;\n return step;\n },\n e: function e(_e2) {\n didErr = true;\n err = _e2;\n },\n f: function f() {\n try {\n if (!normalCompletion && it[\"return\"] != null) it[\"return\"]();\n } finally {\n if (didErr) throw err;\n }\n }\n };\n}","export default function _objectDestructuringEmpty(obj) {\n if (obj == null) throw new TypeError(\"Cannot destructure undefined\");\n}","function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\n// MIT License from https://github.com/kaimallea/isMobile\nvar applePhone = /iPhone/i;\nvar appleIpod = /iPod/i;\nvar appleTablet = /iPad/i;\nvar androidPhone = /\\bAndroid(?:.+)Mobile\\b/i; // Match 'Android' AND 'Mobile'\n\nvar androidTablet = /Android/i;\nvar amazonPhone = /\\bAndroid(?:.+)SD4930UR\\b/i;\nvar amazonTablet = /\\bAndroid(?:.+)(?:KF[A-Z]{2,4})\\b/i;\nvar windowsPhone = /Windows Phone/i;\nvar windowsTablet = /\\bWindows(?:.+)ARM\\b/i; // Match 'Windows' AND 'ARM'\n\nvar otherBlackberry = /BlackBerry/i;\nvar otherBlackberry10 = /BB10/i;\nvar otherOpera = /Opera Mini/i;\nvar otherChrome = /\\b(CriOS|Chrome)(?:.+)Mobile/i;\nvar otherFirefox = /Mobile(?:.+)Firefox\\b/i; // Match 'Mobile' AND 'Firefox'\n\nfunction match(regex, userAgent) {\n return regex.test(userAgent);\n}\n\nfunction isMobile(userAgent) {\n var ua = userAgent || (typeof navigator !== 'undefined' ? navigator.userAgent : ''); // Facebook mobile app's integrated browser adds a bunch of strings that\n // match everything. Strip it out if it exists.\n\n var tmp = ua.split('[FBAN');\n\n if (typeof tmp[1] !== 'undefined') {\n var _tmp = tmp;\n\n var _tmp2 = _slicedToArray(_tmp, 1);\n\n ua = _tmp2[0];\n } // Twitter mobile app's integrated browser on iPad adds a \"Twitter for\n // iPhone\" string. Same probably happens on other tablet platforms.\n // This will confuse detection so strip it out if it exists.\n\n\n tmp = ua.split('Twitter');\n\n if (typeof tmp[1] !== 'undefined') {\n var _tmp3 = tmp;\n\n var _tmp4 = _slicedToArray(_tmp3, 1);\n\n ua = _tmp4[0];\n }\n\n var result = {\n apple: {\n phone: match(applePhone, ua) && !match(windowsPhone, ua),\n ipod: match(appleIpod, ua),\n tablet: !match(applePhone, ua) && match(appleTablet, ua) && !match(windowsPhone, ua),\n device: (match(applePhone, ua) || match(appleIpod, ua) || match(appleTablet, ua)) && !match(windowsPhone, ua)\n },\n amazon: {\n phone: match(amazonPhone, ua),\n tablet: !match(amazonPhone, ua) && match(amazonTablet, ua),\n device: match(amazonPhone, ua) || match(amazonTablet, ua)\n },\n android: {\n phone: !match(windowsPhone, ua) && match(amazonPhone, ua) || !match(windowsPhone, ua) && match(androidPhone, ua),\n tablet: !match(windowsPhone, ua) && !match(amazonPhone, ua) && !match(androidPhone, ua) && (match(amazonTablet, ua) || match(androidTablet, ua)),\n device: !match(windowsPhone, ua) && (match(amazonPhone, ua) || match(amazonTablet, ua) || match(androidPhone, ua) || match(androidTablet, ua)) || match(/\\bokhttp\\b/i, ua)\n },\n windows: {\n phone: match(windowsPhone, ua),\n tablet: match(windowsTablet, ua),\n device: match(windowsPhone, ua) || match(windowsTablet, ua)\n },\n other: {\n blackberry: match(otherBlackberry, ua),\n blackberry10: match(otherBlackberry10, ua),\n opera: match(otherOpera, ua),\n firefox: match(otherFirefox, ua),\n chrome: match(otherChrome, ua),\n device: match(otherBlackberry, ua) || match(otherBlackberry10, ua) || match(otherOpera, ua) || match(otherFirefox, ua) || match(otherChrome, ua)\n },\n // Additional\n any: null,\n phone: null,\n tablet: null\n };\n result.any = result.apple.device || result.android.device || result.windows.device || result.other.device; // excludes 'other' devices and ipods, targeting touchscreen phones\n\n result.phone = result.apple.phone || result.android.phone || result.windows.phone;\n result.tablet = result.apple.tablet || result.android.tablet || result.windows.tablet;\n return result;\n}\n\nvar defaultResult = _objectSpread({}, isMobile(), {\n isMobile: isMobile\n});\n\nexport default defaultResult;","function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nimport * as React from 'react';\nimport isMobile from './utils/isMobile';\nexport function noop() {}\nexport function getKeyFromChildrenIndex(child, menuEventKey, index) {\n var prefix = menuEventKey || '';\n return child.key || \"\".concat(prefix, \"item_\").concat(index);\n}\nexport function getMenuIdFromSubMenuEventKey(eventKey) {\n return \"\".concat(eventKey, \"-menu-\");\n}\nexport function loopMenuItem(children, cb) {\n var index = -1;\n React.Children.forEach(children, function (c) {\n index += 1;\n\n if (c && c.type && c.type.isMenuItemGroup) {\n React.Children.forEach(c.props.children, function (c2) {\n index += 1;\n cb(c2, index);\n });\n } else {\n cb(c, index);\n }\n });\n}\nexport function loopMenuItemRecursively(children, keys, ret) {\n /* istanbul ignore if */\n if (!children || ret.find) {\n return;\n }\n\n React.Children.forEach(children, function (c) {\n if (c) {\n var construct = c.type;\n\n if (!construct || !(construct.isSubMenu || construct.isMenuItem || construct.isMenuItemGroup)) {\n return;\n }\n\n if (keys.indexOf(c.key) !== -1) {\n ret.find = true;\n } else if (c.props.children) {\n loopMenuItemRecursively(c.props.children, keys, ret);\n }\n }\n });\n}\nexport var menuAllProps = ['defaultSelectedKeys', 'selectedKeys', 'defaultOpenKeys', 'openKeys', 'mode', 'getPopupContainer', 'onSelect', 'onDeselect', 'onDestroy', 'openTransitionName', 'openAnimation', 'subMenuOpenDelay', 'subMenuCloseDelay', 'forceSubMenuRender', 'triggerSubMenuAction', 'level', 'selectable', 'multiple', 'onOpenChange', 'visible', 'focusable', 'defaultActiveFirst', 'prefixCls', 'inlineIndent', 'parentMenu', 'title', 'rootPrefixCls', 'eventKey', 'active', 'onItemHover', 'onTitleMouseEnter', 'onTitleMouseLeave', 'onTitleClick', 'popupAlign', 'popupOffset', 'isOpen', 'renderMenuItem', 'manualRef', 'subMenuKey', 'disabled', 'index', 'isSelected', 'store', 'activeKey', 'builtinPlacements', 'overflowedIndicator', 'motion', // the following keys found need to be removed from test regression\n'attribute', 'value', 'popupClassName', 'inlineCollapsed', 'menu', 'theme', 'itemIcon', 'expandIcon']; // ref: https://github.com/ant-design/ant-design/issues/14007\n// ref: https://bugs.chromium.org/p/chromium/issues/detail?id=360889\n// getBoundingClientRect return the full precision value, which is\n// not the same behavior as on chrome. Set the precision to 6 to\n// unify their behavior\n\nexport var getWidth = function getWidth(elem) {\n var width = elem && typeof elem.getBoundingClientRect === 'function' && elem.getBoundingClientRect().width;\n\n if (width) {\n width = +width.toFixed(6);\n }\n\n return width || 0;\n};\nexport var setStyle = function setStyle(elem, styleProperty, value) {\n if (elem && _typeof(elem.style) === 'object') {\n elem.style[styleProperty] = value;\n }\n};\nexport var isMobileDevice = function isMobileDevice() {\n return isMobile.any;\n};","var autoAdjustOverflow = {\n adjustX: 1,\n adjustY: 1\n};\nexport var placements = {\n topLeft: {\n points: ['bl', 'tl'],\n overflow: autoAdjustOverflow,\n offset: [0, -7]\n },\n bottomLeft: {\n points: ['tl', 'bl'],\n overflow: autoAdjustOverflow,\n offset: [0, 7]\n },\n leftTop: {\n points: ['tr', 'tl'],\n overflow: autoAdjustOverflow,\n offset: [-4, 0]\n },\n rightTop: {\n points: ['tl', 'tr'],\n overflow: autoAdjustOverflow,\n offset: [4, 0]\n }\n};\nexport default placements;","function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport Trigger from 'rc-trigger';\nimport KeyCode from \"rc-util/es/KeyCode\"; // import Animate from 'rc-animate';\n\nimport CSSMotion from \"rc-animate/es/CSSMotion\";\nimport classNames from 'classnames';\nimport { connect } from 'mini-store';\nimport SubPopupMenu from './SubPopupMenu';\nimport placements from './placements';\nimport { noop, loopMenuItemRecursively, getMenuIdFromSubMenuEventKey, menuAllProps } from './util';\nvar guid = 0;\nvar popupPlacementMap = {\n horizontal: 'bottomLeft',\n vertical: 'rightTop',\n 'vertical-left': 'rightTop',\n 'vertical-right': 'leftTop'\n};\n\nvar updateDefaultActiveFirst = function updateDefaultActiveFirst(store, eventKey, defaultActiveFirst) {\n var menuId = getMenuIdFromSubMenuEventKey(eventKey);\n var state = store.getState();\n store.setState({\n defaultActiveFirst: _objectSpread({}, state.defaultActiveFirst, _defineProperty({}, menuId, defaultActiveFirst))\n });\n};\n\nexport var SubMenu =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inherits(SubMenu, _React$Component);\n\n function SubMenu(props) {\n var _this;\n\n _classCallCheck(this, SubMenu);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(SubMenu).call(this, props));\n\n _this.onDestroy = function (key) {\n _this.props.onDestroy(key);\n };\n /**\n * note:\n * This legacy code that `onKeyDown` is called by parent instead of dom self.\n * which need return code to check if this event is handled\n */\n\n\n _this.onKeyDown = function (e) {\n var keyCode = e.keyCode;\n var menu = _this.menuInstance;\n var _this$props = _this.props,\n isOpen = _this$props.isOpen,\n store = _this$props.store;\n\n if (keyCode === KeyCode.ENTER) {\n _this.onTitleClick(e);\n\n updateDefaultActiveFirst(store, _this.props.eventKey, true);\n return true;\n }\n\n if (keyCode === KeyCode.RIGHT) {\n if (isOpen) {\n menu.onKeyDown(e);\n } else {\n _this.triggerOpenChange(true); // need to update current menu's defaultActiveFirst value\n\n\n updateDefaultActiveFirst(store, _this.props.eventKey, true);\n }\n\n return true;\n }\n\n if (keyCode === KeyCode.LEFT) {\n var handled;\n\n if (isOpen) {\n handled = menu.onKeyDown(e);\n } else {\n return undefined;\n }\n\n if (!handled) {\n _this.triggerOpenChange(false);\n\n handled = true;\n }\n\n return handled;\n }\n\n if (isOpen && (keyCode === KeyCode.UP || keyCode === KeyCode.DOWN)) {\n return menu.onKeyDown(e);\n }\n\n return undefined;\n };\n\n _this.onOpenChange = function (e) {\n _this.props.onOpenChange(e);\n };\n\n _this.onPopupVisibleChange = function (visible) {\n _this.triggerOpenChange(visible, visible ? 'mouseenter' : 'mouseleave');\n };\n\n _this.onMouseEnter = function (e) {\n var _this$props2 = _this.props,\n key = _this$props2.eventKey,\n onMouseEnter = _this$props2.onMouseEnter,\n store = _this$props2.store;\n updateDefaultActiveFirst(store, _this.props.eventKey, false);\n onMouseEnter({\n key: key,\n domEvent: e\n });\n };\n\n _this.onMouseLeave = function (e) {\n var _this$props3 = _this.props,\n parentMenu = _this$props3.parentMenu,\n eventKey = _this$props3.eventKey,\n onMouseLeave = _this$props3.onMouseLeave;\n parentMenu.subMenuInstance = _assertThisInitialized(_this);\n onMouseLeave({\n key: eventKey,\n domEvent: e\n });\n };\n\n _this.onTitleMouseEnter = function (domEvent) {\n var _this$props4 = _this.props,\n key = _this$props4.eventKey,\n onItemHover = _this$props4.onItemHover,\n onTitleMouseEnter = _this$props4.onTitleMouseEnter;\n onItemHover({\n key: key,\n hover: true\n });\n onTitleMouseEnter({\n key: key,\n domEvent: domEvent\n });\n };\n\n _this.onTitleMouseLeave = function (e) {\n var _this$props5 = _this.props,\n parentMenu = _this$props5.parentMenu,\n eventKey = _this$props5.eventKey,\n onItemHover = _this$props5.onItemHover,\n onTitleMouseLeave = _this$props5.onTitleMouseLeave;\n parentMenu.subMenuInstance = _assertThisInitialized(_this);\n onItemHover({\n key: eventKey,\n hover: false\n });\n onTitleMouseLeave({\n key: eventKey,\n domEvent: e\n });\n };\n\n _this.onTitleClick = function (e) {\n var _assertThisInitialize = _assertThisInitialized(_this),\n props = _assertThisInitialize.props;\n\n props.onTitleClick({\n key: props.eventKey,\n domEvent: e\n });\n\n if (props.triggerSubMenuAction === 'hover') {\n return;\n }\n\n _this.triggerOpenChange(!props.isOpen, 'click');\n\n updateDefaultActiveFirst(props.store, _this.props.eventKey, false);\n };\n\n _this.onSubMenuClick = function (info) {\n // in the case of overflowed submenu\n // onClick is not copied over\n if (typeof _this.props.onClick === 'function') {\n _this.props.onClick(_this.addKeyPath(info));\n }\n };\n\n _this.onSelect = function (info) {\n _this.props.onSelect(info);\n };\n\n _this.onDeselect = function (info) {\n _this.props.onDeselect(info);\n };\n\n _this.getPrefixCls = function () {\n return \"\".concat(_this.props.rootPrefixCls, \"-submenu\");\n };\n\n _this.getActiveClassName = function () {\n return \"\".concat(_this.getPrefixCls(), \"-active\");\n };\n\n _this.getDisabledClassName = function () {\n return \"\".concat(_this.getPrefixCls(), \"-disabled\");\n };\n\n _this.getSelectedClassName = function () {\n return \"\".concat(_this.getPrefixCls(), \"-selected\");\n };\n\n _this.getOpenClassName = function () {\n return \"\".concat(_this.props.rootPrefixCls, \"-submenu-open\");\n };\n\n _this.saveMenuInstance = function (c) {\n // children menu instance\n _this.menuInstance = c;\n };\n\n _this.addKeyPath = function (info) {\n return _objectSpread({}, info, {\n keyPath: (info.keyPath || []).concat(_this.props.eventKey)\n });\n };\n\n _this.triggerOpenChange = function (open, type) {\n var key = _this.props.eventKey;\n\n var openChange = function openChange() {\n _this.onOpenChange({\n key: key,\n item: _assertThisInitialized(_this),\n trigger: type,\n open: open\n });\n };\n\n if (type === 'mouseenter') {\n // make sure mouseenter happen after other menu item's mouseleave\n _this.mouseenterTimeout = setTimeout(function () {\n openChange();\n }, 0);\n } else {\n openChange();\n }\n };\n\n _this.isChildrenSelected = function () {\n var ret = {\n find: false\n };\n loopMenuItemRecursively(_this.props.children, _this.props.selectedKeys, ret);\n return ret.find;\n };\n\n _this.isOpen = function () {\n return _this.props.openKeys.indexOf(_this.props.eventKey) !== -1;\n };\n\n _this.adjustWidth = function () {\n /* istanbul ignore if */\n if (!_this.subMenuTitle || !_this.menuInstance) {\n return;\n }\n\n var popupMenu = ReactDOM.findDOMNode(_this.menuInstance);\n\n if (popupMenu.offsetWidth >= _this.subMenuTitle.offsetWidth) {\n return;\n }\n /* istanbul ignore next */\n\n\n popupMenu.style.minWidth = \"\".concat(_this.subMenuTitle.offsetWidth, \"px\");\n };\n\n _this.saveSubMenuTitle = function (subMenuTitle) {\n _this.subMenuTitle = subMenuTitle;\n };\n\n var store = props.store,\n eventKey = props.eventKey;\n\n var _store$getState = store.getState(),\n defaultActiveFirst = _store$getState.defaultActiveFirst;\n\n _this.isRootMenu = false;\n var value = false;\n\n if (defaultActiveFirst) {\n value = defaultActiveFirst[eventKey];\n }\n\n updateDefaultActiveFirst(store, eventKey, value);\n return _this;\n }\n\n _createClass(SubMenu, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.componentDidUpdate();\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n var _this2 = this;\n\n var _this$props6 = this.props,\n mode = _this$props6.mode,\n parentMenu = _this$props6.parentMenu,\n manualRef = _this$props6.manualRef; // invoke customized ref to expose component to mixin\n\n if (manualRef) {\n manualRef(this);\n }\n\n if (mode !== 'horizontal' || !parentMenu.isRootMenu || !this.props.isOpen) {\n return;\n }\n\n this.minWidthTimeout = setTimeout(function () {\n return _this2.adjustWidth();\n }, 0);\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n var _this$props7 = this.props,\n onDestroy = _this$props7.onDestroy,\n eventKey = _this$props7.eventKey;\n\n if (onDestroy) {\n onDestroy(eventKey);\n }\n /* istanbul ignore if */\n\n\n if (this.minWidthTimeout) {\n clearTimeout(this.minWidthTimeout);\n }\n /* istanbul ignore if */\n\n\n if (this.mouseenterTimeout) {\n clearTimeout(this.mouseenterTimeout);\n }\n }\n }, {\n key: \"renderChildren\",\n value: function renderChildren(children) {\n var _this3 = this;\n\n var props = this.props;\n var baseProps = {\n mode: props.mode === 'horizontal' ? 'vertical' : props.mode,\n visible: this.props.isOpen,\n level: props.level + 1,\n inlineIndent: props.inlineIndent,\n focusable: false,\n onClick: this.onSubMenuClick,\n onSelect: this.onSelect,\n onDeselect: this.onDeselect,\n onDestroy: this.onDestroy,\n selectedKeys: props.selectedKeys,\n eventKey: \"\".concat(props.eventKey, \"-menu-\"),\n openKeys: props.openKeys,\n motion: props.motion,\n onOpenChange: this.onOpenChange,\n subMenuOpenDelay: props.subMenuOpenDelay,\n parentMenu: this,\n subMenuCloseDelay: props.subMenuCloseDelay,\n forceSubMenuRender: props.forceSubMenuRender,\n triggerSubMenuAction: props.triggerSubMenuAction,\n builtinPlacements: props.builtinPlacements,\n defaultActiveFirst: props.store.getState().defaultActiveFirst[getMenuIdFromSubMenuEventKey(props.eventKey)],\n multiple: props.multiple,\n prefixCls: props.rootPrefixCls,\n id: this.internalMenuId,\n manualRef: this.saveMenuInstance,\n itemIcon: props.itemIcon,\n expandIcon: props.expandIcon\n };\n var haveRendered = this.haveRendered;\n this.haveRendered = true;\n this.haveOpened = this.haveOpened || baseProps.visible || baseProps.forceSubMenuRender; // never rendered not planning to, don't render\n\n if (!this.haveOpened) {\n return React.createElement(\"div\", null);\n } // ================== Motion ==================\n // don't show transition on first rendering (no animation for opened menu)\n // show appear transition if it's not visible (not sure why)\n // show appear transition if it's not inline mode\n\n\n var mergedMotion = _objectSpread({}, props.motion, {\n leavedClassName: \"\".concat(props.rootPrefixCls, \"-hidden\"),\n removeOnLeave: false,\n motionAppear: haveRendered || !baseProps.visible || baseProps.mode !== 'inline'\n });\n\n return React.createElement(CSSMotion, Object.assign({\n visible: baseProps.visible\n }, mergedMotion), function (_ref) {\n var className = _ref.className,\n style = _ref.style;\n var mergedClassName = classNames(\"\".concat(baseProps.prefixCls, \"-sub\"), className);\n return React.createElement(SubPopupMenu, Object.assign({}, baseProps, {\n id: _this3.internalMenuId,\n className: mergedClassName,\n style: style\n }), children);\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n var _classNames;\n\n var props = _objectSpread({}, this.props);\n\n var isOpen = props.isOpen;\n var prefixCls = this.getPrefixCls();\n var isInlineMode = props.mode === 'inline';\n var className = classNames(prefixCls, \"\".concat(prefixCls, \"-\").concat(props.mode), (_classNames = {}, _defineProperty(_classNames, props.className, !!props.className), _defineProperty(_classNames, this.getOpenClassName(), isOpen), _defineProperty(_classNames, this.getActiveClassName(), props.active || isOpen && !isInlineMode), _defineProperty(_classNames, this.getDisabledClassName(), props.disabled), _defineProperty(_classNames, this.getSelectedClassName(), this.isChildrenSelected()), _classNames));\n\n if (!this.internalMenuId) {\n if (props.eventKey) {\n this.internalMenuId = \"\".concat(props.eventKey, \"$Menu\");\n } else {\n guid += 1;\n this.internalMenuId = \"$__$\".concat(guid, \"$Menu\");\n }\n }\n\n var mouseEvents = {};\n var titleClickEvents = {};\n var titleMouseEvents = {};\n\n if (!props.disabled) {\n mouseEvents = {\n onMouseLeave: this.onMouseLeave,\n onMouseEnter: this.onMouseEnter\n }; // only works in title, not outer li\n\n titleClickEvents = {\n onClick: this.onTitleClick\n };\n titleMouseEvents = {\n onMouseEnter: this.onTitleMouseEnter,\n onMouseLeave: this.onTitleMouseLeave\n };\n }\n\n var style = {};\n\n if (isInlineMode) {\n style.paddingLeft = props.inlineIndent * props.level;\n }\n\n var ariaOwns = {}; // only set aria-owns when menu is open\n // otherwise it would be an invalid aria-owns value\n // since corresponding node cannot be found\n\n if (this.props.isOpen) {\n ariaOwns = {\n 'aria-owns': this.internalMenuId\n };\n } // expand custom icon should NOT be displayed in menu with horizontal mode.\n\n\n var icon = null;\n\n if (props.mode !== 'horizontal') {\n icon = this.props.expandIcon; // ReactNode\n\n if (typeof this.props.expandIcon === 'function') {\n icon = React.createElement(this.props.expandIcon, _objectSpread({}, this.props));\n }\n }\n\n var title = React.createElement(\"div\", Object.assign({\n ref: this.saveSubMenuTitle,\n style: style,\n className: \"\".concat(prefixCls, \"-title\")\n }, titleMouseEvents, titleClickEvents, {\n \"aria-expanded\": isOpen\n }, ariaOwns, {\n \"aria-haspopup\": \"true\",\n title: typeof props.title === 'string' ? props.title : undefined\n }), props.title, icon || React.createElement(\"i\", {\n className: \"\".concat(prefixCls, \"-arrow\")\n }));\n var children = this.renderChildren(props.children);\n var getPopupContainer = props.parentMenu.isRootMenu ? props.parentMenu.props.getPopupContainer : function (triggerNode) {\n return triggerNode.parentNode;\n };\n var popupPlacement = popupPlacementMap[props.mode];\n var popupAlign = props.popupOffset ? {\n offset: props.popupOffset\n } : {};\n var popupClassName = props.mode === 'inline' ? '' : props.popupClassName;\n var disabled = props.disabled,\n triggerSubMenuAction = props.triggerSubMenuAction,\n subMenuOpenDelay = props.subMenuOpenDelay,\n forceSubMenuRender = props.forceSubMenuRender,\n subMenuCloseDelay = props.subMenuCloseDelay,\n builtinPlacements = props.builtinPlacements;\n menuAllProps.forEach(function (key) {\n return delete props[key];\n }); // Set onClick to null, to ignore propagated onClick event\n\n delete props.onClick;\n return React.createElement(\"li\", Object.assign({}, props, mouseEvents, {\n className: className,\n role: \"menuitem\"\n }), isInlineMode && title, isInlineMode && children, !isInlineMode && React.createElement(Trigger, {\n prefixCls: prefixCls,\n popupClassName: \"\".concat(prefixCls, \"-popup \").concat(popupClassName),\n getPopupContainer: getPopupContainer,\n builtinPlacements: Object.assign({}, placements, builtinPlacements),\n popupPlacement: popupPlacement,\n popupVisible: isOpen,\n popupAlign: popupAlign,\n popup: children,\n action: disabled ? [] : [triggerSubMenuAction],\n mouseEnterDelay: subMenuOpenDelay,\n mouseLeaveDelay: subMenuCloseDelay,\n onPopupVisibleChange: this.onPopupVisibleChange,\n forceRender: forceSubMenuRender\n }, title));\n }\n }]);\n\n return SubMenu;\n}(React.Component);\nSubMenu.defaultProps = {\n onMouseEnter: noop,\n onMouseLeave: noop,\n onTitleMouseEnter: noop,\n onTitleMouseLeave: noop,\n onTitleClick: noop,\n manualRef: noop,\n mode: 'vertical',\n title: ''\n};\nvar connected = connect(function (_ref2, _ref3) {\n var openKeys = _ref2.openKeys,\n activeKey = _ref2.activeKey,\n selectedKeys = _ref2.selectedKeys;\n var eventKey = _ref3.eventKey,\n subMenuKey = _ref3.subMenuKey;\n return {\n isOpen: openKeys.indexOf(eventKey) > -1,\n active: activeKey[subMenuKey] === eventKey,\n selectedKeys: selectedKeys\n };\n})(SubMenu);\nconnected.isSubMenu = true;\nexport default connected;","function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport ResizeObserver from 'resize-observer-polyfill';\nimport SubMenu from './SubMenu';\nimport { getWidth, setStyle, menuAllProps } from './util';\nvar canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);\nvar MENUITEM_OVERFLOWED_CLASSNAME = 'menuitem-overflowed';\nvar FLOAT_PRECISION_ADJUST = 0.5; // Fix ssr\n\nif (canUseDOM) {\n // eslint-disable-next-line global-require\n require('mutationobserver-shim');\n}\n\nvar DOMWrap =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inherits(DOMWrap, _React$Component);\n\n function DOMWrap() {\n var _this;\n\n _classCallCheck(this, DOMWrap);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(DOMWrap).apply(this, arguments));\n _this.resizeObserver = null;\n _this.mutationObserver = null; // original scroll size of the list\n\n _this.originalTotalWidth = 0; // copy of overflowed items\n\n _this.overflowedItems = []; // cache item of the original items (so we can track the size and order)\n\n _this.menuItemSizes = [];\n _this.state = {\n lastVisibleIndex: undefined\n }; // get all valid menuItem nodes\n\n _this.getMenuItemNodes = function () {\n var prefixCls = _this.props.prefixCls;\n var ul = ReactDOM.findDOMNode(_assertThisInitialized(_this));\n\n if (!ul) {\n return [];\n } // filter out all overflowed indicator placeholder\n\n\n return [].slice.call(ul.children).filter(function (node) {\n return node.className.split(' ').indexOf(\"\".concat(prefixCls, \"-overflowed-submenu\")) < 0;\n });\n };\n\n _this.getOverflowedSubMenuItem = function (keyPrefix, overflowedItems, renderPlaceholder) {\n var _this$props = _this.props,\n overflowedIndicator = _this$props.overflowedIndicator,\n level = _this$props.level,\n mode = _this$props.mode,\n prefixCls = _this$props.prefixCls,\n theme = _this$props.theme;\n\n if (level !== 1 || mode !== 'horizontal') {\n return null;\n } // put all the overflowed item inside a submenu\n // with a title of overflow indicator ('...')\n\n\n var copy = _this.props.children[0];\n\n var _copy$props = copy.props,\n throwAway = _copy$props.children,\n title = _copy$props.title,\n propStyle = _copy$props.style,\n rest = _objectWithoutProperties(_copy$props, [\"children\", \"title\", \"style\"]);\n\n var style = _objectSpread({}, propStyle);\n\n var key = \"\".concat(keyPrefix, \"-overflowed-indicator\");\n var eventKey = \"\".concat(keyPrefix, \"-overflowed-indicator\");\n\n if (overflowedItems.length === 0 && renderPlaceholder !== true) {\n style = _objectSpread({}, style, {\n display: 'none'\n });\n } else if (renderPlaceholder) {\n style = _objectSpread({}, style, {\n visibility: 'hidden',\n // prevent from taking normal dom space\n position: 'absolute'\n });\n key = \"\".concat(key, \"-placeholder\");\n eventKey = \"\".concat(eventKey, \"-placeholder\");\n }\n\n var popupClassName = theme ? \"\".concat(prefixCls, \"-\").concat(theme) : '';\n var props = {};\n menuAllProps.forEach(function (k) {\n if (rest[k] !== undefined) {\n props[k] = rest[k];\n }\n });\n return React.createElement(SubMenu, Object.assign({\n title: overflowedIndicator,\n className: \"\".concat(prefixCls, \"-overflowed-submenu\"),\n popupClassName: popupClassName\n }, props, {\n key: key,\n eventKey: eventKey,\n disabled: false,\n style: style\n }), overflowedItems);\n }; // memorize rendered menuSize\n\n\n _this.setChildrenWidthAndResize = function () {\n if (_this.props.mode !== 'horizontal') {\n return;\n }\n\n var ul = ReactDOM.findDOMNode(_assertThisInitialized(_this));\n\n if (!ul) {\n return;\n }\n\n var ulChildrenNodes = ul.children;\n\n if (!ulChildrenNodes || ulChildrenNodes.length === 0) {\n return;\n }\n\n var lastOverflowedIndicatorPlaceholder = ul.children[ulChildrenNodes.length - 1]; // need last overflowed indicator for calculating length;\n\n setStyle(lastOverflowedIndicatorPlaceholder, 'display', 'inline-block');\n\n var menuItemNodes = _this.getMenuItemNodes(); // reset display attribute for all hidden elements caused by overflow to calculate updated width\n // and then reset to original state after width calculation\n\n\n var overflowedItems = menuItemNodes.filter(function (c) {\n return c.className.split(' ').indexOf(MENUITEM_OVERFLOWED_CLASSNAME) >= 0;\n });\n overflowedItems.forEach(function (c) {\n setStyle(c, 'display', 'inline-block');\n });\n _this.menuItemSizes = menuItemNodes.map(function (c) {\n return getWidth(c);\n });\n overflowedItems.forEach(function (c) {\n setStyle(c, 'display', 'none');\n });\n _this.overflowedIndicatorWidth = getWidth(ul.children[ul.children.length - 1]);\n _this.originalTotalWidth = _this.menuItemSizes.reduce(function (acc, cur) {\n return acc + cur;\n }, 0);\n\n _this.handleResize(); // prevent the overflowed indicator from taking space;\n\n\n setStyle(lastOverflowedIndicatorPlaceholder, 'display', 'none');\n };\n\n _this.handleResize = function () {\n if (_this.props.mode !== 'horizontal') {\n return;\n }\n\n var ul = ReactDOM.findDOMNode(_assertThisInitialized(_this));\n\n if (!ul) {\n return;\n }\n\n var width = getWidth(ul);\n _this.overflowedItems = [];\n var currentSumWidth = 0; // index for last visible child in horizontal mode\n\n var lastVisibleIndex; // float number comparison could be problematic\n // e.g. 0.1 + 0.2 > 0.3 =====> true\n // thus using FLOAT_PRECISION_ADJUST as buffer to help the situation\n\n if (_this.originalTotalWidth > width + FLOAT_PRECISION_ADJUST) {\n lastVisibleIndex = -1;\n\n _this.menuItemSizes.forEach(function (liWidth) {\n currentSumWidth += liWidth;\n\n if (currentSumWidth + _this.overflowedIndicatorWidth <= width) {\n lastVisibleIndex += 1;\n }\n });\n }\n\n _this.setState({\n lastVisibleIndex: lastVisibleIndex\n });\n };\n\n return _this;\n }\n\n _createClass(DOMWrap, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this2 = this;\n\n this.setChildrenWidthAndResize();\n\n if (this.props.level === 1 && this.props.mode === 'horizontal') {\n var menuUl = ReactDOM.findDOMNode(this);\n\n if (!menuUl) {\n return;\n }\n\n this.resizeObserver = new ResizeObserver(function (entries) {\n entries.forEach(_this2.setChildrenWidthAndResize);\n });\n [].slice.call(menuUl.children).concat(menuUl).forEach(function (el) {\n _this2.resizeObserver.observe(el);\n });\n\n if (typeof MutationObserver !== 'undefined') {\n this.mutationObserver = new MutationObserver(function () {\n _this2.resizeObserver.disconnect();\n\n [].slice.call(menuUl.children).concat(menuUl).forEach(function (el) {\n _this2.resizeObserver.observe(el);\n });\n\n _this2.setChildrenWidthAndResize();\n });\n this.mutationObserver.observe(menuUl, {\n attributes: false,\n childList: true,\n subTree: false\n });\n }\n }\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n }\n\n if (this.mutationObserver) {\n this.mutationObserver.disconnect();\n }\n }\n }, {\n key: \"renderChildren\",\n value: function renderChildren(children) {\n var _this3 = this;\n\n // need to take care of overflowed items in horizontal mode\n var lastVisibleIndex = this.state.lastVisibleIndex;\n return (children || []).reduce(function (acc, childNode, index) {\n var item = childNode;\n\n if (_this3.props.mode === 'horizontal') {\n var overflowed = _this3.getOverflowedSubMenuItem(childNode.props.eventKey, []);\n\n if (lastVisibleIndex !== undefined && _this3.props.className.indexOf(\"\".concat(_this3.props.prefixCls, \"-root\")) !== -1) {\n if (index > lastVisibleIndex) {\n item = React.cloneElement(childNode, // čæéäæ®ę¹ eventKey ęÆäøŗäŗé²ę¢éčē¶ęäøčæä¼č§¦å openkeys äŗ件\n {\n style: {\n display: 'none'\n },\n eventKey: \"\".concat(childNode.props.eventKey, \"-hidden\"),\n\n /**\n * Legacy code. Here `className` never used:\n * https://github.com/react-component/menu/commit/4cd6b49fce9d116726f4ea00dda85325d6f26500#diff-e2fa48f75c2dd2318295cde428556a76R240\n */\n className: \"\".concat(MENUITEM_OVERFLOWED_CLASSNAME)\n });\n }\n\n if (index === lastVisibleIndex + 1) {\n _this3.overflowedItems = children.slice(lastVisibleIndex + 1).map(function (c) {\n return React.cloneElement(c, // children[index].key will become '.$key' in clone by default,\n // we have to overwrite with the correct key explicitly\n {\n key: c.props.eventKey,\n mode: 'vertical-left'\n });\n });\n overflowed = _this3.getOverflowedSubMenuItem(childNode.props.eventKey, _this3.overflowedItems);\n }\n }\n\n var ret = [].concat(_toConsumableArray(acc), [overflowed, item]);\n\n if (index === children.length - 1) {\n // need a placeholder for calculating overflowed indicator width\n ret.push(_this3.getOverflowedSubMenuItem(childNode.props.eventKey, [], true));\n }\n\n return ret;\n }\n\n return [].concat(_toConsumableArray(acc), [item]);\n }, []);\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this$props2 = this.props,\n visible = _this$props2.visible,\n prefixCls = _this$props2.prefixCls,\n overflowedIndicator = _this$props2.overflowedIndicator,\n mode = _this$props2.mode,\n level = _this$props2.level,\n tag = _this$props2.tag,\n children = _this$props2.children,\n theme = _this$props2.theme,\n rest = _objectWithoutProperties(_this$props2, [\"visible\", \"prefixCls\", \"overflowedIndicator\", \"mode\", \"level\", \"tag\", \"children\", \"theme\"]);\n\n var Tag = tag;\n return React.createElement(Tag, Object.assign({}, rest), this.renderChildren(children));\n }\n }]);\n\n return DOMWrap;\n}(React.Component);\n\nDOMWrap.defaultProps = {\n tag: 'div',\n className: ''\n};\nexport default DOMWrap;","function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nimport * as React from 'react';\nimport { connect } from 'mini-store';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport createChainedFunction from \"rc-util/es/createChainedFunction\";\nimport shallowEqual from 'shallowequal';\nimport classNames from 'classnames';\nimport { getKeyFromChildrenIndex, loopMenuItem, noop, menuAllProps, isMobileDevice } from './util';\nimport DOMWrap from './DOMWrap';\n\nfunction allDisabled(arr) {\n if (!arr.length) {\n return true;\n }\n\n return arr.every(function (c) {\n return !!c.props.disabled;\n });\n}\n\nfunction updateActiveKey(store, menuId, activeKey) {\n var state = store.getState();\n store.setState({\n activeKey: _objectSpread({}, state.activeKey, _defineProperty({}, menuId, activeKey))\n });\n}\n\nfunction getEventKey(props) {\n // when eventKey not available ,it's menu and return menu id '0-menu-'\n return props.eventKey || '0-menu-';\n}\n\nexport function getActiveKey(props, originalActiveKey) {\n var activeKey = originalActiveKey;\n var children = props.children,\n eventKey = props.eventKey;\n\n if (activeKey) {\n var found;\n loopMenuItem(children, function (c, i) {\n if (c && c.props && !c.props.disabled && activeKey === getKeyFromChildrenIndex(c, eventKey, i)) {\n found = true;\n }\n });\n\n if (found) {\n return activeKey;\n }\n }\n\n activeKey = null;\n\n if (props.defaultActiveFirst) {\n loopMenuItem(children, function (c, i) {\n if (!activeKey && c && !c.props.disabled) {\n activeKey = getKeyFromChildrenIndex(c, eventKey, i);\n }\n });\n return activeKey;\n }\n\n return activeKey;\n}\nexport function saveRef(c) {\n if (c) {\n var index = this.instanceArray.indexOf(c);\n\n if (index !== -1) {\n // update component if it's already inside instanceArray\n this.instanceArray[index] = c;\n } else {\n // add component if it's not in instanceArray yet;\n this.instanceArray.push(c);\n }\n }\n}\nexport var SubPopupMenu =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inherits(SubPopupMenu, _React$Component);\n\n function SubPopupMenu(props) {\n var _this;\n\n _classCallCheck(this, SubPopupMenu);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(SubPopupMenu).call(this, props));\n /**\n * all keyboard events callbacks run from here at first\n *\n * note:\n * This legacy code that `onKeyDown` is called by parent instead of dom self.\n * which need return code to check if this event is handled\n */\n\n _this.onKeyDown = function (e, callback) {\n var keyCode = e.keyCode;\n var handled;\n\n _this.getFlatInstanceArray().forEach(function (obj) {\n if (obj && obj.props.active && obj.onKeyDown) {\n handled = obj.onKeyDown(e);\n }\n });\n\n if (handled) {\n return 1;\n }\n\n var activeItem = null;\n\n if (keyCode === KeyCode.UP || keyCode === KeyCode.DOWN) {\n activeItem = _this.step(keyCode === KeyCode.UP ? -1 : 1);\n }\n\n if (activeItem) {\n e.preventDefault();\n updateActiveKey(_this.props.store, getEventKey(_this.props), activeItem.props.eventKey);\n\n if (typeof callback === 'function') {\n callback(activeItem);\n }\n\n return 1;\n }\n\n return undefined;\n };\n\n _this.onItemHover = function (e) {\n var key = e.key,\n hover = e.hover;\n updateActiveKey(_this.props.store, getEventKey(_this.props), hover ? key : null);\n };\n\n _this.onDeselect = function (selectInfo) {\n _this.props.onDeselect(selectInfo);\n };\n\n _this.onSelect = function (selectInfo) {\n _this.props.onSelect(selectInfo);\n };\n\n _this.onClick = function (e) {\n _this.props.onClick(e);\n };\n\n _this.onOpenChange = function (e) {\n _this.props.onOpenChange(e);\n };\n\n _this.onDestroy = function (key) {\n /* istanbul ignore next */\n _this.props.onDestroy(key);\n };\n\n _this.getFlatInstanceArray = function () {\n return _this.instanceArray;\n };\n\n _this.step = function (direction) {\n var children = _this.getFlatInstanceArray();\n\n var activeKey = _this.props.store.getState().activeKey[getEventKey(_this.props)];\n\n var len = children.length;\n\n if (!len) {\n return null;\n }\n\n if (direction < 0) {\n children = children.concat().reverse();\n } // find current activeIndex\n\n\n var activeIndex = -1;\n children.every(function (c, ci) {\n if (c && c.props.eventKey === activeKey) {\n activeIndex = ci;\n return false;\n }\n\n return true;\n });\n\n if (!_this.props.defaultActiveFirst && activeIndex !== -1 && allDisabled(children.slice(activeIndex, len - 1))) {\n return undefined;\n }\n\n var start = (activeIndex + 1) % len;\n var i = start;\n\n do {\n var child = children[i];\n\n if (!child || child.props.disabled) {\n i = (i + 1) % len;\n } else {\n return child;\n }\n } while (i !== start);\n\n return null;\n };\n\n _this.renderCommonMenuItem = function (child, i, extraProps) {\n var state = _this.props.store.getState();\n\n var _assertThisInitialize = _assertThisInitialized(_this),\n props = _assertThisInitialize.props;\n\n var key = getKeyFromChildrenIndex(child, props.eventKey, i);\n var childProps = child.props; // https://github.com/ant-design/ant-design/issues/11517#issuecomment-477403055\n\n if (!childProps || typeof child.type === 'string') {\n return child;\n }\n\n var isActive = key === state.activeKey;\n\n var newChildProps = _objectSpread({\n mode: childProps.mode || props.mode,\n level: props.level,\n inlineIndent: props.inlineIndent,\n renderMenuItem: _this.renderMenuItem,\n rootPrefixCls: props.prefixCls,\n index: i,\n parentMenu: props.parentMenu,\n // customized ref function, need to be invoked manually in child's componentDidMount\n manualRef: childProps.disabled ? undefined : createChainedFunction(child.ref, saveRef.bind(_assertThisInitialized(_this))),\n eventKey: key,\n active: !childProps.disabled && isActive,\n multiple: props.multiple,\n onClick: function onClick(e) {\n (childProps.onClick || noop)(e);\n\n _this.onClick(e);\n },\n onItemHover: _this.onItemHover,\n motion: props.motion,\n subMenuOpenDelay: props.subMenuOpenDelay,\n subMenuCloseDelay: props.subMenuCloseDelay,\n forceSubMenuRender: props.forceSubMenuRender,\n onOpenChange: _this.onOpenChange,\n onDeselect: _this.onDeselect,\n onSelect: _this.onSelect,\n builtinPlacements: props.builtinPlacements,\n itemIcon: childProps.itemIcon || _this.props.itemIcon,\n expandIcon: childProps.expandIcon || _this.props.expandIcon\n }, extraProps); // ref: https://github.com/ant-design/ant-design/issues/13943\n\n\n if (props.mode === 'inline' || isMobileDevice()) {\n newChildProps.triggerSubMenuAction = 'click';\n }\n\n return React.cloneElement(child, newChildProps);\n };\n\n _this.renderMenuItem = function (c, i, subMenuKey) {\n /* istanbul ignore if */\n if (!c) {\n return null;\n }\n\n var state = _this.props.store.getState();\n\n var extraProps = {\n openKeys: state.openKeys,\n selectedKeys: state.selectedKeys,\n triggerSubMenuAction: _this.props.triggerSubMenuAction,\n subMenuKey: subMenuKey\n };\n return _this.renderCommonMenuItem(c, i, extraProps);\n };\n\n props.store.setState({\n activeKey: _objectSpread({}, props.store.getState().activeKey, _defineProperty({}, props.eventKey, getActiveKey(props, props.activeKey)))\n });\n _this.instanceArray = [];\n return _this;\n }\n\n _createClass(SubPopupMenu, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n // invoke customized ref to expose component to mixin\n if (this.props.manualRef) {\n this.props.manualRef(this);\n }\n }\n }, {\n key: \"shouldComponentUpdate\",\n value: function shouldComponentUpdate(nextProps) {\n return this.props.visible || nextProps.visible || this.props.className !== nextProps.className || !shallowEqual(this.props.style, nextProps.style);\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate(prevProps) {\n var props = this.props;\n var originalActiveKey = 'activeKey' in props ? props.activeKey : props.store.getState().activeKey[getEventKey(props)];\n var activeKey = getActiveKey(props, originalActiveKey);\n\n if (activeKey !== originalActiveKey) {\n updateActiveKey(props.store, getEventKey(props), activeKey);\n } else if ('activeKey' in prevProps) {\n // If prev activeKey is not same as current activeKey,\n // we should set it.\n var prevActiveKey = getActiveKey(prevProps, prevProps.activeKey);\n\n if (activeKey !== prevActiveKey) {\n updateActiveKey(props.store, getEventKey(props), activeKey);\n }\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\n\n var props = _extends({}, this.props);\n\n this.instanceArray = [];\n var className = classNames(props.prefixCls, props.className, \"\".concat(props.prefixCls, \"-\").concat(props.mode));\n var domProps = {\n className: className,\n // role could be 'select' and by default set to menu\n role: props.role || 'menu'\n };\n\n if (props.id) {\n domProps.id = props.id;\n }\n\n if (props.focusable) {\n domProps.tabIndex = 0;\n domProps.onKeyDown = this.onKeyDown;\n }\n\n var prefixCls = props.prefixCls,\n eventKey = props.eventKey,\n visible = props.visible,\n level = props.level,\n mode = props.mode,\n overflowedIndicator = props.overflowedIndicator,\n theme = props.theme;\n menuAllProps.forEach(function (key) {\n return delete props[key];\n }); // Otherwise, the propagated click event will trigger another onClick\n\n delete props.onClick;\n return React.createElement(DOMWrap, Object.assign({}, props, {\n prefixCls: prefixCls,\n mode: mode,\n tag: \"ul\",\n level: level,\n theme: theme,\n visible: visible,\n overflowedIndicator: overflowedIndicator\n }, domProps), React.Children.map(props.children, function (c, i) {\n return _this2.renderMenuItem(c, i, eventKey || '0-menu-');\n }));\n }\n }]);\n\n return SubPopupMenu;\n}(React.Component);\nSubPopupMenu.defaultProps = {\n prefixCls: 'rc-menu',\n className: '',\n mode: 'vertical',\n level: 1,\n inlineIndent: 24,\n visible: true,\n focusable: true,\n style: {},\n manualRef: noop\n};\nvar connected = connect()(SubPopupMenu);\nexport default connected;","function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nimport warning from \"rc-util/es/warning\";\nexport function getMotion(_ref) {\n var prefixCls = _ref.prefixCls,\n motion = _ref.motion,\n openAnimation = _ref.openAnimation,\n openTransitionName = _ref.openTransitionName;\n\n if (motion) {\n return motion;\n }\n\n if (_typeof(openAnimation) === 'object' && openAnimation) {\n warning(false, 'Object type of `openAnimation` is removed. Please use `motion` instead.');\n } else if (typeof openAnimation === 'string') {\n return {\n motionName: \"\".concat(prefixCls, \"-open-\").concat(openAnimation)\n };\n }\n\n if (openTransitionName) {\n return {\n motionName: openTransitionName\n };\n }\n\n return null;\n}","function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nimport * as React from 'react';\nimport { Provider, create } from 'mini-store';\nimport SubPopupMenu, { getActiveKey } from './SubPopupMenu';\nimport { noop } from './util';\nimport { getMotion } from './utils/legacyUtil';\n\nvar Menu =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inherits(Menu, _React$Component);\n\n function Menu(props) {\n var _this;\n\n _classCallCheck(this, Menu);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(Menu).call(this, props));\n\n _this.onSelect = function (selectInfo) {\n var _assertThisInitialize = _assertThisInitialized(_this),\n props = _assertThisInitialize.props;\n\n if (props.selectable) {\n // root menu\n var _this$store$getState = _this.store.getState(),\n _selectedKeys = _this$store$getState.selectedKeys;\n\n var selectedKey = selectInfo.key;\n\n if (props.multiple) {\n _selectedKeys = _selectedKeys.concat([selectedKey]);\n } else {\n _selectedKeys = [selectedKey];\n }\n\n if (!('selectedKeys' in props)) {\n _this.store.setState({\n selectedKeys: _selectedKeys\n });\n }\n\n props.onSelect(_objectSpread({}, selectInfo, {\n selectedKeys: _selectedKeys\n }));\n }\n };\n\n _this.onClick = function (e) {\n _this.props.onClick(e);\n }; // onKeyDown needs to be exposed as a instance method\n // e.g., in rc-select, we need to navigate menu item while\n // current active item is rc-select input box rather than the menu itself\n\n\n _this.onKeyDown = function (e, callback) {\n _this.innerMenu.getWrappedInstance().onKeyDown(e, callback);\n };\n\n _this.onOpenChange = function (event) {\n var _assertThisInitialize2 = _assertThisInitialized(_this),\n props = _assertThisInitialize2.props;\n\n var openKeys = _this.store.getState().openKeys.concat();\n\n var changed = false;\n\n var processSingle = function processSingle(e) {\n var oneChanged = false;\n\n if (e.open) {\n oneChanged = openKeys.indexOf(e.key) === -1;\n\n if (oneChanged) {\n openKeys.push(e.key);\n }\n } else {\n var index = openKeys.indexOf(e.key);\n oneChanged = index !== -1;\n\n if (oneChanged) {\n openKeys.splice(index, 1);\n }\n }\n\n changed = changed || oneChanged;\n };\n\n if (Array.isArray(event)) {\n // batch change call\n event.forEach(processSingle);\n } else {\n processSingle(event);\n }\n\n if (changed) {\n if (!('openKeys' in _this.props)) {\n _this.store.setState({\n openKeys: openKeys\n });\n }\n\n props.onOpenChange(openKeys);\n }\n };\n\n _this.onDeselect = function (selectInfo) {\n var _assertThisInitialize3 = _assertThisInitialized(_this),\n props = _assertThisInitialize3.props;\n\n if (props.selectable) {\n var _selectedKeys2 = _this.store.getState().selectedKeys.concat();\n\n var selectedKey = selectInfo.key;\n\n var index = _selectedKeys2.indexOf(selectedKey);\n\n if (index !== -1) {\n _selectedKeys2.splice(index, 1);\n }\n\n if (!('selectedKeys' in props)) {\n _this.store.setState({\n selectedKeys: _selectedKeys2\n });\n }\n\n props.onDeselect(_objectSpread({}, selectInfo, {\n selectedKeys: _selectedKeys2\n }));\n }\n };\n\n _this.getOpenTransitionName = function () {\n var _assertThisInitialize4 = _assertThisInitialized(_this),\n props = _assertThisInitialize4.props;\n\n var transitionName = props.openTransitionName;\n var animationName = props.openAnimation;\n\n if (!transitionName && typeof animationName === 'string') {\n transitionName = \"\".concat(props.prefixCls, \"-open-\").concat(animationName);\n }\n\n return transitionName;\n };\n\n _this.setInnerMenu = function (node) {\n _this.innerMenu = node;\n };\n\n _this.isRootMenu = true;\n var selectedKeys = props.defaultSelectedKeys;\n var openKeys = props.defaultOpenKeys;\n\n if ('selectedKeys' in props) {\n selectedKeys = props.selectedKeys || [];\n }\n\n if ('openKeys' in props) {\n openKeys = props.openKeys || [];\n }\n\n _this.store = create({\n selectedKeys: selectedKeys,\n openKeys: openKeys,\n activeKey: {\n '0-menu-': getActiveKey(props, props.activeKey)\n }\n });\n return _this;\n }\n\n _createClass(Menu, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.updateMiniStore();\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate() {\n this.updateMiniStore();\n }\n }, {\n key: \"updateMiniStore\",\n value: function updateMiniStore() {\n if ('selectedKeys' in this.props) {\n this.store.setState({\n selectedKeys: this.props.selectedKeys || []\n });\n }\n\n if ('openKeys' in this.props) {\n this.store.setState({\n openKeys: this.props.openKeys || []\n });\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var props = _objectSpread({}, this.props);\n\n props.className += \" \".concat(props.prefixCls, \"-root\");\n props = _objectSpread({}, props, {\n onClick: this.onClick,\n onOpenChange: this.onOpenChange,\n onDeselect: this.onDeselect,\n onSelect: this.onSelect,\n parentMenu: this,\n motion: getMotion(this.props)\n });\n delete props.openAnimation;\n delete props.openTransitionName;\n return React.createElement(Provider, {\n store: this.store\n }, React.createElement(SubPopupMenu, Object.assign({}, props, {\n ref: this.setInnerMenu\n }), this.props.children));\n }\n }]);\n\n return Menu;\n}(React.Component);\n\nMenu.defaultProps = {\n selectable: true,\n onClick: noop,\n onSelect: noop,\n onOpenChange: noop,\n onDeselect: noop,\n defaultSelectedKeys: [],\n defaultOpenKeys: [],\n subMenuOpenDelay: 0.1,\n subMenuCloseDelay: 0.1,\n triggerSubMenuAction: 'hover',\n prefixCls: 'rc-menu',\n className: '',\n mode: 'vertical',\n style: {},\n builtinPlacements: {},\n overflowedIndicator: React.createElement(\"span\", null, \"\\xB7\\xB7\\xB7\")\n};\nexport default Menu;","function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport classNames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\nimport { connect } from 'mini-store';\nimport { noop, menuAllProps } from './util';\nexport var MenuItem =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inherits(MenuItem, _React$Component);\n\n function MenuItem() {\n var _this;\n\n _classCallCheck(this, MenuItem);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(MenuItem).apply(this, arguments));\n\n _this.onKeyDown = function (e) {\n var keyCode = e.keyCode;\n\n if (keyCode === KeyCode.ENTER) {\n _this.onClick(e);\n\n return true;\n }\n\n return undefined;\n };\n\n _this.onMouseLeave = function (e) {\n var _this$props = _this.props,\n eventKey = _this$props.eventKey,\n onItemHover = _this$props.onItemHover,\n onMouseLeave = _this$props.onMouseLeave;\n onItemHover({\n key: eventKey,\n hover: false\n });\n onMouseLeave({\n key: eventKey,\n domEvent: e\n });\n };\n\n _this.onMouseEnter = function (e) {\n var _this$props2 = _this.props,\n eventKey = _this$props2.eventKey,\n onItemHover = _this$props2.onItemHover,\n onMouseEnter = _this$props2.onMouseEnter;\n onItemHover({\n key: eventKey,\n hover: true\n });\n onMouseEnter({\n key: eventKey,\n domEvent: e\n });\n };\n\n _this.onClick = function (e) {\n var _this$props3 = _this.props,\n eventKey = _this$props3.eventKey,\n multiple = _this$props3.multiple,\n onClick = _this$props3.onClick,\n onSelect = _this$props3.onSelect,\n onDeselect = _this$props3.onDeselect,\n isSelected = _this$props3.isSelected;\n var info = {\n key: eventKey,\n keyPath: [eventKey],\n item: _assertThisInitialized(_this),\n domEvent: e\n };\n onClick(info);\n\n if (multiple) {\n if (isSelected) {\n onDeselect(info);\n } else {\n onSelect(info);\n }\n } else if (!isSelected) {\n onSelect(info);\n }\n };\n\n _this.saveNode = function (node) {\n _this.node = node;\n };\n\n return _this;\n }\n\n _createClass(MenuItem, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n // invoke customized ref to expose component to mixin\n this.callRef();\n }\n }, {\n key: \"componentDidUpdate\",\n value: function componentDidUpdate(prevProps) {\n var _this$props4 = this.props,\n active = _this$props4.active,\n parentMenu = _this$props4.parentMenu,\n eventKey = _this$props4.eventKey; // åØ parentMenu äøå±äæåę»åØē¶ęļ¼éæå éå¤ē MenuItem key åƼč“ę»åØč·³åØ\n // https://github.com/ant-design/ant-design/issues/16181\n\n if (!prevProps.active && active && (!parentMenu || !parentMenu[\"scrolled-\".concat(eventKey)])) {\n if (this.node) {\n scrollIntoView(this.node, ReactDOM.findDOMNode(parentMenu), {\n onlyScrollIfNeeded: true\n });\n parentMenu[\"scrolled-\".concat(eventKey)] = true;\n }\n } else if (parentMenu && parentMenu[\"scrolled-\".concat(eventKey)]) {\n delete parentMenu[\"scrolled-\".concat(eventKey)];\n }\n\n this.callRef();\n }\n }, {\n key: \"componentWillUnmount\",\n value: function componentWillUnmount() {\n var props = this.props;\n\n if (props.onDestroy) {\n props.onDestroy(props.eventKey);\n }\n }\n }, {\n key: \"getPrefixCls\",\n value: function getPrefixCls() {\n return \"\".concat(this.props.rootPrefixCls, \"-item\");\n }\n }, {\n key: \"getActiveClassName\",\n value: function getActiveClassName() {\n return \"\".concat(this.getPrefixCls(), \"-active\");\n }\n }, {\n key: \"getSelectedClassName\",\n value: function getSelectedClassName() {\n return \"\".concat(this.getPrefixCls(), \"-selected\");\n }\n }, {\n key: \"getDisabledClassName\",\n value: function getDisabledClassName() {\n return \"\".concat(this.getPrefixCls(), \"-disabled\");\n }\n }, {\n key: \"callRef\",\n value: function callRef() {\n if (this.props.manualRef) {\n this.props.manualRef(this);\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _classNames;\n\n var props = _objectSpread({}, this.props);\n\n var className = classNames(this.getPrefixCls(), props.className, (_classNames = {}, _defineProperty(_classNames, this.getActiveClassName(), !props.disabled && props.active), _defineProperty(_classNames, this.getSelectedClassName(), props.isSelected), _defineProperty(_classNames, this.getDisabledClassName(), props.disabled), _classNames));\n\n var attrs = _objectSpread({}, props.attribute, {\n title: props.title,\n className: className,\n // set to menuitem by default\n role: props.role || 'menuitem',\n 'aria-disabled': props.disabled\n });\n\n if (props.role === 'option') {\n // overwrite to option\n attrs = _objectSpread({}, attrs, {\n role: 'option',\n 'aria-selected': props.isSelected\n });\n } else if (props.role === null || props.role === 'none') {\n // sometimes we want to specify role inside element\n //
would be a good example\n // in this case the role on should be \"none\" to\n // remove the implied listitem role.\n // https://www.w3.org/TR/wai-aria-practices-1.1/examples/menubar/menubar-1/menubar-1.html\n attrs.role = 'none';\n } // In case that onClick/onMouseLeave/onMouseEnter is passed down from owner\n\n\n var mouseEvent = {\n onClick: props.disabled ? null : this.onClick,\n onMouseLeave: props.disabled ? null : this.onMouseLeave,\n onMouseEnter: props.disabled ? null : this.onMouseEnter\n };\n\n var style = _objectSpread({}, props.style);\n\n if (props.mode === 'inline') {\n style.paddingLeft = props.inlineIndent * props.level;\n }\n\n menuAllProps.forEach(function (key) {\n return delete props[key];\n });\n var icon = this.props.itemIcon;\n\n if (typeof this.props.itemIcon === 'function') {\n // TODO: This is a bug which should fixed after TS refactor\n icon = React.createElement(this.props.itemIcon, this.props);\n }\n\n return React.createElement(\"li\", Object.assign({}, props, attrs, mouseEvent, {\n style: style,\n ref: this.saveNode\n }), props.children, icon);\n }\n }]);\n\n return MenuItem;\n}(React.Component);\nMenuItem.isMenuItem = true;\nMenuItem.defaultProps = {\n onSelect: noop,\n onMouseEnter: noop,\n onMouseLeave: noop,\n manualRef: noop\n};\nvar connected = connect(function (_ref, _ref2) {\n var activeKey = _ref.activeKey,\n selectedKeys = _ref.selectedKeys;\n var eventKey = _ref2.eventKey,\n subMenuKey = _ref2.subMenuKey;\n return {\n active: activeKey[subMenuKey] === eventKey,\n isSelected: selectedKeys.indexOf(eventKey) !== -1\n };\n})(MenuItem);\nexport default connected;","function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nimport * as React from 'react';\nimport { menuAllProps } from './util';\n\nvar MenuItemGroup =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inherits(MenuItemGroup, _React$Component);\n\n function MenuItemGroup() {\n var _this;\n\n _classCallCheck(this, MenuItemGroup);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(MenuItemGroup).apply(this, arguments));\n\n _this.renderInnerMenuItem = function (item) {\n var _this$props = _this.props,\n renderMenuItem = _this$props.renderMenuItem,\n index = _this$props.index;\n return renderMenuItem(item, index, _this.props.subMenuKey);\n };\n\n return _this;\n }\n\n _createClass(MenuItemGroup, [{\n key: \"render\",\n value: function render() {\n var props = _extends({}, this.props);\n\n var _props$className = props.className,\n className = _props$className === void 0 ? '' : _props$className,\n rootPrefixCls = props.rootPrefixCls;\n var titleClassName = \"\".concat(rootPrefixCls, \"-item-group-title\");\n var listClassName = \"\".concat(rootPrefixCls, \"-item-group-list\");\n var title = props.title,\n children = props.children;\n menuAllProps.forEach(function (key) {\n return delete props[key];\n }); // Set onClick to null, to ignore propagated onClick event\n\n delete props.onClick;\n return React.createElement(\"li\", Object.assign({}, props, {\n className: \"\".concat(className, \" \").concat(rootPrefixCls, \"-item-group\")\n }), React.createElement(\"div\", {\n className: titleClassName,\n title: typeof title === 'string' ? title : undefined\n }, title), React.createElement(\"ul\", {\n className: listClassName\n }, React.Children.map(children, this.renderInnerMenuItem)));\n }\n }]);\n\n return MenuItemGroup;\n}(React.Component);\n\nMenuItemGroup.isMenuItemGroup = true;\nMenuItemGroup.defaultProps = {\n disabled: true\n};\nexport default MenuItemGroup;","import * as React from 'react';\n\nvar Divider = function Divider(_ref) {\n var className = _ref.className,\n rootPrefixCls = _ref.rootPrefixCls,\n style = _ref.style;\n return React.createElement(\"li\", {\n className: \"\".concat(className, \" \").concat(rootPrefixCls, \"-item-divider\"),\n style: style\n });\n};\n\nDivider.defaultProps = {\n // To fix keyboard UX.\n disabled: true,\n className: '',\n style: {}\n};\nexport default Divider;","import Menu from './Menu';\nimport SubMenu from './SubMenu';\nimport MenuItem from './MenuItem';\nimport MenuItemGroup from './MenuItemGroup';\nimport Divider from './Divider';\nexport { SubMenu, MenuItem as Item, MenuItem, MenuItemGroup, MenuItemGroup as ItemGroup, Divider };\nexport default Menu;","import _classCallCheck from 'babel-runtime/helpers/classCallCheck';\nimport _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';\nimport _inherits from 'babel-runtime/helpers/inherits';\nimport PropTypes from 'prop-types';\nimport enUs from '../locale/en_US';\n\nfunction noop() {}\n\nexport var propType = {\n className: PropTypes.string,\n locale: PropTypes.object,\n style: PropTypes.object,\n visible: PropTypes.bool,\n onSelect: PropTypes.func,\n prefixCls: PropTypes.string,\n onChange: PropTypes.func,\n onOk: PropTypes.func\n};\n\nexport var defaultProp = {\n locale: enUs,\n style: {},\n visible: true,\n prefixCls: 'rc-calendar',\n className: '',\n onSelect: noop,\n onChange: noop,\n onClear: noop,\n renderFooter: function renderFooter() {\n return null;\n },\n renderSidebar: function renderSidebar() {\n return null;\n }\n};\n\nexport var commonMixinWrapper = function commonMixinWrapper(ComposeComponent) {\n var _class, _temp2;\n\n return _temp2 = _class = function (_ComposeComponent) {\n _inherits(_class, _ComposeComponent);\n\n function _class() {\n var _temp, _this, _ret;\n\n _classCallCheck(this, _class);\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return _ret = (_temp = (_this = _possibleConstructorReturn(this, _ComposeComponent.call.apply(_ComposeComponent, [this].concat(args))), _this), _this.getFormat = function () {\n var format = _this.props.format;\n var _this$props = _this.props,\n locale = _this$props.locale,\n timePicker = _this$props.timePicker;\n\n if (!format) {\n if (timePicker) {\n format = locale.dateTimeFormat;\n } else {\n format = locale.dateFormat;\n }\n }\n return format;\n }, _this.focus = function () {\n if (_this.focusElement) {\n _this.focusElement.focus();\n } else if (_this.rootInstance) {\n _this.rootInstance.focus();\n }\n }, _this.saveFocusElement = function (focusElement) {\n _this.focusElement = focusElement;\n }, _this.saveRoot = function (root) {\n _this.rootInstance = root;\n }, _temp), _possibleConstructorReturn(_this, _ret);\n }\n\n _class.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {\n return this.props.visible || nextProps.visible;\n };\n\n return _class;\n }(ComposeComponent), _class.displayName = 'CommonMixinWrapper', _class.defaultProps = ComposeComponent.defaultProps, _class.getDerivedStateFromProps = ComposeComponent.getDerivedStateFromProps, _temp2;\n};","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nmodule.exports = isObject;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nmodule.exports = root;\n","/**\n * Safe chained function\n *\n * Will only create a new function if needed,\n * otherwise will pass back existing functions or null.\n *\n * @returns {function|null}\n */\nexport default function createChainedFunction() {\n var args = [].slice.call(arguments, 0);\n\n if (args.length === 1) {\n return args[0];\n }\n\n return function chainedFunction() {\n for (var i = 0; i < args.length; i++) {\n if (args[i] && args[i].apply) {\n args[i].apply(this, arguments);\n }\n }\n };\n}","\"use strict\";\n\nexports.__esModule = true;\n\nvar _from = require(\"../core-js/array/from\");\n\nvar _from2 = _interopRequireDefault(_from);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = function (arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n } else {\n return (0, _from2.default)(arr);\n }\n};","var START_EVENT_NAME_MAP = {\n transitionstart: {\n transition: 'transitionstart',\n WebkitTransition: 'webkitTransitionStart',\n MozTransition: 'mozTransitionStart',\n OTransition: 'oTransitionStart',\n msTransition: 'MSTransitionStart'\n },\n\n animationstart: {\n animation: 'animationstart',\n WebkitAnimation: 'webkitAnimationStart',\n MozAnimation: 'mozAnimationStart',\n OAnimation: 'oAnimationStart',\n msAnimation: 'MSAnimationStart'\n }\n};\n\nvar END_EVENT_NAME_MAP = {\n transitionend: {\n transition: 'transitionend',\n WebkitTransition: 'webkitTransitionEnd',\n MozTransition: 'mozTransitionEnd',\n OTransition: 'oTransitionEnd',\n msTransition: 'MSTransitionEnd'\n },\n\n animationend: {\n animation: 'animationend',\n WebkitAnimation: 'webkitAnimationEnd',\n MozAnimation: 'mozAnimationEnd',\n OAnimation: 'oAnimationEnd',\n msAnimation: 'MSAnimationEnd'\n }\n};\n\nvar startEvents = [];\nvar endEvents = [];\n\nfunction detectEvents() {\n var testEl = document.createElement('div');\n var style = testEl.style;\n\n if (!('AnimationEvent' in window)) {\n delete START_EVENT_NAME_MAP.animationstart.animation;\n delete END_EVENT_NAME_MAP.animationend.animation;\n }\n\n if (!('TransitionEvent' in window)) {\n delete START_EVENT_NAME_MAP.transitionstart.transition;\n delete END_EVENT_NAME_MAP.transitionend.transition;\n }\n\n function process(EVENT_NAME_MAP, events) {\n for (var baseEventName in EVENT_NAME_MAP) {\n if (EVENT_NAME_MAP.hasOwnProperty(baseEventName)) {\n var baseEvents = EVENT_NAME_MAP[baseEventName];\n for (var styleName in baseEvents) {\n if (styleName in style) {\n events.push(baseEvents[styleName]);\n break;\n }\n }\n }\n }\n }\n\n process(START_EVENT_NAME_MAP, startEvents);\n process(END_EVENT_NAME_MAP, endEvents);\n}\n\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n detectEvents();\n}\n\nfunction addEventListener(node, eventName, eventListener) {\n node.addEventListener(eventName, eventListener, false);\n}\n\nfunction removeEventListener(node, eventName, eventListener) {\n node.removeEventListener(eventName, eventListener, false);\n}\n\nvar TransitionEvents = {\n // Start events\n startEvents: startEvents,\n\n addStartEventListener: function addStartEventListener(node, eventListener) {\n if (startEvents.length === 0) {\n window.setTimeout(eventListener, 0);\n return;\n }\n startEvents.forEach(function (startEvent) {\n addEventListener(node, startEvent, eventListener);\n });\n },\n removeStartEventListener: function removeStartEventListener(node, eventListener) {\n if (startEvents.length === 0) {\n return;\n }\n startEvents.forEach(function (startEvent) {\n removeEventListener(node, startEvent, eventListener);\n });\n },\n\n\n // End events\n endEvents: endEvents,\n\n addEndEventListener: function addEndEventListener(node, eventListener) {\n if (endEvents.length === 0) {\n window.setTimeout(eventListener, 0);\n return;\n }\n endEvents.forEach(function (endEvent) {\n addEventListener(node, endEvent, eventListener);\n });\n },\n removeEndEventListener: function removeEndEventListener(node, eventListener) {\n if (endEvents.length === 0) {\n return;\n }\n endEvents.forEach(function (endEvent) {\n removeEventListener(node, endEvent, eventListener);\n });\n }\n};\n\nexport default TransitionEvents;","import { Col } from '../grid';\nexport default Col;","var store = require('./_shared')('wks');\nvar uid = require('./_uid');\nvar Symbol = require('./_global').Symbol;\nvar USE_SYMBOL = typeof Symbol == 'function';\n\nvar $exports = module.exports = function (name) {\n return store[name] || (store[name] =\n USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));\n};\n\n$exports.store = store;\n","/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\nmodule.exports = isArray;\n","'use strict';\n\nvar reactIs = require('react-is');\n\n/**\n * Copyright 2015, Yahoo! Inc.\n * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.\n */\nvar REACT_STATICS = {\n childContextTypes: true,\n contextType: true,\n contextTypes: true,\n defaultProps: true,\n displayName: true,\n getDefaultProps: true,\n getDerivedStateFromError: true,\n getDerivedStateFromProps: true,\n mixins: true,\n propTypes: true,\n type: true\n};\nvar KNOWN_STATICS = {\n name: true,\n length: true,\n prototype: true,\n caller: true,\n callee: true,\n arguments: true,\n arity: true\n};\nvar FORWARD_REF_STATICS = {\n '$$typeof': true,\n render: true,\n defaultProps: true,\n displayName: true,\n propTypes: true\n};\nvar MEMO_STATICS = {\n '$$typeof': true,\n compare: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n type: true\n};\nvar TYPE_STATICS = {};\nTYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;\nTYPE_STATICS[reactIs.Memo] = MEMO_STATICS;\n\nfunction getStatics(component) {\n // React v16.11 and below\n if (reactIs.isMemo(component)) {\n return MEMO_STATICS;\n } // React v16.12 and above\n\n\n return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;\n}\n\nvar defineProperty = Object.defineProperty;\nvar getOwnPropertyNames = Object.getOwnPropertyNames;\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\nvar getPrototypeOf = Object.getPrototypeOf;\nvar objectPrototype = Object.prototype;\nfunction hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {\n if (typeof sourceComponent !== 'string') {\n // don't hoist over string (html) components\n if (objectPrototype) {\n var inheritedComponent = getPrototypeOf(sourceComponent);\n\n if (inheritedComponent && inheritedComponent !== objectPrototype) {\n hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);\n }\n }\n\n var keys = getOwnPropertyNames(sourceComponent);\n\n if (getOwnPropertySymbols) {\n keys = keys.concat(getOwnPropertySymbols(sourceComponent));\n }\n\n var targetStatics = getStatics(targetComponent);\n var sourceStatics = getStatics(sourceComponent);\n\n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n\n if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {\n var descriptor = getOwnPropertyDescriptor(sourceComponent, key);\n\n try {\n // Avoid failures from read-only properties\n defineProperty(targetComponent, key, descriptor);\n } catch (e) {}\n }\n }\n }\n\n return targetComponent;\n}\n\nmodule.exports = hoistNonReactStatics;\n","import React from 'react';\nimport { isFragment } from 'react-is';\nexport default function toArray(children) {\n var ret = [];\n React.Children.forEach(children, function (child) {\n if (child === undefined || child === null) {\n return;\n }\n\n if (Array.isArray(child)) {\n ret = ret.concat(toArray(child));\n } else if (isFragment(child) && child.props) {\n ret = ret.concat(toArray(child.props.children));\n } else {\n ret.push(child);\n }\n });\n return ret;\n}","/*\r\n * @namespace Util\r\n *\r\n * Various utility functions, used by Leaflet internally.\r\n */\r\n\r\n// @function extend(dest: Object, src?: Object): Object\r\n// Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut.\r\nexport function extend(dest) {\r\n\tvar i, j, len, src;\r\n\r\n\tfor (j = 1, len = arguments.length; j < len; j++) {\r\n\t\tsrc = arguments[j];\r\n\t\tfor (i in src) {\r\n\t\t\tdest[i] = src[i];\r\n\t\t}\r\n\t}\r\n\treturn dest;\r\n}\r\n\r\n// @function create(proto: Object, properties?: Object): Object\r\n// Compatibility polyfill for [Object.create](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create)\r\nexport var create = Object.create || (function () {\r\n\tfunction F() {}\r\n\treturn function (proto) {\r\n\t\tF.prototype = proto;\r\n\t\treturn new F();\r\n\t};\r\n})();\r\n\r\n// @function bind(fn: Function, ā¦): Function\r\n// Returns a new function bound to the arguments passed, like [Function.prototype.bind](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).\r\n// Has a `L.bind()` shortcut.\r\nexport function bind(fn, obj) {\r\n\tvar slice = Array.prototype.slice;\r\n\r\n\tif (fn.bind) {\r\n\t\treturn fn.bind.apply(fn, slice.call(arguments, 1));\r\n\t}\r\n\r\n\tvar args = slice.call(arguments, 2);\r\n\r\n\treturn function () {\r\n\t\treturn fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments);\r\n\t};\r\n}\r\n\r\n// @property lastId: Number\r\n// Last unique ID used by [`stamp()`](#util-stamp)\r\nexport var lastId = 0;\r\n\r\n// @function stamp(obj: Object): Number\r\n// Returns the unique ID of an object, assigning it one if it doesn't have it.\r\nexport function stamp(obj) {\r\n\t/*eslint-disable */\r\n\tobj._leaflet_id = obj._leaflet_id || ++lastId;\r\n\treturn obj._leaflet_id;\r\n\t/* eslint-enable */\r\n}\r\n\r\n// @function throttle(fn: Function, time: Number, context: Object): Function\r\n// Returns a function which executes function `fn` with the given scope `context`\r\n// (so that the `this` keyword refers to `context` inside `fn`'s code). The function\r\n// `fn` will be called no more than one time per given amount of `time`. The arguments\r\n// received by the bound function will be any arguments passed when binding the\r\n// function, followed by any arguments passed when invoking the bound function.\r\n// Has an `L.throttle` shortcut.\r\nexport function throttle(fn, time, context) {\r\n\tvar lock, args, wrapperFn, later;\r\n\r\n\tlater = function () {\r\n\t\t// reset lock and call if queued\r\n\t\tlock = false;\r\n\t\tif (args) {\r\n\t\t\twrapperFn.apply(context, args);\r\n\t\t\targs = false;\r\n\t\t}\r\n\t};\r\n\r\n\twrapperFn = function () {\r\n\t\tif (lock) {\r\n\t\t\t// called too soon, queue to call later\r\n\t\t\targs = arguments;\r\n\r\n\t\t} else {\r\n\t\t\t// call and lock until later\r\n\t\t\tfn.apply(context, arguments);\r\n\t\t\tsetTimeout(later, time);\r\n\t\t\tlock = true;\r\n\t\t}\r\n\t};\r\n\r\n\treturn wrapperFn;\r\n}\r\n\r\n// @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number\r\n// Returns the number `num` modulo `range` in such a way so it lies within\r\n// `range[0]` and `range[1]`. The returned value will be always smaller than\r\n// `range[1]` unless `includeMax` is set to `true`.\r\nexport function wrapNum(x, range, includeMax) {\r\n\tvar max = range[1],\r\n\t min = range[0],\r\n\t d = max - min;\r\n\treturn x === max && includeMax ? x : ((x - min) % d + d) % d + min;\r\n}\r\n\r\n// @function falseFn(): Function\r\n// Returns a function which always returns `false`.\r\nexport function falseFn() { return false; }\r\n\r\n// @function formatNum(num: Number, digits?: Number): Number\r\n// Returns the number `num` rounded to `digits` decimals, or to 6 decimals by default.\r\nexport function formatNum(num, digits) {\r\n\tvar pow = Math.pow(10, (digits === undefined ? 6 : digits));\r\n\treturn Math.round(num * pow) / pow;\r\n}\r\n\r\n// @function trim(str: String): String\r\n// Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)\r\nexport function trim(str) {\r\n\treturn str.trim ? str.trim() : str.replace(/^\\s+|\\s+$/g, '');\r\n}\r\n\r\n// @function splitWords(str: String): String[]\r\n// Trims and splits the string on whitespace and returns the array of parts.\r\nexport function splitWords(str) {\r\n\treturn trim(str).split(/\\s+/);\r\n}\r\n\r\n// @function setOptions(obj: Object, options: Object): Object\r\n// Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut.\r\nexport function setOptions(obj, options) {\r\n\tif (!Object.prototype.hasOwnProperty.call(obj, 'options')) {\r\n\t\tobj.options = obj.options ? create(obj.options) : {};\r\n\t}\r\n\tfor (var i in options) {\r\n\t\tobj.options[i] = options[i];\r\n\t}\r\n\treturn obj.options;\r\n}\r\n\r\n// @function getParamString(obj: Object, existingUrl?: String, uppercase?: Boolean): String\r\n// Converts an object into a parameter URL string, e.g. `{a: \"foo\", b: \"bar\"}`\r\n// translates to `'?a=foo&b=bar'`. If `existingUrl` is set, the parameters will\r\n// be appended at the end. If `uppercase` is `true`, the parameter names will\r\n// be uppercased (e.g. `'?A=foo&B=bar'`)\r\nexport function getParamString(obj, existingUrl, uppercase) {\r\n\tvar params = [];\r\n\tfor (var i in obj) {\r\n\t\tparams.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i]));\r\n\t}\r\n\treturn ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');\r\n}\r\n\r\nvar templateRe = /\\{ *([\\w_-]+) *\\}/g;\r\n\r\n// @function template(str: String, data: Object): String\r\n// Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`\r\n// and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string\r\n// `('Hello foo, bar')`. You can also specify functions instead of strings for\r\n// data values ā they will be evaluated passing `data` as an argument.\r\nexport function template(str, data) {\r\n\treturn str.replace(templateRe, function (str, key) {\r\n\t\tvar value = data[key];\r\n\r\n\t\tif (value === undefined) {\r\n\t\t\tthrow new Error('No value provided for variable ' + str);\r\n\r\n\t\t} else if (typeof value === 'function') {\r\n\t\t\tvalue = value(data);\r\n\t\t}\r\n\t\treturn value;\r\n\t});\r\n}\r\n\r\n// @function isArray(obj): Boolean\r\n// Compatibility polyfill for [Array.isArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)\r\nexport var isArray = Array.isArray || function (obj) {\r\n\treturn (Object.prototype.toString.call(obj) === '[object Array]');\r\n};\r\n\r\n// @function indexOf(array: Array, el: Object): Number\r\n// Compatibility polyfill for [Array.prototype.indexOf](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)\r\nexport function indexOf(array, el) {\r\n\tfor (var i = 0; i < array.length; i++) {\r\n\t\tif (array[i] === el) { return i; }\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\n// @property emptyImageUrl: String\r\n// Data URI string containing a base64-encoded empty GIF image.\r\n// Used as a hack to free memory from unused images on WebKit-powered\r\n// mobile devices (by setting image `src` to this string).\r\nexport var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';\r\n\r\n// inspired by http://paulirish.com/2011/requestanimationframe-for-smart-animating/\r\n\r\nfunction getPrefixed(name) {\r\n\treturn window['webkit' + name] || window['moz' + name] || window['ms' + name];\r\n}\r\n\r\nvar lastTime = 0;\r\n\r\n// fallback for IE 7-8\r\nfunction timeoutDefer(fn) {\r\n\tvar time = +new Date(),\r\n\t timeToCall = Math.max(0, 16 - (time - lastTime));\r\n\r\n\tlastTime = time + timeToCall;\r\n\treturn window.setTimeout(fn, timeToCall);\r\n}\r\n\r\nexport var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer;\r\nexport var cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') ||\r\n\t\tgetPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); };\r\n\r\n// @function requestAnimFrame(fn: Function, context?: Object, immediate?: Boolean): Number\r\n// Schedules `fn` to be executed when the browser repaints. `fn` is bound to\r\n// `context` if given. When `immediate` is set, `fn` is called immediately if\r\n// the browser doesn't have native support for\r\n// [`window.requestAnimationFrame`](https://developer.mozilla.org/docs/Web/API/window/requestAnimationFrame),\r\n// otherwise it's delayed. Returns a request ID that can be used to cancel the request.\r\nexport function requestAnimFrame(fn, context, immediate) {\r\n\tif (immediate && requestFn === timeoutDefer) {\r\n\t\tfn.call(context);\r\n\t} else {\r\n\t\treturn requestFn.call(window, bind(fn, context));\r\n\t}\r\n}\r\n\r\n// @function cancelAnimFrame(id: Number): undefined\r\n// Cancels a previous `requestAnimFrame`. See also [window.cancelAnimationFrame](https://developer.mozilla.org/docs/Web/API/window/cancelAnimationFrame).\r\nexport function cancelAnimFrame(id) {\r\n\tif (id) {\r\n\t\tcancelFn.call(window, id);\r\n\t}\r\n}\r\n","import * as Util from './Util';\r\n\r\n// @class Class\r\n// @aka L.Class\r\n\r\n// @section\r\n// @uninheritable\r\n\r\n// Thanks to John Resig and Dean Edwards for inspiration!\r\n\r\nexport function Class() {}\r\n\r\nClass.extend = function (props) {\r\n\r\n\t// @function extend(props: Object): Function\r\n\t// [Extends the current class](#class-inheritance) given the properties to be included.\r\n\t// Returns a Javascript function that is a class constructor (to be called with `new`).\r\n\tvar NewClass = function () {\r\n\r\n\t\t// call the constructor\r\n\t\tif (this.initialize) {\r\n\t\t\tthis.initialize.apply(this, arguments);\r\n\t\t}\r\n\r\n\t\t// call all constructor hooks\r\n\t\tthis.callInitHooks();\r\n\t};\r\n\r\n\tvar parentProto = NewClass.__super__ = this.prototype;\r\n\r\n\tvar proto = Util.create(parentProto);\r\n\tproto.constructor = NewClass;\r\n\r\n\tNewClass.prototype = proto;\r\n\r\n\t// inherit parent's statics\r\n\tfor (var i in this) {\r\n\t\tif (Object.prototype.hasOwnProperty.call(this, i) && i !== 'prototype' && i !== '__super__') {\r\n\t\t\tNewClass[i] = this[i];\r\n\t\t}\r\n\t}\r\n\r\n\t// mix static properties into the class\r\n\tif (props.statics) {\r\n\t\tUtil.extend(NewClass, props.statics);\r\n\t\tdelete props.statics;\r\n\t}\r\n\r\n\t// mix includes into the prototype\r\n\tif (props.includes) {\r\n\t\tcheckDeprecatedMixinEvents(props.includes);\r\n\t\tUtil.extend.apply(null, [proto].concat(props.includes));\r\n\t\tdelete props.includes;\r\n\t}\r\n\r\n\t// merge options\r\n\tif (proto.options) {\r\n\t\tprops.options = Util.extend(Util.create(proto.options), props.options);\r\n\t}\r\n\r\n\t// mix given properties into the prototype\r\n\tUtil.extend(proto, props);\r\n\r\n\tproto._initHooks = [];\r\n\r\n\t// add method for calling all hooks\r\n\tproto.callInitHooks = function () {\r\n\r\n\t\tif (this._initHooksCalled) { return; }\r\n\r\n\t\tif (parentProto.callInitHooks) {\r\n\t\t\tparentProto.callInitHooks.call(this);\r\n\t\t}\r\n\r\n\t\tthis._initHooksCalled = true;\r\n\r\n\t\tfor (var i = 0, len = proto._initHooks.length; i < len; i++) {\r\n\t\t\tproto._initHooks[i].call(this);\r\n\t\t}\r\n\t};\r\n\r\n\treturn NewClass;\r\n};\r\n\r\n\r\n// @function include(properties: Object): this\r\n// [Includes a mixin](#class-includes) into the current class.\r\nClass.include = function (props) {\r\n\tUtil.extend(this.prototype, props);\r\n\treturn this;\r\n};\r\n\r\n// @function mergeOptions(options: Object): this\r\n// [Merges `options`](#class-options) into the defaults of the class.\r\nClass.mergeOptions = function (options) {\r\n\tUtil.extend(this.prototype.options, options);\r\n\treturn this;\r\n};\r\n\r\n// @function addInitHook(fn: Function): this\r\n// Adds a [constructor hook](#class-constructor-hooks) to the class.\r\nClass.addInitHook = function (fn) { // (Function) || (String, args...)\r\n\tvar args = Array.prototype.slice.call(arguments, 1);\r\n\r\n\tvar init = typeof fn === 'function' ? fn : function () {\r\n\t\tthis[fn].apply(this, args);\r\n\t};\r\n\r\n\tthis.prototype._initHooks = this.prototype._initHooks || [];\r\n\tthis.prototype._initHooks.push(init);\r\n\treturn this;\r\n};\r\n\r\nfunction checkDeprecatedMixinEvents(includes) {\r\n\tif (typeof L === 'undefined' || !L || !L.Mixin) { return; }\r\n\r\n\tincludes = Util.isArray(includes) ? includes : [includes];\r\n\r\n\tfor (var i = 0; i < includes.length; i++) {\r\n\t\tif (includes[i] === L.Mixin.Events) {\r\n\t\t\tconsole.warn('Deprecated include of L.Mixin.Events: ' +\r\n\t\t\t\t'this property will be removed in future releases, ' +\r\n\t\t\t\t'please inherit from L.Evented instead.', new Error().stack);\r\n\t\t}\r\n\t}\r\n}\r\n","import {Class} from './Class';\r\nimport * as Util from './Util';\r\n\r\n/*\r\n * @class Evented\r\n * @aka L.Evented\r\n * @inherits Class\r\n *\r\n * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event).\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * map.on('click', function(e) {\r\n * \talert(e.latlng);\r\n * } );\r\n * ```\r\n *\r\n * Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:\r\n *\r\n * ```js\r\n * function onClick(e) { ... }\r\n *\r\n * map.on('click', onClick);\r\n * map.off('click', onClick);\r\n * ```\r\n */\r\n\r\nexport var Events = {\r\n\t/* @method on(type: String, fn: Function, context?: Object): this\r\n\t * Adds a listener function (`fn`) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. `'click dblclick'`).\r\n\t *\r\n\t * @alternative\r\n\t * @method on(eventMap: Object): this\r\n\t * Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`\r\n\t */\r\n\ton: function (types, fn, context) {\r\n\r\n\t\t// types can be a map of types/handlers\r\n\t\tif (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\t// we don't process space-separated events here for performance;\r\n\t\t\t\t// it's a hot path since Layer uses the on(obj) syntax\r\n\t\t\t\tthis._on(type, types[type], fn);\r\n\t\t\t}\r\n\r\n\t\t} else {\r\n\t\t\t// types can be a string of space-separated words\r\n\t\t\ttypes = Util.splitWords(types);\r\n\r\n\t\t\tfor (var i = 0, len = types.length; i < len; i++) {\r\n\t\t\t\tthis._on(types[i], fn, context);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t/* @method off(type: String, fn?: Function, context?: Object): this\r\n\t * Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to `on`, you must pass the same context to `off` in order to remove the listener.\r\n\t *\r\n\t * @alternative\r\n\t * @method off(eventMap: Object): this\r\n\t * Removes a set of type/listener pairs.\r\n\t *\r\n\t * @alternative\r\n\t * @method off: this\r\n\t * Removes all listeners to all events on the object. This includes implicitly attached events.\r\n\t */\r\n\toff: function (types, fn, context) {\r\n\r\n\t\tif (!types) {\r\n\t\t\t// clear all listeners if called without arguments\r\n\t\t\tdelete this._events;\r\n\r\n\t\t} else if (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\tthis._off(type, types[type], fn);\r\n\t\t\t}\r\n\r\n\t\t} else {\r\n\t\t\ttypes = Util.splitWords(types);\r\n\r\n\t\t\tfor (var i = 0, len = types.length; i < len; i++) {\r\n\t\t\t\tthis._off(types[i], fn, context);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// attach listener (without syntactic sugar now)\r\n\t_on: function (type, fn, context) {\r\n\t\tthis._events = this._events || {};\r\n\r\n\t\t/* get/init listeners for type */\r\n\t\tvar typeListeners = this._events[type];\r\n\t\tif (!typeListeners) {\r\n\t\t\ttypeListeners = [];\r\n\t\t\tthis._events[type] = typeListeners;\r\n\t\t}\r\n\r\n\t\tif (context === this) {\r\n\t\t\t// Less memory footprint.\r\n\t\t\tcontext = undefined;\r\n\t\t}\r\n\t\tvar newListener = {fn: fn, ctx: context},\r\n\t\t listeners = typeListeners;\r\n\r\n\t\t// check if fn already there\r\n\t\tfor (var i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\tif (listeners[i].fn === fn && listeners[i].ctx === context) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlisteners.push(newListener);\r\n\t},\r\n\r\n\t_off: function (type, fn, context) {\r\n\t\tvar listeners,\r\n\t\t i,\r\n\t\t len;\r\n\r\n\t\tif (!this._events) { return; }\r\n\r\n\t\tlisteners = this._events[type];\r\n\r\n\t\tif (!listeners) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!fn) {\r\n\t\t\t// Set all removed listeners to noop so they are not called if remove happens in fire\r\n\t\t\tfor (i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\t\tlisteners[i].fn = Util.falseFn;\r\n\t\t\t}\r\n\t\t\t// clear all listeners for a type if function isn't specified\r\n\t\t\tdelete this._events[type];\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (context === this) {\r\n\t\t\tcontext = undefined;\r\n\t\t}\r\n\r\n\t\tif (listeners) {\r\n\r\n\t\t\t// find fn and remove it\r\n\t\t\tfor (i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\t\tvar l = listeners[i];\r\n\t\t\t\tif (l.ctx !== context) { continue; }\r\n\t\t\t\tif (l.fn === fn) {\r\n\r\n\t\t\t\t\t// set the removed listener to noop so that's not called if remove happens in fire\r\n\t\t\t\t\tl.fn = Util.falseFn;\r\n\r\n\t\t\t\t\tif (this._firingCount) {\r\n\t\t\t\t\t\t/* copy array in case events are being fired */\r\n\t\t\t\t\t\tthis._events[type] = listeners = listeners.slice();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tlisteners.splice(i, 1);\r\n\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method fire(type: String, data?: Object, propagate?: Boolean): this\r\n\t// Fires an event of the specified type. You can optionally provide an data\r\n\t// object ā the first argument of the listener function will contain its\r\n\t// properties. The event can optionally be propagated to event parents.\r\n\tfire: function (type, data, propagate) {\r\n\t\tif (!this.listens(type, propagate)) { return this; }\r\n\r\n\t\tvar event = Util.extend({}, data, {\r\n\t\t\ttype: type,\r\n\t\t\ttarget: this,\r\n\t\t\tsourceTarget: data && data.sourceTarget || this\r\n\t\t});\r\n\r\n\t\tif (this._events) {\r\n\t\t\tvar listeners = this._events[type];\r\n\r\n\t\t\tif (listeners) {\r\n\t\t\t\tthis._firingCount = (this._firingCount + 1) || 1;\r\n\t\t\t\tfor (var i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\t\t\tvar l = listeners[i];\r\n\t\t\t\t\tl.fn.call(l.ctx || this, event);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis._firingCount--;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (propagate) {\r\n\t\t\t// propagate the event to parents (set with addEventParent)\r\n\t\t\tthis._propagateEvent(event);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method listens(type: String): Boolean\r\n\t// Returns `true` if a particular event type has any listeners attached to it.\r\n\tlistens: function (type, propagate) {\r\n\t\tvar listeners = this._events && this._events[type];\r\n\t\tif (listeners && listeners.length) { return true; }\r\n\r\n\t\tif (propagate) {\r\n\t\t\t// also check parents for listeners if event propagates\r\n\t\t\tfor (var id in this._eventParents) {\r\n\t\t\t\tif (this._eventParents[id].listens(type, propagate)) { return true; }\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t},\r\n\r\n\t// @method once(ā¦): this\r\n\t// Behaves as [`on(ā¦)`](#evented-on), except the listener will only get fired once and then removed.\r\n\tonce: function (types, fn, context) {\r\n\r\n\t\tif (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\tthis.once(type, types[type], fn);\r\n\t\t\t}\r\n\t\t\treturn this;\r\n\t\t}\r\n\r\n\t\tvar handler = Util.bind(function () {\r\n\t\t\tthis\r\n\t\t\t .off(types, fn, context)\r\n\t\t\t .off(types, handler, context);\r\n\t\t}, this);\r\n\r\n\t\t// add a listener that's executed once and removed after that\r\n\t\treturn this\r\n\t\t .on(types, fn, context)\r\n\t\t .on(types, handler, context);\r\n\t},\r\n\r\n\t// @method addEventParent(obj: Evented): this\r\n\t// Adds an event parent - an `Evented` that will receive propagated events\r\n\taddEventParent: function (obj) {\r\n\t\tthis._eventParents = this._eventParents || {};\r\n\t\tthis._eventParents[Util.stamp(obj)] = obj;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeEventParent(obj: Evented): this\r\n\t// Removes an event parent, so it will stop receiving propagated events\r\n\tremoveEventParent: function (obj) {\r\n\t\tif (this._eventParents) {\r\n\t\t\tdelete this._eventParents[Util.stamp(obj)];\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_propagateEvent: function (e) {\r\n\t\tfor (var id in this._eventParents) {\r\n\t\t\tthis._eventParents[id].fire(e.type, Util.extend({\r\n\t\t\t\tlayer: e.target,\r\n\t\t\t\tpropagatedFrom: e.target\r\n\t\t\t}, e), true);\r\n\t\t}\r\n\t}\r\n};\r\n\r\n// aliases; we should ditch those eventually\r\n\r\n// @method addEventListener(ā¦): this\r\n// Alias to [`on(ā¦)`](#evented-on)\r\nEvents.addEventListener = Events.on;\r\n\r\n// @method removeEventListener(ā¦): this\r\n// Alias to [`off(ā¦)`](#evented-off)\r\n\r\n// @method clearAllEventListeners(ā¦): this\r\n// Alias to [`off()`](#evented-off)\r\nEvents.removeEventListener = Events.clearAllEventListeners = Events.off;\r\n\r\n// @method addOneTimeEventListener(ā¦): this\r\n// Alias to [`once(ā¦)`](#evented-once)\r\nEvents.addOneTimeEventListener = Events.once;\r\n\r\n// @method fireEvent(ā¦): this\r\n// Alias to [`fire(ā¦)`](#evented-fire)\r\nEvents.fireEvent = Events.fire;\r\n\r\n// @method hasEventListeners(ā¦): Boolean\r\n// Alias to [`listens(ā¦)`](#evented-listens)\r\nEvents.hasEventListeners = Events.listens;\r\n\r\nexport var Evented = Class.extend(Events);\r\n","import {isArray, formatNum} from '../core/Util';\r\n\r\n/*\r\n * @class Point\r\n * @aka L.Point\r\n *\r\n * Represents a point with `x` and `y` coordinates in pixels.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var point = L.point(200, 300);\r\n * ```\r\n *\r\n * All Leaflet methods and options that accept `Point` objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent:\r\n *\r\n * ```js\r\n * map.panBy([200, 300]);\r\n * map.panBy(L.point(200, 300));\r\n * ```\r\n *\r\n * Note that `Point` does not inherit from Leaflet's `Class` object,\r\n * which means new classes can't inherit from it, and new methods\r\n * can't be added to it with the `include` function.\r\n */\r\n\r\nexport function Point(x, y, round) {\r\n\t// @property x: Number; The `x` coordinate of the point\r\n\tthis.x = (round ? Math.round(x) : x);\r\n\t// @property y: Number; The `y` coordinate of the point\r\n\tthis.y = (round ? Math.round(y) : y);\r\n}\r\n\r\nvar trunc = Math.trunc || function (v) {\r\n\treturn v > 0 ? Math.floor(v) : Math.ceil(v);\r\n};\r\n\r\nPoint.prototype = {\r\n\r\n\t// @method clone(): Point\r\n\t// Returns a copy of the current point.\r\n\tclone: function () {\r\n\t\treturn new Point(this.x, this.y);\r\n\t},\r\n\r\n\t// @method add(otherPoint: Point): Point\r\n\t// Returns the result of addition of the current and the given points.\r\n\tadd: function (point) {\r\n\t\t// non-destructive, returns a new point\r\n\t\treturn this.clone()._add(toPoint(point));\r\n\t},\r\n\r\n\t_add: function (point) {\r\n\t\t// destructive, used directly for performance in situations where it's safe to modify existing point\r\n\t\tthis.x += point.x;\r\n\t\tthis.y += point.y;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method subtract(otherPoint: Point): Point\r\n\t// Returns the result of subtraction of the given point from the current.\r\n\tsubtract: function (point) {\r\n\t\treturn this.clone()._subtract(toPoint(point));\r\n\t},\r\n\r\n\t_subtract: function (point) {\r\n\t\tthis.x -= point.x;\r\n\t\tthis.y -= point.y;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method divideBy(num: Number): Point\r\n\t// Returns the result of division of the current point by the given number.\r\n\tdivideBy: function (num) {\r\n\t\treturn this.clone()._divideBy(num);\r\n\t},\r\n\r\n\t_divideBy: function (num) {\r\n\t\tthis.x /= num;\r\n\t\tthis.y /= num;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method multiplyBy(num: Number): Point\r\n\t// Returns the result of multiplication of the current point by the given number.\r\n\tmultiplyBy: function (num) {\r\n\t\treturn this.clone()._multiplyBy(num);\r\n\t},\r\n\r\n\t_multiplyBy: function (num) {\r\n\t\tthis.x *= num;\r\n\t\tthis.y *= num;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method scaleBy(scale: Point): Point\r\n\t// Multiply each coordinate of the current point by each coordinate of\r\n\t// `scale`. In linear algebra terms, multiply the point by the\r\n\t// [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation)\r\n\t// defined by `scale`.\r\n\tscaleBy: function (point) {\r\n\t\treturn new Point(this.x * point.x, this.y * point.y);\r\n\t},\r\n\r\n\t// @method unscaleBy(scale: Point): Point\r\n\t// Inverse of `scaleBy`. Divide each coordinate of the current point by\r\n\t// each coordinate of `scale`.\r\n\tunscaleBy: function (point) {\r\n\t\treturn new Point(this.x / point.x, this.y / point.y);\r\n\t},\r\n\r\n\t// @method round(): Point\r\n\t// Returns a copy of the current point with rounded coordinates.\r\n\tround: function () {\r\n\t\treturn this.clone()._round();\r\n\t},\r\n\r\n\t_round: function () {\r\n\t\tthis.x = Math.round(this.x);\r\n\t\tthis.y = Math.round(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method floor(): Point\r\n\t// Returns a copy of the current point with floored coordinates (rounded down).\r\n\tfloor: function () {\r\n\t\treturn this.clone()._floor();\r\n\t},\r\n\r\n\t_floor: function () {\r\n\t\tthis.x = Math.floor(this.x);\r\n\t\tthis.y = Math.floor(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method ceil(): Point\r\n\t// Returns a copy of the current point with ceiled coordinates (rounded up).\r\n\tceil: function () {\r\n\t\treturn this.clone()._ceil();\r\n\t},\r\n\r\n\t_ceil: function () {\r\n\t\tthis.x = Math.ceil(this.x);\r\n\t\tthis.y = Math.ceil(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method trunc(): Point\r\n\t// Returns a copy of the current point with truncated coordinates (rounded towards zero).\r\n\ttrunc: function () {\r\n\t\treturn this.clone()._trunc();\r\n\t},\r\n\r\n\t_trunc: function () {\r\n\t\tthis.x = trunc(this.x);\r\n\t\tthis.y = trunc(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method distanceTo(otherPoint: Point): Number\r\n\t// Returns the cartesian distance between the current and the given points.\r\n\tdistanceTo: function (point) {\r\n\t\tpoint = toPoint(point);\r\n\r\n\t\tvar x = point.x - this.x,\r\n\t\t y = point.y - this.y;\r\n\r\n\t\treturn Math.sqrt(x * x + y * y);\r\n\t},\r\n\r\n\t// @method equals(otherPoint: Point): Boolean\r\n\t// Returns `true` if the given point has the same coordinates.\r\n\tequals: function (point) {\r\n\t\tpoint = toPoint(point);\r\n\r\n\t\treturn point.x === this.x &&\r\n\t\t point.y === this.y;\r\n\t},\r\n\r\n\t// @method contains(otherPoint: Point): Boolean\r\n\t// Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).\r\n\tcontains: function (point) {\r\n\t\tpoint = toPoint(point);\r\n\r\n\t\treturn Math.abs(point.x) <= Math.abs(this.x) &&\r\n\t\t Math.abs(point.y) <= Math.abs(this.y);\r\n\t},\r\n\r\n\t// @method toString(): String\r\n\t// Returns a string representation of the point for debugging purposes.\r\n\ttoString: function () {\r\n\t\treturn 'Point(' +\r\n\t\t formatNum(this.x) + ', ' +\r\n\t\t formatNum(this.y) + ')';\r\n\t}\r\n};\r\n\r\n// @factory L.point(x: Number, y: Number, round?: Boolean)\r\n// Creates a Point object with the given `x` and `y` coordinates. If optional `round` is set to true, rounds the `x` and `y` values.\r\n\r\n// @alternative\r\n// @factory L.point(coords: Number[])\r\n// Expects an array of the form `[x, y]` instead.\r\n\r\n// @alternative\r\n// @factory L.point(coords: Object)\r\n// Expects a plain object of the form `{x: Number, y: Number}` instead.\r\nexport function toPoint(x, y, round) {\r\n\tif (x instanceof Point) {\r\n\t\treturn x;\r\n\t}\r\n\tif (isArray(x)) {\r\n\t\treturn new Point(x[0], x[1]);\r\n\t}\r\n\tif (x === undefined || x === null) {\r\n\t\treturn x;\r\n\t}\r\n\tif (typeof x === 'object' && 'x' in x && 'y' in x) {\r\n\t\treturn new Point(x.x, x.y);\r\n\t}\r\n\treturn new Point(x, y, round);\r\n}\r\n","import {Point, toPoint} from './Point';\r\n\r\n/*\r\n * @class Bounds\r\n * @aka L.Bounds\r\n *\r\n * Represents a rectangular area in pixel coordinates.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var p1 = L.point(10, 10),\r\n * p2 = L.point(40, 60),\r\n * bounds = L.bounds(p1, p2);\r\n * ```\r\n *\r\n * All Leaflet methods that accept `Bounds` objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:\r\n *\r\n * ```js\r\n * otherBounds.intersects([[10, 10], [40, 60]]);\r\n * ```\r\n *\r\n * Note that `Bounds` does not inherit from Leaflet's `Class` object,\r\n * which means new classes can't inherit from it, and new methods\r\n * can't be added to it with the `include` function.\r\n */\r\n\r\nexport function Bounds(a, b) {\r\n\tif (!a) { return; }\r\n\r\n\tvar points = b ? [a, b] : a;\r\n\r\n\tfor (var i = 0, len = points.length; i < len; i++) {\r\n\t\tthis.extend(points[i]);\r\n\t}\r\n}\r\n\r\nBounds.prototype = {\r\n\t// @method extend(point: Point): this\r\n\t// Extends the bounds to contain the given point.\r\n\textend: function (point) { // (Point)\r\n\t\tpoint = toPoint(point);\r\n\r\n\t\t// @property min: Point\r\n\t\t// The top left corner of the rectangle.\r\n\t\t// @property max: Point\r\n\t\t// The bottom right corner of the rectangle.\r\n\t\tif (!this.min && !this.max) {\r\n\t\t\tthis.min = point.clone();\r\n\t\t\tthis.max = point.clone();\r\n\t\t} else {\r\n\t\t\tthis.min.x = Math.min(point.x, this.min.x);\r\n\t\t\tthis.max.x = Math.max(point.x, this.max.x);\r\n\t\t\tthis.min.y = Math.min(point.y, this.min.y);\r\n\t\t\tthis.max.y = Math.max(point.y, this.max.y);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method getCenter(round?: Boolean): Point\r\n\t// Returns the center point of the bounds.\r\n\tgetCenter: function (round) {\r\n\t\treturn new Point(\r\n\t\t (this.min.x + this.max.x) / 2,\r\n\t\t (this.min.y + this.max.y) / 2, round);\r\n\t},\r\n\r\n\t// @method getBottomLeft(): Point\r\n\t// Returns the bottom-left point of the bounds.\r\n\tgetBottomLeft: function () {\r\n\t\treturn new Point(this.min.x, this.max.y);\r\n\t},\r\n\r\n\t// @method getTopRight(): Point\r\n\t// Returns the top-right point of the bounds.\r\n\tgetTopRight: function () { // -> Point\r\n\t\treturn new Point(this.max.x, this.min.y);\r\n\t},\r\n\r\n\t// @method getTopLeft(): Point\r\n\t// Returns the top-left point of the bounds (i.e. [`this.min`](#bounds-min)).\r\n\tgetTopLeft: function () {\r\n\t\treturn this.min; // left, top\r\n\t},\r\n\r\n\t// @method getBottomRight(): Point\r\n\t// Returns the bottom-right point of the bounds (i.e. [`this.max`](#bounds-max)).\r\n\tgetBottomRight: function () {\r\n\t\treturn this.max; // right, bottom\r\n\t},\r\n\r\n\t// @method getSize(): Point\r\n\t// Returns the size of the given bounds\r\n\tgetSize: function () {\r\n\t\treturn this.max.subtract(this.min);\r\n\t},\r\n\r\n\t// @method contains(otherBounds: Bounds): Boolean\r\n\t// Returns `true` if the rectangle contains the given one.\r\n\t// @alternative\r\n\t// @method contains(point: Point): Boolean\r\n\t// Returns `true` if the rectangle contains the given point.\r\n\tcontains: function (obj) {\r\n\t\tvar min, max;\r\n\r\n\t\tif (typeof obj[0] === 'number' || obj instanceof Point) {\r\n\t\t\tobj = toPoint(obj);\r\n\t\t} else {\r\n\t\t\tobj = toBounds(obj);\r\n\t\t}\r\n\r\n\t\tif (obj instanceof Bounds) {\r\n\t\t\tmin = obj.min;\r\n\t\t\tmax = obj.max;\r\n\t\t} else {\r\n\t\t\tmin = max = obj;\r\n\t\t}\r\n\r\n\t\treturn (min.x >= this.min.x) &&\r\n\t\t (max.x <= this.max.x) &&\r\n\t\t (min.y >= this.min.y) &&\r\n\t\t (max.y <= this.max.y);\r\n\t},\r\n\r\n\t// @method intersects(otherBounds: Bounds): Boolean\r\n\t// Returns `true` if the rectangle intersects the given bounds. Two bounds\r\n\t// intersect if they have at least one point in common.\r\n\tintersects: function (bounds) { // (Bounds) -> Boolean\r\n\t\tbounds = toBounds(bounds);\r\n\r\n\t\tvar min = this.min,\r\n\t\t max = this.max,\r\n\t\t min2 = bounds.min,\r\n\t\t max2 = bounds.max,\r\n\t\t xIntersects = (max2.x >= min.x) && (min2.x <= max.x),\r\n\t\t yIntersects = (max2.y >= min.y) && (min2.y <= max.y);\r\n\r\n\t\treturn xIntersects && yIntersects;\r\n\t},\r\n\r\n\t// @method overlaps(otherBounds: Bounds): Boolean\r\n\t// Returns `true` if the rectangle overlaps the given bounds. Two bounds\r\n\t// overlap if their intersection is an area.\r\n\toverlaps: function (bounds) { // (Bounds) -> Boolean\r\n\t\tbounds = toBounds(bounds);\r\n\r\n\t\tvar min = this.min,\r\n\t\t max = this.max,\r\n\t\t min2 = bounds.min,\r\n\t\t max2 = bounds.max,\r\n\t\t xOverlaps = (max2.x > min.x) && (min2.x < max.x),\r\n\t\t yOverlaps = (max2.y > min.y) && (min2.y < max.y);\r\n\r\n\t\treturn xOverlaps && yOverlaps;\r\n\t},\r\n\r\n\tisValid: function () {\r\n\t\treturn !!(this.min && this.max);\r\n\t}\r\n};\r\n\r\n\r\n// @factory L.bounds(corner1: Point, corner2: Point)\r\n// Creates a Bounds object from two corners coordinate pairs.\r\n// @alternative\r\n// @factory L.bounds(points: Point[])\r\n// Creates a Bounds object from the given array of points.\r\nexport function toBounds(a, b) {\r\n\tif (!a || a instanceof Bounds) {\r\n\t\treturn a;\r\n\t}\r\n\treturn new Bounds(a, b);\r\n}\r\n","import {LatLng, toLatLng} from './LatLng';\r\n\r\n/*\r\n * @class LatLngBounds\r\n * @aka L.LatLngBounds\r\n *\r\n * Represents a rectangular geographical area on a map.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var corner1 = L.latLng(40.712, -74.227),\r\n * corner2 = L.latLng(40.774, -74.125),\r\n * bounds = L.latLngBounds(corner1, corner2);\r\n * ```\r\n *\r\n * All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:\r\n *\r\n * ```js\r\n * map.fitBounds([\r\n * \t[40.712, -74.227],\r\n * \t[40.774, -74.125]\r\n * ]);\r\n * ```\r\n *\r\n * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.\r\n *\r\n * Note that `LatLngBounds` does not inherit from Leaflet's `Class` object,\r\n * which means new classes can't inherit from it, and new methods\r\n * can't be added to it with the `include` function.\r\n */\r\n\r\nexport function LatLngBounds(corner1, corner2) { // (LatLng, LatLng) or (LatLng[])\r\n\tif (!corner1) { return; }\r\n\r\n\tvar latlngs = corner2 ? [corner1, corner2] : corner1;\r\n\r\n\tfor (var i = 0, len = latlngs.length; i < len; i++) {\r\n\t\tthis.extend(latlngs[i]);\r\n\t}\r\n}\r\n\r\nLatLngBounds.prototype = {\r\n\r\n\t// @method extend(latlng: LatLng): this\r\n\t// Extend the bounds to contain the given point\r\n\r\n\t// @alternative\r\n\t// @method extend(otherBounds: LatLngBounds): this\r\n\t// Extend the bounds to contain the given bounds\r\n\textend: function (obj) {\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2, ne2;\r\n\r\n\t\tif (obj instanceof LatLng) {\r\n\t\t\tsw2 = obj;\r\n\t\t\tne2 = obj;\r\n\r\n\t\t} else if (obj instanceof LatLngBounds) {\r\n\t\t\tsw2 = obj._southWest;\r\n\t\t\tne2 = obj._northEast;\r\n\r\n\t\t\tif (!sw2 || !ne2) { return this; }\r\n\r\n\t\t} else {\r\n\t\t\treturn obj ? this.extend(toLatLng(obj) || toLatLngBounds(obj)) : this;\r\n\t\t}\r\n\r\n\t\tif (!sw && !ne) {\r\n\t\t\tthis._southWest = new LatLng(sw2.lat, sw2.lng);\r\n\t\t\tthis._northEast = new LatLng(ne2.lat, ne2.lng);\r\n\t\t} else {\r\n\t\t\tsw.lat = Math.min(sw2.lat, sw.lat);\r\n\t\t\tsw.lng = Math.min(sw2.lng, sw.lng);\r\n\t\t\tne.lat = Math.max(ne2.lat, ne.lat);\r\n\t\t\tne.lng = Math.max(ne2.lng, ne.lng);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method pad(bufferRatio: Number): LatLngBounds\r\n\t// Returns bounds created by extending or retracting the current bounds by a given ratio in each direction.\r\n\t// For example, a ratio of 0.5 extends the bounds by 50% in each direction.\r\n\t// Negative values will retract the bounds.\r\n\tpad: function (bufferRatio) {\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,\r\n\t\t widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;\r\n\r\n\t\treturn new LatLngBounds(\r\n\t\t new LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),\r\n\t\t new LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));\r\n\t},\r\n\r\n\t// @method getCenter(): LatLng\r\n\t// Returns the center point of the bounds.\r\n\tgetCenter: function () {\r\n\t\treturn new LatLng(\r\n\t\t (this._southWest.lat + this._northEast.lat) / 2,\r\n\t\t (this._southWest.lng + this._northEast.lng) / 2);\r\n\t},\r\n\r\n\t// @method getSouthWest(): LatLng\r\n\t// Returns the south-west point of the bounds.\r\n\tgetSouthWest: function () {\r\n\t\treturn this._southWest;\r\n\t},\r\n\r\n\t// @method getNorthEast(): LatLng\r\n\t// Returns the north-east point of the bounds.\r\n\tgetNorthEast: function () {\r\n\t\treturn this._northEast;\r\n\t},\r\n\r\n\t// @method getNorthWest(): LatLng\r\n\t// Returns the north-west point of the bounds.\r\n\tgetNorthWest: function () {\r\n\t\treturn new LatLng(this.getNorth(), this.getWest());\r\n\t},\r\n\r\n\t// @method getSouthEast(): LatLng\r\n\t// Returns the south-east point of the bounds.\r\n\tgetSouthEast: function () {\r\n\t\treturn new LatLng(this.getSouth(), this.getEast());\r\n\t},\r\n\r\n\t// @method getWest(): Number\r\n\t// Returns the west longitude of the bounds\r\n\tgetWest: function () {\r\n\t\treturn this._southWest.lng;\r\n\t},\r\n\r\n\t// @method getSouth(): Number\r\n\t// Returns the south latitude of the bounds\r\n\tgetSouth: function () {\r\n\t\treturn this._southWest.lat;\r\n\t},\r\n\r\n\t// @method getEast(): Number\r\n\t// Returns the east longitude of the bounds\r\n\tgetEast: function () {\r\n\t\treturn this._northEast.lng;\r\n\t},\r\n\r\n\t// @method getNorth(): Number\r\n\t// Returns the north latitude of the bounds\r\n\tgetNorth: function () {\r\n\t\treturn this._northEast.lat;\r\n\t},\r\n\r\n\t// @method contains(otherBounds: LatLngBounds): Boolean\r\n\t// Returns `true` if the rectangle contains the given one.\r\n\r\n\t// @alternative\r\n\t// @method contains (latlng: LatLng): Boolean\r\n\t// Returns `true` if the rectangle contains the given point.\r\n\tcontains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean\r\n\t\tif (typeof obj[0] === 'number' || obj instanceof LatLng || 'lat' in obj) {\r\n\t\t\tobj = toLatLng(obj);\r\n\t\t} else {\r\n\t\t\tobj = toLatLngBounds(obj);\r\n\t\t}\r\n\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2, ne2;\r\n\r\n\t\tif (obj instanceof LatLngBounds) {\r\n\t\t\tsw2 = obj.getSouthWest();\r\n\t\t\tne2 = obj.getNorthEast();\r\n\t\t} else {\r\n\t\t\tsw2 = ne2 = obj;\r\n\t\t}\r\n\r\n\t\treturn (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&\r\n\t\t (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);\r\n\t},\r\n\r\n\t// @method intersects(otherBounds: LatLngBounds): Boolean\r\n\t// Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.\r\n\tintersects: function (bounds) {\r\n\t\tbounds = toLatLngBounds(bounds);\r\n\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2 = bounds.getSouthWest(),\r\n\t\t ne2 = bounds.getNorthEast(),\r\n\r\n\t\t latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),\r\n\t\t lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);\r\n\r\n\t\treturn latIntersects && lngIntersects;\r\n\t},\r\n\r\n\t// @method overlaps(otherBounds: LatLngBounds): Boolean\r\n\t// Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.\r\n\toverlaps: function (bounds) {\r\n\t\tbounds = toLatLngBounds(bounds);\r\n\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2 = bounds.getSouthWest(),\r\n\t\t ne2 = bounds.getNorthEast(),\r\n\r\n\t\t latOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),\r\n\t\t lngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);\r\n\r\n\t\treturn latOverlaps && lngOverlaps;\r\n\t},\r\n\r\n\t// @method toBBoxString(): String\r\n\t// Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.\r\n\ttoBBoxString: function () {\r\n\t\treturn [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\r\n\t},\r\n\r\n\t// @method equals(otherBounds: LatLngBounds, maxMargin?: Number): Boolean\r\n\t// Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting `maxMargin` to a small number.\r\n\tequals: function (bounds, maxMargin) {\r\n\t\tif (!bounds) { return false; }\r\n\r\n\t\tbounds = toLatLngBounds(bounds);\r\n\r\n\t\treturn this._southWest.equals(bounds.getSouthWest(), maxMargin) &&\r\n\t\t this._northEast.equals(bounds.getNorthEast(), maxMargin);\r\n\t},\r\n\r\n\t// @method isValid(): Boolean\r\n\t// Returns `true` if the bounds are properly initialized.\r\n\tisValid: function () {\r\n\t\treturn !!(this._southWest && this._northEast);\r\n\t}\r\n};\r\n\r\n// TODO International date line?\r\n\r\n// @factory L.latLngBounds(corner1: LatLng, corner2: LatLng)\r\n// Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle.\r\n\r\n// @alternative\r\n// @factory L.latLngBounds(latlngs: LatLng[])\r\n// Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds).\r\nexport function toLatLngBounds(a, b) {\r\n\tif (a instanceof LatLngBounds) {\r\n\t\treturn a;\r\n\t}\r\n\treturn new LatLngBounds(a, b);\r\n}\r\n","import * as Util from '../core/Util';\r\nimport {Earth} from './crs/CRS.Earth';\r\nimport {toLatLngBounds} from './LatLngBounds';\r\n\r\n/* @class LatLng\r\n * @aka L.LatLng\r\n *\r\n * Represents a geographical point with a certain latitude and longitude.\r\n *\r\n * @example\r\n *\r\n * ```\r\n * var latlng = L.latLng(50.5, 30.5);\r\n * ```\r\n *\r\n * All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent:\r\n *\r\n * ```\r\n * map.panTo([50, 30]);\r\n * map.panTo({lon: 30, lat: 50});\r\n * map.panTo({lat: 50, lng: 30});\r\n * map.panTo(L.latLng(50, 30));\r\n * ```\r\n *\r\n * Note that `LatLng` does not inherit from Leaflet's `Class` object,\r\n * which means new classes can't inherit from it, and new methods\r\n * can't be added to it with the `include` function.\r\n */\r\n\r\nexport function LatLng(lat, lng, alt) {\r\n\tif (isNaN(lat) || isNaN(lng)) {\r\n\t\tthrow new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');\r\n\t}\r\n\r\n\t// @property lat: Number\r\n\t// Latitude in degrees\r\n\tthis.lat = +lat;\r\n\r\n\t// @property lng: Number\r\n\t// Longitude in degrees\r\n\tthis.lng = +lng;\r\n\r\n\t// @property alt: Number\r\n\t// Altitude in meters (optional)\r\n\tif (alt !== undefined) {\r\n\t\tthis.alt = +alt;\r\n\t}\r\n}\r\n\r\nLatLng.prototype = {\r\n\t// @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean\r\n\t// Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overridden by setting `maxMargin` to a small number.\r\n\tequals: function (obj, maxMargin) {\r\n\t\tif (!obj) { return false; }\r\n\r\n\t\tobj = toLatLng(obj);\r\n\r\n\t\tvar margin = Math.max(\r\n\t\t Math.abs(this.lat - obj.lat),\r\n\t\t Math.abs(this.lng - obj.lng));\r\n\r\n\t\treturn margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin);\r\n\t},\r\n\r\n\t// @method toString(): String\r\n\t// Returns a string representation of the point (for debugging purposes).\r\n\ttoString: function (precision) {\r\n\t\treturn 'LatLng(' +\r\n\t\t Util.formatNum(this.lat, precision) + ', ' +\r\n\t\t Util.formatNum(this.lng, precision) + ')';\r\n\t},\r\n\r\n\t// @method distanceTo(otherLatLng: LatLng): Number\r\n\t// Returns the distance (in meters) to the given `LatLng` calculated using the [Spherical Law of Cosines](https://en.wikipedia.org/wiki/Spherical_law_of_cosines).\r\n\tdistanceTo: function (other) {\r\n\t\treturn Earth.distance(this, toLatLng(other));\r\n\t},\r\n\r\n\t// @method wrap(): LatLng\r\n\t// Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees.\r\n\twrap: function () {\r\n\t\treturn Earth.wrapLatLng(this);\r\n\t},\r\n\r\n\t// @method toBounds(sizeInMeters: Number): LatLngBounds\r\n\t// Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2` meters apart from the `LatLng`.\r\n\ttoBounds: function (sizeInMeters) {\r\n\t\tvar latAccuracy = 180 * sizeInMeters / 40075017,\r\n\t\t lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);\r\n\r\n\t\treturn toLatLngBounds(\r\n\t\t [this.lat - latAccuracy, this.lng - lngAccuracy],\r\n\t\t [this.lat + latAccuracy, this.lng + lngAccuracy]);\r\n\t},\r\n\r\n\tclone: function () {\r\n\t\treturn new LatLng(this.lat, this.lng, this.alt);\r\n\t}\r\n};\r\n\r\n\r\n\r\n// @factory L.latLng(latitude: Number, longitude: Number, altitude?: Number): LatLng\r\n// Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude).\r\n\r\n// @alternative\r\n// @factory L.latLng(coords: Array): LatLng\r\n// Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead.\r\n\r\n// @alternative\r\n// @factory L.latLng(coords: Object): LatLng\r\n// Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead.\r\n\r\nexport function toLatLng(a, b, c) {\r\n\tif (a instanceof LatLng) {\r\n\t\treturn a;\r\n\t}\r\n\tif (Util.isArray(a) && typeof a[0] !== 'object') {\r\n\t\tif (a.length === 3) {\r\n\t\t\treturn new LatLng(a[0], a[1], a[2]);\r\n\t\t}\r\n\t\tif (a.length === 2) {\r\n\t\t\treturn new LatLng(a[0], a[1]);\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\tif (a === undefined || a === null) {\r\n\t\treturn a;\r\n\t}\r\n\tif (typeof a === 'object' && 'lat' in a) {\r\n\t\treturn new LatLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt);\r\n\t}\r\n\tif (b === undefined) {\r\n\t\treturn null;\r\n\t}\r\n\treturn new LatLng(a, b, c);\r\n}\r\n","\r\nimport {Bounds} from '../../geometry/Bounds';\r\nimport {LatLng} from '../LatLng';\r\nimport {LatLngBounds} from '../LatLngBounds';\r\nimport * as Util from '../../core/Util';\r\n\r\n/*\r\n * @namespace CRS\r\n * @crs L.CRS.Base\r\n * Object that defines coordinate reference systems for projecting\r\n * geographical points into pixel (screen) coordinates and back (and to\r\n * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See\r\n * [spatial reference system](http://en.wikipedia.org/wiki/Coordinate_reference_system).\r\n *\r\n * Leaflet defines the most usual CRSs by default. If you want to use a\r\n * CRS not defined by default, take a look at the\r\n * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) plugin.\r\n *\r\n * Note that the CRS instances do not inherit from Leaflet's `Class` object,\r\n * and can't be instantiated. Also, new classes can't inherit from them,\r\n * and methods can't be added to them with the `include` function.\r\n */\r\n\r\nexport var CRS = {\r\n\t// @method latLngToPoint(latlng: LatLng, zoom: Number): Point\r\n\t// Projects geographical coordinates into pixel coordinates for a given zoom.\r\n\tlatLngToPoint: function (latlng, zoom) {\r\n\t\tvar projectedPoint = this.projection.project(latlng),\r\n\t\t scale = this.scale(zoom);\r\n\r\n\t\treturn this.transformation._transform(projectedPoint, scale);\r\n\t},\r\n\r\n\t// @method pointToLatLng(point: Point, zoom: Number): LatLng\r\n\t// The inverse of `latLngToPoint`. Projects pixel coordinates on a given\r\n\t// zoom into geographical coordinates.\r\n\tpointToLatLng: function (point, zoom) {\r\n\t\tvar scale = this.scale(zoom),\r\n\t\t untransformedPoint = this.transformation.untransform(point, scale);\r\n\r\n\t\treturn this.projection.unproject(untransformedPoint);\r\n\t},\r\n\r\n\t// @method project(latlng: LatLng): Point\r\n\t// Projects geographical coordinates into coordinates in units accepted for\r\n\t// this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).\r\n\tproject: function (latlng) {\r\n\t\treturn this.projection.project(latlng);\r\n\t},\r\n\r\n\t// @method unproject(point: Point): LatLng\r\n\t// Given a projected coordinate returns the corresponding LatLng.\r\n\t// The inverse of `project`.\r\n\tunproject: function (point) {\r\n\t\treturn this.projection.unproject(point);\r\n\t},\r\n\r\n\t// @method scale(zoom: Number): Number\r\n\t// Returns the scale used when transforming projected coordinates into\r\n\t// pixel coordinates for a particular zoom. For example, it returns\r\n\t// `256 * 2^zoom` for Mercator-based CRS.\r\n\tscale: function (zoom) {\r\n\t\treturn 256 * Math.pow(2, zoom);\r\n\t},\r\n\r\n\t// @method zoom(scale: Number): Number\r\n\t// Inverse of `scale()`, returns the zoom level corresponding to a scale\r\n\t// factor of `scale`.\r\n\tzoom: function (scale) {\r\n\t\treturn Math.log(scale / 256) / Math.LN2;\r\n\t},\r\n\r\n\t// @method getProjectedBounds(zoom: Number): Bounds\r\n\t// Returns the projection's bounds scaled and transformed for the provided `zoom`.\r\n\tgetProjectedBounds: function (zoom) {\r\n\t\tif (this.infinite) { return null; }\r\n\r\n\t\tvar b = this.projection.bounds,\r\n\t\t s = this.scale(zoom),\r\n\t\t min = this.transformation.transform(b.min, s),\r\n\t\t max = this.transformation.transform(b.max, s);\r\n\r\n\t\treturn new Bounds(min, max);\r\n\t},\r\n\r\n\t// @method distance(latlng1: LatLng, latlng2: LatLng): Number\r\n\t// Returns the distance between two geographical coordinates.\r\n\r\n\t// @property code: String\r\n\t// Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`)\r\n\t//\r\n\t// @property wrapLng: Number[]\r\n\t// An array of two numbers defining whether the longitude (horizontal) coordinate\r\n\t// axis wraps around a given range and how. Defaults to `[-180, 180]` in most\r\n\t// geographical CRSs. If `undefined`, the longitude axis does not wrap around.\r\n\t//\r\n\t// @property wrapLat: Number[]\r\n\t// Like `wrapLng`, but for the latitude (vertical) axis.\r\n\r\n\t// wrapLng: [min, max],\r\n\t// wrapLat: [min, max],\r\n\r\n\t// @property infinite: Boolean\r\n\t// If true, the coordinate space will be unbounded (infinite in both axes)\r\n\tinfinite: false,\r\n\r\n\t// @method wrapLatLng(latlng: LatLng): LatLng\r\n\t// Returns a `LatLng` where lat and lng has been wrapped according to the\r\n\t// CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds.\r\n\twrapLatLng: function (latlng) {\r\n\t\tvar lng = this.wrapLng ? Util.wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng,\r\n\t\t lat = this.wrapLat ? Util.wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat,\r\n\t\t alt = latlng.alt;\r\n\r\n\t\treturn new LatLng(lat, lng, alt);\r\n\t},\r\n\r\n\t// @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds\r\n\t// Returns a `LatLngBounds` with the same size as the given one, ensuring\r\n\t// that its center is within the CRS's bounds.\r\n\t// Only accepts actual `L.LatLngBounds` instances, not arrays.\r\n\twrapLatLngBounds: function (bounds) {\r\n\t\tvar center = bounds.getCenter(),\r\n\t\t newCenter = this.wrapLatLng(center),\r\n\t\t latShift = center.lat - newCenter.lat,\r\n\t\t lngShift = center.lng - newCenter.lng;\r\n\r\n\t\tif (latShift === 0 && lngShift === 0) {\r\n\t\t\treturn bounds;\r\n\t\t}\r\n\r\n\t\tvar sw = bounds.getSouthWest(),\r\n\t\t ne = bounds.getNorthEast(),\r\n\t\t newSw = new LatLng(sw.lat - latShift, sw.lng - lngShift),\r\n\t\t newNe = new LatLng(ne.lat - latShift, ne.lng - lngShift);\r\n\r\n\t\treturn new LatLngBounds(newSw, newNe);\r\n\t}\r\n};\r\n","import {CRS} from './CRS';\nimport * as Util from '../../core/Util';\n\n/*\n * @namespace CRS\n * @crs L.CRS.Earth\n *\n * Serves as the base for CRS that are global such that they cover the earth.\n * Can only be used as the base for other CRS and cannot be used directly,\n * since it does not have a `code`, `projection` or `transformation`. `distance()` returns\n * meters.\n */\n\nexport var Earth = Util.extend({}, CRS, {\n\twrapLng: [-180, 180],\n\n\t// Mean Earth Radius, as recommended for use by\n\t// the International Union of Geodesy and Geophysics,\n\t// see http://rosettacode.org/wiki/Haversine_formula\n\tR: 6371000,\n\n\t// distance between two geographical points using spherical law of cosines approximation\n\tdistance: function (latlng1, latlng2) {\n\t\tvar rad = Math.PI / 180,\n\t\t lat1 = latlng1.lat * rad,\n\t\t lat2 = latlng2.lat * rad,\n\t\t sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2),\n\t\t sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2),\n\t\t a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon,\n\t\t c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\t\treturn this.R * c;\n\t}\n});\n","import {LatLng} from '../LatLng';\r\nimport {Bounds} from '../../geometry/Bounds';\r\nimport {Point} from '../../geometry/Point';\r\n\r\n/*\r\n * @namespace Projection\r\n * @projection L.Projection.SphericalMercator\r\n *\r\n * Spherical Mercator projection ā the most common projection for online maps,\r\n * used by almost all free and commercial tile providers. Assumes that Earth is\r\n * a sphere. Used by the `EPSG:3857` CRS.\r\n */\r\n\r\nvar earthRadius = 6378137;\r\n\r\nexport var SphericalMercator = {\r\n\r\n\tR: earthRadius,\r\n\tMAX_LATITUDE: 85.0511287798,\r\n\r\n\tproject: function (latlng) {\r\n\t\tvar d = Math.PI / 180,\r\n\t\t max = this.MAX_LATITUDE,\r\n\t\t lat = Math.max(Math.min(max, latlng.lat), -max),\r\n\t\t sin = Math.sin(lat * d);\r\n\r\n\t\treturn new Point(\r\n\t\t\tthis.R * latlng.lng * d,\r\n\t\t\tthis.R * Math.log((1 + sin) / (1 - sin)) / 2);\r\n\t},\r\n\r\n\tunproject: function (point) {\r\n\t\tvar d = 180 / Math.PI;\r\n\r\n\t\treturn new LatLng(\r\n\t\t\t(2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d,\r\n\t\t\tpoint.x * d / this.R);\r\n\t},\r\n\r\n\tbounds: (function () {\r\n\t\tvar d = earthRadius * Math.PI;\r\n\t\treturn new Bounds([-d, -d], [d, d]);\r\n\t})()\r\n};\r\n","import {Point} from './Point';\r\nimport * as Util from '../core/Util';\r\n\r\n/*\r\n * @class Transformation\r\n * @aka L.Transformation\r\n *\r\n * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d`\r\n * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing\r\n * the reverse. Used by Leaflet in its projections code.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var transformation = L.transformation(2, 5, -1, 10),\r\n * \tp = L.point(1, 2),\r\n * \tp2 = transformation.transform(p), // L.point(7, 8)\r\n * \tp3 = transformation.untransform(p2); // L.point(1, 2)\r\n * ```\r\n */\r\n\r\n\r\n// factory new L.Transformation(a: Number, b: Number, c: Number, d: Number)\r\n// Creates a `Transformation` object with the given coefficients.\r\nexport function Transformation(a, b, c, d) {\r\n\tif (Util.isArray(a)) {\r\n\t\t// use array properties\r\n\t\tthis._a = a[0];\r\n\t\tthis._b = a[1];\r\n\t\tthis._c = a[2];\r\n\t\tthis._d = a[3];\r\n\t\treturn;\r\n\t}\r\n\tthis._a = a;\r\n\tthis._b = b;\r\n\tthis._c = c;\r\n\tthis._d = d;\r\n}\r\n\r\nTransformation.prototype = {\r\n\t// @method transform(point: Point, scale?: Number): Point\r\n\t// Returns a transformed point, optionally multiplied by the given scale.\r\n\t// Only accepts actual `L.Point` instances, not arrays.\r\n\ttransform: function (point, scale) { // (Point, Number) -> Point\r\n\t\treturn this._transform(point.clone(), scale);\r\n\t},\r\n\r\n\t// destructive transform (faster)\r\n\t_transform: function (point, scale) {\r\n\t\tscale = scale || 1;\r\n\t\tpoint.x = scale * (this._a * point.x + this._b);\r\n\t\tpoint.y = scale * (this._c * point.y + this._d);\r\n\t\treturn point;\r\n\t},\r\n\r\n\t// @method untransform(point: Point, scale?: Number): Point\r\n\t// Returns the reverse transformation of the given point, optionally divided\r\n\t// by the given scale. Only accepts actual `L.Point` instances, not arrays.\r\n\tuntransform: function (point, scale) {\r\n\t\tscale = scale || 1;\r\n\t\treturn new Point(\r\n\t\t (point.x / scale - this._b) / this._a,\r\n\t\t (point.y / scale - this._d) / this._c);\r\n\t}\r\n};\r\n\r\n// factory L.transformation(a: Number, b: Number, c: Number, d: Number)\r\n\r\n// @factory L.transformation(a: Number, b: Number, c: Number, d: Number)\r\n// Instantiates a Transformation object with the given coefficients.\r\n\r\n// @alternative\r\n// @factory L.transformation(coefficients: Array): Transformation\r\n// Expects an coefficients array of the form\r\n// `[a: Number, b: Number, c: Number, d: Number]`.\r\n\r\nexport function toTransformation(a, b, c, d) {\r\n\treturn new Transformation(a, b, c, d);\r\n}\r\n","import {Earth} from './CRS.Earth';\r\nimport {SphericalMercator} from '../projection/Projection.SphericalMercator';\r\nimport {toTransformation} from '../../geometry/Transformation';\r\nimport * as Util from '../../core/Util';\r\n\r\n/*\r\n * @namespace CRS\r\n * @crs L.CRS.EPSG3857\r\n *\r\n * The most common CRS for online maps, used by almost all free and commercial\r\n * tile providers. Uses Spherical Mercator projection. Set in by default in\r\n * Map's `crs` option.\r\n */\r\n\r\nexport var EPSG3857 = Util.extend({}, Earth, {\r\n\tcode: 'EPSG:3857',\r\n\tprojection: SphericalMercator,\r\n\r\n\ttransformation: (function () {\r\n\t\tvar scale = 0.5 / (Math.PI * SphericalMercator.R);\r\n\t\treturn toTransformation(scale, 0.5, -scale, 0.5);\r\n\t}())\r\n});\r\n\r\nexport var EPSG900913 = Util.extend({}, EPSG3857, {\r\n\tcode: 'EPSG:900913'\r\n});\r\n","import * as Browser from '../../core/Browser';\n\n// @namespace SVG; @section\n// There are several static functions which can be called without instantiating L.SVG:\n\n// @function create(name: String): SVGElement\n// Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement),\n// corresponding to the class name passed. For example, using 'line' will return\n// an instance of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement).\nexport function svgCreate(name) {\n\treturn document.createElementNS('http://www.w3.org/2000/svg', name);\n}\n\n// @function pointsToPath(rings: Point[], closed: Boolean): String\n// Generates a SVG path string for multiple rings, with each ring turning\n// into \"M..L..L..\" instructions\nexport function pointsToPath(rings, closed) {\n\tvar str = '',\n\ti, j, len, len2, points, p;\n\n\tfor (i = 0, len = rings.length; i < len; i++) {\n\t\tpoints = rings[i];\n\n\t\tfor (j = 0, len2 = points.length; j < len2; j++) {\n\t\t\tp = points[j];\n\t\t\tstr += (j ? 'L' : 'M') + p.x + ' ' + p.y;\n\t\t}\n\n\t\t// closes the ring for polygons; \"x\" is VML syntax\n\t\tstr += closed ? (Browser.svg ? 'z' : 'x') : '';\n\t}\n\n\t// SVG complains about empty path strings\n\treturn str || 'M0 0';\n}\n\n\n\n\n","import * as Util from './Util';\r\nimport {svgCreate} from '../layer/vector/SVG.Util';\r\n\r\n/*\r\n * @namespace Browser\r\n * @aka L.Browser\r\n *\r\n * A namespace with static properties for browser/feature detection used by Leaflet internally.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * if (L.Browser.ielt9) {\r\n * alert('Upgrade your browser, dude!');\r\n * }\r\n * ```\r\n */\r\n\r\nvar style = document.documentElement.style;\r\n\r\n// @property ie: Boolean; `true` for all Internet Explorer versions (not Edge).\r\nexport var ie = 'ActiveXObject' in window;\r\n\r\n// @property ielt9: Boolean; `true` for Internet Explorer versions less than 9.\r\nexport var ielt9 = ie && !document.addEventListener;\r\n\r\n// @property edge: Boolean; `true` for the Edge web browser.\r\nexport var edge = 'msLaunchUri' in navigator && !('documentMode' in document);\r\n\r\n// @property webkit: Boolean;\r\n// `true` for webkit-based browsers like Chrome and Safari (including mobile versions).\r\nexport var webkit = userAgentContains('webkit');\r\n\r\n// @property android: Boolean\r\n// `true` for any browser running on an Android platform.\r\nexport var android = userAgentContains('android');\r\n\r\n// @property android23: Boolean; `true` for browsers running on Android 2 or Android 3.\r\nexport var android23 = userAgentContains('android 2') || userAgentContains('android 3');\r\n\r\n/* See https://stackoverflow.com/a/17961266 for details on detecting stock Android */\r\nvar webkitVer = parseInt(/WebKit\\/([0-9]+)|$/.exec(navigator.userAgent)[1], 10); // also matches AppleWebKit\r\n// @property androidStock: Boolean; `true` for the Android stock browser (i.e. not Chrome)\r\nexport var androidStock = android && userAgentContains('Google') && webkitVer < 537 && !('AudioNode' in window);\r\n\r\n// @property opera: Boolean; `true` for the Opera browser\r\nexport var opera = !!window.opera;\r\n\r\n// @property chrome: Boolean; `true` for the Chrome browser.\r\nexport var chrome = !edge && userAgentContains('chrome');\r\n\r\n// @property gecko: Boolean; `true` for gecko-based browsers like Firefox.\r\nexport var gecko = userAgentContains('gecko') && !webkit && !opera && !ie;\r\n\r\n// @property safari: Boolean; `true` for the Safari browser.\r\nexport var safari = !chrome && userAgentContains('safari');\r\n\r\nexport var phantom = userAgentContains('phantom');\r\n\r\n// @property opera12: Boolean\r\n// `true` for the Opera browser supporting CSS transforms (version 12 or later).\r\nexport var opera12 = 'OTransition' in style;\r\n\r\n// @property win: Boolean; `true` when the browser is running in a Windows platform\r\nexport var win = navigator.platform.indexOf('Win') === 0;\r\n\r\n// @property ie3d: Boolean; `true` for all Internet Explorer versions supporting CSS transforms.\r\nexport var ie3d = ie && ('transition' in style);\r\n\r\n// @property webkit3d: Boolean; `true` for webkit-based browsers supporting CSS transforms.\r\nexport var webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23;\r\n\r\n// @property gecko3d: Boolean; `true` for gecko-based browsers supporting CSS transforms.\r\nexport var gecko3d = 'MozPerspective' in style;\r\n\r\n// @property any3d: Boolean\r\n// `true` for all browsers supporting CSS transforms.\r\nexport var any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantom;\r\n\r\n// @property mobile: Boolean; `true` for all browsers running in a mobile device.\r\nexport var mobile = typeof orientation !== 'undefined' || userAgentContains('mobile');\r\n\r\n// @property mobileWebkit: Boolean; `true` for all webkit-based browsers in a mobile device.\r\nexport var mobileWebkit = mobile && webkit;\r\n\r\n// @property mobileWebkit3d: Boolean\r\n// `true` for all webkit-based browsers in a mobile device supporting CSS transforms.\r\nexport var mobileWebkit3d = mobile && webkit3d;\r\n\r\n// @property msPointer: Boolean\r\n// `true` for browsers implementing the Microsoft touch events model (notably IE10).\r\nexport var msPointer = !window.PointerEvent && window.MSPointerEvent;\r\n\r\n// @property pointer: Boolean\r\n// `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx).\r\nexport var pointer = !!(window.PointerEvent || msPointer);\r\n\r\n// @property touch: Boolean\r\n// `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events).\r\n// This does not necessarily mean that the browser is running in a computer with\r\n// a touchscreen, it only means that the browser is capable of understanding\r\n// touch events.\r\nexport var touch = !window.L_NO_TOUCH && (pointer || 'ontouchstart' in window ||\r\n\t\t(window.DocumentTouch && document instanceof window.DocumentTouch));\r\n\r\n// @property mobileOpera: Boolean; `true` for the Opera browser in a mobile device.\r\nexport var mobileOpera = mobile && opera;\r\n\r\n// @property mobileGecko: Boolean\r\n// `true` for gecko-based browsers running in a mobile device.\r\nexport var mobileGecko = mobile && gecko;\r\n\r\n// @property retina: Boolean\r\n// `true` for browsers on a high-resolution \"retina\" screen or on any screen when browser's display zoom is more than 100%.\r\nexport var retina = (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1;\r\n\r\n// @property passiveEvents: Boolean\r\n// `true` for browsers that support passive events.\r\nexport var passiveEvents = (function () {\r\n\tvar supportsPassiveOption = false;\r\n\ttry {\r\n\t\tvar opts = Object.defineProperty({}, 'passive', {\r\n\t\t\tget: function () { // eslint-disable-line getter-return\r\n\t\t\t\tsupportsPassiveOption = true;\r\n\t\t\t}\r\n\t\t});\r\n\t\twindow.addEventListener('testPassiveEventSupport', Util.falseFn, opts);\r\n\t\twindow.removeEventListener('testPassiveEventSupport', Util.falseFn, opts);\r\n\t} catch (e) {\r\n\t\t// Errors can safely be ignored since this is only a browser support test.\r\n\t}\r\n\treturn supportsPassiveOption;\r\n}());\r\n\r\n// @property canvas: Boolean\r\n// `true` when the browser supports [`