1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2626],{44908:function(e,t,n){var r=n(45652);e.exports=function(e){return e&&e.length?r(e):[]}},67196:function(e,t,n){"use strict";n.d(t,{Z:function(){return je}});var r=n(59499),s=n(67294),i=n(94184),o=n.n(i),a=n(12754),c=n(14416),l=n(37629),u=n(42279),p=n(90887);function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var h=(0,u.P1)([function(e,t){return t.area},p.Z],(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,n=e.id;return(t[n]||[]).map((function(e,t){return f(f({},e),{},{id:"".concat(n,"-").concat(t)})}))})),b=n(50029),v=n(87794),m=n.n(v),y=n(16938),g=n(58350),j=n(9669),w=n.n(j),O=n(90953),x=n(8371),S=n(4114),k=n(29775),P=n(90900),Z=n(52202),C=n(65230),N=n(92777),D=n(82262),I=n(45959),E=n(63553),R=n(37247),A=n(89734),L=n.n(A),T=n(18446),U=n.n(T),M=n(92813),B=n(36646),V=function(e,t){return e.user.areas.items.find((function(e){return e.id===t.area}))},_=(0,u.P1)([function(e){return e.subscriptions.userSelection.area},function(e){return e.subscriptions.list}],(function(e,t){return e?t.filter((function(t){return t.params.area===e.id})):[]})),F=n(10748),q=n(11163),W=n(43026),$=n(64960),K=n(20401),Q=n(51608),G=n(85893);function J(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=(0,R.Z)(e);if(t){var s=(0,R.Z)(this).constructor;n=Reflect.construct(r,arguments,s)}else n=r.apply(this,arguments);return(0,E.Z)(this,n)}}var H=function(e){(0,I.Z)(n,e);var t=J(n);function n(){var e;(0,N.Z)(this,n);for(var s=arguments.length,i=new Array(s),o=0;o<s;o++)i[o]=arguments[o];return e=t.call.apply(t,[this].concat(i)),(0,r.Z)((0,F.Z)(e),"state",{showSubscribePreview:!1}),(0,r.Z)((0,F.Z)(e),"handleCancel",(function(){var t=e.props,n=t.resetModal;(0,t.onRequestClose)(),n()})),(0,r.Z)((0,F.Z)(e),"handleShowSubscribePreview",(function(){e.setState({showSubscribePreview:!0})})),(0,r.Z)((0,F.Z)(e),"handleSubscribe",(function(){var t=e.props,n=t.subscription,r=t.activeArea,s=t.createSubscriptionToArea,i=t.updateSubscription;n.datasets.length>0?r.subscriptions?i():s():r.subscriptions?i():y.Rt.error("Data missing","Please select at least one dataset and a subscription type"),e.props.onRequestClose()})),(0,r.Z)((0,F.Z)(e),"handleGoToMySubscriptions",(function(){var t=e.props,n=t.onRequestClose,r=t.router;n(),r.push("/myrw/areas")})),(0,r.Z)((0,F.Z)(e),"handleState",(function(t){e.setState({showSubscribePreview:t})})),e}return(0,D.Z)(n,[{key:"render",value:function(){var e=this.props,t=e.areas,n=e.activeArea,r=e.userSelection,s=e.loading,i=e.subscriptionCreation,a=e.onRequestClose,c=this.state.showSubscribePreview,l=i.success,u=l?(0,G.jsxs)("p",{children:["Your subscription was successfully created.",(0,G.jsx)("strong",{children:" Please check your email address to confirm it."})]}):null,p="".concat(n.name," subscriptions");return l&&(p="Subscription saved!"),c?(0,G.jsx)(Q.Z,{handleCancel:this.handleCancel,handleSubscribe:this.handleSubscribe,onRequestClose:a,handleState:this.handleState}):(0,G.jsxs)("div",{className:"c-subscriptions-modal",children:[(0,G.jsx)(Z.Z,{className:"-light",isLoading:s}),!l&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)("div",{className:"header-div",children:[(0,G.jsx)("h2",{children:p}),u]}),(0,G.jsx)("div",{className:"selectors-container",children:(0,G.jsx)(W.Z,{properties:{name:"areas",label:"Areas"},children:(0,G.jsx)($.Z,{placeholder:"Select area",options:t,className:"-disabled",allowNonLeafSelection:!1,value:(n||{}).id})})}),(0,G.jsx)("div",{className:"separator"}),(0,G.jsx)(K.Z,{activeArea:n})]}),l&&(0,G.jsx)("div",{className:"icon-container",children:(0,G.jsx)("img",{alt:"success",src:"/static/images/components/modal/widget-saved.svg"})}),!l&&(0,G.jsxs)("div",{className:"buttons",children:[(0,G.jsx)("button",{className:"c-btn -primary",onClick:this.handleSubscribe,children:"Save"}),(0,G.jsx)("button",{className:o()({"c-btn":!0,"-secondary":!0,"-disabled":!r.datasets.length}),onClick:this.handleShowSubscribePreview,disabled:null===r.area||0===r.datasets.length,children:"Preview"}),(0,G.jsx)("button",{className:"c-btn -secondary",onClick:this.handleCancel,children:"Cancel"})]}),l&&(0,G.jsxs)("div",{className:"buttons",children:[(0,G.jsx)("button",{className:"c-btn -secondary",onClick:this.handleCancel,children:"Ok"}),(0,G.jsx)("button",{className:"c-btn -primary",onClick:this.handleGoToMySubscriptions,children:"View my subscriptions"})]})]})}}]),n}(s.PureComponent);(0,r.Z)(H,"defaultProps",{activeArea:null});var Y=(0,q.withRouter)(H);function z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};
1t%2?z(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):z(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ee(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=(0,R.Z)(e);if(t){var s=(0,R.Z)(this).constructor;n=Reflect.construct(r,arguments,s)}else n=r.apply(this,arguments);return(0,E.Z)(this,n)}}var te=function(e){(0,I.Z)(n,e);var t=ee(n);function n(){return(0,N.Z)(this,n),t.apply(this,arguments)}return(0,D.Z)(n,[{key:"UNSAFE_componentWillMount",value:function(){var e=this.props,t=e.activeArea,n=e.setUserSelection,r=(e.getAreas,e.getDatasets),s=e.getUserSubscriptions;(0,e.getUserAreas)(),r(),s(),n({area:t})}},{key:"UNSAFE_componentWillReceiveProps",value:function(e){var t=this.props,n=t.subscriptionsByArea,r=t.setUserSelection,s=e.subscriptionsByArea,i=e.activeArea,o=!U()(n,s);s.length&&o&&i&&i.subscriptions&&r({datasets:i.subscriptions.map((function(e){var t=e.datasets[0],n=e.datasetsQuery[0];return{id:t.id,label:t.name,value:t.name,subscriptions:L()(Object.keys(t.subscribable).map((function(e){return X({label:e,value:e},n.type.includes(e)&&{selected:!0})})),"label"),threshold:n.threshold}}))})}},{key:"componentWillUnmount",value:function(){var e=this.props,t=e.clearSubscriptions,n=e.clearUserSelection;(0,e.clearLocalSubscriptions)(),t(),n()}},{key:"render",value:function(){return(0,G.jsx)(Y,X({},this.props))}}]),n}(s.Component),ne=(0,c.connect)((function(e,t){return{userSelection:e.subscriptions.userSelection,activeArea:V(e,t),areas:(0,B.Ai)(e),areaFound:(0,B.ng)(e),userAreas:e.user.areas.items,subscriptionsByArea:_(e),subscription:e.subscriptions.userSelection,subscriptionCreation:e.subscriptions.subscriptionCreation,preview:e.subscriptions.list.preview,loading:e.subscriptions.areas.loading||e.subscriptions.userAreas.loading||e.subscriptions.datasets.loading}}),X(X({},M),{},{getUserAreas:l.eo}))(te),re=function(e){var t=e.onMouseDown,n=e.onRenameArea,r=e.onChangeVisibility,i=e.onEditSubscriptions,o=e.onDeleteArea,a=e.area,c=e.showSubscriptions,l=e.tooltipRef,u=(0,s.useCallback)((function(e){switch(e){case"rename":n();break;case"change-visibility":r();break;case"edit_subscriptions":i();break;case"delete_area":o();break;default:throw Error("Action '".concat(e,"' not supported"))}t()}),[n,r,i,o,t]);return(0,s.useEffect)((function(){var e=function(e){var n=l.current;n&&!n.contains(e.target)&&t()};return window.addEventListener("mousedown",e),function(){window.removeEventListener("mousedown",e)}}),[t,l]),(0,G.jsx)("div",{className:"c-area-actions-tooltip",children:(0,G.jsxs)("ul",{children:[(0,G.jsx)("li",{children:(0,G.jsx)("button",{type:"button",className:"c-button",onClick:function(){return u("rename")},children:"Rename"})}),(0,G.jsx)("li",{children:(0,G.jsx)("button",{type:"button",className:"c-button",onClick:function(){return u("change-visibility")},children:"Make ".concat(a.public?"Private":"Public")})}),c&&(0,G.jsx)("li",{children:(0,G.jsx)("button",{type:"button",className:"c-button -desktopOnly",onClick:function(){return u("edit_subscriptions")},children:"Edit subscriptions"})}),(0,G.jsx)("li",{children:(0,G.jsx)("button",{type:"button",className:"c-button",onClick:function(){return u("delete_area")},children:"Delete area"})})]})})},se=n(4730),ie=n(88767),oe=n(51290);function ae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ce(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ae(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ae(Object(n)).forEac
1h((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var le=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(0,ie.useQuery)(["fetch-subscriptions",e,t],(function(){return(0,oe.jg)(e,t)}),ce({},n))},ue=["data"];function pe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var de=function(e,t){var n=le(t,{},{enable:e,initialData:[],initialStale:!0}),i=n.data,o=(0,se.Z)(n,ue);return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pe(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({data:(0,s.useMemo)((function(){return i.filter((function(t){return t.params.area===e}))}),[i,e])},o)},fe=n(8452);function he(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function be(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?he(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):he(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ve=function(e){var t=e.area,n=e.token,r=e.removeUserArea,i=e.showSubscriptions,a=e.onMapView,c=e.onEditArea,l=e.onChangedVisibility,u=e.onDeletionArea,p=t.id,d=t.geostore,f=t.subscription,h=t.name,v=t.geostore,j=t.isVisible,N=(0,s.useRef)(null),D=(0,s.useRef)(null),I=(0,s.useRef)(null),E=(0,s.useState)({open:!1,mode:"new"}),R=E[0],A=E[1],L=(0,s.useState)(h),T=L[0],U=L[1],M=(0,s.useState)({open:!1}),B=M[0],V=M[1],_=(0,s.useState)(!0),F=_[0],q=_[1],W=(0,s.useState)({bounds:{},geojson:null}),$=W[0],K=W[1],Q=de(p,n),J=Q.data,H=Q.refetch,Y=(0,s.useCallback)((function(){return a(t)}),[a,t]),z=(0,s.useCallback)((function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];A({open:e,mode:f?"edit":"new"})}),[f]),X=(0,s.useCallback)((function(){y.Rt.confirm("Are you sure you want to delete the area ".concat(t.name,"?\n Deleting an area will delete all the subscriptions associated to it"),{onOk:function(){var e=(0,b.Z)(m().mark((function e(){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,r(t);case 3:u(),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),y.Rt.error(e.t0.message);case 9:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(){return e.apply(this,arguments)}}()})}),[r,u,t]),ee=(0,s.useCallback)((0,b.Z)(m().mark((function e(){var r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.public,e.prev=1,e.next=4,(0,x.wm)(p,{public:!r},n);case 4:l(),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),y.Rt.error("Something went wrong updating the area.");case 10:case"end":return e.stop()}}),e,null,[[1,7]])}))),[p,t,n,l]),te=(0,s.useCallback)((function(e){V((function(t){return be(be({},t),{},{open:e})}))}),[]),se=(0,s.useCallback)((function(){I.current.select()}),[]),ie=(0,s.useCallback)((function(){I.current.select()}),[]),oe=(0,s.useCallback)((function(e){U(e.target.value)}),[]),ae=(0,s.useCallback)(function(){var e=(0,b.Z)(m().mark((function e(t){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:"Escape"===t.key&&(U(h),I.current.blur());case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[h]),ce=(0,s.useCallback)(function(){var e=(0,b.Z)(m().mark((function e(t){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),t.stopPropagation(),e.prev=2,e.next=5,(0,x.wm)(p,{name:T,geostore:d},n);case 5:I.current.blur(),c&&c(p),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),y.Rt.error("Something went wrong updating the area.");case 12:case"end":return e.stop()}}),e,null,[[2,9]])}
1)));return function(t){return e.apply(this,arguments)}}(),[p,T,d,n,c]),le=(0,s.useCallback)((function(){z(!0)}),[z]),ue=(0,s.useCallback)((function(){z(!1),H()}),[z,H]);(0,s.useEffect)((function(){(0,O.U8)(v).then((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.bbox,n=e.geojson;K({bounds:{bbox:t,options:{padding:30}},geojson:n}),q(!1)})).catch((function(e){w().isCancel(e)?console.error("Cancelled by user"):y.Rt.error('Something went wrong loading your area "'.concat(h,'"')),q(!1)}))}),[t,v,h]),(0,s.useEffect)((function(){U(h)}),[h]);var pe=R.open,he=B.open,ve=$.bounds,me=$.geojson,ye=o()({"map-container":!0,"-ready":!F}),ge=(0,s.useMemo)((function(){return me?[(0,fe.n)({id:"user-area",geojson:me})]:[]}),[me]),je=(0,s.useMemo)((function(){return J.filter((function(e){return!e.confirmed}))}),[J]);return(0,G.jsxs)("div",{className:"c-area-card",children:[(0,G.jsxs)("div",{className:ye,children:[(0,G.jsx)(Z.Z,{isLoading:F,className:"-transparent"}),(0,G.jsx)(k.Z,{mapStyle:S.yO,viewport:S.Ps,basemap:"dark",boundaries:!0,bounds:ve,fitBoundsOptions:{transitionDuration:0},getCursor:function(){return"default"},doubleClickZoom:!1,scrollZoom:!1,touchZoom:!1,reuseMaps:!0,dragRotate:!1,dragPan:!1,visible:!F,children:function(e){return(0,G.jsx)(P.Z,{map:e,layers:ge})}})]}),(0,G.jsxs)("div",{className:"text-container",children:[(0,G.jsxs)("div",{className:"basic-info",children:[(0,G.jsxs)("div",{className:"name-visibility",children:[(0,G.jsx)("form",{ref:function(e){D.current=e},onSubmit:ce,children:(0,G.jsx)("input",{type:"text",id:"area-name-".concat(p),name:"area-name",required:!0,minLength:3,ref:function(e){I.current=e},onChange:oe,onClick:ie,onKeyDown:ae,value:T,className:"editable-name"})}),t.public&&(0,G.jsx)("span",{className:"is-public",children:"Public"})]}),(0,G.jsxs)("div",{className:"subscriptions",children:[J.length>0&&(0,G.jsxs)("button",{type:"button",className:"c-btn -clean",onClick:le,children:["".concat(J.length," subscription"),J.length>1&&"s",je.length>0&&" (".concat(je.length," to confirm)")]}),!J.length&&(0,G.jsx)("span",{children:"No subscriptions"})]})]}),(0,G.jsxs)("div",{className:"actions-container",children:[(0,G.jsx)("button",{type:"button",className:o()("c-btn -compressed -fs-medium",{"-primary":j,"-secondary":!j}),onClick:Y,children:j?"Active":"Show area"}),(0,G.jsx)(g.Tooltip,{visible:he,overlayClassName:"c-rc-tooltip -default",placement:"top",destroyTooltipOnHide:!0,onPopupAlign:function(e){N.current=e},overlay:(0,G.jsx)(re,{area:t,tooltipRef:N,showSubscriptions:i,onMouseDown:function(){te(!1)},onRenameArea:se,onChangeVisibility:ee,onEditSubscriptions:le,onDeleteArea:X}),children:(0,G.jsx)("button",{type:"button",className:"c-btn -tertiary -compressed -fs-medium",onClick:function(){te(!0)},children:"Edit"})})]})]}),pe&&(0,G.jsx)(C.Z,{isOpen:!0,onRequestClose:ue,children:(0,G.jsx)(ne,{area:t.id,onRequestClose:ue})})]})};ve.defaultProps={onEditArea:null};var me=ve,ye=(0,c.connect)((function(e,t){return{token:e.user.token,activeAlerts:h(e,t)}}),{removeUserArea:l.hl,getUserAreaLayerGroups:l.u4})(me),ge=function(e){var t=e.areas,n=e.className,s=e.isColumn,i=e.showSubscriptions,c=e.onMapView,l=e.onEditArea,u=e.onChangedVisibility,p=e.onDeletionArea,d=o()((0,r.Z)({"c-areas-list":!0},n,!!n));return(0,G.jsx)("div",{className:d,children:(0,G.jsxs)("div",{className:o()({row:!s}),children:[t.map((function(e){return(0,G.jsx)("div",{className:o()({"column small-12 medium-4":!s}),children:(0,G.jsx)(a.Z,{triggerOnce:!0,threshold:.25,children:function(t){var n=t.ref,r=t.inView;return(0,G.jsx)("div",{ref:n,className:"card-container",style:{height:s?335:390,width:s?300:"auto"},children:r&&(0,G.jsx)(ye,{area:e,showSubscriptions:i,onMapView:c,onEditArea:l,onChangedVisibility:u,onDeletionArea:p})})}})},e.id)})),!t.length&&(0,G.jsx)("div",{className:"no-areas-container",children:"There are no areas to display. Try creating a new one."})]})})};ge.defaultProps={className:null,isColumn:!1,showSubscriptions:!0,onEditArea:null};var je=ge},9664:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(67294),s=n(45697),i=n.n(s),o=n(1307),a=n.n(o),c=(n(82793),{defaultMode:"draw_polygon",displayControlsDefault:!1,styles:[{id:"gl-draw-line",type:"line",filter:["all",["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fab72e","line-width":2}},{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#fab72e","fill-opacity":.2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fab72e","line-width":2}},{id:"gl-draw-polygon-and-line-vertex-halo-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":8,"circle-color":"#000"}},{id:"gl-draw-polygon-and-line-vertex-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":6,"cir
1cle-color":"#fff"}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","$type","LineString"],["==","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fab72e","line-width":2}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","$type","Polygon"],["==","mode","static"]],paint:{"fill-color":"#000","fill-outline-color":"#000","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","$type","Polygon"],["==","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#000","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#ff0000"}}]}),l=function(e){var t=e.drawing,n=e.map,s=e.onDrawComplete,i=e.onReady,o=e.onEscapeKey,l=(0,r.useRef)(new(a())(c)).current,u=(0,r.useState)(!1),p=u[0],d=u[1],f=(0,r.useCallback)((function(e){"Escape"===e.key&&o()}),[o]),h=(0,r.useCallback)((function(){n.addControl(l),n.on("draw.create",(function(e){var t=e.features&&e.features[0];t&&s(t)})),d(!0),i&&i(l)}),[n,s,l,i]),b=(0,r.useCallback)((function(){n.off("draw.create"),n.removeControl(l),d(!1)}),[n,l]);return(0,r.useEffect)((function(){return t&&!p&&h(),!t&&p&&b(),t?window.addEventListener("keydown",f):window.removeEventListener("keydown",f),function(){window.removeEventListener("keydown",f)}}),[t,p,h,b,f]),null};l.propTypes={map:i().shape({}).isRequired,drawing:i().bool.isRequired,onDrawComplete:i().func.isRequired,onEscapeKey:i().func,onReady:i().func},l.defaultProps={onReady:null,onEscapeKey:null};var u=l},20401:function(e,t,n){"use strict";n.d(t,{Z:function(){return A}});var r=n(14416),s=n(92813),i=n(42279),o=n(44908),a=n.n(o),c=n(89734),l=n.n(c),u=(0,i.P1)([function(e){return e.subscriptions.datasets.list}],(function(e){return l()(a()(e.map((function(e){return{id:e.id,label:e.metadata&&e.metadata.length?e.metadata[0].name:e.name,value:e.name,subscriptions:l()(Object.keys(e.subscribable).map((function(t){return{label:t,value:t,query:(e.subscribable[t]||{}).dataQuery}})),"label"),threshold:1}}))),"label")})),p=n(27812),d=n(92777),f=n(82262),h=n(10748),b=n(45959),v=n(63553),m=n(37247),y=n(59499),g=n(67294),j=n(94184),w=n.n(j),O=n(18446),x=n.n(O),S=n(64960),k=n(43026),P=n(34094),Z=n(85893);function C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?C(Object(n),!0).forEach((function(t){(0,y.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function D(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=(0,m.Z)(e);if(t){var s=(0,m.Z)(this).constructor;n=Reflect.construct(r,arguments,s)}else n=r.apply(this,arguments);return(0,v.Z)(this,n)}}var I={id:null,label:"",value:"",subscriptions:[],threshold:1},E=function(e){(0,b.Z)(n,e);var t=D(n);function n(){var e;(0,d.Z)(this,n);for(var r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];return e=t.call.apply(t,[this].concat(s)),(0,y.Z)((0,h.Z)(e),"state",{selectedDatasets:e.props.selectedDatasets}),(0,y.Z)((0,h.Z)(e),"onAddDataset",(function(t,n){var r=e.props.setUserSelection,s=e.state.selectedDatasets;if(s[n]){var i=t.subscriptions;i[0]=N(N({},i[0]),{},{selected:!0});var o=N(N({},t),{},{subscriptions:i});s[n]=o,e.setState({selectedDatasets:(0,p.Z)(s)},(function(){r({datasets:s.filter((function(e){return null!==e.id}))})}))}else e.setState({selectedDatasets:[].concat((0,p.Z)(s),[t])},(function(){r({datasets:s.filter((function(e){return null!==e.id}))})}))})),(0,y.Z)((0,h.Z)(e),"onAddNewSubscription",(function(){var t=e.props.setUserSelection,n=e.state.selectedDatasets;e.setState({selectedDatasets:[].concat((0,p.Z)(n),[I])},(function(){t({datasets:n.filter((function(e){return null!==e.id}))})}))})),(0,y.Z)((0,h.Z)(e),"onSetSubscription",(function(t,n){var r=t.value,s=e.props.setUserSelection,i=e.state.selectedDatasets;i[n]&&(i[n]=N(N({},i[n]),{},{subscriptions:i[n].subscriptions.map((function(e){return N(N({},e),{selected:e.value===r})}))}),e.setState({selectedDatasets:(0,p.Z)(i)},(function(){s({datasets:i.filter((function(e){return null!==e.id}))})})))})),(0,y.Z)((0,h.Z)(e),"onSetthreshold",(function(t,n){var r=e.props.setUserSelection,s=e.state.selectedDatasets;s[n]&&(s[n]=N(N({},s[n]),{},{threshold:t}),e.setState({selectedDatasets:(0,p.Z)(s)},(function(){r({datasets:s.filter((function(e){return null!==e.id}))})})))})),(0,y.Z)((0,h.Z)(e),"onRemoveDataset",(function(t){var n=e.props.setUserSelection,r=e.state.selectedDatasets.filter((function(e,n){return n!==t}));e.setState({selectedDatasets:r},(function(){n({datasets:r})}))})),e}return(0,f.Z)(n,[{key:"UNSAFE_componentWillReceiveProps",value:function(e){var t=this.props.selectedDatasets,n=e.selectedDatasets;
1!x()(t,n)&&this.setState({selectedDatasets:n})}},{key:"render",value:function(){var e=this,t=this.props,n=t.datasets,r=t.activeArea,s=this.state.selectedDatasets;return(0,Z.jsxs)("div",{className:"c-dataset-manager",children:[s.map((function(t,s){return(0,Z.jsxs)("div",{className:"selectors-container",children:[(0,Z.jsx)(k.Z,{properties:{name:0===s?"dataset":null,label:0===s?"Dataset":null},children:(0,Z.jsx)(S.Z,{placeholder:"Select a dataset",className:w()({"-disabled":null===r&&(0===s&&t.value)}),options:n,clearable:!1,onValueChange:function(t){return e.onAddDataset(t,s)},allowNonLeafSelection:!1,value:t&&t.value})}),(0,Z.jsx)(k.Z,{properties:{name:0===s?"type":null,label:0===s?"Type":null},children:(0,Z.jsx)(S.Z,{placeholder:"Select a subscription type",className:w()({"-disabled":!t.subscriptions.length}),options:t.subscriptions,onValueChange:function(t){return e.onSetSubscription(t,s)},allowNonLeafSelection:!1,clearable:!1,value:(t.subscriptions.find((function(e){return e.selected}))||t.subscriptions[0]||{}).value})}),(0,Z.jsx)(k.Z,{className:"threshold-input",onChange:function(t){return e.onSetthreshold(t,s)},properties:{name:"threshold",label:0===s?"Minimum":null,type:"number",default:t.threshold,value:t.threshold},children:P.Z}),(0,Z.jsx)(k.Z,{properties:{name:"delete",label:0===s?" ":null},children:(0,Z.jsx)("button",{className:"c-btn -secondary",onClick:function(){return e.onRemoveDataset(s)},children:"Delete"})})]},s)})),(0,Z.jsx)("div",{className:"subscription-btn-container",children:(0,Z.jsx)("button",{className:w()("c-btn -b -fullwidth",{"-disabled":s.find((function(e){return null===e.id}))}),onClick:this.onAddNewSubscription,children:"Add subscription"})})]})}}]),n}(g.Component);(0,y.Z)(E,"defaultProps",{activeArea:null});var R=E,A=(0,r.connect)((function(e){return{datasets:u(e),selectedDatasets:e.subscriptions.userSelection.datasets}}),{setUserSelection:s.setUserSelection})(R)},36646:function(e,t,n){"use strict";n.d(t,{Ai:function(){return u},ng:function(){return p}});var r=n(27812),s=n(42279),i=n(89734),o=n.n(i),a=[{label:"Upload custom area",value:"upload_area"}],c=(0,s.P1)([function(e){return e.subscriptions.areas.list}],(function(e){return e.map((function(e){return{label:e.name||"",value:e.geostoreId||e.geostore,isGeostore:e.geostoreId||e.geostore,areaID:null}}))})),l=(0,s.P1)([function(e){return e.user.areas.items}],(function(e){return e.map((function(e){return{label:e.name,value:e.id,isGeostore:e.geostore,areaID:e.id,subscriptions:e.subscriptions,id:e.id}}))})),u=(0,s.P1)([c,l],(function(e,t){var n=o()([].concat((0,r.Z)(e),(0,r.Z)(t)),"label");return[].concat((0,r.Z)(a),(0,r.Z)(n)).filter((function(e){return""!==e.label}))})),p=(0,s.P1)([function(e){return e.subscriptions.list},function(e){return e.subscriptions.userSelection}],(function(e,t){var n=t.area;if(!n)return!1;var r=n.areaID;return!!e.find((function(e){return e.params.area===r}))}))},51608:function(e,t,n){"use strict";n.d(t,{Z:function(){return S}});var r=n(14416),s=n(92813),i=n(59499);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){(0,i.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var c=(0,n(42279).P1)([function(e){return e.subscriptions.preview.list},function(e){return e.subscriptions.userSelection.datasets}],(function(e,t){var n=[];return t.forEach((function(e){var t=(e.subscriptions||[]).find((function(e){return e.selected}));t&&n.push(t.label)})),e.map((function(e,t){return{title:n[t],data:e.map((function(e){return a(a({},e),e.geom&&{latitude:JSON.parse(e.geom).coordinates[0],longitude:JSON.parse(e.geom).coordinates[1]})}))}})).map((function(e){return e.data[0]&&e.data[0].geom&&e.data.forEach((function(e){delete e.geom})),a(a({},e),e.data[0]&&{keys:Object.keys(e.data[0])})}))})),l=n(92777),u=n(82262),p=n(10748),d=n(45959),f=n(63553),h=n(37247),b=n(67294),v=n(52202),m=n(85893);function y(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=(0,h.Z)(e);if(t){var s=(0,h.Z)(this).constructor;n=Reflect.construct(r,arguments,s)}else n=r.apply(this,arguments);return(0,f.Z)(this,n)}}var g=function(e){(0,d.Z)(n,e);var t=y(n);function n(){return(0,l.Z)(this,n),t.apply(this,arguments)}return(0,u.Z)(n,[{key:"render",value:function(){var e=this.props.alerts,t=e.title,n=e.keys,r=e.data;return(0,m.jsxs)("div",{className:"c-subscription-preview-table",children:[(0,m.jsx)("h3",{children:t}),(0,m.jsx)("div",{className:"disclaimer-container",children:"This is an example of what an alert subscription might look like. The information here is intended as an example only and does not represent the current status of this alert in your area of interest."}),!r.length&&(0,m.jsx)("span",{children:"Data no available"}),!!r.length&&(0,m.jsxs)("table",{className:"c-table",children:[(0,m.jsx)("thead",{children:(0,m.jsx)("tr",{className:"preview_table_captions",children:(n||[]).map((function(e,t){return(0,m.jsx)("th",{children:e},"".concat(e,"-").concat(t))}))})}),(0,m.jsx)("tbody",{children:r.map((function(e,t){return(0,m.jsx)("tr",{children:(n||[]).map((function(t,n){return(0,m.jsx)("td",{className:"preview-table-element",children:e[t]},"".concat(e[t],"-").concat(n))}))},t)}))})]})]})}}]),n}(b.PureComponent),j=g;function w(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=(0,h.Z)(e);if(t){var s=(0,h.Z)(this).constructor;n=Reflect.construct(r,arguments,s)}else n=r.apply(this,arguments);return(0,f.Z)(this,n)}}var O=function(e){(0,d.Z)(n,e);var t=w(n);function n(){var e;(0,l.Z)(this,n);for(var r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return e=t.call.apply(t,[this].concat(s)),(0,i.Z)((0,p.Z)(e),"handleEdit",(function(){(0,e.props.handleState)(!1)})),e}return(0,u.Z)(n,[{key:"UNSAFE_componentWillMount",value:function(){(0,this.props.getUserSubscriptionsPreview)()}},{key:"render",value:function(){var e=this.props,t=e.loading,n=e.data,r=e.handleCancel,s=e.handleSubscribe,i=e.activeDataset;if(t)return(0,m.jsx)(v.Z,{className:"-light",isLoading:!0});var o=i&&i.metadata&&i.metadata.name;return(0,m.jsxs)("div",{className:"c-subscriptions-preview",children:[(0,m.jsx)("div",{className:"header",children:(0,m.jsx)("h2",{children:o})}),(0,m.jsx)("div",{className:"preview-table",children:n.map((function(e){return(0,m.jsx)(j,{alerts:e})}))}),(0,m.jsxs)("div",{className:"preview-buttons",children:[(0,m.jsx)("button",{className:"c-btn -primary preview",onClick:s,children:"Done"}),(0,m.jsx)("button",{className:"c-btn -secondary preview",onClick:this.handleEdit,children:"Edit"}),(0,m.jsx)("button",{className:"c-btn -secondary preview",onClick:r,children:"Cancel"})]})]})}}]),n}(b.PureComponent);(0,i.Z)(O,"defaultProps",{data:[]});var x=O,S=(0,r.connect)((function(e){return{data:c(e),loading:e.subscriptions.preview.loading,preview:e.subscriptions.preview,datasetTitle:e.subscriptions.userSelection.datasets}}),{getUserSubscriptionsPreview:s.getUserSubscriptionsPreview})(x)},64960:function(e,t,n){"use strict";n.d(t,{Z:function(){return N}});var r=n(59499),s=n(4730),i=n(67294),o=n(50029),a=n(92777),c=n(82262),l=n(10748),u=n(45959),p=n(63553),d=n(37247),f=n(87794),h=n.n(f),b=n(94184),v=n.n(b),m=n(77677),y=n(52202),g=n(85893);function j(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=(0,d.Z)(e);if(t){var s=(0,d.Z)(this).constructor;n=Reflect.construct(r,arguments,s)}else n=r.apply(this,arguments);return(0,p.Z)(this,n)}}var w=function(e){(0,u.Z)(n,e);var t=j(n);function n(e){var r;return(0,a.Z)(this,n),(r=t.call(this,e)).state={selectedItem:e.options?e.options.find((function(t){return t.value===e.value})):null,closed:!0,fullList:e.options||[],filteredOptions:e.options||[],pathToCurrentItemsList:[],pathToSelectedItem:[],selectedIndex:0,waitingConfirmation:!1},r.onType=r.onType.bind((0,l.Z)(r)),r.onEnterSearch=r.onEnterSearch.bind((0,l.Z)(r)),r.onSliderPrev=r.onSliderPrev.bind((0,l.Z)(r)),r.onScreenClick=r.onScreenClick.bind((0,l.Z)(r)),r.onMouseDownOption=r.onMouseDownOption.bind((0,l.Z)(r)),r.toggle=r.toggle.bind((0,l.Z)(r)),r.open=r.open.bind((0,l.Z)(r)),r.close=r.close.bind((0,l.Z)(r)),r.selectItem=r.selectItem.bind((0,l.Z)(r)),r.clearSelectedItem=r.clearSelectedItem.bind((0,l.Z)(r)),r}return(0,c.Z)(n,[{key:"UNSAFE_componentWillReceiveProps",value:function(e){if(e.options.length&&!this.state.fullList.length&&this.setState({fullList:e.options||[],filteredOptions:e.options||[]}),e.options!==this.props.options){var t=e.options&&e.value?e.options.findIndex((function(t){return t.value===e.value})):-1,n=-1!==t?e.options[t]:null;this.setState({fullList:e.options||[],filteredOptions:e.options||[],selectedItem:n,selectedIndex:-1!==t?t:0,pathToCurrentItemsList:[],pathToSelectedItem:[]})}else if(e.value!==this.props.value){var r=this.props.options&&this.props.options.find((function(t){return t.value===e.value}));r&&this.setState({selectedItem:r})}}},{key:"componentWillUnmount",value:function(){window.removeEventListener("click",this.onScreenClick)}},{key:"onType",value:function(){var e=(0,o.Z)(h().mark((function e(t){var n,r,s,i,o=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.keyCode,e.next=38===e.t0?3:40===e.t0?6:13===e.t0?9:27===e.t0?14:16;break;case 3:return n=this.state.selectedIndex>0?this.state.selectedIndex-1:this.state.filteredOptions.length-1,this.setSelectedIndex(n),e.abrupt("break",19);case 6:return r=this.state.selectedIndex<this.state.filteredOptions.length-1?this.state.selectedIndex+1:0,this.setSelectedIndex(r),e.abrupt("break",19);case 9:if(-1===this.state.selectedIndex||!this.state.filteredOptions.length){e.next=13;break}return s=this.state.filteredOptions[this.state.selectedIndex],e.next=13,this.selectItem(s);case 13:return e.abrupt("break",19);case 14:return this.close(),e.abrupt("break",19);case 16:return i=t.currentTarget,setTimeout((function(){var e=i.value,t=o.getItemsListAtCurrentLevel(o.state.pathToCurrentItemsList).filter((function(t){return t.label.toLowerCase().match(e.toLowerCase())}));o.setState({filteredOptions:t})}),0),e.abrupt("break",19);case 19:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"onEnterSearch",value:function(){this.state.closed&&this.open()}},{key:"onSliderNext",value:function(e,t){e.stopPropagation();var n=this.state.pathToCurrentItemsList.slice();n.push(t);var r=this.getItemsListAtCurrentLevel(n);this.setState({pathToCurrentItemsList:n,filteredOptions:r})}},{key:"onSliderPrev",value:function(e){e.stopPropagation();var t=this.state.pathToCurrentItemsList.slice();t.pop();var n=this.getItemsListAtCurrentLevel(t);this.setState({pathToCurrentItemsList:t,filteredOptions:n})}},{key:"onScreenClick",value:function(e){this.el.contains&&!this.el.contains(e.target)&&(this.close(),window.removeEventListener("click",this.onScreenClick))}},{key:"onMouseDownOption",value:function(){var e=(0,o.Z)(h().mark((function e(t,n){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t.target instanceof HTMLButtonElement)){e.next=2;break}return e.abrupt("return");case 2:if(this.props.allowNonLeafSelection||!n.items||!n.items.length){e.next=5;break}return this.onSliderNext(t,n),e.abrupt("return");case 5:return t.stopPropagation(),e.next=8,this.selectItem(n);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"setSelectedIndex",value:function(e){this.setState({selectedIndex:e})}},{key:"getItemsListAtCurrentLevel",value:function(e){var t=this.state.fullList;if(e.length)for(var n=function(n){var r=t.find((function(t){return t.value===e[n].value}));if(!r.items)return"break";t=r.items},r=0;r<e.length;r++){if("break"===n(r))break}return t}},{key:"toggle",value:function(e){e.target!==this.input&&(e.stopPropagation(),this.state.closed?this.open():this.close())}},{key:"open",value:function(){var e=this;window.addEventListener("click",this.onScreenClick),this.setState({closed:!1}
1,(function(){e.input&&e.input.focus()}))}},{key:"close",value:function(){var e=this;if(window.removeEventListener("click",this.onScreenClick),this.setState({closed:!0}),this.state.selectedItem){var t=this.getItemsListAtCurrentLevel(this.state.pathToSelectedItem);this.setState({pathToCurrentItemsList:this.state.pathToSelectedItem,filteredOptions:t,selectedIndex:t.findIndex((function(t){return t===e.state.selectedItem}))})}else this.setState({pathToCurrentItemsList:[],pathToSelectedItem:[],filteredOptions:this.state.fullList,selectedIndex:0});this.input&&(this.input.value="")}},{key:"selectItem",value:function(){var e=(0,o.Z)(h().mark((function e(t){var n,r=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.state.pathToCurrentItemsList,e.abrupt("return",new Promise(function(){var e=(0,o.Z)(h().mark((function e(s,i){var o;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.setState({waitingConfirmation:!0}),e.next=3,r.props.onValueChange(t,n.map((function(e){return e.value})),"vocabulary");case 3:o=e.sent,r.setState({waitingConfirmation:!1}),!r.props.waitForChangeConfirmation||o?s():i();case 6:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()).then((function(){r.setState({selectedItem:t,pathToSelectedItem:n},(function(){return r.close()}))})).catch((function(){})));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"clearSelectedItem",value:function(e){e.stopPropagation(),this.setState({selectedItem:null,pathToCurrentItemsList:[],pathToSelectedItem:[],filteredOptions:this.state.fullList,selectedIndex:0}),this.props.onValueChange()}},{key:"render",value:function(){var e=this,t=this.props,n=t.className,r=t.options,s=t.placeholder,i=t.clearable,o=this.state,a=o.closed,c=o.filteredOptions,l=o.selectedItem,u=o.pathToCurrentItemsList,p=o.selectedIndex,d=o.waitingConfirmation,f=v()({"c-custom-select -search":!0,"-closed":a},n),h=!(!r.length||c.length),b=s;return d?b=(0,g.jsxs)("span",{children:[(0,g.jsx)(y.Z,{isLoading:!0,className:"-light -small -inline"})," ","Waiting for action"]}):l&&(b=l.as||l.label),(0,g.jsxs)("div",{ref:function(t){e.el=t},className:f,children:[(0,g.jsxs)("div",{className:"custom-select-text",children:[(0,g.jsx)("input",{"aria-label":s,ref:function(t){e.input=t},className:"custom-select-search",type:"search",onFocus:this.onEnterSearch,onKeyDown:this.onType}),(0,g.jsxs)("div",{children:[b,l&&i&&(0,g.jsx)("button",{className:"icon-btn clear-button",onClick:this.clearSelectedItem,children:(0,g.jsx)(m.Z,{name:"icon-cross",className:"-smaller icon-cross"})})]})]}),h&&(0,g.jsx)("span",{className:"no-results",children:"No results"}),this.state.closed||(0,g.jsxs)("ul",{className:"custom-select-options",role:"listbox","aria-label":s,ref:function(t){e.options=t},children:[u.length>0&&(0,g.jsx)("li",{role:"option","aria-selected":"false","aria-label":"Go back to the parent options",className:"title",onClick:this.onSliderPrev,children:(0,g.jsxs)("div",{children:[(0,g.jsx)(m.Z,{name:"icon-arrow-left-2",className:"-small icon-arrow-left-2"}),(0,g.jsx)("span",{children:u[u.length-1].label})]})}),c.map((function(t,n){return(0,g.jsxs)("li",{role:"option","aria-selected":t===l,className:v()({"-selected":n===p}),onMouseEnter:function(){e.setSelectedIndex(n)},onMouseDown:function(n){return e.onMouseDownOption(n,t)},children:[(0,g.jsx)("span",{className:"label",children:t.label}),t.items&&t.items.length&&(0,g.jsx)("button",{className:"next",onClick:function(n){return e.onSliderNext(n,t)},children:(0,g.jsx)(m.Z,{name:"icon-arrow-right-2",className:"-small icon-arrow-right-2"})})]},t.id||t.value)}))]})]})}}]),n}(i.Component);(0,r.Z)(w,"defaultProps",{onValueChange:function(){},clearable:!0,allowNonLeafSelection:!0,waitForChangeConfirmation:!1});var O=n(18446),x=n.n(O);function S(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=(0,d.Z)(e);if(t){var s=(0,d.Z)(this).constructor;n=Reflect.construct(r,arguments,s)}else n=r.apply(this,arguments);return(0,p.Z)(this,n)}}var k=function(e){(0,u.Z)(n,e);var t=S(n);function n(e){var r;return(0,a.Z)(this,n),(r=t.call(this,e)).state={selectedItem:e.options?e.options.find((function(t){return t.value===e.value})):null,closed:!0,filteredOptions:e.options||[],selectedIndex:0,value:e.value},r.open=r.open.bind((0,l.Z)(r)),r.close=r.close.bind((0,l.Z)(r)),r.toggle=r.toggle.bind((0,l.Z)(r)),r.selectItem=r.selectItem.bind((0,l.Z)(r)),r.onType=r.onType.bind((0,l.Z)(r)),r.onEnterSearch=r.onEnterSearch.bind((0,l.Z)(r)),r.onScreenClick=r.onScreenClick.bind((0,l.Z)(r)),r.resetSelectedIndex=r.resetSelectedIndex.bind((0,l.Z)(r)),r}return(0,c.Z)(n,[{key:"UNSAFE_componentWillReceiveProps",value:function(e){var t=e.options,n=e.value;x()(this.props.options,t)||this.setState({filteredOptions:t,selectedItem:t.find((function(e){return e.value===n}))}),this.props.value!==n&&this.setState({selectedItem:this.props.options.find((function(e){return e.value===n}))})}},{key:"componentWillUnmount",value:function(){window.removeEventListener("click",this.onScreenClick)}},{key:"onType",value:function(e){var t=this;switch(console(e),e.keyCode){case 38:var n=this.state.selectedIndex>0?this.state.selectedIndex-1:this.state.filteredOptions.length-1;this.setSelectedIndex(n);break;case 40:var r=this.state.selectedIndex<this.state.filteredOptions.length-1?this.state.selectedIndex+1:0;this.setSelectedIndex(r);break;case 13:if(-1!==this.state.selectedIndex&&this.state.filteredOptions.length){var s=this.state.filteredOptions[this.state.selectedIndex];this.resetSelectedIndex(),this.selectItem(s)}break;case 27:this.close();break;default:var i=e.currentTarget.value,o=this.props.options.filter((function(e){return e.label.toLowerCase().match(i.toLowerCase())}));this.setState({filteredOptions:o},(function(){t.props.onKeyPressed&&t.props.onKeyPressed({value:i},[],"name")}))}}},{key:"onEnterSearch",value:function(){this.setState({closed:!1}
1)}},{key:"onScreenClick",value:function(e){this.el.contains&&!this.el.contains(e.target)&&(this.close(),window.removeEventListener("click",this.onScreenClick))}},{key:"setSelectedIndex",value:function(e){this.setState({selectedIndex:e})}},{key:"resetSelectedIndex",value:function(){this.setSelectedIndex(0)}},{key:"selectItem",value:function(e){this.setState({selectedItem:e}),this.close(),this.props.onValueChange&&this.props.onValueChange(e)}},{key:"toggle",value:function(){return this.state.closed?this.open():this.close()}},{key:"open",value:function(){var e=this;window.addEventListener("click",this.onScreenClick),this.setState({closed:!1},(function(){e.input&&e.input.focus()}))}},{key:"close",value:function(){window.removeEventListener("click",this.onScreenClick),this.setState({closed:!0,filteredOptions:this.props.options,value:this.input.value},this.resetSelectedIndex)}},{key:"render",value:function(){var e=this,t=["c-custom-select -search"];this.props.className&&t.push(this.props.className),this.state.closed&&t.push("-closed");var n=!(!this.props.options.length||this.state.filteredOptions.length);return(0,g.jsxs)("div",{ref:function(t){e.el=t},className:t.join(" "),children:[(0,g.jsxs)("span",{className:"custom-select-text",onClick:this.toggle,children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("span",{children:this.state.value?this.state.value:this.props.placeholder}),(0,g.jsx)("button",{className:"icon-btn",onClick:this.toggle,children:(0,g.jsx)(m.Z,{name:"icon-search",className:"-small"})})]}),(0,g.jsx)("input",{ref:function(t){e.input=t},className:"custom-select-search",type:"search",defaultValue:this.props.value,onBlur:this.close,onFocus:this.onEnterSearch,onChange:this.onType})]}),n&&(0,g.jsx)("span",{className:"no-results",children:"No results"}),!this.state.closed&&!this.props.hideList&&(0,g.jsx)("ul",{className:"custom-select-options",children:this.state.filteredOptions.map((function(t,n){var r=n===e.state.selectedIndex?"-selected":"";return(0,g.jsx)("li",{className:r,onMouseEnter:function(){e.setSelectedIndex(n)},onMouseDown:function(){return e.selectItem(t)},children:(0,g.jsx)("span",{className:"label",children:t.label})},t.id||t.label)}))})]})}}]),n}(i.Component),P=["search"];function Z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Z(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Z(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var N=function(e){var t=e.search,n=(0,s.Z)(e,P);return t?(0,g.jsx)(k,C({},n)):(0,g.jsx)(w,C({},n))}},11592:function(e,t,n){"use strict";var r=n(59499),s=n(88767),i=n(49357);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}t.Z=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(0,s.useQuery)(["fetch-collection",t,e,n],(function(){return(0,i.lA)(t,e,n)}),a({},r))}},91789:function(e,t,n){"use strict";var r=n(59499),s=n(88767),i=n(90953);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var a=function(){return(0,i.tf)().then((function(e){return e.filter((function(e){return!!e.name})).sort((function(e,t){return e.name>t.name?1:e.name<t.name?-1:0})).map((function(e){return{name:e.name,geostoreId:e.geostoreId}}))}))};t.Z=function(e){return(0,s.useQuery)(["fetch-countries"],a,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};
1t%2?o(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({initialData:[],initialStale:!0},e))}},89562:function(e,t,n){"use strict";var r=n(88767),s=n(8371);t.Z=function(e,t){return(0,r.useQuery)(["paginated-user-areas",e,t],(function(){return(0,s.Id)(e,t,!0)}),{initialData:{areas:[],meta:{}},initialStale:!0,keepPreviousData:!0})}},90887:function(e,t,n){"use strict";var r=n(59499),s=n(42279);function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){(0,r.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}t.Z=(0,s.P1)((function(e){return e.user}),(function(e){var t=e.areas,n={};return t&&t.items&&t.items.map((function(e){var t=e.subscription;if(!t)return null;var r=t.datasetsQuery,s=t.datasets;return n[e.id]=[],r&&s&&r.map((function(t,r){return n[e.id].push(o(o({},t),{},{dataset:s[r]})),t})),e})),n}))},33964:function(e,t,n){"use strict";n.d(t,{$E:function(){return l}});var r=n(50029),s=n(87794),i=n.n(s),o=function(e){var t=new FormData;return t.append("file",e),fetch("".concat("https://api.resourcewatch.org","/v1/ogr/convert"),{method:"POST",body:t,multipart:!0}).then((function(e){if(!e.ok)throw new Error("The file couldn't be processed correctly. Make sure the format is supported. If it is, try again in a few minutes.");return e.json()})).then((function(e){var t=e.data,n=t.attributes.features;if(!n||!n.length||!Array.isArray(n))throw new Error("The geometry seems to be empty. Please make sure the file isn't empty.");return t.attributes}))},a=function(e){return new Promise((function(t){var n=new FileReader;n.onload=function(){return t(JSON.parse(n.result))},n.onerror=function(){throw new Error("Unable to read the geojson file. Please try to upload it again.")},n.readAsText(e)}))},c=function(e){return e.name.split(".").pop()},l=function(){var e=(0,r.Z)(i().mark((function e(t){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){"geojson"===c(t)?a(t).then(e).catch(n):o(t).then(e).catch(n)})).then((function(e){return fetch("".concat("https://api.resourcewatch.org","/v1/geostore"),{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify({geojson:e})})})).then((function(e){if(!e.ok)throw new Error("The file couldn't be processed correctly. Try again in a few minutes.");return e.json()})).then((function(e){return e.data.id})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.