UNPKG

@goongmaps/goong-geocoder-react

Version:

React wrapper for goong-geocoder for use with goong-map-react

11 lines (10 loc) 49.6 kB
var e,t=require("react"),n=(e=require("events"))&&"object"==typeof e&&"default"in e?e.default:e,r=require("@goongmaps/goong-map-react"),o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e,t){return e(t={exports:{}},t.exports),t.exports /** @license React v16.13.0 * react-is.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */}var s="function"==typeof Symbol&&Symbol.for,a=s?Symbol.for("react.element"):60103,u=s?Symbol.for("react.portal"):60106,c=s?Symbol.for("react.fragment"):60107,l=s?Symbol.for("react.strict_mode"):60108,h=s?Symbol.for("react.profiler"):60114,p=s?Symbol.for("react.provider"):60109,f=s?Symbol.for("react.context"):60110,d=s?Symbol.for("react.async_mode"):60111,y=s?Symbol.for("react.concurrent_mode"):60111,m=s?Symbol.for("react.forward_ref"):60112,g=s?Symbol.for("react.suspense"):60113,v=s?Symbol.for("react.suspense_list"):60120,b=s?Symbol.for("react.memo"):60115,_=s?Symbol.for("react.lazy"):60116,E=s?Symbol.for("react.block"):60121,w=s?Symbol.for("react.fundamental"):60117,O=s?Symbol.for("react.responder"):60118,x=s?Symbol.for("react.scope"):60119;function j(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case a:switch(e=e.type){case d:case y:case c:case h:case l:case g:return e;default:switch(e=e&&e.$$typeof){case f:case m:case _:case b:case p:return e;default:return t}}case u:return t}}}function C(e){return j(e)===y}var k={AsyncMode:d,ConcurrentMode:y,ContextConsumer:f,ContextProvider:p,Element:a,ForwardRef:m,Fragment:c,Lazy:_,Memo:b,Portal:u,Profiler:h,StrictMode:l,Suspense:g,isAsyncMode:function(e){return C(e)||j(e)===d},isConcurrentMode:C,isContextConsumer:function(e){return j(e)===f},isContextProvider:function(e){return j(e)===p},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===a},isForwardRef:function(e){return j(e)===m},isFragment:function(e){return j(e)===c},isLazy:function(e){return j(e)===_},isMemo:function(e){return j(e)===b},isPortal:function(e){return j(e)===u},isProfiler:function(e){return j(e)===h},isStrictMode:function(e){return j(e)===l},isSuspense:function(e){return j(e)===g},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===c||e===y||e===h||e===l||e===g||e===v||"object"==typeof e&&null!==e&&(e.$$typeof===_||e.$$typeof===b||e.$$typeof===p||e.$$typeof===f||e.$$typeof===m||e.$$typeof===w||e.$$typeof===O||e.$$typeof===x||e.$$typeof===E)},typeOf:j},S=i(function(e,t){"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,n=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,i=e?Symbol.for("react.strict_mode"):60108,s=e?Symbol.for("react.profiler"):60114,a=e?Symbol.for("react.provider"):60109,u=e?Symbol.for("react.context"):60110,c=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,h=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,f=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,y=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,g=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,b=e?Symbol.for("react.scope"):60119;function _(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:var f=e.type;switch(f){case c:case l:case o:case s:case i:case p:return f;default:var m=f&&f.$$typeof;switch(m){case u:case h:case y:case d:case a:return m;default:return t}}case r:return t}}}var E=l,w=u,O=a,x=n,j=h,C=o,k=y,S=d,P=r,R=s,T=i,L=p,I=!1;function A(e){return _(e)===l}t.AsyncMode=c,t.ConcurrentMode=E,t.ContextConsumer=w,t.ContextProvider=O,t.Element=x,t.ForwardRef=j,t.Fragment=C,t.Lazy=k,t.Memo=S,t.Portal=P,t.Profiler=R,t.StrictMode=T,t.Suspense=L,t.isAsyncMode=function(e){return I||(I=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),A(e)||_(e)===c},t.isConcurrentMode=A,t.isContextConsumer=function(e){return _(e)===u},t.isContextProvider=function(e){return _(e)===a},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},t.isForwardRef=function(e){return _(e)===h},t.isFragment=function(e){return _(e)===o},t.isLazy=function(e){return _(e)===y},t.isMemo=function(e){return _(e)===d},t.isPortal=function(e){return _(e)===r},t.isProfiler=function(e){return _(e)===s},t.isStrictMode=function(e){return _(e)===i},t.isSuspense=function(e){return _(e)===p},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===l||e===s||e===i||e===p||e===f||"object"==typeof e&&null!==e&&(e.$$typeof===y||e.$$typeof===d||e.$$typeof===a||e.$$typeof===u||e.$$typeof===h||e.$$typeof===g||e.$$typeof===v||e.$$typeof===b||e.$$typeof===m)},t.typeOf=_}()}),P=i(function(e){e.exports="production"===process.env.NODE_ENV?k:S}),R=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;function I(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var A=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,r,o=I(e),i=1;i<arguments.length;i++){for(var s in n=Object(arguments[i]))T.call(n,s)&&(o[s]=n[s]);if(R){r=R(n);for(var a=0;a<r.length;a++)L.call(n,r[a])&&(o[r[a]]=n[r[a]])}}return o},q="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",M=function(){};if("production"!==process.env.NODE_ENV){var N=q,$={},B=Function.call.bind(Object.prototype.hasOwnProperty);M=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function V(e,t,n,r,o){if("production"!==process.env.NODE_ENV)for(var i in e)if(B(e,i)){var s;try{if("function"!=typeof e[i]){var a=Error((r||"React class")+": "+n+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.");throw a.name="Invariant Violation",a}s=e[i](t,i,r,n,null,N)}catch(e){s=e}if(!s||s instanceof Error||M((r||"React class")+": type specification of "+n+" `"+i+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof s+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),s instanceof Error&&!(s.message in $)){$[s.message]=!0;var u=o?o():"";M("Failed "+n+" type: "+s.message+(null!=u?u:""))}}}V.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&($={})};var D=V,z=Function.call.bind(Object.prototype.hasOwnProperty),F=function(){};function G(){return null}function U(){}function W(){}"production"!==process.env.NODE_ENV&&(F=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),W.resetWarningCache=U;var H=i(function(e){e.exports="production"!==process.env.NODE_ENV?function(e,t){var n="function"==typeof Symbol&&Symbol.iterator,r={array:a("array"),bool:a("boolean"),func:a("function"),number:a("number"),object:a("object"),string:a("string"),symbol:a("symbol"),any:s(G),arrayOf:function(e){return s(function(t,n,r,o,s){if("function"!=typeof e)return new i("Property `"+s+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=t[n];if(!Array.isArray(a))return new i("Invalid "+o+" `"+s+"` of type `"+c(a)+"` supplied to `"+r+"`, expected an array.");for(var u=0;u<a.length;u++){var l=e(a,u,r,o,s+"["+u+"]",q);if(l instanceof Error)return l}return null})},element:s(function(t,n,r,o,s){var a=t[n];return e(a)?null:new i("Invalid "+o+" `"+s+"` of type `"+c(a)+"` supplied to `"+r+"`, expected a single ReactElement.")}),elementType:s(function(e,t,n,r,o){var s=e[t];return P.isValidElementType(s)?null:new i("Invalid "+r+" `"+o+"` of type `"+c(s)+"` supplied to `"+n+"`, expected a single ReactElement type.")}),instanceOf:function(e){return s(function(t,n,r,o,s){var a;return t[n]instanceof e?null:new i("Invalid "+o+" `"+s+"` of type `"+((a=t[n]).constructor&&a.constructor.name?a.constructor.name:"<<anonymous>>")+"` supplied to `"+r+"`, expected instance of `"+(e.name||"<<anonymous>>")+"`.")})},node:s(function(e,t,n,r,o){return u(e[t])?null:new i("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")}),objectOf:function(e){return s(function(t,n,r,o,s){if("function"!=typeof e)return new i("Property `"+s+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var a=t[n],u=c(a);if("object"!==u)return new i("Invalid "+o+" `"+s+"` of type `"+u+"` supplied to `"+r+"`, expected an object.");for(var l in a)if(z(a,l)){var h=e(a,l,r,o,s+"."+l,q);if(h instanceof Error)return h}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&F(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),G;function t(t,n,r,s,a){for(var u=t[n],c=0;c<e.length;c++)if(o(u,e[c]))return null;var h=JSON.stringify(e,function(e,t){return"symbol"===l(t)?String(t):t});return new i("Invalid "+s+" `"+a+"` of value `"+String(u)+"` supplied to `"+r+"`, expected one of "+h+".")}return s(t)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&F("Invalid argument supplied to oneOfType, expected an instance of array."),G;for(var t=0;t<e.length;t++){var n=e[t];if("function"!=typeof n)return F("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+h(n)+" at index "+t+"."),G}return s(function(t,n,r,o,s){for(var a=0;a<e.length;a++)if(null==(0,e[a])(t,n,r,o,s,q))return null;return new i("Invalid "+o+" `"+s+"` supplied to `"+r+"`.")})},shape:function(e){return s(function(t,n,r,o,s){var a=t[n],u=c(a);if("object"!==u)return new i("Invalid "+o+" `"+s+"` of type `"+u+"` supplied to `"+r+"`, expected `object`.");for(var l in e){var h=e[l];if(h){var p=h(a,l,r,o,s+"."+l,q);if(p)return p}}return null})},exact:function(e){return s(function(t,n,r,o,s){var a=t[n],u=c(a);if("object"!==u)return new i("Invalid "+o+" `"+s+"` of type `"+u+"` supplied to `"+r+"`, expected `object`.");var l=A({},t[n],e);for(var h in l){var p=e[h];if(!p)return new i("Invalid "+o+" `"+s+"` key `"+h+"` supplied to `"+r+"`.\nBad object: "+JSON.stringify(t[n],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var f=p(a,h,r,o,s+"."+h,q);if(f)return f}return null})}};function o(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function i(e){this.message=e,this.stack=""}function s(e){function t(t,n,r,o,s,a,u){if(o=o||"<<anonymous>>",a=a||r,u!==q){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}return null==n[r]?t?new i(null===n[r]?"The "+s+" `"+a+"` is marked as required in `"+o+"`, but its value is `null`.":"The "+s+" `"+a+"` is marked as required in `"+o+"`, but its value is `undefined`."):null:e(n,r,o,s,a)}process;var n=t.bind(null,!1);return n.isRequired=t.bind(null,!0),n}function a(e){return s(function(t,n,r,o,s,a){var u=t[n];return c(u)!==e?new i("Invalid "+o+" `"+s+"` of type `"+l(u)+"` supplied to `"+r+"`, expected `"+e+"`."):null})}function u(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(u);if(null===t||e(t))return!0;var r=function(e){var t=e&&(n&&e[n]||e["@@iterator"]);if("function"==typeof t)return t}(t);if(!r)return!1;var o,i=r.call(t);if(r!==t.entries){for(;!(o=i.next()).done;)if(!u(o.value))return!1}else for(;!(o=i.next()).done;){var s=o.value;if(s&&!u(s[1]))return!1}return!0;default:return!1}}function c(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function l(e){if(null==e)return""+e;var t=c(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function h(e){var t=l(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return i.prototype=Error.prototype,r.checkPropTypes=D,r.resetWarningCache=D.resetWarningCache,r.PropTypes=r,r}(P.isElement):function(){function e(e,t,n,r,o,i){if(i!==q){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:W,resetWarningCache:U};return n.PropTypes=n,n}()}),K=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var r in n)J.call(n,r)&&(e[r]=n[r])}return e},J=Object.prototype.hasOwnProperty,Q=i(function(e,t){!function(){var t={};e.exports=t,t.simpleFilter=function(e,n){return n.filter(function(n){return t.test(e,n)})},t.test=function(e,n){return null!==t.match(e,n)},t.match=function(e,t,n){var r,o=0,i=[],s=t.length,a=0,u=0,c=(n=n||{}).pre||"",l=n.post||"",h=n.caseSensitive&&t||t.toLowerCase();e=n.caseSensitive&&e||e.toLowerCase();for(var p=0;p<s;p++)r=t[p],h[p]===e[o]?(r=c+r+l,o+=1,u+=1+u):u=0,a+=u,i[i.length]=r;return o===e.length?(a=h===e?Infinity:a,{rendered:i.join(""),score:a}):null},t.filter=function(e,n,r){return n&&0!==n.length?"string"!=typeof e?n:(r=r||{},n.reduce(function(n,o,i,s){var a=o;r.extract&&(a=r.extract(o));var u=t.match(e,a,r);return null!=u&&(n[n.length]={string:u.rendered,score:u.score,index:i,original:o}),n},[]).sort(function(e,t){return t.score-e.score||e.index-t.index})):[]}}()}),Z=function(e){return this.component=e,this.items=[],this.active=0,this.wrapper=document.createElement("div"),this.wrapper.className="suggestions-wrapper",this.element=document.createElement("ul"),this.element.className="suggestions",this.wrapper.appendChild(this.element),this.selectingListItem=!1,e.el.parentNode.insertBefore(this.wrapper,e.el.nextSibling),this};Z.prototype.show=function(){this.element.style.display="block"},Z.prototype.hide=function(){this.element.style.display="none"},Z.prototype.add=function(e){this.items.push(e)},Z.prototype.clear=function(){this.items=[],this.active=0},Z.prototype.isEmpty=function(){return!this.items.length},Z.prototype.isVisible=function(){return"block"===this.element.style.display},Z.prototype.draw=function(){if(this.element.innerHTML="",0!==this.items.length){for(var e=0;e<this.items.length;e++)this.drawItem(this.items[e],this.active===e);this.show()}else this.hide()},Z.prototype.drawItem=function(e,t){var n=document.createElement("li"),r=document.createElement("a");t&&(n.className+=" active"),r.innerHTML=e.string,n.appendChild(r),this.element.appendChild(n),n.addEventListener("mousedown",function(){this.selectingListItem=!0}.bind(this)),n.addEventListener("mouseup",function(){this.handleMouseUp.call(this,e)}.bind(this))},Z.prototype.handleMouseUp=function(e){this.selectingListItem=!1,this.component.value(e.original),this.clear(),this.draw()},Z.prototype.move=function(e){this.active=e,this.draw()},Z.prototype.previous=function(){this.move(0===this.active?this.items.length-1:this.active-1)},Z.prototype.next=function(){this.move(this.active===this.items.length-1?0:this.active+1)},Z.prototype.drawError=function(e){var t=document.createElement("li");t.innerHTML=e,this.element.appendChild(t),this.show()};var Y=Z,X=function(e,t,n){return this.options=K({minLength:2,limit:5,filter:!0,hideOnBlur:!0},n=n||{}),this.el=e,this.data=t||[],this.list=new Y(this),this.query="",this.selected=null,this.list.draw(),this.el.addEventListener("keyup",function(e){this.handleKeyUp(e.keyCode)}.bind(this),!1),this.el.addEventListener("keydown",function(e){this.handleKeyDown(e)}.bind(this)),this.el.addEventListener("focus",function(){this.handleFocus()}.bind(this)),this.el.addEventListener("blur",function(){this.handleBlur()}.bind(this)),this.el.addEventListener("paste",function(e){this.handlePaste(e)}.bind(this)),this.render=this.options.render?this.options.render.bind(this):this.render.bind(this),this.getItemValue=this.options.getItemValue?this.options.getItemValue.bind(this):this.getItemValue.bind(this),this};X.prototype.handleKeyUp=function(e){40!==e&&38!==e&&27!==e&&13!==e&&9!==e&&this.handleInputChange(this.el.value)},X.prototype.handleKeyDown=function(e){switch(e.keyCode){case 13:case 9:this.list.isEmpty()||(this.list.isVisible()&&e.preventDefault(),this.value(this.list.items[this.list.active].original),this.list.hide());break;case 27:this.list.isEmpty()||this.list.hide();break;case 38:this.list.previous();break;case 40:this.list.next()}},X.prototype.handleBlur=function(){!this.list.selectingListItem&&this.options.hideOnBlur&&this.list.hide()},X.prototype.handlePaste=function(e){if(e.clipboardData)this.handleInputChange(e.clipboardData.getData("Text"));else{var t=this;setTimeout(function(){t.handleInputChange(e.target.value)},100)}},X.prototype.handleInputChange=function(e){this.query=this.normalize(e),this.list.clear(),this.query.length<this.options.minLength?this.list.draw():this.getCandidates(function(e){for(var t=0;t<e.length&&(this.list.add(e[t]),t!==this.options.limit-1);t++);this.list.draw()}.bind(this))},X.prototype.handleFocus=function(){this.list.isEmpty()||this.list.show(),this.list.selectingListItem=!1},X.prototype.update=function(e){this.data=e,this.handleKeyUp()},X.prototype.clear=function(){this.data=[],this.list.clear()},X.prototype.normalize=function(e){return e.toLowerCase()},X.prototype.match=function(e,t){return e.indexOf(t)>-1},X.prototype.value=function(e){if(this.selected=e,this.el.value=this.getItemValue(e),document.createEvent){var t=document.createEvent("HTMLEvents");t.initEvent("change",!0,!1),this.el.dispatchEvent(t)}else this.el.fireEvent("onchange")},X.prototype.getCandidates=function(e){var t={pre:"<strong>",post:"</strong>",extract:function(e){return this.getItemValue(e)}.bind(this)};e(this.options.filter?Q.filter(this.query,this.data,t).map(function(e){return{original:e.original,string:this.render(e.original,e.string)}}.bind(this)):this.data.map(function(e){return{original:e,string:this.render(e)}}.bind(this)))},X.prototype.getItemValue=function(e){return e},X.prototype.render=function(e,t){if(t)return t;for(var n=this.getItemValue(e.original?e.original:e),r=this.normalize(n),o=r.lastIndexOf(this.query);o>-1;){var i=o+this.query.length;n=n.slice(0,o)+"<strong>"+n.slice(o,i)+"</strong>"+n.slice(i),o=r.slice(0,o).lastIndexOf(this.query)}return n},X.prototype.renderError=function(e){this.list.drawError(e)};var ee=X,te=i(function(e){window.Suggestions=e.exports=ee}),ne=/^\s+|\s+$/g,re=/^[-+]0x[0-9a-f]+$/i,oe=/^0b[01]+$/i,ie=/^0o[0-7]+$/i,se=parseInt,ae="object"==typeof self&&self&&self.Object===Object&&self,ue="object"==typeof o&&o&&o.Object===Object&&o||ae||Function("return this")(),ce=Object.prototype.toString,le=Math.max,he=Math.min,pe=function(){return ue.Date.now()};function fe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function de(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==ce.call(e)}(e))return NaN;if(fe(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=fe(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(ne,"");var n=oe.test(e);return n||ie.test(e)?se(e.slice(2),n?2:8):re.test(e)?NaN:+e}function ye(e,t){this.request=e,this.headers=t.headers,this.rawBody=t.body,this.statusCode=t.statusCode;try{this.body=JSON.parse(t.body||"{}")}catch(e){this.body=t.body}var n;this.links=(n=this.headers.link)?n.split(/,\s*</).reduce(function(e,t){var n=function(e){var t=e.match(/<?([^>]*)>(.*)/);if(!t)return null;var n=t[1],r=t[2].split(";"),o=null,i=r.reduce(function(e,t){var n=function(e){var t=e.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return t?{key:t[1],value:t[2]}:null}(t);return n?"rel"===n.key?(o||(o=n.value),e):(e[n.key]=n.value,e):e},{});return o?{url:n,rel:o,params:i}:null}(t);return n?(n.rel.split(/\s+/).forEach(function(t){e[t]||(e[t]={url:n.url,params:n.params})}),e):e},{}):{}}ye.prototype.hasNextPage=function(){return!!this.links.next},ye.prototype.nextPage=function(){return this.hasNextPage()?this.request._extend({path:this.links.next.url}):null};var me=ye,ge=function(e){var t,n=e.type||"HttpError";if(e.body)try{t=JSON.parse(e.body)}catch(n){t=e.body}else t=null;var r=e.message||null;r||("string"==typeof t?r=t:t&&"string"==typeof t.message?r=t.message:"RequestAbortedError"===n&&(r="Request aborted")),this.message=r,this.type=n,this.statusCode=e.statusCode||null,this.request=e.request,this.body=t},ve={};function be(e){var t=e.total,n=e.loaded;return{total:t,transferred:n,percent:100*n/t}}var _e=i(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new o(r,i||e,s),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=this._events[n?n+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var r=0,o=t.length,i=new Array(o);r<o;r++)i[r]=t[r].fn;return i},a.prototype.listenerCount=function(e){var t=this._events[n?n+e:e];return t?t.fn?1:t.length:0},a.prototype.emit=function(e,t,r,o,i,s){var a=n?n+e:e;if(!this._events[a])return!1;var u,c,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,i),!0;case 6:return l.fn.call(l.context,t,r,o,i,s),!0}for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var p,f=l.length;for(c=0;c<f;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),h){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,r);break;case 4:l[c].fn.call(l[c].context,t,r,o);break;default:if(!u)for(p=1,u=new Array(h-1);p<h;p++)u[p-1]=arguments[p];l[c].fn.apply(l[c].context,u)}}return!0},a.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||s(this,i);else{for(var u=0,c=[],l=a.length;u<l;u++)(a[u].fn!==t||o&&!a[u].once||r&&a[u].context!==r)&&c.push(a[u]);c.length?this._events[i]=1===c.length?c[0]:c:s(this,i)}return this},a.prototype.removeAllListeners=function(e){var t;return e?this._events[t=n?n+e:e]&&s(this,t):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a});function Ee(e){return Array.isArray(e)?e.map(encodeURIComponent).join(","):encodeURIComponent(String(e))}function we(e,t,n){if(!1===n||null===n)return e;var r=/\?/.test(e)?"&":"?",o=encodeURIComponent(t);return void 0!==n&&""!==n&&!0!==n&&(o+="="+Ee(n)),""+e+r+o}var Oe={appendQueryObject:function(e,t){if(!t)return e;var n=e;return Object.keys(t).forEach(function(e){var r=t[e];void 0!==r&&(Array.isArray(r)&&(r=r.filter(function(e){return!!e}).join(",")),n=we(n,e,r))}),n},appendQueryParam:we,prependOrigin:function(e,t){if(!t)return e;if("http"===e.slice(0,4))return e;var n="/"===e[0]?"":"/";return""+t.replace(/\/$/,"")+n+e},interpolateRouteParams:function(e,t){return t?e.replace(/\/:([a-zA-Z0-9]+)/g,function(e,n){var r=t[n];if(void 0===r)throw new Error("Unspecified route parameter "+n);return"/"+Ee(r)}):e}},xe=1;function je(e,t){if(!e)throw new Error("GAPIRequest requires a client");if(!t||!t.path||!t.method)throw new Error("GAPIRequest requires an options object with path and method properties");var n={};t.body&&(n["content-type"]="application/json");var r=K(n,t.headers),o=Object.keys(r).reduce(function(e,t){return e[t.toLowerCase()]=r[t],e},{});this.id=xe++,this._options=t,this.emitter=new _e,this.client=e,this.response=null,this.error=null,this.sent=!1,this.aborted=!1,this.path=t.path,this.method=t.method,this.origin=t.origin||e.origin,this.query=t.query||{},this.params=t.params||{},this.body=t.body||null,this.file=t.file||null,this.encoding=t.encoding||"utf8",this.sendFileAs=t.sendFileAs||null,this.headers=o}je.prototype.url=function(e){var t=Oe.prependOrigin(this.path,this.origin);t=Oe.appendQueryObject(t,this.query);var n=this.params,r=null==e?this.client.accessToken:e;return r&&(t=Oe.appendQueryParam(t,"api_key",r)),Oe.interpolateRouteParams(t,n)},je.prototype.send=function(){var e=this;if(e.sent)throw new Error("This request has already been sent. Check the response and error properties. Create a new request with clone().");return e.sent=!0,e.client.sendRequest(e).then(function(t){return e.response=t,e.emitter.emit("response",t),t},function(t){throw e.error=t,e.emitter.emit("error",t),t})},je.prototype.abort=function(){this._nextPageRequest&&(this._nextPageRequest.abort(),delete this._nextPageRequest),this.response||this.error||this.aborted||(this.aborted=!0,this.client.abortRequest(this))},je.prototype.eachPage=function(e){var t=this;function n(n){e(null,n,function(){delete t._nextPageRequest;var e=n.nextPage();e&&(t._nextPageRequest=e,o(e))})}function r(t){e(t,null,function(){})}function o(e){e.send().then(n,r)}o(this)},je.prototype.clone=function(){return this._extend()},je.prototype._extend=function(e){var t=K(this._options,e);return new je(this.client,t)};var Ce=je;function ke(e){if(!e||!e.accessToken)throw new Error("Cannot create a client without an API key");this.accessToken=e.accessToken,this.origin=e.origin||"https://rsapi.goong.io"}ke.prototype.createRequest=function(e){return new Ce(this,e)};var Se=ke;function Pe(e){Se.call(this,e)}(Pe.prototype=Object.create(Se.prototype)).constructor=Pe,Pe.prototype.sendRequest=function(e){return Promise.resolve().then(function(){var t=function(e,t){var n=e.url(t),r=new window.XMLHttpRequest;return r.open(e.method,n),Object.keys(e.headers).forEach(function(t){r.setRequestHeader(t,e.headers[t])}),r}(e,e.client.accessToken);return function(e,t){return new Promise(function(n,r){t.onprogress=function(t){e.emitter.emit("downloadProgress",be(t))};var o=e.file;o&&(t.upload.onprogress=function(t){e.emitter.emit("uploadProgress",be(t))}),t.onerror=function(e){r(e)},t.onabort=function(){var t=new ge({request:e,type:"RequestAbortedError"});r(t)},t.onload=function(){if(delete ve[e.id],t.status<200||t.status>=400){var o=new ge({request:e,body:t.response,statusCode:t.status});r(o)}else n(t)};var i=e.body;"string"==typeof i?t.send(i):i?t.send(JSON.stringify(i)):o?t.send(o):t.send(),ve[e.id]=t}).then(function(t){return function(e,t){return new me(e,{body:t.response,headers:(n=t.getAllResponseHeaders(),r={},n?(n.trim().split(/[\r|\n]+/).forEach(function(e){var t=function(e){var t=e.indexOf(":");return{name:e.substring(0,t).trim().toLowerCase(),value:e.substring(t+1).trim()}}(e);r[t.name]=t.value}),r):r),statusCode:t.status});var n,r}(e,t)})}(e,t)})},Pe.prototype.abortRequest=function(e){var t=ve[e.id];t&&(t.abort(),delete ve[e.id])};var Re=function(e){return new Pe(e)},Te=Re,Le=Object.prototype.toString,Ie={};function Ae(e){var t=Array.isArray(e);return function(n){var r=qe(Ie.plainArray,n);if(r)return r;if(t&&n.length!==e.length)return"an array with "+e.length+" items";for(var o=0;o<n.length;o++)if(r=qe(t?e[o]:e,n[o]))return[o].concat(r)}}function qe(e,t){if(null!=t||e.hasOwnProperty("__required")){var n=e(t);return n?Array.isArray(n)?n:[n]:void 0}}function Me(e,t){var n=e.length,r=e[n-1],o=e.slice(0,n-1);return 0===o.length&&(o=["value"]),t=K(t,{path:o}),"function"==typeof r?r(t):$e(t,function(e){return"must be "+(/^an? /.test(t=e)?t:/^[aeiou]/i.test(t)?"an "+t:/^[a-z]/i.test(t)?"a "+t:t)+".";var t}(r))}function Ne(e){return e.length<2?e[0]:2===e.length?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e.slice(-1)}function $e(e,t){return(Be(e.path)?"Item at position ":"")+e.path.join(".")+" "+t}function Be(e){return"number"==typeof e[e.length-1]||"number"==typeof e[0]}Ie.assert=function(e,t){return t=t||{},function(n){var r=qe(e,n);if(r){var o=Me(r,t);throw t.apiName&&(o=t.apiName+": "+o),new Error(o)}}},Ie.shape=function(e){var t,n=(t=e,Object.keys(t||{}).map(function(e){return{key:e,value:t[e]}}));return function(e){var t,r=qe(Ie.plainObject,e);if(r)return r;for(var o=[],i=0;i<n.length;i++)(r=qe(n[i].value,e[t=n[i].key]))&&o.push([t].concat(r));return o.length<2?o[0]:function(e){o=o.map(function(t){return"- "+t[0]+": "+Me(t,e).split("\n").join("\n ")});var t=e.path.join(".");return"The following properties"+("value"===t?"":" of "+t)+" have invalid values:\n "+o.join("\n ")}}},Ie.strictShape=function(e){var t=Ie.shape(e);return function(n){var r=t(n);if(r)return r;var o=Object.keys(n).reduce(function(t,n){return void 0===e[n]&&t.push(n),t},[]);return 0!==o.length?function(){return"The following keys are invalid: "+o.join(", ")}:void 0}},Ie.arrayOf=function(e){return Ae(e)},Ie.tuple=function(){var e=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);return Ae(e)},Ie.required=function(e){function t(t){return null==t?function(e){return $e(e,Be(e.path)?"cannot be undefined/null.":"is required.")}:e.apply(this,arguments)}return t.__required=!0,t},Ie.oneOfType=function(){var e=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);return function(t){var n=e.map(function(e){return qe(e,t)}).filter(Boolean);if(n.length===e.length)return n.every(function(e){return 1===e.length&&"string"==typeof e[0]})?Ne(n.map(function(e){return e[0]})):n.reduce(function(e,t){return t.length>e.length?t:e})}},Ie.equal=function(e){return function(t){if(t!==e)return JSON.stringify(e)}},Ie.oneOf=function(){var e=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments),t=e.map(function(e){return Ie.equal(e)});return Ie.oneOfType.apply(this,t)},Ie.range=function(e){var t=e[0],n=e[1];return function(e){if(qe(Ie.number,e)||e<t||e>n)return"number between "+t+" & "+n+" (inclusive)"}},Ie.any=function(){},Ie.boolean=function(e){if("boolean"!=typeof e)return"boolean"},Ie.number=function(e){if("number"!=typeof e)return"number"},Ie.plainArray=function(e){if(!Array.isArray(e))return"array"},Ie.plainObject=function(e){if(!function(e){var t;return"[object Object]"===Le.call(e)&&(null===(t=Object.getPrototypeOf(e))||t===Object.getPrototypeOf({}))}(e))return"object"},Ie.string=function(e){if("string"!=typeof e)return"string"},Ie.func=function(e){if("function"!=typeof e)return"function"},Ie.validate=qe,Ie.processMessage=Me;var Ve,De=Ie,ze=K(De,{file:function(e){if("undefined"!=typeof window){if(e instanceof o.Blob||e instanceof o.ArrayBuffer)return;return"Blob or ArrayBuffer"}if("string"!=typeof e&&void 0===e.pipe)return"Filename or Readable stream"},date:function(e){if("boolean"==typeof e)return"date";try{var t=new Date(e);if(t.getTime&&isNaN(t.getTime()))return"date"}catch(e){return"date"}},coordinates:function(e){return De.tuple(De.number,De.number)(e)},assertShape:function(e,t){return De.assert(De.strictShape(e),t)}}),Fe=(Ve={search:function(e){return ze.assertShape({input:ze.required(ze.string),location:ze.string,radius:ze.number,limit:ze.number})(e),this.client.createRequest({method:"GET",path:"/Place/AutoComplete",query:e})},placeDetail:function(e){return ze.assertShape({placeid:ze.required(ze.string)})(e),this.client.createRequest({method:"GET",path:"/Place/Detail",query:e})}},function(e){var t;t=Se.prototype.isPrototypeOf.call(e)?e:Re(e);var n=Object.create(Ve);return n.client=t,n}),Ge=n.EventEmitter;function Ue(e){this._eventEmitter=new Ge,this.options=K({},this.options,e),this.inputString="",this.fresh=!0,this.lastSelected=null}Ue.prototype={options:{zoom:16,flyTo:!0,trackProximity:!0,minLength:2,limit:5,radius:3e3,origin:"https://rsapi.goong.io",marker:!0,goongjs:null,collapsed:!1,clearAndBlurOnEsc:!1,clearOnBlur:!1,getItemValue:function(e){return e.description},render:function(e){var t=e.structured_formatting;return'<div class="goongjs-ctrl-geocoder--suggestion"><div class="goongjs-ctrl-geocoder--suggestion-title">'+t.main_text+'</div><div class="goongjs-ctrl-geocoder--suggestion-address">'+t.secondary_text+"</div></div>"}},request:null,addTo:function(e){if(e._controlContainer)e.addControl(this);else{if("string"!=typeof e||!e.startsWith("#")&&!e.startsWith("."))throw new Error("Error: addTo Container must be a goong-js map or a html element reference");var t=document.querySelectorAll(e);if(0==t.length)throw new Error("Element ",e,"not found.");if(t.length>1)throw new Error("Geocoder can only be added to a single html element");t.forEach(function(e){var t=this.onAdd();e.appendChild(t)}.bind(this))}},onAdd:function(e){e&&"string"!=typeof e&&(this._map=e),this.autoCompleteService=Fe(Te({accessToken:this.options.accessToken,origin:this.options.origin})),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onPaste=this._onPaste.bind(this),this._onBlur=this._onBlur.bind(this),this._showButton=this._showButton.bind(this),this._hideButton=this._hideButton.bind(this),this._onQueryResult=this._onQueryResult.bind(this),this.clear=this.clear.bind(this),this._updateProximity=this._updateProximity.bind(this),this._collapse=this._collapse.bind(this),this._unCollapse=this._unCollapse.bind(this),this._clear=this._clear.bind(this),this._clearOnBlur=this._clearOnBlur.bind(this);var t=this.container=document.createElement("div");t.className="goongjs-ctrl-geocoder goongjs-ctrl";var n=this.createIcon("search",'<path d="M7.4 2.5c-2.7 0-4.9 2.2-4.9 4.9s2.2 4.9 4.9 4.9c1 0 1.8-.2 2.5-.8l3.7 3.7c.2.2.4.3.8.3.7 0 1.1-.4 1.1-1.1 0-.3-.1-.5-.3-.8L11.4 10c.4-.8.8-1.6.8-2.5.1-2.8-2.1-5-4.8-5zm0 1.6c1.8 0 3.2 1.4 3.2 3.2s-1.4 3.2-3.2 3.2-3.3-1.3-3.3-3.1 1.4-3.3 3.3-3.3z"/>');this._inputEl=document.createElement("input"),this._inputEl.type="text",this._inputEl.className="goongjs-ctrl-geocoder--input",this.setPlaceholder(),this.options.collapsed&&(this._collapse(),this.container.addEventListener("mouseenter",this._unCollapse),this.container.addEventListener("mouseleave",this._collapse),this._inputEl.addEventListener("focus",this._unCollapse)),(this.options.collapsed||this.options.clearOnBlur)&&this._inputEl.addEventListener("blur",this._onBlur),this._inputEl.addEventListener("keydown",function(e,t,n){var r,o,i,s,a,u,c=0,l=!1,h=!1,p=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){var n=r,i=o;return r=o=void 0,c=t,s=e.apply(i,n)}function d(e){return c=e,a=setTimeout(m,t),l?f(e):s}function y(e){var n=e-u;return void 0===u||n>=t||n<0||h&&e-c>=i}function m(){var e=pe();if(y(e))return g(e);a=setTimeout(m,function(e){var n=t-(e-u);return h?he(n,i-(e-c)):n}(e))}function g(e){return a=void 0,p&&r?f(e):(r=o=void 0,s)}function v(){var e=pe(),n=y(e);if(r=arguments,o=this,u=e,n){if(void 0===a)return d(u);if(h)return a=setTimeout(m,t),f(u)}return void 0===a&&(a=setTimeout(m,t)),s}return t=de(t)||0,fe(void 0)&&(l=!!(void 0).leading,i=(h="maxWait"in void 0)?le(de((void 0).maxWait)||0,t):i,p="trailing"in void 0?!!(void 0).trailing:p),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,r=u=o=a=void 0},v.flush=function(){return void 0===a?s:g(pe())},v}(this._onKeyDown,200)),this._inputEl.addEventListener("paste",this._onPaste),this._inputEl.addEventListener("change",this._onChange),this.container.addEventListener("mouseenter",this._showButton),this.container.addEventListener("mouseleave",this._hideButton),this._inputEl.addEventListener("keyup",function(){}.bind(this));var r=document.createElement("div");r.classList.add("goongjs-ctrl-geocoder--pin-right"),this._clearEl=document.createElement("button"),this._clearEl.setAttribute("aria-label","Clear"),this._clearEl.addEventListener("click",this.clear),this._clearEl.className="goongjs-ctrl-geocoder--button";var o=this.createIcon("close",'<path d="M3.8 2.5c-.6 0-1.3.7-1.3 1.3 0 .3.2.7.5.8L7.2 9 3 13.2c-.3.3-.5.7-.5 1 0 .6.7 1.3 1.3 1.3.3 0 .7-.2 1-.5L9 10.8l4.2 4.2c.2.3.7.3 1 .3.6 0 1.3-.7 1.3-1.3 0-.3-.2-.7-.3-1l-4.4-4L15 4.6c.3-.2.5-.5.5-.8 0-.7-.7-1.3-1.3-1.3-.3 0-.7.2-1 .3L9 7.1 4.8 2.8c-.3-.1-.7-.3-1-.3z"/>');return this._clearEl.appendChild(o),this._loadingEl=this.createIcon("loading",'<path fill="#333" d="M4.4 4.4l.8.8c2.1-2.1 5.5-2.1 7.6 0l.8-.8c-2.5-2.5-6.7-2.5-9.2 0z"/><path opacity=".1" d="M12.8 12.9c-2.1 2.1-5.5 2.1-7.6 0-2.1-2.1-2.1-5.5 0-7.7l-.8-.8c-2.5 2.5-2.5 6.7 0 9.2s6.6 2.5 9.2 0 2.5-6.6 0-9.2l-.8.8c2.2 2.1 2.2 5.6 0 7.7z"/>'),r.appendChild(this._clearEl),r.appendChild(this._loadingEl),t.appendChild(n),t.appendChild(this._inputEl),t.appendChild(r),this._typeahead=new te(this._inputEl,[],{filter:!1,minLength:this.options.minLength,limit:this.options.limit}),this.setRenderFunction(this.options.render),this._typeahead.getItemValue=this.options.getItemValue,this.mapMarker=null,this._handleMarker=this._handleMarker.bind(this),this._map&&(this.options.trackProximity&&(this._updateProximity(),this._map.on("moveend",this._updateProximity)),this._goongjs=this.options.goongjs,!this._goongjs&&this.options.marker&&(console.error("No goongjs detected in options. Map markers are disabled. Please set options.goongjs."),this.options.marker=!1)),t},createIcon:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("class","goongjs-ctrl-geocoder--icon goongjs-ctrl-geocoder--icon-"+e),n.setAttribute("viewBox","0 0 18 18"),n.setAttribute("xml:space","preserve"),n.setAttribute("width",18),n.setAttribute("height",18),n.innerHTML=t,n},onRemove:function(){return this.container.parentNode.removeChild(this.container),this.options.trackProximity&&this._map&&this._map.off("moveend",this._updateProximity),this._removeMarker(),this._map=null,this},_onPaste:function(e){var t=(e.clipboardData||window.clipboardData).getData("text");t.length>=this.options.minLength&&this._geocode(t)},_onKeyDown:function(e){var t=27,n=9;if(e.keyCode===t&&this.options.clearAndBlurOnEsc)return this._clear(e),this._inputEl.blur();var r=e.target&&e.target.shadowRoot?e.target.shadowRoot.activeElement:e.target;if(!r||!r.value)return this.fresh=!0,e.keyCode!==n&&this.clear(e),this._clearEl.style.display="none";e.metaKey||-1!==[n,t,37,39,13,38,40].indexOf(e.keyCode)||r.value.length>=this.options.minLength&&this._geocode(r.value)},_showButton:function(){this._typeahead.selected&&(this._clearEl.style.display="block")},_hideButton:function(){this._typeahead.selected&&(this._clearEl.style.display="none")},_onBlur:function(e){this.options.clearOnBlur&&this._clearOnBlur(e),this.options.collapsed&&this._collapse()},_onChange:function(){var e=this._typeahead.selected;if(e&&JSON.stringify(e)!==this.lastSelected){if(!this.options.flyTo)return;var t=this.autoCompleteService.placeDetail({placeid:e.place_id}).send();return t.then(function(t){this._clearEl.style.display="none";var n,r=t.body;(n=K({},{zoom:this.options.zoom},this.options.flyTo)).center=[r.result.geometry.location.lng,r.result.geometry.location.lat],this._map&&this._map.flyTo(n),this.options.marker&&this._goongjs&&this._handleMarker(r),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),this.lastSelected=JSON.stringify(e),this._eventEmitter.emit("result",{result:r})}.bind(this)),t.catch(function(e){this._eventEmitter.emit("error",{error:e})}.bind(this)),t}},_geocode:function(e){var t;this._loadingEl.style.display="block",this._eventEmitter.emit("loading",{query:e}),this.inputString=e;var n={input:e,radius:this.options.radius};return this.options.trackProximity&&this._map&&this.options.proximity&&this.options.proximity.latitude&&this.options.proximity.longitude&&(n=K(n,{location:this.options.proximity.latitude+","+this.options.proximity.longitude})),(t=this.autoCompleteService.search(n).send()).then(function(e){var t=e.body;this._loadingEl.style.display="none",this.fresh&&(this.fresh=!1),t.predictions.length?(this._clearEl.style.display="block",this._eventEmitter.emit("results",t),this._typeahead.update(t.predictions)):(this._clearEl.style.display="none",this._typeahead.selected=null,this._renderNoResults(),this._eventEmitter.emit("results",t))}.bind(this)),t.catch(function(e){e&&0===e.status||(this._loadingEl.style.display="none",this._clearEl.style.display="none",this._typeahead.selected=null,this._renderError(),this._eventEmitter.emit("results",{predictions:[]}),this._eventEmitter.emit("error",{error:e}))}.bind(this)),t},_clear:function(e){e&&e.preventDefault(),this._inputEl.value="",this._typeahead.selected=null,this._typeahead.clear(),this._onChange(),this._clearEl.style.display="none",this._removeMarker(),this.lastSelected=null,this._eventEmitter.emit("clear"),this.fresh=!0},clear:function(e){this._clear(e),this._inputEl.focus()},_clearOnBlur:function(e){e.relatedTarget&&this._clear(e)},_onQueryResult:function(e){var t=e.result;this._typeahead.selected=t,this._inputEl.value=t.geometry.name},_updateProximity:function(){if(this._map)if(this._map.getZoom()>9){var e=this._map.getCenter().wrap();this.setProximity({longitude:e.lng,latitude:e.lat})}else this.setProximity(null)},_collapse:function(){this._inputEl.value||this._inputEl===document.activeElement||this.container.classList.add("goongjs-ctrl-geocoder--collapsed")},_unCollapse:function(){this.container.classList.remove("goongjs-ctrl-geocoder--collapsed")},query:function(e){return this._geocode(e).then(this._onQueryResult),this},_renderError:function(){this._renderMessage("<div class='goong-js-geocoder--error'>There was an error reaching the server</div>")},_renderNoResults:function(){this._renderMessage("<div class='goong-js-geocoder--error goongjs-gl-geocoder--no-results'>No results found</div>")},_renderMessage:function(e){this._typeahead.update([]),this._typeahead.selected=null,this._typeahead.clear(),this._typeahead.renderError(e)},_getPlaceholderText:function(){return this.options.placeholder?this.options.placeholder:"Search"},setInput:function(e){return this._inputEl.value=e,this._typeahead.selected=null,this._typeahead.clear(),this._onChange(),this},setProximity:function(e){return this.options.proximity=e,this},getProximity:function(){return this.options.proximity},setRenderFunction:function(e){return e&&"function"==typeof e&&(this._typeahead.render=e),this},getRenderFunction:function(){return this._typeahead.render},getZoom:function(){return this.options.zoom},setZoom:function(e){return this.options.zoom=e,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(e){return this.options.flyTo=e,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(e){return this.placeholder=e||this._getPlaceholderText(),this._inputEl.placeholder=this.placeholder,this._inputEl.setAttribute("aria-label",this.placeholder),this},getMinLength:function(){return this.options.minLength},setMinLength:function(e){return this.options.minLength=e,this._typeahead&&(this._typeahead.minLength=e),this},getLimit:function(){return this.options.limit},setLimit:function(e){return this.options.limit=e,this._typeahead&&(this._typeahead.options.limit=e),this},getRadius:function(){return this.options.radius},setRadius:function(e){return this.options.radius=e,this._typeahead&&(this._typeahead.options.radius=e),this},setOrigin:function(e){return this.options.origin=e,this.autoCompleteService=Fe(Te({accessToken:this.options.accessToken,origin:this.options.origin})),this},getOrigin:function(){return this.options.origin},_handleMarker:function(e){if(this._map){this._removeMarker();var t=K({},{color:"#469af7"},this.options.marker);return this.mapMarker=new this._goongjs.Marker(t),this.mapMarker.setLngLat([e.result.geometry.location.lng,e.result.geometry.location.lat]).addTo(this._map),this}},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},on:function(e,t){return this._eventEmitter.on(e,t),this},off:function(e,t){return this._eventEmitter.removeListener(e,t),this}};var We=Ue,He=["top-left","top-right","bottom-left","bottom-right"],Ke=function(e){var t,n;function o(){for(var t,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return(t=e.call.apply(e,[this].concat(o))||this).geocoder=null,t.cachedResult=null,t.initializeGeocoder=function(){var e=t.getGoongMap(),n=t.getContainerNode(),r=t.props,o=r.inputValue,i=r.render,s=r.getItemValue,a=r.onInit,u=r.position,c={accessToken:r.goongApiAccessToken,origin:r.origin,zoom:r.zoom,radius:r.radius,flyTo:!0,placeholder:r.placeholder,proximity:r.proximity,trackProximity:r.trackProximity,collapsed:r.collapsed,clearAndBlurOnEsc:r.clearAndBlurOnEsc,clearOnBlur:r.clearOnBlur,minLength:r.minLength,limit:r.limit,marker:!1};i&&"function"==typeof i&&(c.render=i),s&&"function"==typeof s&&(c.getItemValue=s),t.geocoder=new We(c),t.subscribeEvents(),n?n.appendChild(t.geocoder.onAdd(e)):e.addControl(t.geocoder,He.find(function(e){return u===e})),null!=o?t.geocoder.setInput(o):t.cachedResult&&t.geocoder.setInput(t.cachedResult.place_name),(t.cachedResult||null!=o)&&t.showClearIcon(),a(t.geocoder)},t.showClearIcon=function(){t.geocoder._clearEl.style.display="block"},t.getGoongMap=function(){var e=t.props.mapRef;return e&&e.current&&e.current.getMap()||null},t.getContainerNode=function(){var e=t.props.containerRef;return e&&e.current||null},t.subscribeEvents=function(){t.geocoder.on("clear",t.handleClear),t.geocoder.on("loading",t.handleLoading),t.geocoder.on("results",t.handleResults),t.geocoder.on("result",t.handleResult),t.geocoder.on("error",t.handleError)},t.unsubscribeEvents=function(){t.geocoder.off("clear",t.handleClear),t.geocoder.off("loading",t.handleLoading),t.geocoder.off("results",t.handleResults),t.geocoder.off("result",t.handleResult),t.geocoder.off("error",t.handleError)},t.removeGeocoder=function(){var e=t.getGoongMap();t.unsubscribeEvents(),e&&e.removeControl&&t.getGoongMap().removeControl(t.geocoder),t.geocoder=null},t.handleClear=function(){t.cachedResult=null,t.props.onClear()},t.handleLoading=function(e){t.props.onLoading(e)},t.handleResults=function(e){t.props.onResults(e)},t.handleResult=function(e){var n=e.result.result,o=t.props,i=o.onResult,s=n.geometry,a=void 0===s?{}:s;(0,o.onViewportChange)({longitude:a.location.lng,latitude:a.location.lat,zoom:t.geocoder.options.zoom,transitionInterpolator:new r.FlyToInterpolator,transitionDuration:3e3}),i(e),t.cachedResult=n,t.geocoder._typeahead.selected=null,t.showClearIcon()},t.handleError=function(e){t.props.onError(e)},t}n=e,(t=o).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var i=o.prototype;return i.componentDidMount=function(){this.initializeGeocoder()},i.componentWillUnmount=function(){this.removeGeocoder()},i.componentDidUpdate=function(){this.removeGeocoder(),this.initializeGeocoder()},i.getGeocoder=function(){return this.geocoder},i.render=function(){return null},o}(t.PureComponent);Ke.propTypes={mapRef:H.object.isRequired,containerRef:H.object,onViewportChange:H.func,goongApiAccessToken:H.string.isRequired,inputValue:H.string,origin:H.string,zoom:H.number,radius:H.number,placeholder:H.string,proximity:H.object,trackProximity:H.bool,collapsed:H.bool,clearAndBlurOnEsc:H.bool,clearOnBlur:H.bool,minLength:H.number,limit:H.number,render:H.func,getItemValue:H.func,position:H.oneOf(He),onInit:H.func,onClear:H.func,onLoading:H.func,onResults:H.func,onResult:H.func,onError:H.func},Ke.defaultProps={onViewportChange:function(){},origin:"https://rsapi.goong.io",zoom:14,radius:3e3,placeholder:"Search",trackProximity:!0,collapsed:!1,clearAndBlurOnEsc:!1,clearOnBlur:!1,minLength:2,limit:10,position:"top-right",onInit:function(){},onClear:function(){},onLoading:function(){},onResults:function(){},onResult:function(){},onError:function(){}},module.exports=Ke; //# sourceMappingURL=index.js.map