u.index){var v=l-s.x-s.vx,m=c-s.y-s.vy,y=v*v+m*m;ye.r&&(e.r=e[t].r)}function u(){if(t){var r,o,i=t.length;for(n=new Array(i),r=0;r=s)){(e.data!==t||e.next)&&(0===f&&(p+=(f=Io(n))*f),0===h&&(p+=(h=Io(n))*h),pn&&(n=o,this.emit(Jo.SIMULATION_PROGRESS,{nodes:this._nodes,edges:this._edges,progress:o/100})),this.simulation.tick()}this.settings.isPhysicsEnabled||this.fixNodes(),this._isStabilizing=!1,this.emit(Jo.SIMULATION_END,{nodes:this._nodes,edges:this._edges})}}},{key:"setNodeIndexByNodeId",value:function(){this._nodeIndexByNodeId={};for(var e=0;e0&&t.fontSize>0&&t.position&&(Pi(e,t),Ti(e,t))},Pi=function(e,t){if(t.properties.fontBackgroundColor&&t.position){e.fillStyle=t.properties.fontBackgroundColor.toString();for(var n=.12*t.fontSize,r=t.fontSize+2*n,o=1.2*t.fontSize,i=t.textBaseline===wi.MIDDLE?t.fontSize/2:0,a=0;a0?a>0?o=l:i=l:a>0?i=l:o=l,s++;return u.t=null!==l&&void 0!==l?l:0,u},Ai=function(e,t){var n=e.endNode,r=e.startNode;t.id===e.startNode.id&&(n=e.startNode,r=e.endNode);var o=n.getCenter(),i=r.getCenter(),a=o.x-i.x,s=o.y-i.y,u=Math.sqrt(a*a+s*s),l=(u-t.getDistanceToBorder())/u;return{x:(1-l)*i.x+l*o.x,y:(1-l)*i.y+l*o.y,t:0}},Ri=function(e,t){var n=t.getLabel();if(n){var r=new Si(n,{position:t.getCenter(),textBaseline:wi.MIDDLE,properties:{fontBackgroundColor:t.style.fontBackgroundColor,fontColor:t.style.fontColor,fontFamily:t.style.fontFamily,fontSize:t.style.fontSize}});Ei(e,r)}},Li=function(e,t){if(t instanceof xe)return function(e,t){var n=t.startNode.getCenter(),r=t.endNode.getCenter();n&&r&&(e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke())}(e,t);if(t instanceof Oe)return function(e,t){var n=t.startNode.getCenter(),r=t.endNode.getCenter();if(n&&r){var o=t.getCurvedControlPoint();e.beginPath(),e.moveTo(n.x,n.y),e.quadraticCurveTo(o.x,o.y,r.x,r.y),e.stroke()}}(e,t);if(t instanceof Se)return function(e,t){var n=t.getCircularData(),r=n.x,o=n.y,i=n.radius;e.beginPath(),e.arc(r,o,i,0,2*Math.PI,!1),e.closePath(),e.stroke()}(e,t);throw new Error("Failed to draw unsupported edge type")},Di=function(e,t){if(0!==t.style.arrowSize){var n=zi(t),r=Wi([{x:0,y:0},{x:-1,y:.4},{x:-1,y:-.4}],n);e.beginPath();for(var o=0;o0&&(e.lineWidth=n);var r=t.getColor();r&&(e.strokeStyle=r.toString(),e.fillStyle=r.toString())},Bi=function(e,t){t.style.shadowColor&&(e.shadowColor=t.style.shadowColor.toString()),t.style.shadowSize&&(e.shadowBlur=t.style.shadowSize),t.style.shadowOffsetX&&(e.shadowOffsetX=t.style.shadowOffsetX),t.style.shadowOffsetY&&(e.shadowOffsetY=t.style.shadowOffsetY)},Fi=function(e,t){t.style.shadowColor&&(e.shadowColor="rgba(0,0,0,0)"),t.style.shadowSize&&(e.shadowBlur=0),t.style.shadowOffsetX&&(e.shadowOffsetX=0),t.style.shadowOffsetY&&(e.shadowOffsetY=0)},Wi=function(e,t){for(var n=t.point.x,r=t.point.y,o=t.angle,i=t.length,a=0;a1&&void 0!==arguments[1]?arguments[1]:300,r=!1,o=Date.now();return function(){var i=arguments,a=Date.now();if(!r)return e.apply(void 0,R(i)),o=a,void(r=!0);clearTimeout(t);var s=Math.max(n-(a-o),0);t=setTimeout((function(){a-o>=n&&(e.apply(void 0,R(i)),o=a)}),s)}},Qi=function(e){var t=Math.max(e,1);return Math.round(1e3/t)},Ji=function(e){l(n,e);var t=d(n);function n(e,o){var i;return r(this,n),(i=t.call(this))._isOriginCentered=!1,i._isInitiallyRendered=!1,i._context=e,i.width=640,i.height=480,i.transform=_o,i._settings=Object.assign(Object.assign({},xi),o),i._throttleRender=Xi((function(e){i._render(e)}),Qi(i._settings.fps)),i}return s(n,[{key:"isInitiallyRendered",get:function(){return this._isInitiallyRendered}},{key:"getSettings",value:function(){return ni(this._settings)}},{key:"setSettings",value:function(e){var t=this,n=e.fps&&e.fps!==this._settings.fps;this._settings=Object.assign(Object.assign({},this._settings),e),n&&(this._throttleRender=Xi((function(e){t._render(e)}),Qi(this._settings.fps)))}},{key:"render",value:function(e){this._throttleRender(e)}},{key:"_render",value:function(e){if(e.getNodeCount()){this.emit(_i.RENDER_START,void 0);var t=Date.now();this._context.clearRect(0,0,this.width,this.height),this._settings.backgroundColor&&(this._context.fillStyle=this._settings.backgroundColor.toString(),this._context.fillRect(0,0,this.width,this.height)),this._context.save(),this._context.translate(this.transform.x,this.transform.y),this._context.scale(this.transform.k,this.transform.k),this._isOriginCentered&&this._context.translate(this.width/2,this.height/2),this.drawObjects(e.getEdges()),this.drawObjects(e.getNodes()),this._context.restore(),this.emit(_i.RENDER_END,{durationMs:Date.now()-t}),this._isInitiallyRendered=!0}}},{key:"drawObjects",value:function(e){if(0!==e.length){for(var t=[],n=[],r=0;r1&&void 0!==arguments[1]?arguments[1]:gi.CANVAS,n=arguments.length>2?arguments[2]:void 0;if(t===gi.WEBGL){var r=e.getContext("webgl2");if(!r)throw new na("Failed to create WebGL context.");return new $i(r,n)}var o=e.getContext("2d");if(!o)throw new na("Failed to create Canvas context.");return new Ji(o,n)}}]),e}(),oa=/^\s*0+\s*(?:px|rem|em|vh|vw)?\s*$/i,ia=function(e){return null===e||void 0===e||""===e||oa.test(e)},aa=function(){function e(t,n){var o,i=this;r(this,e),this._isSimulating=!1,this._simulationStartedAt=Date.now(),this.dragSubject=function(e){var t,n=i.getCanvasMousePosition(e.sourceEvent),r=null===(t=i._renderer)||void 0===t?void 0:t.getSimulationPosition(n);return i._graph.getNearestNode(r)},this.dragStarted=function(e){var t=i.getCanvasMousePosition(e.sourceEvent),n=i._renderer.getSimulationPosition(t);i._events.emit(vi.NODE_DRAG_START,{node:e.subject,event:e.sourceEvent,localPoint:n,globalPoint:t}),i._dragStartPosition=t},this.dragged=function(e){var t=i.getCanvasMousePosition(e.sourceEvent),n=i._renderer.getSimulationPosition(t);Co(i._dragStartPosition,t)||(i._dragStartPosition=void 0),i._simulator.dragNode(e.subject.id,n),i._events.emit(vi.NODE_DRAG,{node:e.subject,event:e.sourceEvent,localPoint:n,globalPoint:t})},this.dragEnded=function(e){var t=i.getCanvasMousePosition(e.sourceEvent),n=i._renderer.getSimulationPosition(t);Co(i._dragStartPosition,t)||i._simulator.endDragNode(e.subject.id),i._events.emit(vi.NODE_DRAG_END,{node:e.subject,event:e.sourceEvent,localPoint:n,globalPoint:t})},this.zoomed=function(e){i._renderer.transform=e.transform,setTimeout((function(){i._renderer.render(i._graph),i._events.emit(vi.TRANSFORM,{transform:e.transform})}),1)},this.mouseMoved=function(e){var t=i.getCanvasMousePosition(e),n=i._renderer.getSimulationPosition(t);if(i._strategy.onMouseMove){var r=i._strategy.onMouseMove(i._graph,n),o=r.changedSubject;o&&r.isStateChanged&&(ve(o)&&i._events.emit(vi.NODE_HOVER,{node:o,event:e,localPoint:n,globalPoint:t}),_e(o)&&i._events.emit(vi.EDGE_HOVER,{edge:o,event:e,localPoint:n,globalPoint:t})),i._events.emit(vi.MOUSE_MOVE,{subject:o,event:e,localPoint:n,globalPoint:t}),r.isStateChanged&&i._renderer.render(i._graph)}},this.mouseClicked=function(e){var t=i.getCanvasMousePosition(e),n=i._renderer.getSimulationPosition(t);if(i._strategy.onMouseClick){var r=i._strategy.onMouseClick(i._graph,n),o=r.changedSubject;o&&(ve(o)&&i._events.emit(vi.NODE_CLICK,{node:o,event:e,localPoint:n,globalPoint:t}),_e(o)&&i._events.emit(vi.EDGE_CLICK,{edge:o,event:e,localPoint:n,globalPoint:t})),i._events.emit(vi.MOUSE_CLICK,{subject:o,event:e,localPoint:n,globalPoint:t}),(r.isStateChanged||r.changedSubject)&&i._renderer.render(i._graph)}},this.mouseRightClicked=function(e){var t=i.getCanvasMousePosition(e),n=i._renderer.getSimulationPosition(t);if(i._strategy.onMouseRightClick){var r=i._strategy.onMouseRightClick(i._graph,n),o=r.changedSubject;o&&(ve(o)&&i._events.emit(vi.NODE_RIGHT_CLICK,{node:o,event:e,localPoint:n,globalPoint:t}),_e(o)&&i._events.emit(vi.EDGE_RIGHT_CLICK,{edge:o,event:e,localPoint:n,globalPoint:t})),i._events.emit(vi.MOUSE_RIGHT_CLICK,{subject:o,event:e,localPoint:n,globalPoint:t}),(r.isStateChanged||r.changedSubject)&&i._renderer.render(i._graph)}},this.mouseDoubleClicked=function(e){var t=i.getCanvasMousePosition(e),n=i._renderer.getSimulationPosition(t);if(i._strategy.onMouseDoubleClick){var r=i._strategy.onMouseDoubleClick(i._graph,n),o=r.changedSubject;o&&(ve(o)&&i._events.emit(vi.NODE_DOUBLE_CLICK,{node:o,event:e,localPoint:n,globalPoint:t}),_e(o)&&i._events.emit(vi.EDGE_DOUBLE_CLICK,{edge:o,event:e,localPoint:n,globalPoint:t})),i._events.emit(vi.MOUSE_DOUBLE_CLICK,{subject:o,event:e,localPoint:n,globalPoint:t}),(r.isStateChanged||r.changedSubject)&&i._renderer.render(i._graph)}},this._container=t.container,this._graph=t.graph,this._events=t.events,this._strategy=t.strategy,this._settings=Object.assign(Object.assign({getPosition:null===n||void 0===n?void 0:n.getPosition,zoomFitTransitionMs:200,isOutOfBoundsDragEnabled:!1,areCoordinatesRounded:!0,isSimulationAnimated:!0,areCollapsedContainerDimensionsAllowed:!1},n),{simulation:Object.assign({isPhysicsEnabled:!1},null===n||void 0===n?void 0:n.simulation),render:Object.assign({},null===n||void 0===n?void 0:n.render)}),function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.style.position="relative";var n=getComputedStyle(e);n.display||(e.style.display="block",console.warn("[Orb] Graph container doesn't have defined 'display' property. Setting 'display' to 'block'...")),!t&&ia(n.width)&&(e.style.width="100%",ia(getComputedStyle(e).width)?(e.style.width="400px",console.warn("[Orb] The graph container element and its parent don't have defined width properties.","If you are using percentage values,","please make sure that the parent element of the graph container has a defined position and width.","Setting the width of the graph container to an arbirtrary value of '400px'...")):console.warn("[Orb] The graph container element doesn't have defined width. Setting width to 100%...")),!t&&ia(n.height)&&(e.style.height="100%",ia(getComputedStyle(e).height)?(e.style.height="400px",console.warn("[Orb] The graph container element and its parent don't have defined height properties.","If you are using percentage values,","please make sure that the parent element of the graph container has a defined position and height.","Setting the height of the graph container to an arbitrary value of '400px'...")):console.warn("[Orb] Graph container doesn't have defined height. Setting height to 100%..."))}(this._container,this._settings.areCollapsedContainerDimensionsAllowed),this._canvas=this._initCanvas();try{this._renderer=ra.getRenderer(this._canvas,null===(o=null===n||void 0===n?void 0:n.render)||void 0===o?void 0:o.type,this._settings.render)}catch(a){throw this._container.textContent=a.message,a}this._renderer.on(_i.RENDER_START,(function(){i._events.emit(vi.RENDER_START,void 0)})),this._renderer.on(_i.RENDER_END,(function(e){i._events.emit(vi.RENDER_END,e)})),this._renderer.translateOriginToCenter(),this._settings.render=this._renderer.getSettings(),new ResizeObserver((function(){return i._handleResize()})).observe(this._container),this._handleResize(),this._d3Zoom=function(){var e,t,n,r=xo,o=Oo,i=To,a=Eo,s=Po,u=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,f=vn,h=Ae("start","zoom","end"),d=500,p=150,v=0,m=10;function y(e){e.property("__zoom",So).on("wheel.zoom",S,{passive:!1}).on("mousedown.zoom",E).on("dblclick.zoom",P).filter(s).on("touchstart.zoom",T).on("touchmove.zoom",k).on("touchend.zoom touchcancel.zoom",C).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(e,t){return(t=Math.max(u[0],Math.min(u[1],t)))===e.k?e:new go(t,e.x,e.y)}function _(e,t,n){var r=t[0]-n[0]*e.k,o=t[1]-n[1]*e.k;return r===e.x&&o===e.y?e:new go(e.k,r,o)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function w(e,t,n,r){e.on("start.zoom",(function(){x(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){x(this,arguments).event(r).end()})).tween("zoom",(function(){var e=this,i=arguments,a=x(e,i).event(r),s=o.apply(e,i),u=null==n?b(s):"function"===typeof n?n.apply(e,i):n,l=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),c=e.__zoom,h="function"===typeof t?t.apply(e,i):t,d=f(c.invert(u).concat(l/c.k),h.invert(u).concat(l/h.k));return function(e){if(1===e)e=h;else{var t=d(e),n=l/t[2];e=new go(n,u[0]-t[0]*n,u[1]-t[1]*n)}a.zoom(null,e)}}))}function x(e,t,n){return!n&&e.__zooming||new O(e,t)}function O(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=o.apply(e,t),this.taps=0}function S(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o1?t-1:0),a=1;av}u.event(e).zoom("mouse",i(_(u.that.__zoom,u.mouse[0]=Qt(e,s),u.mouse[1]),u.extent,l))}),!0).on("mouseup.zoom",(function(e){c.on("mousemove.zoom mouseup.zoom",null),rn(e.view,u.moved),wo(e),u.event(e).end()}),!0),f=Qt(e,s),h=e.clientX,d=e.clientY;nn(e.view),bo(e),u.mouse=[f,this.__zoom.invert(f)],Zn(this),u.start()}}function P(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a0?Xt(this).transition().duration(c).call(w,d,u,e):Xt(this).call(y.transform,d,u,e)}}function T(n){for(var o=arguments.length,i=new Array(o>1?o-1:0),a=1;a1?t-1:0),r=1;r1?r-1:0),i=1;if}u.mouse("drag",r)}function v(e){Xt(e.view).on("mousemove.drag mouseup.drag",null),rn(e.view,n),tn(e),u.mouse("end",e)}function m(e,t){if(o.call(this,e,t)){var n,r,a=e.changedTouches,s=i.call(this,e,t),u=a.length;for(n=0;n0}}},{key:"onMouseMove",value:function(e,t){var n=e.getNearestNode(t);return n&&!n.isSelected()?n===this.lastHoveredNode?{changedSubject:n,isStateChanged:!1}:(fa(e,n),this.lastHoveredNode=n,{isStateChanged:!0,changedSubject:n}):(this.lastHoveredNode=void 0,n?{isStateChanged:!1}:{isStateChanged:ha(e).changedCount>0})}},{key:"onMouseRightClick",value:function(e,t){var n=e.getNearestNode(t);if(n)return ua(e,n),{isStateChanged:!0,changedSubject:n};var r=e.getNearestEdge(t);return r?(la(e,r),{isStateChanged:!0,changedSubject:r}):{isStateChanged:ca(e).changedCount>0}}},{key:"onMouseDoubleClick",value:function(e,t){var n=e.getNearestNode(t);if(n)return ua(e,n),{isStateChanged:!0,changedSubject:n};var r=e.getNearestEdge(t);return r?(la(e,r),{isStateChanged:!0,changedSubject:r}):{isStateChanged:ca(e).changedCount>0}}}]),e}()),ua=function(e,t){ca(e),da(t,fe,{isStateOverride:!0})},la=function(e,t){ca(e),pa(t,fe,{isStateOverride:!0})},ca=function(e){for(var t=e.getNodes((function(e){return e.isSelected()})),n=0;n0&&void 0!==arguments[0]?arguments[0]:.3;return e.getColorFromRGB({r:this.rgb.r-t*this.rgb.r,g:this.rgb.g-t*this.rgb.g,b:this.rgb.b-t*this.rgb.b})}},{key:"getLighterColor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.3;return e.getColorFromRGB({r:this.rgb.r+t*(255-this.rgb.r),g:this.rgb.g+t*(255-this.rgb.g),b:this.rgb.b+t*(255-this.rgb.b)})}},{key:"getMixedColor",value:function(t){return e.getColorFromRGB({r:(this.rgb.r+t.rgb.r)/2,g:(this.rgb.g+t.rgb.g)/2,b:(this.rgb.b+t.rgb.b)/2})}},{key:"isEqual",value:function(e){return this.rgb.r===e.rgb.r&&this.rgb.g===e.rgb.g&&this.rgb.b===e.rgb.b}}],[{key:"getColorFromRGB",value:function(t){var n=Math.round(Math.max(Math.min(t.r,255),0)),r=Math.round(Math.max(Math.min(t.g,255),0)),o=Math.round(Math.max(Math.min(t.b,255),0));return new e(_a({r:n,g:r,b:o}))}},{key:"getRandomColor",value:function(){return e.getColorFromRGB({r:Math.round(255*Math.random()),g:Math.round(255*Math.random()),b:Math.round(255*Math.random())})}}]),e}(),ga=function(e){return{r:parseInt(e.substring(1,3),16),g:parseInt(e.substring(3,5),16),b:parseInt(e.substring(6,7),16)}},_a=function(e){return"#"+((1<<24)+(e.r<<16)+(e.g<<8)+e.b).toString(16).slice(1)},ba=["label","name"],wa={size:5,color:new ya("#1d87c9")},xa={color:new ya("#ababab"),width:.3},Oa=function(e){for(var t=0;t0&&this._graph.clearPositions(),this._view&&this._view.destroy(),this._view=e(this._context)}}]),e}(),Ea=function(e){l(n,e);var t=d(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n,[{key:"render",value:function(){var e=this;return(0,_.jsxs)("div",{className:"is-flex is-align-items-center",children:[this.props.node.labels.map((function(t){return(0,_.jsx)(S,{label:t,database:e.props.database||N.database,tabManager:e.props.tabManager,size:"mr-1 "+(e.props.small?"":"is-medium")},t)})),(0,_.jsx)(O,{onClick:function(){return e.props.tabManager.add({prefix:"Node",i:e.props.node.identity},"fa-solid fa-pen-to-square",m.Node,{id:N.getId(e.props.node),database:e.props.database||N.database})},icon:"fa-solid fa-pen-clip",color:this.props.small?"is-small":"",text:"#"+N.strInt(this.props.node.identity)}),Object.keys(this.props.node.properties).length>0&&(0,_.jsx)(G.Consumer,{children:function(t){return(0,_.jsx)(O,{icon:"fa-solid fa-rectangle-list",onClick:function(){return t(e.props.node.properties)},color:"ml-1 "+(e.props.small?"is-small":"")})}})]})}}]),n}(e.Component),Pa=function(e){l(n,e);var t=d(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n,[{key:"render",value:function(){var e=this;return(0,_.jsxs)("div",{className:"is-flex is-align-items-center",children:[(0,_.jsx)(E,{type:this.props.rel.type,database:this.props.database||N.database,tabManager:this.props.tabManager,size:"mr-1 "+(this.props.small?"":"is-medium")}),(0,_.jsx)(O,{onClick:function(){return e.props.tabManager.add({prefix:"Rel",i:e.props.rel.identity},"fa-regular fa-pen-to-square",m.Rel,{id:N.getId(e.props.rel),database:N.database})},icon:"fa-solid fa-pen-clip",color:this.props.small?"is-small":"",text:"#"+N.strInt(this.props.rel.identity)}),Object.keys(this.props.rel.properties).length>0&&(0,_.jsx)(G.Consumer,{children:function(t){return(0,_.jsx)(O,{icon:"fa-solid fa-rectangle-list",onClick:function(){return t(e.props.rel.properties)},color:"ml-1 "+(e.props.small?"is-small":"")})}})]})}}]),n}(e.Component),Ta=n.p+"static/media/orb_logo.8956ce3915ca9959c3a8.png",ka=function(t){l(o,t);var n=d(o);function o(){var t;r(this,o);for(var i=arguments.length,a=new Array(i),s=0;s":"-","("]}),t.printValue(N.strInt(e.start.identity)===N.strInt(n.identity)?e.end:e.start),(0,_.jsx)("span",{className:"is-size-4",children:")"})]});return n=e.end,r=!1,o}))})}if(e instanceof C.Date){var o="toString"===ae().temporalValueToStringFunction?"toDateString":ae().temporalValueToStringFunction;return(0,_.jsx)("p",{className:"wspace-nowrap",children:e.toStandardDate()[o]()})}return e instanceof C.DateTime?(0,_.jsx)("p",{className:"wspace-nowrap",children:e.toStandardDate()[ae().temporalValueToStringFunction]()}):e instanceof C.Time?(0,_.jsx)("p",{className:"wspace-nowrap",children:e.toString()}):e instanceof C.LocalDateTime?(0,_.jsx)("p",{className:"wspace-nowrap",children:e.toStandardDate().toLocaleString()}):e instanceof C.LocalTime?(0,_.jsx)("p",{className:"wspace-nowrap",children:e.toString()}):e instanceof C.Duration?(0,_.jsx)("p",{className:"wspace-nowrap",children:ee(e)}):"object"===typeof e?(0,_.jsxs)(_.Fragment,{children:[e.constructor.name||"",(0,_.jsxs)("div",{className:"control has-icons-right",children:[(0,_.jsx)("pre",{children:K(e)}),(0,_.jsx)(Z.Consumer,{children:function(e){return(0,_.jsx)("span",{className:"icon is-right is-clickable",onClick:e,children:(0,_.jsx)("i",{className:"fa-regular fa-copy"})})}})]})]}):e.toString()},t}return s(o,[{key:"componentDidMount",value:function(){this.props.execute&&this.handleSubmit(null)}},{key:"componentWillUnmount",value:function(){localStorage.removeItem(this.props.tabId)}},{key:"shouldComponentUpdate",value:function(e,t){var n=this;return this.props.execute&&this.props.query!==e.query&&this.setState({query:e.query},(function(){n.handleSubmit(null)})),Object.keys(this.props).some((function(t){return n.props[t]!==e[t]}))||Object.keys(this.state).some((function(e){return n.state[e]!==t[e]}))}},{key:"render",value:function(){var e=this,t=[];return this.state.rows.forEach((function(e){var n,r=k(e.keys);try{for(r.s();!(n=r.n()).done;){var o=n.value;t.includes(o)||t.push(o)}}catch(i){r.e(i)}finally{r.f()}})),(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("form",{onSubmit:this.handleSubmit,className:"block",children:[(0,_.jsx)("div",{className:"field",children:(0,_.jsxs)("div",{className:"control has-icons-right has-icons-left",children:[(0,_.jsx)(x,{required:!0,name:"query",value:this.state.query,onChange:function(t){e.setState({query:t.currentTarget.value}),localStorage.setItem(e.props.tabId,t.currentTarget.value)},color:"is-family-code",focus:!0,onKeyDown:function(t){"Enter"===t.key&&t.ctrlKey&&e.handleSubmit(null)}}),(0,_.jsx)("span",{className:"icon is-left",children:(0,_.jsx)("i",{className:"fa-solid fa-terminal","aria-hidden":"true"})}),(0,_.jsx)(Z.Consumer,{children:function(e){return(0,_.jsx)("span",{className:"icon is-right is-clickable",onClick:e,children:(0,_.jsx)("i",{className:"fa-regular fa-copy"})})}})]})}),(0,_.jsx)("div",{className:"field",children:(0,_.jsxs)("div",{className:"buttons is-justify-content-flex-end",children:[(0,_.jsx)(O,{color:"is-success "+(this.state.loading?"is-loading":""),type:"submit",icon:"fa-solid fa-check",text:"Execute"}),(0,_.jsx)(O,{icon:"fa-solid fa-xmark",text:"Close",onClick:function(t){return e.props.tabManager.close(e.props.tabId,t)}})]})})]}),"string"===typeof this.state.error&&(0,_.jsxs)("div",{className:"message is-danger block",children:[(0,_.jsxs)("div",{className:"message-header",children:[(0,_.jsx)("p",{children:"Error"}),(0,_.jsx)("button",{className:"delete","aria-label":"delete",onClick:function(){return e.setState({error:null})}})]}),(0,_.jsx)("div",{className:"message-body",children:this.state.error})]}),(0,_.jsx)("div",{className:"block",children:(0,_.jsxs)("div",{className:"buttons has-addons",children:[(0,_.jsxs)("span",{children:[(0,_.jsx)(O,{text:"Table",color:this.state.view===g.Table?"is-link is-light is-active":"",icon:"fa-solid fa-table",onClick:function(){return e.changeView(g.Table)}}),(0,_.jsx)(O,{text:"JSON",color:this.state.view===g.JSON?"is-link is-light is-active":"",icon:"fa-brands fa-js",onClick:function(){return e.changeView(g.JSON)}}),(0,_.jsx)(O,{text:"Graph",color:this.state.view===g.Graph?"is-link is-light is-active":"",icon:"fa-solid fa-circle-nodes",onClick:function(){return e.changeView(g.Graph)}}),(0,_.jsx)(O,{text:"Summary",color:this.state.view===g.Summary?"is-link is-light is-active":"",icon:"fa-solid fa-gauge-high",onClick:function(){return e.changeView(g.Summary)}})]}),this.state.view===g.Table&&this.showTableSize&&(0,_.jsxs)("span",{className:"ml-3",children:[(0,_.jsx)(O,{color:1===this.state.tableSize?"is-link is-light is-active":"",icon:"fa-solid fa-arrows-up-down is-size-7",onClick:function(){return e.setTableSize(1)},children:(0,_.jsx)("span",{className:"is-size-7",children:"Small"})}),(0,_.jsx)(O,{text:"Medium",color:2===this.state.tableSize?"is-link is-light is-active":"",icon:"fa-solid fa-arrows-up-down",onClick:function(){return e.setTableSize(2)}})]})]})}),(0,_.jsx)("div",{className:"block "+(this.state.view===g.Table&&this.state.rows.length?"":"is-hidden"),children:(0,_.jsx)("div",{className:"table-container",children:(0,_.jsxs)("table",{className:"table is-bordered is-striped is-narrow is-hoverable",children:[(0,_.jsx)("thead",{children:(0,_.jsx)("tr",{children:t.map((function(e){return(0,_.jsx)("th",{children:e},e)}))})}),(0,_.jsx)("tbody",{children:this.state.rows.map((function(n,r){return(0,_.jsx)("tr",{children:t.map((function(t){return(0,_.jsx)("td",{children:n.has(t)?e.printValue(n.get(t)):""},t)}))},r)}))})]})})}),(0,_.jsx)("div",{className:"block "+(this.state.view===g.Graph&&this.state.rows.length?"":"is-hidden"),children:(0,_.jsxs)("div",{className:"graph",ref:this.graphElement,children:[(0,_.jsxs)("div",{className:"buttons",children:[document.fullscreenEnabled&&(0,_.jsx)(O,{icon:"fa-solid "+(null===document.fullscreenElement?"fa-expand":"fa-compress"),color:"mr-0",onClick:function(){null===document.fullscreenElement?e.graphElement.current.requestFullscreen().then((function(){setTimeout((function(){return e.orb.view.recenter()}),100),e.setState({})})):document.exitFullscreen().then((function(){setTimeout((function(){return e.orb.view.recenter()}),100),e.setState({})}))},title:"Fullscreen"}),(0,_.jsx)(O,{icon:"fa-solid fa-maximize",onClick:function(){return e.orb.view.recenter()},color:"mr-0",title:"Recenter"})]}),(0,_.jsxs)("div",{className:"brand is-flex is-align-items-center",children:[(0,_.jsx)("span",{className:"is-size-7",children:"Powered by"}),(0,_.jsx)("a",{href:"https://github.com/memgraph/orb",target:"_blank",className:"ml-1",children:(0,_.jsx)("img",{src:Ta,alt:"ORB"})})]})]})}),(0,_.jsx)("div",{className:"block "+(this.state.view===g.JSON&&this.state.rows.length?"":"is-hidden"),children:(0,_.jsxs)("div",{className:"control has-icons-right",children:[(0,_.jsx)("pre",{children:K(this.state.rows)}),(0,_.jsx)(Z.Consumer,{children:function(e){return(0,_.jsx)("span",{className:"icon is-right is-clickable",onClick:e,children:(0,_.jsx)("i",{className:"fa-regular fa-copy"})})}})]})}),(0,_.jsx)("div",{className:"block "+(this.state.view===g.Summary&&this.state.summary?"":"is-hidden"),children:(0,_.jsxs)("div",{className:"control has-icons-right",children:[(0,_.jsx)("pre",{children:K(this.state.summary)}),(0,_.jsx)(Z.Consumer,{children:function(e){return(0,_.jsx)("span",{className:"icon is-right is-clickable",onClick:e,children:(0,_.jsx)("i",{className:"fa-regular fa-copy"})})}})]})}),0===this.state.rows.length&&!this.state.summary&&(0,_.jsx)("div",{className:"block",children:"No result"})]})}}]),o}(e.Component),Ca=ka,ja=function(e){l(n,e);var t=d(n);function n(){var e;r(this,n);for(var o=arguments.length,i=new Array(o),a=0;a-1&&(r[o].key=n.value,e.props.updateProperties(r),e.setState({focus:n.name}))},e.handleValueChange=function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=R(e.props.properties),i=o.findIndex((function(e){return e.name===t}));if(i>-1)o[i].temp=r,o[i].value=n;else if((i=o.findIndex((function(e){return t.startsWith(e.name)})))>-1){var a=parseInt(t.split(".",2)[1]);o[i].temp[a]=r,o[i].value[a]=n}i>-1&&(e.props.updateProperties(o),e.setState({focus:t}))},e.handleTypeChange=function(t){var n=t.currentTarget,r=R(e.props.properties),o=r.findIndex((function(e){return"type."+e.name===n.name}));if(o>-1)r[o].type=y[n.value],y[n.value]===y.List&&(r[o].subtype=y.String),r[o].value=e.getDefaultValue(y[n.value]),r[o].temp=Q(y[n.value],r[o].value);else if((o=r.findIndex((function(e){return"subtype."+e.name===n.name})))>-1){var i=e.getDefaultValue(y[n.value]),a=Q(y[n.value],i);r[o].subtype=y[n.value],r[o].value=[i],r[o].temp=[a]}o>-1&&(e.props.updateProperties(r),e.setState({focus:n.name}))},e.getDefaultValue=function(e){var t=N.toInt(0);switch(e){case y.String:return"";case y.Boolean:return!1;case y.Integer:return t;case y.Float:return 0;case y.List:return[];case y.Time:return C.Time.fromStandardDate(new Date);case y.Date:return C.Date.fromStandardDate(new Date);case y.DateTime:return C.DateTime.fromStandardDate(new Date);case y.LocalTime:return C.LocalTime.fromStandardDate(new Date);case y.LocalDateTime:return C.LocalDateTime.fromStandardDate(new Date);case y.Point:return new C.Point(t,0,0,0);case y.Duration:return new C.Duration(t,t,t,t)}},e.handleDelete=function(t){var n=R(e.props.properties),r=n.findIndex((function(e){return e.name===t}));if(r>-1)n.splice(r,1);else if((r=n.findIndex((function(e){return t.startsWith(e.name)})))>-1){var o=parseInt(t.split(".",2)[1]);n[r].value.splice(o,1)}r>-1&&e.props.updateProperties(n)},e.handleAdd=function(t){t.preventDefault();var n=t.currentTarget,r=R(e.props.properties);if(n.value){var o=r.findIndex((function(e){return e.name===n.value}));if(o>-1){var i=e.getDefaultValue(r[o].subtype);r[o].value.push(i),r[o].temp.push(Q(r[o].subtype,i)),e.props.updateProperties(r),e.setState({focus:r[o].name+"."+(r[o].value.length-1)})}}else{var a=(new Date).getTime().toString();r.push({name:a,key:"",value:"",type:y.String,subtype:null,temp:null}),e.props.updateProperties(r),e.setState({focus:"key."+a})}},e}return s(n,[{key:"render",value:function(){var e=this;return(0,_.jsxs)(_.Fragment,{children:[this.props.properties.map((function(t){return(0,_.jsx)(Na,{focus:e.state.focus,property:t,onKeyChange:e.handleKeyChange,onValueChange:e.handleValueChange,onTypeChange:e.handleTypeChange,onDelete:e.handleDelete,onAdd:e.handleAdd},t.name)})),(0,_.jsx)(O,{icon:"fa-solid fa-plus",color:"ml-1",text:"Add property",onClick:this.handleAdd})]})}}]),n}(e.Component),Na=function(e){l(n,e);var t=d(n);function n(){var e;r(this,n);for(var o=arguments.length,i=new Array(o),a=0;a=0?"+":"-")+Math.abs(e).toString().padStart(2,"0")+":00"},t)}))})})})}}]),n}(e.Component),Wa=function(t){l(o,t);var n=d(o);function o(){var t;r(this,o);for(var i=arguments.length,a=new Array(i),s=0;s0&&void 0!==arguments[0]&&arguments[0],n=e.create?e.state.labels.join(":"):e.state.labels.filter((function(t){return!e.state.node.labels.includes(t)})).join(":");n.length>0&&(n=" SET n:"+n);var r=e.create?"":e.state.node.labels.filter((function(t){return!e.state.labels.includes(t)})).join(":");r.length>0&&(r=" REMOVE n:"+r);var o,i={},a=k(e.state.properties);try{for(a.s();!(o=a.n()).done;){var s=o.value;i[s.key]=s.value}}catch(l){a.e(l)}finally{a.f()}var u="";return t?(e.create?u+="CREATE (n)":u+="MATCH (n) WHERE "+N.fnId()+" = "+("string"===typeof e.props.id?"'"+e.props.id+"'":e.props.id),u+=n+r,e.state.properties.length&&(u+=" SET n = "+J(e.state.properties))):u+=(e.create?"CREATE (n)":"MATCH (n) WHERE "+N.fnId()+" = $id")+n+r+" SET n = $p RETURN n",{query:u,props:i}},e.handleDeleteModalConfirm=function(t,n){N.query("MATCH (n) WHERE "+N.fnId()+" = $id "+(n?"DETACH ":"")+"DELETE n",{id:t},e.props.database,!0).then((function(t){t.summary.counters.updates().nodesDeleted>0&&(e.props.tabManager.close(e.props.tabId),e.props.toast("Node deleted"))})).catch((function(t){e.setState({error:t.message})}))},e}return s(n,[{key:"componentDidMount",value:function(){this.requestData()}},{key:"componentDidUpdate",value:function(e){var t=this;!this.create&&this.props.active&&this.props.active!==e.active&&N.query("MATCH (n) WHERE "+N.fnId()+" = $id RETURN COUNT(n) AS c",{id:this.props.id},this.props.database).then((function(e){1!==N.fromInt(e.records[0].get("c"))&&t.props.tabManager.close(t.props.tabId)})).catch((function(){return t.props.tabManager.close(t.props.tabId)}))}},{key:"render",value:function(){var e=this;return this.create||null!==this.state.node?(0,_.jsxs)(_.Fragment,{children:[this.state.delete&&(0,_.jsx)(ne,{delete:this.state.delete,detach:!0,handleConfirm:this.handleDeleteModalConfirm,handleClose:function(){return e.setState({delete:!1})}}),Array.isArray(this.state.labelModal)&&(0,_.jsxs)(te,{title:"Add label",icon:"fa-solid fa-tag",handleClose:this.handleLabelModalClose,children:[(0,_.jsx)("div",{className:"buttons",children:this.state.labelModal.map((function(t){return(0,_.jsx)(O,{text:t,color:"is-link is-rounded",onClick:function(){return e.handleLabelSelect(t)}},t)}))}),(0,_.jsxs)("form",{onSubmit:function(t){return t.preventDefault(),e.handleLabelSelect(e.state.labelModalInput),!0},children:[(0,_.jsx)("label",{className:"label",children:"Or specify new one"}),(0,_.jsxs)("div",{className:"field is-grouped",children:[(0,_.jsx)("div",{className:"control is-expanded",children:(0,_.jsx)("input",{autoFocus:!0,pattern:"^[A-Za-z][A-Za-z_0-9]*$",required:!0,className:"input",type:"text",value:this.state.labelModalInput,onChange:this.handleLabelInput})}),(0,_.jsx)("div",{className:"control",children:(0,_.jsx)(O,{icon:"fa-solid fa-check",type:"submit"})})]})]})]}),(0,_.jsxs)("form",{onSubmit:this.handleSubmit,children:[!this.create&&(0,_.jsx)(Z.Consumer,{children:function(t){return(0,_.jsxs)("div",{className:"columns",children:[(0,_.jsx)("div",{className:"column "+(N.hasElementId?"is-half-desktop":""),children:(0,_.jsxs)("div",{className:"field",children:[(0,_.jsx)("label",{className:"label",children:"identity"}),(0,_.jsx)("div",{className:"control",onClick:t,children:(0,_.jsx)("input",{className:"input is-copyable",disabled:!0,type:"text",value:N.strInt(e.state.node.identity)})})]})}),N.hasElementId&&(0,_.jsx)("div",{className:"column is-half-desktop",children:(0,_.jsxs)("div",{className:"field",children:[(0,_.jsx)("label",{className:"label",children:"elementId"}),(0,_.jsx)("div",{className:"control",onClick:t,children:(0,_.jsx)("input",{className:"input is-copyable",disabled:!0,type:"text",value:e.state.node.elementId})})]})})]})}}),(0,_.jsxs)("fieldset",{className:"box",children:[(0,_.jsxs)("legend",{className:"tag is-link is-light",children:[(0,_.jsx)("i",{className:"fa-solid fa-tags mr-2"}),"Labels"]}),(0,_.jsxs)("div",{className:"buttons tags",children:[this.state.labels.map((function(t){return(0,_.jsxs)("span",{className:"tag is-link is-medium mr-3 is-rounded",children:[(0,_.jsx)("a",{className:"has-text-white mr-1",onClick:function(){return e.props.tabManager.add(t,"fa-regular fa-circle",m.Label,{label:t,database:e.props.database})},children:t}),(0,_.jsx)("button",{className:"delete",onClick:function(){return e.handleLabelDelete(t)}})]},"label-"+t)})),(0,_.jsx)(O,{icon:"fa-solid fa-plus",onClick:this.handleLabelOpenModal})]})]}),(0,_.jsxs)("fieldset",{className:"box",children:[(0,_.jsxs)("legend",{className:"tag is-link is-light",children:[(0,_.jsx)("i",{className:"fa-solid fa-rectangle-list mr-2"}),"Properties"]}),(0,_.jsx)(Ka,{properties:this.state.properties,updateProperties:function(t){e.setState({properties:t})}})]}),this.rels.length>0&&(0,_.jsxs)("fieldset",{className:"box",children:[(0,_.jsxs)("legend",{className:"tag is-link is-light",children:[(0,_.jsx)("i",{className:"fa-solid fa-circle-nodes mr-2"}),"Relationships"]}),(this.state.showAllRels?this.rels:this.rels.slice(0,3)).map((function(t){var n=N.getId(t,"startNodeElementId","start")===e.props.id?1:2,r=e.nodes.find((function(e){return N.getId(e)===N.getId(t,2===n?"startNodeElementId":"endNodeElementId",2===n?"start":"end")}));return(0,_.jsxs)("div",{className:"is-flex is-align-items-center is-justify-content-flex-start mb-3 mb-last-none",children:[(0,_.jsx)("i",{className:"fa-regular fa-circle"}),(0,_.jsxs)("span",{className:"is-size-4",children:[2===n&&"<","-["]}),(0,_.jsx)(Pa,{rel:t,tabManager:e.props.tabManager,small:!0}),(0,_.jsxs)("span",{className:"is-size-4",children:["]-",1===n&&">","("]}),(0,_.jsx)(Ea,{node:r,tabManager:e.props.tabManager,small:!0}),(0,_.jsx)("span",{className:" is-size-4",children:")"}),(0,_.jsx)("span",{className:"ml-auto"})]},N.strInt(t.identity))})),!this.state.showAllRels&&(0,_.jsx)(O,{icon:"fa-solid fa-caret-down",text:"Show all (+"+(this.rels.length-3)+")",onClick:function(){return e.setState({showAllRels:!0})}})]}),(0,_.jsx)("div",{className:"mb-3",style:{overflowY:"auto"},children:(0,_.jsxs)("span",{className:"icon-text is-flex-wrap-nowrap",children:[(0,_.jsx)("span",{className:"icon",children:(0,_.jsx)("i",{className:"fa-solid fa-terminal","aria-hidden":"true"})}),(0,_.jsx)(Z.Consumer,{children:function(t){return(0,_.jsx)("span",{className:"is-family-code is-pre-wrap is-copyable",onClick:t,children:e.generateQuery(!0).query})}})]})}),this.state.error&&(0,_.jsxs)("div",{className:"message is-danger",children:[(0,_.jsxs)("div",{className:"message-header",children:[(0,_.jsx)("p",{children:"Error"}),(0,_.jsx)("button",{className:"delete","aria-label":"delete",onClick:function(){return e.setState({error:null})}})]}),(0,_.jsx)("div",{className:"message-body",children:this.state.error})]}),(0,_.jsx)("div",{className:"field",children:(0,_.jsxs)("div",{className:"control buttons is-justify-content-flex-end",children:[(0,_.jsx)(O,{color:"is-success",type:"submit",icon:"fa-solid fa-check",text:"Execute"}),!this.create&&this.props.stashManager.button(this.state.node,this.props.database),!this.create&&(0,_.jsx)(O,{icon:"fa-solid fa-refresh",text:"Reload",onClick:this.requestData}),(0,_.jsx)(O,{icon:"fa-solid fa-xmark",text:"Close",onClick:function(t){return e.props.tabManager.close(e.props.tabId,t)}}),!this.create&&(0,_.jsx)(O,{icon:"fa-regular fa-trash-can",color:"is-danger",text:"Delete",onClick:function(){return e.setState({delete:N.getId(e.state.node)})}})]})})]})]}):(0,_.jsx)("span",{className:"has-text-grey-light",children:"Loading..."})}}]),n}(e.Component),Qa=Xa,Ja=function(e){l(n,e);var t=d(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n,[{key:"render",value:function(){var e=this;if(1!==this.props.pages){var t=[];if(this.props.page>=4)t.push(1,"e",this.props.page-1);else for(var n=1;n0&&(e.requestData(),e.props.tabManager.close(t+e.props.database),e.props.toast("Node deleted"))})).catch((function(t){e.setState({error:t.message})}))},e.handleSetSort=function(t){e.setState((function(e){var n=e.sort.indexOf(t),r=e.sort.indexOf(t+" DESC"),o=R(e.sort);return-1!==n?o[n]=t+" DESC":-1!==r?o.splice(n,1):o.push(t),{sort:o}}),e.requestData)},e.printProperty=function(e){return N.isInt(e)?N.strInt(e):Array.isArray(e)?"["+e.join(", ")+"]":"boolean"===typeof e?(0,_.jsx)(w,{name:"",label:"",checked:e,disabled:!0}):e.toString()},e}return s(n,[{key:"componentDidMount",value:function(){this.requestData()}},{key:"componentDidUpdate",value:function(e){e.active!==this.props.active&&this.props.active&&this.requestData()}},{key:"render",value:function(){var e,t=this,n=[],r=k(this.state.rows);try{for(r.s();!(e=r.n()).done;){var o=e.value;for(var i in o.properties)n.includes(i)||n.push(i)}}catch(f){r.e(f)}finally{r.f()}var a,s=k(this.state.sort);try{for(s.s();!(a=s.n()).done;){var u=a.value;u=u.replace(/^n\.([^ ]+)(?: DESC)?$/,"$1"),n.includes(u)||n.push(u)}}catch(f){s.e(f)}finally{s.f()}n.sort();var l=this.state.rows.filter((function(e){return e.labels.length>1})).length>0,c="MATCH (n:"+this.props.label+") RETURN n"+(this.state.sort.length?" ORDER BY "+this.state.sort.join(", "):"")+" SKIP "+(this.state.page-1)*this.perPage+" LIMIT "+this.perPage;return(0,_.jsxs)(_.Fragment,{children:[this.state.delete&&(0,_.jsx)(ne,{delete:this.state.delete,detach:!0,handleConfirm:this.handleDeleteModalConfirm,handleClose:function(){return t.setState({delete:!1})}}),this.state.error&&(0,_.jsxs)("div",{className:"message is-danger",children:[(0,_.jsxs)("div",{className:"message-header",children:[(0,_.jsx)("p",{children:"Error"}),(0,_.jsx)("button",{className:"delete","aria-label":"delete",onClick:function(){return t.setState({error:null})}})]}),(0,_.jsx)("div",{className:"message-body",children:this.state.error})]}),(0,_.jsx)("div",{className:"mb-3",style:{overflowY:"auto"},children:(0,_.jsxs)("span",{className:"icon-text is-flex-wrap-nowrap",children:[(0,_.jsx)("span",{className:"icon",children:(0,_.jsx)("i",{className:"fa-solid fa-terminal","aria-hidden":"true"})}),(0,_.jsx)("span",{className:"is-family-code",children:c})]})}),(0,_.jsxs)("div",{className:"buttons mb-1",children:[(0,_.jsx)(O,{icon:"fa-solid fa-plus",text:"Create node",color:"is-primary",onClick:function(){return t.props.tabManager.add({prefix:"New node"},"fa-solid fa-square-plus",m.Node,{id:null,database:t.props.database,label:t.props.label},(new Date).getTime().toString())}}),(0,_.jsx)(O,{icon:"",text:"View as graph",onClick:function(){return t.queryTabId=t.props.tabManager.add({prefix:"Query"},"fa-solid fa-terminal",m.Query,{query:c,execute:!0,view:g.Graph},t.queryTabId)}})]}),(0,_.jsx)("div",{className:"table-container",children:(0,_.jsxs)("table",{className:"table is-bordered is-striped is-narrow is-hoverable",children:[(0,_.jsxs)("thead",{children:[(0,_.jsxs)("tr",{children:[(0,_.jsx)("th",{colSpan:ae().tableViewShowElementId&&N.hasElementId?3:2,children:"Node"}),l&&(0,_.jsx)("th",{rowSpan:2,children:"additional labels"}),n.length>0?(0,_.jsx)("th",{colSpan:n.length,children:"properties"}):""]}),(0,_.jsxs)("tr",{children:[(0,_.jsxs)("th",{className:"wspace-nowrap is-clickable",onClick:function(){return t.handleSetSort("id(n)")},children:["id ",(0,_.jsx)($a,{sort:"id(n)",current:this.state.sort})]}),ae().tableViewShowElementId&&N.hasElementId&&(0,_.jsxs)("th",{className:"wspace-nowrap is-clickable",onClick:function(){return t.handleSetSort("elementId(n)")},children:["elementId ",(0,_.jsx)($a,{sort:"elementId(n)",current:this.state.sort})]}),(0,_.jsx)("th",{}),n.map((function(e){return(0,_.jsxs)("th",{className:"wspace-nowrap is-clickable",onClick:function(){return t.handleSetSort("n."+e)},children:[e," ",(0,_.jsx)($a,{sort:"n."+e,current:t.state.sort})]},"th-"+e)}))]})]}),(0,_.jsx)("tbody",{children:this.state.rows.map((function(e){return(0,_.jsxs)("tr",{children:[(0,_.jsx)("td",{children:(0,_.jsx)(O,{onClick:function(){return t.props.tabManager.add({prefix:"Node",i:e.identity},"fa-solid fa-pen-to-square",m.Node,{id:N.getId(e),database:t.props.database})},icon:"fa-solid fa-pen-clip",text:"#"+N.strInt(e.identity)})}),ae().tableViewShowElementId&&N.hasElementId&&(0,_.jsx)("td",{className:"wspace-nowrap",children:e.elementId}),(0,_.jsx)("td",{children:(0,_.jsxs)("div",{className:"buttons is-flex-wrap-nowrap",children:[t.props.stashManager.button(e,t.props.database),(0,_.jsx)(O,{icon:"fa-regular fa-trash-can",color:"is-danger is-outlined",title:"Delete",onClick:function(){return t.setState({delete:N.getId(e)})}})]})}),l&&(0,_.jsx)("td",{children:(0,_.jsx)("span",{className:"buttons",children:e.labels.filter((function(e){return e!==t.props.label})).map((function(e){return(0,_.jsx)(S,{label:e,database:t.props.database,tabManager:t.props.tabManager},e)}))})}),n.map((function(n){return(0,_.jsx)("td",{children:n in e.properties&&t.printProperty(e.properties[n])},"td-"+n)}))]},"tr-"+N.strInt(e.identity))}))})]})}),(0,_.jsx)(Ja,{page:this.state.page,pages:Math.ceil(this.state.total/this.perPage),action:this.handleChangePage})]})}}]),n}(e.Component),ts=es,ns=function(e){l(n,e);var t=d(n);function n(){var e;r(this,n);for(var o=arguments.length,i=new Array(o),a=0;a() RETURN COUNT(r) AS cnt",{},e.props.database).then((function(t){var n=N.fromInt(t.records[0].get("cnt")),r=Math.min(e.state.page,Math.ceil(n/e.perPage));N.query("MATCH (a)-[r:"+e.props.type+"]->(b) RETURN r "+(e.state.sort.length?"ORDER BY "+e.state.sort.join(", "):"")+" SKIP $s LIMIT $l",{s:N.toInt((r-1)*e.perPage),l:N.toInt(e.perPage)},e.props.database).then((function(t){e.setState({rows:t.records.map((function(e){return e.get("r")})),total:n,page:r})})).catch((function(t){return e.setState({error:"["+t.name+"] "+t.message})}))})).catch((function(){return e.props.tabManager.close(e.props.tabId)}))},e.handleChangePage=function(t){e.setState({page:t},e.requestData)},e.handleClearError=function(){e.setState({error:null})},e.handleDeleteModalConfirm=function(t){N.query("MATCH ()-[r]-() WHERE "+N.fnId("r")+" = $id DELETE r",{id:t},e.props.database,!0).then((function(n){n.summary.counters.updates().nodesDeleted>0&&(e.requestData(),e.props.tabManager.close(t+e.props.database),e.props.toast("Relationship deleted"))})).catch((function(t){e.setState({error:t.message})}))},e.handleSetSort=function(t){e.setState((function(e){var n=e.sort.indexOf(t),r=e.sort.indexOf(t+" DESC"),o=R(e.sort);return-1!==n?o[n]=t+" DESC":-1!==r?o.splice(n,1):o.push(t),{sort:o}}),e.requestData)},e.printProperty=function(e){return N.isInt(e)?N.strInt(e):Array.isArray(e)?"["+e.join(", ")+"]":"boolean"===typeof e?(0,_.jsx)(w,{name:"",label:"",checked:e,disabled:!0}):e.toString()},e}return s(n,[{key:"componentDidMount",value:function(){this.requestData()}},{key:"componentDidUpdate",value:function(e){e.active!==this.props.active&&this.props.active&&this.requestData()}},{key:"render",value:function(){var e,t=this,n=[],r=k(this.state.rows);try{for(r.s();!(e=r.n()).done;){var o=e.value;for(var i in o.properties)n.includes(i)||n.push(i)}}catch(l){r.e(l)}finally{r.f()}var a,s=k(this.state.sort);try{for(s.s();!(a=s.n()).done;){var u=a.value;u=u.replace(/^r\.([^ ]+)(?: DESC)?$/,"$1"),n.includes(u)||n.push(u)}}catch(l){s.e(l)}finally{s.f()}return n.sort(),(0,_.jsxs)(_.Fragment,{children:[this.state.delete&&(0,_.jsx)(ne,{delete:this.state.delete,handleConfirm:this.handleDeleteModalConfirm,handleClose:function(){return t.setState({delete:!1})}}),"string"===typeof this.state.error&&(0,_.jsxs)("div",{className:"message is-danger",children:[(0,_.jsxs)("div",{className:"message-header",children:[(0,_.jsx)("p",{children:"Error"}),(0,_.jsx)("button",{className:"delete","aria-label":"delete",onClick:this.handleClearError})]}),(0,_.jsx)("div",{className:"message-body",children:this.state.error})]}),(0,_.jsx)("div",{className:"mb-3",style:{overflowY:"auto"},children:(0,_.jsxs)("span",{className:"icon-text is-flex-wrap-nowrap",children:[(0,_.jsx)("span",{className:"icon",children:(0,_.jsx)("i",{className:"fa-solid fa-terminal","aria-hidden":"true"})}),(0,_.jsx)("span",{className:"is-family-code",children:"MATCH (a)-[r:"+this.props.type+"]->(b) RETURN r"+(this.state.sort.length?" ORDER BY "+this.state.sort.join(", "):"")+" SKIP "+(this.state.page-1)*this.perPage+" LIMIT "+this.perPage})]})}),(0,_.jsxs)("div",{className:"buttons mb-1",children:[(0,_.jsx)(O,{icon:"fa-solid fa-plus",text:"Create relationship",color:"is-primary",onClick:function(){return t.props.tabManager.add({prefix:"New relationship"},"fa-regular fa-square-plus",m.Rel,{id:null,database:t.props.database,type:t.props.type})}}),(0,_.jsx)(O,{icon:"",text:"View as graph",onClick:function(){return t.queryTabId=t.props.tabManager.add({prefix:"Query"},"fa-solid fa-terminal",m.Query,{query:"MATCH (a)-[r:"+t.props.type+"]->(b) RETURN a, r, b"+(t.state.sort.length?" ORDER BY "+t.state.sort.join(", "):"")+" SKIP "+(t.state.page-1)*t.perPage+" LIMIT "+t.perPage,execute:!0,view:g.Graph},t.queryTabId)}})]}),(0,_.jsx)("div",{className:"table-container",children:(0,_.jsxs)("table",{className:"table is-bordered is-striped is-narrow is-hoverable",children:[(0,_.jsxs)("thead",{children:[(0,_.jsxs)("tr",{children:[(0,_.jsx)("th",{colSpan:ae().tableViewShowElementId&&N.hasElementId?3:2,children:"Relationship"}),n.length>0?(0,_.jsx)("th",{colSpan:n.length,children:"properties"}):"",(0,_.jsx)("th",{colSpan:ae().tableViewShowElementId&&N.hasElementId?2:1,children:"Start node"}),(0,_.jsx)("th",{colSpan:ae().tableViewShowElementId&&N.hasElementId?2:1,children:"End node"})]}),(0,_.jsxs)("tr",{children:[(0,_.jsxs)("th",{rowSpan:2,className:"wspace-nowrap is-clickable",onClick:function(){return t.handleSetSort("id(r)")},children:["id ",(0,_.jsx)($a,{sort:"id(r)",current:this.state.sort})]}),ae().tableViewShowElementId&&N.hasElementId&&(0,_.jsxs)("th",{rowSpan:2,className:"wspace-nowrap is-clickable",onClick:function(){return t.handleSetSort("elementId(r)")},children:["elementId ",(0,_.jsx)($a,{sort:"elementId(r)",current:this.state.sort})]}),(0,_.jsx)("th",{}),n.map((function(e){return(0,_.jsxs)("th",{className:"wspace-nowrap is-clickable",onClick:function(){return t.handleSetSort("r."+e)},children:[e," ",(0,_.jsx)($a,{sort:"r."+e,current:t.state.sort})]},"th-"+e)})),(0,_.jsxs)("th",{className:"wspace-nowrap is-clickable",onClick:function(){return t.handleSetSort("id(a)")},children:["id ",(0,_.jsx)($a,{sort:"id(a)",current:this.state.sort})]}),ae().tableViewShowElementId&&N.hasElementId&&(0,_.jsxs)("th",{className:"wspace-nowrap is-clickable",onClick:function(){return t.handleSetSort("elementId(a)")},children:["elementId ",(0,_.jsx)($a,{sort:"elementId(a)",current:this.state.sort})]}),(0,_.jsxs)("th",{className:"wspace-nowrap is-clickable",onClick:function(){return t.handleSetSort("id(b)")},children:["id ",(0,_.jsx)($a,{sort:"id(b)",current:this.state.sort})]}),ae().tableViewShowElementId&&N.hasElementId&&(0,_.jsxs)("th",{className:"wspace-nowrap is-clickable",onClick:function(){return t.handleSetSort("elementId(b)")},children:["elementId ",(0,_.jsx)($a,{sort:"elementId(b)",current:this.state.sort})]})]})]}),(0,_.jsx)("tbody",{children:this.state.rows.map((function(e){return(0,_.jsxs)("tr",{children:[(0,_.jsx)("td",{children:(0,_.jsx)(O,{onClick:function(){return t.props.tabManager.add({prefix:"Rel",i:e.identity},"fa-regular fa-pen-to-square",m.Rel,{id:N.getId(e),database:t.props.database})},icon:"fa-solid fa-pen-clip",text:"#"+N.strInt(e.identity)})}),ae().tableViewShowElementId&&N.hasElementId&&(0,_.jsx)("td",{className:"wspace-nowrap",children:e.elementId}),(0,_.jsx)("td",{children:(0,_.jsxs)("div",{className:"is-flex-wrap-nowrap buttons",children:[t.props.stashManager.button(e,t.props.database),(0,_.jsx)(O,{icon:"fa-regular fa-trash-can",color:"is-danger is-outlined",title:"Delete",onClick:function(){return t.setState({delete:N.getId(e)})}})]})}),n.map((function(n){return(0,_.jsx)("td",{children:n in e.properties&&t.printProperty(e.properties[n])},"td-"+n)})),(0,_.jsx)("td",{children:(0,_.jsx)(O,{onClick:function(){return t.props.tabManager.add({prefix:"Node",i:e.start},"fa-solid fa-pen-to-square",m.Node,{id:N.getId(e,"startNodeElementId","start"),database:t.props.database})},icon:"fa-solid fa-pen-clip",text:"#"+N.strInt(e.start)})}),ae().tableViewShowElementId&&N.hasElementId&&(0,_.jsx)("td",{className:"wspace-nowrap",children:e.startNodeElementId}),(0,_.jsx)("td",{children:(0,_.jsx)(O,{onClick:function(){return t.props.tabManager.add({prefix:"Node",i:e.end},"fa-solid fa-pen-to-square",m.Node,{id:N.getId(e,"endNodeElementId","end"),database:t.props.database})},icon:"fa-solid fa-pen-clip",text:"#"+N.strInt(e.end)})}),ae().tableViewShowElementId&&N.hasElementId&&(0,_.jsx)("td",{className:"wspace-nowrap",children:e.endNodeElementId})]},"tr-"+N.strInt(e.identity))}))})]})}),(0,_.jsx)(Ja,{page:this.state.page,pages:Math.ceil(this.state.total/this.perPage),action:this.handleChangePage})]})}}]),n}(e.Component),rs=ns,os=function(e){l(n,e);var t=d(n);function n(){var e;r(this,n);for(var o=arguments.length,i=new Array(o),a=0;a(b) WHERE "+N.fnId("r")+" = $id RETURN r, a, b",{id:e.props.id},e.props.database).then((function(t){if(0!==t.records.length){var n=t.records[0].get("r"),r=[],o=(new Date).getTime();for(var i in n.properties){var a=X(n.properties[i]),s=a===y.List?X(n.properties[i][0]):null;r.push({name:i+o,key:i,value:n.properties[i],type:a,subtype:s,temp:Q(a,n.properties[i],s)})}r.sort((function(e,t){return e.name.toLowerCase().localeCompare(t.name.toLowerCase())})),e.setState({rel:n,start:t.records[0].get("a"),end:t.records[0].get("b"),type:n.type,properties:r})}else e.props.tabManager.close(e.props.tabId)})).catch((function(){return e.props.tabManager.close(e.props.tabId)}))},e.handleTypeOpenModal=function(){N.query("MATCH ()-[r]->() RETURN collect(DISTINCT type(r)) AS c",{},e.props.database).then((function(t){e.setState({typeModal:t.records[0].get("c").filter((function(t){return e.state.type!==t}))})})).catch((function(t){return e.setState({error:"["+t.name+"] "+t.message})}))},e.handleTypeSelect=function(t){e.setState({type:t,typeModal:!1,typeModalInput:""})},e.handleTypeInput=function(t){var n=t.currentTarget.value;ae().forceNamingRecommendations&&(n=n.replace(/^[^a-zA-Z]*/,"").replace(/[a-z]/,(function(e){return e.toUpperCase()}))),e.setState({typeModalInput:n})},e.handleTypeModalClose=function(){e.setState({typeModal:!1})},e.handleSubmit=function(t){if(t.preventDefault(),!e.state.type)return e.setState({error:"Not defined relationship type"}),!1;if(!e.state.start)return e.setState({error:"Not defined start node"}),!1;if(!e.state.end)return e.setState({error:"Not defined end node"}),!1;var n=e.generateQuery(),r=n.query,o=n.props;N.query(r,{id:e.state.rel?N.hasElementId?e.state.rel.elementId:e.state.rel.identity:null,a:N.hasElementId?e.state.start.elementId:e.state.start.identity,b:N.hasElementId?e.state.end.elementId:e.state.end.identity,p:o},e.props.database,!0).then((function(t){if(t.summary.counters.containsUpdates()&&(e.props.toast(e.create?"Relationship created":"Relationship updated"),!ae().closeEditAfterExecuteSuccess)){var n=t.records[0].get("r");(e.create||N.getId(e.state.rel)!==N.getId(n))&&(e.props.tabManager.add({prefix:"Rel",i:n.identity},"fa-solid fa-pen-to-square",m.Rel,{id:N.getId(n),database:e.props.database}),e.props.tabManager.close(e.props.tabId))}ae().closeEditAfterExecuteSuccess&&e.props.tabManager.close(e.props.tabId)})).catch((function(t){return e.setState({error:"["+t.name+"] "+t.message})}))},e.generateQuery=function(){var t,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r={},o=k(e.state.properties);try{for(o.s();!(t=o.n()).done;){var i=t.value;r[i.key]=i.value}}catch(f){o.e(f)}finally{o.f()}var a="",s=function(e){return"number"===typeof e?e.toString():"'"+e+"'"};if(e.create)a+="MATCH (a) WHERE "+N.fnId("a")+" = "+(e.state.start?n?s(N.getId(e.state.start)):"$a":""),a+=" MATCH (b) WHERE "+N.fnId("b")+" = "+(e.state.end?n?s(N.getId(e.state.end)):"$b":""),a+=" CREATE (a)-[r:"+e.state.type+"]->(b)";else{var u=N.getId(e.state.rel,"startNodeElementId","start")!==N.getId(e.state.start),l=N.getId(e.state.rel,"endNodeElementId","end")!==N.getId(e.state.end),c=u||l||e.state.rel.type!==e.state.type;a+="MATCH "+(u?"()":"(a)")+"-[r]->"+(l?"()":"(b)"),a+=" WHERE "+N.fnId("r")+" = "+(n?s(e.props.id):"$id"),u&&(a+=" MATCH (a) WHERE "+N.fnId("a")+" = "+(n?s(N.getId(e.state.start)):"$a")),l&&(a+=" MATCH (b) WHERE "+N.fnId("b")+" = "+(n?s(N.getId(e.state.end)):"$b")),c&&(a+=" DELETE r"),c&&(a+=" WITH a, b CREATE (a)-[r:"+e.state.type+"]->(b)")}return n?e.state.properties.length&&(a+=" SET r = "+J(e.state.properties)):a+=" SET r = $p RETURN r",{query:a,props:r}},e.handleDeleteModalConfirm=function(t){N.query("MATCH ()-[r]-() WHERE "+N.fnId("r")+" = $id DELETE r",{id:t},e.props.database,!0).then((function(n){n.summary.counters.updates().nodesDeleted>0&&(e.props.tabManager.close(t+e.props.database),e.props.toast("Relationship deleted"))})).catch((function(t){e.setState({error:t.message})}))},e}return s(n,[{key:"componentDidMount",value:function(){this.requestData()}},{key:"componentDidUpdate",value:function(e){var t=this;return!this.create&&this.props.active&&this.props.active!==e.active&&N.query("MATCH ()-[r]->() WHERE "+N.fnId("r")+" = $id RETURN COUNT(r) AS c",{id:this.props.id},this.props.database).then((function(e){1!==N.fromInt(e.records[0].get("c"))&&t.props.tabManager.close(t.props.tabId)})).catch((function(){return t.props.tabManager.close(t.props.tabId)})),!0}},{key:"render",value:function(){var e=this;return this.create||null!==this.state.rel?(0,_.jsxs)(_.Fragment,{children:[this.state.delete&&(0,_.jsx)(ne,{delete:this.state.delete,handleConfirm:this.handleDeleteModalConfirm,handleClose:function(){return e.setState({delete:!1})}}),Array.isArray(this.state.typeModal)&&(0,_.jsxs)(te,{title:"Set type",icon:"fa-solid fa-tag",handleClose:this.handleTypeModalClose,children:[(0,_.jsx)("div",{className:"buttons",children:this.state.typeModal.map((function(t){return(0,_.jsx)(O,{text:t,color:"is-info is-rounded",onClick:function(){return e.handleTypeSelect(t)}},t)}))}),(0,_.jsxs)("form",{onSubmit:function(t){return t.preventDefault(),e.handleTypeSelect(e.state.typeModalInput),!0},children:[(0,_.jsx)("label",{className:"label",children:"Or specify new one"}),(0,_.jsxs)("div",{className:"field is-grouped",children:[(0,_.jsx)("div",{className:"control is-expanded",children:(0,_.jsx)("input",{autoFocus:!0,pattern:"^[A-Za-z][A-Za-z_0-9]*$",required:!0,className:"input",type:"text",value:this.state.typeModalInput,onChange:this.handleTypeInput})}),(0,_.jsx)("div",{className:"control",children:(0,_.jsx)(O,{icon:"fa-solid fa-check",type:"submit"})})]})]})]}),this.state.selectNodeModal&&(0,_.jsx)(is,{stashManager:this.props.stashManager,handleNodeSelect:function(t){1===e.state.selectNodeModal?e.setState({start:t,selectNodeModal:null}):e.setState({end:t,selectNodeModal:null})},handleClose:function(){return e.setState({selectNodeModal:null})},database:this.props.database}),(0,_.jsxs)("form",{onSubmit:this.handleSubmit,children:[!this.create&&(0,_.jsx)(Z.Consumer,{children:function(t){return(0,_.jsxs)("div",{className:"columns",children:[(0,_.jsx)("div",{className:"column "+(N.hasElementId?"is-half-desktop":""),children:(0,_.jsxs)("div",{className:"field",children:[(0,_.jsx)("label",{className:"label",children:"identity"}),(0,_.jsx)("div",{className:"control",onClick:t,children:(0,_.jsx)("input",{className:"input is-copyable",disabled:!0,type:"text",value:N.strInt(e.state.rel.identity)})})]})}),N.hasElementId&&(0,_.jsx)("div",{className:"column is-half-desktop",children:(0,_.jsxs)("div",{className:"field",children:[(0,_.jsx)("label",{className:"label",children:"elementId"}),(0,_.jsx)("div",{className:"control",onClick:t,children:(0,_.jsx)("input",{className:"input is-copyable",disabled:!0,type:"text",value:e.state.rel.elementId})})]})})]})}}),(0,_.jsxs)("fieldset",{className:"box",children:[(0,_.jsxs)("legend",{className:"tag is-link is-light",children:[(0,_.jsx)("i",{className:"fa-solid fa-tags mr-2"}),"Type"]}),(0,_.jsxs)("div",{className:"buttons tags",children:[this.state.type&&(0,_.jsx)("span",{className:"tag is-info is-medium mr-3 is-rounded",children:(0,_.jsx)("a",{className:"has-text-white mr-1",onClick:function(){return e.props.tabManager.add(e.state.type,"fa-regular fa-circle",m.Type,{type:e.state.type,database:e.props.database})},children:this.state.type})}),(0,_.jsx)(O,{icon:"fa-solid fa-pen-clip",onClick:this.handleTypeOpenModal})]})]}),(0,_.jsxs)("fieldset",{className:"box",children:[(0,_.jsxs)("legend",{className:"tag is-link is-light",children:[(0,_.jsx)("i",{className:"fa-solid fa-rectangle-list mr-2"}),"Properties"]}),(0,_.jsx)(Ka,{properties:this.state.properties,updateProperties:function(t){e.setState({properties:t})}})]}),(0,_.jsxs)("fieldset",{className:"box",children:[(0,_.jsxs)("legend",{className:"tag is-link is-light",children:[(0,_.jsx)("i",{className:"fa-solid fa-circle-nodes mr-2"}),"Start node"]}),(0,_.jsxs)("div",{className:"is-flex is-align-items-center is-justify-content-flex-start mb-3 mb-last-none",children:[this.state.start&&(0,_.jsx)(Ea,{node:this.state.start,tabManager:this.props.tabManager}),(0,_.jsx)("span",{className:"ml-auto",children:(0,_.jsx)(O,{icon:"fa-solid fa-shuffle",text:"Change",onClick:function(){return e.setState({selectNodeModal:1})}})})]})]}),(0,_.jsxs)("fieldset",{className:"box",children:[(0,_.jsxs)("legend",{className:"tag is-link is-light",children:[(0,_.jsx)("i",{className:"fa-solid fa-circle-nodes mr-2"}),"End node"]}),(0,_.jsxs)("div",{className:"is-flex is-align-items-center is-justify-content-flex-start mb-3 mb-last-none",children:[this.state.end&&(0,_.jsx)(Ea,{node:this.state.end,tabManager:this.props.tabManager}),(0,_.jsx)("span",{className:"ml-auto",children:(0,_.jsx)(O,{icon:"fa-solid fa-shuffle",text:"Change",onClick:function(){return e.setState({selectNodeModal:2})}})})]})]}),(0,_.jsx)("div",{className:"mb-3",style:{overflowY:"auto"},children:(0,_.jsxs)("span",{className:"icon-text is-flex-wrap-nowrap",children:[(0,_.jsx)("span",{className:"icon",children:(0,_.jsx)("i",{className:"fa-solid fa-terminal","aria-hidden":"true"})}),(0,_.jsx)(Z.Consumer,{children:function(t){return(0,_.jsx)("span",{className:"is-family-code is-pre-wrap is-copyable",onClick:t,children:e.generateQuery(!0).query})}})]})}),this.state.error&&(0,_.jsxs)("div",{className:"message is-danger",children:[(0,_.jsxs)("div",{className:"message-header",children:[(0,_.jsx)("p",{children:"Error"}),(0,_.jsx)("button",{className:"delete","aria-label":"delete",onClick:function(){return e.setState({error:null})}})]}),(0,_.jsx)("div",{className:"message-body",children:this.state.error})]}),(0,_.jsx)("div",{className:"field",children:(0,_.jsxs)("div",{className:"control buttons is-justify-content-flex-end",children:[(0,_.jsx)(O,{color:"is-success",type:"submit",icon:"fa-solid fa-check",text:"Execute"}),!this.create&&this.props.stashManager.button(this.state.rel,this.props.database),!this.create&&(0,_.jsx)(O,{icon:"fa-solid fa-refresh",text:"Reload",onClick:this.requestData}),(0,_.jsx)(O,{icon:"fa-solid fa-xmark",text:"Close",onClick:function(t){return e.props.tabManager.close(e.props.tabId,t)}}),!this.create&&(0,_.jsx)(O,{icon:"fa-regular fa-trash-can",color:"is-danger",text:"Delete",onClick:function(){return e.setState({delete:N.getId(e.state.rel)})}})]})})]})]}):(0,_.jsx)("span",{className:"has-text-grey-light",children:"Loading..."})}}]),n}(e.Component),is=function(e){l(n,e);var t=d(n);function n(){var e;r(this,n);for(var o=arguments.length,i=new Array(o),a=0;a0?(e.props.handleNodeSelect(t.records[0].get("n")),!0):(e.setState({error:"Node not found"}),!1)})).catch((function(t){e.setState({error:"["+t.name+"] "+t.message})}))},e}return s(n,[{key:"render",value:function(){var e=this;return(0,_.jsxs)(te,{title:"Select node",icon:"fa-regular fa-circle",handleClose:this.props.handleClose,backdrop:!0,children:[(0,_.jsx)("label",{className:"label",children:"Stashed nodes"}),this.props.stashManager.get().filter((function(e){return e.value instanceof C.Node})).length>0?(0,_.jsx)("div",{className:"buttons",children:this.props.stashManager.get().filter((function(t){return t.database===e.props.database&&t.value instanceof C.Node})).map((function(t){return(0,_.jsx)(O,{text:(t.value.labels.length>0?":"+t.value.labels.join(":")+" ":"")+"#"+N.strInt(t.value.identity),onClick:function(){return e.props.handleNodeSelect(t.value)}},t.id)}))}):(0,_.jsx)("div",{className:"has-text-grey-light mb-3",children:"none"}),(0,_.jsxs)("form",{onSubmit:this.handleSubmit,children:[(0,_.jsxs)("label",{className:"label",children:["Or enter id ",N.hasElementId?"or elementId":""]}),(0,_.jsxs)("div",{className:"field is-grouped",children:[(0,_.jsx)("div",{className:"control is-expanded",children:(0,_.jsx)("input",{autoFocus:!0,required:!0,className:"input",type:"text",value:this.state.id,onChange:function(t){var n=t.currentTarget;e.setState({id:n.value,error:null})}})}),(0,_.jsx)("div",{className:"control",children:(0,_.jsx)(O,{icon:"fa-solid fa-check",type:"submit"})})]}),this.state.error&&(0,_.jsx)("div",{className:"notification is-danger",children:this.state.error})]})]})}}]),n}(e.Component),as=os,ss=function(e){l(n,e);var t=d(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n,[{key:"render",value:function(){return(0,_.jsx)(_.Fragment,{children:"history"})}}]),n}(e.Component),us=ss,ls=function(e){l(n,e);var t=d(n);function n(){var e;r(this,n);for(var o=arguments.length,i=new Array(o),a=0;a1&&(0,_.jsxs)("span",{className:"ml-1",children:["(db: ",t.database,")"]}),(0,_.jsx)("button",{className:"delete ml-auto",onClick:function(){return e.props.stashManager.remove(t.id)}})]},t.id)})),0===this.props.stashed.filter(this.filter).length&&(0,_.jsx)("span",{className:"panel-block has-text-grey-light",children:"empty"}),(0,_.jsx)("div",{className:"panel-block",children:(0,_.jsx)(O,{text:"Clear stash",color:"is-link is-outlined is-fullwidth",onClick:function(){return e.props.stashManager.empty()}})})]})]})}}]),n}(e.Component),cs=ls,fs=function(e){l(n,e);var t=d(n);function n(e){var o,i;r(this,n),(i=t.call(this,e)).state={activeTab:null,tabs:[],contents:[],toasts:[],settingsModal:!1,stashed:[],propertiesModal:null},i.components=(L(o={},m.Start,H),L(o,m.Query,Ca),L(o,m.Node,Qa),L(o,m.Label,ts),L(o,m.Type,rs),L(o,m.Rel,as),L(o,m.History,us),o),i.tabManager={add:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return"object"===typeof e&&(e=i.tabManager.generateName(e.prefix,e.i)),0===o.length&&(o=!("id"in r)||"number"!==typeof r.id&&"string"!==typeof r.id?e:r.id.toString(),"database"in r&&(o+=r.database)),i.setState((function(i){if(i.tabs.find((function(e){return e.id===o}))){var s=i.contents.find((function(e){return e.id===o}));s.props=z(z({},s.props),r)}else{var u=i.tabs.findIndex((function(e){return e.id===i.activeTab}));-1!==u?i.tabs.splice(u+1,0,{id:o,title:e,icon:t}):i.tabs.push({id:o,title:e,icon:t}),i.contents.push({id:o,page:n,props:r})}var l={tabs:i.tabs,contents:i.contents,activeTab:a||!i.activeTab?o:i.activeTab};return localStorage.setItem("tabs",JSON.stringify(l)),l})),o},close:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;null!==t&&t.stopPropagation(),i.setState((function(t){var n=t.activeTab;if(n===e){var r=t.tabs.findIndex((function(t){return t.id===e}));r>0&&(n=t.tabs[r-1].id)}var o={tabs:t.tabs.filter((function(t){return e!==t.id})),contents:t.contents.filter((function(t){return e!==t.id})),activeTab:n};return localStorage.setItem("tabs",JSON.stringify(o)),o}))},setActive:function(e){i.setState((function(t){return localStorage.setItem("tabs",JSON.stringify({tabs:t.tabs,contents:t.contents,activeTab:e})),{activeTab:e}}))},generateName:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return t=null===t?Math.max.apply(Math,[0].concat(R(i.state.tabs.filter((function(t){return t.title.startsWith(e)})).map((function(e){return parseInt(e.title.split("#")[1])})))))+1:N.strInt(t),e+"#"+t}},i.saveStashToStorage=function(){localStorage.setItem("stash",JSON.stringify(i.state.stashed.map((function(e){return{database:e.database,type:e.value instanceof C.Node?"node":e.value instanceof C.Relationship?"rel":"",identity:N.getId(e.value)}}))))},i.stashManager={add:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(new Date).getTime();i.setState((function(r){return{stashed:-1===i.stashManager.indexOf(e,r.stashed)?r.stashed.concat({id:n,value:e,database:t}):r.stashed}}),i.saveStashToStorage)},remove:function(e){i.setState((function(t){return{stashed:t.stashed.filter((function(t){return t.id!==e}))}}),i.saveStashToStorage)},indexOf:function(e){return((arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||i.state.stashed).findIndex((function(t){return N.getId(e)===N.getId(t.value)}))},empty:function(){i.state.stashed.length>0&&i.setState({stashed:[]}),localStorage.removeItem("stash")},button:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=i.stashManager.indexOf(e);return(0,_.jsx)(O,{title:-1===r?"Add to stash":"Remove from stash",onClick:function(){return-1===r?i.stashManager.add(e,t):i.stashManager.remove(i.state.stashed[r].id)},color:n,icon:-1===r?"fa-solid fa-folder-plus":"fa-solid fa-folder-minus"})},get:function(){return i.state.stashed}},i.toast=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"is-success",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,r=(new Date).getTime();i.setState({toasts:[{key:r,message:e,color:t,delay:n,timeout:setTimeout((function(){return i.discardToast(r)}),1e3*n)}].concat(R(i.state.toasts))})},i.discardToast=function(e){i.setState((function(t){return{toasts:t.toasts.filter((function(t){return t.key!==e}))}}))},i.handleCopyToClipboard=function(e){var t=e.currentTarget,n="";if(t.hasAttribute("data-copy"))n=t.getAttribute("data-copy");else if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLButtonElement)t.value.length>0&&(n=t.value);else if(t instanceof HTMLElement)if(t.firstChild instanceof HTMLInputElement&&t.firstChild.disabled||t.firstChild instanceof HTMLTextAreaElement&&t.firstChild.disabled)t.firstChild.value.length>0&&(n=t.firstChild.value);else if(t.className.includes("icon")&&t.className.includes("is-right"))for(var r,o=0;o0&&(n=r.value);break}if(!r.className.includes("icon")){r.innerText.length>0&&(n=r.innerText);break}}else t.innerText.length>0&&(n=t.innerText);n.length>0&&navigator.clipboard.writeText(n).then((function(){return i.toast("Copied to clipboard","is-success is-light")}))},i.handleShowPropertiesModal=function(e){i.setState({propertiesModal:e})};var a=localStorage.getItem("tabs");if(a){var s=JSON.parse(a);i.state.tabs=s.tabs,i.state.contents=s.contents,i.state.activeTab=s.activeTab}return i}return s(n,[{key:"componentDidMount",value:function(){var e=this;this.tabManager.add("Start","fa-solid fa-play",m.Start,{},"Start",!1);var t=localStorage.getItem("stash");if(t){var n=JSON.parse(t),r=1;N.databases.forEach((function(t){var o=t,i=n.filter((function(e){return e.database===o&&"node"===e.type})).map((function(e){return e.identity}));i.length&&N.query("MATCH (n) WHERE "+N.fnId("n")+" IN $id RETURN n",{id:i},o).then((function(t){t.records.length&&t.records.forEach((function(t){e.stashManager.add(t.get("n"),o,r++)}))})).catch(console.error);var a=n.filter((function(e){return e.database===o&&"rel"===e.type})).map((function(e){return e.identity}));a.length&&N.query("MATCH ()-[r]->() WHERE "+N.fnId("r")+" IN $id RETURN r",{id:a},o).then((function(t){t.records.length&&t.records.forEach((function(t){e.stashManager.add(t.get("r"),o,r++)}))})).catch(console.error)}))}}},{key:"render",value:function(){var e=this;if(0!==this.state.tabs.length&&null!==this.state.activeTab){var t=this.state.contents.find((function(t){return t.id===e.state.activeTab}));return document.title=this.state.tabs.find((function(t){return t.id===e.state.activeTab})).title+(N.databases.length>1&&"database"in t.props?" (db: "+t.props.database+")":"")+" / cypherGUI",(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(W,{handleLogout:this.props.handleLogout,handleOpenSettings:function(){return e.setState({settingsModal:!0})},tabManager:this.tabManager}),(0,_.jsx)("section",{className:"tabs is-boxed sticky has-background-white",children:(0,_.jsx)("ul",{children:this.state.tabs.map((function(t){return(0,_.jsx)(B,z({active:t.id===e.state.activeTab,handleClick:e.tabManager.setActive,handleRemove:e.tabManager.close},t),"tab-"+t.id)}))})}),(0,_.jsxs)(G.Provider,{value:this.handleShowPropertiesModal,children:[(0,_.jsx)(Z.Provider,{value:this.handleCopyToClipboard,children:(0,_.jsx)(V.Provider,{value:this.toast,children:(0,_.jsx)("section",{className:"container is-fluid",children:this.state.contents.map((function(t){var n=e.components[t.page];return(0,_.jsx)("div",{className:t.id===e.state.activeTab?"":"is-hidden",children:(0,_.jsx)(n,z({active:t.id===e.state.activeTab,tabName:e.state.tabs.filter((function(e){return e.id===t.id}))[0].title,tabId:t.id,tabManager:e.tabManager,toast:e.toast,stashManager:e.stashManager},t.props))},"content-"+t.id)}))})})}),(0,_.jsx)(cs,{stashed:this.state.stashed,tabManager:this.tabManager,stashManager:this.stashManager})]}),(0,_.jsx)("section",{className:"notifications",children:this.state.toasts.map((function(t){return(0,_.jsxs)("div",{className:"notification box fadeOut "+t.color,style:{animationDelay:t.delay-1+"s"},children:[(0,_.jsx)("button",{className:"delete",onClick:function(){return e.discardToast(t.key)}}),t.message]},t.key)}))}),this.state.settingsModal&&(0,_.jsx)(ie,{handleClose:function(){e.setState({settingsModal:!1})}}),this.state.propertiesModal&&(0,_.jsx)(re,{properties:this.state.propertiesModal,handleClose:function(){return e.setState({propertiesModal:null})}})]})}}}]),n}(e.Component),hs=fs,ds=function(e){l(n,e);var t=d(n);function n(){var e;r(this,n);for(var o=arguments.length,i=new Array(o),a=0;a 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nconst base64 = require('base64-js')\nconst ieee754 = require('ieee754')\nconst customInspectSymbol =\n (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation\n ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation\n : null\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nconst K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n typeof console.error === 'function') {\n console.error(\n 'This browser lacks typed array (Uint8Array) support which is required by ' +\n '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n )\n}\n\nfunction typedArraySupport () {\n // Can typed array instances can be augmented?\n try {\n const arr = new Uint8Array(1)\n const proto = { foo: function () { return 42 } }\n Object.setPrototypeOf(proto, Uint8Array.prototype)\n Object.setPrototypeOf(arr, proto)\n return arr.foo() === 42\n } catch (e) {\n return false\n }\n}\n\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.buffer\n }\n})\n\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.byteOffset\n }\n})\n\nfunction createBuffer (length) {\n if (length > K_MAX_LENGTH) {\n throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"')\n }\n // Return an augmented `Uint8Array` instance\n const buf = new Uint8Array(length)\n Object.setPrototypeOf(buf, Buffer.prototype)\n return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new TypeError(\n 'The \"string\" argument must be of type string. Received type number'\n )\n }\n return allocUnsafe(arg)\n }\n return from(arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n if (typeof value === 'string') {\n return fromString(value, encodingOrOffset)\n }\n\n if (ArrayBuffer.isView(value)) {\n return fromArrayView(value)\n }\n\n if (value == null) {\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n }\n\n if (isInstance(value, ArrayBuffer) ||\n (value && isInstance(value.buffer, ArrayBuffer))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof SharedArrayBuffer !== 'undefined' &&\n (isInstance(value, SharedArrayBuffer) ||\n (value && isInstance(value.buffer, SharedArrayBuffer)))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof value === 'number') {\n throw new TypeError(\n 'The \"value\" argument must not be of type number. Received type number'\n )\n }\n\n const valueOf = value.valueOf && value.valueOf()\n if (valueOf != null && valueOf !== value) {\n return Buffer.from(valueOf, encodingOrOffset, length)\n }\n\n const b = fromObject(value)\n if (b) return b\n\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&\n typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)\n }\n\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nObject.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)\nObject.setPrototypeOf(Buffer, Uint8Array)\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be of type number')\n } else if (size < 0) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n}\n\nfunction alloc (size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpreted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(size).fill(fill, encoding)\n : createBuffer(size).fill(fill)\n }\n return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n assertSize(size)\n return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n\n const length = byteLength(string, encoding) | 0\n let buf = createBuffer(length)\n\n const actual = buf.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual)\n }\n\n return buf\n}\n\nfunction fromArrayLike (array) {\n const length = array.length < 0 ? 0 : checked(array.length) | 0\n const buf = createBuffer(length)\n for (let i = 0; i < length; i += 1) {\n buf[i] = array[i] & 255\n }\n return buf\n}\n\nfunction fromArrayView (arrayView) {\n if (isInstance(arrayView, Uint8Array)) {\n const copy = new Uint8Array(arrayView)\n return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)\n }\n return fromArrayLike(arrayView)\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\"offset\" is outside of buffer bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\"length\" is outside of buffer bounds')\n }\n\n let buf\n if (byteOffset === undefined && length === undefined) {\n buf = new Uint8Array(array)\n } else if (length === undefined) {\n buf = new Uint8Array(array, byteOffset)\n } else {\n buf = new Uint8Array(array, byteOffset, length)\n }\n\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(buf, Buffer.prototype)\n\n return buf\n}\n\nfunction fromObject (obj) {\n if (Buffer.isBuffer(obj)) {\n const len = checked(obj.length) | 0\n const buf = createBuffer(len)\n\n if (buf.length === 0) {\n return buf\n }\n\n obj.copy(buf, 0, 0, len)\n return buf\n }\n\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n return createBuffer(0)\n }\n return fromArrayLike(obj)\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data)\n }\n}\n\nfunction checked (length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= K_MAX_LENGTH) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return b != null && b._isBuffer === true &&\n b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n}\n\nBuffer.compare = function compare (a, b) {\n if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)\n if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError(\n 'The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array'\n )\n }\n\n if (a === b) return 0\n\n let x = a.length\n let y = b.length\n\n for (let i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!Array.isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n let i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n const buffer = Buffer.allocUnsafe(length)\n let pos = 0\n for (i = 0; i < list.length; ++i) {\n let buf = list[i]\n if (isInstance(buf, Uint8Array)) {\n if (pos + buf.length > buffer.length) {\n if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)\n buf.copy(buffer, pos)\n } else {\n Uint8Array.prototype.set.call(\n buffer,\n buf,\n pos\n )\n }\n } else if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n } else {\n buf.copy(buffer, pos)\n }\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n throw new TypeError(\n 'The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. ' +\n 'Received type ' + typeof string\n )\n }\n\n const len = string.length\n const mustMatch = (arguments.length > 2 && arguments[2] === true)\n if (!mustMatch && len === 0) return 0\n\n // Use a for loop to avoid recursion\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) {\n return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8\n }\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n let loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coercion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n const i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n const len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (let i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n const len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (let i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n const len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (let i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n const length = this.length\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n let str = ''\n const max = exports.INSPECT_MAX_BYTES\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()\n if (this.length > max) str += ' ... '\n return ''\n}\nif (customInspectSymbol) {\n Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (isInstance(target, Uint8Array)) {\n target = Buffer.from(target, target.offset, target.byteLength)\n }\n if (!Buffer.isBuffer(target)) {\n throw new TypeError(\n 'The \"target\" argument must be one of type Buffer or Uint8Array. ' +\n 'Received type ' + (typeof target)\n )\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n let x = thisEnd - thisStart\n let y = end - start\n const len = Math.min(x, y)\n\n const thisCopy = this.slice(thisStart, thisEnd)\n const targetCopy = target.slice(start, end)\n\n for (let i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (numberIsNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n let indexSize = 1\n let arrLength = arr.length\n let valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n let i\n if (dir) {\n let foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n let found = true\n for (let j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n const remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n const strLen = string.length\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n let i\n for (i = 0; i < length; ++i) {\n const parsed = parseInt(string.substr(i * 2, 2), 16)\n if (numberIsNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0\n if (isFinite(length)) {\n length = length >>> 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n const remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n case 'latin1':\n case 'binary':\n return asciiWrite(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n const res = []\n\n let i = start\n while (i < end) {\n const firstByte = buf[i]\n let codePoint = null\n let bytesPerSequence = (firstByte > 0xEF)\n ? 4\n : (firstByte > 0xDF)\n ? 3\n : (firstByte > 0xBF)\n ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n let secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nconst MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n const len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n let res = ''\n let i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n const len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n let out = ''\n for (let i = start; i < end; ++i) {\n out += hexSliceLookupTable[buf[i]]\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n const bytes = buf.slice(start, end)\n let res = ''\n // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)\n for (let i = 0; i < bytes.length - 1; i += 2) {\n res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n const len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n const newBuf = this.subarray(start, end)\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(newBuf, Buffer.prototype)\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUintLE =\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUintBE =\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n let val = this[offset + --byteLength]\n let mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUint8 =\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUint16LE =\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUint16BE =\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUint32LE =\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUint32BE =\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const lo = first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24\n\n const hi = this[++offset] +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n last * 2 ** 24\n\n return BigInt(lo) + (BigInt(hi) << BigInt(32))\n})\n\nBuffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const hi = first * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n const lo = this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last\n\n return (BigInt(hi) << BigInt(32)) + BigInt(lo)\n})\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let i = byteLength\n let mul = 1\n let val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = this[offset + 4] +\n this[offset + 5] * 2 ** 8 +\n this[offset + 6] * 2 ** 16 +\n (last << 24) // Overflow\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24)\n})\n\nBuffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = (first << 24) + // Overflow\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last)\n})\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUintLE =\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let mul = 1\n let i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUintBE =\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let i = byteLength - 1\n let mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUint8 =\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeUint16LE =\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeUint16BE =\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeUint32LE =\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeUint32BE =\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nfunction wrtBigUInt64LE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n return offset\n}\n\nfunction wrtBigUInt64BE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset + 7] = lo\n lo = lo >> 8\n buf[offset + 6] = lo\n lo = lo >> 8\n buf[offset + 5] = lo\n lo = lo >> 8\n buf[offset + 4] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset + 3] = hi\n hi = hi >> 8\n buf[offset + 2] = hi\n hi = hi >> 8\n buf[offset + 1] = hi\n hi = hi >> 8\n buf[offset] = hi\n return offset + 8\n}\n\nBuffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = 0\n let mul = 1\n let sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = byteLength - 1\n let mul = 1\n let sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nBuffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n const len = end - start\n\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {\n // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end)\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, end),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n if (val.length === 1) {\n const code = val.charCodeAt(0)\n if ((encoding === 'utf8' && code < 128) ||\n encoding === 'latin1') {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code\n }\n }\n } else if (typeof val === 'number') {\n val = val & 255\n } else if (typeof val === 'boolean') {\n val = Number(val)\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n let i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n const bytes = Buffer.isBuffer(val)\n ? val\n : Buffer.from(val, encoding)\n const len = bytes.length\n if (len === 0) {\n throw new TypeError('The value \"' + val +\n '\" is invalid for argument \"value\"')\n }\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// CUSTOM ERRORS\n// =============\n\n// Simplified versions from Node, changed for Buffer-only usage\nconst errors = {}\nfunction E (sym, getMessage, Base) {\n errors[sym] = class NodeError extends Base {\n constructor () {\n super()\n\n Object.defineProperty(this, 'message', {\n value: getMessage.apply(this, arguments),\n writable: true,\n configurable: true\n })\n\n // Add the error code to the name to include it in the stack trace.\n this.name = `${this.name} [${sym}]`\n // Access the stack to generate the error message including the error code\n // from the name.\n this.stack // eslint-disable-line no-unused-expressions\n // Reset the name to the actual name.\n delete this.name\n }\n\n get code () {\n return sym\n }\n\n set code (value) {\n Object.defineProperty(this, 'code', {\n configurable: true,\n enumerable: true,\n value,\n writable: true\n })\n }\n\n toString () {\n return `${this.name} [${sym}]: ${this.message}`\n }\n }\n}\n\nE('ERR_BUFFER_OUT_OF_BOUNDS',\n function (name) {\n if (name) {\n return `${name} is outside of buffer bounds`\n }\n\n return 'Attempt to access memory outside buffer bounds'\n }, RangeError)\nE('ERR_INVALID_ARG_TYPE',\n function (name, actual) {\n return `The \"${name}\" argument must be of type number. Received type ${typeof actual}`\n }, TypeError)\nE('ERR_OUT_OF_RANGE',\n function (str, range, input) {\n let msg = `The value of \"${str}\" is out of range.`\n let received = input\n if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {\n received = addNumericalSeparator(String(input))\n } else if (typeof input === 'bigint') {\n received = String(input)\n if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {\n received = addNumericalSeparator(received)\n }\n received += 'n'\n }\n msg += ` It must be ${range}. Received ${received}`\n return msg\n }, RangeError)\n\nfunction addNumericalSeparator (val) {\n let res = ''\n let i = val.length\n const start = val[0] === '-' ? 1 : 0\n for (; i >= start + 4; i -= 3) {\n res = `_${val.slice(i - 3, i)}${res}`\n }\n return `${val.slice(0, i)}${res}`\n}\n\n// CHECK FUNCTIONS\n// ===============\n\nfunction checkBounds (buf, offset, byteLength) {\n validateNumber(offset, 'offset')\n if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {\n boundsError(offset, buf.length - (byteLength + 1))\n }\n}\n\nfunction checkIntBI (value, min, max, buf, offset, byteLength) {\n if (value > max || value < min) {\n const n = typeof min === 'bigint' ? 'n' : ''\n let range\n if (byteLength > 3) {\n if (min === 0 || min === BigInt(0)) {\n range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`\n } else {\n range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +\n `${(byteLength + 1) * 8 - 1}${n}`\n }\n } else {\n range = `>= ${min}${n} and <= ${max}${n}`\n }\n throw new errors.ERR_OUT_OF_RANGE('value', range, value)\n }\n checkBounds(buf, offset, byteLength)\n}\n\nfunction validateNumber (value, name) {\n if (typeof value !== 'number') {\n throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)\n }\n}\n\nfunction boundsError (value, length, type) {\n if (Math.floor(value) !== value) {\n validateNumber(value, type)\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)\n }\n\n if (length < 0) {\n throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()\n }\n\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset',\n `>= ${type ? 1 : 0} and <= ${length}`,\n value)\n}\n\n// HELPER FUNCTIONS\n// ================\n\nconst INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0]\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n let codePoint\n const length = string.length\n let leadSurrogate = null\n const bytes = []\n\n for (let i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n let c, hi, lo\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n let i\n for (i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction isInstance (obj, type) {\n return obj instanceof type ||\n (obj != null && obj.constructor != null && obj.constructor.name != null &&\n obj.constructor.name === type.name)\n}\nfunction numberIsNaN (obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n}\n\n// Create lookup table for `toString('hex')`\n// See: https://github.com/feross/buffer/issues/219\nconst hexSliceLookupTable = (function () {\n const alphabet = '0123456789abcdef'\n const table = new Array(256)\n for (let i = 0; i < 16; ++i) {\n const i16 = i * 16\n for (let j = 0; j < 16; ++j) {\n table[i16 + j] = alphabet[i] + alphabet[j]\n }\n }\n return table\n})()\n\n// Return not function with Error if BigInt not supported\nfunction defineBigIntMethod (fn) {\n return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn\n}\n\nfunction BufferBigIntNotDefined () {\n throw new Error('BigInt not supported')\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","/*\r\n * @namespace Util\r\n *\r\n * Various utility functions, used by Leaflet internally.\r\n */\r\n\r\n// @function extend(dest: Object, src?: Object): Object\r\n// Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut.\r\nexport function extend(dest) {\r\n\tvar i, j, len, src;\r\n\r\n\tfor (j = 1, len = arguments.length; j < len; j++) {\r\n\t\tsrc = arguments[j];\r\n\t\tfor (i in src) {\r\n\t\t\tdest[i] = src[i];\r\n\t\t}\r\n\t}\r\n\treturn dest;\r\n}\r\n\r\n// @function create(proto: Object, properties?: Object): Object\r\n// Compatibility polyfill for [Object.create](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create)\r\nexport var create = Object.create || (function () {\r\n\tfunction F() {}\r\n\treturn function (proto) {\r\n\t\tF.prototype = proto;\r\n\t\treturn new F();\r\n\t};\r\n})();\r\n\r\n// @function bind(fn: Function, …): Function\r\n// Returns a new function bound to the arguments passed, like [Function.prototype.bind](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).\r\n// Has a `L.bind()` shortcut.\r\nexport function bind(fn, obj) {\r\n\tvar slice = Array.prototype.slice;\r\n\r\n\tif (fn.bind) {\r\n\t\treturn fn.bind.apply(fn, slice.call(arguments, 1));\r\n\t}\r\n\r\n\tvar args = slice.call(arguments, 2);\r\n\r\n\treturn function () {\r\n\t\treturn fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments);\r\n\t};\r\n}\r\n\r\n// @property lastId: Number\r\n// Last unique ID used by [`stamp()`](#util-stamp)\r\nexport var lastId = 0;\r\n\r\n// @function stamp(obj: Object): Number\r\n// Returns the unique ID of an object, assigning it one if it doesn't have it.\r\nexport function stamp(obj) {\r\n\tif (!('_leaflet_id' in obj)) {\r\n\t\tobj['_leaflet_id'] = ++lastId;\r\n\t}\r\n\treturn obj._leaflet_id;\r\n}\r\n\r\n// @function throttle(fn: Function, time: Number, context: Object): Function\r\n// Returns a function which executes function `fn` with the given scope `context`\r\n// (so that the `this` keyword refers to `context` inside `fn`'s code). The function\r\n// `fn` will be called no more than one time per given amount of `time`. The arguments\r\n// received by the bound function will be any arguments passed when binding the\r\n// function, followed by any arguments passed when invoking the bound function.\r\n// Has an `L.throttle` shortcut.\r\nexport function throttle(fn, time, context) {\r\n\tvar lock, args, wrapperFn, later;\r\n\r\n\tlater = function () {\r\n\t\t// reset lock and call if queued\r\n\t\tlock = false;\r\n\t\tif (args) {\r\n\t\t\twrapperFn.apply(context, args);\r\n\t\t\targs = false;\r\n\t\t}\r\n\t};\r\n\r\n\twrapperFn = function () {\r\n\t\tif (lock) {\r\n\t\t\t// called too soon, queue to call later\r\n\t\t\targs = arguments;\r\n\r\n\t\t} else {\r\n\t\t\t// call and lock until later\r\n\t\t\tfn.apply(context, arguments);\r\n\t\t\tsetTimeout(later, time);\r\n\t\t\tlock = true;\r\n\t\t}\r\n\t};\r\n\r\n\treturn wrapperFn;\r\n}\r\n\r\n// @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number\r\n// Returns the number `num` modulo `range` in such a way so it lies within\r\n// `range[0]` and `range[1]`. The returned value will be always smaller than\r\n// `range[1]` unless `includeMax` is set to `true`.\r\nexport function wrapNum(x, range, includeMax) {\r\n\tvar max = range[1],\r\n\t min = range[0],\r\n\t d = max - min;\r\n\treturn x === max && includeMax ? x : ((x - min) % d + d) % d + min;\r\n}\r\n\r\n// @function falseFn(): Function\r\n// Returns a function which always returns `false`.\r\nexport function falseFn() { return false; }\r\n\r\n// @function formatNum(num: Number, precision?: Number|false): Number\r\n// Returns the number `num` rounded with specified `precision`.\r\n// The default `precision` value is 6 decimal places.\r\n// `false` can be passed to skip any processing (can be useful to avoid round-off errors).\r\nexport function formatNum(num, precision) {\r\n\tif (precision === false) { return num; }\r\n\tvar pow = Math.pow(10, precision === undefined ? 6 : precision);\r\n\treturn Math.round(num * pow) / pow;\r\n}\r\n\r\n// @function trim(str: String): String\r\n// Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)\r\nexport function trim(str) {\r\n\treturn str.trim ? str.trim() : str.replace(/^\\s+|\\s+$/g, '');\r\n}\r\n\r\n// @function splitWords(str: String): String[]\r\n// Trims and splits the string on whitespace and returns the array of parts.\r\nexport function splitWords(str) {\r\n\treturn trim(str).split(/\\s+/);\r\n}\r\n\r\n// @function setOptions(obj: Object, options: Object): Object\r\n// Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut.\r\nexport function setOptions(obj, options) {\r\n\tif (!Object.prototype.hasOwnProperty.call(obj, 'options')) {\r\n\t\tobj.options = obj.options ? create(obj.options) : {};\r\n\t}\r\n\tfor (var i in options) {\r\n\t\tobj.options[i] = options[i];\r\n\t}\r\n\treturn obj.options;\r\n}\r\n\r\n// @function getParamString(obj: Object, existingUrl?: String, uppercase?: Boolean): String\r\n// Converts an object into a parameter URL string, e.g. `{a: \"foo\", b: \"bar\"}`\r\n// translates to `'?a=foo&b=bar'`. If `existingUrl` is set, the parameters will\r\n// be appended at the end. If `uppercase` is `true`, the parameter names will\r\n// be uppercased (e.g. `'?A=foo&B=bar'`)\r\nexport function getParamString(obj, existingUrl, uppercase) {\r\n\tvar params = [];\r\n\tfor (var i in obj) {\r\n\t\tparams.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i]));\r\n\t}\r\n\treturn ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');\r\n}\r\n\r\nvar templateRe = /\\{ *([\\w_ -]+) *\\}/g;\r\n\r\n// @function template(str: String, data: Object): String\r\n// Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`\r\n// and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string\r\n// `('Hello foo, bar')`. You can also specify functions instead of strings for\r\n// data values — they will be evaluated passing `data` as an argument.\r\nexport function template(str, data) {\r\n\treturn str.replace(templateRe, function (str, key) {\r\n\t\tvar value = data[key];\r\n\r\n\t\tif (value === undefined) {\r\n\t\t\tthrow new Error('No value provided for variable ' + str);\r\n\r\n\t\t} else if (typeof value === 'function') {\r\n\t\t\tvalue = value(data);\r\n\t\t}\r\n\t\treturn value;\r\n\t});\r\n}\r\n\r\n// @function isArray(obj): Boolean\r\n// Compatibility polyfill for [Array.isArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)\r\nexport var isArray = Array.isArray || function (obj) {\r\n\treturn (Object.prototype.toString.call(obj) === '[object Array]');\r\n};\r\n\r\n// @function indexOf(array: Array, el: Object): Number\r\n// Compatibility polyfill for [Array.prototype.indexOf](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)\r\nexport function indexOf(array, el) {\r\n\tfor (var i = 0; i < array.length; i++) {\r\n\t\tif (array[i] === el) { return i; }\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\n// @property emptyImageUrl: String\r\n// Data URI string containing a base64-encoded empty GIF image.\r\n// Used as a hack to free memory from unused images on WebKit-powered\r\n// mobile devices (by setting image `src` to this string).\r\nexport var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';\r\n\r\n// inspired by https://paulirish.com/2011/requestanimationframe-for-smart-animating/\r\n\r\nfunction getPrefixed(name) {\r\n\treturn window['webkit' + name] || window['moz' + name] || window['ms' + name];\r\n}\r\n\r\nvar lastTime = 0;\r\n\r\n// fallback for IE 7-8\r\nfunction timeoutDefer(fn) {\r\n\tvar time = +new Date(),\r\n\t timeToCall = Math.max(0, 16 - (time - lastTime));\r\n\r\n\tlastTime = time + timeToCall;\r\n\treturn window.setTimeout(fn, timeToCall);\r\n}\r\n\r\nexport var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer;\r\nexport var cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') ||\r\n\t\tgetPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); };\r\n\r\n// @function requestAnimFrame(fn: Function, context?: Object, immediate?: Boolean): Number\r\n// Schedules `fn` to be executed when the browser repaints. `fn` is bound to\r\n// `context` if given. When `immediate` is set, `fn` is called immediately if\r\n// the browser doesn't have native support for\r\n// [`window.requestAnimationFrame`](https://developer.mozilla.org/docs/Web/API/window/requestAnimationFrame),\r\n// otherwise it's delayed. Returns a request ID that can be used to cancel the request.\r\nexport function requestAnimFrame(fn, context, immediate) {\r\n\tif (immediate && requestFn === timeoutDefer) {\r\n\t\tfn.call(context);\r\n\t} else {\r\n\t\treturn requestFn.call(window, bind(fn, context));\r\n\t}\r\n}\r\n\r\n// @function cancelAnimFrame(id: Number): undefined\r\n// Cancels a previous `requestAnimFrame`. See also [window.cancelAnimationFrame](https://developer.mozilla.org/docs/Web/API/window/cancelAnimationFrame).\r\nexport function cancelAnimFrame(id) {\r\n\tif (id) {\r\n\t\tcancelFn.call(window, id);\r\n\t}\r\n}\r\n","import * as Util from './Util';\r\n\r\n// @class Class\r\n// @aka L.Class\r\n\r\n// @section\r\n// @uninheritable\r\n\r\n// Thanks to John Resig and Dean Edwards for inspiration!\r\n\r\nexport function Class() {}\r\n\r\nClass.extend = function (props) {\r\n\r\n\t// @function extend(props: Object): Function\r\n\t// [Extends the current class](#class-inheritance) given the properties to be included.\r\n\t// Returns a Javascript function that is a class constructor (to be called with `new`).\r\n\tvar NewClass = function () {\r\n\r\n\t\tUtil.setOptions(this);\r\n\r\n\t\t// call the constructor\r\n\t\tif (this.initialize) {\r\n\t\t\tthis.initialize.apply(this, arguments);\r\n\t\t}\r\n\r\n\t\t// call all constructor hooks\r\n\t\tthis.callInitHooks();\r\n\t};\r\n\r\n\tvar parentProto = NewClass.__super__ = this.prototype;\r\n\r\n\tvar proto = Util.create(parentProto);\r\n\tproto.constructor = NewClass;\r\n\r\n\tNewClass.prototype = proto;\r\n\r\n\t// inherit parent's statics\r\n\tfor (var i in this) {\r\n\t\tif (Object.prototype.hasOwnProperty.call(this, i) && i !== 'prototype' && i !== '__super__') {\r\n\t\t\tNewClass[i] = this[i];\r\n\t\t}\r\n\t}\r\n\r\n\t// mix static properties into the class\r\n\tif (props.statics) {\r\n\t\tUtil.extend(NewClass, props.statics);\r\n\t}\r\n\r\n\t// mix includes into the prototype\r\n\tif (props.includes) {\r\n\t\tcheckDeprecatedMixinEvents(props.includes);\r\n\t\tUtil.extend.apply(null, [proto].concat(props.includes));\r\n\t}\r\n\r\n\t// mix given properties into the prototype\r\n\tUtil.extend(proto, props);\r\n\tdelete proto.statics;\r\n\tdelete proto.includes;\r\n\r\n\t// merge options\r\n\tif (proto.options) {\r\n\t\tproto.options = parentProto.options ? Util.create(parentProto.options) : {};\r\n\t\tUtil.extend(proto.options, props.options);\r\n\t}\r\n\r\n\tproto._initHooks = [];\r\n\r\n\t// add method for calling all hooks\r\n\tproto.callInitHooks = function () {\r\n\r\n\t\tif (this._initHooksCalled) { return; }\r\n\r\n\t\tif (parentProto.callInitHooks) {\r\n\t\t\tparentProto.callInitHooks.call(this);\r\n\t\t}\r\n\r\n\t\tthis._initHooksCalled = true;\r\n\r\n\t\tfor (var i = 0, len = proto._initHooks.length; i < len; i++) {\r\n\t\t\tproto._initHooks[i].call(this);\r\n\t\t}\r\n\t};\r\n\r\n\treturn NewClass;\r\n};\r\n\r\n\r\n// @function include(properties: Object): this\r\n// [Includes a mixin](#class-includes) into the current class.\r\nClass.include = function (props) {\r\n\tvar parentOptions = this.prototype.options;\r\n\tUtil.extend(this.prototype, props);\r\n\tif (props.options) {\r\n\t\tthis.prototype.options = parentOptions;\r\n\t\tthis.mergeOptions(props.options);\r\n\t}\r\n\treturn this;\r\n};\r\n\r\n// @function mergeOptions(options: Object): this\r\n// [Merges `options`](#class-options) into the defaults of the class.\r\nClass.mergeOptions = function (options) {\r\n\tUtil.extend(this.prototype.options, options);\r\n\treturn this;\r\n};\r\n\r\n// @function addInitHook(fn: Function): this\r\n// Adds a [constructor hook](#class-constructor-hooks) to the class.\r\nClass.addInitHook = function (fn) { // (Function) || (String, args...)\r\n\tvar args = Array.prototype.slice.call(arguments, 1);\r\n\r\n\tvar init = typeof fn === 'function' ? fn : function () {\r\n\t\tthis[fn].apply(this, args);\r\n\t};\r\n\r\n\tthis.prototype._initHooks = this.prototype._initHooks || [];\r\n\tthis.prototype._initHooks.push(init);\r\n\treturn this;\r\n};\r\n\r\nfunction checkDeprecatedMixinEvents(includes) {\r\n\tif (typeof L === 'undefined' || !L || !L.Mixin) { return; }\r\n\r\n\tincludes = Util.isArray(includes) ? includes : [includes];\r\n\r\n\tfor (var i = 0; i < includes.length; i++) {\r\n\t\tif (includes[i] === L.Mixin.Events) {\r\n\t\t\tconsole.warn('Deprecated include of L.Mixin.Events: ' +\r\n\t\t\t\t'this property will be removed in future releases, ' +\r\n\t\t\t\t'please inherit from L.Evented instead.', new Error().stack);\r\n\t\t}\r\n\t}\r\n}\r\n","import {Class} from './Class';\r\nimport * as Util from './Util';\r\n\r\n/*\r\n * @class Evented\r\n * @aka L.Evented\r\n * @inherits Class\r\n *\r\n * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event).\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * map.on('click', function(e) {\r\n * \talert(e.latlng);\r\n * } );\r\n * ```\r\n *\r\n * Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:\r\n *\r\n * ```js\r\n * function onClick(e) { ... }\r\n *\r\n * map.on('click', onClick);\r\n * map.off('click', onClick);\r\n * ```\r\n */\r\n\r\nexport var Events = {\r\n\t/* @method on(type: String, fn: Function, context?: Object): this\r\n\t * Adds a listener function (`fn`) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. `'click dblclick'`).\r\n\t *\r\n\t * @alternative\r\n\t * @method on(eventMap: Object): this\r\n\t * Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`\r\n\t */\r\n\ton: function (types, fn, context) {\r\n\r\n\t\t// types can be a map of types/handlers\r\n\t\tif (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\t// we don't process space-separated events here for performance;\r\n\t\t\t\t// it's a hot path since Layer uses the on(obj) syntax\r\n\t\t\t\tthis._on(type, types[type], fn);\r\n\t\t\t}\r\n\r\n\t\t} else {\r\n\t\t\t// types can be a string of space-separated words\r\n\t\t\ttypes = Util.splitWords(types);\r\n\r\n\t\t\tfor (var i = 0, len = types.length; i < len; i++) {\r\n\t\t\t\tthis._on(types[i], fn, context);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t/* @method off(type: String, fn?: Function, context?: Object): this\r\n\t * Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to `on`, you must pass the same context to `off` in order to remove the listener.\r\n\t *\r\n\t * @alternative\r\n\t * @method off(eventMap: Object): this\r\n\t * Removes a set of type/listener pairs.\r\n\t *\r\n\t * @alternative\r\n\t * @method off: this\r\n\t * Removes all listeners to all events on the object. This includes implicitly attached events.\r\n\t */\r\n\toff: function (types, fn, context) {\r\n\r\n\t\tif (!arguments.length) {\r\n\t\t\t// clear all listeners if called without arguments\r\n\t\t\tdelete this._events;\r\n\r\n\t\t} else if (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\tthis._off(type, types[type], fn);\r\n\t\t\t}\r\n\r\n\t\t} else {\r\n\t\t\ttypes = Util.splitWords(types);\r\n\r\n\t\t\tvar removeAll = arguments.length === 1;\r\n\t\t\tfor (var i = 0, len = types.length; i < len; i++) {\r\n\t\t\t\tif (removeAll) {\r\n\t\t\t\t\tthis._off(types[i]);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis._off(types[i], fn, context);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// attach listener (without syntactic sugar now)\r\n\t_on: function (type, fn, context) {\r\n\t\tif (typeof fn !== 'function') {\r\n\t\t\tconsole.warn('wrong listener type: ' + typeof fn);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._events = this._events || {};\r\n\r\n\t\t/* get/init listeners for type */\r\n\t\tvar typeListeners = this._events[type];\r\n\t\tif (!typeListeners) {\r\n\t\t\ttypeListeners = [];\r\n\t\t\tthis._events[type] = typeListeners;\r\n\t\t}\r\n\r\n\t\tif (context === this) {\r\n\t\t\t// Less memory footprint.\r\n\t\t\tcontext = undefined;\r\n\t\t}\r\n\t\tvar newListener = {fn: fn, ctx: context},\r\n\t\t listeners = typeListeners;\r\n\r\n\t\t// check if fn already there\r\n\t\tfor (var i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\tif (listeners[i].fn === fn && listeners[i].ctx === context) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlisteners.push(newListener);\r\n\t},\r\n\r\n\t_off: function (type, fn, context) {\r\n\t\tvar listeners,\r\n\t\t i,\r\n\t\t len;\r\n\r\n\t\tif (!this._events) { return; }\r\n\r\n\t\tlisteners = this._events[type];\r\n\r\n\t\tif (!listeners) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (arguments.length === 1) { // remove all\r\n\t\t\tif (this._firingCount) {\r\n\t\t\t\t// Set all removed listeners to noop\r\n\t\t\t\t// so they are not called if remove happens in fire\r\n\t\t\t\tfor (i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\t\t\tlisteners[i].fn = Util.falseFn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// clear all listeners for a type if function isn't specified\r\n\t\t\tdelete this._events[type];\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (context === this) {\r\n\t\t\tcontext = undefined;\r\n\t\t}\r\n\r\n\t\tif (typeof fn !== 'function') {\r\n\t\t\tconsole.warn('wrong listener type: ' + typeof fn);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// find fn and remove it\r\n\t\tfor (i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\tvar l = listeners[i];\r\n\t\t\tif (l.ctx !== context) { continue; }\r\n\t\t\tif (l.fn === fn) {\r\n\t\t\t\tif (this._firingCount) {\r\n\t\t\t\t\t// set the removed listener to noop so that's not called if remove happens in fire\r\n\t\t\t\t\tl.fn = Util.falseFn;\r\n\r\n\t\t\t\t\t/* copy array in case events are being fired */\r\n\t\t\t\t\tthis._events[type] = listeners = listeners.slice();\r\n\t\t\t\t}\r\n\t\t\t\tlisteners.splice(i, 1);\r\n\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t\tconsole.warn('listener not found');\r\n\t},\r\n\r\n\t// @method fire(type: String, data?: Object, propagate?: Boolean): this\r\n\t// Fires an event of the specified type. You can optionally provide a data\r\n\t// object — the first argument of the listener function will contain its\r\n\t// properties. The event can optionally be propagated to event parents.\r\n\tfire: function (type, data, propagate) {\r\n\t\tif (!this.listens(type, propagate)) { return this; }\r\n\r\n\t\tvar event = Util.extend({}, data, {\r\n\t\t\ttype: type,\r\n\t\t\ttarget: this,\r\n\t\t\tsourceTarget: data && data.sourceTarget || this\r\n\t\t});\r\n\r\n\t\tif (this._events) {\r\n\t\t\tvar listeners = this._events[type];\r\n\r\n\t\t\tif (listeners) {\r\n\t\t\t\tthis._firingCount = (this._firingCount + 1) || 1;\r\n\t\t\t\tfor (var i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\t\t\tvar l = listeners[i];\r\n\t\t\t\t\tl.fn.call(l.ctx || this, event);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis._firingCount--;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (propagate) {\r\n\t\t\t// propagate the event to parents (set with addEventParent)\r\n\t\t\tthis._propagateEvent(event);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method listens(type: String, propagate?: Boolean): Boolean\r\n\t// Returns `true` if a particular event type has any listeners attached to it.\r\n\t// The verification can optionally be propagated, it will return `true` if parents have the listener attached to it.\r\n\tlistens: function (type, propagate) {\r\n\t\tif (typeof type !== 'string') {\r\n\t\t\tconsole.warn('\"string\" type argument expected');\r\n\t\t}\r\n\t\tvar listeners = this._events && this._events[type];\r\n\t\tif (listeners && listeners.length) { return true; }\r\n\r\n\t\tif (propagate) {\r\n\t\t\t// also check parents for listeners if event propagates\r\n\t\t\tfor (var id in this._eventParents) {\r\n\t\t\t\tif (this._eventParents[id].listens(type, propagate)) { return true; }\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t},\r\n\r\n\t// @method once(…): this\r\n\t// Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed.\r\n\tonce: function (types, fn, context) {\r\n\r\n\t\tif (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\tthis.once(type, types[type], fn);\r\n\t\t\t}\r\n\t\t\treturn this;\r\n\t\t}\r\n\r\n\t\tvar handler = Util.bind(function () {\r\n\t\t\tthis\r\n\t\t\t .off(types, fn, context)\r\n\t\t\t .off(types, handler, context);\r\n\t\t}, this);\r\n\r\n\t\t// add a listener that's executed once and removed after that\r\n\t\treturn this\r\n\t\t .on(types, fn, context)\r\n\t\t .on(types, handler, context);\r\n\t},\r\n\r\n\t// @method addEventParent(obj: Evented): this\r\n\t// Adds an event parent - an `Evented` that will receive propagated events\r\n\taddEventParent: function (obj) {\r\n\t\tthis._eventParents = this._eventParents || {};\r\n\t\tthis._eventParents[Util.stamp(obj)] = obj;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeEventParent(obj: Evented): this\r\n\t// Removes an event parent, so it will stop receiving propagated events\r\n\tremoveEventParent: function (obj) {\r\n\t\tif (this._eventParents) {\r\n\t\t\tdelete this._eventParents[Util.stamp(obj)];\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_propagateEvent: function (e) {\r\n\t\tfor (var id in this._eventParents) {\r\n\t\t\tthis._eventParents[id].fire(e.type, Util.extend({\r\n\t\t\t\tlayer: e.target,\r\n\t\t\t\tpropagatedFrom: e.target\r\n\t\t\t}, e), true);\r\n\t\t}\r\n\t}\r\n};\r\n\r\n// aliases; we should ditch those eventually\r\n\r\n// @method addEventListener(…): this\r\n// Alias to [`on(…)`](#evented-on)\r\nEvents.addEventListener = Events.on;\r\n\r\n// @method removeEventListener(…): this\r\n// Alias to [`off(…)`](#evented-off)\r\n\r\n// @method clearAllEventListeners(…): this\r\n// Alias to [`off()`](#evented-off)\r\nEvents.removeEventListener = Events.clearAllEventListeners = Events.off;\r\n\r\n// @method addOneTimeEventListener(…): this\r\n// Alias to [`once(…)`](#evented-once)\r\nEvents.addOneTimeEventListener = Events.once;\r\n\r\n// @method fireEvent(…): this\r\n// Alias to [`fire(…)`](#evented-fire)\r\nEvents.fireEvent = Events.fire;\r\n\r\n// @method hasEventListeners(…): Boolean\r\n// Alias to [`listens(…)`](#evented-listens)\r\nEvents.hasEventListeners = Events.listens;\r\n\r\nexport var Evented = Class.extend(Events);\r\n","import {isArray, formatNum} from '../core/Util';\r\n\r\n/*\r\n * @class Point\r\n * @aka L.Point\r\n *\r\n * Represents a point with `x` and `y` coordinates in pixels.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var point = L.point(200, 300);\r\n * ```\r\n *\r\n * All Leaflet methods and options that accept `Point` objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent:\r\n *\r\n * ```js\r\n * map.panBy([200, 300]);\r\n * map.panBy(L.point(200, 300));\r\n * ```\r\n *\r\n * Note that `Point` does not inherit from Leaflet's `Class` object,\r\n * which means new classes can't inherit from it, and new methods\r\n * can't be added to it with the `include` function.\r\n */\r\n\r\nexport function Point(x, y, round) {\r\n\t// @property x: Number; The `x` coordinate of the point\r\n\tthis.x = (round ? Math.round(x) : x);\r\n\t// @property y: Number; The `y` coordinate of the point\r\n\tthis.y = (round ? Math.round(y) : y);\r\n}\r\n\r\nvar trunc = Math.trunc || function (v) {\r\n\treturn v > 0 ? Math.floor(v) : Math.ceil(v);\r\n};\r\n\r\nPoint.prototype = {\r\n\r\n\t// @method clone(): Point\r\n\t// Returns a copy of the current point.\r\n\tclone: function () {\r\n\t\treturn new Point(this.x, this.y);\r\n\t},\r\n\r\n\t// @method add(otherPoint: Point): Point\r\n\t// Returns the result of addition of the current and the given points.\r\n\tadd: function (point) {\r\n\t\t// non-destructive, returns a new point\r\n\t\treturn this.clone()._add(toPoint(point));\r\n\t},\r\n\r\n\t_add: function (point) {\r\n\t\t// destructive, used directly for performance in situations where it's safe to modify existing point\r\n\t\tthis.x += point.x;\r\n\t\tthis.y += point.y;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method subtract(otherPoint: Point): Point\r\n\t// Returns the result of subtraction of the given point from the current.\r\n\tsubtract: function (point) {\r\n\t\treturn this.clone()._subtract(toPoint(point));\r\n\t},\r\n\r\n\t_subtract: function (point) {\r\n\t\tthis.x -= point.x;\r\n\t\tthis.y -= point.y;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method divideBy(num: Number): Point\r\n\t// Returns the result of division of the current point by the given number.\r\n\tdivideBy: function (num) {\r\n\t\treturn this.clone()._divideBy(num);\r\n\t},\r\n\r\n\t_divideBy: function (num) {\r\n\t\tthis.x /= num;\r\n\t\tthis.y /= num;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method multiplyBy(num: Number): Point\r\n\t// Returns the result of multiplication of the current point by the given number.\r\n\tmultiplyBy: function (num) {\r\n\t\treturn this.clone()._multiplyBy(num);\r\n\t},\r\n\r\n\t_multiplyBy: function (num) {\r\n\t\tthis.x *= num;\r\n\t\tthis.y *= num;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method scaleBy(scale: Point): Point\r\n\t// Multiply each coordinate of the current point by each coordinate of\r\n\t// `scale`. In linear algebra terms, multiply the point by the\r\n\t// [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation)\r\n\t// defined by `scale`.\r\n\tscaleBy: function (point) {\r\n\t\treturn new Point(this.x * point.x, this.y * point.y);\r\n\t},\r\n\r\n\t// @method unscaleBy(scale: Point): Point\r\n\t// Inverse of `scaleBy`. Divide each coordinate of the current point by\r\n\t// each coordinate of `scale`.\r\n\tunscaleBy: function (point) {\r\n\t\treturn new Point(this.x / point.x, this.y / point.y);\r\n\t},\r\n\r\n\t// @method round(): Point\r\n\t// Returns a copy of the current point with rounded coordinates.\r\n\tround: function () {\r\n\t\treturn this.clone()._round();\r\n\t},\r\n\r\n\t_round: function () {\r\n\t\tthis.x = Math.round(this.x);\r\n\t\tthis.y = Math.round(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method floor(): Point\r\n\t// Returns a copy of the current point with floored coordinates (rounded down).\r\n\tfloor: function () {\r\n\t\treturn this.clone()._floor();\r\n\t},\r\n\r\n\t_floor: function () {\r\n\t\tthis.x = Math.floor(this.x);\r\n\t\tthis.y = Math.floor(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method ceil(): Point\r\n\t// Returns a copy of the current point with ceiled coordinates (rounded up).\r\n\tceil: function () {\r\n\t\treturn this.clone()._ceil();\r\n\t},\r\n\r\n\t_ceil: function () {\r\n\t\tthis.x = Math.ceil(this.x);\r\n\t\tthis.y = Math.ceil(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method trunc(): Point\r\n\t// Returns a copy of the current point with truncated coordinates (rounded towards zero).\r\n\ttrunc: function () {\r\n\t\treturn this.clone()._trunc();\r\n\t},\r\n\r\n\t_trunc: function () {\r\n\t\tthis.x = trunc(this.x);\r\n\t\tthis.y = trunc(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method distanceTo(otherPoint: Point): Number\r\n\t// Returns the cartesian distance between the current and the given points.\r\n\tdistanceTo: function (point) {\r\n\t\tpoint = toPoint(point);\r\n\r\n\t\tvar x = point.x - this.x,\r\n\t\t y = point.y - this.y;\r\n\r\n\t\treturn Math.sqrt(x * x + y * y);\r\n\t},\r\n\r\n\t// @method equals(otherPoint: Point): Boolean\r\n\t// Returns `true` if the given point has the same coordinates.\r\n\tequals: function (point) {\r\n\t\tpoint = toPoint(point);\r\n\r\n\t\treturn point.x === this.x &&\r\n\t\t point.y === this.y;\r\n\t},\r\n\r\n\t// @method contains(otherPoint: Point): Boolean\r\n\t// Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).\r\n\tcontains: function (point) {\r\n\t\tpoint = toPoint(point);\r\n\r\n\t\treturn Math.abs(point.x) <= Math.abs(this.x) &&\r\n\t\t Math.abs(point.y) <= Math.abs(this.y);\r\n\t},\r\n\r\n\t// @method toString(): String\r\n\t// Returns a string representation of the point for debugging purposes.\r\n\ttoString: function () {\r\n\t\treturn 'Point(' +\r\n\t\t formatNum(this.x) + ', ' +\r\n\t\t formatNum(this.y) + ')';\r\n\t}\r\n};\r\n\r\n// @factory L.point(x: Number, y: Number, round?: Boolean)\r\n// Creates a Point object with the given `x` and `y` coordinates. If optional `round` is set to true, rounds the `x` and `y` values.\r\n\r\n// @alternative\r\n// @factory L.point(coords: Number[])\r\n// Expects an array of the form `[x, y]` instead.\r\n\r\n// @alternative\r\n// @factory L.point(coords: Object)\r\n// Expects a plain object of the form `{x: Number, y: Number}` instead.\r\nexport function toPoint(x, y, round) {\r\n\tif (x instanceof Point) {\r\n\t\treturn x;\r\n\t}\r\n\tif (isArray(x)) {\r\n\t\treturn new Point(x[0], x[1]);\r\n\t}\r\n\tif (x === undefined || x === null) {\r\n\t\treturn x;\r\n\t}\r\n\tif (typeof x === 'object' && 'x' in x && 'y' in x) {\r\n\t\treturn new Point(x.x, x.y);\r\n\t}\r\n\treturn new Point(x, y, round);\r\n}\r\n","import {Point, toPoint} from './Point';\r\n\r\n/*\r\n * @class Bounds\r\n * @aka L.Bounds\r\n *\r\n * Represents a rectangular area in pixel coordinates.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var p1 = L.point(10, 10),\r\n * p2 = L.point(40, 60),\r\n * bounds = L.bounds(p1, p2);\r\n * ```\r\n *\r\n * All Leaflet methods that accept `Bounds` objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:\r\n *\r\n * ```js\r\n * otherBounds.intersects([[10, 10], [40, 60]]);\r\n * ```\r\n *\r\n * Note that `Bounds` does not inherit from Leaflet's `Class` object,\r\n * which means new classes can't inherit from it, and new methods\r\n * can't be added to it with the `include` function.\r\n */\r\n\r\nexport function Bounds(a, b) {\r\n\tif (!a) { return; }\r\n\r\n\tvar points = b ? [a, b] : a;\r\n\r\n\tfor (var i = 0, len = points.length; i < len; i++) {\r\n\t\tthis.extend(points[i]);\r\n\t}\r\n}\r\n\r\nBounds.prototype = {\r\n\t// @method extend(point: Point): this\r\n\t// Extends the bounds to contain the given point.\r\n\textend: function (point) { // (Point)\r\n\t\tpoint = toPoint(point);\r\n\r\n\t\t// @property min: Point\r\n\t\t// The top left corner of the rectangle.\r\n\t\t// @property max: Point\r\n\t\t// The bottom right corner of the rectangle.\r\n\t\tif (!this.min && !this.max) {\r\n\t\t\tthis.min = point.clone();\r\n\t\t\tthis.max = point.clone();\r\n\t\t} else {\r\n\t\t\tthis.min.x = Math.min(point.x, this.min.x);\r\n\t\t\tthis.max.x = Math.max(point.x, this.max.x);\r\n\t\t\tthis.min.y = Math.min(point.y, this.min.y);\r\n\t\t\tthis.max.y = Math.max(point.y, this.max.y);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method getCenter(round?: Boolean): Point\r\n\t// Returns the center point of the bounds.\r\n\tgetCenter: function (round) {\r\n\t\treturn new Point(\r\n\t\t (this.min.x + this.max.x) / 2,\r\n\t\t (this.min.y + this.max.y) / 2, round);\r\n\t},\r\n\r\n\t// @method getBottomLeft(): Point\r\n\t// Returns the bottom-left point of the bounds.\r\n\tgetBottomLeft: function () {\r\n\t\treturn new Point(this.min.x, this.max.y);\r\n\t},\r\n\r\n\t// @method getTopRight(): Point\r\n\t// Returns the top-right point of the bounds.\r\n\tgetTopRight: function () { // -> Point\r\n\t\treturn new Point(this.max.x, this.min.y);\r\n\t},\r\n\r\n\t// @method getTopLeft(): Point\r\n\t// Returns the top-left point of the bounds (i.e. [`this.min`](#bounds-min)).\r\n\tgetTopLeft: function () {\r\n\t\treturn this.min; // left, top\r\n\t},\r\n\r\n\t// @method getBottomRight(): Point\r\n\t// Returns the bottom-right point of the bounds (i.e. [`this.max`](#bounds-max)).\r\n\tgetBottomRight: function () {\r\n\t\treturn this.max; // right, bottom\r\n\t},\r\n\r\n\t// @method getSize(): Point\r\n\t// Returns the size of the given bounds\r\n\tgetSize: function () {\r\n\t\treturn this.max.subtract(this.min);\r\n\t},\r\n\r\n\t// @method contains(otherBounds: Bounds): Boolean\r\n\t// Returns `true` if the rectangle contains the given one.\r\n\t// @alternative\r\n\t// @method contains(point: Point): Boolean\r\n\t// Returns `true` if the rectangle contains the given point.\r\n\tcontains: function (obj) {\r\n\t\tvar min, max;\r\n\r\n\t\tif (typeof obj[0] === 'number' || obj instanceof Point) {\r\n\t\t\tobj = toPoint(obj);\r\n\t\t} else {\r\n\t\t\tobj = toBounds(obj);\r\n\t\t}\r\n\r\n\t\tif (obj instanceof Bounds) {\r\n\t\t\tmin = obj.min;\r\n\t\t\tmax = obj.max;\r\n\t\t} else {\r\n\t\t\tmin = max = obj;\r\n\t\t}\r\n\r\n\t\treturn (min.x >= this.min.x) &&\r\n\t\t (max.x <= this.max.x) &&\r\n\t\t (min.y >= this.min.y) &&\r\n\t\t (max.y <= this.max.y);\r\n\t},\r\n\r\n\t// @method intersects(otherBounds: Bounds): Boolean\r\n\t// Returns `true` if the rectangle intersects the given bounds. Two bounds\r\n\t// intersect if they have at least one point in common.\r\n\tintersects: function (bounds) { // (Bounds) -> Boolean\r\n\t\tbounds = toBounds(bounds);\r\n\r\n\t\tvar min = this.min,\r\n\t\t max = this.max,\r\n\t\t min2 = bounds.min,\r\n\t\t max2 = bounds.max,\r\n\t\t xIntersects = (max2.x >= min.x) && (min2.x <= max.x),\r\n\t\t yIntersects = (max2.y >= min.y) && (min2.y <= max.y);\r\n\r\n\t\treturn xIntersects && yIntersects;\r\n\t},\r\n\r\n\t// @method overlaps(otherBounds: Bounds): Boolean\r\n\t// Returns `true` if the rectangle overlaps the given bounds. Two bounds\r\n\t// overlap if their intersection is an area.\r\n\toverlaps: function (bounds) { // (Bounds) -> Boolean\r\n\t\tbounds = toBounds(bounds);\r\n\r\n\t\tvar min = this.min,\r\n\t\t max = this.max,\r\n\t\t min2 = bounds.min,\r\n\t\t max2 = bounds.max,\r\n\t\t xOverlaps = (max2.x > min.x) && (min2.x < max.x),\r\n\t\t yOverlaps = (max2.y > min.y) && (min2.y < max.y);\r\n\r\n\t\treturn xOverlaps && yOverlaps;\r\n\t},\r\n\r\n\tisValid: function () {\r\n\t\treturn !!(this.min && this.max);\r\n\t}\r\n};\r\n\r\n\r\n// @factory L.bounds(corner1: Point, corner2: Point)\r\n// Creates a Bounds object from two corners coordinate pairs.\r\n// @alternative\r\n// @factory L.bounds(points: Point[])\r\n// Creates a Bounds object from the given array of points.\r\nexport function toBounds(a, b) {\r\n\tif (!a || a instanceof Bounds) {\r\n\t\treturn a;\r\n\t}\r\n\treturn new Bounds(a, b);\r\n}\r\n","import {LatLng, toLatLng} from './LatLng';\r\n\r\n/*\r\n * @class LatLngBounds\r\n * @aka L.LatLngBounds\r\n *\r\n * Represents a rectangular geographical area on a map.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var corner1 = L.latLng(40.712, -74.227),\r\n * corner2 = L.latLng(40.774, -74.125),\r\n * bounds = L.latLngBounds(corner1, corner2);\r\n * ```\r\n *\r\n * All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:\r\n *\r\n * ```js\r\n * map.fitBounds([\r\n * \t[40.712, -74.227],\r\n * \t[40.774, -74.125]\r\n * ]);\r\n * ```\r\n *\r\n * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.\r\n *\r\n * Note that `LatLngBounds` does not inherit from Leaflet's `Class` object,\r\n * which means new classes can't inherit from it, and new methods\r\n * can't be added to it with the `include` function.\r\n */\r\n\r\nexport function LatLngBounds(corner1, corner2) { // (LatLng, LatLng) or (LatLng[])\r\n\tif (!corner1) { return; }\r\n\r\n\tvar latlngs = corner2 ? [corner1, corner2] : corner1;\r\n\r\n\tfor (var i = 0, len = latlngs.length; i < len; i++) {\r\n\t\tthis.extend(latlngs[i]);\r\n\t}\r\n}\r\n\r\nLatLngBounds.prototype = {\r\n\r\n\t// @method extend(latlng: LatLng): this\r\n\t// Extend the bounds to contain the given point\r\n\r\n\t// @alternative\r\n\t// @method extend(otherBounds: LatLngBounds): this\r\n\t// Extend the bounds to contain the given bounds\r\n\textend: function (obj) {\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2, ne2;\r\n\r\n\t\tif (obj instanceof LatLng) {\r\n\t\t\tsw2 = obj;\r\n\t\t\tne2 = obj;\r\n\r\n\t\t} else if (obj instanceof LatLngBounds) {\r\n\t\t\tsw2 = obj._southWest;\r\n\t\t\tne2 = obj._northEast;\r\n\r\n\t\t\tif (!sw2 || !ne2) { return this; }\r\n\r\n\t\t} else {\r\n\t\t\treturn obj ? this.extend(toLatLng(obj) || toLatLngBounds(obj)) : this;\r\n\t\t}\r\n\r\n\t\tif (!sw && !ne) {\r\n\t\t\tthis._southWest = new LatLng(sw2.lat, sw2.lng);\r\n\t\t\tthis._northEast = new LatLng(ne2.lat, ne2.lng);\r\n\t\t} else {\r\n\t\t\tsw.lat = Math.min(sw2.lat, sw.lat);\r\n\t\t\tsw.lng = Math.min(sw2.lng, sw.lng);\r\n\t\t\tne.lat = Math.max(ne2.lat, ne.lat);\r\n\t\t\tne.lng = Math.max(ne2.lng, ne.lng);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method pad(bufferRatio: Number): LatLngBounds\r\n\t// Returns bounds created by extending or retracting the current bounds by a given ratio in each direction.\r\n\t// For example, a ratio of 0.5 extends the bounds by 50% in each direction.\r\n\t// Negative values will retract the bounds.\r\n\tpad: function (bufferRatio) {\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,\r\n\t\t widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;\r\n\r\n\t\treturn new LatLngBounds(\r\n\t\t new LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),\r\n\t\t new LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));\r\n\t},\r\n\r\n\t// @method getCenter(): LatLng\r\n\t// Returns the center point of the bounds.\r\n\tgetCenter: function () {\r\n\t\treturn new LatLng(\r\n\t\t (this._southWest.lat + this._northEast.lat) / 2,\r\n\t\t (this._southWest.lng + this._northEast.lng) / 2);\r\n\t},\r\n\r\n\t// @method getSouthWest(): LatLng\r\n\t// Returns the south-west point of the bounds.\r\n\tgetSouthWest: function () {\r\n\t\treturn this._southWest;\r\n\t},\r\n\r\n\t// @method getNorthEast(): LatLng\r\n\t// Returns the north-east point of the bounds.\r\n\tgetNorthEast: function () {\r\n\t\treturn this._northEast;\r\n\t},\r\n\r\n\t// @method getNorthWest(): LatLng\r\n\t// Returns the north-west point of the bounds.\r\n\tgetNorthWest: function () {\r\n\t\treturn new LatLng(this.getNorth(), this.getWest());\r\n\t},\r\n\r\n\t// @method getSouthEast(): LatLng\r\n\t// Returns the south-east point of the bounds.\r\n\tgetSouthEast: function () {\r\n\t\treturn new LatLng(this.getSouth(), this.getEast());\r\n\t},\r\n\r\n\t// @method getWest(): Number\r\n\t// Returns the west longitude of the bounds\r\n\tgetWest: function () {\r\n\t\treturn this._southWest.lng;\r\n\t},\r\n\r\n\t// @method getSouth(): Number\r\n\t// Returns the south latitude of the bounds\r\n\tgetSouth: function () {\r\n\t\treturn this._southWest.lat;\r\n\t},\r\n\r\n\t// @method getEast(): Number\r\n\t// Returns the east longitude of the bounds\r\n\tgetEast: function () {\r\n\t\treturn this._northEast.lng;\r\n\t},\r\n\r\n\t// @method getNorth(): Number\r\n\t// Returns the north latitude of the bounds\r\n\tgetNorth: function () {\r\n\t\treturn this._northEast.lat;\r\n\t},\r\n\r\n\t// @method contains(otherBounds: LatLngBounds): Boolean\r\n\t// Returns `true` if the rectangle contains the given one.\r\n\r\n\t// @alternative\r\n\t// @method contains (latlng: LatLng): Boolean\r\n\t// Returns `true` if the rectangle contains the given point.\r\n\tcontains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean\r\n\t\tif (typeof obj[0] === 'number' || obj instanceof LatLng || 'lat' in obj) {\r\n\t\t\tobj = toLatLng(obj);\r\n\t\t} else {\r\n\t\t\tobj = toLatLngBounds(obj);\r\n\t\t}\r\n\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2, ne2;\r\n\r\n\t\tif (obj instanceof LatLngBounds) {\r\n\t\t\tsw2 = obj.getSouthWest();\r\n\t\t\tne2 = obj.getNorthEast();\r\n\t\t} else {\r\n\t\t\tsw2 = ne2 = obj;\r\n\t\t}\r\n\r\n\t\treturn (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&\r\n\t\t (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);\r\n\t},\r\n\r\n\t// @method intersects(otherBounds: LatLngBounds): Boolean\r\n\t// Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.\r\n\tintersects: function (bounds) {\r\n\t\tbounds = toLatLngBounds(bounds);\r\n\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2 = bounds.getSouthWest(),\r\n\t\t ne2 = bounds.getNorthEast(),\r\n\r\n\t\t latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),\r\n\t\t lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);\r\n\r\n\t\treturn latIntersects && lngIntersects;\r\n\t},\r\n\r\n\t// @method overlaps(otherBounds: LatLngBounds): Boolean\r\n\t// Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.\r\n\toverlaps: function (bounds) {\r\n\t\tbounds = toLatLngBounds(bounds);\r\n\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2 = bounds.getSouthWest(),\r\n\t\t ne2 = bounds.getNorthEast(),\r\n\r\n\t\t latOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),\r\n\t\t lngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);\r\n\r\n\t\treturn latOverlaps && lngOverlaps;\r\n\t},\r\n\r\n\t// @method toBBoxString(): String\r\n\t// Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.\r\n\ttoBBoxString: function () {\r\n\t\treturn [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\r\n\t},\r\n\r\n\t// @method equals(otherBounds: LatLngBounds, maxMargin?: Number): Boolean\r\n\t// Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting `maxMargin` to a small number.\r\n\tequals: function (bounds, maxMargin) {\r\n\t\tif (!bounds) { return false; }\r\n\r\n\t\tbounds = toLatLngBounds(bounds);\r\n\r\n\t\treturn this._southWest.equals(bounds.getSouthWest(), maxMargin) &&\r\n\t\t this._northEast.equals(bounds.getNorthEast(), maxMargin);\r\n\t},\r\n\r\n\t// @method isValid(): Boolean\r\n\t// Returns `true` if the bounds are properly initialized.\r\n\tisValid: function () {\r\n\t\treturn !!(this._southWest && this._northEast);\r\n\t}\r\n};\r\n\r\n// TODO International date line?\r\n\r\n// @factory L.latLngBounds(corner1: LatLng, corner2: LatLng)\r\n// Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle.\r\n\r\n// @alternative\r\n// @factory L.latLngBounds(latlngs: LatLng[])\r\n// Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds).\r\nexport function toLatLngBounds(a, b) {\r\n\tif (a instanceof LatLngBounds) {\r\n\t\treturn a;\r\n\t}\r\n\treturn new LatLngBounds(a, b);\r\n}\r\n","import * as Util from '../core/Util';\r\nimport {Earth} from './crs/CRS.Earth';\r\nimport {toLatLngBounds} from './LatLngBounds';\r\n\r\n/* @class LatLng\r\n * @aka L.LatLng\r\n *\r\n * Represents a geographical point with a certain latitude and longitude.\r\n *\r\n * @example\r\n *\r\n * ```\r\n * var latlng = L.latLng(50.5, 30.5);\r\n * ```\r\n *\r\n * All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent:\r\n *\r\n * ```\r\n * map.panTo([50, 30]);\r\n * map.panTo({lon: 30, lat: 50});\r\n * map.panTo({lat: 50, lng: 30});\r\n * map.panTo(L.latLng(50, 30));\r\n * ```\r\n *\r\n * Note that `LatLng` does not inherit from Leaflet's `Class` object,\r\n * which means new classes can't inherit from it, and new methods\r\n * can't be added to it with the `include` function.\r\n */\r\n\r\nexport function LatLng(lat, lng, alt) {\r\n\tif (isNaN(lat) || isNaN(lng)) {\r\n\t\tthrow new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');\r\n\t}\r\n\r\n\t// @property lat: Number\r\n\t// Latitude in degrees\r\n\tthis.lat = +lat;\r\n\r\n\t// @property lng: Number\r\n\t// Longitude in degrees\r\n\tthis.lng = +lng;\r\n\r\n\t// @property alt: Number\r\n\t// Altitude in meters (optional)\r\n\tif (alt !== undefined) {\r\n\t\tthis.alt = +alt;\r\n\t}\r\n}\r\n\r\nLatLng.prototype = {\r\n\t// @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean\r\n\t// Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overridden by setting `maxMargin` to a small number.\r\n\tequals: function (obj, maxMargin) {\r\n\t\tif (!obj) { return false; }\r\n\r\n\t\tobj = toLatLng(obj);\r\n\r\n\t\tvar margin = Math.max(\r\n\t\t Math.abs(this.lat - obj.lat),\r\n\t\t Math.abs(this.lng - obj.lng));\r\n\r\n\t\treturn margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin);\r\n\t},\r\n\r\n\t// @method toString(): String\r\n\t// Returns a string representation of the point (for debugging purposes).\r\n\ttoString: function (precision) {\r\n\t\treturn 'LatLng(' +\r\n\t\t Util.formatNum(this.lat, precision) + ', ' +\r\n\t\t Util.formatNum(this.lng, precision) + ')';\r\n\t},\r\n\r\n\t// @method distanceTo(otherLatLng: LatLng): Number\r\n\t// Returns the distance (in meters) to the given `LatLng` calculated using the [Spherical Law of Cosines](https://en.wikipedia.org/wiki/Spherical_law_of_cosines).\r\n\tdistanceTo: function (other) {\r\n\t\treturn Earth.distance(this, toLatLng(other));\r\n\t},\r\n\r\n\t// @method wrap(): LatLng\r\n\t// Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees.\r\n\twrap: function () {\r\n\t\treturn Earth.wrapLatLng(this);\r\n\t},\r\n\r\n\t// @method toBounds(sizeInMeters: Number): LatLngBounds\r\n\t// Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2` meters apart from the `LatLng`.\r\n\ttoBounds: function (sizeInMeters) {\r\n\t\tvar latAccuracy = 180 * sizeInMeters / 40075017,\r\n\t\t lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);\r\n\r\n\t\treturn toLatLngBounds(\r\n\t\t [this.lat - latAccuracy, this.lng - lngAccuracy],\r\n\t\t [this.lat + latAccuracy, this.lng + lngAccuracy]);\r\n\t},\r\n\r\n\tclone: function () {\r\n\t\treturn new LatLng(this.lat, this.lng, this.alt);\r\n\t}\r\n};\r\n\r\n\r\n\r\n// @factory L.latLng(latitude: Number, longitude: Number, altitude?: Number): LatLng\r\n// Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude).\r\n\r\n// @alternative\r\n// @factory L.latLng(coords: Array): LatLng\r\n// Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead.\r\n\r\n// @alternative\r\n// @factory L.latLng(coords: Object): LatLng\r\n// Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead.\r\n\r\nexport function toLatLng(a, b, c) {\r\n\tif (a instanceof LatLng) {\r\n\t\treturn a;\r\n\t}\r\n\tif (Util.isArray(a) && typeof a[0] !== 'object') {\r\n\t\tif (a.length === 3) {\r\n\t\t\treturn new LatLng(a[0], a[1], a[2]);\r\n\t\t}\r\n\t\tif (a.length === 2) {\r\n\t\t\treturn new LatLng(a[0], a[1]);\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\tif (a === undefined || a === null) {\r\n\t\treturn a;\r\n\t}\r\n\tif (typeof a === 'object' && 'lat' in a) {\r\n\t\treturn new LatLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt);\r\n\t}\r\n\tif (b === undefined) {\r\n\t\treturn null;\r\n\t}\r\n\treturn new LatLng(a, b, c);\r\n}\r\n","\r\nimport {Bounds} from '../../geometry/Bounds';\r\nimport {LatLng} from '../LatLng';\r\nimport {LatLngBounds} from '../LatLngBounds';\r\nimport * as Util from '../../core/Util';\r\n\r\n/*\r\n * @namespace CRS\r\n * @crs L.CRS.Base\r\n * Object that defines coordinate reference systems for projecting\r\n * geographical points into pixel (screen) coordinates and back (and to\r\n * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See\r\n * [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system).\r\n *\r\n * Leaflet defines the most usual CRSs by default. If you want to use a\r\n * CRS not defined by default, take a look at the\r\n * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) plugin.\r\n *\r\n * Note that the CRS instances do not inherit from Leaflet's `Class` object,\r\n * and can't be instantiated. Also, new classes can't inherit from them,\r\n * and methods can't be added to them with the `include` function.\r\n */\r\n\r\nexport var CRS = {\r\n\t// @method latLngToPoint(latlng: LatLng, zoom: Number): Point\r\n\t// Projects geographical coordinates into pixel coordinates for a given zoom.\r\n\tlatLngToPoint: function (latlng, zoom) {\r\n\t\tvar projectedPoint = this.projection.project(latlng),\r\n\t\t scale = this.scale(zoom);\r\n\r\n\t\treturn this.transformation._transform(projectedPoint, scale);\r\n\t},\r\n\r\n\t// @method pointToLatLng(point: Point, zoom: Number): LatLng\r\n\t// The inverse of `latLngToPoint`. Projects pixel coordinates on a given\r\n\t// zoom into geographical coordinates.\r\n\tpointToLatLng: function (point, zoom) {\r\n\t\tvar scale = this.scale(zoom),\r\n\t\t untransformedPoint = this.transformation.untransform(point, scale);\r\n\r\n\t\treturn this.projection.unproject(untransformedPoint);\r\n\t},\r\n\r\n\t// @method project(latlng: LatLng): Point\r\n\t// Projects geographical coordinates into coordinates in units accepted for\r\n\t// this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).\r\n\tproject: function (latlng) {\r\n\t\treturn this.projection.project(latlng);\r\n\t},\r\n\r\n\t// @method unproject(point: Point): LatLng\r\n\t// Given a projected coordinate returns the corresponding LatLng.\r\n\t// The inverse of `project`.\r\n\tunproject: function (point) {\r\n\t\treturn this.projection.unproject(point);\r\n\t},\r\n\r\n\t// @method scale(zoom: Number): Number\r\n\t// Returns the scale used when transforming projected coordinates into\r\n\t// pixel coordinates for a particular zoom. For example, it returns\r\n\t// `256 * 2^zoom` for Mercator-based CRS.\r\n\tscale: function (zoom) {\r\n\t\treturn 256 * Math.pow(2, zoom);\r\n\t},\r\n\r\n\t// @method zoom(scale: Number): Number\r\n\t// Inverse of `scale()`, returns the zoom level corresponding to a scale\r\n\t// factor of `scale`.\r\n\tzoom: function (scale) {\r\n\t\treturn Math.log(scale / 256) / Math.LN2;\r\n\t},\r\n\r\n\t// @method getProjectedBounds(zoom: Number): Bounds\r\n\t// Returns the projection's bounds scaled and transformed for the provided `zoom`.\r\n\tgetProjectedBounds: function (zoom) {\r\n\t\tif (this.infinite) { return null; }\r\n\r\n\t\tvar b = this.projection.bounds,\r\n\t\t s = this.scale(zoom),\r\n\t\t min = this.transformation.transform(b.min, s),\r\n\t\t max = this.transformation.transform(b.max, s);\r\n\r\n\t\treturn new Bounds(min, max);\r\n\t},\r\n\r\n\t// @method distance(latlng1: LatLng, latlng2: LatLng): Number\r\n\t// Returns the distance between two geographical coordinates.\r\n\r\n\t// @property code: String\r\n\t// Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`)\r\n\t//\r\n\t// @property wrapLng: Number[]\r\n\t// An array of two numbers defining whether the longitude (horizontal) coordinate\r\n\t// axis wraps around a given range and how. Defaults to `[-180, 180]` in most\r\n\t// geographical CRSs. If `undefined`, the longitude axis does not wrap around.\r\n\t//\r\n\t// @property wrapLat: Number[]\r\n\t// Like `wrapLng`, but for the latitude (vertical) axis.\r\n\r\n\t// wrapLng: [min, max],\r\n\t// wrapLat: [min, max],\r\n\r\n\t// @property infinite: Boolean\r\n\t// If true, the coordinate space will be unbounded (infinite in both axes)\r\n\tinfinite: false,\r\n\r\n\t// @method wrapLatLng(latlng: LatLng): LatLng\r\n\t// Returns a `LatLng` where lat and lng has been wrapped according to the\r\n\t// CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds.\r\n\twrapLatLng: function (latlng) {\r\n\t\tvar lng = this.wrapLng ? Util.wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng,\r\n\t\t lat = this.wrapLat ? Util.wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat,\r\n\t\t alt = latlng.alt;\r\n\r\n\t\treturn new LatLng(lat, lng, alt);\r\n\t},\r\n\r\n\t// @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds\r\n\t// Returns a `LatLngBounds` with the same size as the given one, ensuring\r\n\t// that its center is within the CRS's bounds.\r\n\t// Only accepts actual `L.LatLngBounds` instances, not arrays.\r\n\twrapLatLngBounds: function (bounds) {\r\n\t\tvar center = bounds.getCenter(),\r\n\t\t newCenter = this.wrapLatLng(center),\r\n\t\t latShift = center.lat - newCenter.lat,\r\n\t\t lngShift = center.lng - newCenter.lng;\r\n\r\n\t\tif (latShift === 0 && lngShift === 0) {\r\n\t\t\treturn bounds;\r\n\t\t}\r\n\r\n\t\tvar sw = bounds.getSouthWest(),\r\n\t\t ne = bounds.getNorthEast(),\r\n\t\t newSw = new LatLng(sw.lat - latShift, sw.lng - lngShift),\r\n\t\t newNe = new LatLng(ne.lat - latShift, ne.lng - lngShift);\r\n\r\n\t\treturn new LatLngBounds(newSw, newNe);\r\n\t}\r\n};\r\n","import {CRS} from './CRS';\nimport * as Util from '../../core/Util';\n\n/*\n * @namespace CRS\n * @crs L.CRS.Earth\n *\n * Serves as the base for CRS that are global such that they cover the earth.\n * Can only be used as the base for other CRS and cannot be used directly,\n * since it does not have a `code`, `projection` or `transformation`. `distance()` returns\n * meters.\n */\n\nexport var Earth = Util.extend({}, CRS, {\n\twrapLng: [-180, 180],\n\n\t// Mean Earth Radius, as recommended for use by\n\t// the International Union of Geodesy and Geophysics,\n\t// see https://rosettacode.org/wiki/Haversine_formula\n\tR: 6371000,\n\n\t// distance between two geographical points using spherical law of cosines approximation\n\tdistance: function (latlng1, latlng2) {\n\t\tvar rad = Math.PI / 180,\n\t\t lat1 = latlng1.lat * rad,\n\t\t lat2 = latlng2.lat * rad,\n\t\t sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2),\n\t\t sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2),\n\t\t a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon,\n\t\t c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\t\treturn this.R * c;\n\t}\n});\n","import {LatLng} from '../LatLng';\r\nimport {Bounds} from '../../geometry/Bounds';\r\nimport {Point} from '../../geometry/Point';\r\n\r\n/*\r\n * @namespace Projection\r\n * @projection L.Projection.SphericalMercator\r\n *\r\n * Spherical Mercator projection — the most common projection for online maps,\r\n * used by almost all free and commercial tile providers. Assumes that Earth is\r\n * a sphere. Used by the `EPSG:3857` CRS.\r\n */\r\n\r\nvar earthRadius = 6378137;\r\n\r\nexport var SphericalMercator = {\r\n\r\n\tR: earthRadius,\r\n\tMAX_LATITUDE: 85.0511287798,\r\n\r\n\tproject: function (latlng) {\r\n\t\tvar d = Math.PI / 180,\r\n\t\t max = this.MAX_LATITUDE,\r\n\t\t lat = Math.max(Math.min(max, latlng.lat), -max),\r\n\t\t sin = Math.sin(lat * d);\r\n\r\n\t\treturn new Point(\r\n\t\t\tthis.R * latlng.lng * d,\r\n\t\t\tthis.R * Math.log((1 + sin) / (1 - sin)) / 2);\r\n\t},\r\n\r\n\tunproject: function (point) {\r\n\t\tvar d = 180 / Math.PI;\r\n\r\n\t\treturn new LatLng(\r\n\t\t\t(2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d,\r\n\t\t\tpoint.x * d / this.R);\r\n\t},\r\n\r\n\tbounds: (function () {\r\n\t\tvar d = earthRadius * Math.PI;\r\n\t\treturn new Bounds([-d, -d], [d, d]);\r\n\t})()\r\n};\r\n","import {Point} from './Point';\r\nimport * as Util from '../core/Util';\r\n\r\n/*\r\n * @class Transformation\r\n * @aka L.Transformation\r\n *\r\n * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d`\r\n * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing\r\n * the reverse. Used by Leaflet in its projections code.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var transformation = L.transformation(2, 5, -1, 10),\r\n * \tp = L.point(1, 2),\r\n * \tp2 = transformation.transform(p), // L.point(7, 8)\r\n * \tp3 = transformation.untransform(p2); // L.point(1, 2)\r\n * ```\r\n */\r\n\r\n\r\n// factory new L.Transformation(a: Number, b: Number, c: Number, d: Number)\r\n// Creates a `Transformation` object with the given coefficients.\r\nexport function Transformation(a, b, c, d) {\r\n\tif (Util.isArray(a)) {\r\n\t\t// use array properties\r\n\t\tthis._a = a[0];\r\n\t\tthis._b = a[1];\r\n\t\tthis._c = a[2];\r\n\t\tthis._d = a[3];\r\n\t\treturn;\r\n\t}\r\n\tthis._a = a;\r\n\tthis._b = b;\r\n\tthis._c = c;\r\n\tthis._d = d;\r\n}\r\n\r\nTransformation.prototype = {\r\n\t// @method transform(point: Point, scale?: Number): Point\r\n\t// Returns a transformed point, optionally multiplied by the given scale.\r\n\t// Only accepts actual `L.Point` instances, not arrays.\r\n\ttransform: function (point, scale) { // (Point, Number) -> Point\r\n\t\treturn this._transform(point.clone(), scale);\r\n\t},\r\n\r\n\t// destructive transform (faster)\r\n\t_transform: function (point, scale) {\r\n\t\tscale = scale || 1;\r\n\t\tpoint.x = scale * (this._a * point.x + this._b);\r\n\t\tpoint.y = scale * (this._c * point.y + this._d);\r\n\t\treturn point;\r\n\t},\r\n\r\n\t// @method untransform(point: Point, scale?: Number): Point\r\n\t// Returns the reverse transformation of the given point, optionally divided\r\n\t// by the given scale. Only accepts actual `L.Point` instances, not arrays.\r\n\tuntransform: function (point, scale) {\r\n\t\tscale = scale || 1;\r\n\t\treturn new Point(\r\n\t\t (point.x / scale - this._b) / this._a,\r\n\t\t (point.y / scale - this._d) / this._c);\r\n\t}\r\n};\r\n\r\n// factory L.transformation(a: Number, b: Number, c: Number, d: Number)\r\n\r\n// @factory L.transformation(a: Number, b: Number, c: Number, d: Number)\r\n// Instantiates a Transformation object with the given coefficients.\r\n\r\n// @alternative\r\n// @factory L.transformation(coefficients: Array): Transformation\r\n// Expects an coefficients array of the form\r\n// `[a: Number, b: Number, c: Number, d: Number]`.\r\n\r\nexport function toTransformation(a, b, c, d) {\r\n\treturn new Transformation(a, b, c, d);\r\n}\r\n","import {Earth} from './CRS.Earth';\r\nimport {SphericalMercator} from '../projection/Projection.SphericalMercator';\r\nimport {toTransformation} from '../../geometry/Transformation';\r\nimport * as Util from '../../core/Util';\r\n\r\n/*\r\n * @namespace CRS\r\n * @crs L.CRS.EPSG3857\r\n *\r\n * The most common CRS for online maps, used by almost all free and commercial\r\n * tile providers. Uses Spherical Mercator projection. Set in by default in\r\n * Map's `crs` option.\r\n */\r\n\r\nexport var EPSG3857 = Util.extend({}, Earth, {\r\n\tcode: 'EPSG:3857',\r\n\tprojection: SphericalMercator,\r\n\r\n\ttransformation: (function () {\r\n\t\tvar scale = 0.5 / (Math.PI * SphericalMercator.R);\r\n\t\treturn toTransformation(scale, 0.5, -scale, 0.5);\r\n\t}())\r\n});\r\n\r\nexport var EPSG900913 = Util.extend({}, EPSG3857, {\r\n\tcode: 'EPSG:900913'\r\n});\r\n","import Browser from '../../core/Browser';\n\n// @namespace SVG; @section\n// There are several static functions which can be called without instantiating L.SVG:\n\n// @function create(name: String): SVGElement\n// Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement),\n// corresponding to the class name passed. For example, using 'line' will return\n// an instance of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement).\nexport function svgCreate(name) {\n\treturn document.createElementNS('http://www.w3.org/2000/svg', name);\n}\n\n// @function pointsToPath(rings: Point[], closed: Boolean): String\n// Generates a SVG path string for multiple rings, with each ring turning\n// into \"M..L..L..\" instructions\nexport function pointsToPath(rings, closed) {\n\tvar str = '',\n\ti, j, len, len2, points, p;\n\n\tfor (i = 0, len = rings.length; i < len; i++) {\n\t\tpoints = rings[i];\n\n\t\tfor (j = 0, len2 = points.length; j < len2; j++) {\n\t\t\tp = points[j];\n\t\t\tstr += (j ? 'L' : 'M') + p.x + ' ' + p.y;\n\t\t}\n\n\t\t// closes the ring for polygons; \"x\" is VML syntax\n\t\tstr += closed ? (Browser.svg ? 'z' : 'x') : '';\n\t}\n\n\t// SVG complains about empty path strings\n\treturn str || 'M0 0';\n}\n\n\n\n\n","import * as Util from './Util';\r\nimport {svgCreate} from '../layer/vector/SVG.Util';\r\n\r\n/*\r\n * @namespace Browser\r\n * @aka L.Browser\r\n *\r\n * A namespace with static properties for browser/feature detection used by Leaflet internally.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * if (L.Browser.ielt9) {\r\n * alert('Upgrade your browser, dude!');\r\n * }\r\n * ```\r\n */\r\n\r\nvar style = document.documentElement.style;\r\n\r\n// @property ie: Boolean; `true` for all Internet Explorer versions (not Edge).\r\nvar ie = 'ActiveXObject' in window;\r\n\r\n// @property ielt9: Boolean; `true` for Internet Explorer versions less than 9.\r\nvar ielt9 = ie && !document.addEventListener;\r\n\r\n// @property edge: Boolean; `true` for the Edge web browser.\r\nvar edge = 'msLaunchUri' in navigator && !('documentMode' in document);\r\n\r\n// @property webkit: Boolean;\r\n// `true` for webkit-based browsers like Chrome and Safari (including mobile versions).\r\nvar webkit = userAgentContains('webkit');\r\n\r\n// @property android: Boolean\r\n// **Deprecated.** `true` for any browser running on an Android platform.\r\nvar android = userAgentContains('android');\r\n\r\n// @property android23: Boolean; **Deprecated.** `true` for browsers running on Android 2 or Android 3.\r\nvar android23 = userAgentContains('android 2') || userAgentContains('android 3');\r\n\r\n/* See https://stackoverflow.com/a/17961266 for details on detecting stock Android */\r\nvar webkitVer = parseInt(/WebKit\\/([0-9]+)|$/.exec(navigator.userAgent)[1], 10); // also matches AppleWebKit\r\n// @property androidStock: Boolean; **Deprecated.** `true` for the Android stock browser (i.e. not Chrome)\r\nvar androidStock = android && userAgentContains('Google') && webkitVer < 537 && !('AudioNode' in window);\r\n\r\n// @property opera: Boolean; `true` for the Opera browser\r\nvar opera = !!window.opera;\r\n\r\n// @property chrome: Boolean; `true` for the Chrome browser.\r\nvar chrome = !edge && userAgentContains('chrome');\r\n\r\n// @property gecko: Boolean; `true` for gecko-based browsers like Firefox.\r\nvar gecko = userAgentContains('gecko') && !webkit && !opera && !ie;\r\n\r\n// @property safari: Boolean; `true` for the Safari browser.\r\nvar safari = !chrome && userAgentContains('safari');\r\n\r\nvar phantom = userAgentContains('phantom');\r\n\r\n// @property opera12: Boolean\r\n// `true` for the Opera browser supporting CSS transforms (version 12 or later).\r\nvar opera12 = 'OTransition' in style;\r\n\r\n// @property win: Boolean; `true` when the browser is running in a Windows platform\r\nvar win = navigator.platform.indexOf('Win') === 0;\r\n\r\n// @property ie3d: Boolean; `true` for all Internet Explorer versions supporting CSS transforms.\r\nvar ie3d = ie && ('transition' in style);\r\n\r\n// @property webkit3d: Boolean; `true` for webkit-based browsers supporting CSS transforms.\r\nvar webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23;\r\n\r\n// @property gecko3d: Boolean; `true` for gecko-based browsers supporting CSS transforms.\r\nvar gecko3d = 'MozPerspective' in style;\r\n\r\n// @property any3d: Boolean\r\n// `true` for all browsers supporting CSS transforms.\r\nvar any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantom;\r\n\r\n// @property mobile: Boolean; `true` for all browsers running in a mobile device.\r\nvar mobile = typeof orientation !== 'undefined' || userAgentContains('mobile');\r\n\r\n// @property mobileWebkit: Boolean; `true` for all webkit-based browsers in a mobile device.\r\nvar mobileWebkit = mobile && webkit;\r\n\r\n// @property mobileWebkit3d: Boolean\r\n// `true` for all webkit-based browsers in a mobile device supporting CSS transforms.\r\nvar mobileWebkit3d = mobile && webkit3d;\r\n\r\n// @property msPointer: Boolean\r\n// `true` for browsers implementing the Microsoft touch events model (notably IE10).\r\nvar msPointer = !window.PointerEvent && window.MSPointerEvent;\r\n\r\n// @property pointer: Boolean\r\n// `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx).\r\nvar pointer = !!(window.PointerEvent || msPointer);\r\n\r\n// @property touchNative: Boolean\r\n// `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events).\r\n// **This does not necessarily mean** that the browser is running in a computer with\r\n// a touchscreen, it only means that the browser is capable of understanding\r\n// touch events.\r\nvar touchNative = 'ontouchstart' in window || !!window.TouchEvent;\r\n\r\n// @property touch: Boolean\r\n// `true` for all browsers supporting either [touch](#browser-touch) or [pointer](#browser-pointer) events.\r\n// Note: pointer events will be preferred (if available), and processed for all `touch*` listeners.\r\nvar touch = !window.L_NO_TOUCH && (touchNative || pointer);\r\n\r\n// @property mobileOpera: Boolean; `true` for the Opera browser in a mobile device.\r\nvar mobileOpera = mobile && opera;\r\n\r\n// @property mobileGecko: Boolean\r\n// `true` for gecko-based browsers running in a mobile device.\r\nvar mobileGecko = mobile && gecko;\r\n\r\n// @property retina: Boolean\r\n// `true` for browsers on a high-resolution \"retina\" screen or on any screen when browser's display zoom is more than 100%.\r\nvar retina = (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1;\r\n\r\n// @property passiveEvents: Boolean\r\n// `true` for browsers that support passive events.\r\nvar passiveEvents = (function () {\r\n\tvar supportsPassiveOption = false;\r\n\ttry {\r\n\t\tvar opts = Object.defineProperty({}, 'passive', {\r\n\t\t\tget: function () { // eslint-disable-line getter-return\r\n\t\t\t\tsupportsPassiveOption = true;\r\n\t\t\t}\r\n\t\t});\r\n\t\twindow.addEventListener('testPassiveEventSupport', Util.falseFn, opts);\r\n\t\twindow.removeEventListener('testPassiveEventSupport', Util.falseFn, opts);\r\n\t} catch (e) {\r\n\t\t// Errors can safely be ignored since this is only a browser support test.\r\n\t}\r\n\treturn supportsPassiveOption;\r\n}());\r\n\r\n// @property canvas: Boolean\r\n// `true` when the browser supports [`