diff --git a/assets/index.697723cd.css b/assets/index.62a125ed.css similarity index 74% rename from assets/index.697723cd.css rename to assets/index.62a125ed.css index d6d2953..0ef3e4d 100644 --- a/assets/index.697723cd.css +++ b/assets/index.62a125ed.css @@ -1 +1 @@ -.notify{font-size:20px!important;font-weight:700}.leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-pane>svg,.leaflet-pane>canvas,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer{position:absolute;left:0;top:0}.leaflet-container{overflow:hidden}.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow{-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-user-drag:none}.leaflet-tile::selection{background:transparent}.leaflet-safari .leaflet-tile{image-rendering:-webkit-optimize-contrast}.leaflet-safari .leaflet-tile-container{width:1600px;height:1600px;-webkit-transform-origin:0 0}.leaflet-marker-icon,.leaflet-marker-shadow{display:block}.leaflet-container .leaflet-overlay-pane svg{max-width:none!important;max-height:none!important}.leaflet-container .leaflet-marker-pane img,.leaflet-container .leaflet-shadow-pane img,.leaflet-container .leaflet-tile-pane img,.leaflet-container img.leaflet-image-layer,.leaflet-container .leaflet-tile{max-width:none!important;max-height:none!important;width:auto;padding:0}.leaflet-container.leaflet-touch-zoom{-ms-touch-action:pan-x pan-y;touch-action:pan-x pan-y}.leaflet-container.leaflet-touch-drag{-ms-touch-action:pinch-zoom;touch-action:none;touch-action:pinch-zoom}.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom{-ms-touch-action:none;touch-action:none}.leaflet-container{-webkit-tap-highlight-color:transparent}.leaflet-container a{-webkit-tap-highlight-color:rgba(51,181,229,.4)}.leaflet-tile{filter:inherit;visibility:hidden}.leaflet-tile-loaded{visibility:inherit}.leaflet-zoom-box{width:0;height:0;-moz-box-sizing:border-box;box-sizing:border-box;z-index:800}.leaflet-overlay-pane svg{-moz-user-select:none}.leaflet-pane{z-index:400}.leaflet-tile-pane{z-index:200}.leaflet-overlay-pane{z-index:400}.leaflet-shadow-pane{z-index:500}.leaflet-marker-pane{z-index:600}.leaflet-tooltip-pane{z-index:650}.leaflet-popup-pane{z-index:700}.leaflet-map-pane canvas{z-index:100}.leaflet-map-pane svg{z-index:200}.leaflet-vml-shape{width:1px;height:1px}.lvml{behavior:url(#default#VML);display:inline-block;position:absolute}.leaflet-control{position:relative;z-index:800;pointer-events:visiblePainted;pointer-events:auto}.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}.leaflet-control{float:left;clear:both}.leaflet-right .leaflet-control{float:right}.leaflet-top .leaflet-control{margin-top:10px}.leaflet-bottom .leaflet-control{margin-bottom:10px}.leaflet-left .leaflet-control{margin-left:10px}.leaflet-right .leaflet-control{margin-right:10px}.leaflet-fade-anim .leaflet-popup{opacity:0;-webkit-transition:opacity .2s linear;-moz-transition:opacity .2s linear;transition:opacity .2s linear}.leaflet-fade-anim .leaflet-map-pane .leaflet-popup{opacity:1}.leaflet-zoom-animated{-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0}svg.leaflet-zoom-animated{will-change:transform}.leaflet-zoom-anim .leaflet-zoom-animated{-webkit-transition:-webkit-transform .25s cubic-bezier(0,0,.25,1);-moz-transition:-moz-transform .25s cubic-bezier(0,0,.25,1);transition:transform .25s cubic-bezier(0,0,.25,1)}.leaflet-zoom-anim .leaflet-tile,.leaflet-pan-anim .leaflet-tile{-webkit-transition:none;-moz-transition:none;transition:none}.leaflet-zoom-anim .leaflet-zoom-hide{visibility:hidden}.leaflet-interactive{cursor:pointer}.leaflet-grab{cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.leaflet-crosshair,.leaflet-crosshair .leaflet-interactive{cursor:crosshair}.leaflet-popup-pane,.leaflet-control{cursor:auto}.leaflet-dragging .leaflet-grab,.leaflet-dragging .leaflet-grab .leaflet-interactive,.leaflet-dragging .leaflet-marker-draggable{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-image-layer,.leaflet-pane>svg path,.leaflet-tile-container{pointer-events:none}.leaflet-marker-icon.leaflet-interactive,.leaflet-image-layer.leaflet-interactive,.leaflet-pane>svg path.leaflet-interactive,svg.leaflet-image-layer.leaflet-interactive path{pointer-events:visiblePainted;pointer-events:auto}.leaflet-container{background:#ddd;outline-offset:1px}.leaflet-container a{color:#0078a8}.leaflet-zoom-box{border:2px dotted #38f;background:rgba(255,255,255,.5)}.leaflet-container{font-family:Helvetica Neue,Arial,Helvetica,sans-serif;font-size:12px;font-size:.75rem;line-height:1.5}.leaflet-bar{box-shadow:0 1px 5px #000000a6;border-radius:4px}.leaflet-bar a{background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;display:block;text-align:center;text-decoration:none;color:#000}.leaflet-bar a,.leaflet-control-layers-toggle{background-position:50% 50%;background-repeat:no-repeat;display:block}.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:#f4f4f4}.leaflet-bar a:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.leaflet-bar a:last-child{border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-bottom:none}.leaflet-bar a.leaflet-disabled{cursor:default;background-color:#f4f4f4;color:#bbb}.leaflet-touch .leaflet-bar a{width:30px;height:30px;line-height:30px}.leaflet-touch .leaflet-bar a:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.leaflet-touch .leaflet-bar a:last-child{border-bottom-left-radius:2px;border-bottom-right-radius:2px}.leaflet-control-zoom-in,.leaflet-control-zoom-out{font:700 18px Lucida Console,Monaco,monospace;text-indent:1px}.leaflet-touch .leaflet-control-zoom-in,.leaflet-touch .leaflet-control-zoom-out{font-size:22px}.leaflet-control-layers{box-shadow:0 1px 5px #0006;background:#fff;border-radius:5px}.leaflet-control-layers-toggle{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAQAAAADQ4RFAAACf0lEQVR4AY1UM3gkARTePdvdoTxXKc+qTl3aU5U6b2Kbkz3Gtq3Zw6ziLGNPzrYx7946Tr6/ee/XeCQ4D3ykPtL5tHno4n0d/h3+xfuWHGLX81cn7r0iTNzjr7LrlxCqPtkbTQEHeqOrTy4Yyt3VCi/IOB0v7rVC7q45Q3Gr5K6jt+3Gl5nCoDD4MtO+j96Wu8atmhGqcNGHObuf8OM/x3AMx38+4Z2sPqzCxRFK2aF2e5Jol56XTLyggAMTL56XOMoS1W4pOyjUcGGQdZxU6qRh7B9Zp+PfpOFlqt0zyDZckPi1ttmIp03jX8gyJ8a/PG2yutpS/Vol7peZIbZcKBAEEheEIAgFbDkz5H6Zrkm2hVWGiXKiF4Ycw0RWKdtC16Q7qe3X4iOMxruonzegJzWaXFrU9utOSsLUmrc0YjeWYjCW4PDMADElpJSSQ0vQvA1Tm6/JlKnqFs1EGyZiFCqnRZTEJJJiKRYzVYzJck2Rm6P4iH+cmSY0YzimYa8l0EtTODFWhcMIMVqdsI2uiTvKmTisIDHJ3od5GILVhBCarCfVRmo4uTjkhrhzkiBV7SsaqS+TzrzM1qpGGUFt28pIySQHR6h7F6KSwGWm97ay+Z+ZqMcEjEWebE7wxCSQwpkhJqoZA5ivCdZDjJepuJ9IQjGGUmuXJdBFUygxVqVsxFsLMbDe8ZbDYVCGKxs+W080max1hFCarCfV+C1KATwcnvE9gRRuMP2prdbWGowm1KB1y+zwMMENkM755cJ2yPDtqhTI6ED1M/82yIDtC/4j4BijjeObflpO9I9MwXTCsSX8jWAFeHr05WoLTJ5G8IQVS/7vwR6ohirYM7f6HzYpogfS3R2OAAAAAElFTkSuQmCC);width:36px;height:36px}.leaflet-retina .leaflet-control-layers-toggle{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAQAAABvcdNgAAAEsklEQVR4AWL4TydIhpZK1kpWOlg0w3ZXP6D2soBtG42jeI6ZmQTHzAxiTbSJsYLjO9HhP+WOmcuhciVnmHVQcJnp7DFvScowZorad/+V/fVzMdMT2g9Cv9guXGv/7pYOrXh2U+RRR3dSd9JRx6bIFc/ekqHI29JC6pJ5ZEh1yWkhkbcFeSjxgx3L2m1cb1C7bceyxA+CNjT/Ifff+/kDk2u/w/33/IeCMOSaWZ4glosqT3DNnNZQ7Cs58/3Ce5HL78iZH/vKVIaYlqzfdLu8Vi7dnvUbEza5Idt36tquZFldl6N5Z/POLof0XLK61mZCmJSWjVF9tEjUluu74IUXvgttuVIHE7YxSkaYhJZam7yiM9Pv82JYfl9nptxZaxMJE4YSPty+vF0+Y2up9d3wwijfjZbabqm/3bZ9ecKHsiGmRflnn1MW4pjHf9oLufyn2z3y1D6n8g8TZhxyzipLNPnAUpsOiuWimg52psrTZYnOWYNDTMuWBWa0tJb4rgq1UvmutpaYEbZlwU3CLJm/ayYjHW5/h7xWLn9Hh1vepDkyf7dE7MtT5LR4e7yYpHrkhOUpEfssBLq2pPhAqoSWKUkk7EDqkmK6RrCEzqDjhNDWNE+XSMvkJRDWlZTmCW0l0PHQGRZY5t1L83kT0Y3l2SItk5JAWHl2dCOBm+fPu3fo5/3v61RMCO9Jx2EEYYhb0rmNQMX/vm7gqOEJLcXTGw3CAuRNeyaPWwjR8PRqKQ1PDA/dpv+on9Shox52WFnx0KY8onHayrJzm87i5h9xGw/tfkev0jGsQizqezUKjk12hBMKJ4kbCqGPVNXudyyrShovGw5CgxsRICxF6aRmSjlBnHRzg7Gx8fKqEubI2rahQYdR1YgDIRQO7JvQyD52hoIQx0mxa0ODtW2Iozn1le2iIRdzwWewedyZzewidueOGqlsn1MvcnQpuVwLGG3/IR1hIKxCjelIDZ8ldqWz25jWAsnldEnK0Zxro19TGVb2ffIZEsIO89EIEDvKMPrzmBOQcKQ+rroye6NgRRxqR4U8EAkz0CL6uSGOm6KQCdWjvjRiSP1BPalCRS5iQYiEIvxuBMJEWgzSoHADcVMuN7IuqqTeyUPq22qFimFtxDyBBJEwNyt6TM88blFHao/6tWWhuuOM4SAK4EI4QmFHA+SEyWlp4EQoJ13cYGzMu7yszEIBOm2rVmHUNqwAIQabISNMRstmdhNWcFLsSm+0tjJH1MdRxO5Nx0WDMhCtgD6OKgZeljJqJKc9po8juskR9XN0Y1lZ3mWjLR9JCO1jRDMd0fpYC2VnvjBSEFg7wBENc0R9HFlb0xvF1+TBEpF68d+DHR6IOWVv2BECtxo46hOFUBd/APU57WIoEwJhIi2CdpyZX0m93BZicktMj1AS9dClteUFAUNUIEygRZCtik5zSxI9MubTBH1GOiHsiLJ3OCoSZkILa9PxiN0EbvhsAo8tdAf9Seepd36lGWHmtNANTv5Jd0z4QYyeo/UEJqxKRpg5LZx6btLPsOaEmdMyxYdlc8LMaJnikDlhclqmPiQnTEpLUIZEwkRagjYkEibQErwhkTAKCLQEbUgkzJQWc/0PstHHcfEdQ+UAAAAASUVORK5CYII=);background-size:26px 26px}.leaflet-touch .leaflet-control-layers-toggle{width:44px;height:44px}.leaflet-control-layers .leaflet-control-layers-list,.leaflet-control-layers-expanded .leaflet-control-layers-toggle{display:none}.leaflet-control-layers-expanded .leaflet-control-layers-list{display:block;position:relative}.leaflet-control-layers-expanded{padding:6px 10px 6px 6px;color:#333;background:#fff}.leaflet-control-layers-scrollbar{overflow-y:scroll;overflow-x:hidden;padding-right:5px}.leaflet-control-layers-selector{margin-top:2px;position:relative;top:1px}.leaflet-control-layers label{display:block;font-size:13px;font-size:1.08333em}.leaflet-control-layers-separator{height:0;border-top:1px solid #ddd;margin:5px -10px 5px -6px}.leaflet-default-icon-path{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=)}.leaflet-container .leaflet-control-attribution{background:#fff;background:rgba(255,255,255,.8);margin:0}.leaflet-control-attribution,.leaflet-control-scale-line{padding:0 5px;color:#333;line-height:1.4}.leaflet-control-attribution a{text-decoration:none}.leaflet-control-attribution a:hover,.leaflet-control-attribution a:focus{text-decoration:underline}.leaflet-attribution-flag{display:inline!important;vertical-align:baseline!important;width:1em;height:.6669em}.leaflet-left .leaflet-control-scale{margin-left:5px}.leaflet-bottom .leaflet-control-scale{margin-bottom:5px}.leaflet-control-scale-line{border:2px solid #777;border-top:none;line-height:1.1;padding:2px 5px 1px;white-space:nowrap;overflow:hidden;-moz-box-sizing:border-box;box-sizing:border-box;background:#fff;background:rgba(255,255,255,.5)}.leaflet-control-scale-line:not(:first-child){border-top:2px solid #777;border-bottom:none;margin-top:-2px}.leaflet-control-scale-line:not(:first-child):not(:last-child){border-bottom:2px solid #777}.leaflet-touch .leaflet-control-attribution,.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{box-shadow:none}.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{border:2px solid rgba(0,0,0,.2);background-clip:padding-box}.leaflet-popup{position:absolute;text-align:center;margin-bottom:20px}.leaflet-popup-content-wrapper{padding:1px;text-align:left;border-radius:12px}.leaflet-popup-content{margin:13px 24px 13px 20px;line-height:1.3;font-size:13px;font-size:1.08333em;min-height:1px}.leaflet-popup-content p{margin:1.3em 0}.leaflet-popup-tip-container{width:40px;height:20px;position:absolute;left:50%;margin-top:-1px;margin-left:-20px;overflow:hidden;pointer-events:none}.leaflet-popup-tip{width:17px;height:17px;padding:1px;margin:-10px auto 0;pointer-events:auto;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:white;color:#333;box-shadow:0 3px 14px #0006}.leaflet-container a.leaflet-popup-close-button{position:absolute;top:0;right:0;border:none;text-align:center;width:24px;height:24px;font:16px/24px Tahoma,Verdana,sans-serif;color:#757575;text-decoration:none;background:transparent}.leaflet-container a.leaflet-popup-close-button:hover,.leaflet-container a.leaflet-popup-close-button:focus{color:#585858}.leaflet-popup-scrolled{overflow:auto}.leaflet-oldie .leaflet-popup-content-wrapper{-ms-zoom:1}.leaflet-oldie .leaflet-popup-tip{width:24px;margin:0 auto;-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";filter:progid:DXImageTransform.Microsoft.Matrix(M11=.70710678,M12=.70710678,M21=-.70710678,M22=.70710678)}.leaflet-oldie .leaflet-control-zoom,.leaflet-oldie .leaflet-control-layers,.leaflet-oldie .leaflet-popup-content-wrapper,.leaflet-oldie .leaflet-popup-tip{border:1px solid #999}.leaflet-div-icon{background:#fff;border:1px solid #666}.leaflet-tooltip{position:absolute;padding:6px;background-color:#fff;border:1px solid #fff;border-radius:3px;color:#222;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;box-shadow:0 1px 3px #0006}.leaflet-tooltip.leaflet-interactive{cursor:pointer;pointer-events:auto}.leaflet-tooltip-top:before,.leaflet-tooltip-bottom:before,.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{position:absolute;pointer-events:none;border:6px solid transparent;background:transparent;content:""}.leaflet-tooltip-bottom{margin-top:6px}.leaflet-tooltip-top{margin-top:-6px}.leaflet-tooltip-bottom:before,.leaflet-tooltip-top:before{left:50%;margin-left:-6px}.leaflet-tooltip-top:before{bottom:0;margin-bottom:-12px;border-top-color:#fff}.leaflet-tooltip-bottom:before{top:0;margin-top:-12px;margin-left:-6px;border-bottom-color:#fff}.leaflet-tooltip-left{margin-left:-6px}.leaflet-tooltip-right{margin-left:6px}.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{top:50%;margin-top:-6px}.leaflet-tooltip-left:before{right:0;margin-right:-12px;border-left-color:#fff}.leaflet-tooltip-right:before{left:0;margin-left:-12px;border-right-color:#fff}@media print{.leaflet-control{-webkit-print-color-adjust:exact;print-color-adjust:exact}}.marker-cluster-small{background-color:#b5e28c99}.marker-cluster-small div{background-color:#6ecc3999}.marker-cluster-medium{background-color:#f1d35799}.marker-cluster-medium div{background-color:#f0c20c99}.marker-cluster-large{background-color:#fd9c7399}.marker-cluster-large div{background-color:#f1801799}.leaflet-oldie .marker-cluster-small{background-color:#b5e28c}.leaflet-oldie .marker-cluster-small div{background-color:#6ecc39}.leaflet-oldie .marker-cluster-medium{background-color:#f1d357}.leaflet-oldie .marker-cluster-medium div{background-color:#f0c20c}.leaflet-oldie .marker-cluster-large{background-color:#fd9c73}.leaflet-oldie .marker-cluster-large div{background-color:#f18017}.marker-cluster{background-clip:padding-box;border-radius:20px}.marker-cluster div{width:30px;height:30px;margin-left:5px;margin-top:5px;text-align:center;border-radius:15px;font:12px Helvetica Neue,Arial,Helvetica,sans-serif}.marker-cluster span{line-height:30px}.leaflet-cluster-anim .leaflet-marker-icon,.leaflet-cluster-anim .leaflet-marker-shadow{-webkit-transition:-webkit-transform .3s ease-out,opacity .3s ease-in;-moz-transition:-moz-transform .3s ease-out,opacity .3s ease-in;-o-transition:-o-transform .3s ease-out,opacity .3s ease-in;transition:transform .3s ease-out,opacity .3s ease-in}.leaflet-cluster-spider-leg{-webkit-transition:-webkit-stroke-dashoffset .3s ease-out,-webkit-stroke-opacity .3s ease-in;-moz-transition:-moz-stroke-dashoffset .3s ease-out,-moz-stroke-opacity .3s ease-in;-o-transition:-o-stroke-dashoffset .3s ease-out,-o-stroke-opacity .3s ease-in;transition:stroke-dashoffset .3s ease-out,stroke-opacity .3s ease-in}.leaflet-control-velocity{background-color:#ffffffb3;padding:0 5px;margin:0!important;color:#333;font:11px/1.5 Helvetica Neue,Arial,Helvetica,sans-serif}.velocity-overlay{position:absolute;z-index:1}a[data-v-88863373],a b[data-v-88863373]{display:block}.addresssm[data-v-88863373]{color:var(--app-textcolor);font-size:.7em}section[data-v-88863373]{justify-content:space-between}section[data-v-88863373]:not(:last-child){padding-bottom:var(--gap);border-bottom:1px solid var(--app-textcolor)}button[data-v-88863373]{border:0;cursor:pointer;font-size:1.2em;transition:color .2s ease-in}button[data-v-88863373]:hover{color:var(--color-red)}.mapcontrols[data-v-0e5a211e]{bottom:0;box-sizing:border-box;display:flex;justify-content:space-between;left:0;padding:0 var(--app-controlsgap) var(--app-controlsgap);position:absolute;right:0;z-index:12;pointer-events:none}.mapcontrols>*[data-v-0e5a211e]{pointer-events:all}.popover-bottom-right[data-v-0e5a211e],.popover-bottom-left[data-v-0e5a211e]{bottom:calc(var(--app-inputheight) + var(--app-controlsgap) * 2);max-width:calc(100vw - var(--app-controlsgap) * 2)}.popover-bottom-right[data-v-0e5a211e]{right:var(--app-controlsgap)}.popover-bottom-left[data-v-0e5a211e]{left:var(--app-controlsgap)}.popovercontrol.active{border-color:var(--color-green)}.popovercontrol.active path{fill:var(--color-green)!important}.leaflet-control-attribution,.leaflet-container .leaflet-control-attribution{font-size:calc(var(--font-size) * .5);background:none;margin:0!important}.leaflet-bottom .leaflet-control-locate{border:var(--app-borderwidth) solid var(--app-bordercolor)}.leaflet-bottom .leaflet-control-locate .leaflet-bar-part-single{background:var(--app-inputbg)}.leaflet-right .leaflet-control{margin-right:var(--gap)}.leaflet-bottom .leaflet-control{margin-bottom:.3rem}.leaflet-control-locate a .leaflet-control-locate-location-arrow,.leaflet-control-locate.following a .leaflet-control-locate-location-arrow{background:var(--app-bordercolor)}.leaflet-touch .leaflet-bar,.leaflet-touch .leaflet-bar a,.leaflet-bar a,.leaflet-bar{border-radius:50%!important}.leaflet-touch .leaflet-bar a,.leaflet-bar a{width:calc(var(--app-inputheight) - var(--app-borderwidth) * 2);height:calc(var(--app-inputheight) - var(--app-borderwidth) * 2);line-height:1;display:flex;align-items:center;justify-content:center;border-radius:50%!important}.marker-cluster-circle{border-width:2px;border-style:solid;border-radius:18px}.marker-cluster-circle span{line-height:27px;font-weight:700}.marker-cluster-msg{font-weight:700;background-size:contain;color:#fff;padding-top:4px;font-size:16px;width:40px!important;height:40px!important}.marker-icon-brand{width:35px!important;height:35px!important;border-radius:50%}.marker-icon-msg{width:40px;height:40px}.mapcontainer[data-v-66a2c2ad]{background-color:var(--color-light-gray);position:absolute;top:0;left:0;z-index:0;width:100%;height:100svh;overflow:hidden}.mapcontainer.inactive[data-v-66a2c2ad]{filter:grayscale(100%)}.st0[data-v-1ca21f0d]{fill:#fff;stroke:#000;stroke-width:.5;stroke-miterlimit:10}header[data-v-a4474917]{left:0;padding:var(--app-controlsgap);position:absolute;top:0;width:100vw;z-index:10;pointer-events:none}header>*[data-v-a4474917]{pointer-events:all}.appicon[data-v-a4474917]{border-radius:.5rem;display:block;overflow:hidden;user-select:none;width:2.5rem}.appicon img[data-v-a4474917]{display:block;max-width:100%}.popover-top-right[data-v-a4474917]{top:calc(var(--gap) * 3 + var(--app-inputheight));right:var(--gap);width:500px;max-width:calc(100vw - var(--gap) * 2)}@supports not selector(:popover-open){.popover-top-right[data-v-a4474917]{right:var(--gap)!important}}#about p[data-v-a4474917]{font-size:.9em}.navlinks[data-v-a4474917]{font-weight:700}.navlinks a[data-v-a4474917]{display:block}.navlinks a[data-v-a4474917]:not(:last-child){margin-bottom:calc(var(--gap) * .5)}.sensorscount[data-v-a4474917]{color:#fff;background:var(--color-orange);padding:4px 10px;display:block;border-radius:5px;display:flex;gap:10px;align-items:center}.sensorscount svg[data-v-a4474917]{width:22px}.install-pwa__container[data-v-b59a209f]{position:relative;display:flex;align-items:center;justify-content:space-between;background-color:#fff;z-index:10}.install-pwa__content img[data-v-b59a209f]{width:36px;height:36px;border-radius:5px}.install-pwa__content[data-v-b59a209f]{display:flex;align-items:center;gap:var(--gap)}.install-pwa__content h3[data-v-b59a209f]{margin:0;margin-bottom:calc(var(--gap) * .2);font-size:calc(var(--font-size) * .8);text-transform:none}.install-pwa__btn[data-v-b59a209f]{padding:calc(var(--gap) * .2) calc(var(--gap) * 1.8);font-weight:700;font-family:var(--font-family--normal);color:#fff;background-color:#3658c6;border-radius:15px;border:none;cursor:pointer}.install-pwa__remove[data-v-b59a209f]{width:20px;height:20px;background-image:url('data:image/svg+xml,');background-position:center;background-repeat:no-repeat;border:none;cursor:pointer}h2[data-v-c5bfb7c2]{margin-bottom:calc(var(--gap) * .7)}.sensors-panel[data-v-c5bfb7c2]{position:absolute;top:40px;bottom:0;right:0;z-index:14;width:48%}.sensor-popup.popup-js[data-v-c5bfb7c2]{padding-right:0!important;background-color:var(--sensor-popup-bg)}.sensor-popup.container[data-v-c5bfb7c2]{padding:0;padding-bottom:calc(var(--gap) * 6)}.sensor-popup .popup__close[data-v-c5bfb7c2]{right:calc(var(--gap) * 2);top:1.5rem;color:#fff}.sensor-popup__header[data-v-c5bfb7c2]{min-height:110px;padding:calc(var(--gap) * 2) var(--gap);display:flex;align-items:center;color:#fff}.sensor-popup__header-wrapper .fa-copy[data-v-c5bfb7c2]{margin-left:var(--gap)}.sensor-popup__header--neutral[data-v-c5bfb7c2]{background-color:#747a80}.sensor-popup__header--good[data-v-c5bfb7c2]{background-color:var(--color-green)}.sensor-popup__header--attention[data-v-c5bfb7c2]{background-color:var(--color-orange)}.sensor-popup__header--danger[data-v-c5bfb7c2]{background-color:var(--color-red)}.sensor-popup__header a[data-v-c5bfb7c2]{color:inherit}.sensor-popup__header-icon[data-v-c5bfb7c2]{font-size:3rem;margin-right:calc(var(--gap) * 2)}.sensor-popup--subtitle[data-v-c5bfb7c2]{display:flex;align-items:center;font-family:var(--font-family--normal);text-transform:none}.sensor-popup--subtitle span[data-v-c5bfb7c2]:not(:last-child){margin-right:calc(var(--gap) * 2)}ul.sensor-popup--data[data-v-c5bfb7c2]{display:flex;align-items:center;flex-wrap:wrap;list-style:none;padding:calc(var(--gap) * .7) 0}ul.sensor-popup--data .icon[data-v-c5bfb7c2]{display:inline-block;font-size:calc(var(--gap) * 1.5);text-align:center;width:calc(var(--gap) * 2.5)}.sensor-popup--content[data-v-c5bfb7c2]{height:80%;overflow-y:auto;padding:calc(var(--gap) * 2);padding-top:0;padding-right:calc(var(--gap) * 2.2);padding-bottom:calc(var(--gap) * 2);margin-top:var(--gap);margin-right:calc(var(--gap) * 2)}.sensor-popup--content img[data-v-c5bfb7c2]{max-width:100%;width:100%}@media screen and (max-width: 1080px){.sensors-panel[data-v-c5bfb7c2]{width:90%}}@media screen and (max-width: 580px){h2[data-v-c5bfb7c2]{font-size:1rem}.sensors-panel[data-v-c5bfb7c2]{position:absolute;top:calc(var(--gap) * 16);left:0;right:0;bottom:0;z-index:9;width:100%}.sensor-popup.container[data-v-c5bfb7c2]{padding-bottom:calc(var(--gap) * 5)}.sensor-popup .popup__close[data-v-c5bfb7c2]{right:var(--gap)}.sensor-popup__header[data-v-c5bfb7c2]{flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:var(--gap)}.sensor-popup__header-icon[data-v-c5bfb7c2]{font-size:2rem;line-height:1.5;margin-right:0}.sensor-popup--subtitle span[data-v-c5bfb7c2]:not(:last-child){margin-right:var(--gap)}}button[data-v-8cca7f79]{padding-right:calc(var(--app-inputpadding)*2);padding-left:calc(var(--app-inputpadding)*2)}.highcharts-legend-item{font-weight:900}.highcharts-legend-item .highcharts-graph,.highcharts-legend-item .highcharts-point{stroke:#000!important}.highcharts-legend-item .highcharts-point{fill:#000!important}.highcharts-legend-item-hidden text{fill:#999!important;color:#999!important;text-decoration:none!important}.highcharts-legend-item-hidden .highcharts-graph,.highcharts-legend-item-hidden .highcharts-point{stroke:#999!important}.highcharts-legend-item-hidden .highcharts-point{fill:#999!important}.copy[data-v-951f909f]{cursor:pointer}.fa-copy[data-v-951f909f],.fa-check[data-v-951f909f]{margin-left:calc(var(--gap) * .8);color:var(--color-blue)}.copy-btn[data-v-951f909f]{margin-left:calc(var(--gap) * .8);width:14px;height:16px;padding:calc(var(--gap) * .1);background-image:url("data:image/svg+xml,%0A%3Csvg width='14' height='17' viewBox='0 0 14 17' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.3752 0H12.3964C13.1986 0 13.8549 0.656284 13.8549 1.45841V10.9381C13.8549 11.3391 13.5267 11.6673 13.1257 11.6673C12.7246 11.6673 12.3964 11.3391 12.3964 10.9381V2.18761C12.3964 1.78655 12.0683 1.45841 11.6672 1.45841H4.3752C3.97414 1.45841 3.646 1.13027 3.646 0.729204C3.646 0.328142 3.97414 0 4.3752 0ZM1.45839 2.91682H9.47963C10.2818 2.91682 10.938 3.5731 10.938 4.37523V14.5841C10.938 15.3862 10.2818 16.0425 9.47963 16.0425H1.45839C0.656261 16.0425 -2.19345e-05 15.3862 -2.19345e-05 14.5841V4.37523C-2.19345e-05 3.5731 0.656261 2.91682 1.45839 2.91682ZM2.18759 14.5841H8.75043C9.15149 14.5841 9.47963 14.2559 9.47963 13.8549V5.10443C9.47963 4.70337 9.15149 4.37523 8.75043 4.37523H2.18759C1.78653 4.37523 1.45839 4.70337 1.45839 5.10443V13.8549C1.45839 14.2559 1.78653 14.5841 2.18759 14.5841Z' fill='%2303A5ED'/%3E%3C/svg%3E%0A");background-size:100%;background-position:center;background-repeat:no-repeat;border:none;cursor:pointer}@media screen and (max-width: 680px){.copy[data-v-951f909f]{font-size:calc(var(--font-size) * .8)}}.popup-js.active[data-v-cf7806f0]{container:popup / inline-size;background:var(--app-popoverbg);border-radius:0;bottom:0;box-sizing:border-box;color:var(--app-textcolor);padding:var(--gap);position:absolute;right:0;top:0;width:80vw;max-width:1000px;z-index:100}.scrollable-y[data-v-cf7806f0]{max-height:90%}.close[data-v-cf7806f0]{border:0;color:var(--app-textcolor);cursor:pointer;font-size:1.2em;position:absolute;right:var(--gap);top:var(--gap)}.close[data-v-cf7806f0]:hover{color:var(--color-red)}.flexline[data-v-cf7806f0]{gap:calc(var(--gap) * 2)}.flexline .flexline[data-v-cf7806f0]{gap:var(--gap)}h3.flexline[data-v-cf7806f0]{gap:calc(var(--gap) * .5);max-width:calc(100% - var(--gap) * 2)}.icontitle[data-v-cf7806f0]{display:inline-block;max-height:calc(var(--font-size) * 2)}@media screen and (max-width: 700px){.popup-js.active[data-v-cf7806f0]{left:0;width:100vw;top:30vw;padding-right:calc(var(--gap) * .5)}}@container popup (min-width: 400px){.close[data-v-cf7806f0]{font-size:1.6em}}@container popup (max-width: 400px){h3.flexline[data-v-cf7806f0]{max-width:calc(100% - var(--gap) * 3)}}.infoline.flexline[data-v-cf7806f0]{gap:calc(var(--gap) * .5)}.infoline-title[data-v-cf7806f0]{font-weight:700}.scalegrid[data-v-cf7806f0]{display:grid;grid-template-columns:repeat(3,1fr);gap:var(--gap);font-size:.8em}.scalegrid p[data-v-cf7806f0]{margin-bottom:calc(var(--gap) * .5)}.scales-color[data-v-cf7806f0]{position:relative;padding-left:calc(var(--gap) * 2)}.scales-color[data-v-cf7806f0]:before{content:"";display:block;position:absolute;background-color:var(--color);top:0;left:0;bottom:0;width:var(--gap)}.rt-title[data-v-cf7806f0]{font-weight:900}.rt-title[data-v-cf7806f0]:before{animation:blink infinite 1.5s;background-color:var(--color-green);border-radius:50%;content:"";display:inline-block;height:8px;margin-right:5px;vertical-align:middle;width:8px}.rt-time[data-v-cf7806f0]{font-size:.8em;font-weight:300;padding-left:13px}.rt-unit[data-v-cf7806f0],.rt-number[data-v-cf7806f0]{font-size:.8em;font-weight:900}.optout-form[data-v-ee8b7997]{padding:1.5rem .8rem;border:2px solid #333}.optout-form strong[data-v-ee8b7997]{padding-left:10px}.privacy-policy ul[data-v-168a0093]{padding-left:20px;list-style:disc}.privacy-policy__wrapper[data-v-168a0093]:not(:last-of-type){margin-bottom:3rem}.mb[data-v-10839161]{margin-bottom:calc(var(--gap) * 2)!important}.air-measurements__header p[data-v-10839161]{font-size:calc(var(--font-size) * .9);font-weight:500;line-height:1.7}.air-measurements__wrapper[data-v-10839161]:not(:last-of-type){margin-bottom:5rem}.air-measurements__header[data-v-10839161]{max-width:800px;margin:0 auto;margin-bottom:calc(var(--gap) * 2)}.air-measurements__content[data-v-10839161]{display:grid;grid-template-columns:350px 630px;justify-content:center;gap:calc(var(--gap) * 2);font-weight:500}.air-measurements__recs[data-v-10839161]{font-size:calc(var(--font-size) * .9)}.air-measurements ol[data-v-10839161]{padding-left:calc(var(--gap) * 1.5);margin-bottom:calc(var(--gap) * .5)}.air-measurements ul li[data-v-10839161]{width:100%;padding:calc(var(--gap) * .5) calc(var(--gap) * .9);color:var(--color-light);font-size:calc(var(--font-size) * .8);font-weight:900}.air-measurements .green[data-v-10839161]{background-color:var(--color-green)}.air-measurements .blue[data-v-10839161]{background-color:var(--color-teal)}.air-measurements .navy[data-v-10839161]{background-color:var(--color-navy)}.air-measurements .orange[data-v-10839161]{background-color:var(--color-orange)}.air-measurements .red[data-v-10839161]{background-color:var(--color-bright-red)}.air-measurements .purple[data-v-10839161]{background-color:var(--color-purple)}@media screen and (max-width: 880px){.air-measurements__content[data-v-10839161]{grid-template-columns:1fr;gap:var(--gap)}}*{margin:0;padding:0;outline:0;background:transparent;vertical-align:baseline;box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}img{border:0}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,main{display:block}ul{list-style:none}table{border-collapse:collapse;border-spacing:0}input,select{vertical-align:middle}sup{vertical-align:super}sub{vertical-align:sub}:root{--color-light: #fff;--color-gray: #4e4e4f;--color-middle-gray: #B6BDC4;--color-light-gray: #d5d3d3;--color-dark: #000;--color-blue: #03a5ed;--color-teal: #12bfcc;--color-green: #60bc2a;--color-red: #fc0202;--color-bright-red: #ff4d00;--color-yellow: #f5ff00;--color-orange: #ff9d00;--color-purple: #7a00da;--color-navy: hsl(219, 63%, 45%);--color-link: var(--color-blue);--color-link-hover: var(--color-green);--font-family--normal: "Noto Sans", sans-serif;--font-size: 1rem;--gap: 1rem;--sensor-popup-bg: #ffffff;--main-bg: #ffffff;--app-borderwidth: 2px;--app-bordercolor: #000;--app-inputbg: #fff;--app-inputpadding: .4rem;--app-inputbradius: .3rem;--app-textcolor: #000;--app-inputheight: 2.4rem;--app-buttoncolor:hsl(219, 63%, 45%);--app-buttoncolor-active:hsl(219, 63%, 60%);--app-buttoncolor-hover:hsl(219, 63%, 35%);--app-buttontextcolor: #fff;--app-popoverbg: #fff;--app-controlsgap: calc(var(--gap) * 2)}@media screen and (max-width: 500px){:root{--font-size: .8rem;--gap: .5rem}.leaflet-bottom .leaflet-control{margin-bottom:0}}@font-face{font-family:Noto Sans;src:url(/assets/notosansdisplay-black-webfont.9f247781.woff2) format("woff2");src:url(/assets/notosansdisplay-black-webfont.00b4a963.woff) format("woff");font-weight:900;font-display:swap;font-style:normal}@font-face{font-family:Noto Sans;src:url(/assets/notosans-bold-webfont.b1ab6654.woff2) format("woff2");src:url(/assets/notosans-bold-webfont.8b1ca092.woff) format("woff");font-weight:700;font-display:swap;font-style:normal}@font-face{font-family:Noto Sans;src:url(/assets/notosansdisplay-medium-webfont.5dca4cb1.woff2) format("woff2");src:url(/assets/notosansdisplay-medium-webfont.cf14dc66.woff) format("woff");font-weight:500;font-display:swap;font-style:normal}@font-face{font-family:Noto Sans;src:url(/assets/notosans-regular-webfont.7d4a5d04.woff2) format("woff2");src:url(/assets/notosans-regular-webfont.c3dfba11.woff) format("woff");font-weight:400;font-display:swap;font-style:normal}body{font-size:var(--font-size);font-family:var(--font-family--normal);background-color:var(--color-light)}a{color:var(--color-link);text-decoration:none}a:hover{color:var(--color-link-hover)}p:not(:last-child),ul:not(:last-child),ol:not(:last-child),dl:not(:last-child),h2,h3,h4,h5{margin-bottom:var(--gap)}h1,h2,h3,h4,h5{font-weight:900}h1{font-size:calc(var(--font-size) * 2);font-weight:900;margin-bottom:calc(var(--gap) * 3)}li,dd{margin-bottom:calc(var(--gap) * .5)}hr{margin:calc(var(--gap)*2) 0;border:.5px solid var(--app-bordercolor)}input,select,.button{background-color:var(--app-inputbg);border-radius:var(--app-inputbradius);border:var(--app-borderwidth) solid var(--app-bordercolor);box-sizing:border-box;color:var(--app-textcolor);font-family:var(--font-family--normal);font-size:var(--font-size);font-weight:700;height:var(--app-inputheight);line-height:1;padding:calc(var(--app-inputpadding) * .8) var(--app-inputpadding);transition-duration:.33s;transition-property:border,background-color;transition-timing-function:ease-in-out}input.block,select.block,.button.block{display:block;width:100%}select{appearance:none;background-image:url("data:image/svg+xml;utf8,");background-position-x:calc(100% - var(--app-inputpadding));background-position-y:50%;background-repeat:no-repeat;background-size:.5rem;padding-right:calc(var(--app-inputpadding) * 1.5 + .5rem);user-select:none}input[type=text]:focus,input[type=password]:focus{--app-bordercolor: var(--color-navy)}input[type=checkbox]{border:var(--app-borderwidth) solid var(--app-bordercolor);height:calc(var(--app-inputheight) * .5);width:calc(var(--app-inputheight) * .5)}input[type=checkbox]:not(:last-child){margin-right:calc(var(--gap) * .5)}input[type=submit],.button{background-color:var(--app-buttoncolor);border-color:var(--app-buttoncolor);color:var(--app-buttontextcolor)}input[type=submit]:not(:disabled):active,.button:not(:disabled):active{--app-buttoncolor: var(--app-buttoncolor-active)}input[type=submit]:not(:disabled):hover,.button:not(:disabled):hover{--app-buttoncolor: var(--app-buttoncolor-hover)}select:not([disabled]),input[type=checkbox]:not([disabled]),input[type=submit]:not([disabled]),.button:not([disabled]){cursor:pointer}.button-green{--app-buttoncolor: var(--color-green)}.button>*:not(:last-child){margin-right:calc(var(--gap) * .5)}label{font-weight:700}:popover-open{background-color:var(--app-popoverbg);box-shadow:0 4px 8px #0003,0 6px 20px #00000030;border-radius:var(--app-inputbradius);border:none;inset:unset;padding:var(--gap)}[popovertarget]{transition:opacity .3s ease-in-out}:popover-open~[popovertarget]{opacity:.6}:popover-open::backdrop{backdrop-filter:grayscale(1)}.popovercontrol{align-items:center;background-color:var(--app-inputbg);border-radius:50%;border:var(--app-borderwidth) solid var(--app-bordercolor);cursor:pointer;display:flex;height:var(--app-inputheight);justify-content:center;user-select:none;width:var(--app-inputheight);color:var(--app-textcolor);font-size:var(--font-size)}.popovercontrol .svg-inline--fa path{fill:var(--app-textcolor)}@supports not selector(:popover-open){.popover{background-color:#fff;inset:unset;border:0;padding:var(--gap)}}.scrollable-y{overflow-y:auto;max-height:100%}::-webkit-scrollbar{width:7px}::-webkit-scrollbar-track{border-radius:4px;background:#EAEAEA}::-webkit-scrollbar-thumb{border-radius:4px;background:#A5A5A5}.flexline{display:flex;gap:var(--gap);align-items:center}.flexline.space-between{justify-content:space-between}.flexline.align-start{align-items:start}.clipoverflow{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.textsmall{font-size:.8em}section:not(:last-child){margin-bottom:calc(var(--gap) * 2)}#app{position:relative;max-width:100vw;min-height:100svh}#app.map{overflow:hidden}.container{padding:calc(var(--gap) * .5) var(--gap)}.container-pagetext{padding:calc(var(--gap) * 7) var(--gap) calc(var(--gap) * 3);margin:0 auto;max-width:1200px}.sensors-container{padding-top:2rem;display:inline-flex;flex-direction:column}@media screen and (max-width: 680px){.sensors-container{display:flex}}.title{margin:0;font-size:12px;font-weight:700;transition:color .33s ease-in-out,background-color .33s ease-in-out}.subtitle{margin:0;font-size:14px;font-weight:600;font-family:var(--font-family--normal);transition:color .33s ease-in-out,background-color .33s ease-in-out}.text{font-family:var(--font-family--normal);font-weight:400;text-transform:none;line-height:1.5;text-align:justify!important;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;hyphens:auto;transition:color .33s ease-in-out,background-color .33s ease-in-out}@media (prefers-color-scheme: dark){.text-changabletheme{color:var(--color-light)}}.text-small{font-size:.8em}.text-tip{margin-top:var(--gap);font-family:var(--font-family--normal);color:var(--color-dark);font-weight:400;font-style:italic;text-transform:none}.sensors-screen{position:relative;width:100vw;height:100vh;overflow:hidden;transition:color .33s ease-in-out,background-color .33s ease-in-out}.sensors-screen-layers{display:flex;flex-direction:column;pointer-events:none;position:relative;width:100%;height:100%;z-index:1000;transition:color .33s ease-in-out,background-color .33s ease-in-out}.sensors-screen-layers--center{flex:1 0 auto;position:relative}*[class*=sensors-panel--center-]{position:absolute;top:calc(var(--gap) * 5);bottom:var(--gap);z-index:10;width:48%}.sensors-panel--center-right{right:var(--gap)}.sensors-panel--center-left{left:var(--gap)}*[class*=sensors-panel--center-] .sensors-panel:not(:last-child){margin-bottom:var(--gap)}.dark .sensors-screen.loading{background-color:#424241}.sensors-screen.loading{display:flex;align-items:center;justify-content:center;background-color:var(--color-light);z-index:9999}.sensors-container .fa-compass{display:none}.sensors-screen.loading .fa-spin{display:block;position:fixed;z-index:100;top:calc(50% - 2rem);left:calc(50% - 2rem);font-size:4rem;color:var(--color-link)}.popup,.popup-js{background-color:var(--color-light);color:var(--color-dark);display:none;opacity:0;position:relative;transform:translateY(20px);transition:color .33s ease-in-out,background-color .33s ease-in-out}.popup:target,.popup-js.active{display:block;animation:popup .2s linear .2s forwards}.popup-wrapper{position:absolute;top:calc(var(--gap) * 3);z-index:10}@keyframes popup{to{opacity:1;transform:translateY(0)}}.popup__close{color:var(--color-dark);font-size:calc(var(--gap) * 1.8);position:absolute;right:calc(var(--gap) * .5);top:calc(var(--gap) * .5);background-color:transparent}.popup__close svg{display:block}.popup__content{max-height:500px;overflow-y:auto}.header .popup__content h3{text-transform:none;margin-bottom:var(--gap)}.header .sensors-panel-top-nav-content h3{margin-top:calc(var(--gap) * 1.5);margin-bottom:calc(var(--gap) * .5)}.sensors-panel-top-nav-content .nav__item{padding:.2rem 0;margin-bottom:0}.sensors-panel-top-nav-content .nav__link{font-family:var(--font-family--normal);font-weight:300;font-size:calc(var(--font-size) * .85);color:var(--color-blue);text-transform:none}.header .popup__content .text{font-size:calc(var(--font-size) * .85);text-align:left!important}.header__close-popup,.footer__close-popup{align-self:flex-end;width:20px;height:20px;margin-bottom:var(--gap);background-image:url('data:image/svg+xml,');background-position:center;background-repeat:no-repeat;border:none;cursor:pointer}.dark .header__close-popup,.dark .footer__close-popup{background-image:url('data:image/svg+xml,')}.overlay{position:fixed;left:0;top:0;width:100%;height:100%;background-color:#0009;z-index:15;opacity:0;visibility:hidden}.overlay.open{opacity:1;visibility:visible;transition:all .3s}.sensors-dateselect input[type=date]{padding:.2rem .5rem;border-width:2px;font:inherit}.sensors-dateselect span{display:inline-block;color:var(--color-dark);vertical-align:middle}.dark .sensors-dateselect span{color:var(--color-middle-gray)}.sensors-dateselect .sensors-switcher label{margin:0 .4rem 0 1.2rem}@media screen and (max-width: 1250px){.sensors-panel--bottom{align-items:flex-start}.sensors-panel--bottom .sensors-switcher{display:block;margin-top:calc(var(--gap) * .5)}.sensors-dateselect .sensors-switcher label{margin:0}}@media screen and (max-width: 600px){.sensors-panel--bottom{display:block}.sensors-panel--bottom .sensors-panel-section:not(:last-child){margin-bottom:var(--gap)}}@keyframes fadeIn{to{opacity:1;visibility:visible}}@keyframes blink{0%{opacity:.5}50%{opacity:1}to{opacity:.5}} +.notify{font-size:20px!important;font-weight:700}.leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-pane>svg,.leaflet-pane>canvas,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer{position:absolute;left:0;top:0}.leaflet-container{overflow:hidden}.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow{-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-user-drag:none}.leaflet-tile::selection{background:transparent}.leaflet-safari .leaflet-tile{image-rendering:-webkit-optimize-contrast}.leaflet-safari .leaflet-tile-container{width:1600px;height:1600px;-webkit-transform-origin:0 0}.leaflet-marker-icon,.leaflet-marker-shadow{display:block}.leaflet-container .leaflet-overlay-pane svg{max-width:none!important;max-height:none!important}.leaflet-container .leaflet-marker-pane img,.leaflet-container .leaflet-shadow-pane img,.leaflet-container .leaflet-tile-pane img,.leaflet-container img.leaflet-image-layer,.leaflet-container .leaflet-tile{max-width:none!important;max-height:none!important;width:auto;padding:0}.leaflet-container.leaflet-touch-zoom{-ms-touch-action:pan-x pan-y;touch-action:pan-x pan-y}.leaflet-container.leaflet-touch-drag{-ms-touch-action:pinch-zoom;touch-action:none;touch-action:pinch-zoom}.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom{-ms-touch-action:none;touch-action:none}.leaflet-container{-webkit-tap-highlight-color:transparent}.leaflet-container a{-webkit-tap-highlight-color:rgba(51,181,229,.4)}.leaflet-tile{filter:inherit;visibility:hidden}.leaflet-tile-loaded{visibility:inherit}.leaflet-zoom-box{width:0;height:0;-moz-box-sizing:border-box;box-sizing:border-box;z-index:800}.leaflet-overlay-pane svg{-moz-user-select:none}.leaflet-pane{z-index:400}.leaflet-tile-pane{z-index:200}.leaflet-overlay-pane{z-index:400}.leaflet-shadow-pane{z-index:500}.leaflet-marker-pane{z-index:600}.leaflet-tooltip-pane{z-index:650}.leaflet-popup-pane{z-index:700}.leaflet-map-pane canvas{z-index:100}.leaflet-map-pane svg{z-index:200}.leaflet-vml-shape{width:1px;height:1px}.lvml{behavior:url(#default#VML);display:inline-block;position:absolute}.leaflet-control{position:relative;z-index:800;pointer-events:visiblePainted;pointer-events:auto}.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}.leaflet-control{float:left;clear:both}.leaflet-right .leaflet-control{float:right}.leaflet-top .leaflet-control{margin-top:10px}.leaflet-bottom .leaflet-control{margin-bottom:10px}.leaflet-left .leaflet-control{margin-left:10px}.leaflet-right .leaflet-control{margin-right:10px}.leaflet-fade-anim .leaflet-popup{opacity:0;-webkit-transition:opacity .2s linear;-moz-transition:opacity .2s linear;transition:opacity .2s linear}.leaflet-fade-anim .leaflet-map-pane .leaflet-popup{opacity:1}.leaflet-zoom-animated{-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0}svg.leaflet-zoom-animated{will-change:transform}.leaflet-zoom-anim .leaflet-zoom-animated{-webkit-transition:-webkit-transform .25s cubic-bezier(0,0,.25,1);-moz-transition:-moz-transform .25s cubic-bezier(0,0,.25,1);transition:transform .25s cubic-bezier(0,0,.25,1)}.leaflet-zoom-anim .leaflet-tile,.leaflet-pan-anim .leaflet-tile{-webkit-transition:none;-moz-transition:none;transition:none}.leaflet-zoom-anim .leaflet-zoom-hide{visibility:hidden}.leaflet-interactive{cursor:pointer}.leaflet-grab{cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.leaflet-crosshair,.leaflet-crosshair .leaflet-interactive{cursor:crosshair}.leaflet-popup-pane,.leaflet-control{cursor:auto}.leaflet-dragging .leaflet-grab,.leaflet-dragging .leaflet-grab .leaflet-interactive,.leaflet-dragging .leaflet-marker-draggable{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-image-layer,.leaflet-pane>svg path,.leaflet-tile-container{pointer-events:none}.leaflet-marker-icon.leaflet-interactive,.leaflet-image-layer.leaflet-interactive,.leaflet-pane>svg path.leaflet-interactive,svg.leaflet-image-layer.leaflet-interactive path{pointer-events:visiblePainted;pointer-events:auto}.leaflet-container{background:#ddd;outline-offset:1px}.leaflet-container a{color:#0078a8}.leaflet-zoom-box{border:2px dotted #38f;background:rgba(255,255,255,.5)}.leaflet-container{font-family:Helvetica Neue,Arial,Helvetica,sans-serif;font-size:12px;font-size:.75rem;line-height:1.5}.leaflet-bar{box-shadow:0 1px 5px #000000a6;border-radius:4px}.leaflet-bar a{background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;display:block;text-align:center;text-decoration:none;color:#000}.leaflet-bar a,.leaflet-control-layers-toggle{background-position:50% 50%;background-repeat:no-repeat;display:block}.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:#f4f4f4}.leaflet-bar a:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.leaflet-bar a:last-child{border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-bottom:none}.leaflet-bar a.leaflet-disabled{cursor:default;background-color:#f4f4f4;color:#bbb}.leaflet-touch .leaflet-bar a{width:30px;height:30px;line-height:30px}.leaflet-touch .leaflet-bar a:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.leaflet-touch .leaflet-bar a:last-child{border-bottom-left-radius:2px;border-bottom-right-radius:2px}.leaflet-control-zoom-in,.leaflet-control-zoom-out{font:700 18px Lucida Console,Monaco,monospace;text-indent:1px}.leaflet-touch .leaflet-control-zoom-in,.leaflet-touch .leaflet-control-zoom-out{font-size:22px}.leaflet-control-layers{box-shadow:0 1px 5px #0006;background:#fff;border-radius:5px}.leaflet-control-layers-toggle{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAQAAAADQ4RFAAACf0lEQVR4AY1UM3gkARTePdvdoTxXKc+qTl3aU5U6b2Kbkz3Gtq3Zw6ziLGNPzrYx7946Tr6/ee/XeCQ4D3ykPtL5tHno4n0d/h3+xfuWHGLX81cn7r0iTNzjr7LrlxCqPtkbTQEHeqOrTy4Yyt3VCi/IOB0v7rVC7q45Q3Gr5K6jt+3Gl5nCoDD4MtO+j96Wu8atmhGqcNGHObuf8OM/x3AMx38+4Z2sPqzCxRFK2aF2e5Jol56XTLyggAMTL56XOMoS1W4pOyjUcGGQdZxU6qRh7B9Zp+PfpOFlqt0zyDZckPi1ttmIp03jX8gyJ8a/PG2yutpS/Vol7peZIbZcKBAEEheEIAgFbDkz5H6Zrkm2hVWGiXKiF4Ycw0RWKdtC16Q7qe3X4iOMxruonzegJzWaXFrU9utOSsLUmrc0YjeWYjCW4PDMADElpJSSQ0vQvA1Tm6/JlKnqFs1EGyZiFCqnRZTEJJJiKRYzVYzJck2Rm6P4iH+cmSY0YzimYa8l0EtTODFWhcMIMVqdsI2uiTvKmTisIDHJ3od5GILVhBCarCfVRmo4uTjkhrhzkiBV7SsaqS+TzrzM1qpGGUFt28pIySQHR6h7F6KSwGWm97ay+Z+ZqMcEjEWebE7wxCSQwpkhJqoZA5ivCdZDjJepuJ9IQjGGUmuXJdBFUygxVqVsxFsLMbDe8ZbDYVCGKxs+W080max1hFCarCfV+C1KATwcnvE9gRRuMP2prdbWGowm1KB1y+zwMMENkM755cJ2yPDtqhTI6ED1M/82yIDtC/4j4BijjeObflpO9I9MwXTCsSX8jWAFeHr05WoLTJ5G8IQVS/7vwR6ohirYM7f6HzYpogfS3R2OAAAAAElFTkSuQmCC);width:36px;height:36px}.leaflet-retina .leaflet-control-layers-toggle{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAQAAABvcdNgAAAEsklEQVR4AWL4TydIhpZK1kpWOlg0w3ZXP6D2soBtG42jeI6ZmQTHzAxiTbSJsYLjO9HhP+WOmcuhciVnmHVQcJnp7DFvScowZorad/+V/fVzMdMT2g9Cv9guXGv/7pYOrXh2U+RRR3dSd9JRx6bIFc/ekqHI29JC6pJ5ZEh1yWkhkbcFeSjxgx3L2m1cb1C7bceyxA+CNjT/Ifff+/kDk2u/w/33/IeCMOSaWZ4glosqT3DNnNZQ7Cs58/3Ce5HL78iZH/vKVIaYlqzfdLu8Vi7dnvUbEza5Idt36tquZFldl6N5Z/POLof0XLK61mZCmJSWjVF9tEjUluu74IUXvgttuVIHE7YxSkaYhJZam7yiM9Pv82JYfl9nptxZaxMJE4YSPty+vF0+Y2up9d3wwijfjZbabqm/3bZ9ecKHsiGmRflnn1MW4pjHf9oLufyn2z3y1D6n8g8TZhxyzipLNPnAUpsOiuWimg52psrTZYnOWYNDTMuWBWa0tJb4rgq1UvmutpaYEbZlwU3CLJm/ayYjHW5/h7xWLn9Hh1vepDkyf7dE7MtT5LR4e7yYpHrkhOUpEfssBLq2pPhAqoSWKUkk7EDqkmK6RrCEzqDjhNDWNE+XSMvkJRDWlZTmCW0l0PHQGRZY5t1L83kT0Y3l2SItk5JAWHl2dCOBm+fPu3fo5/3v61RMCO9Jx2EEYYhb0rmNQMX/vm7gqOEJLcXTGw3CAuRNeyaPWwjR8PRqKQ1PDA/dpv+on9Shox52WFnx0KY8onHayrJzm87i5h9xGw/tfkev0jGsQizqezUKjk12hBMKJ4kbCqGPVNXudyyrShovGw5CgxsRICxF6aRmSjlBnHRzg7Gx8fKqEubI2rahQYdR1YgDIRQO7JvQyD52hoIQx0mxa0ODtW2Iozn1le2iIRdzwWewedyZzewidueOGqlsn1MvcnQpuVwLGG3/IR1hIKxCjelIDZ8ldqWz25jWAsnldEnK0Zxro19TGVb2ffIZEsIO89EIEDvKMPrzmBOQcKQ+rroye6NgRRxqR4U8EAkz0CL6uSGOm6KQCdWjvjRiSP1BPalCRS5iQYiEIvxuBMJEWgzSoHADcVMuN7IuqqTeyUPq22qFimFtxDyBBJEwNyt6TM88blFHao/6tWWhuuOM4SAK4EI4QmFHA+SEyWlp4EQoJ13cYGzMu7yszEIBOm2rVmHUNqwAIQabISNMRstmdhNWcFLsSm+0tjJH1MdRxO5Nx0WDMhCtgD6OKgZeljJqJKc9po8juskR9XN0Y1lZ3mWjLR9JCO1jRDMd0fpYC2VnvjBSEFg7wBENc0R9HFlb0xvF1+TBEpF68d+DHR6IOWVv2BECtxo46hOFUBd/APU57WIoEwJhIi2CdpyZX0m93BZicktMj1AS9dClteUFAUNUIEygRZCtik5zSxI9MubTBH1GOiHsiLJ3OCoSZkILa9PxiN0EbvhsAo8tdAf9Seepd36lGWHmtNANTv5Jd0z4QYyeo/UEJqxKRpg5LZx6btLPsOaEmdMyxYdlc8LMaJnikDlhclqmPiQnTEpLUIZEwkRagjYkEibQErwhkTAKCLQEbUgkzJQWc/0PstHHcfEdQ+UAAAAASUVORK5CYII=);background-size:26px 26px}.leaflet-touch .leaflet-control-layers-toggle{width:44px;height:44px}.leaflet-control-layers .leaflet-control-layers-list,.leaflet-control-layers-expanded .leaflet-control-layers-toggle{display:none}.leaflet-control-layers-expanded .leaflet-control-layers-list{display:block;position:relative}.leaflet-control-layers-expanded{padding:6px 10px 6px 6px;color:#333;background:#fff}.leaflet-control-layers-scrollbar{overflow-y:scroll;overflow-x:hidden;padding-right:5px}.leaflet-control-layers-selector{margin-top:2px;position:relative;top:1px}.leaflet-control-layers label{display:block;font-size:13px;font-size:1.08333em}.leaflet-control-layers-separator{height:0;border-top:1px solid #ddd;margin:5px -10px 5px -6px}.leaflet-default-icon-path{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=)}.leaflet-container .leaflet-control-attribution{background:#fff;background:rgba(255,255,255,.8);margin:0}.leaflet-control-attribution,.leaflet-control-scale-line{padding:0 5px;color:#333;line-height:1.4}.leaflet-control-attribution a{text-decoration:none}.leaflet-control-attribution a:hover,.leaflet-control-attribution a:focus{text-decoration:underline}.leaflet-attribution-flag{display:inline!important;vertical-align:baseline!important;width:1em;height:.6669em}.leaflet-left .leaflet-control-scale{margin-left:5px}.leaflet-bottom .leaflet-control-scale{margin-bottom:5px}.leaflet-control-scale-line{border:2px solid #777;border-top:none;line-height:1.1;padding:2px 5px 1px;white-space:nowrap;overflow:hidden;-moz-box-sizing:border-box;box-sizing:border-box;background:#fff;background:rgba(255,255,255,.5)}.leaflet-control-scale-line:not(:first-child){border-top:2px solid #777;border-bottom:none;margin-top:-2px}.leaflet-control-scale-line:not(:first-child):not(:last-child){border-bottom:2px solid #777}.leaflet-touch .leaflet-control-attribution,.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{box-shadow:none}.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{border:2px solid rgba(0,0,0,.2);background-clip:padding-box}.leaflet-popup{position:absolute;text-align:center;margin-bottom:20px}.leaflet-popup-content-wrapper{padding:1px;text-align:left;border-radius:12px}.leaflet-popup-content{margin:13px 24px 13px 20px;line-height:1.3;font-size:13px;font-size:1.08333em;min-height:1px}.leaflet-popup-content p{margin:1.3em 0}.leaflet-popup-tip-container{width:40px;height:20px;position:absolute;left:50%;margin-top:-1px;margin-left:-20px;overflow:hidden;pointer-events:none}.leaflet-popup-tip{width:17px;height:17px;padding:1px;margin:-10px auto 0;pointer-events:auto;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:white;color:#333;box-shadow:0 3px 14px #0006}.leaflet-container a.leaflet-popup-close-button{position:absolute;top:0;right:0;border:none;text-align:center;width:24px;height:24px;font:16px/24px Tahoma,Verdana,sans-serif;color:#757575;text-decoration:none;background:transparent}.leaflet-container a.leaflet-popup-close-button:hover,.leaflet-container a.leaflet-popup-close-button:focus{color:#585858}.leaflet-popup-scrolled{overflow:auto}.leaflet-oldie .leaflet-popup-content-wrapper{-ms-zoom:1}.leaflet-oldie .leaflet-popup-tip{width:24px;margin:0 auto;-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";filter:progid:DXImageTransform.Microsoft.Matrix(M11=.70710678,M12=.70710678,M21=-.70710678,M22=.70710678)}.leaflet-oldie .leaflet-control-zoom,.leaflet-oldie .leaflet-control-layers,.leaflet-oldie .leaflet-popup-content-wrapper,.leaflet-oldie .leaflet-popup-tip{border:1px solid #999}.leaflet-div-icon{background:#fff;border:1px solid #666}.leaflet-tooltip{position:absolute;padding:6px;background-color:#fff;border:1px solid #fff;border-radius:3px;color:#222;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;box-shadow:0 1px 3px #0006}.leaflet-tooltip.leaflet-interactive{cursor:pointer;pointer-events:auto}.leaflet-tooltip-top:before,.leaflet-tooltip-bottom:before,.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{position:absolute;pointer-events:none;border:6px solid transparent;background:transparent;content:""}.leaflet-tooltip-bottom{margin-top:6px}.leaflet-tooltip-top{margin-top:-6px}.leaflet-tooltip-bottom:before,.leaflet-tooltip-top:before{left:50%;margin-left:-6px}.leaflet-tooltip-top:before{bottom:0;margin-bottom:-12px;border-top-color:#fff}.leaflet-tooltip-bottom:before{top:0;margin-top:-12px;margin-left:-6px;border-bottom-color:#fff}.leaflet-tooltip-left{margin-left:-6px}.leaflet-tooltip-right{margin-left:6px}.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{top:50%;margin-top:-6px}.leaflet-tooltip-left:before{right:0;margin-right:-12px;border-left-color:#fff}.leaflet-tooltip-right:before{left:0;margin-left:-12px;border-right-color:#fff}@media print{.leaflet-control{-webkit-print-color-adjust:exact;print-color-adjust:exact}}.marker-cluster-small{background-color:#b5e28c99}.marker-cluster-small div{background-color:#6ecc3999}.marker-cluster-medium{background-color:#f1d35799}.marker-cluster-medium div{background-color:#f0c20c99}.marker-cluster-large{background-color:#fd9c7399}.marker-cluster-large div{background-color:#f1801799}.leaflet-oldie .marker-cluster-small{background-color:#b5e28c}.leaflet-oldie .marker-cluster-small div{background-color:#6ecc39}.leaflet-oldie .marker-cluster-medium{background-color:#f1d357}.leaflet-oldie .marker-cluster-medium div{background-color:#f0c20c}.leaflet-oldie .marker-cluster-large{background-color:#fd9c73}.leaflet-oldie .marker-cluster-large div{background-color:#f18017}.marker-cluster{background-clip:padding-box;border-radius:20px}.marker-cluster div{width:30px;height:30px;margin-left:5px;margin-top:5px;text-align:center;border-radius:15px;font:12px Helvetica Neue,Arial,Helvetica,sans-serif}.marker-cluster span{line-height:30px}.leaflet-cluster-anim .leaflet-marker-icon,.leaflet-cluster-anim .leaflet-marker-shadow{-webkit-transition:-webkit-transform .3s ease-out,opacity .3s ease-in;-moz-transition:-moz-transform .3s ease-out,opacity .3s ease-in;-o-transition:-o-transform .3s ease-out,opacity .3s ease-in;transition:transform .3s ease-out,opacity .3s ease-in}.leaflet-cluster-spider-leg{-webkit-transition:-webkit-stroke-dashoffset .3s ease-out,-webkit-stroke-opacity .3s ease-in;-moz-transition:-moz-stroke-dashoffset .3s ease-out,-moz-stroke-opacity .3s ease-in;-o-transition:-o-stroke-dashoffset .3s ease-out,-o-stroke-opacity .3s ease-in;transition:stroke-dashoffset .3s ease-out,stroke-opacity .3s ease-in}.leaflet-control-velocity{background-color:#ffffffb3;padding:0 5px;margin:0!important;color:#333;font:11px/1.5 Helvetica Neue,Arial,Helvetica,sans-serif}.velocity-overlay{position:absolute;z-index:1}a[data-v-88863373],a b[data-v-88863373]{display:block}.addresssm[data-v-88863373]{color:var(--app-textcolor);font-size:.7em}section[data-v-88863373]{justify-content:space-between}section[data-v-88863373]:not(:last-child){padding-bottom:var(--gap);border-bottom:1px solid var(--app-textcolor)}button[data-v-88863373]{border:0;cursor:pointer;font-size:1.2em;transition:color .2s ease-in}button[data-v-88863373]:hover{color:var(--color-red)}.mapcontrols[data-v-0e5a211e]{bottom:0;box-sizing:border-box;display:flex;justify-content:space-between;left:0;padding:0 var(--app-controlsgap) var(--app-controlsgap);position:absolute;right:0;z-index:12;pointer-events:none}.mapcontrols>*[data-v-0e5a211e]{pointer-events:all}.popover-bottom-right[data-v-0e5a211e],.popover-bottom-left[data-v-0e5a211e]{bottom:calc(var(--app-inputheight) + var(--app-controlsgap) * 2);max-width:calc(100vw - var(--app-controlsgap) * 2)}.popover-bottom-right[data-v-0e5a211e]{right:var(--app-controlsgap)}.popover-bottom-left[data-v-0e5a211e]{left:var(--app-controlsgap)}.popovercontrol.active{border-color:var(--color-green)}.popovercontrol.active path{fill:var(--color-green)!important}.leaflet-control-attribution,.leaflet-container .leaflet-control-attribution{font-size:calc(var(--font-size) * .5);background:none;margin:0!important}.leaflet-bottom .leaflet-control-locate{border:var(--app-borderwidth) solid var(--app-bordercolor)}.leaflet-bottom .leaflet-control-locate .leaflet-bar-part-single{background:var(--app-inputbg)}.leaflet-right .leaflet-control{margin-right:var(--gap)}.leaflet-bottom .leaflet-control{margin-bottom:.3rem}.leaflet-control-locate a .leaflet-control-locate-location-arrow,.leaflet-control-locate.following a .leaflet-control-locate-location-arrow{background:var(--app-bordercolor)}.leaflet-touch .leaflet-bar,.leaflet-touch .leaflet-bar a,.leaflet-bar a,.leaflet-bar{border-radius:50%!important}.leaflet-touch .leaflet-bar a,.leaflet-bar a{width:calc(var(--app-inputheight) - var(--app-borderwidth) * 2);height:calc(var(--app-inputheight) - var(--app-borderwidth) * 2);line-height:1;display:flex;align-items:center;justify-content:center;border-radius:50%!important}.marker-cluster-circle{border-width:2px;border-style:solid;border-radius:18px}.marker-cluster-circle span{line-height:27px;font-weight:700}.marker-cluster-msg{font-weight:700;background-size:contain;color:#fff;padding-top:4px;font-size:16px;width:40px!important;height:40px!important}.marker-icon-brand{width:35px!important;height:35px!important;border-radius:50%}.marker-icon-msg{width:40px;height:40px}.mapcontainer[data-v-66a2c2ad]{background-color:var(--color-light-gray);position:absolute;top:0;left:0;z-index:0;width:100%;height:100svh;overflow:hidden}.mapcontainer.inactive[data-v-66a2c2ad]{filter:grayscale(100%)}.st0[data-v-1ca21f0d]{fill:#fff;stroke:#000;stroke-width:.5;stroke-miterlimit:10}header[data-v-a4474917]{left:0;padding:var(--app-controlsgap);position:absolute;top:0;width:100vw;z-index:10;pointer-events:none}header>*[data-v-a4474917]{pointer-events:all}.appicon[data-v-a4474917]{border-radius:.5rem;display:block;overflow:hidden;user-select:none;width:2.5rem}.appicon img[data-v-a4474917]{display:block;max-width:100%}.popover-top-right[data-v-a4474917]{top:calc(var(--gap) * 3 + var(--app-inputheight));right:var(--gap);width:500px;max-width:calc(100vw - var(--gap) * 2)}@supports not selector(:popover-open){.popover-top-right[data-v-a4474917]{right:var(--gap)!important}}#about p[data-v-a4474917]{font-size:.9em}.navlinks[data-v-a4474917]{font-weight:700}.navlinks a[data-v-a4474917]{display:block}.navlinks a[data-v-a4474917]:not(:last-child){margin-bottom:calc(var(--gap) * .5)}.sensorscount[data-v-a4474917]{color:#fff;background:var(--color-orange);padding:4px 10px;display:block;border-radius:5px;display:flex;gap:10px;align-items:center}.sensorscount svg[data-v-a4474917]{width:22px}.install-pwa__container[data-v-b59a209f]{position:relative;display:flex;align-items:center;justify-content:space-between;background-color:#fff;z-index:10}.install-pwa__content img[data-v-b59a209f]{width:36px;height:36px;border-radius:5px}.install-pwa__content[data-v-b59a209f]{display:flex;align-items:center;gap:var(--gap)}.install-pwa__content h3[data-v-b59a209f]{margin:0;margin-bottom:calc(var(--gap) * .2);font-size:calc(var(--font-size) * .8);text-transform:none}.install-pwa__btn[data-v-b59a209f]{padding:calc(var(--gap) * .2) calc(var(--gap) * 1.8);font-weight:700;font-family:var(--font-family--normal);color:#fff;background-color:#3658c6;border-radius:15px;border:none;cursor:pointer}.install-pwa__remove[data-v-b59a209f]{width:20px;height:20px;background-image:url('data:image/svg+xml,');background-position:center;background-repeat:no-repeat;border:none;cursor:pointer}h2[data-v-c5bfb7c2]{margin-bottom:calc(var(--gap) * .7)}.sensors-panel[data-v-c5bfb7c2]{position:absolute;top:40px;bottom:0;right:0;z-index:14;width:48%}.sensor-popup.popup-js[data-v-c5bfb7c2]{padding-right:0!important;background-color:var(--sensor-popup-bg)}.sensor-popup.container[data-v-c5bfb7c2]{padding:0;padding-bottom:calc(var(--gap) * 6)}.sensor-popup .popup__close[data-v-c5bfb7c2]{right:calc(var(--gap) * 2);top:1.5rem;color:#fff}.sensor-popup__header[data-v-c5bfb7c2]{min-height:110px;padding:calc(var(--gap) * 2) var(--gap);display:flex;align-items:center;color:#fff}.sensor-popup__header-wrapper .fa-copy[data-v-c5bfb7c2]{margin-left:var(--gap)}.sensor-popup__header--neutral[data-v-c5bfb7c2]{background-color:#747a80}.sensor-popup__header--good[data-v-c5bfb7c2]{background-color:var(--color-green)}.sensor-popup__header--attention[data-v-c5bfb7c2]{background-color:var(--color-orange)}.sensor-popup__header--danger[data-v-c5bfb7c2]{background-color:var(--color-red)}.sensor-popup__header a[data-v-c5bfb7c2]{color:inherit}.sensor-popup__header-icon[data-v-c5bfb7c2]{font-size:3rem;margin-right:calc(var(--gap) * 2)}.sensor-popup--subtitle[data-v-c5bfb7c2]{display:flex;align-items:center;font-family:var(--font-family--normal);text-transform:none}.sensor-popup--subtitle span[data-v-c5bfb7c2]:not(:last-child){margin-right:calc(var(--gap) * 2)}ul.sensor-popup--data[data-v-c5bfb7c2]{display:flex;align-items:center;flex-wrap:wrap;list-style:none;padding:calc(var(--gap) * .7) 0}ul.sensor-popup--data .icon[data-v-c5bfb7c2]{display:inline-block;font-size:calc(var(--gap) * 1.5);text-align:center;width:calc(var(--gap) * 2.5)}.sensor-popup--content[data-v-c5bfb7c2]{height:80%;overflow-y:auto;padding:calc(var(--gap) * 2);padding-top:0;padding-right:calc(var(--gap) * 2.2);padding-bottom:calc(var(--gap) * 2);margin-top:var(--gap);margin-right:calc(var(--gap) * 2)}.sensor-popup--content img[data-v-c5bfb7c2]{max-width:100%;width:100%}@media screen and (max-width: 1080px){.sensors-panel[data-v-c5bfb7c2]{width:90%}}@media screen and (max-width: 580px){h2[data-v-c5bfb7c2]{font-size:1rem}.sensors-panel[data-v-c5bfb7c2]{position:absolute;top:calc(var(--gap) * 16);left:0;right:0;bottom:0;z-index:9;width:100%}.sensor-popup.container[data-v-c5bfb7c2]{padding-bottom:calc(var(--gap) * 5)}.sensor-popup .popup__close[data-v-c5bfb7c2]{right:var(--gap)}.sensor-popup__header[data-v-c5bfb7c2]{flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:var(--gap)}.sensor-popup__header-icon[data-v-c5bfb7c2]{font-size:2rem;line-height:1.5;margin-right:0}.sensor-popup--subtitle span[data-v-c5bfb7c2]:not(:last-child){margin-right:var(--gap)}}button[data-v-8cca7f79]{padding-right:calc(var(--app-inputpadding)*2);padding-left:calc(var(--app-inputpadding)*2)}.highcharts-legend-item{font-weight:900}.highcharts-legend-item .highcharts-graph,.highcharts-legend-item .highcharts-point{stroke:#000!important}.highcharts-legend-item .highcharts-point{fill:#000!important}.highcharts-legend-item-hidden text{fill:#999!important;color:#999!important;text-decoration:none!important}.highcharts-legend-item-hidden .highcharts-graph,.highcharts-legend-item-hidden .highcharts-point{stroke:#999!important}.highcharts-legend-item-hidden .highcharts-point{fill:#999!important}.copy[data-v-951f909f]{cursor:pointer}.fa-copy[data-v-951f909f],.fa-check[data-v-951f909f]{margin-left:calc(var(--gap) * .8);color:var(--color-blue)}.copy-btn[data-v-951f909f]{margin-left:calc(var(--gap) * .8);width:14px;height:16px;padding:calc(var(--gap) * .1);background-image:url("data:image/svg+xml,%0A%3Csvg width='14' height='17' viewBox='0 0 14 17' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.3752 0H12.3964C13.1986 0 13.8549 0.656284 13.8549 1.45841V10.9381C13.8549 11.3391 13.5267 11.6673 13.1257 11.6673C12.7246 11.6673 12.3964 11.3391 12.3964 10.9381V2.18761C12.3964 1.78655 12.0683 1.45841 11.6672 1.45841H4.3752C3.97414 1.45841 3.646 1.13027 3.646 0.729204C3.646 0.328142 3.97414 0 4.3752 0ZM1.45839 2.91682H9.47963C10.2818 2.91682 10.938 3.5731 10.938 4.37523V14.5841C10.938 15.3862 10.2818 16.0425 9.47963 16.0425H1.45839C0.656261 16.0425 -2.19345e-05 15.3862 -2.19345e-05 14.5841V4.37523C-2.19345e-05 3.5731 0.656261 2.91682 1.45839 2.91682ZM2.18759 14.5841H8.75043C9.15149 14.5841 9.47963 14.2559 9.47963 13.8549V5.10443C9.47963 4.70337 9.15149 4.37523 8.75043 4.37523H2.18759C1.78653 4.37523 1.45839 4.70337 1.45839 5.10443V13.8549C1.45839 14.2559 1.78653 14.5841 2.18759 14.5841Z' fill='%2303A5ED'/%3E%3C/svg%3E%0A");background-size:100%;background-position:center;background-repeat:no-repeat;border:none;cursor:pointer}@media screen and (max-width: 680px){.copy[data-v-951f909f]{font-size:calc(var(--font-size) * .8)}}.popup-js.active[data-v-cf7806f0]{container:popup / inline-size;background:var(--app-popoverbg);border-radius:0;bottom:0;box-sizing:border-box;color:var(--app-textcolor);padding:var(--gap);position:absolute;right:0;top:0;width:80vw;max-width:1000px;z-index:100}.scrollable-y[data-v-cf7806f0]{max-height:90%}.close[data-v-cf7806f0]{border:0;color:var(--app-textcolor);cursor:pointer;font-size:1.2em;position:absolute;right:var(--gap);top:var(--gap)}.close[data-v-cf7806f0]:hover{color:var(--color-red)}.flexline[data-v-cf7806f0]{gap:calc(var(--gap) * 2)}.flexline .flexline[data-v-cf7806f0]{gap:var(--gap)}h3.flexline[data-v-cf7806f0]{gap:calc(var(--gap) * .5);max-width:calc(100% - var(--gap) * 2)}.icontitle[data-v-cf7806f0]{display:inline-block;max-height:calc(var(--font-size) * 2)}@media screen and (max-width: 700px){.popup-js.active[data-v-cf7806f0]{left:0;width:100vw;top:30vw;padding-right:calc(var(--gap) * .5)}}@container popup (min-width: 400px){.close[data-v-cf7806f0]{font-size:1.6em}}@container popup (max-width: 400px){h3.flexline[data-v-cf7806f0]{max-width:calc(100% - var(--gap) * 3)}}.infoline.flexline[data-v-cf7806f0]{gap:calc(var(--gap) * .5)}.infoline-title[data-v-cf7806f0]{font-weight:700}.scalegrid[data-v-cf7806f0]{display:grid;grid-template-columns:repeat(3,1fr);gap:var(--gap);font-size:.8em}.scalegrid p[data-v-cf7806f0]{margin-bottom:calc(var(--gap) * .5)}.scales-color[data-v-cf7806f0]{position:relative;padding-left:calc(var(--gap) * 2)}.scales-color[data-v-cf7806f0]:before{content:"";display:block;position:absolute;background-color:var(--color);top:0;left:0;bottom:0;width:var(--gap)}.rt-title[data-v-cf7806f0]{font-weight:900}.rt-title[data-v-cf7806f0]:before{animation:blink infinite 1.5s;background-color:var(--color-green);border-radius:50%;content:"";display:inline-block;height:8px;margin-right:5px;vertical-align:middle;width:8px}.rt-time[data-v-cf7806f0]{font-size:.8em;font-weight:300;padding-left:13px}.rt-unit[data-v-cf7806f0],.rt-number[data-v-cf7806f0]{font-size:.8em;font-weight:900}.optout-form[data-v-ee8b7997]{padding:1.5rem .8rem;border:2px solid #333}.optout-form strong[data-v-ee8b7997]{padding-left:10px}.privacy-policy ul[data-v-168a0093]{padding-left:20px;list-style:disc}.privacy-policy__wrapper[data-v-168a0093]:not(:last-of-type){margin-bottom:3rem}.mb[data-v-10839161]{margin-bottom:calc(var(--gap) * 2)!important}.air-measurements__header p[data-v-10839161]{font-size:calc(var(--font-size) * .9);font-weight:500;line-height:1.7}.air-measurements__wrapper[data-v-10839161]:not(:last-of-type){margin-bottom:5rem}.air-measurements__header[data-v-10839161]{max-width:800px;margin:0 auto;margin-bottom:calc(var(--gap) * 2)}.air-measurements__content[data-v-10839161]{display:grid;grid-template-columns:350px 630px;justify-content:center;gap:calc(var(--gap) * 2);font-weight:500}.air-measurements__recs[data-v-10839161]{font-size:calc(var(--font-size) * .9)}.air-measurements ol[data-v-10839161]{padding-left:calc(var(--gap) * 1.5);margin-bottom:calc(var(--gap) * .5)}.air-measurements ul li[data-v-10839161]{width:100%;padding:calc(var(--gap) * .5) calc(var(--gap) * .9);color:var(--color-light);font-size:calc(var(--font-size) * .8);font-weight:900}.air-measurements .green[data-v-10839161]{background-color:var(--color-green)}.air-measurements .blue[data-v-10839161]{background-color:var(--color-teal)}.air-measurements .navy[data-v-10839161]{background-color:var(--color-navy)}.air-measurements .orange[data-v-10839161]{background-color:var(--color-orange)}.air-measurements .red[data-v-10839161]{background-color:var(--color-bright-red)}.air-measurements .purple[data-v-10839161]{background-color:var(--color-purple)}@media screen and (max-width: 880px){.air-measurements__content[data-v-10839161]{grid-template-columns:1fr;gap:var(--gap)}}*{margin:0;padding:0;outline:0;background:transparent;vertical-align:baseline;box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}img{border:0}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,main{display:block}ul{list-style:none}table{border-collapse:collapse;border-spacing:0}input,select{vertical-align:middle}sup{vertical-align:super}sub{vertical-align:sub}:root{--color-light: #fff;--color-gray: #4e4e4f;--color-middle-gray: #B6BDC4;--color-light-gray: #d5d3d3;--color-dark: #000;--color-blue: #03a5ed;--color-teal: #12bfcc;--color-green: #60bc2a;--color-red: #fc0202;--color-bright-red: #ff4d00;--color-yellow: #f5ff00;--color-orange: #ff9d00;--color-purple: #7a00da;--color-navy: hsl(219, 63%, 45%);--color-link: var(--color-blue);--color-link-hover: var(--color-green);--font-family--normal: "Noto Sans", sans-serif;--font-size: 1rem;--gap: 1rem;--sensor-popup-bg: #ffffff;--main-bg: #ffffff;--app-borderwidth: 2px;--app-bordercolor: #000;--app-inputbg: #fff;--app-inputpadding: .4rem;--app-inputbradius: .3rem;--app-textcolor: #000;--app-inputheight: 2.4rem;--app-buttoncolor:hsl(219, 63%, 45%);--app-buttoncolor-active:hsl(219, 63%, 60%);--app-buttoncolor-hover:hsl(219, 63%, 35%);--app-buttontextcolor: #fff;--app-popoverbg: #fff;--app-controlsgap: calc(var(--gap) * 2)}@media screen and (max-width: 500px){:root{--font-size: .8rem;--gap: .5rem}.leaflet-bottom .leaflet-control{margin-bottom:0}}@font-face{font-family:Noto Sans;src:url(./notosansdisplay-black-webfont.9f247781.woff2) format("woff2");src:url(./notosansdisplay-black-webfont.00b4a963.woff) format("woff");font-weight:900;font-display:swap;font-style:normal}@font-face{font-family:Noto Sans;src:url(./notosans-bold-webfont.b1ab6654.woff2) format("woff2");src:url(./notosans-bold-webfont.8b1ca092.woff) format("woff");font-weight:700;font-display:swap;font-style:normal}@font-face{font-family:Noto Sans;src:url(./notosansdisplay-medium-webfont.5dca4cb1.woff2) format("woff2");src:url(./notosansdisplay-medium-webfont.cf14dc66.woff) format("woff");font-weight:500;font-display:swap;font-style:normal}@font-face{font-family:Noto Sans;src:url(./notosans-regular-webfont.7d4a5d04.woff2) format("woff2");src:url(./notosans-regular-webfont.c3dfba11.woff) format("woff");font-weight:400;font-display:swap;font-style:normal}body{font-size:var(--font-size);font-family:var(--font-family--normal);background-color:var(--color-light)}a{color:var(--color-link);text-decoration:none}a:hover{color:var(--color-link-hover)}p:not(:last-child),ul:not(:last-child),ol:not(:last-child),dl:not(:last-child),h2,h3,h4,h5{margin-bottom:var(--gap)}h1,h2,h3,h4,h5{font-weight:900}h1{font-size:calc(var(--font-size) * 2);font-weight:900;margin-bottom:calc(var(--gap) * 3)}li,dd{margin-bottom:calc(var(--gap) * .5)}hr{margin:calc(var(--gap)*2) 0;border:.5px solid var(--app-bordercolor)}input,select,.button{background-color:var(--app-inputbg);border-radius:var(--app-inputbradius);border:var(--app-borderwidth) solid var(--app-bordercolor);box-sizing:border-box;color:var(--app-textcolor);font-family:var(--font-family--normal);font-size:var(--font-size);font-weight:700;height:var(--app-inputheight);line-height:1;padding:calc(var(--app-inputpadding) * .8) var(--app-inputpadding);transition-duration:.33s;transition-property:border,background-color;transition-timing-function:ease-in-out}input.block,select.block,.button.block{display:block;width:100%}select{appearance:none;background-image:url("data:image/svg+xml;utf8,");background-position-x:calc(100% - var(--app-inputpadding));background-position-y:50%;background-repeat:no-repeat;background-size:.5rem;padding-right:calc(var(--app-inputpadding) * 1.5 + .5rem);user-select:none}input[type=text]:focus,input[type=password]:focus{--app-bordercolor: var(--color-navy)}input[type=checkbox]{border:var(--app-borderwidth) solid var(--app-bordercolor);height:calc(var(--app-inputheight) * .5);width:calc(var(--app-inputheight) * .5)}input[type=checkbox]:not(:last-child){margin-right:calc(var(--gap) * .5)}input[type=submit],.button{background-color:var(--app-buttoncolor);border-color:var(--app-buttoncolor);color:var(--app-buttontextcolor)}input[type=submit]:not(:disabled):active,.button:not(:disabled):active{--app-buttoncolor: var(--app-buttoncolor-active)}input[type=submit]:not(:disabled):hover,.button:not(:disabled):hover{--app-buttoncolor: var(--app-buttoncolor-hover)}select:not([disabled]),input[type=checkbox]:not([disabled]),input[type=submit]:not([disabled]),.button:not([disabled]){cursor:pointer}.button-green{--app-buttoncolor: var(--color-green)}.button>*:not(:last-child){margin-right:calc(var(--gap) * .5)}label{font-weight:700}:popover-open{background-color:var(--app-popoverbg);box-shadow:0 4px 8px #0003,0 6px 20px #00000030;border-radius:var(--app-inputbradius);border:none;inset:unset;padding:var(--gap)}[popovertarget]{transition:opacity .3s ease-in-out}:popover-open~[popovertarget]{opacity:.6}:popover-open::backdrop{backdrop-filter:grayscale(1)}.popovercontrol{align-items:center;background-color:var(--app-inputbg);border-radius:50%;border:var(--app-borderwidth) solid var(--app-bordercolor);cursor:pointer;display:flex;height:var(--app-inputheight);justify-content:center;user-select:none;width:var(--app-inputheight);color:var(--app-textcolor);font-size:var(--font-size)}.popovercontrol .svg-inline--fa path{fill:var(--app-textcolor)}@supports not selector(:popover-open){.popover{background-color:#fff;inset:unset;border:0;padding:var(--gap)}}.scrollable-y{overflow-y:auto;max-height:100%}::-webkit-scrollbar{width:7px}::-webkit-scrollbar-track{border-radius:4px;background:#EAEAEA}::-webkit-scrollbar-thumb{border-radius:4px;background:#A5A5A5}.flexline{display:flex;gap:var(--gap);align-items:center}.flexline.space-between{justify-content:space-between}.flexline.align-start{align-items:start}.clipoverflow{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.textsmall{font-size:.8em}section:not(:last-child){margin-bottom:calc(var(--gap) * 2)}#app{position:relative;max-width:100vw;min-height:100svh}#app.map{overflow:hidden}.container{padding:calc(var(--gap) * .5) var(--gap)}.container-pagetext{padding:calc(var(--gap) * 7) var(--gap) calc(var(--gap) * 3);margin:0 auto;max-width:1200px}.sensors-container{padding-top:2rem;display:inline-flex;flex-direction:column}@media screen and (max-width: 680px){.sensors-container{display:flex}}.title{margin:0;font-size:12px;font-weight:700;transition:color .33s ease-in-out,background-color .33s ease-in-out}.subtitle{margin:0;font-size:14px;font-weight:600;font-family:var(--font-family--normal);transition:color .33s ease-in-out,background-color .33s ease-in-out}.text{font-family:var(--font-family--normal);font-weight:400;text-transform:none;line-height:1.5;text-align:justify!important;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;hyphens:auto;transition:color .33s ease-in-out,background-color .33s ease-in-out}@media (prefers-color-scheme: dark){.text-changabletheme{color:var(--color-light)}}.text-small{font-size:.8em}.text-tip{margin-top:var(--gap);font-family:var(--font-family--normal);color:var(--color-dark);font-weight:400;font-style:italic;text-transform:none}.sensors-screen{position:relative;width:100vw;height:100vh;overflow:hidden;transition:color .33s ease-in-out,background-color .33s ease-in-out}.sensors-screen-layers{display:flex;flex-direction:column;pointer-events:none;position:relative;width:100%;height:100%;z-index:1000;transition:color .33s ease-in-out,background-color .33s ease-in-out}.sensors-screen-layers--center{flex:1 0 auto;position:relative}*[class*=sensors-panel--center-]{position:absolute;top:calc(var(--gap) * 5);bottom:var(--gap);z-index:10;width:48%}.sensors-panel--center-right{right:var(--gap)}.sensors-panel--center-left{left:var(--gap)}*[class*=sensors-panel--center-] .sensors-panel:not(:last-child){margin-bottom:var(--gap)}.dark .sensors-screen.loading{background-color:#424241}.sensors-screen.loading{display:flex;align-items:center;justify-content:center;background-color:var(--color-light);z-index:9999}.sensors-container .fa-compass{display:none}.sensors-screen.loading .fa-spin{display:block;position:fixed;z-index:100;top:calc(50% - 2rem);left:calc(50% - 2rem);font-size:4rem;color:var(--color-link)}.popup,.popup-js{background-color:var(--color-light);color:var(--color-dark);display:none;opacity:0;position:relative;transform:translateY(20px);transition:color .33s ease-in-out,background-color .33s ease-in-out}.popup:target,.popup-js.active{display:block;animation:popup .2s linear .2s forwards}.popup-wrapper{position:absolute;top:calc(var(--gap) * 3);z-index:10}@keyframes popup{to{opacity:1;transform:translateY(0)}}.popup__close{color:var(--color-dark);font-size:calc(var(--gap) * 1.8);position:absolute;right:calc(var(--gap) * .5);top:calc(var(--gap) * .5);background-color:transparent}.popup__close svg{display:block}.popup__content{max-height:500px;overflow-y:auto}.header .popup__content h3{text-transform:none;margin-bottom:var(--gap)}.header .sensors-panel-top-nav-content h3{margin-top:calc(var(--gap) * 1.5);margin-bottom:calc(var(--gap) * .5)}.sensors-panel-top-nav-content .nav__item{padding:.2rem 0;margin-bottom:0}.sensors-panel-top-nav-content .nav__link{font-family:var(--font-family--normal);font-weight:300;font-size:calc(var(--font-size) * .85);color:var(--color-blue);text-transform:none}.header .popup__content .text{font-size:calc(var(--font-size) * .85);text-align:left!important}.header__close-popup,.footer__close-popup{align-self:flex-end;width:20px;height:20px;margin-bottom:var(--gap);background-image:url('data:image/svg+xml,');background-position:center;background-repeat:no-repeat;border:none;cursor:pointer}.dark .header__close-popup,.dark .footer__close-popup{background-image:url('data:image/svg+xml,')}.overlay{position:fixed;left:0;top:0;width:100%;height:100%;background-color:#0009;z-index:15;opacity:0;visibility:hidden}.overlay.open{opacity:1;visibility:visible;transition:all .3s}.sensors-dateselect input[type=date]{padding:.2rem .5rem;border-width:2px;font:inherit}.sensors-dateselect span{display:inline-block;color:var(--color-dark);vertical-align:middle}.dark .sensors-dateselect span{color:var(--color-middle-gray)}.sensors-dateselect .sensors-switcher label{margin:0 .4rem 0 1.2rem}@media screen and (max-width: 1250px){.sensors-panel--bottom{align-items:flex-start}.sensors-panel--bottom .sensors-switcher{display:block;margin-top:calc(var(--gap) * .5)}.sensors-dateselect .sensors-switcher label{margin:0}}@media screen and (max-width: 600px){.sensors-panel--bottom{display:block}.sensors-panel--bottom .sensors-panel-section:not(:last-child){margin-bottom:var(--gap)}}@keyframes fadeIn{to{opacity:1;visibility:visible}}@keyframes blink{0%{opacity:.5}50%{opacity:1}to{opacity:.5}} diff --git a/assets/index.1b734f7a.js b/assets/index.994c6d4a.js similarity index 94% rename from assets/index.1b734f7a.js rename to assets/index.994c6d4a.js index 3774d23..18e2b10 100644 --- a/assets/index.1b734f7a.js +++ b/assets/index.994c6d4a.js @@ -1,4 +1,4 @@ -var Gl=Object.defineProperty;var ql=(e,t,r)=>t in e?Gl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Zl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Xe=(e,t,r)=>(ql(e,typeof t!="symbol"?t+"":t,r),r),ga=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var ir=(e,t,r)=>(ga(e,t,"read from private field"),r?r.call(e):t.get(e)),Er=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ln=(e,t,r,n)=>(ga(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var xr=(e,t,r)=>(ga(e,t,"access private method"),r);var cc=Zl((exports,module)=>{(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function r(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerpolicy&&(a.referrerPolicy=o.referrerpolicy),o.crossorigin==="use-credentials"?a.credentials="include":o.crossorigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(o){if(o.ep)return;o.ep=!0;const a=r(o);fetch(o.href,a)}})();var commonjsGlobal$2=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function getAugmentedNamespace(e){var t=e.default;if(typeof t=="function"){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}),r}var buffer$1={},base64Js={};base64Js.byteLength=byteLength;base64Js.toByteArray=toByteArray;base64Js.fromByteArray=fromByteArray;var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code$4="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i$1=0,len=code$4.length;i$10)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function byteLength(e){var t=getLens(e),r=t[0],n=t[1];return(r+n)*3/4-n}function _byteLength(e,t,r){return(t+r)*3/4-r}function toByteArray(e){var t,r=getLens(e),n=r[0],o=r[1],a=new Arr(_byteLength(e,n,o)),l=0,c=o>0?n-4:n,u;for(u=0;u>16&255,a[l++]=t>>8&255,a[l++]=t&255;return o===2&&(t=revLookup[e.charCodeAt(u)]<<2|revLookup[e.charCodeAt(u+1)]>>4,a[l++]=t&255),o===1&&(t=revLookup[e.charCodeAt(u)]<<10|revLookup[e.charCodeAt(u+1)]<<4|revLookup[e.charCodeAt(u+2)]>>2,a[l++]=t>>8&255,a[l++]=t&255),a}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[e&63]}function encodeChunk(e,t,r){for(var n,o=[],a=t;ac?c:l+a));return n===1?(t=e[r-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}var ieee754={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ieee754.read=function(e,t,r,n,o){var a,l,c=o*8-n-1,u=(1<>1,b=-7,x=r?o-1:0,S=r?-1:1,$=e[t+x];for(x+=S,a=$&(1<<-b)-1,$>>=-b,b+=c;b>0;a=a*256+e[t+x],x+=S,b-=8);for(l=a&(1<<-b)-1,a>>=-b,b+=n;b>0;l=l*256+e[t+x],x+=S,b-=8);if(a===0)a=1-g;else{if(a===u)return l?NaN:($?-1:1)*(1/0);l=l+Math.pow(2,n),a=a-g}return($?-1:1)*l*Math.pow(2,a-n)};ieee754.write=function(e,t,r,n,o,a){var l,c,u,g=a*8-o-1,b=(1<>1,S=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,$=n?0:a-1,k=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,l=b):(l=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-l))<1&&(l--,u*=2),l+x>=1?t+=S/u:t+=S*Math.pow(2,1-x),t*u>=2&&(l++,u/=2),l+x>=b?(c=0,l=b):l+x>=1?(c=(t*u-1)*Math.pow(2,o),l=l+x):(c=t*Math.pow(2,x-1)*Math.pow(2,o),l=0));o>=8;e[r+$]=c&255,$+=k,c/=256,o-=8);for(l=l<0;e[r+$]=l&255,$+=k,l/=256,g-=8);e[r+$-k]|=T*128};/*! +var Gl=Object.defineProperty;var ql=(e,t,r)=>t in e?Gl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Xe=(e,t,r)=>(ql(e,typeof t!="symbol"?t+"":t,r),r),ga=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var ir=(e,t,r)=>(ga(e,t,"read from private field"),r?r.call(e):t.get(e)),Er=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ln=(e,t,r,n)=>(ga(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var xr=(e,t,r)=>(ga(e,t,"access private method"),r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function r(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerpolicy&&(a.referrerPolicy=o.referrerpolicy),o.crossorigin==="use-credentials"?a.credentials="include":o.crossorigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(o){if(o.ep)return;o.ep=!0;const a=r(o);fetch(o.href,a)}})();var commonjsGlobal$2=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function getAugmentedNamespace(e){var t=e.default;if(typeof t=="function"){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}),r}var buffer$1={},base64Js={};base64Js.byteLength=byteLength;base64Js.toByteArray=toByteArray;base64Js.fromByteArray=fromByteArray;var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code$4="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i$1=0,len=code$4.length;i$10)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function byteLength(e){var t=getLens(e),r=t[0],n=t[1];return(r+n)*3/4-n}function _byteLength(e,t,r){return(t+r)*3/4-r}function toByteArray(e){var t,r=getLens(e),n=r[0],o=r[1],a=new Arr(_byteLength(e,n,o)),l=0,c=o>0?n-4:n,u;for(u=0;u>16&255,a[l++]=t>>8&255,a[l++]=t&255;return o===2&&(t=revLookup[e.charCodeAt(u)]<<2|revLookup[e.charCodeAt(u+1)]>>4,a[l++]=t&255),o===1&&(t=revLookup[e.charCodeAt(u)]<<10|revLookup[e.charCodeAt(u+1)]<<4|revLookup[e.charCodeAt(u+2)]>>2,a[l++]=t>>8&255,a[l++]=t&255),a}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[e&63]}function encodeChunk(e,t,r){for(var n,o=[],a=t;ac?c:l+a));return n===1?(t=e[r-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}var ieee754={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ieee754.read=function(e,t,r,n,o){var a,l,c=o*8-n-1,u=(1<>1,b=-7,x=r?o-1:0,S=r?-1:1,$=e[t+x];for(x+=S,a=$&(1<<-b)-1,$>>=-b,b+=c;b>0;a=a*256+e[t+x],x+=S,b-=8);for(l=a&(1<<-b)-1,a>>=-b,b+=n;b>0;l=l*256+e[t+x],x+=S,b-=8);if(a===0)a=1-g;else{if(a===u)return l?NaN:($?-1:1)*(1/0);l=l+Math.pow(2,n),a=a-g}return($?-1:1)*l*Math.pow(2,a-n)};ieee754.write=function(e,t,r,n,o,a){var l,c,u,g=a*8-o-1,b=(1<>1,S=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,$=n?0:a-1,k=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,l=b):(l=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-l))<1&&(l--,u*=2),l+x>=1?t+=S/u:t+=S*Math.pow(2,1-x),t*u>=2&&(l++,u/=2),l+x>=b?(c=0,l=b):l+x>=1?(c=(t*u-1)*Math.pow(2,o),l=l+x):(c=t*Math.pow(2,x-1)*Math.pow(2,o),l=0));o>=8;e[r+$]=c&255,$+=k,c/=256,o-=8);for(l=l<0;e[r+$]=l&255,$+=k,l/=256,g-=8);e[r+$-k]|=T*128};/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh @@ -31,7 +31,7 @@ Arguments: `+Array.prototype.slice.call(n).join("")+` hooks.version="2.29.4";setHookCallback(createLocal);hooks.fn=proto;hooks.min=min;hooks.max=max;hooks.now=now;hooks.utc=createUTC;hooks.unix=createUnix;hooks.months=listMonths;hooks.isDate=isDate$2;hooks.locale=getSetGlobalLocale;hooks.invalid=createInvalid;hooks.duration=createDuration;hooks.isMoment=isMoment;hooks.weekdays=listWeekdays;hooks.parseZone=createInZone;hooks.localeData=getLocale;hooks.isDuration=isDuration;hooks.monthsShort=listMonthsShort;hooks.weekdaysMin=listWeekdaysMin;hooks.defineLocale=defineLocale;hooks.updateLocale=updateLocale;hooks.locales=listLocales;hooks.weekdaysShort=listWeekdaysShort;hooks.normalizeUnits=normalizeUnits;hooks.relativeTimeRounding=getSetRelativeTimeRounding;hooks.relativeTimeThreshold=getSetRelativeTimeThreshold;hooks.calendarFormat=getCalendarFormat;hooks.prototype=proto;hooks.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"};var leafletSrc={exports:{}};/* @preserve * Leaflet 1.9.2, a JS library for interactive maps. https://leafletjs.com * (c) 2010-2022 Vladimir Agafonkin, (c) 2010-2011 CloudMade - */(function(e,t){(function(r,n){n(t)})(commonjsGlobal$2,function(r){var n="1.9.2";function o(_){var E,H,be,Me;for(H=1,be=arguments.length;H"u"||!L||!L.Mixin)){_=N(_)?_:[_];for(var E=0;E<_.length;E++)_[E]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}var pe={on:function(_,E,H){if(typeof _=="object")for(var be in _)this._on(be,_[be],E);else{_=k(_);for(var Me=0,Je=_.length;Me0?Math.floor(_):Math.ceil(_)};ge.prototype={clone:function(){return new ge(this.x,this.y)},add:function(_){return this.clone()._add(Ae(_))},_add:function(_){return this.x+=_.x,this.y+=_.y,this},subtract:function(_){return this.clone()._subtract(Ae(_))},_subtract:function(_){return this.x-=_.x,this.y-=_.y,this},divideBy:function(_){return this.clone()._divideBy(_)},_divideBy:function(_){return this.x/=_,this.y/=_,this},multiplyBy:function(_){return this.clone()._multiplyBy(_)},_multiplyBy:function(_){return this.x*=_,this.y*=_,this},scaleBy:function(_){return new ge(this.x*_.x,this.y*_.y)},unscaleBy:function(_){return new ge(this.x/_.x,this.y/_.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=ye(this.x),this.y=ye(this.y),this},distanceTo:function(_){_=Ae(_);var E=_.x-this.x,H=_.y-this.y;return Math.sqrt(E*E+H*H)},equals:function(_){return _=Ae(_),_.x===this.x&&_.y===this.y},contains:function(_){return _=Ae(_),Math.abs(_.x)<=Math.abs(this.x)&&Math.abs(_.y)<=Math.abs(this.y)},toString:function(){return"Point("+S(this.x)+", "+S(this.y)+")"}};function Ae(_,E,H){return _ instanceof ge?_:N(_)?new ge(_[0],_[1]):_==null?_:typeof _=="object"&&"x"in _&&"y"in _?new ge(_.x,_.y):new ge(_,E,H)}function Re(_,E){if(!!_)for(var H=E?[_,E]:_,be=0,Me=H.length;be=this.min.x&&H.x<=this.max.x&&E.y>=this.min.y&&H.y<=this.max.y},intersects:function(_){_=We(_);var E=this.min,H=this.max,be=_.min,Me=_.max,Je=Me.x>=E.x&&be.x<=H.x,ct=Me.y>=E.y&&be.y<=H.y;return Je&&ct},overlaps:function(_){_=We(_);var E=this.min,H=this.max,be=_.min,Me=_.max,Je=Me.x>E.x&&be.xE.y&&be.y=E.lat&&Me.lat<=H.lat&&be.lng>=E.lng&&Me.lng<=H.lng},intersects:function(_){_=Ue(_);var E=this._southWest,H=this._northEast,be=_.getSouthWest(),Me=_.getNorthEast(),Je=Me.lat>=E.lat&&be.lat<=H.lat,ct=Me.lng>=E.lng&&be.lng<=H.lng;return Je&&ct},overlaps:function(_){_=Ue(_);var E=this._southWest,H=this._northEast,be=_.getSouthWest(),Me=_.getNorthEast(),Je=Me.lat>E.lat&&be.latE.lng&&be.lng1,Pr=function(){var _=!1;try{var E=Object.defineProperty({},"passive",{get:function(){_=!0}});window.addEventListener("testPassiveEventSupport",x,E),window.removeEventListener("testPassiveEventSupport",x,E)}catch{}return _}(),fr=function(){return!!document.createElement("canvas").getContext}(),hr=!!(document.createElementNS&&me("svg").createSVGRect),$r=!!hr&&function(){var _=document.createElement("div");return _.innerHTML="",(_.firstChild&&_.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"}(),Bi=!hr&&function(){try{var _=document.createElement("div");_.innerHTML='';var E=_.firstChild;return E.style.behavior="url(#default#VML)",E&&typeof E.adj=="object"}catch{return!1}}(),li=navigator.platform.indexOf("Mac")===0,Mn=navigator.platform.indexOf("Linux")===0;function Sr(_){return navigator.userAgent.toLowerCase().indexOf(_)>=0}var Lt={ie:He,ielt9:ze,edge:Qe,webkit:rt,android:Ke,android23:Ie,androidStock:je,opera:Ze,chrome:Ce,gecko:ce,safari:de,phantom:De,opera12:qe,win:nt,ie3d:lt,webkit3d:pt,gecko3d:bt,any3d:St,mobile:Et,mobileWebkit:vt,mobileWebkit3d:Nt,msPointer:Ft,pointer:qt,touch:mr,touchNative:Zt,mobileOpera:nr,mobileGecko:ur,retina:Mr,passiveEvents:Pr,canvas:fr,svg:hr,vml:Bi,inlineSvg:$r,mac:li,linux:Mn},On=Lt.msPointer?"MSPointerDown":"pointerdown",Ur=Lt.msPointer?"MSPointerMove":"pointermove",Dn=Lt.msPointer?"MSPointerUp":"pointerup",tn=Lt.msPointer?"MSPointerCancel":"pointercancel",rn={touchstart:On,touchmove:Ur,touchend:Dn,touchcancel:tn},Nn={touchstart:So,touchmove:Bn,touchend:Bn,touchcancel:Bn},Ir={},qr=!1;function ci(_,E,H){return E==="touchstart"&&Eo(),Nn[E]?(H=Nn[E].bind(this,H),_.addEventListener(rn[E],H,!1),H):(console.warn("wrong event specified:",E),L.Util.falseFn)}function nn(_,E,H){if(!rn[E]){console.warn("wrong event specified:",E);return}_.removeEventListener(rn[E],H,!1)}function xo(_){Ir[_.pointerId]=_}function _s(_){Ir[_.pointerId]&&(Ir[_.pointerId]=_)}function vs(_){delete Ir[_.pointerId]}function Eo(){qr||(document.addEventListener(On,xo,!0),document.addEventListener(Ur,_s,!0),document.addEventListener(Dn,vs,!0),document.addEventListener(tn,vs,!0),qr=!0)}function Bn(_,E){if(E.pointerType!==(E.MSPOINTER_TYPE_MOUSE||"mouse")){E.touches=[];for(var H in Ir)E.touches.push(Ir[H]);E.changedTouches=[E],_(E)}}function So(_,E){E.MSPOINTER_TYPE_TOUCH&&E.pointerType===E.MSPOINTER_TYPE_TOUCH&&gr(E),Bn(_,E)}function Co(_){var E={},H,be;for(be in _)H=_[be],E[be]=H&&H.bind?H.bind(_):H;return _=E,E.type="dblclick",E.detail=2,E.isTrusted=!1,E._simulated=!0,E}var ko=200;function Ao(_,E){_.addEventListener("dblclick",E);var H=0,be;function Me(Je){if(Je.detail!==1){be=Je.detail;return}if(!(Je.pointerType==="mouse"||Je.sourceCapabilities&&!Je.sourceCapabilities.firesTouchEvents)){var ct=ws(Je);if(!(ct.some(function(_t){return _t instanceof HTMLLabelElement&&_t.attributes.for})&&!ct.some(function(_t){return _t instanceof HTMLInputElement||_t instanceof HTMLSelectElement}))){var gt=Date.now();gt-H<=ko?(be++,be===2&&E(Co(Je))):be=1,H=gt}}}return _.addEventListener("click",Me),{dblclick:E,simDblclick:Me}}function To(_,E){_.removeEventListener("dblclick",E.dblclick),_.removeEventListener("click",E.simDblclick)}var Fi=Fn(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),sn=Fn(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),an=sn==="webkitTransition"||sn==="OTransition"?sn+"End":"transitionend";function ui(_){return typeof _=="string"?document.getElementById(_):_}function Or(_,E){var H=_.style[E]||_.currentStyle&&_.currentStyle[E];if((!H||H==="auto")&&document.defaultView){var be=document.defaultView.getComputedStyle(_,null);H=be?be[E]:null}return H==="auto"?null:H}function Kt(_,E,H){var be=document.createElement(_);return be.className=E||"",H&&H.appendChild(be),be}function ar(_){var E=_.parentNode;E&&E.removeChild(_)}function hi(_){for(;_.firstChild;)_.removeChild(_.firstChild)}function En(_){var E=_.parentNode;E&&E.lastChild!==_&&E.appendChild(_)}function Sn(_){var E=_.parentNode;E&&E.firstChild!==_&&E.insertBefore(_,E.firstChild)}function di(_,E){if(_.classList!==void 0)return _.classList.contains(E);var H=fi(_);return H.length>0&&new RegExp("(^|\\s)"+E+"(\\s|$)").test(H)}function Bt(_,E){if(_.classList!==void 0)for(var H=k(E),be=0,Me=H.length;be0?2*window.devicePixelRatio:1;function Zi(_){return Lt.edge?_.wheelDeltaY/2:_.deltaY&&_.deltaMode===0?-_.deltaY/qi:_.deltaY&&_.deltaMode===1?-_.deltaY*20:_.deltaY&&_.deltaMode===2?-_.deltaY*60:_.deltaX||_.deltaZ?0:_.wheelDelta?(_.wheelDeltaY||_.wheelDelta)/2:_.detail&&Math.abs(_.detail)<32765?-_.detail*20:_.detail?_.detail/-32765*60:0}function Xi(_,E){var H=E.relatedTarget;if(!H)return!0;try{for(;H&&H!==_;)H=H.parentNode}catch{return!1}return H!==_}var $o={__proto__:null,on:Ot,off:tr,stopPropagation:un,disableScrollPropagation:yi,disableClickPropagation:Dr,preventDefault:gr,stop:hn,getPropagationPath:ws,getMousePosition:_i,getWheelDelta:Zi,isExternalTarget:Xi,addListener:Ot,removeListener:tr},xs=ue.extend({run:function(_,E,H,be){this.stop(),this._el=_,this._inProgress=!0,this._duration=H||.25,this._easeOutPower=1/Math.max(be||.5,.2),this._startPos=cn(_),this._offset=E.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){!this._inProgress||(this._step(!0),this._complete())},_animate:function(){this._animId=he(this._animate,this),this._step()},_step:function(_){var E=+new Date-this._startTime,H=this._duration*1e3;Ethis.options.maxZoom)?this.setZoom(_):this},panInsideBounds:function(_,E){this._enforcingBounds=!0;var H=this.getCenter(),be=this._limitCenter(H,this._zoom,Ue(_));return H.equals(be)||this.panTo(be,E),this._enforcingBounds=!1,this},panInside:function(_,E){E=E||{};var H=Ae(E.paddingTopLeft||E.padding||[0,0]),be=Ae(E.paddingBottomRight||E.padding||[0,0]),Me=this.project(this.getCenter()),Je=this.project(_),ct=this.getPixelBounds(),gt=We([ct.min.add(H),ct.max.subtract(be)]),_t=gt.getSize();if(!gt.contains(Je)){this._enforcingBounds=!0;var xt=Je.subtract(gt.getCenter()),Tt=gt.extend(Je).getSize().subtract(_t);Me.x+=xt.x<0?-Tt.x:Tt.x,Me.y+=xt.y<0?-Tt.y:Tt.y,this.panTo(this.unproject(Me),E),this._enforcingBounds=!1}return this},invalidateSize:function(_){if(!this._loaded)return this;_=o({animate:!1,pan:!0},_===!0?{animate:!0}:_);var E=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var H=this.getSize(),be=E.divideBy(2).round(),Me=H.divideBy(2).round(),Je=be.subtract(Me);return!Je.x&&!Je.y?this:(_.animate&&_.pan?this.panBy(Je):(_.pan&&this._rawPanBy(Je),this.fire("move"),_.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(l(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:E,newSize:H}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(_){if(_=this._locateOptions=o({timeout:1e4,watch:!1},_),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var E=l(this._handleGeolocationResponse,this),H=l(this._handleGeolocationError,this);return _.watch?this._locationWatchId=navigator.geolocation.watchPosition(E,H,_):navigator.geolocation.getCurrentPosition(E,H,_),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(_){if(!!this._container._leaflet_id){var E=_.code,H=_.message||(E===1?"permission denied":E===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:E,message:"Geolocation error: "+H+"."})}},_handleGeolocationResponse:function(_){if(!!this._container._leaflet_id){var E=_.coords.latitude,H=_.coords.longitude,be=new Oe(E,H),Me=be.toBounds(_.coords.accuracy*2),Je=this._locateOptions;if(Je.setView){var ct=this.getBoundsZoom(Me);this.setView(be,Je.maxZoom?Math.min(ct,Je.maxZoom):ct)}var gt={latlng:be,bounds:Me,timestamp:_.timestamp};for(var _t in _.coords)typeof _.coords[_t]=="number"&&(gt[_t]=_.coords[_t]);this.fire("locationfound",gt)}},addHandler:function(_,E){if(!E)return this;var H=this[_]=new E(this);return this._handlers.push(H),this.options[_]&&H.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),ar(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(_e(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var _;for(_ in this._layers)this._layers[_].remove();for(_ in this._panes)ar(this._panes[_]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(_,E){var H="leaflet-pane"+(_?" leaflet-"+_.replace("Pane","")+"-pane":""),be=Kt("div",H,E||this._mapPane);return _&&(this._panes[_]=be),be},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var _=this.getPixelBounds(),E=this.unproject(_.getBottomLeft()),H=this.unproject(_.getTopRight());return new Pe(E,H)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(_,E,H){_=Ue(_),H=Ae(H||[0,0]);var be=this.getZoom()||0,Me=this.getMinZoom(),Je=this.getMaxZoom(),ct=_.getNorthWest(),gt=_.getSouthEast(),_t=this.getSize().subtract(H),xt=We(this.project(gt,be),this.project(ct,be)).getSize(),Tt=Lt.any3d?this.options.zoomSnap:1,Mt=_t.x/xt.x,Dt=_t.y/xt.y,Cr=E?Math.max(Mt,Dt):Math.min(Mt,Dt);return be=this.getScaleZoom(Cr,be),Tt&&(be=Math.round(be/(Tt/100))*(Tt/100),be=E?Math.ceil(be/Tt)*Tt:Math.floor(be/Tt)*Tt),Math.max(Me,Math.min(Je,be))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new ge(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(_,E){var H=this._getTopLeftPoint(_,E);return new Re(H,H.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(_){return this.options.crs.getProjectedBounds(_===void 0?this.getZoom():_)},getPane:function(_){return typeof _=="string"?this._panes[_]:_},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(_,E){var H=this.options.crs;return E=E===void 0?this._zoom:E,H.scale(_)/H.scale(E)},getScaleZoom:function(_,E){var H=this.options.crs;E=E===void 0?this._zoom:E;var be=H.zoom(_*H.scale(E));return isNaN(be)?1/0:be},project:function(_,E){return E=E===void 0?this._zoom:E,this.options.crs.latLngToPoint(Be(_),E)},unproject:function(_,E){return E=E===void 0?this._zoom:E,this.options.crs.pointToLatLng(Ae(_),E)},layerPointToLatLng:function(_){var E=Ae(_).add(this.getPixelOrigin());return this.unproject(E)},latLngToLayerPoint:function(_){var E=this.project(Be(_))._round();return E._subtract(this.getPixelOrigin())},wrapLatLng:function(_){return this.options.crs.wrapLatLng(Be(_))},wrapLatLngBounds:function(_){return this.options.crs.wrapLatLngBounds(Ue(_))},distance:function(_,E){return this.options.crs.distance(Be(_),Be(E))},containerPointToLayerPoint:function(_){return Ae(_).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(_){return Ae(_).add(this._getMapPanePos())},containerPointToLatLng:function(_){var E=this.containerPointToLayerPoint(Ae(_));return this.layerPointToLatLng(E)},latLngToContainerPoint:function(_){return this.layerPointToContainerPoint(this.latLngToLayerPoint(Be(_)))},mouseEventToContainerPoint:function(_){return _i(_,this._container)},mouseEventToLayerPoint:function(_){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(_))},mouseEventToLatLng:function(_){return this.layerPointToLatLng(this.mouseEventToLayerPoint(_))},_initContainer:function(_){var E=this._container=ui(_);if(E){if(E._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");Ot(E,"scroll",this._onScroll,this),this._containerId=u(E)},_initLayout:function(){var _=this._container;this._fadeAnimated=this.options.fadeAnimation&&Lt.any3d,Bt(_,"leaflet-container"+(Lt.touch?" leaflet-touch":"")+(Lt.retina?" leaflet-retina":"")+(Lt.ielt9?" leaflet-oldie":"")+(Lt.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var E=Or(_,"position");E!=="absolute"&&E!=="relative"&&E!=="fixed"&&(_.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var _=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),dr(this._mapPane,new ge(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(Bt(_.markerPane,"leaflet-zoom-hide"),Bt(_.shadowPane,"leaflet-zoom-hide"))},_resetView:function(_,E,H){dr(this._mapPane,new ge(0,0));var be=!this._loaded;this._loaded=!0,E=this._limitZoom(E),this.fire("viewprereset");var Me=this._zoom!==E;this._moveStart(Me,H)._move(_,E)._moveEnd(Me),this.fire("viewreset"),be&&this.fire("load")},_moveStart:function(_,E){return _&&this.fire("zoomstart"),E||this.fire("movestart"),this},_move:function(_,E,H,be){E===void 0&&(E=this._zoom);var Me=this._zoom!==E;return this._zoom=E,this._lastCenter=_,this._pixelOrigin=this._getNewPixelOrigin(_),be?H&&H.pinch&&this.fire("zoom",H):((Me||H&&H.pinch)&&this.fire("zoom",H),this.fire("move",H)),this},_moveEnd:function(_){return _&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return _e(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(_){dr(this._mapPane,this._getMapPanePos().subtract(_))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(_){this._targets={},this._targets[u(this._container)]=this;var E=_?tr:Ot;E(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&E(window,"resize",this._onResize,this),Lt.any3d&&this.options.transform3DLimit&&(_?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){_e(this._resizeRequest),this._resizeRequest=he(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var _=this._getMapPanePos();Math.max(Math.abs(_.x),Math.abs(_.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(_,E){for(var H=[],be,Me=E==="mouseout"||E==="mouseover",Je=_.target||_.srcElement,ct=!1;Je;){if(be=this._targets[u(Je)],be&&(E==="click"||E==="preclick")&&this._draggableMoved(be)){ct=!0;break}if(be&&be.listens(E,!0)&&(Me&&!Xi(Je,_)||(H.push(be),Me))||Je===this._container)break;Je=Je.parentNode}return!H.length&&!ct&&!Me&&this.listens(E,!0)&&(H=[this]),H},_isClickDisabled:function(_){for(;_&&_!==this._container;){if(_._leaflet_disable_click)return!0;_=_.parentNode}},_handleDOMEvent:function(_){var E=_.target||_.srcElement;if(!(!this._loaded||E._leaflet_disable_events||_.type==="click"&&this._isClickDisabled(E))){var H=_.type;H==="mousedown"&&ji(E),this._fireDOMEvent(_,H)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(_,E,H){if(_.type==="click"){var be=o({},_);be.type="preclick",this._fireDOMEvent(be,be.type,H)}var Me=this._findEventTargets(_,E);if(H){for(var Je=[],ct=0;ct0?Math.round(_-E)/2:Math.max(0,Math.ceil(_))-Math.max(0,Math.floor(E))},_limitZoom:function(_){var E=this.getMinZoom(),H=this.getMaxZoom(),be=Lt.any3d?this.options.zoomSnap:1;return be&&(_=Math.round(_/be)*be),Math.max(E,Math.min(H,_))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){cr(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(_,E){var H=this._getCenterOffset(_)._trunc();return(E&&E.animate)!==!0&&!this.getSize().contains(H)?!1:(this.panBy(H,E),!0)},_createAnimProxy:function(){var _=this._proxy=Kt("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(_),this.on("zoomanim",function(E){var H=Fi,be=this._proxy.style[H];ln(this._proxy,this.project(E.center,E.zoom),this.getZoomScale(E.zoom,1)),be===this._proxy.style[H]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ar(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var _=this.getCenter(),E=this.getZoom();ln(this._proxy,this.project(_,E),this.getZoomScale(E,1))},_catchTransitionEnd:function(_){this._animatingZoom&&_.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(_,E,H){if(this._animatingZoom)return!0;if(H=H||{},!this._zoomAnimated||H.animate===!1||this._nothingToAnimate()||Math.abs(E-this._zoom)>this.options.zoomAnimationThreshold)return!1;var be=this.getZoomScale(E),Me=this._getCenterOffset(_)._divideBy(1-1/be);return H.animate!==!0&&!this.getSize().contains(Me)?!1:(he(function(){this._moveStart(!0,!1)._animateZoom(_,E,!0)},this),!0)},_animateZoom:function(_,E,H,be){!this._mapPane||(H&&(this._animatingZoom=!0,this._animateToCenter=_,this._animateToZoom=E,Bt(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:_,zoom:E,noUpdate:be}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(l(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){!this._animatingZoom||(this._mapPane&&cr(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function Es(_,E){return new zt(_,E)}var Lr=ae.extend({options:{position:"topright"},initialize:function(_){T(this,_)},getPosition:function(){return this.options.position},setPosition:function(_){var E=this._map;return E&&E.removeControl(this),this.options.position=_,E&&E.addControl(this),this},getContainer:function(){return this._container},addTo:function(_){this.remove(),this._map=_;var E=this._container=this.onAdd(_),H=this.getPosition(),be=_._controlCorners[H];return Bt(E,"leaflet-control"),H.indexOf("bottom")!==-1?be.insertBefore(E,be.firstChild):be.appendChild(E),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(ar(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(_){this._map&&_&&_.screenX>0&&_.screenY>0&&this._map.getContainer().focus()}}),jn=function(_){return new Lr(_)};zt.include({addControl:function(_){return _.addTo(this),this},removeControl:function(_){return _.remove(),this},_initControlPos:function(){var _=this._controlCorners={},E="leaflet-",H=this._controlContainer=Kt("div",E+"control-container",this._container);function be(Me,Je){var ct=E+Me+" "+E+Je;_[Me+Je]=Kt("div",ct,H)}be("top","left"),be("top","right"),be("bottom","left"),be("bottom","right")},_clearControlPos:function(){for(var _ in this._controlCorners)ar(this._controlCorners[_]);ar(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Ss=Lr.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(_,E,H,be){return H1,this._baseLayersList.style.display=_?"":"none"),this._separator.style.display=E&&_?"":"none",this},_onLayerChange:function(_){this._handlingClick||this._update();var E=this._getLayer(u(_.target)),H=E.overlay?_.type==="add"?"overlayadd":"overlayremove":_.type==="add"?"baselayerchange":null;H&&this._map.fire(H,E)},_createRadioElement:function(_,E){var H='",be=document.createElement("div");return be.innerHTML=H,be.firstChild},_addItem:function(_){var E=document.createElement("label"),H=this._map.hasLayer(_.layer),be;_.overlay?(be=document.createElement("input"),be.type="checkbox",be.className="leaflet-control-layers-selector",be.defaultChecked=H):be=this._createRadioElement("leaflet-base-layers_"+u(this),H),this._layerControlInputs.push(be),be.layerId=u(_.layer),Ot(be,"click",this._onInputClick,this);var Me=document.createElement("span");Me.innerHTML=" "+_.name;var Je=document.createElement("span");E.appendChild(Je),Je.appendChild(be),Je.appendChild(Me);var ct=_.overlay?this._overlaysList:this._baseLayersList;return ct.appendChild(E),this._checkDisabledLayers(),E},_onInputClick:function(){var _=this._layerControlInputs,E,H,be=[],Me=[];this._handlingClick=!0;for(var Je=_.length-1;Je>=0;Je--)E=_[Je],H=this._getLayer(E.layerId).layer,E.checked?be.push(H):E.checked||Me.push(H);for(Je=0;Je=0;Me--)E=_[Me],H=this._getLayer(E.layerId).layer,E.disabled=H.options.minZoom!==void 0&&beH.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this}}),Io=function(_,E,H){return new Ss(_,E,H)},Qi=Lr.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(_){var E="leaflet-control-zoom",H=Kt("div",E+" leaflet-bar"),be=this.options;return this._zoomInButton=this._createButton(be.zoomInText,be.zoomInTitle,E+"-in",H,this._zoomIn),this._zoomOutButton=this._createButton(be.zoomOutText,be.zoomOutTitle,E+"-out",H,this._zoomOut),this._updateDisabled(),_.on("zoomend zoomlevelschange",this._updateDisabled,this),H},onRemove:function(_){_.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(_){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(_.shiftKey?3:1))},_createButton:function(_,E,H,be,Me){var Je=Kt("a",H,be);return Je.innerHTML=_,Je.href="#",Je.title=E,Je.setAttribute("role","button"),Je.setAttribute("aria-label",E),Dr(Je),Ot(Je,"click",hn),Ot(Je,"click",Me,this),Ot(Je,"click",this._refocusOnMap,this),Je},_updateDisabled:function(){var _=this._map,E="leaflet-disabled";cr(this._zoomInButton,E),cr(this._zoomOutButton,E),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||_._zoom===_.getMinZoom())&&(Bt(this._zoomOutButton,E),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||_._zoom===_.getMaxZoom())&&(Bt(this._zoomInButton,E),this._zoomInButton.setAttribute("aria-disabled","true"))}});zt.mergeOptions({zoomControl:!0}),zt.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new Qi,this.addControl(this.zoomControl))});var Lo=function(_){return new Qi(_)},Cs=Lr.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(_){var E="leaflet-control-scale",H=Kt("div",E),be=this.options;return this._addScales(be,E+"-line",H),_.on(be.updateWhenIdle?"moveend":"move",this._update,this),_.whenReady(this._update,this),H},onRemove:function(_){_.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(_,E,H){_.metric&&(this._mScale=Kt("div",E,H)),_.imperial&&(this._iScale=Kt("div",E,H))},_update:function(){var _=this._map,E=_.getSize().y/2,H=_.distance(_.containerPointToLatLng([0,E]),_.containerPointToLatLng([this.options.maxWidth,E]));this._updateScales(H)},_updateScales:function(_){this.options.metric&&_&&this._updateMetric(_),this.options.imperial&&_&&this._updateImperial(_)},_updateMetric:function(_){var E=this._getRoundNum(_),H=E<1e3?E+" m":E/1e3+" km";this._updateScale(this._mScale,H,E/_)},_updateImperial:function(_){var E=_*3.2808399,H,be,Me;E>5280?(H=E/5280,be=this._getRoundNum(H),this._updateScale(this._iScale,be+" mi",be/H)):(Me=this._getRoundNum(E),this._updateScale(this._iScale,Me+" ft",Me/E))},_updateScale:function(_,E,H){_.style.width=Math.round(this.options.maxWidth*H)+"px",_.innerHTML=E},_getRoundNum:function(_){var E=Math.pow(10,(Math.floor(_)+"").length-1),H=_/E;return H=H>=10?10:H>=5?5:H>=3?3:H>=2?2:1,E*H}}),ks=function(_){return new Cs(_)},Ro='',Ji=Lr.extend({options:{position:"bottomright",prefix:''+(Lt.inlineSvg?Ro+" ":"")+"Leaflet"},initialize:function(_){T(this,_),this._attributions={}},onAdd:function(_){_.attributionControl=this,this._container=Kt("div","leaflet-control-attribution"),Dr(this._container);for(var E in _._layers)_._layers[E].getAttribution&&this.addAttribution(_._layers[E].getAttribution());return this._update(),_.on("layeradd",this._addAttribution,this),this._container},onRemove:function(_){_.off("layeradd",this._addAttribution,this)},_addAttribution:function(_){_.layer.getAttribution&&(this.addAttribution(_.layer.getAttribution()),_.layer.once("remove",function(){this.removeAttribution(_.layer.getAttribution())},this))},setPrefix:function(_){return this.options.prefix=_,this._update(),this},addAttribution:function(_){return _?(this._attributions[_]||(this._attributions[_]=0),this._attributions[_]++,this._update(),this):this},removeAttribution:function(_){return _?(this._attributions[_]&&(this._attributions[_]--,this._update()),this):this},_update:function(){if(!!this._map){var _=[];for(var E in this._attributions)this._attributions[E]&&_.push(E);var H=[];this.options.prefix&&H.push(this.options.prefix),_.length&&H.push(_.join(", ")),this._container.innerHTML=H.join(' ')}}});zt.mergeOptions({attributionControl:!0}),zt.addInitHook(function(){this.options.attributionControl&&new Ji().addTo(this)});var Mo=function(_){return new Ji(_)};Lr.Layers=Ss,Lr.Zoom=Qi,Lr.Scale=Cs,Lr.Attribution=Ji,jn.layers=Io,jn.zoom=Lo,jn.scale=ks,jn.attribution=Mo;var Nr=ae.extend({initialize:function(_){this._map=_},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});Nr.addTo=function(_,E){return _.addHandler(E,this),this};var Oo={Events:pe},As=Lt.touch?"touchstart mousedown":"mousedown",Zr=ue.extend({options:{clickTolerance:3},initialize:function(_,E,H,be){T(this,be),this._element=_,this._dragStartTarget=E||_,this._preventOutline=H},enable:function(){this._enabled||(Ot(this._dragStartTarget,As,this._onDown,this),this._enabled=!0)},disable:function(){!this._enabled||(Zr._dragging===this&&this.finishDrag(!0),tr(this._dragStartTarget,As,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(_){if(!!this._enabled&&(this._moved=!1,!di(this._element,"leaflet-zoom-anim"))){if(_.touches&&_.touches.length!==1){Zr._dragging===this&&this.finishDrag();return}if(!(Zr._dragging||_.shiftKey||_.which!==1&&_.button!==1&&!_.touches)&&(Zr._dragging=this,this._preventOutline&&ji(this._element),Hi(),Un(),!this._moving)){this.fire("down");var E=_.touches?_.touches[0]:_,H=Ki(this._element);this._startPoint=new ge(E.clientX,E.clientY),this._startPos=cn(this._element),this._parentScale=gi(H);var be=_.type==="mousedown";Ot(document,be?"mousemove":"touchmove",this._onMove,this),Ot(document,be?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(_){if(!!this._enabled){if(_.touches&&_.touches.length>1){this._moved=!0;return}var E=_.touches&&_.touches.length===1?_.touches[0]:_,H=new ge(E.clientX,E.clientY)._subtract(this._startPoint);!H.x&&!H.y||Math.abs(H.x)+Math.abs(H.y)Je&&(ct=gt,Je=_t);Je>H&&(E[ct]=1,es(_,E,H,be,ct),es(_,E,H,ct,Me))}function No(_,E){for(var H=[_[0]],be=1,Me=0,Je=_.length;beE&&(H.push(_[be]),Me=be);return MeE.max.x&&(H|=2),_.yE.max.y&&(H|=8),H}function Bo(_,E){var H=E.x-_.x,be=E.y-_.y;return H*H+be*be}function Yn(_,E,H,be){var Me=E.x,Je=E.y,ct=H.x-Me,gt=H.y-Je,_t=ct*ct+gt*gt,xt;return _t>0&&(xt=((_.x-Me)*ct+(_.y-Je)*gt)/_t,xt>1?(Me=H.x,Je=H.y):xt>0&&(Me+=ct*xt,Je+=gt*xt)),ct=_.x-Me,gt=_.y-Je,be?ct*ct+gt*gt:new ge(Me,Je)}function Ar(_){return!N(_[0])||typeof _[0][0]!="object"&&typeof _[0][0]<"u"}function Rs(_){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),Ar(_)}function Ms(_,E){var H,be,Me,Je,ct,gt,_t,xt;if(!_||_.length===0)throw new Error("latlngs not passed");Ar(_)||(console.warn("latlngs are not flat! Only the first ring will be used"),_=_[0]);var Tt=[];for(var Mt in _)Tt.push(E.project(Be(_[Mt])));var Dt=Tt.length;for(H=0,be=0;Hbe){_t=(Je-be)/Me,xt=[gt.x-_t*(gt.x-ct.x),gt.y-_t*(gt.y-ct.y)];break}return E.unproject(Ae(xt))}var Os={__proto__:null,simplify:Ts,pointToSegmentDistance:Ps,closestPointOnSegment:Do,clipSegment:Ls,_getEdgeIntersection:Kn,_getBitCode:dn,_sqClosestPointOnSegment:Yn,isFlat:Ar,_flat:Rs,polylineCenter:Ms};function Gn(_,E,H){var be,Me=[1,4,2,8],Je,ct,gt,_t,xt,Tt,Mt,Dt;for(Je=0,Tt=_.length;Je1e-7;gt++)xt=Me*Math.sin(ct),xt=Math.pow((1-xt)/(1+xt),Me/2),_t=Math.PI/2-2*Math.atan(Je*xt)-ct,ct+=_t;return new Oe(ct*E,_.x*E/H)}},Fo={__proto__:null,LonLat:ts,Mercator:bi,SphericalMercator:$e},Ns=o({},Se,{code:"EPSG:3395",projection:bi,transformation:function(){var _=.5/(Math.PI*bi.R);return oe(_,.5,-_,.5)}()}),Bs=o({},Se,{code:"EPSG:4326",projection:ts,transformation:oe(1/180,1,-1/180,.5)}),qn=o({},Ye,{projection:ts,transformation:oe(1,0,-1,0),scale:function(_){return Math.pow(2,_)},zoom:function(_){return Math.log(_)/Math.LN2},distance:function(_,E){var H=E.lng-_.lng,be=E.lat-_.lat;return Math.sqrt(H*H+be*be)},infinite:!0});Ye.Earth=Se,Ye.EPSG3395=Ns,Ye.EPSG3857=te,Ye.EPSG900913=se,Ye.EPSG4326=Bs,Ye.Simple=qn;var Rr=ue.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(_){return _.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(_){return _&&_.removeLayer(this),this},getPane:function(_){return this._map.getPane(_?this.options[_]||_:this.options.pane)},addInteractiveTarget:function(_){return this._map._targets[u(_)]=this,this},removeInteractiveTarget:function(_){return delete this._map._targets[u(_)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(_){var E=_.target;if(!!E.hasLayer(this)){if(this._map=E,this._zoomAnimated=E._zoomAnimated,this.getEvents){var H=this.getEvents();E.on(H,this),this.once("remove",function(){E.off(H,this)},this)}this.onAdd(E),this.fire("add"),E.fire("layeradd",{layer:this})}}});zt.include({addLayer:function(_){if(!_._layerAdd)throw new Error("The provided object is not a Layer.");var E=u(_);return this._layers[E]?this:(this._layers[E]=_,_._mapToAdd=this,_.beforeAdd&&_.beforeAdd(this),this.whenReady(_._layerAdd,_),this)},removeLayer:function(_){var E=u(_);return this._layers[E]?(this._loaded&&_.onRemove(this),delete this._layers[E],this._loaded&&(this.fire("layerremove",{layer:_}),_.fire("remove")),_._map=_._mapToAdd=null,this):this},hasLayer:function(_){return u(_)in this._layers},eachLayer:function(_,E){for(var H in this._layers)_.call(E,this._layers[H]);return this},_addLayers:function(_){_=_?N(_)?_:[_]:[];for(var E=0,H=_.length;Ethis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()=2&&E[0]instanceof Oe&&E[0].equals(E[H-1])&&E.pop(),E},_setLatLngs:function(_){Br.prototype._setLatLngs.call(this,_),Ar(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Ar(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var _=this._renderer._bounds,E=this.options.weight,H=new ge(E,E);if(_=new Re(_.min.subtract(H),_.max.add(H)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(_))){if(this.options.noClip){this._parts=this._rings;return}for(var be=0,Me=this._rings.length,Je;be_.y!=Me.y>_.y&&_.x<(Me.x-be.x)*(_.y-be.y)/(Me.y-be.y)+be.x&&(E=!E);return E||Br.prototype._containsPoint.call(this,_,!0)}});function xi(_,E){return new pn(_,E)}var Vr=fn.extend({initialize:function(_,E){T(this,E),this._layers={},_&&this.addData(_)},addData:function(_){var E=N(_)?_:_.features,H,be,Me;if(E){for(H=0,be=E.length;H0?be:[E.src];return}N(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(E.style,"objectFit")&&(E.style.objectFit="fill"),E.autoplay=!!this.options.autoplay,E.loop=!!this.options.loop,E.muted=!!this.options.muted,E.playsInline=!!this.options.playsInline;for(var Je=0;JeMe?(E.height=Me+"px",Bt(_,Je)):cr(_,Je),this._containerWidth=this._container.offsetWidth},_animateZoom:function(_){var E=this._map._latLngToNewLayerPoint(this._latlng,_.zoom,_.center),H=this._getAnchor();dr(this._container,E.add(H))},_adjustPan:function(_){if(!!this.options.autoPan){this._map._panAnim&&this._map._panAnim.stop();var E=this._map,H=parseInt(Or(this._container,"marginBottom"),10)||0,be=this._container.offsetHeight+H,Me=this._containerWidth,Je=new ge(this._containerLeft,-be-this._containerBottom);Je._add(cn(this._container));var ct=E.layerPointToContainerPoint(Je),gt=Ae(this.options.autoPanPadding),_t=Ae(this.options.autoPanPaddingTopLeft||gt),xt=Ae(this.options.autoPanPaddingBottomRight||gt),Tt=E.getSize(),Mt=0,Dt=0;ct.x+Me+xt.x>Tt.x&&(Mt=ct.x+Me-Tt.x+xt.x),ct.x-Mt-_t.x<0&&(Mt=ct.x-_t.x),ct.y+be+xt.y>Tt.y&&(Dt=ct.y+be-Tt.y+xt.y),ct.y-Dt-_t.y<0&&(Dt=ct.y-_t.y),(Mt||Dt)&&E.fire("autopanstart").panBy([Mt,Dt],{animate:_&&_.type==="moveend"})}},_getAnchor:function(){return Ae(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Yo=function(_,E){return new gn(_,E)};zt.mergeOptions({closePopupOnClick:!0}),zt.include({openPopup:function(_,E,H){return this._initOverlay(gn,_,E,H).openOn(this),this},closePopup:function(_){return _=arguments.length?_:this._popup,_&&_.close(),this}}),Rr.include({bindPopup:function(_,E){return this._popup=this._initOverlay(gn,this._popup,_,E),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(_){return this._popup&&this._popup._prepareOpen(_||this._latlng)&&this._popup.openOn(this._map),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(_){return this._popup&&this._popup.setContent(_),this},getPopup:function(){return this._popup},_openPopup:function(_){if(!(!this._popup||!this._map)){hn(_);var E=_.layer||_.target;if(this._popup._source===E&&!(E instanceof Xr)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(_.latlng);return}this._popup._source=E,this.openPopup(_.latlng)}},_movePopup:function(_){this._popup.setLatLng(_.latlng)},_onKeyPress:function(_){_.originalEvent.keyCode===13&&this._openPopup(_)}});var Ci=Fr.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(_){Fr.prototype.onAdd.call(this,_),this.setOpacity(this.options.opacity),_.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(_){Fr.prototype.onRemove.call(this,_),_.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var _=Fr.prototype.getEvents.call(this);return this.options.permanent||(_.preclick=this.close),_},_initLayout:function(){var _="leaflet-tooltip",E=_+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=Kt("div",E),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+u(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(_){var E,H,be=this._map,Me=this._container,Je=be.latLngToContainerPoint(be.getCenter()),ct=be.layerPointToContainerPoint(_),gt=this.options.direction,_t=Me.offsetWidth,xt=Me.offsetHeight,Tt=Ae(this.options.offset),Mt=this._getAnchor();gt==="top"?(E=_t/2,H=xt):gt==="bottom"?(E=_t/2,H=0):gt==="center"?(E=_t/2,H=xt/2):gt==="right"?(E=0,H=xt/2):gt==="left"?(E=_t,H=xt/2):ct.xthis.options.maxZoom||Hbe?this._retainParent(Me,Je,ct,be):!1)},_retainChildren:function(_,E,H,be){for(var Me=2*_;Me<2*_+2;Me++)for(var Je=2*E;Je<2*E+2;Je++){var ct=new ge(Me,Je);ct.z=H+1;var gt=this._tileCoordsToKey(ct),_t=this._tiles[gt];if(_t&&_t.active){_t.retain=!0;continue}else _t&&_t.loaded&&(_t.retain=!0);H+1this.options.maxZoom||this.options.minZoom!==void 0&&Me1){this._setView(_,H);return}for(var Mt=Me.min.y;Mt<=Me.max.y;Mt++)for(var Dt=Me.min.x;Dt<=Me.max.x;Dt++){var Cr=new ge(Dt,Mt);if(Cr.z=this._tileZoom,!!this._isValidTile(Cr)){var Jr=this._tiles[this._tileCoordsToKey(Cr)];Jr?Jr.current=!0:ct.push(Cr)}}if(ct.sort(function(zr,ii){return zr.distanceTo(Je)-ii.distanceTo(Je)}),ct.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var Ti=document.createDocumentFragment();for(Dt=0;DtH.max.x)||!E.wrapLat&&(_.yH.max.y))return!1}if(!this.options.bounds)return!0;var be=this._tileCoordsToBounds(_);return Ue(this.options.bounds).overlaps(be)},_keyToBounds:function(_){return this._tileCoordsToBounds(this._keyToTileCoords(_))},_tileCoordsToNwSe:function(_){var E=this._map,H=this.getTileSize(),be=_.scaleBy(H),Me=be.add(H),Je=E.unproject(be,_.z),ct=E.unproject(Me,_.z);return[Je,ct]},_tileCoordsToBounds:function(_){var E=this._tileCoordsToNwSe(_),H=new Pe(E[0],E[1]);return this.options.noWrap||(H=this._map.wrapLatLngBounds(H)),H},_tileCoordsToKey:function(_){return _.x+":"+_.y+":"+_.z},_keyToTileCoords:function(_){var E=_.split(":"),H=new ge(+E[0],+E[1]);return H.z=+E[2],H},_removeTile:function(_){var E=this._tiles[_];!E||(ar(E.el),delete this._tiles[_],this.fire("tileunload",{tile:E.el,coords:this._keyToTileCoords(_)}))},_initTile:function(_){Bt(_,"leaflet-tile");var E=this.getTileSize();_.style.width=E.x+"px",_.style.height=E.y+"px",_.onselectstart=x,_.onmousemove=x,Lt.ielt9&&this.options.opacity<1&&kr(_,this.options.opacity)},_addTile:function(_,E){var H=this._getTilePos(_),be=this._tileCoordsToKey(_),Me=this.createTile(this._wrapCoords(_),l(this._tileReady,this,_));this._initTile(Me),this.createTile.length<2&&he(l(this._tileReady,this,_,null,Me)),dr(Me,H),this._tiles[be]={el:Me,coords:_,current:!0},E.appendChild(Me),this.fire("tileloadstart",{tile:Me,coords:_})},_tileReady:function(_,E,H){E&&this.fire("tileerror",{error:E,tile:H,coords:_});var be=this._tileCoordsToKey(_);H=this._tiles[be],H&&(H.loaded=+new Date,this._map._fadeAnimated?(kr(H.el,0),_e(this._fadeFrame),this._fadeFrame=he(this._updateOpacity,this)):(H.active=!0,this._pruneTiles()),E||(Bt(H.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:H.el,coords:_})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Lt.ielt9||!this._map._fadeAnimated?he(this._pruneTiles,this):setTimeout(l(this._pruneTiles,this),250)))},_getTilePos:function(_){return _.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(_){var E=new ge(this._wrapX?b(_.x,this._wrapX):_.x,this._wrapY?b(_.y,this._wrapY):_.y);return E.z=_.z,E},_pxBoundsToTileRange:function(_){var E=this.getTileSize();return new Re(_.min.unscaleBy(E).floor(),_.max.unscaleBy(E).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var _ in this._tiles)if(!this._tiles[_].loaded)return!1;return!0}});function qo(_){return new ti(_)}var yn=ti.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(_,E){this._url=_,E=T(this,E),E.detectRetina&&Lt.retina&&E.maxZoom>0?(E.tileSize=Math.floor(E.tileSize/2),E.zoomReverse?(E.zoomOffset--,E.minZoom=Math.min(E.maxZoom,E.minZoom+1)):(E.zoomOffset++,E.maxZoom=Math.max(E.minZoom,E.maxZoom-1)),E.minZoom=Math.max(0,E.minZoom)):E.zoomReverse?E.minZoom=Math.min(E.maxZoom,E.minZoom):E.maxZoom=Math.max(E.minZoom,E.maxZoom),typeof E.subdomains=="string"&&(E.subdomains=E.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(_,E){return this._url===_&&E===void 0&&(E=!0),this._url=_,E||this.redraw(),this},createTile:function(_,E){var H=document.createElement("img");return Ot(H,"load",l(this._tileOnLoad,this,E,H)),Ot(H,"error",l(this._tileOnError,this,E,H)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(H.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(H.referrerPolicy=this.options.referrerPolicy),H.alt="",H.src=this.getTileUrl(_),H},getTileUrl:function(_){var E={r:Lt.retina?"@2x":"",s:this._getSubdomain(_),x:_.x,y:_.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var H=this._globalTileRange.max.y-_.y;this.options.tms&&(E.y=H),E["-y"]=H}return O(this._url,o(E,this.options))},_tileOnLoad:function(_,E){Lt.ielt9?setTimeout(l(_,this,null,E),0):_(null,E)},_tileOnError:function(_,E,H){var be=this.options.errorTileUrl;be&&E.getAttribute("src")!==be&&(E.src=be),_(H,E)},_onTileRemove:function(_){_.tile.onload=null},_getZoomForUrl:function(){var _=this._tileZoom,E=this.options.maxZoom,H=this.options.zoomReverse,be=this.options.zoomOffset;return H&&(_=E-_),_+be},_getSubdomain:function(_){var E=Math.abs(_.x+_.y)%this.options.subdomains.length;return this.options.subdomains[E]},_abortLoading:function(){var _,E;for(_ in this._tiles)if(this._tiles[_].coords.z!==this._tileZoom&&(E=this._tiles[_].el,E.onload=x,E.onerror=x,!E.complete)){E.src=ne;var H=this._tiles[_].coords;ar(E),delete this._tiles[_],this.fire("tileabort",{tile:E,coords:H})}},_removeTile:function(_){var E=this._tiles[_];if(!!E)return E.el.setAttribute("src",ne),ti.prototype._removeTile.call(this,_)},_tileReady:function(_,E,H){if(!(!this._map||H&&H.getAttribute("src")===ne))return ti.prototype._tileReady.call(this,_,E,H)}});function os(_,E){return new yn(_,E)}var Ys=yn.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(_,E){this._url=_;var H=o({},this.defaultWmsParams);for(var be in E)be in this.options||(H[be]=E[be]);E=T(this,E);var Me=E.detectRetina&&Lt.retina?2:1,Je=this.getTileSize();H.width=Je.x*Me,H.height=Je.y*Me,this.wmsParams=H},onAdd:function(_){this._crs=this.options.crs||_.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var E=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[E]=this._crs.code,yn.prototype.onAdd.call(this,_)},getTileUrl:function(_){var E=this._tileCoordsToNwSe(_),H=this._crs,be=We(H.project(E[0]),H.project(E[1])),Me=be.min,Je=be.max,ct=(this._wmsVersion>=1.3&&this._crs===Bs?[Me.y,Me.x,Je.y,Je.x]:[Me.x,Me.y,Je.x,Je.y]).join(","),gt=yn.prototype.getTileUrl.call(this,_);return gt+D(this.wmsParams,gt,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+ct},setParams:function(_,E){return o(this.wmsParams,_),E||this.redraw(),this}});function Zo(_,E){return new Ys(_,E)}yn.WMS=Ys,os.wms=Zo;var Hr=Rr.extend({options:{padding:.1},initialize:function(_){T(this,_),u(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),this._zoomAnimated&&Bt(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var _={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(_.zoomanim=this._onAnimZoom),_},_onAnimZoom:function(_){this._updateTransform(_.center,_.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(_,E){var H=this._map.getZoomScale(E,this._zoom),be=this._map.getSize().multiplyBy(.5+this.options.padding),Me=this._map.project(this._center,E),Je=be.multiplyBy(-H).add(Me).subtract(this._map._getNewPixelOrigin(_,E));Lt.any3d?ln(this._container,Je,H):dr(this._container,Je)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var _ in this._layers)this._layers[_]._reset()},_onZoomEnd:function(){for(var _ in this._layers)this._layers[_]._project()},_updatePaths:function(){for(var _ in this._layers)this._layers[_]._update()},_update:function(){var _=this.options.padding,E=this._map.getSize(),H=this._map.containerPointToLayerPoint(E.multiplyBy(-_)).round();this._bounds=new Re(H,H.add(E.multiplyBy(1+_*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Gs=Hr.extend({options:{tolerance:0},getEvents:function(){var _=Hr.prototype.getEvents.call(this);return _.viewprereset=this._onViewPreReset,_},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Hr.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var _=this._container=document.createElement("canvas");Ot(_,"mousemove",this._onMouseMove,this),Ot(_,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Ot(_,"mouseout",this._handleMouseOut,this),_._leaflet_disable_events=!0,this._ctx=_.getContext("2d")},_destroyContainer:function(){_e(this._redrawRequest),delete this._ctx,ar(this._container),tr(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var _;this._redrawBounds=null;for(var E in this._layers)_=this._layers[E],_._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Hr.prototype._update.call(this);var _=this._bounds,E=this._container,H=_.getSize(),be=Lt.retina?2:1;dr(E,_.min),E.width=be*H.x,E.height=be*H.y,E.style.width=H.x+"px",E.style.height=H.y+"px",Lt.retina&&this._ctx.scale(2,2),this._ctx.translate(-_.min.x,-_.min.y),this.fire("update")}},_reset:function(){Hr.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(_){this._updateDashArray(_),this._layers[u(_)]=_;var E=_._order={layer:_,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=E),this._drawLast=E,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(_){this._requestRedraw(_)},_removePath:function(_){var E=_._order,H=E.next,be=E.prev;H?H.prev=be:this._drawLast=be,be?be.next=H:this._drawFirst=H,delete _._order,delete this._layers[u(_)],this._requestRedraw(_)},_updatePath:function(_){this._extendRedrawBounds(_),_._project(),_._update(),this._requestRedraw(_)},_updateStyle:function(_){this._updateDashArray(_),this._requestRedraw(_)},_updateDashArray:function(_){if(typeof _.options.dashArray=="string"){var E=_.options.dashArray.split(/[, ]+/),H=[],be,Me;for(Me=0;Me')}}catch{}return function(_){return document.createElement("<"+_+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),Xo={_initContainer:function(){this._container=Kt("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Hr.prototype._update.call(this),this.fire("update"))},_initPath:function(_){var E=_._container=ri("shape");Bt(E,"leaflet-vml-shape "+(this.options.className||"")),E.coordsize="1 1",_._path=ri("path"),E.appendChild(_._path),this._updateStyle(_),this._layers[u(_)]=_},_addPath:function(_){var E=_._container;this._container.appendChild(E),_.options.interactive&&_.addInteractiveTarget(E)},_removePath:function(_){var E=_._container;ar(E),_.removeInteractiveTarget(E),delete this._layers[u(_)]},_updateStyle:function(_){var E=_._stroke,H=_._fill,be=_.options,Me=_._container;Me.stroked=!!be.stroke,Me.filled=!!be.fill,be.stroke?(E||(E=_._stroke=ri("stroke")),Me.appendChild(E),E.weight=be.weight+"px",E.color=be.color,E.opacity=be.opacity,be.dashArray?E.dashStyle=N(be.dashArray)?be.dashArray.join(" "):be.dashArray.replace(/( *, *)/g," "):E.dashStyle="",E.endcap=be.lineCap.replace("butt","flat"),E.joinstyle=be.lineJoin):E&&(Me.removeChild(E),_._stroke=null),be.fill?(H||(H=_._fill=ri("fill")),Me.appendChild(H),H.color=be.fillColor||be.color,H.opacity=be.fillOpacity):H&&(Me.removeChild(H),_._fill=null)},_updateCircle:function(_){var E=_._point.round(),H=Math.round(_._radius),be=Math.round(_._radiusY||H);this._setPath(_,_._empty()?"M0 0":"AL "+E.x+","+E.y+" "+H+","+be+" 0,"+65535*360)},_setPath:function(_,E){_._path.v=E},_bringToFront:function(_){En(_._container)},_bringToBack:function(_){Sn(_._container)}},Ai=Lt.vml?ri:me,ni=Hr.extend({_initContainer:function(){this._container=Ai("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=Ai("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ar(this._container),tr(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Hr.prototype._update.call(this);var _=this._bounds,E=_.getSize(),H=this._container;(!this._svgSize||!this._svgSize.equals(E))&&(this._svgSize=E,H.setAttribute("width",E.x),H.setAttribute("height",E.y)),dr(H,_.min),H.setAttribute("viewBox",[_.min.x,_.min.y,E.x,E.y].join(" ")),this.fire("update")}},_initPath:function(_){var E=_._path=Ai("path");_.options.className&&Bt(E,_.options.className),_.options.interactive&&Bt(E,"leaflet-interactive"),this._updateStyle(_),this._layers[u(_)]=_},_addPath:function(_){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(_._path),_.addInteractiveTarget(_._path)},_removePath:function(_){ar(_._path),_.removeInteractiveTarget(_._path),delete this._layers[u(_)]},_updatePath:function(_){_._project(),_._update()},_updateStyle:function(_){var E=_._path,H=_.options;!E||(H.stroke?(E.setAttribute("stroke",H.color),E.setAttribute("stroke-opacity",H.opacity),E.setAttribute("stroke-width",H.weight),E.setAttribute("stroke-linecap",H.lineCap),E.setAttribute("stroke-linejoin",H.lineJoin),H.dashArray?E.setAttribute("stroke-dasharray",H.dashArray):E.removeAttribute("stroke-dasharray"),H.dashOffset?E.setAttribute("stroke-dashoffset",H.dashOffset):E.removeAttribute("stroke-dashoffset")):E.setAttribute("stroke","none"),H.fill?(E.setAttribute("fill",H.fillColor||H.color),E.setAttribute("fill-opacity",H.fillOpacity),E.setAttribute("fill-rule",H.fillRule||"evenodd")):E.setAttribute("fill","none"))},_updatePoly:function(_,E){this._setPath(_,Ee(_._parts,E))},_updateCircle:function(_){var E=_._point,H=Math.max(Math.round(_._radius),1),be=Math.max(Math.round(_._radiusY),1)||H,Me="a"+H+","+be+" 0 1,0 ",Je=_._empty()?"M0 0":"M"+(E.x-H)+","+E.y+Me+H*2+",0 "+Me+-H*2+",0 ";this._setPath(_,Je)},_setPath:function(_,E){_._path.setAttribute("d",E)},_bringToFront:function(_){En(_._path)},_bringToBack:function(_){Sn(_._path)}});Lt.vml&&ni.include(Xo);function Zs(_){return Lt.svg||Lt.vml?new ni(_):null}zt.include({getRenderer:function(_){var E=_.options.renderer||this._getPaneRenderer(_.options.pane)||this.options.renderer||this._renderer;return E||(E=this._renderer=this._createRenderer()),this.hasLayer(E)||this.addLayer(E),E},_getPaneRenderer:function(_){if(_==="overlayPane"||_===void 0)return!1;var E=this._paneRenderers[_];return E===void 0&&(E=this._createRenderer({pane:_}),this._paneRenderers[_]=E),E},_createRenderer:function(_){return this.options.preferCanvas&&qs(_)||Zs(_)}});var Xs=pn.extend({initialize:function(_,E){pn.prototype.initialize.call(this,this._boundsToLatLngs(_),E)},setBounds:function(_){return this.setLatLngs(this._boundsToLatLngs(_))},_boundsToLatLngs:function(_){return _=Ue(_),[_.getSouthWest(),_.getNorthWest(),_.getNorthEast(),_.getSouthEast()]}});function Qo(_,E){return new Xs(_,E)}ni.create=Ai,ni.pointsToPath=Ee,Vr.geometryToLayer=Jn,Vr.coordsToLatLng=rs,Vr.coordsToLatLngs=Ei,Vr.latLngToCoords=ns,Vr.latLngsToCoords=Si,Vr.getFeature=Qr,Vr.asFeature=mn,zt.mergeOptions({boxZoom:!0});var Qs=Nr.extend({initialize:function(_){this._map=_,this._container=_._container,this._pane=_._panes.overlayPane,this._resetStateTimeout=0,_.on("unload",this._destroy,this)},addHooks:function(){Ot(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){tr(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ar(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(_){if(!_.shiftKey||_.which!==1&&_.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),Un(),Hi(),this._startPoint=this._map.mouseEventToContainerPoint(_),Ot(document,{contextmenu:hn,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(_){this._moved||(this._moved=!0,this._box=Kt("div","leaflet-zoom-box",this._container),Bt(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(_);var E=new Re(this._point,this._startPoint),H=E.getSize();dr(this._box,E.min),this._box.style.width=H.x+"px",this._box.style.height=H.y+"px"},_finish:function(){this._moved&&(ar(this._box),cr(this._container,"leaflet-crosshair")),Vn(),zi(),tr(document,{contextmenu:hn,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(_){if(!(_.which!==1&&_.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(l(this._resetState,this),0);var E=new Pe(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(E).fire("boxzoomend",{boxZoomBounds:E})}},_onKeyDown:function(_){_.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});zt.addInitHook("addHandler","boxZoom",Qs),zt.mergeOptions({doubleClickZoom:!0});var Js=Nr.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(_){var E=this._map,H=E.getZoom(),be=E.options.zoomDelta,Me=_.originalEvent.shiftKey?H-be:H+be;E.options.doubleClickZoom==="center"?E.setZoom(Me):E.setZoomAround(_.containerPoint,Me)}});zt.addInitHook("addHandler","doubleClickZoom",Js),zt.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var ls=Nr.extend({addHooks:function(){if(!this._draggable){var _=this._map;this._draggable=new Zr(_._mapPane,_._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),_.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),_.on("zoomend",this._onZoomEnd,this),_.whenReady(this._onZoomEnd,this))}Bt(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){cr(this._map._container,"leaflet-grab"),cr(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var _=this._map;if(_._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var E=Ue(this._map.options.maxBounds);this._offsetLimit=We(this._map.latLngToContainerPoint(E.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(E.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;_.fire("movestart").fire("dragstart"),_.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(_){if(this._map.options.inertia){var E=this._lastTime=+new Date,H=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(H),this._times.push(E),this._prunePositions(E)}this._map.fire("move",_).fire("drag",_)},_prunePositions:function(_){for(;this._positions.length>1&&_-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var _=this._map.getSize().divideBy(2),E=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=E.subtract(_).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(_,E){return _-(_-E)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var _=this._draggable._newPos.subtract(this._draggable._startPos),E=this._offsetLimit;_.xE.max.x&&(_.x=this._viscousLimit(_.x,E.max.x)),_.y>E.max.y&&(_.y=this._viscousLimit(_.y,E.max.y)),this._draggable._newPos=this._draggable._startPos.add(_)}},_onPreDragWrap:function(){var _=this._worldWidth,E=Math.round(_/2),H=this._initialWorldOffset,be=this._draggable._newPos.x,Me=(be-E+H)%_+E-H,Je=(be+E+H)%_-E-H,ct=Math.abs(Me+H)0?Je:-Je))-E;this._delta=0,this._startTime=null,ct&&(_.options.scrollWheelZoom==="center"?_.setZoom(E+ct):_.setZoomAround(this._lastMousePos,E+ct))}});zt.addInitHook("addHandler","scrollWheelZoom",eo);var ro=600;zt.mergeOptions({tapHold:Lt.touchNative&&Lt.safari&&Lt.mobile,tapTolerance:15});var no=Nr.extend({addHooks:function(){Ot(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){tr(this._map._container,"touchstart",this._onDown,this)},_onDown:function(_){if(clearTimeout(this._holdTimeout),_.touches.length===1){var E=_.touches[0];this._startPos=this._newPos=new ge(E.clientX,E.clientY),this._holdTimeout=setTimeout(l(function(){this._cancel(),this._isTapValid()&&(Ot(document,"touchend",gr),Ot(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",E))},this),ro),Ot(document,"touchend touchcancel contextmenu",this._cancel,this),Ot(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function _(){tr(document,"touchend",gr),tr(document,"touchend touchcancel",_)},_cancel:function(){clearTimeout(this._holdTimeout),tr(document,"touchend touchcancel contextmenu",this._cancel,this),tr(document,"touchmove",this._onMove,this)},_onMove:function(_){var E=_.touches[0];this._newPos=new ge(E.clientX,E.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(_,E){var H=new MouseEvent(_,{bubbles:!0,cancelable:!0,view:window,screenX:E.screenX,screenY:E.screenY,clientX:E.clientX,clientY:E.clientY});H._simulated=!0,E.target.dispatchEvent(H)}});zt.addInitHook("addHandler","tapHold",no),zt.mergeOptions({touchZoom:Lt.touch,bounceAtZoomLimits:!0});var so=Nr.extend({addHooks:function(){Bt(this._map._container,"leaflet-touch-zoom"),Ot(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){cr(this._map._container,"leaflet-touch-zoom"),tr(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(_){var E=this._map;if(!(!_.touches||_.touches.length!==2||E._animatingZoom||this._zooming)){var H=E.mouseEventToContainerPoint(_.touches[0]),be=E.mouseEventToContainerPoint(_.touches[1]);this._centerPoint=E.getSize()._divideBy(2),this._startLatLng=E.containerPointToLatLng(this._centerPoint),E.options.touchZoom!=="center"&&(this._pinchStartLatLng=E.containerPointToLatLng(H.add(be)._divideBy(2))),this._startDist=H.distanceTo(be),this._startZoom=E.getZoom(),this._moved=!1,this._zooming=!0,E._stop(),Ot(document,"touchmove",this._onTouchMove,this),Ot(document,"touchend touchcancel",this._onTouchEnd,this),gr(_)}},_onTouchMove:function(_){if(!(!_.touches||_.touches.length!==2||!this._zooming)){var E=this._map,H=E.mouseEventToContainerPoint(_.touches[0]),be=E.mouseEventToContainerPoint(_.touches[1]),Me=H.distanceTo(be)/this._startDist;if(this._zoom=E.getScaleZoom(Me,this._startZoom),!E.options.bounceAtZoomLimits&&(this._zoomE.getMaxZoom()&&Me>1)&&(this._zoom=E._limitZoom(this._zoom)),E.options.touchZoom==="center"){if(this._center=this._startLatLng,Me===1)return}else{var Je=H._add(be)._divideBy(2)._subtract(this._centerPoint);if(Me===1&&Je.x===0&&Je.y===0)return;this._center=E.unproject(E.project(this._pinchStartLatLng,this._zoom).subtract(Je),this._zoom)}this._moved||(E._moveStart(!0,!1),this._moved=!0),_e(this._animRequest);var ct=l(E._move,E,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=he(ct,this,!0),gr(_)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,_e(this._animRequest),tr(document,"touchmove",this._onTouchMove,this),tr(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});zt.addInitHook("addHandler","touchZoom",so),zt.BoxZoom=Qs,zt.DoubleClickZoom=Js,zt.Drag=ls,zt.Keyboard=cs,zt.ScrollWheelZoom=eo,zt.TapHold=no,zt.TouchZoom=so,r.Bounds=Re,r.Browser=Lt,r.CRS=Ye,r.Canvas=Gs,r.Circle=Qn,r.CircleMarker=wi,r.Class=ae,r.Control=Lr,r.DivIcon=ki,r.DivOverlay=Fr,r.DomEvent=$o,r.DomUtil=Po,r.Draggable=Zr,r.Evented=ue,r.FeatureGroup=fn,r.GeoJSON=Vr,r.GridLayer=ti,r.Handler=Nr,r.Icon=kn,r.ImageOverlay=An,r.LatLng=Oe,r.LatLngBounds=Pe,r.Layer=Rr,r.LayerGroup=Cn,r.LineUtil=Os,r.Map=zt,r.Marker=Xn,r.Mixin=Oo,r.Path=Xr,r.Point=ge,r.PolyUtil=Ds,r.Polygon=pn,r.Polyline=Br,r.Popup=gn,r.PosAnimation=xs,r.Projection=Fo,r.Rectangle=Xs,r.Renderer=Hr,r.SVG=ni,r.SVGOverlay=is,r.TileLayer=yn,r.Tooltip=Ci,r.Transformation=Ve,r.Util=ve,r.VideoOverlay=js,r.bind=l,r.bounds=We,r.canvas=qs,r.circle=Vs,r.circleMarker=zo,r.control=jn,r.divIcon=Go,r.extend=o,r.featureGroup=Vo,r.geoJSON=Ws,r.geoJson=Wo,r.gridLayer=qo,r.icon=Ho,r.imageOverlay=jo,r.latLng=Be,r.latLngBounds=Ue,r.layerGroup=Uo,r.map=Es,r.marker=Us,r.point=Ae,r.polygon=xi,r.polyline=Hs,r.popup=Yo,r.rectangle=Qo,r.setOptions=T,r.stamp=u,r.svg=Zs,r.svgOverlay=ss,r.tileLayer=os,r.tooltip=Ks,r.transformation=oe,r.version=n,r.videoOverlay=Ko;var _n=window.L;r.noConflict=function(){return window.L=_n,this},window.L=r})})(leafletSrc,leafletSrc.exports);const L$2=leafletSrc.exports;(function(e){typeof e>"u"&&(e={getCenter:L.Map.prototype.getCenter,setView:L.Map.prototype.setView,flyTo:L.Map.prototype.flyTo,setZoomAround:L.Map.prototype.setZoomAround,getBoundsZoom:L.Map.prototype.getBoundsZoom,PopupAdjustPan:L.Popup.prototype._adjustPan,RendererUpdate:L.Renderer.prototype._update}),L.Map.include({getBounds:function(){if(this._viewport)return this.getViewportLatLngBounds();var t=this.getPixelBounds(),r=this.unproject(t.getBottomLeft()),n=this.unproject(t.getTopRight());return new L.LatLngBounds(r,n)},getViewport:function(){return this._viewport},getViewportBounds:function(){var t=this._viewport,r=L.point(t.offsetLeft,t.offsetTop),n=L.point(t.clientWidth,t.clientHeight);return(n.x===0||n.y===0)&&(t=this.getContainer(),t&&(r=L.point(0,0),n=L.point(t.clientWidth,t.clientHeight))),L.bounds(r,r.add(n))},getViewportLatLngBounds:function(){var t=this.getViewportBounds();return L.latLngBounds(this.containerPointToLatLng(t.min),this.containerPointToLatLng(t.max))},getOffset:function(){var t=this.getSize().divideBy(2),r=this.getViewportBounds().getCenter();return t.subtract(r)},getCenter:function(t){var r=e.getCenter.call(this);if(this.getViewport()&&!t){var n=this.getZoom(),o=this.project(r,n);o=o.subtract(this.getOffset()),r=this.unproject(o,n)}return r},setView:function(t,r,n){if(t=L.latLng(t),r=r===void 0?this._zoom:this._limitZoom(r),this.getViewport()){var o=this.project(t,this._limitZoom(r));o=o.add(this.getOffset()),t=this.unproject(o,this._limitZoom(r))}return e.setView.call(this,t,r,n)},flyTo:function(t,r,n){if(t=L.latLng(t),r=r===void 0?u:r,this.getViewport()){var o=this.project(t,this._limitZoom(r));o=o.add(this.getOffset()),t=this.unproject(o,this._limitZoom(r))}if(n=n||{},n.animate===!1||!L.Browser.any3d)return this.setView(t,r,n);this._stop();var a=this.project(e.getCenter.call(this)),l=this.project(t),c=this.getSize(),u=this._zoom,g=Math.max(c.x,c.y),b=g*this.getZoomScale(u,r),x=l.distanceTo(a)||1,S=1.42,$=S*S;function k(we){var he=we?-1:1,_e=we?b:g,ve=b*b-g*g+he*$*$*x*x,ae=2*_e*$*x,ie=ve/ae,pe=Math.sqrt(ie*ie+1)-ie,ue=pe<1e-9?-18:Math.log(pe);return ue}function T(we){return(Math.exp(we)-Math.exp(-we))/2}function D(we){return(Math.exp(we)+Math.exp(-we))/2}function I(we){return T(we)/D(we)}var O=k(0);function N(we){return g*(D(O)/D(O+S*we))}function ee(we){return g*(D(O)*I(O+S*we)-T(O))/$}function ne(we){return 1-Math.pow(1-we,1.5)}var B=Date.now(),le=(k(1)-O)/S,fe=n.duration?1e3*n.duration:1e3*le*.8;function xe(){var we=(Date.now()-B)/fe,he=ne(we)*le;we<=1?(this._flyToFrame=L.Util.requestAnimFrame(xe,this),this._move(this.unproject(a.add(l.subtract(a).multiplyBy(ee(he)/x)),u),this.getScaleZoom(g/N(he),u),{flyTo:!0})):this._move(t,r)._moveEnd(!0)}return this._moveStart(!0,n.noMoveStart),xe.call(this),this},setZoomAround:function(t,r,n){var o=this.getViewport();if(o){var a=this.getZoomScale(r),l=this.getViewportBounds().getCenter(),c=t instanceof L.Point?t:this.latLngToContainerPoint(t),u=c.subtract(l).multiplyBy(1-1/a),g=this.containerPointToLatLng(l.add(u));return this.setView(g,r,{zoom:n})}else return e.setZoomAround.call(this,t,r,n)},getBoundsZoom:function(t,r,n){t=L.latLngBounds(t),n=L.point(n||[0,0]);var o=this.getZoom()||0,a=this.getMinZoom(),l=this.getMaxZoom(),c=t.getNorthWest(),u=t.getSouthEast(),g=this.getViewport(),b=(g?L.point(g.clientWidth,g.clientHeight):this.getSize()).subtract(n),x=this.project(u,o).subtract(this.project(c,o)),S=L.Browser.any3d?this.options.zoomSnap:1,$=b.x/x.x,k=b.y/x.y,T=r?Math.max($,k):Math.min($,k);return o=this.getScaleZoom(T,o),S&&(o=Math.round(o/(S/100))*(S/100),o=r?Math.ceil(o/S)*S:Math.floor(o/S)*S),Math.max(a,Math.min(l,o))},setActiveArea:function(t,r,n){var o;if(r&&this._zoom&&(o=this.getCenter()),!this._viewport){var a=this.getContainer();this._viewport=L.DomUtil.create("div",""),a.insertBefore(this._viewport,a.firstChild)}return typeof t=="string"?this._viewport.className=t:L.extend(this._viewport.style,t),o&&this.setView(o,this.getZoom(),{animate:!!n}),this}}),L.Renderer.include({_onZoom:function(){this._updateTransform(this._map.getCenter(!0),this._map.getZoom())},_update:function(){e.RendererUpdate.call(this),this._center=this._map.getCenter(!0)}}),L.GridLayer.include({_updateLevels:function(){var t=this._tileZoom,r=this.options.maxZoom;if(t!==void 0){for(var n in this._levels)n=Number(n),this._levels[n].el.children.length||n===t?(this._levels[n].el.style.zIndex=r-Math.abs(t-n),this._onUpdateLevel(n)):(L.DomUtil.remove(this._levels[n].el),this._removeTilesAtZoom(n),this._onRemoveLevel(n),delete this._levels[n]);var o=this._levels[t],a=this._map;return o||(o=this._levels[t]={},o.el=L.DomUtil.create("div","leaflet-tile-container leaflet-zoom-animated",this._container),o.el.style.zIndex=r,o.origin=a.project(a.unproject(a.getPixelOrigin()),t).round(),o.zoom=t,this._setZoomTransform(o,a.getCenter(!0),a.getZoom()),L.Util.falseFn(o.el.offsetWidth),this._onCreateLevel(o)),this._level=o,o}},_resetView:function(t){var r=t&&(t.pinch||t.flyTo);this._setView(this._map.getCenter(!0),this._map.getZoom(),r,r)},_update:function(t){var r=this._map;if(!!r){var n=this._clampZoom(r.getZoom());if(t===void 0&&(t=r.getCenter(!0)),this._tileZoom!==void 0){var o=this._getTiledPixelBounds(t),a=this._pxBoundsToTileRange(o),l=a.getCenter(),c=[],u=this.options.keepBuffer,g=new L.Bounds(a.getBottomLeft().subtract([u,-u]),a.getTopRight().add([u,-u]));if(!(isFinite(a.min.x)&&isFinite(a.min.y)&&isFinite(a.max.x)&&isFinite(a.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var b in this._tiles){var x=this._tiles[b].coords;(x.z!==this._tileZoom||!g.contains(new L.Point(x.x,x.y)))&&(this._tiles[b].current=!1)}if(Math.abs(n-this._tileZoom)>1){this._setView(t,n);return}for(var S=a.min.y;S<=a.max.y;S++)for(var $=a.min.x;$<=a.max.x;$++){var k=new L.Point($,S);if(k.z=this._tileZoom,!!this._isValidTile(k)){var T=this._tiles[this._tileCoordsToKey(k)];T?T.current=!0:c.push(k)}}if(c.sort(function(I,O){return I.distanceTo(l)-O.distanceTo(l)}),c.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var D=document.createDocumentFragment();for($=0;$x.x&&(S=c.x+o-x.x+b.x),c.x-S-g.x<0&&(S=c.x-g.x),c.y+n+b.y>x.y&&($=c.y+n-x.y+b.y),c.y-$-g.y<0&&($=c.y-g.y),(S||$)&&t.fire("autopanstart").panBy([S,$])}}})})(window.leafletActiveAreaPreviousMethods);L.TileLayer.ColorFilter=L.TileLayer.extend({intialize:function(e,t){L.TileLayer.prototype.initialize.call(this,e,t)},colorFilter:function(){var e=["blur:px","brightness:%","bright:brightness:%","bri:brightness:%","contrast:%","con:contrast:%","grayscale:%","gray:grayscale:%","hue-rotate:deg","hue:hue-rotate:deg","hue-rotation:hue-rotate:deg","invert:%","inv:invert:%","opacity:%","op:opacity:%","saturate:%","saturation:saturate:%","sat:saturate:%","sepia:%","sep:sepia:%"];return(this.options.filter?this.options.filter:[]).map(function(t){var r=t.toLowerCase().split(":");if(r.length===2){var n=e.find(function(o){return o.split(":")[0]===r[0]});if(n)return n=n.split(":"),r[1]+=/^\d+$/.test(r[1])?n[n.length-1]:"","".concat(n[n.length-2],"(").concat(r[1],")")}return""}).join(" ")},_initContainer:function(){L.TileLayer.prototype._initContainer.call(this),this._container.style.filter=this.colorFilter()},updateFilter:function(e){this.options.filter=e,this._container&&(this._container.style.filter=this.colorFilter())}}),L.tileLayer.colorFilter=function(e,t){return new L.TileLayer.ColorFilter(e,t)};const leaflet="";let map$3,usermarker;const attrs$1={attribution:'© OpenStreetMap contributors'},layerMapLight=L$2.tileLayer.colorFilter("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{...attrs$1,filter:["grayscale:50%","saturate:70%"]}),layerMapDark=L$2.tileLayer.colorFilter("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{...attrs$1,filter:["invert:100%","grayscale:100%","bright:100%","saturate:0%","sepia:10%"]});function instanceMap(){if(map$3)return map$3;throw new Error("Must be initialized before using the mapd.")}function removeMap(){map$3.remove(),map$3=void 0}function init$3(e,t,r="light"){return map$3=L$2.map("map",{minZoom:3}),setTheme(r),map$3.attributionControl.setPrefix(""),map$3.setView(e,t),map$3.zoomControl.remove(),map$3}function setTheme(e){const t=instanceMap();e==="light"?(t.removeLayer(layerMapDark),t.addLayer(layerMapLight)):(t.removeLayer(layerMapLight),t.addLayer(layerMapDark))}function setview(e,t){const r=instanceMap();r&&r.setView(e,t)}function drawuser(e,t){const r=instanceMap();let n=100;r&&(usermarker&&r.removeLayer(usermarker),t>0&&(n=10*t),t>4&&(n=5*t),t>7&&(n=2*t),usermarker=new L$2.circleMarker(e,{radius:n,opacity:.2}),usermarker.addTo(r))}const scriptRel="modulepreload",assetsURL=function(e){return"/"+e},seen={},__vitePreload=function(t,r,n){if(!r||r.length===0)return t();const o=document.getElementsByTagName("link");return Promise.all(r.map(a=>{if(a=assetsURL(a),a in seen)return;seen[a]=!0;const l=a.endsWith(".css"),c=l?'[rel="stylesheet"]':"";if(!!n)for(let b=o.length-1;b>=0;b--){const x=o[b];if(x.href===a&&(!l||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${a}"]${c}`))return;const g=document.createElement("link");if(g.rel=l?"stylesheet":scriptRel,l||(g.as="script",g.crossOrigin=""),g.href=a,document.head.appendChild(g),l)return new Promise((b,x)=>{g.addEventListener("load",b),g.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${a}`)))})})).then(()=>t())},__variableDynamicImportRuntimeHelper=(e,t)=>{const r=e[t];return r?typeof r=="function"?r():Promise.resolve(r):new Promise((n,o)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(o.bind(null,new Error("Unknown variable dynamic import: "+t)))})};function Queue(e){Object.defineProperties(this,{add:{enumerable:!0,writable:!1,value:l},next:{enumerable:!0,writable:!1,value:c},clear:{enumerable:!0,writable:!1,value:n},contents:{enumerable:!1,get:o,set:a},autoRun:{enumerable:!0,writable:!0,value:!0},stop:{enumerable:!0,writable:!0,value:!1}});var t=[],r=!1;function n(){return t=[],t}function o(){return t}function a(u){return t=u,t}function l(){for(var u in arguments)t.push(arguments[u]);!r&&!this.stop&&this.autoRun&&this.next()}function c(){if(r=!0,t.length<1||this.stop){r=!1;return}t.shift().bind(this)()}}var queue$1=Queue,leaflet_geometryutil={exports:{}};(function(e){(function(t){var r;r=leafletSrc.exports,e.exports=t(r)})(function(t){return t.Polyline._flat=t.LineUtil.isFlat||t.Polyline._flat||function(r){return!t.Util.isArray(r[0])||typeof r[0][0]!="object"&&typeof r[0][0]<"u"},t.GeometryUtil=t.extend(t.GeometryUtil||{},{distance:function(r,n,o){return r.latLngToLayerPoint(n).distanceTo(r.latLngToLayerPoint(o))},distanceSegment:function(r,n,o,a){var l=r.latLngToLayerPoint(n),c=r.latLngToLayerPoint(o),u=r.latLngToLayerPoint(a);return t.LineUtil.pointToSegmentDistance(l,c,u)},readableDistance:function(r,n){var o=n!=="imperial",a;return o?r>1e3?a=(r/1e3).toFixed(2)+" km":a=r.toFixed(1)+" m":(r*=1.09361,r>1760?a=(r/1760).toFixed(2)+" miles":a=r.toFixed(1)+" yd"),a},belongsSegment:function(r,n,o,a){a=a===void 0?.2:a;var l=n.distanceTo(o),c=n.distanceTo(r)+r.distanceTo(o)-l;return c/l0?n[n.length-1]:0},accumulatedLengths:function(r){if(typeof r.getLatLngs=="function"&&(r=r.getLatLngs()),r.length===0)return[];for(var n=0,o=[0],a=0,l=r.length-1;aa?l.slice(0,a):l},layersWithin:function(r,n,o,a){a=typeof a=="number"?a:1/0;for(var l=[],c=null,u=0,g=0,b=n.length;ga)return null;if(l&&typeof c.layer.getLatLngs=="function"){var u=t.GeometryUtil.closest(r,c.layer,c.latlng,!0);u.distance0&&(u+=c[g-1].distanceTo(c[g]));for(var b=u*o,x=0,S=0,g=0;Sa)return t.GeometryUtil.extract(r,t.GeometryUtil.reverse(n),1-o,1-a);o=Math.max(Math.min(o,1),0),a=Math.max(Math.min(a,1),0);var l=n.getLatLngs(),c=t.GeometryUtil.interpolateOnLine(r,n,o),u=t.GeometryUtil.interpolateOnLine(r,n,a);if(o==a){var g=t.GeometryUtil.interpolateOnLine(r,n,a);return[g.latLng]}c.predecessor==-1&&(c.predecessor=0),u.predecessor==-1&&(u.predecessor=0);var b=l.slice(c.predecessor+1,u.predecessor+1);return b.unshift(c.latLng),b.push(u.latLng),b},isBefore:function(r,n){if(!n)return!1;var o=r.getLatLngs(),a=n.getLatLngs();return o[o.length-1].equals(a[0])},isAfter:function(r,n){if(!n)return!1;var o=r.getLatLngs(),a=n.getLatLngs();return o[0].equals(a[a.length-1])},startsAtExtremity:function(r,n){if(!n)return!1;var o=r.getLatLngs(),a=n.getLatLngs(),l=o[0];return l.equals(a[0])||l.equals(a[a.length-1])},computeAngle:function(r,n){return Math.atan2(n.y-r.y,n.x-r.x)*180/Math.PI},computeSlope:function(r,n){var o=(n.y-r.y)/(n.x-r.x),a=r.y-o*r.x;return{a:o,b:a}},rotatePoint:function(r,n,o,a){var l=r.getMaxZoom();l===1/0&&(l=r.getZoom());var c=o*Math.PI/180,u=r.project(n,l),g=r.project(a,l),b=Math.cos(c)*(u.x-g.x)-Math.sin(c)*(u.y-g.y)+g.x,x=Math.sin(c)*(u.x-g.x)+Math.cos(c)*(u.y-g.y)+g.y;return r.unproject(new t.Point(b,x),l)},bearing:function(r,n){var o=Math.PI/180,a=r.lat*o,l=n.lat*o,c=r.lng*o,u=n.lng*o,g=Math.sin(u-c)*Math.cos(l),b=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(u-c),x=(Math.atan2(g,b)*180/Math.PI+360)%360;return x>=180?x-360:x},destination:function(r,n,o){n=(n+360)%360;var a=Math.PI/180,l=180/Math.PI,c=6378137,u=r.lng*a,g=r.lat*a,b=n*a,x=Math.sin(g),S=Math.cos(g),$=Math.cos(o/c),k=Math.sin(o/c),T=Math.asin(x*$+S*k*Math.cos(b)),D=u+Math.atan2(Math.sin(b)*k*S,$-x*Math.sin(T));return D=D*l,D=D>180?D-360:D<-180?D+360:D,t.latLng([T*l,D])},angle:function(r,n,o){var a=r.latLngToContainerPoint(n),l=r.latLngToContainerPoint(o),c=Math.atan2(l.y-a.y,l.x-a.x)*180/Math.PI+90;return c+=c<0?360:0,c},destinationOnSegment:function(r,n,o,a){var l=t.GeometryUtil.angle(r,n,o),c=t.GeometryUtil.destination(n,l,a);return t.GeometryUtil.closestOnSegment(r,c,n,o)}}),t.GeometryUtil})})(leaflet_geometryutil);function modulus(e,t){return(e%t+t)%t}function definedProps(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0))}function isInMeters(e){return e.toString().trim().slice(e.toString().length-1,e.toString().length)==="m"}function isInPercent(e){return e.toString().trim().slice(e.toString().length-1,e.toString().length)==="%"}function isInPixels(e){return e.toString().trim().slice(e.toString().length-2,e.toString().length)==="px"}function pixelsToMeters(e,t){let r=t.getCenter(),n=t.latLngToLayerPoint(r),o={x:n.x+Number(e),y:n.y},a=t.layerPointToLatLng(o);return t.distance(r,a)}L.Polyline.include({arrowheads:function(e={}){const t={yawn:60,size:"15%",frequency:"allvertices",proportionalToTotal:!1};this.options.noClip=!0;let r=Object.assign({},t,e);return this._arrowheadOptions=r,this._hatsApplied=!0,this},buildVectorHats:function(e){this._arrowheads&&this._arrowheads.remove(),this._ghosts&&this._ghosts.remove();let t=Object.getPrototypeOf(Object.getPrototypeOf(this.options)),r=Object.assign({},t,this.options),n=Object.assign({},r,e);n.smoothFactor=1,n.fillOpacity=1,n.fill=!!e.fill,n.interactive=!1;let o=e.size.toString(),a=[];const{frequency:l,offsets:c}=e;(c?.start||c?.end)&&this._buildGhosts({start:c.start,end:c.end}),(this._ghosts||this)._parts.forEach((b,x)=>{const S=b.map(B=>this._map.layerPointToLatLng(B)),$=(()=>{let B=0;for(var le=0;le{let B=l.slice(0,l.length-2);return pixelsToMeters(B,this._map)/$})(),I=1/D,I=Math.floor(I),D=1/I):(D=1/l,I=l),e.frequency==="allvertices")T=(()=>{let B=[];for(var le=1;le=2)k=[S[S.length-1]],T=[L.GeometryUtil.angle(this._map,S[S.length-2],S[S.length-1])+180];else{k=[];let B=[];for(var O=0;O{let le=[];for(var fe=0;fe{let fe=le.yawn??e.yawn,xe=L.GeometryUtil.destination(k[O],T[O]-fe/2,B),we=L.GeometryUtil.destination(k[O],T[O]+fe/2,B),he=[[xe.lat,xe.lng],[k[O].lat,k[O].lng],[we.lat,we.lng]],_e=e.fill?L.polygon(he,{...n,...le}):L.polyline(he,{...n,...le});N.push(_e)},ne=(B,le={})=>{let fe=B.slice(0,B.length-2),xe=le.yawn??e.yawn,we=this._map.latLngToLayerPoint(k[O]),he=T[O],_e=(180-he-xe/2)*(Math.PI/180),ve=(180-he+xe/2)*(Math.PI/180),ae=fe*Math.sin(_e),ie=fe*Math.cos(_e),pe=fe*Math.sin(ve),ue=fe*Math.cos(ve),ge={x:we.x+ae,y:we.y+ie},ye={x:we.x+pe,y:we.y+ue},Ae=this._map.layerPointToLatLng(ge),Re=this._map.layerPointToLatLng(ye),We=[[Ae.lat,Ae.lng],[k[O].lat,k[O].lng],[Re.lat,Re.lng]],Pe=e.fill?L.polygon(We,{...n,...le}):L.polyline(We,{...n,...le});N.push(Pe)};for(var O=0;Oe.frequency==="endonly"&&e.proportionalToTotal?$*xe/100:$/(b.length-1)*xe/100)();ee(we,le)}else isInPixels(o)?ne(e.size,le):console.error("Error: Arrowhead size unit not defined. Check your arrowhead options.")}a.push(...N)});let g=L.layerGroup(a);return this._arrowheads=g,this},getArrowheads:function(){return this._arrowheads?this._arrowheads:console.error("Error: You tried to call '.getArrowheads() on a shape that does not have a arrowhead. Use '.arrowheads()' to add a arrowheads before trying to call '.getArrowheads()'")},_buildGhosts:function({start:e,end:t}){if(e||t){let r=this.getLatLngs();r=Array.isArray(r[0])?r:[r];const n=r.map(o=>{const a=(()=>{let l=0;for(var c=0;c{if(isInMeters(e))return Number(e.slice(0,e.length-1));if(isInPixels(e)){let u=Number(e.slice(0,e.length-2));return pixelsToMeters(u,this._map)}})(),c=L.GeometryUtil.interpolateOnLine(this._map,o,l/a);o=o.slice(c.predecessor===-1?1:c.predecessor+1,o.length),o.unshift(c.latLng)}if(t){let l=(()=>{if(isInMeters(t))return Number(t.slice(0,t.length-1));if(isInPixels(t)){let u=Number(t.slice(0,t.length-2));return pixelsToMeters(u,this._map)}})(),c=L.GeometryUtil.interpolateOnLine(this._map,o,(a-l)/a);o=o.slice(0,c.predecessor+1),o.push(c.latLng)}return o});this._ghosts=L.polyline(n,{...this.options,color:"rgba(0,0,0,0)",stroke:0,smoothFactor:0,interactive:!1}),this._ghosts.addTo(this._map)}},deleteArrowheads:function(){this._arrowheads&&(this._arrowheads.remove(),delete this._arrowheads,delete this._arrowheadOptions,this._hatsApplied=!1),this._ghosts&&this._ghosts.remove()},_update:function(){!this._map||(this._clipPoints(),this._simplifyPoints(),this._updatePath(),this._hatsApplied&&(this.buildVectorHats(this._arrowheadOptions),this._map.addLayer(this._arrowheads)))},remove:function(){return this._arrowheads&&this._arrowheads.remove(),this._ghosts&&this._ghosts.remove(),this.removeFrom(this._map||this._mapToAdd)}});L.LayerGroup.include({removeLayer:function(e){var t=e in this._layers?e:this.getLayerId(e);return this._map&&this._layers[t]&&(this._layers[t]._arrowheads&&this._layers[t]._arrowheads.remove(),this._map.removeLayer(this._layers[t])),delete this._layers[t],this},onRemove:function(e,t){for(var t in this._layers)this._layers[t]&&this._layers[t].remove();this.eachLayer(e.removeLayer,e)}});L.Map.include({removeLayer:function(e){var t=L.Util.stamp(e);return e._arrowheads&&e._arrowheads.remove(),e._ghosts&&e._ghosts.remove(),this._layers[t]?(this._loaded&&e.onRemove(this),e.getAttribution&&this.attributionControl&&this.attributionControl.removeAttribution(e.getAttribution()),delete this._layers[t],this._loaded&&(this.fire("layerremove",{layer:e}),e.fire("remove")),e._map=e._mapToAdd=null,this):this}});L.GeoJSON.include({geometryToLayer:function(e,t){var r=e.type==="Feature"?e.geometry:e,n=r?r.coordinates:null,o=[],a=t&&t.pointToLayer,l=t&&t.coordsToLatLng||L.GeoJSON.coordsToLatLng,c,u,g,b;if(!n&&!r)return null;switch(r.type){case"Point":return c=l(n),this._pointToLayer(a,e,c,t);case"MultiPoint":for(g=0,b=n.length;g=c;)l=l.__parent;return this._currentShownBounds.contains(l.getLatLng())&&(this.options.animateAddingMarkers?this._animationAddLayer(a,l):this._animationAddLayerNonAnimated(a,l)),this},removeLayer:function(a){return a instanceof L.LayerGroup?this.removeLayers([a]):a.getLatLng?this._map?a.__parent?(this._unspiderfy&&(this._unspiderfy(),this._unspiderfyLayer(a)),this._removeLayer(a,!0),this.fire("layerremove",{layer:a}),this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),a.off(this._childMarkerEventHandlers,this),this._featureGroup.hasLayer(a)&&(this._featureGroup.removeLayer(a),a.clusterShow&&a.clusterShow()),this):this:(!this._arraySplice(this._needsClustering,a)&&this.hasLayer(a)&&this._needsRemoving.push({layer:a,latlng:a._latlng}),this.fire("layerremove",{layer:a}),this):(this._nonPointGroup.removeLayer(a),this.fire("layerremove",{layer:a}),this)},addLayers:function(a,l){if(!L.Util.isArray(a))return this.addLayer(a);var c=this._featureGroup,u=this._nonPointGroup,g=this.options.chunkedLoading,b=this.options.chunkInterval,x=this.options.chunkProgress,S=a.length,$=0,k=!0,T;if(this._map){var D=new Date().getTime(),I=L.bind(function(){var N=new Date().getTime();for(this._map&&this._unspiderfy&&this._unspiderfy();$b)break}if(T=a[$],T instanceof L.LayerGroup){k&&(a=a.slice(),k=!1),this._extractNonGroupLayers(T,a),S=a.length;continue}if(!T.getLatLng){u.addLayer(T),l||this.fire("layeradd",{layer:T});continue}if(!this.hasLayer(T)&&(this._addLayer(T,this._maxZoom),l||this.fire("layeradd",{layer:T}),T.__parent&&T.__parent.getChildCount()===2)){var ne=T.__parent.getAllChildMarkers(),B=ne[0]===T?ne[1]:ne[0];c.removeLayer(B)}}x&&x($,S,new Date().getTime()-D),$===S?(this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds)):setTimeout(I,this.options.chunkDelay)},this);I()}else for(var O=this._needsClustering;$=0;l--)a.extend(this._needsClustering[l].getLatLng());return a.extend(this._nonPointGroup.getBounds()),a},eachLayer:function(a,l){var c=this._needsClustering.slice(),u=this._needsRemoving,g,b,x;for(this._topClusterLevel&&this._topClusterLevel.getAllChildMarkers(c),b=c.length-1;b>=0;b--){for(g=!0,x=u.length-1;x>=0;x--)if(u[x].layer===c[b]){g=!1;break}g&&a.call(l,c[b])}this._nonPointGroup.eachLayer(a,l)},getLayers:function(){var a=[];return this.eachLayer(function(l){a.push(l)}),a},getLayer:function(a){var l=null;return a=parseInt(a,10),this.eachLayer(function(c){L.stamp(c)===a&&(l=c)}),l},hasLayer:function(a){if(!a)return!1;var l,c=this._needsClustering;for(l=c.length-1;l>=0;l--)if(c[l]===a)return!0;for(c=this._needsRemoving,l=c.length-1;l>=0;l--)if(c[l].layer===a)return!1;return!!(a.__parent&&a.__parent._group===this)||this._nonPointGroup.hasLayer(a)},zoomToShowLayer:function(a,l){var c=this._map;typeof l!="function"&&(l=function(){});var u=function(){(c.hasLayer(a)||c.hasLayer(a.__parent))&&!this._inZoomAnimation&&(this._map.off("moveend",u,this),this.off("animationend",u,this),c.hasLayer(a)?l():a.__parent._icon&&(this.once("spiderfied",l,this),a.__parent.spiderfy()))};a._icon&&this._map.getBounds().contains(a.getLatLng())?l():a.__parent._zoom=0;c--)if(a[c]===l)return a.splice(c,1),!0},_removeFromGridUnclustered:function(a,l){for(var c=this._map,u=this._gridUnclustered,g=Math.floor(this._map.getMinZoom());l>=g&&u[l].removeObject(a,c.project(a.getLatLng(),l));l--);},_childMarkerDragStart:function(a){a.target.__dragStart=a.target._latlng},_childMarkerMoved:function(a){if(!this._ignoreMove&&!a.target.__dragStart){var l=a.target._popup&&a.target._popup.isOpen();this._moveChild(a.target,a.oldLatLng,a.latlng),l&&a.target.openPopup()}},_moveChild:function(a,l,c){a._latlng=l,this.removeLayer(a),a._latlng=c,this.addLayer(a)},_childMarkerDragEnd:function(a){var l=a.target.__dragStart;delete a.target.__dragStart,l&&this._moveChild(a.target,l,a.target._latlng)},_removeLayer:function(a,l,c){var u=this._gridClusters,g=this._gridUnclustered,b=this._featureGroup,x=this._map,S=Math.floor(this._map.getMinZoom());l&&this._removeFromGridUnclustered(a,this._maxZoom);var $=a.__parent,k=$._markers,T;for(this._arraySplice(k,a);$&&($._childCount--,$._boundsNeedUpdate=!0,!($._zoom"+l+"",className:"marker-cluster"+c,iconSize:new L.Point(40,40)})},_bindEvents:function(){var a=this._map,l=this.options.spiderfyOnMaxZoom,c=this.options.showCoverageOnHover,u=this.options.zoomToBoundsOnClick,g=this.options.spiderfyOnEveryZoom;(l||u||g)&&this.on("clusterclick clusterkeypress",this._zoomOrSpiderfy,this),c&&(this.on("clustermouseover",this._showCoverage,this),this.on("clustermouseout",this._hideCoverage,this),a.on("zoomend",this._hideCoverage,this))},_zoomOrSpiderfy:function(a){var l=a.layer,c=l;if(!(a.type==="clusterkeypress"&&a.originalEvent&&a.originalEvent.keyCode!==13)){for(;c._childClusters.length===1;)c=c._childClusters[0];c._zoom===this._maxZoom&&c._childCount===l._childCount&&this.options.spiderfyOnMaxZoom?l.spiderfy():this.options.zoomToBoundsOnClick&&l.zoomToBounds(),this.options.spiderfyOnEveryZoom&&l.spiderfy(),a.originalEvent&&a.originalEvent.keyCode===13&&this._map._container.focus()}},_showCoverage:function(a){var l=this._map;this._inZoomAnimation||(this._shownPolygon&&l.removeLayer(this._shownPolygon),a.layer.getChildCount()>2&&a.layer!==this._spiderfied&&(this._shownPolygon=new L.Polygon(a.layer.getConvexHull(),this.options.polygonOptions),l.addLayer(this._shownPolygon)))},_hideCoverage:function(){this._shownPolygon&&(this._map.removeLayer(this._shownPolygon),this._shownPolygon=null)},_unbindEvents:function(){var a=this.options.spiderfyOnMaxZoom,l=this.options.showCoverageOnHover,c=this.options.zoomToBoundsOnClick,u=this.options.spiderfyOnEveryZoom,g=this._map;(a||c||u)&&this.off("clusterclick clusterkeypress",this._zoomOrSpiderfy,this),l&&(this.off("clustermouseover",this._showCoverage,this),this.off("clustermouseout",this._hideCoverage,this),g.off("zoomend",this._hideCoverage,this))},_zoomEnd:function(){!this._map||(this._mergeSplitClusters(),this._zoom=Math.round(this._map._zoom),this._currentShownBounds=this._getExpandedVisibleBounds())},_moveEnd:function(){if(!this._inZoomAnimation){var a=this._getExpandedVisibleBounds();this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),this._zoom,a),this._topClusterLevel._recursivelyAddChildrenToMap(null,Math.round(this._map._zoom),a),this._currentShownBounds=a}},_generateInitialClusters:function(){var a=Math.ceil(this._map.getMaxZoom()),l=Math.floor(this._map.getMinZoom()),c=this.options.maxClusterRadius,u=c;typeof c!="function"&&(u=function(){return c}),this.options.disableClusteringAtZoom!==null&&(a=this.options.disableClusteringAtZoom-1),this._maxZoom=a,this._gridClusters={},this._gridUnclustered={};for(var g=a;g>=l;g--)this._gridClusters[g]=new L.DistanceGrid(u(g)),this._gridUnclustered[g]=new L.DistanceGrid(u(g));this._topClusterLevel=new this._markerCluster(this,l-1)},_addLayer:function(a,l){var c=this._gridClusters,u=this._gridUnclustered,g=Math.floor(this._map.getMinZoom()),b,x;for(this.options.singleMarkerMode&&this._overrideMarkerIcon(a),a.on(this._childMarkerEventHandlers,this);l>=g;l--){b=this._map.project(a.getLatLng(),l);var S=c[l].getNearObject(b);if(S){S._addChild(a),a.__parent=S;return}if(S=u[l].getNearObject(b),S){var $=S.__parent;$&&this._removeLayer(S,!1);var k=new this._markerCluster(this,l,S,a);c[l].addObject(k,this._map.project(k._cLatLng,l)),S.__parent=k,a.__parent=k;var T=k;for(x=l-1;x>$._zoom;x--)T=new this._markerCluster(this,x,T),c[x].addObject(T,this._map.project(S.getLatLng(),x));$._addChild(T),this._removeFromGridUnclustered(S,l);return}u[l].addObject(a,b)}this._topClusterLevel._addChild(a),a.__parent=this._topClusterLevel},_refreshClustersIcons:function(){this._featureGroup.eachLayer(function(a){a instanceof L.MarkerCluster&&a._iconNeedsUpdate&&a._updateIcon()})},_enqueue:function(a){this._queue.push(a),this._queueTimeout||(this._queueTimeout=setTimeout(L.bind(this._processQueue,this),300))},_processQueue:function(){for(var a=0;aa?(this._animationStart(),this._animationZoomOut(this._zoom,a)):this._moveEnd()},_getExpandedVisibleBounds:function(){if(this.options.removeOutsideVisibleBounds){if(L.Browser.mobile)return this._checkBoundsMaxLat(this._map.getBounds())}else return this._mapBoundsInfinite;return this._checkBoundsMaxLat(this._map.getBounds().pad(1))},_checkBoundsMaxLat:function(a){var l=this._maxLat;return l!==void 0&&(a.getNorth()>=l&&(a._northEast.lat=1/0),a.getSouth()<=-l&&(a._southWest.lat=-1/0)),a},_animationAddLayerNonAnimated:function(a,l){if(l===a)this._featureGroup.addLayer(a);else if(l._childCount===2){l._addToMap();var c=l.getAllChildMarkers();this._featureGroup.removeLayer(c[0]),this._featureGroup.removeLayer(c[1])}else l._updateIcon()},_extractNonGroupLayers:function(a,l){var c=a.getLayers(),u=0,g;for(l=l||[];u=0;b--)k=$[b],c.contains(k._latlng)||u.removeLayer(k)}),this._forceLayout(),this._topClusterLevel._recursivelyBecomeVisible(c,l),u.eachLayer(function(x){!(x instanceof L.MarkerCluster)&&x._icon&&x.clusterShow()}),this._topClusterLevel._recursively(c,a,l,function(x){x._recursivelyRestoreChildPositions(l)}),this._ignoreMove=!1,this._enqueue(function(){this._topClusterLevel._recursively(c,a,g,function(x){u.removeLayer(x),x.clusterShow()}),this._animationEnd()})},_animationZoomOut:function(a,l){this._animationZoomOutSingle(this._topClusterLevel,a-1,l),this._topClusterLevel._recursivelyAddChildrenToMap(null,l,this._getExpandedVisibleBounds()),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),a,this._getExpandedVisibleBounds())},_animationAddLayer:function(a,l){var c=this,u=this._featureGroup;u.addLayer(a),l!==a&&(l._childCount>2?(l._updateIcon(),this._forceLayout(),this._animationStart(),a._setPos(this._map.latLngToLayerPoint(l.getLatLng())),a.clusterHide(),this._enqueue(function(){u.removeLayer(a),a.clusterShow(),c._animationEnd()})):(this._forceLayout(),c._animationStart(),c._animationZoomOutSingle(l,this._map.getMaxZoom(),this._zoom)))}},_animationZoomOutSingle:function(a,l,c){var u=this._getExpandedVisibleBounds(),g=Math.floor(this._map.getMinZoom());a._recursivelyAnimateChildrenInAndAddSelfToMap(u,g,l+1,c);var b=this;this._forceLayout(),a._recursivelyBecomeVisible(u,c),this._enqueue(function(){if(a._childCount===1){var x=a._markers[0];this._ignoreMove=!0,x.setLatLng(x.getLatLng()),this._ignoreMove=!1,x.clusterShow&&x.clusterShow()}else a._recursively(u,c,g,function(S){S._recursivelyRemoveChildrenFromMap(u,g,l+1)});b._animationEnd()})},_animationEnd:function(){this._map&&(this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim","")),this._inZoomAnimation--,this.fire("animationend")},_forceLayout:function(){L.Util.falseFn(document.body.offsetWidth)}}),L.markerClusterGroup=function(a){return new L.MarkerClusterGroup(a)};var o=L.MarkerCluster=L.Marker.extend({options:L.Icon.prototype.options,initialize:function(a,l,c,u){L.Marker.prototype.initialize.call(this,c?c._cLatLng||c.getLatLng():new L.LatLng(0,0),{icon:this,pane:a.options.clusterPane}),this._group=a,this._zoom=l,this._markers=[],this._childClusters=[],this._childCount=0,this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._bounds=new L.LatLngBounds,c&&this._addChild(c),u&&this._addChild(u)},getAllChildMarkers:function(a,l){a=a||[];for(var c=this._childClusters.length-1;c>=0;c--)this._childClusters[c].getAllChildMarkers(a,l);for(var u=this._markers.length-1;u>=0;u--)l&&this._markers[u].__dragStart||a.push(this._markers[u]);return a},getChildCount:function(){return this._childCount},zoomToBounds:function(a){for(var l=this._childClusters.slice(),c=this._group._map,u=c.getBoundsZoom(this._bounds),g=this._zoom+1,b=c.getZoom(),x;l.length>0&&u>g;){g++;var S=[];for(x=0;xg?this._group._map.setView(this._latlng,g):u<=b?this._group._map.setView(this._latlng,b+1):this._group._map.fitBounds(this._bounds,a)},getBounds:function(){var a=new L.LatLngBounds;return a.extend(this._bounds),a},_updateIcon:function(){this._iconNeedsUpdate=!0,this._icon&&this.setIcon(this)},createIcon:function(){return this._iconNeedsUpdate&&(this._iconObj=this._group.options.iconCreateFunction(this),this._iconNeedsUpdate=!1),this._iconObj.createIcon()},createShadow:function(){return this._iconObj.createShadow()},_addChild:function(a,l){this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._setClusterCenter(a),a instanceof L.MarkerCluster?(l||(this._childClusters.push(a),a.__parent=this),this._childCount+=a._childCount):(l||this._markers.push(a),this._childCount++),this.__parent&&this.__parent._addChild(a,!0)},_setClusterCenter:function(a){this._cLatLng||(this._cLatLng=a._cLatLng||a._latlng)},_resetBounds:function(){var a=this._bounds;a._southWest&&(a._southWest.lat=1/0,a._southWest.lng=1/0),a._northEast&&(a._northEast.lat=-1/0,a._northEast.lng=-1/0)},_recalculateBounds:function(){var a=this._markers,l=this._childClusters,c=0,u=0,g=this._childCount,b,x,S,$;if(g!==0){for(this._resetBounds(),b=0;b=0;b--)x=g[b],x._icon&&(x._setPos(l),x.clusterHide())},function(u){var g=u._childClusters,b,x;for(b=g.length-1;b>=0;b--)x=g[b],x._icon&&(x._setPos(l),x.clusterHide())})},_recursivelyAnimateChildrenInAndAddSelfToMap:function(a,l,c,u){this._recursively(a,u,l,function(g){g._recursivelyAnimateChildrenIn(a,g._group._map.latLngToLayerPoint(g.getLatLng()).round(),c),g._isSingleParent()&&c-1===u?(g.clusterShow(),g._recursivelyRemoveChildrenFromMap(a,l,c)):g.clusterHide(),g._addToMap()})},_recursivelyBecomeVisible:function(a,l){this._recursively(a,this._group._map.getMinZoom(),l,null,function(c){c.clusterShow()})},_recursivelyAddChildrenToMap:function(a,l,c){this._recursively(c,this._group._map.getMinZoom()-1,l,function(u){if(l!==u._zoom)for(var g=u._markers.length-1;g>=0;g--){var b=u._markers[g];!c.contains(b._latlng)||(a&&(b._backupLatlng=b.getLatLng(),b.setLatLng(a),b.clusterHide&&b.clusterHide()),u._group._featureGroup.addLayer(b))}},function(u){u._addToMap(a)})},_recursivelyRestoreChildPositions:function(a){for(var l=this._markers.length-1;l>=0;l--){var c=this._markers[l];c._backupLatlng&&(c.setLatLng(c._backupLatlng),delete c._backupLatlng)}if(a-1===this._zoom)for(var u=this._childClusters.length-1;u>=0;u--)this._childClusters[u]._restorePosition();else for(var g=this._childClusters.length-1;g>=0;g--)this._childClusters[g]._recursivelyRestoreChildPositions(a)},_restorePosition:function(){this._backupLatlng&&(this.setLatLng(this._backupLatlng),delete this._backupLatlng)},_recursivelyRemoveChildrenFromMap:function(a,l,c,u){var g,b;this._recursively(a,l-1,c-1,function(x){for(b=x._markers.length-1;b>=0;b--)g=x._markers[b],(!u||!u.contains(g._latlng))&&(x._group._featureGroup.removeLayer(g),g.clusterShow&&g.clusterShow())},function(x){for(b=x._childClusters.length-1;b>=0;b--)g=x._childClusters[b],(!u||!u.contains(g._latlng))&&(x._group._featureGroup.removeLayer(g),g.clusterShow&&g.clusterShow())})},_recursively:function(a,l,c,u,g){var b=this._childClusters,x=this._zoom,S,$;if(l<=x&&(u&&u(this),g&&x===c&&g(this)),x=0;S--)$=b[S],$._boundsNeedUpdate&&$._recalculateBounds(),a.intersects($._bounds)&&$._recursively(a,l,c,u,g)},_isSingleParent:function(){return this._childClusters.length>0&&this._childClusters[0]._childCount===this._childCount}});L.Marker.include({clusterHide:function(){var a=this.options.opacity;return this.setOpacity(0),this.options.opacity=a,this},clusterShow:function(){return this.setOpacity(this.options.opacity)}}),L.DistanceGrid=function(a){this._cellSize=a,this._sqCellSize=a*a,this._grid={},this._objectPoint={}},L.DistanceGrid.prototype={addObject:function(a,l){var c=this._getCoord(l.x),u=this._getCoord(l.y),g=this._grid,b=g[u]=g[u]||{},x=b[c]=b[c]||[],S=L.Util.stamp(a);this._objectPoint[S]=l,x.push(a)},updateObject:function(a,l){this.removeObject(a),this.addObject(a,l)},removeObject:function(a,l){var c=this._getCoord(l.x),u=this._getCoord(l.y),g=this._grid,b=g[u]=g[u]||{},x=b[c]=b[c]||[],S,$;for(delete this._objectPoint[L.Util.stamp(a)],S=0,$=x.length;S<$;S++)if(x[S]===a)return x.splice(S,1),$===1&&delete b[c],!0},eachObject:function(a,l){var c,u,g,b,x,S,$,k=this._grid;for(c in k){x=k[c];for(u in x)for(S=x[u],g=0,b=S.length;g=0;b--){if(x=l[b],S=this.getDistant(x,a),S>0)g.push(x);else continue;S>c&&(c=S,u=x)}return{maxPoint:u,newPoints:g}},buildConvexHull:function(a,l){var c=[],u=this.findMostDistantPointFromBaseLine(a,l);return u.maxPoint?(c=c.concat(this.buildConvexHull([a[0],u.maxPoint],u.newPoints)),c=c.concat(this.buildConvexHull([u.maxPoint,a[1]],u.newPoints)),c):[a[0]]},getConvexHull:function(a){var l=!1,c=!1,u=!1,g=!1,b=null,x=null,S=null,$=null,k=null,T=null,D;for(D=a.length-1;D>=0;D--){var I=a[D];(l===!1||I.lat>l)&&(b=I,l=I.lat),(c===!1||I.latu)&&(S=I,u=I.lng),(g===!1||I.lng=0;u--)c=a[u].getLatLng(),l.push(c);return L.QuickHull.getConvexHull(l)}}),L.MarkerCluster.include({_2PI:Math.PI*2,_circleFootSeparation:25,_circleStartAngle:0,_spiralFootSeparation:28,_spiralLengthStart:11,_spiralLengthFactor:5,_circleSpiralSwitchover:9,spiderfy:function(){if(!(this._group._spiderfied===this||this._group._inZoomAnimation)){var a=this.getAllChildMarkers(null,!0),l=this._group,c=l._map,u=c.latLngToLayerPoint(this._latlng),g;this._group._unspiderfy(),this._group._spiderfied=this,this._group.options.spiderfyShapePositions?g=this._group.options.spiderfyShapePositions(a.length,u):a.length>=this._circleSpiralSwitchover?g=this._generatePointsSpiral(a.length,u):(u.y+=10,g=this._generatePointsCircle(a.length,u)),this._animationSpiderfy(a,g)}},unspiderfy:function(a){this._group._inZoomAnimation||(this._animationUnspiderfy(a),this._group._spiderfied=null)},_generatePointsCircle:function(a,l){var c=this._group.options.spiderfyDistanceMultiplier*this._circleFootSeparation*(2+a),u=c/this._2PI,g=this._2PI/a,b=[],x,S;for(u=Math.max(u,35),b.length=a,x=0;x=0;$--)$=0;b--)g=u[b],c.removeLayer(g),g._preSpiderfyLatlng&&(g.setLatLng(g._preSpiderfyLatlng),delete g._preSpiderfyLatlng),g.setZIndexOffset&&g.setZIndexOffset(0),g._spiderLeg&&(l.removeLayer(g._spiderLeg),delete g._spiderLeg);a.fire("unspiderfied",{cluster:this,markers:u}),a._ignoreMove=!1,a._spiderfied=null}}),L.MarkerClusterNonAnimated=L.MarkerCluster.extend({_animationSpiderfy:function(a,l){var c=this._group,u=c._map,g=c._featureGroup,b=this._group.options.spiderLegPolylineOptions,x,S,$,k;for(c._ignoreMove=!0,x=0;x=0;D--)ne=g.layerPointToLatLng(l[D]),I=a[D],I._preSpiderfyLatlng=I._latlng,I.setLatLng(ne),I.clusterShow&&I.clusterShow(),$&&(O=I._spiderLeg,N=O._path,N.style.strokeDashoffset=0,O.setStyle({opacity:T}));this.setOpacity(.3),u._ignoreMove=!1,setTimeout(function(){u._animationEnd(),u.fire("spiderfied",{cluster:c,markers:a})},200)},_animationUnspiderfy:function(a){var l=this,c=this._group,u=c._map,g=c._featureGroup,b=a?u._latLngToNewLayerPoint(this._latlng,a.zoom,a.center):u.latLngToLayerPoint(this._latlng),x=this.getAllChildMarkers(null,!0),S=L.Path.SVG,$,k,T,D,I,O;for(c._ignoreMove=!0,c._animationStart(),this.setOpacity(1),k=x.length-1;k>=0;k--)$=x[k],$._preSpiderfyLatlng&&($.closePopup(),$.setLatLng($._preSpiderfyLatlng),delete $._preSpiderfyLatlng,O=!0,$._setPos&&($._setPos(b),O=!1),$.clusterHide&&($.clusterHide(),O=!1),O&&g.removeLayer($),S&&(T=$._spiderLeg,D=T._path,I=D.getTotalLength()+.1,D.style.strokeDashoffset=I,T.setStyle({opacity:0})));c._ignoreMove=!1,setTimeout(function(){var N=0;for(k=x.length-1;k>=0;k--)$=x[k],$._spiderLeg&&N++;for(k=x.length-1;k>=0;k--)$=x[k],$._spiderLeg&&($.clusterShow&&$.clusterShow(),$.setZIndexOffset&&$.setZIndexOffset(0),N>1&&g.removeLayer($),u.removeLayer($._spiderLeg),delete $._spiderLeg);c._animationEnd(),c.fire("unspiderfied",{cluster:l,markers:x})},200)}}),L.MarkerClusterGroup.include({_spiderfied:null,unspiderfy:function(){this._unspiderfy.apply(this,arguments)},_spiderfierOnAdd:function(){this._map.on("click",this._unspiderfyWrapper,this),this._map.options.zoomAnimation&&this._map.on("zoomstart",this._unspiderfyZoomStart,this),this._map.on("zoomend",this._noanimationUnspiderfy,this),L.Browser.touch||this._map.getRenderer(this)},_spiderfierOnRemove:function(){this._map.off("click",this._unspiderfyWrapper,this),this._map.off("zoomstart",this._unspiderfyZoomStart,this),this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._map.off("zoomend",this._noanimationUnspiderfy,this),this._noanimationUnspiderfy()},_unspiderfyZoomStart:function(){!this._map||this._map.on("zoomanim",this._unspiderfyZoomAnim,this)},_unspiderfyZoomAnim:function(a){L.DomUtil.hasClass(this._map._mapPane,"leaflet-touching")||(this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._unspiderfy(a))},_unspiderfyWrapper:function(){this._unspiderfy()},_unspiderfy:function(a){this._spiderfied&&this._spiderfied.unspiderfy(a)},_noanimationUnspiderfy:function(){this._spiderfied&&this._spiderfied._noanimationUnspiderfy()},_unspiderfyLayer:function(a){a._spiderLeg&&(this._featureGroup.removeLayer(a),a.clusterShow&&a.clusterShow(),a.setZIndexOffset&&a.setZIndexOffset(0),this._map.removeLayer(a._spiderLeg),delete a._spiderLeg)}}),L.MarkerClusterGroup.include({refreshClusters:function(a){return a?a instanceof L.MarkerClusterGroup?a=a._topClusterLevel.getAllChildMarkers():a instanceof L.LayerGroup?a=a._layers:a instanceof L.MarkerCluster?a=a.getAllChildMarkers():a instanceof L.Marker&&(a=[a]):a=this._topClusterLevel.getAllChildMarkers(),this._flagParentsIconsNeedUpdate(a),this._refreshClustersIcons(),this.options.singleMarkerMode&&this._refreshSingleMarkerModeMarkers(a),this},_flagParentsIconsNeedUpdate:function(a){var l,c;for(l in a)for(c=a[l].__parent;c;)c._iconNeedsUpdate=!0,c=c.__parent},_refreshSingleMarkerModeMarkers:function(a){var l,c;for(l in a)c=a[l],this.hasLayer(c)&&c.setIcon(this._overrideMarkerIcon(c))}}),L.Marker.include({refreshIconOptions:function(a,l){var c=this.options.icon;return L.setOptions(c,a),this.setIcon(c),l&&this.__parent&&this.__parent._group.refreshClusters(this),this}}),r.MarkerClusterGroup=n,r.MarkerCluster=o,Object.defineProperty(r,"__esModule",{value:!0})})})(leaflet_markerclusterSrc,leaflet_markerclusterSrc.exports);const MarkerCluster_Default="",MarkerCluster="",airtemp={label:"Airtemp",unit:"\u2103"},airtempavg={label:"AvgAirtemp",unit:"\u2103"},airtempmax={label:"MaxAirtemp",unit:"\u2103"},airtempmin={label:"MinAirtemp",unit:"\u2103"},co={label:"CO",name:{en:"Carbon monoxide",ru:"\u0423\u0433\u0430\u0440\u043D\u044B\u0439 \u0433\u0430\u0437"},unit:"mg/m3",chartColor:"#c1c1c1",colors:["#60bc2a","#ff9d00","#fc0202"],range:[0,2,4,14],zones:[{value:0,color:"#60bc2a",label:{en:"Good",ru:"\u0425\u043E\u0440\u043E\u0448\u043E"}},{value:2,color:"#12bfcc",label:{en:"Satisfyingly",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{value:4,color:"#ff9d00",label:{en:"Poor",ru:"\u041F\u043B\u043E\u0445\u043E"}},{color:"#7a00da",label:{en:"Very poor",ru:"\u041E\u0447\u0435\u043D\u044C \u043F\u043B\u043E\u0445\u043E"}}],calculate:function(e){return converterPpmToMgm3(e,28.01)},info:"\u0421arbon monoxide. It is formed during the incomplete decomposition of organic compounds and during the combustion of biomass during forest fires."},gc={label:"GC",name:{en:"Radiation",ru:"\u0420\u0430\u0434\u0438\u0430\u0446\u0438\u044F"},unit:"\u03BCR/h",chartColor:"#e99152",range:[2,10,100,1e3],zones:[{value:2,color:"#60bc2a",label:{en:"Background",ru:"\u0424\u043E\u043D\u043E\u0432\u0430\u044F"}},{value:10,color:"#03a5ed",label:{en:"Moderate",ru:"\u041D\u0435\u0432\u044B\u0441\u043E\u043A\u0430\u044F"}},{value:100,color:"#ff9d00",label:{en:"Elevated",ru:"\u041F\u043E\u0432\u044B\u0448\u0435\u043D\u043D\u0430\u044F"}},{color:"#ff4d00",label:{en:"High",ru:"\u0412\u044B\u0441\u043E\u043A\u0430\u044F"}}]},humidity={label:"Hm",name:{en:"Humidity",ru:"\u0412\u043B\u0430\u0436\u043D\u043E\u0441\u0442\u044C"},unit:"%",chartColor:"#6fd3ff",range:[30,40,60,70],zones:[{value:30,color:"#ff4d00",label:{en:"Very dry",ru:"\u041E\u0447\u0435\u043D\u044C \u0441\u0443\u0445\u043E"}},{value:40,color:"#ff9d00",label:{en:"Dry",ru:"\u0421\u0443\u0445\u043E"}},{value:60,color:"#03a5ed",label:{en:"Comfortable",ru:"\u041A\u043E\u043C\u0444\u043E\u0440\u0442\u043D\u043E"}},{value:70,color:"#2a5cbc",label:{en:"Humid",ru:"\u0412\u043B\u0430\u0436\u043D\u043E"}},{color:"#7a00da",label:{en:"Very humid",ru:"\u041E\u0447\u0435\u043D\u044C \u0432\u043B\u0430\u0436\u043D\u043E"}}]},nh3={label:"NH3",name:{en:"Ammonia",ru:"\u0410\u043C\u043C\u0438\u0430\u043A"},unit:"mg/m3",icon:"vial-virus",chartColor:"#a1e37a",colors:["#60bc2a","#ff9d00","#fc0202"],range:[0,15,40],zones:[{value:15,color:"#60bc2a",label:{en:"Good",ru:"\u0425\u043E\u0440\u043E\u0448\u043E"}},{value:40,color:"#ff9d00",label:{en:"Satisfyingly",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{color:"#fc0202",label:{en:"Poor",ru:"\u041F\u043B\u043E\u0445\u043E"}}],calculate:function(e){return converterPpmToMgm3(e,17.03)}},no2={label:"NO2",name:{en:"Nitrogen Dioxide",ru:"\u0414\u0438\u043E\u043A\u0441\u0438\u0434 \u0430\u0437\u043E\u0442\u0430"},unit:"mg/m3",chartColor:"#d4dd53",colors:["#60bc2a","#ff9d00","#fc0202"],range:[0,1,5],zones:[{value:1,color:"#60bc2a",label:{en:"Good",ru:"\u0425\u043E\u0440\u043E\u0448\u043E"}},{value:5,color:"#ff9d00",label:{en:"Satisfyingly",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{color:"#fc0202",label:{en:"Poor",ru:"\u041F\u043B\u043E\u0445\u043E"}}],calculate:function(e){return converterPpmToMgm3(e,46.01)}},noiseavg={label:"Noise Avg.",unit:"dB",range:[0,40,70,80,100],zones:[{value:40,color:"#60bc2a",label:{en:"Faint",ru:"\u0422\u0438\u0445\u043E"}},{value:70,color:"#12bfcc",label:{en:"Moderate",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{value:80,color:"#ff9d00",label:{en:"Loud",ru:"\u0428\u0443\u043C\u043D\u043E"}},{value:100,color:"#ff4d00",label:{en:"Very loud",ru:"\u041E\u0447\u0435\u043D\u044C \u0448\u0443\u043C\u043D\u043E"}},{color:"#7a00da",label:{en:"Extremely loud",ru:"\u042D\u043A\u0441\u0442\u0440\u0435\u043C\u0430\u043B\u044C\u043D\u043E \u0448\u0443\u043C\u043D\u043E"}}],calculate:function(e){return toFixed(e)},info:"Noise is what your ears or noise sensor can sense. Measured in Decibel (dB)."},noisemax={label:"Noise Max.",unit:"dB",range:[0,40,70,80,100],zones:[{value:40,color:"#60bc2a",label:{en:"Faint",ru:"\u0422\u0438\u0445\u043E"}},{value:70,color:"#12bfcc",label:{en:"Moderate",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{value:80,color:"#ff9d00",label:{en:"Loud",ru:"\u0428\u0443\u043C\u043D\u043E"}},{value:100,color:"#ff4d00",label:{en:"Very loud",ru:"\u041E\u0447\u0435\u043D\u044C \u0448\u0443\u043C\u043D\u043E"}},{color:"#7a00da",label:{en:"Extremely loud",ru:"\u042D\u043A\u0441\u0442\u0440\u0435\u043C\u0430\u043B\u044C\u043D\u043E \u0448\u0443\u043C\u043D\u043E"}}],calculate:function(e){return toFixed(e)},info:"Noise is what your ears or noise sensor can sense. Measured in Decibel (dB)."},pm1={label:"PM1",unit:"\u03BCg/m3",chartColor:"#ff99e9"},pm10={label:"PM10",unit:"\u03BCg/m3",chartColor:"#e8b738",colors:["#60bc2a","#ff9d00","#fc0202"],range:[0,51,101,251,350],zones:[{value:50,color:"#60bc2a",label:{en:"Good",ru:"\u0425\u043E\u0440\u043E\u0448\u043E"}},{value:100,color:"#12bfcc",label:{en:"Satisfyingly",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{value:250,color:"#ff9d00",label:{en:"Poor",ru:"\u041F\u043B\u043E\u0445\u043E"}},{value:350,color:"#ff4d00",label:{en:"Very poor",ru:"\u041E\u0447\u0435\u043D\u044C \u043F\u043B\u043E\u0445\u043E"}},{color:"#7a00da",label:{en:"Unacceptable",ru:"\u041D\u0435\u043F\u0440\u0438\u0435\u043C\u043B\u0435\u043C\u043E"}}],calculate:function(e){return toFixed(e)},info:"PM10 - suspended particles (PM - particulate matter) of a substance with a diameter of less than 10 micrometers (\u03BCm). Pollen and other allergens."},pm25={label:"PM2.5",unit:"\u03BCg/m3",chartColor:"#89b268",colors:["#60bc2a","#ff9d00","#fc0202"],range:[0,36,70,151,251],zones:[{value:36,color:"#60bc2a",label:{en:"Good",ru:"\u0425\u043E\u0440\u043E\u0448\u043E"}},{value:70,color:"#12bfcc",label:{en:"Satisfyingly",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{value:150,color:"#ff9d00",label:{en:"Poor",ru:"\u041F\u043B\u043E\u0445\u043E"}},{value:250,color:"#ff4d00",label:{en:"Very poor",ru:"\u041E\u0447\u0435\u043D\u044C \u043F\u043B\u043E\u0445\u043E"}},{color:"#7a00da",label:{en:"Unacceptable",ru:"\u041D\u0435\u043F\u0440\u0438\u0435\u043C\u043B\u0435\u043C\u043E"}}],calculate:function(e){return toFixed(e)},info:"Suspended, solid and liquid particles with a diameter of 2.5 microns are an air pollutant."},pressure={label:"Pr",name:{en:"Atmospheric pressure",ru:"\u0410\u0442\u043C\u043E\u0441\u0444\u0435\u0440\u043D\u043E\u0435 \u0434\u0430\u0432\u043B\u0435\u043D\u0438\u0435"},unit:"mmHg"},rainfall={label:"Rainfall",unit:"mm"},sat10={label:"Sat10",unit:""},sat5={label:"Sat5",unit:""},soiltemp={label:"Soiltemp",unit:"\u2103"},temperature={label:"Tmp",name:{en:"Temperature",ru:"\u0422\u0435\u043C\u043F\u0435\u0440\u0430\u0442\u0443\u0440\u0430"},unit:"\u2103",chartColor:"#2d7ac7",colors:["#fc0202","#ff9d00","#60bc2a","#ff9d00","#fc0202"],range:[-10,0,10,25],zones:[{value:-9,color:"#7a00da",label:{en:"Very cold",ru:"\u041E\u0447\u0435\u043D\u044C \u0445\u043E\u043B\u043E\u0434\u043D\u043E"}},{value:0,color:"#2a5cbc",label:{en:"Cold",ru:"\u0425\u043E\u043B\u043E\u0434\u043D\u043E"}},{value:10,color:"#03a5ed",label:{en:"Cool",ru:"\u041F\u0440\u043E\u0445\u043B\u0430\u0434\u043D\u043E"}},{value:25,color:"#60bc2a",label:{en:"Warm",ru:"\u0422\u0435\u043F\u043B\u043E"}},{value:9999,color:"#ff9d00",label:{en:"Very warm",ru:"\u041E\u0447\u0435\u043D\u044C \u0442\u0435\u043F\u043B\u043E"}}],states:["danger","attention","good","attention","danger","neutral"],calculate:function(e){return toFixed(e)},info:"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u0435\u043B\u044C \u0442\u0435\u043C\u043F\u0435\u0440\u0430\u0442\u0443\u0440\u044B \u0432\u043E\u0437\u0434\u0443\u0445\u0430"},windang={label:"Windang",unit:"\xB0",icon:"wind"},windspeed={label:"Windspeed",unit:"m/s",icon:"wind"},windspeedmax={label:"Windspeedmax",unit:"m/s"},measurements={airtemp,airtempavg,airtempmax,airtempmin,co,gc,humidity,nh3,no2,noiseavg,noisemax,pm1,pm10,pm25,pressure,rainfall,sat10,sat5,soiltemp,temperature,windang,windspeed,windspeedmax};function toFixed(e,t=4){return+(+e||0).toFixed(t)}function converterPpmToMgm3(e,t){return toFixed(e*t/24.05526)}const states=["good","attention","danger","neutral"];function getMeasurementByName(e){return measurements[e]||measurements.pm10}const artesiantlt="/assets/artesiantlt.b6bada62.jpg",atc="/assets/atc.09cec0ab.png",dolinatlt="/assets/dolinatlt.9bfd5fdc.jpg",ekovoz="/assets/ekovoz.af7d8a74.png",panorama="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACGVBMVEUAAACz00SfykaQuUWZx0ZQnEyax0aBu0iBu0iBvElgmUhpsExosEtgm0irz0SawkWrz0aTxUiTxEd2rkeTw0d4uUp6uUp6uEp6uUl6uUpwoUZhrUxTnkuly0ZGnE1Jok6lzUaLwUiNwUiNwEdko0hztUp0tUpztkpcn0lam0qHtUZbqk1ooEebw0ZytUpytUlTmks7iktytkp0tUxAnVBBnk9Ank9Bn088lk8vf0wueUote0s/mk9AnU0sbEgobUl9q0Ztn0d6qUaYw0aeyUaCskeAskdzo0Ztnkeax0eaxkeKu0dknEdRkklYoUtRm0tWnUpPkUlknUeSwUebx0eCu0qCu0mBu0lkoklBhUpAhUpqp0qCvElUmEpiqEtpsExpr0tpsEtYn0pZn0tmrUtVlkl4qUZLjkpJmExQpE5GlkxHlkxIl0xQkkproUeiyEWTw0iTw0dSkkk1iU0ziU0zjE45iUtZmEl3rEeSw0d6uEp6t0pvrkpQkklMjUp0s0pgm0lPlkpirExhrExUnEtWnktdl0ily0aUwEZblkhHjUpClExBlE1JoU5Hnk1EjktgmUiFs0alzEaMwEhloElEjEovf0wvgk1FjEpemkiGukh0tUt0tEpXmUp0tUpvsUpcl0hNkEpUoExbqk1bqUxPm0xPmktbqU1RnEtJjklytUpBi0s8jUxCm048kk1CnE5AiktcoUv///8iSiW7AAAAQHRSTlMAf/7+f/7+f/7+f/7+f3/+f3/+/v5//v7+f3/+/n/+/n9//v5//v7+/n9//v5/f/7v/v5/YL+/v7+/3++/YEA/+66NsgAAAAFiS0dEsq1qz+gAAAEDSURBVBjTY2B0cHRydnFxdWNycXb3YGZkYPH08vbx9fNnDQgMCmYLYWFg5wgNC+eMiIyKDguLieFkZ+CKjYtP4E5MSuaJT0xISeVl4ONPS8/IzMzKzszMyc3LF2AQLCgUEi4qLiktK68QEqkUZBCtqharqqqprasXrxITk5BkkGpolG5qbm6RaZJukm5tk2KQbe/o7JKT7+7p7eufMHGSAoPi5MlKk6dMnTZ9xsxZk5WUFRlUZs9Rna2mrjF3tursebPnazJoLVi4SHvxkqXLli/XXrFSR5dBb5W+weo1a9etW2+4YaPRKmMGE1MzU3MLSytrSxtTILBlgAI7ewZUABcAAE5TTddsyTFjAAAAAElFTkSuQmCC",qvantorium="/assets/qvantorium.d5858788.jpg",sun="/assets/sun.d26ef6d1.png",beon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAAAAAAYplnuAAAElUlEQVR42u3b3XXiOhAH8P/ec19FAasGTAFRA04BuAFTAG4ACogbMAXgW4ApAAq42gJQA9oCUAG7D4R4ZL6MoxBxzswTjh38syONRrLzI8HzxT/fDWB0zMFoRjM6gmA0oxkdQTCa0YyOIBjNaEZHEIxmNKMjCEYzmtERBKMZzegIgtGMZnQEwWhGMzqCYDSjGR1BMJrRjI4gGM3oK/Fvn4N+Xt71O1r09tpOZ/dmZ8wj0T/6vD+9u32I1Uv7dGgAevEodsCOqDZz8XRoIG/k86EhVw9RB87T8u0J0VD5E6JRPKAz9hpcaJQGwN4dNiQSmfrNWKTr+NBGkw0LjVK9eWwVIfo09OtKUfT5o4QYCwDWBRjwA6CBYksa8rmk9/Kq2pFXm+aT8CBo11zLGSKfep1TqdxW68+cL0z2uFKciNn2NKHIcjP5djStlJy356U5nwNluRk+eIZBj8hn767P6os0uRr8X4Vh0Cn5TDvZrLjyS7LJvhMt6dnrnmYAbwPvdQi0XJEN3bbvW2agHtauP5/yROZ1tbK9lo7Z7JwYSe/mirfpQ9DJH7IxEnKsvOywbJs0vf9w9eqQVuSMtiU1WQ9AB5wjAoBpRZOS/FwXbSaUFTmnfR2ADluaajIy0saxnpLsbbOm3ZDpzS/9YvSS2Cakj9m5f1xJBqMhk4aQ6IrcQdCW2+1tbtF+VgMmDSHRxaatrAWpULcn6yGaFOUD2kfYNp2tjgTav9fdw0RCmrjC3RGkNG1DVtXyhPK/5x0nyhtSxt+OBgosAe9OG3fJe7jOB6DNvnvSzlmLXxpe3bcHhJIquaAb0BHvHlymurtXjCdeuWYzB5Bq2enrGeL+9hGgIzq9eKX1qOykXpFeNjtTL3B3hGnTNq/JXyxb9rrWnTF62OJwoI7oSlIeyeTGbNtpO9QbEg1tST9TBrsL3c4aq81nF9+DpTyqTM4+QLLaWO36f+MD0FQz6lazVhuzC+INi6bNQQC/6PVkgR/GBKs9aLZ1gCXpXNwqP8VspXd6NXk0Oqe52AKgY1B+ppKbtDky3RZKQKje6zeB0IlX5lsANW3C5Yl6VlZHYVodL1j2fNAUBC1mjbdtADg6rxXV3OO8rIqPh0qSXK/o98jm7tpj3qk9pBylnZL4MFkVW3/0brbv+S5R779gM4fu6shpaRMC3SPKwyJTPu/usBaQo/ZaTO6AxhPU5a1vxxfU04B9f/5fdyunkyo2mS/8OU7P6voL3vf4mGtXNxf8s5M/Rq/qOjx6+fGihctvqlMBf+DpNWwGR5cVEeT19YPt1HU6zBY9IjDaTj2mK8trt26bWeA/70d9kkdYtFu+dk9aZ83Fo8vCwV8DQb83XcKlPLdZn79N/jrpx+HHZVT66sJ6jj4RAu32Zm/0lU4nVerPbZ1uSGV9vCpX3egCd6GvJ89+dWcy/iklALe3v3fdC5SpEtY0fSvuXujY4ilfJmQ0oxkdQTCa0YyOIBjNaEZHEIxmNKMjCEYzmtERBKMZzegIgtGMZnQEwWhGMzqCYDSjGR1BMJrRjI4gGM1oRkcQjGY0oyOIp0T/BRrCOxyOfITTAAAAAElFTkSuQmCC",owlcat="/assets/owlcatgames.ae9238f4.jpg",sensors={"7e071fd9b023ed8f18458a73613a0834f6220bd5cc50357ba3493c6040a9ea8c":{icon:ekovoz,link:"http://ekovoz.ru/"},"162ebfac08a69bc96c0bd569c95026c6750cbecca7a61731dfe1a985a9391176":{icon:atc,link:"http://atcgaz.ru/"},"7c7ffabc786c46ff40d8ca922b1248e1261baefec702eea160001140063f8c53":{icon:atc,link:"http://atcgaz.ru/"},"7cdeafa03331cb330c3993ff0381457f0713a8fd6d0b3dbe93ea24affe5676ac":{icon:artesiantlt,link:"https://www.artesiantlt.ru/"},"217a9ae639e48a9b99de7895c496b224ad6a80f9b679d516557561aedd47c58b":{icon:qvantorium,link:"https://vk.com/kvantoriumtlt"},f5cf0ec44b696400af9b280cb5bedc9e10893f5f961159658a218286f8e97372:{icon:dolinatlt,link:"https://dolinatlt.ru/"},"5bd528a4d708304254d2417b83f8b5c997ed08ccf956fa4e538fc6cfa40f86c0":{icon:panorama,link:"https://panorama-park63.ru/"},e4871acd155431c63fbbc54b89d015bc17bc5fbe44d5846502f7e58566e24a8e:{link:"https://airalab.org/"},"62c86fb3712e2c8e3d8a7a79f62c1cb0dbd4ad2980606dbf8fcf96ce9ed46c8d":{icon:sun},"3d10918f84c47d7134be14136d3af157ebc3335fe72e8dafd26fbeb01e3116fd":{icon:beon,link:"The most technologically advanced office in Cyprus. https://beon.center/"},"28695c0354e91eb0a31744641356c5d3f6868f02b01148762f467c3687ede97b":{icon:owlcat,link:"https://owlcat.games"}};var chroma$1={exports:{}};/** + */(function(e,t){(function(r,n){n(t)})(commonjsGlobal$2,function(r){var n="1.9.2";function o(_){var E,H,be,Me;for(H=1,be=arguments.length;H"u"||!L||!L.Mixin)){_=N(_)?_:[_];for(var E=0;E<_.length;E++)_[E]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}var pe={on:function(_,E,H){if(typeof _=="object")for(var be in _)this._on(be,_[be],E);else{_=k(_);for(var Me=0,Je=_.length;Me0?Math.floor(_):Math.ceil(_)};ge.prototype={clone:function(){return new ge(this.x,this.y)},add:function(_){return this.clone()._add(Ae(_))},_add:function(_){return this.x+=_.x,this.y+=_.y,this},subtract:function(_){return this.clone()._subtract(Ae(_))},_subtract:function(_){return this.x-=_.x,this.y-=_.y,this},divideBy:function(_){return this.clone()._divideBy(_)},_divideBy:function(_){return this.x/=_,this.y/=_,this},multiplyBy:function(_){return this.clone()._multiplyBy(_)},_multiplyBy:function(_){return this.x*=_,this.y*=_,this},scaleBy:function(_){return new ge(this.x*_.x,this.y*_.y)},unscaleBy:function(_){return new ge(this.x/_.x,this.y/_.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=ye(this.x),this.y=ye(this.y),this},distanceTo:function(_){_=Ae(_);var E=_.x-this.x,H=_.y-this.y;return Math.sqrt(E*E+H*H)},equals:function(_){return _=Ae(_),_.x===this.x&&_.y===this.y},contains:function(_){return _=Ae(_),Math.abs(_.x)<=Math.abs(this.x)&&Math.abs(_.y)<=Math.abs(this.y)},toString:function(){return"Point("+S(this.x)+", "+S(this.y)+")"}};function Ae(_,E,H){return _ instanceof ge?_:N(_)?new ge(_[0],_[1]):_==null?_:typeof _=="object"&&"x"in _&&"y"in _?new ge(_.x,_.y):new ge(_,E,H)}function Re(_,E){if(!!_)for(var H=E?[_,E]:_,be=0,Me=H.length;be=this.min.x&&H.x<=this.max.x&&E.y>=this.min.y&&H.y<=this.max.y},intersects:function(_){_=We(_);var E=this.min,H=this.max,be=_.min,Me=_.max,Je=Me.x>=E.x&&be.x<=H.x,ct=Me.y>=E.y&&be.y<=H.y;return Je&&ct},overlaps:function(_){_=We(_);var E=this.min,H=this.max,be=_.min,Me=_.max,Je=Me.x>E.x&&be.xE.y&&be.y=E.lat&&Me.lat<=H.lat&&be.lng>=E.lng&&Me.lng<=H.lng},intersects:function(_){_=Ue(_);var E=this._southWest,H=this._northEast,be=_.getSouthWest(),Me=_.getNorthEast(),Je=Me.lat>=E.lat&&be.lat<=H.lat,ct=Me.lng>=E.lng&&be.lng<=H.lng;return Je&&ct},overlaps:function(_){_=Ue(_);var E=this._southWest,H=this._northEast,be=_.getSouthWest(),Me=_.getNorthEast(),Je=Me.lat>E.lat&&be.latE.lng&&be.lng1,Pr=function(){var _=!1;try{var E=Object.defineProperty({},"passive",{get:function(){_=!0}});window.addEventListener("testPassiveEventSupport",x,E),window.removeEventListener("testPassiveEventSupport",x,E)}catch{}return _}(),fr=function(){return!!document.createElement("canvas").getContext}(),hr=!!(document.createElementNS&&me("svg").createSVGRect),$r=!!hr&&function(){var _=document.createElement("div");return _.innerHTML="",(_.firstChild&&_.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"}(),Bi=!hr&&function(){try{var _=document.createElement("div");_.innerHTML='';var E=_.firstChild;return E.style.behavior="url(#default#VML)",E&&typeof E.adj=="object"}catch{return!1}}(),li=navigator.platform.indexOf("Mac")===0,Mn=navigator.platform.indexOf("Linux")===0;function Sr(_){return navigator.userAgent.toLowerCase().indexOf(_)>=0}var Lt={ie:He,ielt9:ze,edge:Qe,webkit:rt,android:Ke,android23:Ie,androidStock:je,opera:Ze,chrome:Ce,gecko:ce,safari:de,phantom:De,opera12:qe,win:nt,ie3d:lt,webkit3d:pt,gecko3d:bt,any3d:St,mobile:Et,mobileWebkit:vt,mobileWebkit3d:Nt,msPointer:Ft,pointer:qt,touch:mr,touchNative:Zt,mobileOpera:nr,mobileGecko:ur,retina:Mr,passiveEvents:Pr,canvas:fr,svg:hr,vml:Bi,inlineSvg:$r,mac:li,linux:Mn},On=Lt.msPointer?"MSPointerDown":"pointerdown",Ur=Lt.msPointer?"MSPointerMove":"pointermove",Dn=Lt.msPointer?"MSPointerUp":"pointerup",tn=Lt.msPointer?"MSPointerCancel":"pointercancel",rn={touchstart:On,touchmove:Ur,touchend:Dn,touchcancel:tn},Nn={touchstart:So,touchmove:Bn,touchend:Bn,touchcancel:Bn},Ir={},qr=!1;function ci(_,E,H){return E==="touchstart"&&Eo(),Nn[E]?(H=Nn[E].bind(this,H),_.addEventListener(rn[E],H,!1),H):(console.warn("wrong event specified:",E),L.Util.falseFn)}function nn(_,E,H){if(!rn[E]){console.warn("wrong event specified:",E);return}_.removeEventListener(rn[E],H,!1)}function xo(_){Ir[_.pointerId]=_}function _s(_){Ir[_.pointerId]&&(Ir[_.pointerId]=_)}function vs(_){delete Ir[_.pointerId]}function Eo(){qr||(document.addEventListener(On,xo,!0),document.addEventListener(Ur,_s,!0),document.addEventListener(Dn,vs,!0),document.addEventListener(tn,vs,!0),qr=!0)}function Bn(_,E){if(E.pointerType!==(E.MSPOINTER_TYPE_MOUSE||"mouse")){E.touches=[];for(var H in Ir)E.touches.push(Ir[H]);E.changedTouches=[E],_(E)}}function So(_,E){E.MSPOINTER_TYPE_TOUCH&&E.pointerType===E.MSPOINTER_TYPE_TOUCH&&gr(E),Bn(_,E)}function Co(_){var E={},H,be;for(be in _)H=_[be],E[be]=H&&H.bind?H.bind(_):H;return _=E,E.type="dblclick",E.detail=2,E.isTrusted=!1,E._simulated=!0,E}var ko=200;function Ao(_,E){_.addEventListener("dblclick",E);var H=0,be;function Me(Je){if(Je.detail!==1){be=Je.detail;return}if(!(Je.pointerType==="mouse"||Je.sourceCapabilities&&!Je.sourceCapabilities.firesTouchEvents)){var ct=ws(Je);if(!(ct.some(function(_t){return _t instanceof HTMLLabelElement&&_t.attributes.for})&&!ct.some(function(_t){return _t instanceof HTMLInputElement||_t instanceof HTMLSelectElement}))){var gt=Date.now();gt-H<=ko?(be++,be===2&&E(Co(Je))):be=1,H=gt}}}return _.addEventListener("click",Me),{dblclick:E,simDblclick:Me}}function To(_,E){_.removeEventListener("dblclick",E.dblclick),_.removeEventListener("click",E.simDblclick)}var Fi=Fn(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),sn=Fn(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),an=sn==="webkitTransition"||sn==="OTransition"?sn+"End":"transitionend";function ui(_){return typeof _=="string"?document.getElementById(_):_}function Or(_,E){var H=_.style[E]||_.currentStyle&&_.currentStyle[E];if((!H||H==="auto")&&document.defaultView){var be=document.defaultView.getComputedStyle(_,null);H=be?be[E]:null}return H==="auto"?null:H}function Kt(_,E,H){var be=document.createElement(_);return be.className=E||"",H&&H.appendChild(be),be}function ar(_){var E=_.parentNode;E&&E.removeChild(_)}function hi(_){for(;_.firstChild;)_.removeChild(_.firstChild)}function En(_){var E=_.parentNode;E&&E.lastChild!==_&&E.appendChild(_)}function Sn(_){var E=_.parentNode;E&&E.firstChild!==_&&E.insertBefore(_,E.firstChild)}function di(_,E){if(_.classList!==void 0)return _.classList.contains(E);var H=fi(_);return H.length>0&&new RegExp("(^|\\s)"+E+"(\\s|$)").test(H)}function Bt(_,E){if(_.classList!==void 0)for(var H=k(E),be=0,Me=H.length;be0?2*window.devicePixelRatio:1;function Zi(_){return Lt.edge?_.wheelDeltaY/2:_.deltaY&&_.deltaMode===0?-_.deltaY/qi:_.deltaY&&_.deltaMode===1?-_.deltaY*20:_.deltaY&&_.deltaMode===2?-_.deltaY*60:_.deltaX||_.deltaZ?0:_.wheelDelta?(_.wheelDeltaY||_.wheelDelta)/2:_.detail&&Math.abs(_.detail)<32765?-_.detail*20:_.detail?_.detail/-32765*60:0}function Xi(_,E){var H=E.relatedTarget;if(!H)return!0;try{for(;H&&H!==_;)H=H.parentNode}catch{return!1}return H!==_}var $o={__proto__:null,on:Ot,off:tr,stopPropagation:un,disableScrollPropagation:yi,disableClickPropagation:Dr,preventDefault:gr,stop:hn,getPropagationPath:ws,getMousePosition:_i,getWheelDelta:Zi,isExternalTarget:Xi,addListener:Ot,removeListener:tr},xs=ue.extend({run:function(_,E,H,be){this.stop(),this._el=_,this._inProgress=!0,this._duration=H||.25,this._easeOutPower=1/Math.max(be||.5,.2),this._startPos=cn(_),this._offset=E.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){!this._inProgress||(this._step(!0),this._complete())},_animate:function(){this._animId=he(this._animate,this),this._step()},_step:function(_){var E=+new Date-this._startTime,H=this._duration*1e3;Ethis.options.maxZoom)?this.setZoom(_):this},panInsideBounds:function(_,E){this._enforcingBounds=!0;var H=this.getCenter(),be=this._limitCenter(H,this._zoom,Ue(_));return H.equals(be)||this.panTo(be,E),this._enforcingBounds=!1,this},panInside:function(_,E){E=E||{};var H=Ae(E.paddingTopLeft||E.padding||[0,0]),be=Ae(E.paddingBottomRight||E.padding||[0,0]),Me=this.project(this.getCenter()),Je=this.project(_),ct=this.getPixelBounds(),gt=We([ct.min.add(H),ct.max.subtract(be)]),_t=gt.getSize();if(!gt.contains(Je)){this._enforcingBounds=!0;var xt=Je.subtract(gt.getCenter()),Tt=gt.extend(Je).getSize().subtract(_t);Me.x+=xt.x<0?-Tt.x:Tt.x,Me.y+=xt.y<0?-Tt.y:Tt.y,this.panTo(this.unproject(Me),E),this._enforcingBounds=!1}return this},invalidateSize:function(_){if(!this._loaded)return this;_=o({animate:!1,pan:!0},_===!0?{animate:!0}:_);var E=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var H=this.getSize(),be=E.divideBy(2).round(),Me=H.divideBy(2).round(),Je=be.subtract(Me);return!Je.x&&!Je.y?this:(_.animate&&_.pan?this.panBy(Je):(_.pan&&this._rawPanBy(Je),this.fire("move"),_.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(l(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:E,newSize:H}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(_){if(_=this._locateOptions=o({timeout:1e4,watch:!1},_),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var E=l(this._handleGeolocationResponse,this),H=l(this._handleGeolocationError,this);return _.watch?this._locationWatchId=navigator.geolocation.watchPosition(E,H,_):navigator.geolocation.getCurrentPosition(E,H,_),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(_){if(!!this._container._leaflet_id){var E=_.code,H=_.message||(E===1?"permission denied":E===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:E,message:"Geolocation error: "+H+"."})}},_handleGeolocationResponse:function(_){if(!!this._container._leaflet_id){var E=_.coords.latitude,H=_.coords.longitude,be=new Oe(E,H),Me=be.toBounds(_.coords.accuracy*2),Je=this._locateOptions;if(Je.setView){var ct=this.getBoundsZoom(Me);this.setView(be,Je.maxZoom?Math.min(ct,Je.maxZoom):ct)}var gt={latlng:be,bounds:Me,timestamp:_.timestamp};for(var _t in _.coords)typeof _.coords[_t]=="number"&&(gt[_t]=_.coords[_t]);this.fire("locationfound",gt)}},addHandler:function(_,E){if(!E)return this;var H=this[_]=new E(this);return this._handlers.push(H),this.options[_]&&H.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),ar(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(_e(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var _;for(_ in this._layers)this._layers[_].remove();for(_ in this._panes)ar(this._panes[_]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(_,E){var H="leaflet-pane"+(_?" leaflet-"+_.replace("Pane","")+"-pane":""),be=Kt("div",H,E||this._mapPane);return _&&(this._panes[_]=be),be},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var _=this.getPixelBounds(),E=this.unproject(_.getBottomLeft()),H=this.unproject(_.getTopRight());return new Pe(E,H)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(_,E,H){_=Ue(_),H=Ae(H||[0,0]);var be=this.getZoom()||0,Me=this.getMinZoom(),Je=this.getMaxZoom(),ct=_.getNorthWest(),gt=_.getSouthEast(),_t=this.getSize().subtract(H),xt=We(this.project(gt,be),this.project(ct,be)).getSize(),Tt=Lt.any3d?this.options.zoomSnap:1,Mt=_t.x/xt.x,Dt=_t.y/xt.y,Cr=E?Math.max(Mt,Dt):Math.min(Mt,Dt);return be=this.getScaleZoom(Cr,be),Tt&&(be=Math.round(be/(Tt/100))*(Tt/100),be=E?Math.ceil(be/Tt)*Tt:Math.floor(be/Tt)*Tt),Math.max(Me,Math.min(Je,be))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new ge(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(_,E){var H=this._getTopLeftPoint(_,E);return new Re(H,H.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(_){return this.options.crs.getProjectedBounds(_===void 0?this.getZoom():_)},getPane:function(_){return typeof _=="string"?this._panes[_]:_},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(_,E){var H=this.options.crs;return E=E===void 0?this._zoom:E,H.scale(_)/H.scale(E)},getScaleZoom:function(_,E){var H=this.options.crs;E=E===void 0?this._zoom:E;var be=H.zoom(_*H.scale(E));return isNaN(be)?1/0:be},project:function(_,E){return E=E===void 0?this._zoom:E,this.options.crs.latLngToPoint(Be(_),E)},unproject:function(_,E){return E=E===void 0?this._zoom:E,this.options.crs.pointToLatLng(Ae(_),E)},layerPointToLatLng:function(_){var E=Ae(_).add(this.getPixelOrigin());return this.unproject(E)},latLngToLayerPoint:function(_){var E=this.project(Be(_))._round();return E._subtract(this.getPixelOrigin())},wrapLatLng:function(_){return this.options.crs.wrapLatLng(Be(_))},wrapLatLngBounds:function(_){return this.options.crs.wrapLatLngBounds(Ue(_))},distance:function(_,E){return this.options.crs.distance(Be(_),Be(E))},containerPointToLayerPoint:function(_){return Ae(_).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(_){return Ae(_).add(this._getMapPanePos())},containerPointToLatLng:function(_){var E=this.containerPointToLayerPoint(Ae(_));return this.layerPointToLatLng(E)},latLngToContainerPoint:function(_){return this.layerPointToContainerPoint(this.latLngToLayerPoint(Be(_)))},mouseEventToContainerPoint:function(_){return _i(_,this._container)},mouseEventToLayerPoint:function(_){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(_))},mouseEventToLatLng:function(_){return this.layerPointToLatLng(this.mouseEventToLayerPoint(_))},_initContainer:function(_){var E=this._container=ui(_);if(E){if(E._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");Ot(E,"scroll",this._onScroll,this),this._containerId=u(E)},_initLayout:function(){var _=this._container;this._fadeAnimated=this.options.fadeAnimation&&Lt.any3d,Bt(_,"leaflet-container"+(Lt.touch?" leaflet-touch":"")+(Lt.retina?" leaflet-retina":"")+(Lt.ielt9?" leaflet-oldie":"")+(Lt.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var E=Or(_,"position");E!=="absolute"&&E!=="relative"&&E!=="fixed"&&(_.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var _=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),dr(this._mapPane,new ge(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(Bt(_.markerPane,"leaflet-zoom-hide"),Bt(_.shadowPane,"leaflet-zoom-hide"))},_resetView:function(_,E,H){dr(this._mapPane,new ge(0,0));var be=!this._loaded;this._loaded=!0,E=this._limitZoom(E),this.fire("viewprereset");var Me=this._zoom!==E;this._moveStart(Me,H)._move(_,E)._moveEnd(Me),this.fire("viewreset"),be&&this.fire("load")},_moveStart:function(_,E){return _&&this.fire("zoomstart"),E||this.fire("movestart"),this},_move:function(_,E,H,be){E===void 0&&(E=this._zoom);var Me=this._zoom!==E;return this._zoom=E,this._lastCenter=_,this._pixelOrigin=this._getNewPixelOrigin(_),be?H&&H.pinch&&this.fire("zoom",H):((Me||H&&H.pinch)&&this.fire("zoom",H),this.fire("move",H)),this},_moveEnd:function(_){return _&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return _e(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(_){dr(this._mapPane,this._getMapPanePos().subtract(_))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(_){this._targets={},this._targets[u(this._container)]=this;var E=_?tr:Ot;E(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&E(window,"resize",this._onResize,this),Lt.any3d&&this.options.transform3DLimit&&(_?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){_e(this._resizeRequest),this._resizeRequest=he(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var _=this._getMapPanePos();Math.max(Math.abs(_.x),Math.abs(_.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(_,E){for(var H=[],be,Me=E==="mouseout"||E==="mouseover",Je=_.target||_.srcElement,ct=!1;Je;){if(be=this._targets[u(Je)],be&&(E==="click"||E==="preclick")&&this._draggableMoved(be)){ct=!0;break}if(be&&be.listens(E,!0)&&(Me&&!Xi(Je,_)||(H.push(be),Me))||Je===this._container)break;Je=Je.parentNode}return!H.length&&!ct&&!Me&&this.listens(E,!0)&&(H=[this]),H},_isClickDisabled:function(_){for(;_&&_!==this._container;){if(_._leaflet_disable_click)return!0;_=_.parentNode}},_handleDOMEvent:function(_){var E=_.target||_.srcElement;if(!(!this._loaded||E._leaflet_disable_events||_.type==="click"&&this._isClickDisabled(E))){var H=_.type;H==="mousedown"&&ji(E),this._fireDOMEvent(_,H)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(_,E,H){if(_.type==="click"){var be=o({},_);be.type="preclick",this._fireDOMEvent(be,be.type,H)}var Me=this._findEventTargets(_,E);if(H){for(var Je=[],ct=0;ct0?Math.round(_-E)/2:Math.max(0,Math.ceil(_))-Math.max(0,Math.floor(E))},_limitZoom:function(_){var E=this.getMinZoom(),H=this.getMaxZoom(),be=Lt.any3d?this.options.zoomSnap:1;return be&&(_=Math.round(_/be)*be),Math.max(E,Math.min(H,_))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){cr(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(_,E){var H=this._getCenterOffset(_)._trunc();return(E&&E.animate)!==!0&&!this.getSize().contains(H)?!1:(this.panBy(H,E),!0)},_createAnimProxy:function(){var _=this._proxy=Kt("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(_),this.on("zoomanim",function(E){var H=Fi,be=this._proxy.style[H];ln(this._proxy,this.project(E.center,E.zoom),this.getZoomScale(E.zoom,1)),be===this._proxy.style[H]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ar(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var _=this.getCenter(),E=this.getZoom();ln(this._proxy,this.project(_,E),this.getZoomScale(E,1))},_catchTransitionEnd:function(_){this._animatingZoom&&_.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(_,E,H){if(this._animatingZoom)return!0;if(H=H||{},!this._zoomAnimated||H.animate===!1||this._nothingToAnimate()||Math.abs(E-this._zoom)>this.options.zoomAnimationThreshold)return!1;var be=this.getZoomScale(E),Me=this._getCenterOffset(_)._divideBy(1-1/be);return H.animate!==!0&&!this.getSize().contains(Me)?!1:(he(function(){this._moveStart(!0,!1)._animateZoom(_,E,!0)},this),!0)},_animateZoom:function(_,E,H,be){!this._mapPane||(H&&(this._animatingZoom=!0,this._animateToCenter=_,this._animateToZoom=E,Bt(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:_,zoom:E,noUpdate:be}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(l(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){!this._animatingZoom||(this._mapPane&&cr(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function Es(_,E){return new zt(_,E)}var Lr=ae.extend({options:{position:"topright"},initialize:function(_){T(this,_)},getPosition:function(){return this.options.position},setPosition:function(_){var E=this._map;return E&&E.removeControl(this),this.options.position=_,E&&E.addControl(this),this},getContainer:function(){return this._container},addTo:function(_){this.remove(),this._map=_;var E=this._container=this.onAdd(_),H=this.getPosition(),be=_._controlCorners[H];return Bt(E,"leaflet-control"),H.indexOf("bottom")!==-1?be.insertBefore(E,be.firstChild):be.appendChild(E),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(ar(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(_){this._map&&_&&_.screenX>0&&_.screenY>0&&this._map.getContainer().focus()}}),jn=function(_){return new Lr(_)};zt.include({addControl:function(_){return _.addTo(this),this},removeControl:function(_){return _.remove(),this},_initControlPos:function(){var _=this._controlCorners={},E="leaflet-",H=this._controlContainer=Kt("div",E+"control-container",this._container);function be(Me,Je){var ct=E+Me+" "+E+Je;_[Me+Je]=Kt("div",ct,H)}be("top","left"),be("top","right"),be("bottom","left"),be("bottom","right")},_clearControlPos:function(){for(var _ in this._controlCorners)ar(this._controlCorners[_]);ar(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Ss=Lr.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(_,E,H,be){return H1,this._baseLayersList.style.display=_?"":"none"),this._separator.style.display=E&&_?"":"none",this},_onLayerChange:function(_){this._handlingClick||this._update();var E=this._getLayer(u(_.target)),H=E.overlay?_.type==="add"?"overlayadd":"overlayremove":_.type==="add"?"baselayerchange":null;H&&this._map.fire(H,E)},_createRadioElement:function(_,E){var H='",be=document.createElement("div");return be.innerHTML=H,be.firstChild},_addItem:function(_){var E=document.createElement("label"),H=this._map.hasLayer(_.layer),be;_.overlay?(be=document.createElement("input"),be.type="checkbox",be.className="leaflet-control-layers-selector",be.defaultChecked=H):be=this._createRadioElement("leaflet-base-layers_"+u(this),H),this._layerControlInputs.push(be),be.layerId=u(_.layer),Ot(be,"click",this._onInputClick,this);var Me=document.createElement("span");Me.innerHTML=" "+_.name;var Je=document.createElement("span");E.appendChild(Je),Je.appendChild(be),Je.appendChild(Me);var ct=_.overlay?this._overlaysList:this._baseLayersList;return ct.appendChild(E),this._checkDisabledLayers(),E},_onInputClick:function(){var _=this._layerControlInputs,E,H,be=[],Me=[];this._handlingClick=!0;for(var Je=_.length-1;Je>=0;Je--)E=_[Je],H=this._getLayer(E.layerId).layer,E.checked?be.push(H):E.checked||Me.push(H);for(Je=0;Je=0;Me--)E=_[Me],H=this._getLayer(E.layerId).layer,E.disabled=H.options.minZoom!==void 0&&beH.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this}}),Io=function(_,E,H){return new Ss(_,E,H)},Qi=Lr.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(_){var E="leaflet-control-zoom",H=Kt("div",E+" leaflet-bar"),be=this.options;return this._zoomInButton=this._createButton(be.zoomInText,be.zoomInTitle,E+"-in",H,this._zoomIn),this._zoomOutButton=this._createButton(be.zoomOutText,be.zoomOutTitle,E+"-out",H,this._zoomOut),this._updateDisabled(),_.on("zoomend zoomlevelschange",this._updateDisabled,this),H},onRemove:function(_){_.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(_){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(_.shiftKey?3:1))},_createButton:function(_,E,H,be,Me){var Je=Kt("a",H,be);return Je.innerHTML=_,Je.href="#",Je.title=E,Je.setAttribute("role","button"),Je.setAttribute("aria-label",E),Dr(Je),Ot(Je,"click",hn),Ot(Je,"click",Me,this),Ot(Je,"click",this._refocusOnMap,this),Je},_updateDisabled:function(){var _=this._map,E="leaflet-disabled";cr(this._zoomInButton,E),cr(this._zoomOutButton,E),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||_._zoom===_.getMinZoom())&&(Bt(this._zoomOutButton,E),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||_._zoom===_.getMaxZoom())&&(Bt(this._zoomInButton,E),this._zoomInButton.setAttribute("aria-disabled","true"))}});zt.mergeOptions({zoomControl:!0}),zt.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new Qi,this.addControl(this.zoomControl))});var Lo=function(_){return new Qi(_)},Cs=Lr.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(_){var E="leaflet-control-scale",H=Kt("div",E),be=this.options;return this._addScales(be,E+"-line",H),_.on(be.updateWhenIdle?"moveend":"move",this._update,this),_.whenReady(this._update,this),H},onRemove:function(_){_.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(_,E,H){_.metric&&(this._mScale=Kt("div",E,H)),_.imperial&&(this._iScale=Kt("div",E,H))},_update:function(){var _=this._map,E=_.getSize().y/2,H=_.distance(_.containerPointToLatLng([0,E]),_.containerPointToLatLng([this.options.maxWidth,E]));this._updateScales(H)},_updateScales:function(_){this.options.metric&&_&&this._updateMetric(_),this.options.imperial&&_&&this._updateImperial(_)},_updateMetric:function(_){var E=this._getRoundNum(_),H=E<1e3?E+" m":E/1e3+" km";this._updateScale(this._mScale,H,E/_)},_updateImperial:function(_){var E=_*3.2808399,H,be,Me;E>5280?(H=E/5280,be=this._getRoundNum(H),this._updateScale(this._iScale,be+" mi",be/H)):(Me=this._getRoundNum(E),this._updateScale(this._iScale,Me+" ft",Me/E))},_updateScale:function(_,E,H){_.style.width=Math.round(this.options.maxWidth*H)+"px",_.innerHTML=E},_getRoundNum:function(_){var E=Math.pow(10,(Math.floor(_)+"").length-1),H=_/E;return H=H>=10?10:H>=5?5:H>=3?3:H>=2?2:1,E*H}}),ks=function(_){return new Cs(_)},Ro='',Ji=Lr.extend({options:{position:"bottomright",prefix:''+(Lt.inlineSvg?Ro+" ":"")+"Leaflet"},initialize:function(_){T(this,_),this._attributions={}},onAdd:function(_){_.attributionControl=this,this._container=Kt("div","leaflet-control-attribution"),Dr(this._container);for(var E in _._layers)_._layers[E].getAttribution&&this.addAttribution(_._layers[E].getAttribution());return this._update(),_.on("layeradd",this._addAttribution,this),this._container},onRemove:function(_){_.off("layeradd",this._addAttribution,this)},_addAttribution:function(_){_.layer.getAttribution&&(this.addAttribution(_.layer.getAttribution()),_.layer.once("remove",function(){this.removeAttribution(_.layer.getAttribution())},this))},setPrefix:function(_){return this.options.prefix=_,this._update(),this},addAttribution:function(_){return _?(this._attributions[_]||(this._attributions[_]=0),this._attributions[_]++,this._update(),this):this},removeAttribution:function(_){return _?(this._attributions[_]&&(this._attributions[_]--,this._update()),this):this},_update:function(){if(!!this._map){var _=[];for(var E in this._attributions)this._attributions[E]&&_.push(E);var H=[];this.options.prefix&&H.push(this.options.prefix),_.length&&H.push(_.join(", ")),this._container.innerHTML=H.join(' ')}}});zt.mergeOptions({attributionControl:!0}),zt.addInitHook(function(){this.options.attributionControl&&new Ji().addTo(this)});var Mo=function(_){return new Ji(_)};Lr.Layers=Ss,Lr.Zoom=Qi,Lr.Scale=Cs,Lr.Attribution=Ji,jn.layers=Io,jn.zoom=Lo,jn.scale=ks,jn.attribution=Mo;var Nr=ae.extend({initialize:function(_){this._map=_},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});Nr.addTo=function(_,E){return _.addHandler(E,this),this};var Oo={Events:pe},As=Lt.touch?"touchstart mousedown":"mousedown",Zr=ue.extend({options:{clickTolerance:3},initialize:function(_,E,H,be){T(this,be),this._element=_,this._dragStartTarget=E||_,this._preventOutline=H},enable:function(){this._enabled||(Ot(this._dragStartTarget,As,this._onDown,this),this._enabled=!0)},disable:function(){!this._enabled||(Zr._dragging===this&&this.finishDrag(!0),tr(this._dragStartTarget,As,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(_){if(!!this._enabled&&(this._moved=!1,!di(this._element,"leaflet-zoom-anim"))){if(_.touches&&_.touches.length!==1){Zr._dragging===this&&this.finishDrag();return}if(!(Zr._dragging||_.shiftKey||_.which!==1&&_.button!==1&&!_.touches)&&(Zr._dragging=this,this._preventOutline&&ji(this._element),Hi(),Un(),!this._moving)){this.fire("down");var E=_.touches?_.touches[0]:_,H=Ki(this._element);this._startPoint=new ge(E.clientX,E.clientY),this._startPos=cn(this._element),this._parentScale=gi(H);var be=_.type==="mousedown";Ot(document,be?"mousemove":"touchmove",this._onMove,this),Ot(document,be?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(_){if(!!this._enabled){if(_.touches&&_.touches.length>1){this._moved=!0;return}var E=_.touches&&_.touches.length===1?_.touches[0]:_,H=new ge(E.clientX,E.clientY)._subtract(this._startPoint);!H.x&&!H.y||Math.abs(H.x)+Math.abs(H.y)Je&&(ct=gt,Je=_t);Je>H&&(E[ct]=1,es(_,E,H,be,ct),es(_,E,H,ct,Me))}function No(_,E){for(var H=[_[0]],be=1,Me=0,Je=_.length;beE&&(H.push(_[be]),Me=be);return MeE.max.x&&(H|=2),_.yE.max.y&&(H|=8),H}function Bo(_,E){var H=E.x-_.x,be=E.y-_.y;return H*H+be*be}function Yn(_,E,H,be){var Me=E.x,Je=E.y,ct=H.x-Me,gt=H.y-Je,_t=ct*ct+gt*gt,xt;return _t>0&&(xt=((_.x-Me)*ct+(_.y-Je)*gt)/_t,xt>1?(Me=H.x,Je=H.y):xt>0&&(Me+=ct*xt,Je+=gt*xt)),ct=_.x-Me,gt=_.y-Je,be?ct*ct+gt*gt:new ge(Me,Je)}function Ar(_){return!N(_[0])||typeof _[0][0]!="object"&&typeof _[0][0]<"u"}function Rs(_){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),Ar(_)}function Ms(_,E){var H,be,Me,Je,ct,gt,_t,xt;if(!_||_.length===0)throw new Error("latlngs not passed");Ar(_)||(console.warn("latlngs are not flat! Only the first ring will be used"),_=_[0]);var Tt=[];for(var Mt in _)Tt.push(E.project(Be(_[Mt])));var Dt=Tt.length;for(H=0,be=0;Hbe){_t=(Je-be)/Me,xt=[gt.x-_t*(gt.x-ct.x),gt.y-_t*(gt.y-ct.y)];break}return E.unproject(Ae(xt))}var Os={__proto__:null,simplify:Ts,pointToSegmentDistance:Ps,closestPointOnSegment:Do,clipSegment:Ls,_getEdgeIntersection:Kn,_getBitCode:dn,_sqClosestPointOnSegment:Yn,isFlat:Ar,_flat:Rs,polylineCenter:Ms};function Gn(_,E,H){var be,Me=[1,4,2,8],Je,ct,gt,_t,xt,Tt,Mt,Dt;for(Je=0,Tt=_.length;Je1e-7;gt++)xt=Me*Math.sin(ct),xt=Math.pow((1-xt)/(1+xt),Me/2),_t=Math.PI/2-2*Math.atan(Je*xt)-ct,ct+=_t;return new Oe(ct*E,_.x*E/H)}},Fo={__proto__:null,LonLat:ts,Mercator:bi,SphericalMercator:$e},Ns=o({},Se,{code:"EPSG:3395",projection:bi,transformation:function(){var _=.5/(Math.PI*bi.R);return oe(_,.5,-_,.5)}()}),Bs=o({},Se,{code:"EPSG:4326",projection:ts,transformation:oe(1/180,1,-1/180,.5)}),qn=o({},Ye,{projection:ts,transformation:oe(1,0,-1,0),scale:function(_){return Math.pow(2,_)},zoom:function(_){return Math.log(_)/Math.LN2},distance:function(_,E){var H=E.lng-_.lng,be=E.lat-_.lat;return Math.sqrt(H*H+be*be)},infinite:!0});Ye.Earth=Se,Ye.EPSG3395=Ns,Ye.EPSG3857=te,Ye.EPSG900913=se,Ye.EPSG4326=Bs,Ye.Simple=qn;var Rr=ue.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(_){return _.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(_){return _&&_.removeLayer(this),this},getPane:function(_){return this._map.getPane(_?this.options[_]||_:this.options.pane)},addInteractiveTarget:function(_){return this._map._targets[u(_)]=this,this},removeInteractiveTarget:function(_){return delete this._map._targets[u(_)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(_){var E=_.target;if(!!E.hasLayer(this)){if(this._map=E,this._zoomAnimated=E._zoomAnimated,this.getEvents){var H=this.getEvents();E.on(H,this),this.once("remove",function(){E.off(H,this)},this)}this.onAdd(E),this.fire("add"),E.fire("layeradd",{layer:this})}}});zt.include({addLayer:function(_){if(!_._layerAdd)throw new Error("The provided object is not a Layer.");var E=u(_);return this._layers[E]?this:(this._layers[E]=_,_._mapToAdd=this,_.beforeAdd&&_.beforeAdd(this),this.whenReady(_._layerAdd,_),this)},removeLayer:function(_){var E=u(_);return this._layers[E]?(this._loaded&&_.onRemove(this),delete this._layers[E],this._loaded&&(this.fire("layerremove",{layer:_}),_.fire("remove")),_._map=_._mapToAdd=null,this):this},hasLayer:function(_){return u(_)in this._layers},eachLayer:function(_,E){for(var H in this._layers)_.call(E,this._layers[H]);return this},_addLayers:function(_){_=_?N(_)?_:[_]:[];for(var E=0,H=_.length;Ethis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()=2&&E[0]instanceof Oe&&E[0].equals(E[H-1])&&E.pop(),E},_setLatLngs:function(_){Br.prototype._setLatLngs.call(this,_),Ar(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Ar(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var _=this._renderer._bounds,E=this.options.weight,H=new ge(E,E);if(_=new Re(_.min.subtract(H),_.max.add(H)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(_))){if(this.options.noClip){this._parts=this._rings;return}for(var be=0,Me=this._rings.length,Je;be_.y!=Me.y>_.y&&_.x<(Me.x-be.x)*(_.y-be.y)/(Me.y-be.y)+be.x&&(E=!E);return E||Br.prototype._containsPoint.call(this,_,!0)}});function xi(_,E){return new pn(_,E)}var Vr=fn.extend({initialize:function(_,E){T(this,E),this._layers={},_&&this.addData(_)},addData:function(_){var E=N(_)?_:_.features,H,be,Me;if(E){for(H=0,be=E.length;H0?be:[E.src];return}N(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(E.style,"objectFit")&&(E.style.objectFit="fill"),E.autoplay=!!this.options.autoplay,E.loop=!!this.options.loop,E.muted=!!this.options.muted,E.playsInline=!!this.options.playsInline;for(var Je=0;JeMe?(E.height=Me+"px",Bt(_,Je)):cr(_,Je),this._containerWidth=this._container.offsetWidth},_animateZoom:function(_){var E=this._map._latLngToNewLayerPoint(this._latlng,_.zoom,_.center),H=this._getAnchor();dr(this._container,E.add(H))},_adjustPan:function(_){if(!!this.options.autoPan){this._map._panAnim&&this._map._panAnim.stop();var E=this._map,H=parseInt(Or(this._container,"marginBottom"),10)||0,be=this._container.offsetHeight+H,Me=this._containerWidth,Je=new ge(this._containerLeft,-be-this._containerBottom);Je._add(cn(this._container));var ct=E.layerPointToContainerPoint(Je),gt=Ae(this.options.autoPanPadding),_t=Ae(this.options.autoPanPaddingTopLeft||gt),xt=Ae(this.options.autoPanPaddingBottomRight||gt),Tt=E.getSize(),Mt=0,Dt=0;ct.x+Me+xt.x>Tt.x&&(Mt=ct.x+Me-Tt.x+xt.x),ct.x-Mt-_t.x<0&&(Mt=ct.x-_t.x),ct.y+be+xt.y>Tt.y&&(Dt=ct.y+be-Tt.y+xt.y),ct.y-Dt-_t.y<0&&(Dt=ct.y-_t.y),(Mt||Dt)&&E.fire("autopanstart").panBy([Mt,Dt],{animate:_&&_.type==="moveend"})}},_getAnchor:function(){return Ae(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Yo=function(_,E){return new gn(_,E)};zt.mergeOptions({closePopupOnClick:!0}),zt.include({openPopup:function(_,E,H){return this._initOverlay(gn,_,E,H).openOn(this),this},closePopup:function(_){return _=arguments.length?_:this._popup,_&&_.close(),this}}),Rr.include({bindPopup:function(_,E){return this._popup=this._initOverlay(gn,this._popup,_,E),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(_){return this._popup&&this._popup._prepareOpen(_||this._latlng)&&this._popup.openOn(this._map),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(_){return this._popup&&this._popup.setContent(_),this},getPopup:function(){return this._popup},_openPopup:function(_){if(!(!this._popup||!this._map)){hn(_);var E=_.layer||_.target;if(this._popup._source===E&&!(E instanceof Xr)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(_.latlng);return}this._popup._source=E,this.openPopup(_.latlng)}},_movePopup:function(_){this._popup.setLatLng(_.latlng)},_onKeyPress:function(_){_.originalEvent.keyCode===13&&this._openPopup(_)}});var Ci=Fr.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(_){Fr.prototype.onAdd.call(this,_),this.setOpacity(this.options.opacity),_.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(_){Fr.prototype.onRemove.call(this,_),_.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var _=Fr.prototype.getEvents.call(this);return this.options.permanent||(_.preclick=this.close),_},_initLayout:function(){var _="leaflet-tooltip",E=_+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=Kt("div",E),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+u(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(_){var E,H,be=this._map,Me=this._container,Je=be.latLngToContainerPoint(be.getCenter()),ct=be.layerPointToContainerPoint(_),gt=this.options.direction,_t=Me.offsetWidth,xt=Me.offsetHeight,Tt=Ae(this.options.offset),Mt=this._getAnchor();gt==="top"?(E=_t/2,H=xt):gt==="bottom"?(E=_t/2,H=0):gt==="center"?(E=_t/2,H=xt/2):gt==="right"?(E=0,H=xt/2):gt==="left"?(E=_t,H=xt/2):ct.xthis.options.maxZoom||Hbe?this._retainParent(Me,Je,ct,be):!1)},_retainChildren:function(_,E,H,be){for(var Me=2*_;Me<2*_+2;Me++)for(var Je=2*E;Je<2*E+2;Je++){var ct=new ge(Me,Je);ct.z=H+1;var gt=this._tileCoordsToKey(ct),_t=this._tiles[gt];if(_t&&_t.active){_t.retain=!0;continue}else _t&&_t.loaded&&(_t.retain=!0);H+1this.options.maxZoom||this.options.minZoom!==void 0&&Me1){this._setView(_,H);return}for(var Mt=Me.min.y;Mt<=Me.max.y;Mt++)for(var Dt=Me.min.x;Dt<=Me.max.x;Dt++){var Cr=new ge(Dt,Mt);if(Cr.z=this._tileZoom,!!this._isValidTile(Cr)){var Jr=this._tiles[this._tileCoordsToKey(Cr)];Jr?Jr.current=!0:ct.push(Cr)}}if(ct.sort(function(zr,ii){return zr.distanceTo(Je)-ii.distanceTo(Je)}),ct.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var Ti=document.createDocumentFragment();for(Dt=0;DtH.max.x)||!E.wrapLat&&(_.yH.max.y))return!1}if(!this.options.bounds)return!0;var be=this._tileCoordsToBounds(_);return Ue(this.options.bounds).overlaps(be)},_keyToBounds:function(_){return this._tileCoordsToBounds(this._keyToTileCoords(_))},_tileCoordsToNwSe:function(_){var E=this._map,H=this.getTileSize(),be=_.scaleBy(H),Me=be.add(H),Je=E.unproject(be,_.z),ct=E.unproject(Me,_.z);return[Je,ct]},_tileCoordsToBounds:function(_){var E=this._tileCoordsToNwSe(_),H=new Pe(E[0],E[1]);return this.options.noWrap||(H=this._map.wrapLatLngBounds(H)),H},_tileCoordsToKey:function(_){return _.x+":"+_.y+":"+_.z},_keyToTileCoords:function(_){var E=_.split(":"),H=new ge(+E[0],+E[1]);return H.z=+E[2],H},_removeTile:function(_){var E=this._tiles[_];!E||(ar(E.el),delete this._tiles[_],this.fire("tileunload",{tile:E.el,coords:this._keyToTileCoords(_)}))},_initTile:function(_){Bt(_,"leaflet-tile");var E=this.getTileSize();_.style.width=E.x+"px",_.style.height=E.y+"px",_.onselectstart=x,_.onmousemove=x,Lt.ielt9&&this.options.opacity<1&&kr(_,this.options.opacity)},_addTile:function(_,E){var H=this._getTilePos(_),be=this._tileCoordsToKey(_),Me=this.createTile(this._wrapCoords(_),l(this._tileReady,this,_));this._initTile(Me),this.createTile.length<2&&he(l(this._tileReady,this,_,null,Me)),dr(Me,H),this._tiles[be]={el:Me,coords:_,current:!0},E.appendChild(Me),this.fire("tileloadstart",{tile:Me,coords:_})},_tileReady:function(_,E,H){E&&this.fire("tileerror",{error:E,tile:H,coords:_});var be=this._tileCoordsToKey(_);H=this._tiles[be],H&&(H.loaded=+new Date,this._map._fadeAnimated?(kr(H.el,0),_e(this._fadeFrame),this._fadeFrame=he(this._updateOpacity,this)):(H.active=!0,this._pruneTiles()),E||(Bt(H.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:H.el,coords:_})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Lt.ielt9||!this._map._fadeAnimated?he(this._pruneTiles,this):setTimeout(l(this._pruneTiles,this),250)))},_getTilePos:function(_){return _.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(_){var E=new ge(this._wrapX?b(_.x,this._wrapX):_.x,this._wrapY?b(_.y,this._wrapY):_.y);return E.z=_.z,E},_pxBoundsToTileRange:function(_){var E=this.getTileSize();return new Re(_.min.unscaleBy(E).floor(),_.max.unscaleBy(E).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var _ in this._tiles)if(!this._tiles[_].loaded)return!1;return!0}});function qo(_){return new ti(_)}var yn=ti.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(_,E){this._url=_,E=T(this,E),E.detectRetina&&Lt.retina&&E.maxZoom>0?(E.tileSize=Math.floor(E.tileSize/2),E.zoomReverse?(E.zoomOffset--,E.minZoom=Math.min(E.maxZoom,E.minZoom+1)):(E.zoomOffset++,E.maxZoom=Math.max(E.minZoom,E.maxZoom-1)),E.minZoom=Math.max(0,E.minZoom)):E.zoomReverse?E.minZoom=Math.min(E.maxZoom,E.minZoom):E.maxZoom=Math.max(E.minZoom,E.maxZoom),typeof E.subdomains=="string"&&(E.subdomains=E.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(_,E){return this._url===_&&E===void 0&&(E=!0),this._url=_,E||this.redraw(),this},createTile:function(_,E){var H=document.createElement("img");return Ot(H,"load",l(this._tileOnLoad,this,E,H)),Ot(H,"error",l(this._tileOnError,this,E,H)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(H.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(H.referrerPolicy=this.options.referrerPolicy),H.alt="",H.src=this.getTileUrl(_),H},getTileUrl:function(_){var E={r:Lt.retina?"@2x":"",s:this._getSubdomain(_),x:_.x,y:_.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var H=this._globalTileRange.max.y-_.y;this.options.tms&&(E.y=H),E["-y"]=H}return O(this._url,o(E,this.options))},_tileOnLoad:function(_,E){Lt.ielt9?setTimeout(l(_,this,null,E),0):_(null,E)},_tileOnError:function(_,E,H){var be=this.options.errorTileUrl;be&&E.getAttribute("src")!==be&&(E.src=be),_(H,E)},_onTileRemove:function(_){_.tile.onload=null},_getZoomForUrl:function(){var _=this._tileZoom,E=this.options.maxZoom,H=this.options.zoomReverse,be=this.options.zoomOffset;return H&&(_=E-_),_+be},_getSubdomain:function(_){var E=Math.abs(_.x+_.y)%this.options.subdomains.length;return this.options.subdomains[E]},_abortLoading:function(){var _,E;for(_ in this._tiles)if(this._tiles[_].coords.z!==this._tileZoom&&(E=this._tiles[_].el,E.onload=x,E.onerror=x,!E.complete)){E.src=ne;var H=this._tiles[_].coords;ar(E),delete this._tiles[_],this.fire("tileabort",{tile:E,coords:H})}},_removeTile:function(_){var E=this._tiles[_];if(!!E)return E.el.setAttribute("src",ne),ti.prototype._removeTile.call(this,_)},_tileReady:function(_,E,H){if(!(!this._map||H&&H.getAttribute("src")===ne))return ti.prototype._tileReady.call(this,_,E,H)}});function os(_,E){return new yn(_,E)}var Ys=yn.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(_,E){this._url=_;var H=o({},this.defaultWmsParams);for(var be in E)be in this.options||(H[be]=E[be]);E=T(this,E);var Me=E.detectRetina&&Lt.retina?2:1,Je=this.getTileSize();H.width=Je.x*Me,H.height=Je.y*Me,this.wmsParams=H},onAdd:function(_){this._crs=this.options.crs||_.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var E=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[E]=this._crs.code,yn.prototype.onAdd.call(this,_)},getTileUrl:function(_){var E=this._tileCoordsToNwSe(_),H=this._crs,be=We(H.project(E[0]),H.project(E[1])),Me=be.min,Je=be.max,ct=(this._wmsVersion>=1.3&&this._crs===Bs?[Me.y,Me.x,Je.y,Je.x]:[Me.x,Me.y,Je.x,Je.y]).join(","),gt=yn.prototype.getTileUrl.call(this,_);return gt+D(this.wmsParams,gt,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+ct},setParams:function(_,E){return o(this.wmsParams,_),E||this.redraw(),this}});function Zo(_,E){return new Ys(_,E)}yn.WMS=Ys,os.wms=Zo;var Hr=Rr.extend({options:{padding:.1},initialize:function(_){T(this,_),u(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),this._zoomAnimated&&Bt(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var _={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(_.zoomanim=this._onAnimZoom),_},_onAnimZoom:function(_){this._updateTransform(_.center,_.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(_,E){var H=this._map.getZoomScale(E,this._zoom),be=this._map.getSize().multiplyBy(.5+this.options.padding),Me=this._map.project(this._center,E),Je=be.multiplyBy(-H).add(Me).subtract(this._map._getNewPixelOrigin(_,E));Lt.any3d?ln(this._container,Je,H):dr(this._container,Je)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var _ in this._layers)this._layers[_]._reset()},_onZoomEnd:function(){for(var _ in this._layers)this._layers[_]._project()},_updatePaths:function(){for(var _ in this._layers)this._layers[_]._update()},_update:function(){var _=this.options.padding,E=this._map.getSize(),H=this._map.containerPointToLayerPoint(E.multiplyBy(-_)).round();this._bounds=new Re(H,H.add(E.multiplyBy(1+_*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Gs=Hr.extend({options:{tolerance:0},getEvents:function(){var _=Hr.prototype.getEvents.call(this);return _.viewprereset=this._onViewPreReset,_},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Hr.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var _=this._container=document.createElement("canvas");Ot(_,"mousemove",this._onMouseMove,this),Ot(_,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Ot(_,"mouseout",this._handleMouseOut,this),_._leaflet_disable_events=!0,this._ctx=_.getContext("2d")},_destroyContainer:function(){_e(this._redrawRequest),delete this._ctx,ar(this._container),tr(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var _;this._redrawBounds=null;for(var E in this._layers)_=this._layers[E],_._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Hr.prototype._update.call(this);var _=this._bounds,E=this._container,H=_.getSize(),be=Lt.retina?2:1;dr(E,_.min),E.width=be*H.x,E.height=be*H.y,E.style.width=H.x+"px",E.style.height=H.y+"px",Lt.retina&&this._ctx.scale(2,2),this._ctx.translate(-_.min.x,-_.min.y),this.fire("update")}},_reset:function(){Hr.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(_){this._updateDashArray(_),this._layers[u(_)]=_;var E=_._order={layer:_,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=E),this._drawLast=E,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(_){this._requestRedraw(_)},_removePath:function(_){var E=_._order,H=E.next,be=E.prev;H?H.prev=be:this._drawLast=be,be?be.next=H:this._drawFirst=H,delete _._order,delete this._layers[u(_)],this._requestRedraw(_)},_updatePath:function(_){this._extendRedrawBounds(_),_._project(),_._update(),this._requestRedraw(_)},_updateStyle:function(_){this._updateDashArray(_),this._requestRedraw(_)},_updateDashArray:function(_){if(typeof _.options.dashArray=="string"){var E=_.options.dashArray.split(/[, ]+/),H=[],be,Me;for(Me=0;Me')}}catch{}return function(_){return document.createElement("<"+_+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),Xo={_initContainer:function(){this._container=Kt("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Hr.prototype._update.call(this),this.fire("update"))},_initPath:function(_){var E=_._container=ri("shape");Bt(E,"leaflet-vml-shape "+(this.options.className||"")),E.coordsize="1 1",_._path=ri("path"),E.appendChild(_._path),this._updateStyle(_),this._layers[u(_)]=_},_addPath:function(_){var E=_._container;this._container.appendChild(E),_.options.interactive&&_.addInteractiveTarget(E)},_removePath:function(_){var E=_._container;ar(E),_.removeInteractiveTarget(E),delete this._layers[u(_)]},_updateStyle:function(_){var E=_._stroke,H=_._fill,be=_.options,Me=_._container;Me.stroked=!!be.stroke,Me.filled=!!be.fill,be.stroke?(E||(E=_._stroke=ri("stroke")),Me.appendChild(E),E.weight=be.weight+"px",E.color=be.color,E.opacity=be.opacity,be.dashArray?E.dashStyle=N(be.dashArray)?be.dashArray.join(" "):be.dashArray.replace(/( *, *)/g," "):E.dashStyle="",E.endcap=be.lineCap.replace("butt","flat"),E.joinstyle=be.lineJoin):E&&(Me.removeChild(E),_._stroke=null),be.fill?(H||(H=_._fill=ri("fill")),Me.appendChild(H),H.color=be.fillColor||be.color,H.opacity=be.fillOpacity):H&&(Me.removeChild(H),_._fill=null)},_updateCircle:function(_){var E=_._point.round(),H=Math.round(_._radius),be=Math.round(_._radiusY||H);this._setPath(_,_._empty()?"M0 0":"AL "+E.x+","+E.y+" "+H+","+be+" 0,"+65535*360)},_setPath:function(_,E){_._path.v=E},_bringToFront:function(_){En(_._container)},_bringToBack:function(_){Sn(_._container)}},Ai=Lt.vml?ri:me,ni=Hr.extend({_initContainer:function(){this._container=Ai("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=Ai("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ar(this._container),tr(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Hr.prototype._update.call(this);var _=this._bounds,E=_.getSize(),H=this._container;(!this._svgSize||!this._svgSize.equals(E))&&(this._svgSize=E,H.setAttribute("width",E.x),H.setAttribute("height",E.y)),dr(H,_.min),H.setAttribute("viewBox",[_.min.x,_.min.y,E.x,E.y].join(" ")),this.fire("update")}},_initPath:function(_){var E=_._path=Ai("path");_.options.className&&Bt(E,_.options.className),_.options.interactive&&Bt(E,"leaflet-interactive"),this._updateStyle(_),this._layers[u(_)]=_},_addPath:function(_){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(_._path),_.addInteractiveTarget(_._path)},_removePath:function(_){ar(_._path),_.removeInteractiveTarget(_._path),delete this._layers[u(_)]},_updatePath:function(_){_._project(),_._update()},_updateStyle:function(_){var E=_._path,H=_.options;!E||(H.stroke?(E.setAttribute("stroke",H.color),E.setAttribute("stroke-opacity",H.opacity),E.setAttribute("stroke-width",H.weight),E.setAttribute("stroke-linecap",H.lineCap),E.setAttribute("stroke-linejoin",H.lineJoin),H.dashArray?E.setAttribute("stroke-dasharray",H.dashArray):E.removeAttribute("stroke-dasharray"),H.dashOffset?E.setAttribute("stroke-dashoffset",H.dashOffset):E.removeAttribute("stroke-dashoffset")):E.setAttribute("stroke","none"),H.fill?(E.setAttribute("fill",H.fillColor||H.color),E.setAttribute("fill-opacity",H.fillOpacity),E.setAttribute("fill-rule",H.fillRule||"evenodd")):E.setAttribute("fill","none"))},_updatePoly:function(_,E){this._setPath(_,Ee(_._parts,E))},_updateCircle:function(_){var E=_._point,H=Math.max(Math.round(_._radius),1),be=Math.max(Math.round(_._radiusY),1)||H,Me="a"+H+","+be+" 0 1,0 ",Je=_._empty()?"M0 0":"M"+(E.x-H)+","+E.y+Me+H*2+",0 "+Me+-H*2+",0 ";this._setPath(_,Je)},_setPath:function(_,E){_._path.setAttribute("d",E)},_bringToFront:function(_){En(_._path)},_bringToBack:function(_){Sn(_._path)}});Lt.vml&&ni.include(Xo);function Zs(_){return Lt.svg||Lt.vml?new ni(_):null}zt.include({getRenderer:function(_){var E=_.options.renderer||this._getPaneRenderer(_.options.pane)||this.options.renderer||this._renderer;return E||(E=this._renderer=this._createRenderer()),this.hasLayer(E)||this.addLayer(E),E},_getPaneRenderer:function(_){if(_==="overlayPane"||_===void 0)return!1;var E=this._paneRenderers[_];return E===void 0&&(E=this._createRenderer({pane:_}),this._paneRenderers[_]=E),E},_createRenderer:function(_){return this.options.preferCanvas&&qs(_)||Zs(_)}});var Xs=pn.extend({initialize:function(_,E){pn.prototype.initialize.call(this,this._boundsToLatLngs(_),E)},setBounds:function(_){return this.setLatLngs(this._boundsToLatLngs(_))},_boundsToLatLngs:function(_){return _=Ue(_),[_.getSouthWest(),_.getNorthWest(),_.getNorthEast(),_.getSouthEast()]}});function Qo(_,E){return new Xs(_,E)}ni.create=Ai,ni.pointsToPath=Ee,Vr.geometryToLayer=Jn,Vr.coordsToLatLng=rs,Vr.coordsToLatLngs=Ei,Vr.latLngToCoords=ns,Vr.latLngsToCoords=Si,Vr.getFeature=Qr,Vr.asFeature=mn,zt.mergeOptions({boxZoom:!0});var Qs=Nr.extend({initialize:function(_){this._map=_,this._container=_._container,this._pane=_._panes.overlayPane,this._resetStateTimeout=0,_.on("unload",this._destroy,this)},addHooks:function(){Ot(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){tr(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ar(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(_){if(!_.shiftKey||_.which!==1&&_.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),Un(),Hi(),this._startPoint=this._map.mouseEventToContainerPoint(_),Ot(document,{contextmenu:hn,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(_){this._moved||(this._moved=!0,this._box=Kt("div","leaflet-zoom-box",this._container),Bt(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(_);var E=new Re(this._point,this._startPoint),H=E.getSize();dr(this._box,E.min),this._box.style.width=H.x+"px",this._box.style.height=H.y+"px"},_finish:function(){this._moved&&(ar(this._box),cr(this._container,"leaflet-crosshair")),Vn(),zi(),tr(document,{contextmenu:hn,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(_){if(!(_.which!==1&&_.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(l(this._resetState,this),0);var E=new Pe(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(E).fire("boxzoomend",{boxZoomBounds:E})}},_onKeyDown:function(_){_.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});zt.addInitHook("addHandler","boxZoom",Qs),zt.mergeOptions({doubleClickZoom:!0});var Js=Nr.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(_){var E=this._map,H=E.getZoom(),be=E.options.zoomDelta,Me=_.originalEvent.shiftKey?H-be:H+be;E.options.doubleClickZoom==="center"?E.setZoom(Me):E.setZoomAround(_.containerPoint,Me)}});zt.addInitHook("addHandler","doubleClickZoom",Js),zt.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var ls=Nr.extend({addHooks:function(){if(!this._draggable){var _=this._map;this._draggable=new Zr(_._mapPane,_._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),_.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),_.on("zoomend",this._onZoomEnd,this),_.whenReady(this._onZoomEnd,this))}Bt(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){cr(this._map._container,"leaflet-grab"),cr(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var _=this._map;if(_._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var E=Ue(this._map.options.maxBounds);this._offsetLimit=We(this._map.latLngToContainerPoint(E.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(E.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;_.fire("movestart").fire("dragstart"),_.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(_){if(this._map.options.inertia){var E=this._lastTime=+new Date,H=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(H),this._times.push(E),this._prunePositions(E)}this._map.fire("move",_).fire("drag",_)},_prunePositions:function(_){for(;this._positions.length>1&&_-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var _=this._map.getSize().divideBy(2),E=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=E.subtract(_).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(_,E){return _-(_-E)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var _=this._draggable._newPos.subtract(this._draggable._startPos),E=this._offsetLimit;_.xE.max.x&&(_.x=this._viscousLimit(_.x,E.max.x)),_.y>E.max.y&&(_.y=this._viscousLimit(_.y,E.max.y)),this._draggable._newPos=this._draggable._startPos.add(_)}},_onPreDragWrap:function(){var _=this._worldWidth,E=Math.round(_/2),H=this._initialWorldOffset,be=this._draggable._newPos.x,Me=(be-E+H)%_+E-H,Je=(be+E+H)%_-E-H,ct=Math.abs(Me+H)0?Je:-Je))-E;this._delta=0,this._startTime=null,ct&&(_.options.scrollWheelZoom==="center"?_.setZoom(E+ct):_.setZoomAround(this._lastMousePos,E+ct))}});zt.addInitHook("addHandler","scrollWheelZoom",eo);var ro=600;zt.mergeOptions({tapHold:Lt.touchNative&&Lt.safari&&Lt.mobile,tapTolerance:15});var no=Nr.extend({addHooks:function(){Ot(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){tr(this._map._container,"touchstart",this._onDown,this)},_onDown:function(_){if(clearTimeout(this._holdTimeout),_.touches.length===1){var E=_.touches[0];this._startPos=this._newPos=new ge(E.clientX,E.clientY),this._holdTimeout=setTimeout(l(function(){this._cancel(),this._isTapValid()&&(Ot(document,"touchend",gr),Ot(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",E))},this),ro),Ot(document,"touchend touchcancel contextmenu",this._cancel,this),Ot(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function _(){tr(document,"touchend",gr),tr(document,"touchend touchcancel",_)},_cancel:function(){clearTimeout(this._holdTimeout),tr(document,"touchend touchcancel contextmenu",this._cancel,this),tr(document,"touchmove",this._onMove,this)},_onMove:function(_){var E=_.touches[0];this._newPos=new ge(E.clientX,E.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(_,E){var H=new MouseEvent(_,{bubbles:!0,cancelable:!0,view:window,screenX:E.screenX,screenY:E.screenY,clientX:E.clientX,clientY:E.clientY});H._simulated=!0,E.target.dispatchEvent(H)}});zt.addInitHook("addHandler","tapHold",no),zt.mergeOptions({touchZoom:Lt.touch,bounceAtZoomLimits:!0});var so=Nr.extend({addHooks:function(){Bt(this._map._container,"leaflet-touch-zoom"),Ot(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){cr(this._map._container,"leaflet-touch-zoom"),tr(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(_){var E=this._map;if(!(!_.touches||_.touches.length!==2||E._animatingZoom||this._zooming)){var H=E.mouseEventToContainerPoint(_.touches[0]),be=E.mouseEventToContainerPoint(_.touches[1]);this._centerPoint=E.getSize()._divideBy(2),this._startLatLng=E.containerPointToLatLng(this._centerPoint),E.options.touchZoom!=="center"&&(this._pinchStartLatLng=E.containerPointToLatLng(H.add(be)._divideBy(2))),this._startDist=H.distanceTo(be),this._startZoom=E.getZoom(),this._moved=!1,this._zooming=!0,E._stop(),Ot(document,"touchmove",this._onTouchMove,this),Ot(document,"touchend touchcancel",this._onTouchEnd,this),gr(_)}},_onTouchMove:function(_){if(!(!_.touches||_.touches.length!==2||!this._zooming)){var E=this._map,H=E.mouseEventToContainerPoint(_.touches[0]),be=E.mouseEventToContainerPoint(_.touches[1]),Me=H.distanceTo(be)/this._startDist;if(this._zoom=E.getScaleZoom(Me,this._startZoom),!E.options.bounceAtZoomLimits&&(this._zoomE.getMaxZoom()&&Me>1)&&(this._zoom=E._limitZoom(this._zoom)),E.options.touchZoom==="center"){if(this._center=this._startLatLng,Me===1)return}else{var Je=H._add(be)._divideBy(2)._subtract(this._centerPoint);if(Me===1&&Je.x===0&&Je.y===0)return;this._center=E.unproject(E.project(this._pinchStartLatLng,this._zoom).subtract(Je),this._zoom)}this._moved||(E._moveStart(!0,!1),this._moved=!0),_e(this._animRequest);var ct=l(E._move,E,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=he(ct,this,!0),gr(_)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,_e(this._animRequest),tr(document,"touchmove",this._onTouchMove,this),tr(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});zt.addInitHook("addHandler","touchZoom",so),zt.BoxZoom=Qs,zt.DoubleClickZoom=Js,zt.Drag=ls,zt.Keyboard=cs,zt.ScrollWheelZoom=eo,zt.TapHold=no,zt.TouchZoom=so,r.Bounds=Re,r.Browser=Lt,r.CRS=Ye,r.Canvas=Gs,r.Circle=Qn,r.CircleMarker=wi,r.Class=ae,r.Control=Lr,r.DivIcon=ki,r.DivOverlay=Fr,r.DomEvent=$o,r.DomUtil=Po,r.Draggable=Zr,r.Evented=ue,r.FeatureGroup=fn,r.GeoJSON=Vr,r.GridLayer=ti,r.Handler=Nr,r.Icon=kn,r.ImageOverlay=An,r.LatLng=Oe,r.LatLngBounds=Pe,r.Layer=Rr,r.LayerGroup=Cn,r.LineUtil=Os,r.Map=zt,r.Marker=Xn,r.Mixin=Oo,r.Path=Xr,r.Point=ge,r.PolyUtil=Ds,r.Polygon=pn,r.Polyline=Br,r.Popup=gn,r.PosAnimation=xs,r.Projection=Fo,r.Rectangle=Xs,r.Renderer=Hr,r.SVG=ni,r.SVGOverlay=is,r.TileLayer=yn,r.Tooltip=Ci,r.Transformation=Ve,r.Util=ve,r.VideoOverlay=js,r.bind=l,r.bounds=We,r.canvas=qs,r.circle=Vs,r.circleMarker=zo,r.control=jn,r.divIcon=Go,r.extend=o,r.featureGroup=Vo,r.geoJSON=Ws,r.geoJson=Wo,r.gridLayer=qo,r.icon=Ho,r.imageOverlay=jo,r.latLng=Be,r.latLngBounds=Ue,r.layerGroup=Uo,r.map=Es,r.marker=Us,r.point=Ae,r.polygon=xi,r.polyline=Hs,r.popup=Yo,r.rectangle=Qo,r.setOptions=T,r.stamp=u,r.svg=Zs,r.svgOverlay=ss,r.tileLayer=os,r.tooltip=Ks,r.transformation=oe,r.version=n,r.videoOverlay=Ko;var _n=window.L;r.noConflict=function(){return window.L=_n,this},window.L=r})})(leafletSrc,leafletSrc.exports);const L$2=leafletSrc.exports;(function(e){typeof e>"u"&&(e={getCenter:L.Map.prototype.getCenter,setView:L.Map.prototype.setView,flyTo:L.Map.prototype.flyTo,setZoomAround:L.Map.prototype.setZoomAround,getBoundsZoom:L.Map.prototype.getBoundsZoom,PopupAdjustPan:L.Popup.prototype._adjustPan,RendererUpdate:L.Renderer.prototype._update}),L.Map.include({getBounds:function(){if(this._viewport)return this.getViewportLatLngBounds();var t=this.getPixelBounds(),r=this.unproject(t.getBottomLeft()),n=this.unproject(t.getTopRight());return new L.LatLngBounds(r,n)},getViewport:function(){return this._viewport},getViewportBounds:function(){var t=this._viewport,r=L.point(t.offsetLeft,t.offsetTop),n=L.point(t.clientWidth,t.clientHeight);return(n.x===0||n.y===0)&&(t=this.getContainer(),t&&(r=L.point(0,0),n=L.point(t.clientWidth,t.clientHeight))),L.bounds(r,r.add(n))},getViewportLatLngBounds:function(){var t=this.getViewportBounds();return L.latLngBounds(this.containerPointToLatLng(t.min),this.containerPointToLatLng(t.max))},getOffset:function(){var t=this.getSize().divideBy(2),r=this.getViewportBounds().getCenter();return t.subtract(r)},getCenter:function(t){var r=e.getCenter.call(this);if(this.getViewport()&&!t){var n=this.getZoom(),o=this.project(r,n);o=o.subtract(this.getOffset()),r=this.unproject(o,n)}return r},setView:function(t,r,n){if(t=L.latLng(t),r=r===void 0?this._zoom:this._limitZoom(r),this.getViewport()){var o=this.project(t,this._limitZoom(r));o=o.add(this.getOffset()),t=this.unproject(o,this._limitZoom(r))}return e.setView.call(this,t,r,n)},flyTo:function(t,r,n){if(t=L.latLng(t),r=r===void 0?u:r,this.getViewport()){var o=this.project(t,this._limitZoom(r));o=o.add(this.getOffset()),t=this.unproject(o,this._limitZoom(r))}if(n=n||{},n.animate===!1||!L.Browser.any3d)return this.setView(t,r,n);this._stop();var a=this.project(e.getCenter.call(this)),l=this.project(t),c=this.getSize(),u=this._zoom,g=Math.max(c.x,c.y),b=g*this.getZoomScale(u,r),x=l.distanceTo(a)||1,S=1.42,$=S*S;function k(we){var he=we?-1:1,_e=we?b:g,ve=b*b-g*g+he*$*$*x*x,ae=2*_e*$*x,ie=ve/ae,pe=Math.sqrt(ie*ie+1)-ie,ue=pe<1e-9?-18:Math.log(pe);return ue}function T(we){return(Math.exp(we)-Math.exp(-we))/2}function D(we){return(Math.exp(we)+Math.exp(-we))/2}function I(we){return T(we)/D(we)}var O=k(0);function N(we){return g*(D(O)/D(O+S*we))}function ee(we){return g*(D(O)*I(O+S*we)-T(O))/$}function ne(we){return 1-Math.pow(1-we,1.5)}var B=Date.now(),le=(k(1)-O)/S,fe=n.duration?1e3*n.duration:1e3*le*.8;function xe(){var we=(Date.now()-B)/fe,he=ne(we)*le;we<=1?(this._flyToFrame=L.Util.requestAnimFrame(xe,this),this._move(this.unproject(a.add(l.subtract(a).multiplyBy(ee(he)/x)),u),this.getScaleZoom(g/N(he),u),{flyTo:!0})):this._move(t,r)._moveEnd(!0)}return this._moveStart(!0,n.noMoveStart),xe.call(this),this},setZoomAround:function(t,r,n){var o=this.getViewport();if(o){var a=this.getZoomScale(r),l=this.getViewportBounds().getCenter(),c=t instanceof L.Point?t:this.latLngToContainerPoint(t),u=c.subtract(l).multiplyBy(1-1/a),g=this.containerPointToLatLng(l.add(u));return this.setView(g,r,{zoom:n})}else return e.setZoomAround.call(this,t,r,n)},getBoundsZoom:function(t,r,n){t=L.latLngBounds(t),n=L.point(n||[0,0]);var o=this.getZoom()||0,a=this.getMinZoom(),l=this.getMaxZoom(),c=t.getNorthWest(),u=t.getSouthEast(),g=this.getViewport(),b=(g?L.point(g.clientWidth,g.clientHeight):this.getSize()).subtract(n),x=this.project(u,o).subtract(this.project(c,o)),S=L.Browser.any3d?this.options.zoomSnap:1,$=b.x/x.x,k=b.y/x.y,T=r?Math.max($,k):Math.min($,k);return o=this.getScaleZoom(T,o),S&&(o=Math.round(o/(S/100))*(S/100),o=r?Math.ceil(o/S)*S:Math.floor(o/S)*S),Math.max(a,Math.min(l,o))},setActiveArea:function(t,r,n){var o;if(r&&this._zoom&&(o=this.getCenter()),!this._viewport){var a=this.getContainer();this._viewport=L.DomUtil.create("div",""),a.insertBefore(this._viewport,a.firstChild)}return typeof t=="string"?this._viewport.className=t:L.extend(this._viewport.style,t),o&&this.setView(o,this.getZoom(),{animate:!!n}),this}}),L.Renderer.include({_onZoom:function(){this._updateTransform(this._map.getCenter(!0),this._map.getZoom())},_update:function(){e.RendererUpdate.call(this),this._center=this._map.getCenter(!0)}}),L.GridLayer.include({_updateLevels:function(){var t=this._tileZoom,r=this.options.maxZoom;if(t!==void 0){for(var n in this._levels)n=Number(n),this._levels[n].el.children.length||n===t?(this._levels[n].el.style.zIndex=r-Math.abs(t-n),this._onUpdateLevel(n)):(L.DomUtil.remove(this._levels[n].el),this._removeTilesAtZoom(n),this._onRemoveLevel(n),delete this._levels[n]);var o=this._levels[t],a=this._map;return o||(o=this._levels[t]={},o.el=L.DomUtil.create("div","leaflet-tile-container leaflet-zoom-animated",this._container),o.el.style.zIndex=r,o.origin=a.project(a.unproject(a.getPixelOrigin()),t).round(),o.zoom=t,this._setZoomTransform(o,a.getCenter(!0),a.getZoom()),L.Util.falseFn(o.el.offsetWidth),this._onCreateLevel(o)),this._level=o,o}},_resetView:function(t){var r=t&&(t.pinch||t.flyTo);this._setView(this._map.getCenter(!0),this._map.getZoom(),r,r)},_update:function(t){var r=this._map;if(!!r){var n=this._clampZoom(r.getZoom());if(t===void 0&&(t=r.getCenter(!0)),this._tileZoom!==void 0){var o=this._getTiledPixelBounds(t),a=this._pxBoundsToTileRange(o),l=a.getCenter(),c=[],u=this.options.keepBuffer,g=new L.Bounds(a.getBottomLeft().subtract([u,-u]),a.getTopRight().add([u,-u]));if(!(isFinite(a.min.x)&&isFinite(a.min.y)&&isFinite(a.max.x)&&isFinite(a.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var b in this._tiles){var x=this._tiles[b].coords;(x.z!==this._tileZoom||!g.contains(new L.Point(x.x,x.y)))&&(this._tiles[b].current=!1)}if(Math.abs(n-this._tileZoom)>1){this._setView(t,n);return}for(var S=a.min.y;S<=a.max.y;S++)for(var $=a.min.x;$<=a.max.x;$++){var k=new L.Point($,S);if(k.z=this._tileZoom,!!this._isValidTile(k)){var T=this._tiles[this._tileCoordsToKey(k)];T?T.current=!0:c.push(k)}}if(c.sort(function(I,O){return I.distanceTo(l)-O.distanceTo(l)}),c.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var D=document.createDocumentFragment();for($=0;$x.x&&(S=c.x+o-x.x+b.x),c.x-S-g.x<0&&(S=c.x-g.x),c.y+n+b.y>x.y&&($=c.y+n-x.y+b.y),c.y-$-g.y<0&&($=c.y-g.y),(S||$)&&t.fire("autopanstart").panBy([S,$])}}})})(window.leafletActiveAreaPreviousMethods);L.TileLayer.ColorFilter=L.TileLayer.extend({intialize:function(e,t){L.TileLayer.prototype.initialize.call(this,e,t)},colorFilter:function(){var e=["blur:px","brightness:%","bright:brightness:%","bri:brightness:%","contrast:%","con:contrast:%","grayscale:%","gray:grayscale:%","hue-rotate:deg","hue:hue-rotate:deg","hue-rotation:hue-rotate:deg","invert:%","inv:invert:%","opacity:%","op:opacity:%","saturate:%","saturation:saturate:%","sat:saturate:%","sepia:%","sep:sepia:%"];return(this.options.filter?this.options.filter:[]).map(function(t){var r=t.toLowerCase().split(":");if(r.length===2){var n=e.find(function(o){return o.split(":")[0]===r[0]});if(n)return n=n.split(":"),r[1]+=/^\d+$/.test(r[1])?n[n.length-1]:"","".concat(n[n.length-2],"(").concat(r[1],")")}return""}).join(" ")},_initContainer:function(){L.TileLayer.prototype._initContainer.call(this),this._container.style.filter=this.colorFilter()},updateFilter:function(e){this.options.filter=e,this._container&&(this._container.style.filter=this.colorFilter())}}),L.tileLayer.colorFilter=function(e,t){return new L.TileLayer.ColorFilter(e,t)};const leaflet="";let map$3,usermarker;const attrs$1={attribution:'© OpenStreetMap contributors'},layerMapLight=L$2.tileLayer.colorFilter("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{...attrs$1,filter:["grayscale:50%","saturate:70%"]}),layerMapDark=L$2.tileLayer.colorFilter("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{...attrs$1,filter:["invert:100%","grayscale:100%","bright:100%","saturate:0%","sepia:10%"]});function instanceMap(){if(map$3)return map$3;throw new Error("Must be initialized before using the mapd.")}function removeMap(){map$3.remove(),map$3=void 0}function init$3(e,t,r="light"){return map$3=L$2.map("map",{minZoom:3}),setTheme(r),map$3.attributionControl.setPrefix(""),map$3.setView(e,t),map$3.zoomControl.remove(),map$3}function setTheme(e){const t=instanceMap();e==="light"?(t.removeLayer(layerMapDark),t.addLayer(layerMapLight)):(t.removeLayer(layerMapLight),t.addLayer(layerMapDark))}function setview(e,t){const r=instanceMap();r&&r.setView(e,t)}function drawuser(e,t){const r=instanceMap();let n=100;r&&(usermarker&&r.removeLayer(usermarker),t>0&&(n=10*t),t>4&&(n=5*t),t>7&&(n=2*t),usermarker=new L$2.circleMarker(e,{radius:n,opacity:.2}),usermarker.addTo(r))}const scriptRel="modulepreload",assetsURL=function(e,t){return new URL(e,t).href},seen={},__vitePreload=function(t,r,n){if(!r||r.length===0)return t();const o=document.getElementsByTagName("link");return Promise.all(r.map(a=>{if(a=assetsURL(a,n),a in seen)return;seen[a]=!0;const l=a.endsWith(".css"),c=l?'[rel="stylesheet"]':"";if(!!n)for(let b=o.length-1;b>=0;b--){const x=o[b];if(x.href===a&&(!l||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${a}"]${c}`))return;const g=document.createElement("link");if(g.rel=l?"stylesheet":scriptRel,l||(g.as="script",g.crossOrigin=""),g.href=a,document.head.appendChild(g),l)return new Promise((b,x)=>{g.addEventListener("load",b),g.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${a}`)))})})).then(()=>t())},__variableDynamicImportRuntimeHelper=(e,t)=>{const r=e[t];return r?typeof r=="function"?r():Promise.resolve(r):new Promise((n,o)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(o.bind(null,new Error("Unknown variable dynamic import: "+t)))})};function Queue(e){Object.defineProperties(this,{add:{enumerable:!0,writable:!1,value:l},next:{enumerable:!0,writable:!1,value:c},clear:{enumerable:!0,writable:!1,value:n},contents:{enumerable:!1,get:o,set:a},autoRun:{enumerable:!0,writable:!0,value:!0},stop:{enumerable:!0,writable:!0,value:!1}});var t=[],r=!1;function n(){return t=[],t}function o(){return t}function a(u){return t=u,t}function l(){for(var u in arguments)t.push(arguments[u]);!r&&!this.stop&&this.autoRun&&this.next()}function c(){if(r=!0,t.length<1||this.stop){r=!1;return}t.shift().bind(this)()}}var queue$1=Queue,leaflet_geometryutil={exports:{}};(function(e){(function(t){var r;r=leafletSrc.exports,e.exports=t(r)})(function(t){return t.Polyline._flat=t.LineUtil.isFlat||t.Polyline._flat||function(r){return!t.Util.isArray(r[0])||typeof r[0][0]!="object"&&typeof r[0][0]<"u"},t.GeometryUtil=t.extend(t.GeometryUtil||{},{distance:function(r,n,o){return r.latLngToLayerPoint(n).distanceTo(r.latLngToLayerPoint(o))},distanceSegment:function(r,n,o,a){var l=r.latLngToLayerPoint(n),c=r.latLngToLayerPoint(o),u=r.latLngToLayerPoint(a);return t.LineUtil.pointToSegmentDistance(l,c,u)},readableDistance:function(r,n){var o=n!=="imperial",a;return o?r>1e3?a=(r/1e3).toFixed(2)+" km":a=r.toFixed(1)+" m":(r*=1.09361,r>1760?a=(r/1760).toFixed(2)+" miles":a=r.toFixed(1)+" yd"),a},belongsSegment:function(r,n,o,a){a=a===void 0?.2:a;var l=n.distanceTo(o),c=n.distanceTo(r)+r.distanceTo(o)-l;return c/l0?n[n.length-1]:0},accumulatedLengths:function(r){if(typeof r.getLatLngs=="function"&&(r=r.getLatLngs()),r.length===0)return[];for(var n=0,o=[0],a=0,l=r.length-1;aa?l.slice(0,a):l},layersWithin:function(r,n,o,a){a=typeof a=="number"?a:1/0;for(var l=[],c=null,u=0,g=0,b=n.length;ga)return null;if(l&&typeof c.layer.getLatLngs=="function"){var u=t.GeometryUtil.closest(r,c.layer,c.latlng,!0);u.distance0&&(u+=c[g-1].distanceTo(c[g]));for(var b=u*o,x=0,S=0,g=0;Sa)return t.GeometryUtil.extract(r,t.GeometryUtil.reverse(n),1-o,1-a);o=Math.max(Math.min(o,1),0),a=Math.max(Math.min(a,1),0);var l=n.getLatLngs(),c=t.GeometryUtil.interpolateOnLine(r,n,o),u=t.GeometryUtil.interpolateOnLine(r,n,a);if(o==a){var g=t.GeometryUtil.interpolateOnLine(r,n,a);return[g.latLng]}c.predecessor==-1&&(c.predecessor=0),u.predecessor==-1&&(u.predecessor=0);var b=l.slice(c.predecessor+1,u.predecessor+1);return b.unshift(c.latLng),b.push(u.latLng),b},isBefore:function(r,n){if(!n)return!1;var o=r.getLatLngs(),a=n.getLatLngs();return o[o.length-1].equals(a[0])},isAfter:function(r,n){if(!n)return!1;var o=r.getLatLngs(),a=n.getLatLngs();return o[0].equals(a[a.length-1])},startsAtExtremity:function(r,n){if(!n)return!1;var o=r.getLatLngs(),a=n.getLatLngs(),l=o[0];return l.equals(a[0])||l.equals(a[a.length-1])},computeAngle:function(r,n){return Math.atan2(n.y-r.y,n.x-r.x)*180/Math.PI},computeSlope:function(r,n){var o=(n.y-r.y)/(n.x-r.x),a=r.y-o*r.x;return{a:o,b:a}},rotatePoint:function(r,n,o,a){var l=r.getMaxZoom();l===1/0&&(l=r.getZoom());var c=o*Math.PI/180,u=r.project(n,l),g=r.project(a,l),b=Math.cos(c)*(u.x-g.x)-Math.sin(c)*(u.y-g.y)+g.x,x=Math.sin(c)*(u.x-g.x)+Math.cos(c)*(u.y-g.y)+g.y;return r.unproject(new t.Point(b,x),l)},bearing:function(r,n){var o=Math.PI/180,a=r.lat*o,l=n.lat*o,c=r.lng*o,u=n.lng*o,g=Math.sin(u-c)*Math.cos(l),b=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(u-c),x=(Math.atan2(g,b)*180/Math.PI+360)%360;return x>=180?x-360:x},destination:function(r,n,o){n=(n+360)%360;var a=Math.PI/180,l=180/Math.PI,c=6378137,u=r.lng*a,g=r.lat*a,b=n*a,x=Math.sin(g),S=Math.cos(g),$=Math.cos(o/c),k=Math.sin(o/c),T=Math.asin(x*$+S*k*Math.cos(b)),D=u+Math.atan2(Math.sin(b)*k*S,$-x*Math.sin(T));return D=D*l,D=D>180?D-360:D<-180?D+360:D,t.latLng([T*l,D])},angle:function(r,n,o){var a=r.latLngToContainerPoint(n),l=r.latLngToContainerPoint(o),c=Math.atan2(l.y-a.y,l.x-a.x)*180/Math.PI+90;return c+=c<0?360:0,c},destinationOnSegment:function(r,n,o,a){var l=t.GeometryUtil.angle(r,n,o),c=t.GeometryUtil.destination(n,l,a);return t.GeometryUtil.closestOnSegment(r,c,n,o)}}),t.GeometryUtil})})(leaflet_geometryutil);function modulus(e,t){return(e%t+t)%t}function definedProps(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0))}function isInMeters(e){return e.toString().trim().slice(e.toString().length-1,e.toString().length)==="m"}function isInPercent(e){return e.toString().trim().slice(e.toString().length-1,e.toString().length)==="%"}function isInPixels(e){return e.toString().trim().slice(e.toString().length-2,e.toString().length)==="px"}function pixelsToMeters(e,t){let r=t.getCenter(),n=t.latLngToLayerPoint(r),o={x:n.x+Number(e),y:n.y},a=t.layerPointToLatLng(o);return t.distance(r,a)}L.Polyline.include({arrowheads:function(e={}){const t={yawn:60,size:"15%",frequency:"allvertices",proportionalToTotal:!1};this.options.noClip=!0;let r=Object.assign({},t,e);return this._arrowheadOptions=r,this._hatsApplied=!0,this},buildVectorHats:function(e){this._arrowheads&&this._arrowheads.remove(),this._ghosts&&this._ghosts.remove();let t=Object.getPrototypeOf(Object.getPrototypeOf(this.options)),r=Object.assign({},t,this.options),n=Object.assign({},r,e);n.smoothFactor=1,n.fillOpacity=1,n.fill=!!e.fill,n.interactive=!1;let o=e.size.toString(),a=[];const{frequency:l,offsets:c}=e;(c?.start||c?.end)&&this._buildGhosts({start:c.start,end:c.end}),(this._ghosts||this)._parts.forEach((b,x)=>{const S=b.map(B=>this._map.layerPointToLatLng(B)),$=(()=>{let B=0;for(var le=0;le{let B=l.slice(0,l.length-2);return pixelsToMeters(B,this._map)/$})(),I=1/D,I=Math.floor(I),D=1/I):(D=1/l,I=l),e.frequency==="allvertices")T=(()=>{let B=[];for(var le=1;le=2)k=[S[S.length-1]],T=[L.GeometryUtil.angle(this._map,S[S.length-2],S[S.length-1])+180];else{k=[];let B=[];for(var O=0;O{let le=[];for(var fe=0;fe{let fe=le.yawn??e.yawn,xe=L.GeometryUtil.destination(k[O],T[O]-fe/2,B),we=L.GeometryUtil.destination(k[O],T[O]+fe/2,B),he=[[xe.lat,xe.lng],[k[O].lat,k[O].lng],[we.lat,we.lng]],_e=e.fill?L.polygon(he,{...n,...le}):L.polyline(he,{...n,...le});N.push(_e)},ne=(B,le={})=>{let fe=B.slice(0,B.length-2),xe=le.yawn??e.yawn,we=this._map.latLngToLayerPoint(k[O]),he=T[O],_e=(180-he-xe/2)*(Math.PI/180),ve=(180-he+xe/2)*(Math.PI/180),ae=fe*Math.sin(_e),ie=fe*Math.cos(_e),pe=fe*Math.sin(ve),ue=fe*Math.cos(ve),ge={x:we.x+ae,y:we.y+ie},ye={x:we.x+pe,y:we.y+ue},Ae=this._map.layerPointToLatLng(ge),Re=this._map.layerPointToLatLng(ye),We=[[Ae.lat,Ae.lng],[k[O].lat,k[O].lng],[Re.lat,Re.lng]],Pe=e.fill?L.polygon(We,{...n,...le}):L.polyline(We,{...n,...le});N.push(Pe)};for(var O=0;Oe.frequency==="endonly"&&e.proportionalToTotal?$*xe/100:$/(b.length-1)*xe/100)();ee(we,le)}else isInPixels(o)?ne(e.size,le):console.error("Error: Arrowhead size unit not defined. Check your arrowhead options.")}a.push(...N)});let g=L.layerGroup(a);return this._arrowheads=g,this},getArrowheads:function(){return this._arrowheads?this._arrowheads:console.error("Error: You tried to call '.getArrowheads() on a shape that does not have a arrowhead. Use '.arrowheads()' to add a arrowheads before trying to call '.getArrowheads()'")},_buildGhosts:function({start:e,end:t}){if(e||t){let r=this.getLatLngs();r=Array.isArray(r[0])?r:[r];const n=r.map(o=>{const a=(()=>{let l=0;for(var c=0;c{if(isInMeters(e))return Number(e.slice(0,e.length-1));if(isInPixels(e)){let u=Number(e.slice(0,e.length-2));return pixelsToMeters(u,this._map)}})(),c=L.GeometryUtil.interpolateOnLine(this._map,o,l/a);o=o.slice(c.predecessor===-1?1:c.predecessor+1,o.length),o.unshift(c.latLng)}if(t){let l=(()=>{if(isInMeters(t))return Number(t.slice(0,t.length-1));if(isInPixels(t)){let u=Number(t.slice(0,t.length-2));return pixelsToMeters(u,this._map)}})(),c=L.GeometryUtil.interpolateOnLine(this._map,o,(a-l)/a);o=o.slice(0,c.predecessor+1),o.push(c.latLng)}return o});this._ghosts=L.polyline(n,{...this.options,color:"rgba(0,0,0,0)",stroke:0,smoothFactor:0,interactive:!1}),this._ghosts.addTo(this._map)}},deleteArrowheads:function(){this._arrowheads&&(this._arrowheads.remove(),delete this._arrowheads,delete this._arrowheadOptions,this._hatsApplied=!1),this._ghosts&&this._ghosts.remove()},_update:function(){!this._map||(this._clipPoints(),this._simplifyPoints(),this._updatePath(),this._hatsApplied&&(this.buildVectorHats(this._arrowheadOptions),this._map.addLayer(this._arrowheads)))},remove:function(){return this._arrowheads&&this._arrowheads.remove(),this._ghosts&&this._ghosts.remove(),this.removeFrom(this._map||this._mapToAdd)}});L.LayerGroup.include({removeLayer:function(e){var t=e in this._layers?e:this.getLayerId(e);return this._map&&this._layers[t]&&(this._layers[t]._arrowheads&&this._layers[t]._arrowheads.remove(),this._map.removeLayer(this._layers[t])),delete this._layers[t],this},onRemove:function(e,t){for(var t in this._layers)this._layers[t]&&this._layers[t].remove();this.eachLayer(e.removeLayer,e)}});L.Map.include({removeLayer:function(e){var t=L.Util.stamp(e);return e._arrowheads&&e._arrowheads.remove(),e._ghosts&&e._ghosts.remove(),this._layers[t]?(this._loaded&&e.onRemove(this),e.getAttribution&&this.attributionControl&&this.attributionControl.removeAttribution(e.getAttribution()),delete this._layers[t],this._loaded&&(this.fire("layerremove",{layer:e}),e.fire("remove")),e._map=e._mapToAdd=null,this):this}});L.GeoJSON.include({geometryToLayer:function(e,t){var r=e.type==="Feature"?e.geometry:e,n=r?r.coordinates:null,o=[],a=t&&t.pointToLayer,l=t&&t.coordsToLatLng||L.GeoJSON.coordsToLatLng,c,u,g,b;if(!n&&!r)return null;switch(r.type){case"Point":return c=l(n),this._pointToLayer(a,e,c,t);case"MultiPoint":for(g=0,b=n.length;g=c;)l=l.__parent;return this._currentShownBounds.contains(l.getLatLng())&&(this.options.animateAddingMarkers?this._animationAddLayer(a,l):this._animationAddLayerNonAnimated(a,l)),this},removeLayer:function(a){return a instanceof L.LayerGroup?this.removeLayers([a]):a.getLatLng?this._map?a.__parent?(this._unspiderfy&&(this._unspiderfy(),this._unspiderfyLayer(a)),this._removeLayer(a,!0),this.fire("layerremove",{layer:a}),this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),a.off(this._childMarkerEventHandlers,this),this._featureGroup.hasLayer(a)&&(this._featureGroup.removeLayer(a),a.clusterShow&&a.clusterShow()),this):this:(!this._arraySplice(this._needsClustering,a)&&this.hasLayer(a)&&this._needsRemoving.push({layer:a,latlng:a._latlng}),this.fire("layerremove",{layer:a}),this):(this._nonPointGroup.removeLayer(a),this.fire("layerremove",{layer:a}),this)},addLayers:function(a,l){if(!L.Util.isArray(a))return this.addLayer(a);var c=this._featureGroup,u=this._nonPointGroup,g=this.options.chunkedLoading,b=this.options.chunkInterval,x=this.options.chunkProgress,S=a.length,$=0,k=!0,T;if(this._map){var D=new Date().getTime(),I=L.bind(function(){var N=new Date().getTime();for(this._map&&this._unspiderfy&&this._unspiderfy();$b)break}if(T=a[$],T instanceof L.LayerGroup){k&&(a=a.slice(),k=!1),this._extractNonGroupLayers(T,a),S=a.length;continue}if(!T.getLatLng){u.addLayer(T),l||this.fire("layeradd",{layer:T});continue}if(!this.hasLayer(T)&&(this._addLayer(T,this._maxZoom),l||this.fire("layeradd",{layer:T}),T.__parent&&T.__parent.getChildCount()===2)){var ne=T.__parent.getAllChildMarkers(),B=ne[0]===T?ne[1]:ne[0];c.removeLayer(B)}}x&&x($,S,new Date().getTime()-D),$===S?(this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds)):setTimeout(I,this.options.chunkDelay)},this);I()}else for(var O=this._needsClustering;$=0;l--)a.extend(this._needsClustering[l].getLatLng());return a.extend(this._nonPointGroup.getBounds()),a},eachLayer:function(a,l){var c=this._needsClustering.slice(),u=this._needsRemoving,g,b,x;for(this._topClusterLevel&&this._topClusterLevel.getAllChildMarkers(c),b=c.length-1;b>=0;b--){for(g=!0,x=u.length-1;x>=0;x--)if(u[x].layer===c[b]){g=!1;break}g&&a.call(l,c[b])}this._nonPointGroup.eachLayer(a,l)},getLayers:function(){var a=[];return this.eachLayer(function(l){a.push(l)}),a},getLayer:function(a){var l=null;return a=parseInt(a,10),this.eachLayer(function(c){L.stamp(c)===a&&(l=c)}),l},hasLayer:function(a){if(!a)return!1;var l,c=this._needsClustering;for(l=c.length-1;l>=0;l--)if(c[l]===a)return!0;for(c=this._needsRemoving,l=c.length-1;l>=0;l--)if(c[l].layer===a)return!1;return!!(a.__parent&&a.__parent._group===this)||this._nonPointGroup.hasLayer(a)},zoomToShowLayer:function(a,l){var c=this._map;typeof l!="function"&&(l=function(){});var u=function(){(c.hasLayer(a)||c.hasLayer(a.__parent))&&!this._inZoomAnimation&&(this._map.off("moveend",u,this),this.off("animationend",u,this),c.hasLayer(a)?l():a.__parent._icon&&(this.once("spiderfied",l,this),a.__parent.spiderfy()))};a._icon&&this._map.getBounds().contains(a.getLatLng())?l():a.__parent._zoom=0;c--)if(a[c]===l)return a.splice(c,1),!0},_removeFromGridUnclustered:function(a,l){for(var c=this._map,u=this._gridUnclustered,g=Math.floor(this._map.getMinZoom());l>=g&&u[l].removeObject(a,c.project(a.getLatLng(),l));l--);},_childMarkerDragStart:function(a){a.target.__dragStart=a.target._latlng},_childMarkerMoved:function(a){if(!this._ignoreMove&&!a.target.__dragStart){var l=a.target._popup&&a.target._popup.isOpen();this._moveChild(a.target,a.oldLatLng,a.latlng),l&&a.target.openPopup()}},_moveChild:function(a,l,c){a._latlng=l,this.removeLayer(a),a._latlng=c,this.addLayer(a)},_childMarkerDragEnd:function(a){var l=a.target.__dragStart;delete a.target.__dragStart,l&&this._moveChild(a.target,l,a.target._latlng)},_removeLayer:function(a,l,c){var u=this._gridClusters,g=this._gridUnclustered,b=this._featureGroup,x=this._map,S=Math.floor(this._map.getMinZoom());l&&this._removeFromGridUnclustered(a,this._maxZoom);var $=a.__parent,k=$._markers,T;for(this._arraySplice(k,a);$&&($._childCount--,$._boundsNeedUpdate=!0,!($._zoom"+l+"",className:"marker-cluster"+c,iconSize:new L.Point(40,40)})},_bindEvents:function(){var a=this._map,l=this.options.spiderfyOnMaxZoom,c=this.options.showCoverageOnHover,u=this.options.zoomToBoundsOnClick,g=this.options.spiderfyOnEveryZoom;(l||u||g)&&this.on("clusterclick clusterkeypress",this._zoomOrSpiderfy,this),c&&(this.on("clustermouseover",this._showCoverage,this),this.on("clustermouseout",this._hideCoverage,this),a.on("zoomend",this._hideCoverage,this))},_zoomOrSpiderfy:function(a){var l=a.layer,c=l;if(!(a.type==="clusterkeypress"&&a.originalEvent&&a.originalEvent.keyCode!==13)){for(;c._childClusters.length===1;)c=c._childClusters[0];c._zoom===this._maxZoom&&c._childCount===l._childCount&&this.options.spiderfyOnMaxZoom?l.spiderfy():this.options.zoomToBoundsOnClick&&l.zoomToBounds(),this.options.spiderfyOnEveryZoom&&l.spiderfy(),a.originalEvent&&a.originalEvent.keyCode===13&&this._map._container.focus()}},_showCoverage:function(a){var l=this._map;this._inZoomAnimation||(this._shownPolygon&&l.removeLayer(this._shownPolygon),a.layer.getChildCount()>2&&a.layer!==this._spiderfied&&(this._shownPolygon=new L.Polygon(a.layer.getConvexHull(),this.options.polygonOptions),l.addLayer(this._shownPolygon)))},_hideCoverage:function(){this._shownPolygon&&(this._map.removeLayer(this._shownPolygon),this._shownPolygon=null)},_unbindEvents:function(){var a=this.options.spiderfyOnMaxZoom,l=this.options.showCoverageOnHover,c=this.options.zoomToBoundsOnClick,u=this.options.spiderfyOnEveryZoom,g=this._map;(a||c||u)&&this.off("clusterclick clusterkeypress",this._zoomOrSpiderfy,this),l&&(this.off("clustermouseover",this._showCoverage,this),this.off("clustermouseout",this._hideCoverage,this),g.off("zoomend",this._hideCoverage,this))},_zoomEnd:function(){!this._map||(this._mergeSplitClusters(),this._zoom=Math.round(this._map._zoom),this._currentShownBounds=this._getExpandedVisibleBounds())},_moveEnd:function(){if(!this._inZoomAnimation){var a=this._getExpandedVisibleBounds();this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),this._zoom,a),this._topClusterLevel._recursivelyAddChildrenToMap(null,Math.round(this._map._zoom),a),this._currentShownBounds=a}},_generateInitialClusters:function(){var a=Math.ceil(this._map.getMaxZoom()),l=Math.floor(this._map.getMinZoom()),c=this.options.maxClusterRadius,u=c;typeof c!="function"&&(u=function(){return c}),this.options.disableClusteringAtZoom!==null&&(a=this.options.disableClusteringAtZoom-1),this._maxZoom=a,this._gridClusters={},this._gridUnclustered={};for(var g=a;g>=l;g--)this._gridClusters[g]=new L.DistanceGrid(u(g)),this._gridUnclustered[g]=new L.DistanceGrid(u(g));this._topClusterLevel=new this._markerCluster(this,l-1)},_addLayer:function(a,l){var c=this._gridClusters,u=this._gridUnclustered,g=Math.floor(this._map.getMinZoom()),b,x;for(this.options.singleMarkerMode&&this._overrideMarkerIcon(a),a.on(this._childMarkerEventHandlers,this);l>=g;l--){b=this._map.project(a.getLatLng(),l);var S=c[l].getNearObject(b);if(S){S._addChild(a),a.__parent=S;return}if(S=u[l].getNearObject(b),S){var $=S.__parent;$&&this._removeLayer(S,!1);var k=new this._markerCluster(this,l,S,a);c[l].addObject(k,this._map.project(k._cLatLng,l)),S.__parent=k,a.__parent=k;var T=k;for(x=l-1;x>$._zoom;x--)T=new this._markerCluster(this,x,T),c[x].addObject(T,this._map.project(S.getLatLng(),x));$._addChild(T),this._removeFromGridUnclustered(S,l);return}u[l].addObject(a,b)}this._topClusterLevel._addChild(a),a.__parent=this._topClusterLevel},_refreshClustersIcons:function(){this._featureGroup.eachLayer(function(a){a instanceof L.MarkerCluster&&a._iconNeedsUpdate&&a._updateIcon()})},_enqueue:function(a){this._queue.push(a),this._queueTimeout||(this._queueTimeout=setTimeout(L.bind(this._processQueue,this),300))},_processQueue:function(){for(var a=0;aa?(this._animationStart(),this._animationZoomOut(this._zoom,a)):this._moveEnd()},_getExpandedVisibleBounds:function(){if(this.options.removeOutsideVisibleBounds){if(L.Browser.mobile)return this._checkBoundsMaxLat(this._map.getBounds())}else return this._mapBoundsInfinite;return this._checkBoundsMaxLat(this._map.getBounds().pad(1))},_checkBoundsMaxLat:function(a){var l=this._maxLat;return l!==void 0&&(a.getNorth()>=l&&(a._northEast.lat=1/0),a.getSouth()<=-l&&(a._southWest.lat=-1/0)),a},_animationAddLayerNonAnimated:function(a,l){if(l===a)this._featureGroup.addLayer(a);else if(l._childCount===2){l._addToMap();var c=l.getAllChildMarkers();this._featureGroup.removeLayer(c[0]),this._featureGroup.removeLayer(c[1])}else l._updateIcon()},_extractNonGroupLayers:function(a,l){var c=a.getLayers(),u=0,g;for(l=l||[];u=0;b--)k=$[b],c.contains(k._latlng)||u.removeLayer(k)}),this._forceLayout(),this._topClusterLevel._recursivelyBecomeVisible(c,l),u.eachLayer(function(x){!(x instanceof L.MarkerCluster)&&x._icon&&x.clusterShow()}),this._topClusterLevel._recursively(c,a,l,function(x){x._recursivelyRestoreChildPositions(l)}),this._ignoreMove=!1,this._enqueue(function(){this._topClusterLevel._recursively(c,a,g,function(x){u.removeLayer(x),x.clusterShow()}),this._animationEnd()})},_animationZoomOut:function(a,l){this._animationZoomOutSingle(this._topClusterLevel,a-1,l),this._topClusterLevel._recursivelyAddChildrenToMap(null,l,this._getExpandedVisibleBounds()),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),a,this._getExpandedVisibleBounds())},_animationAddLayer:function(a,l){var c=this,u=this._featureGroup;u.addLayer(a),l!==a&&(l._childCount>2?(l._updateIcon(),this._forceLayout(),this._animationStart(),a._setPos(this._map.latLngToLayerPoint(l.getLatLng())),a.clusterHide(),this._enqueue(function(){u.removeLayer(a),a.clusterShow(),c._animationEnd()})):(this._forceLayout(),c._animationStart(),c._animationZoomOutSingle(l,this._map.getMaxZoom(),this._zoom)))}},_animationZoomOutSingle:function(a,l,c){var u=this._getExpandedVisibleBounds(),g=Math.floor(this._map.getMinZoom());a._recursivelyAnimateChildrenInAndAddSelfToMap(u,g,l+1,c);var b=this;this._forceLayout(),a._recursivelyBecomeVisible(u,c),this._enqueue(function(){if(a._childCount===1){var x=a._markers[0];this._ignoreMove=!0,x.setLatLng(x.getLatLng()),this._ignoreMove=!1,x.clusterShow&&x.clusterShow()}else a._recursively(u,c,g,function(S){S._recursivelyRemoveChildrenFromMap(u,g,l+1)});b._animationEnd()})},_animationEnd:function(){this._map&&(this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim","")),this._inZoomAnimation--,this.fire("animationend")},_forceLayout:function(){L.Util.falseFn(document.body.offsetWidth)}}),L.markerClusterGroup=function(a){return new L.MarkerClusterGroup(a)};var o=L.MarkerCluster=L.Marker.extend({options:L.Icon.prototype.options,initialize:function(a,l,c,u){L.Marker.prototype.initialize.call(this,c?c._cLatLng||c.getLatLng():new L.LatLng(0,0),{icon:this,pane:a.options.clusterPane}),this._group=a,this._zoom=l,this._markers=[],this._childClusters=[],this._childCount=0,this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._bounds=new L.LatLngBounds,c&&this._addChild(c),u&&this._addChild(u)},getAllChildMarkers:function(a,l){a=a||[];for(var c=this._childClusters.length-1;c>=0;c--)this._childClusters[c].getAllChildMarkers(a,l);for(var u=this._markers.length-1;u>=0;u--)l&&this._markers[u].__dragStart||a.push(this._markers[u]);return a},getChildCount:function(){return this._childCount},zoomToBounds:function(a){for(var l=this._childClusters.slice(),c=this._group._map,u=c.getBoundsZoom(this._bounds),g=this._zoom+1,b=c.getZoom(),x;l.length>0&&u>g;){g++;var S=[];for(x=0;xg?this._group._map.setView(this._latlng,g):u<=b?this._group._map.setView(this._latlng,b+1):this._group._map.fitBounds(this._bounds,a)},getBounds:function(){var a=new L.LatLngBounds;return a.extend(this._bounds),a},_updateIcon:function(){this._iconNeedsUpdate=!0,this._icon&&this.setIcon(this)},createIcon:function(){return this._iconNeedsUpdate&&(this._iconObj=this._group.options.iconCreateFunction(this),this._iconNeedsUpdate=!1),this._iconObj.createIcon()},createShadow:function(){return this._iconObj.createShadow()},_addChild:function(a,l){this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._setClusterCenter(a),a instanceof L.MarkerCluster?(l||(this._childClusters.push(a),a.__parent=this),this._childCount+=a._childCount):(l||this._markers.push(a),this._childCount++),this.__parent&&this.__parent._addChild(a,!0)},_setClusterCenter:function(a){this._cLatLng||(this._cLatLng=a._cLatLng||a._latlng)},_resetBounds:function(){var a=this._bounds;a._southWest&&(a._southWest.lat=1/0,a._southWest.lng=1/0),a._northEast&&(a._northEast.lat=-1/0,a._northEast.lng=-1/0)},_recalculateBounds:function(){var a=this._markers,l=this._childClusters,c=0,u=0,g=this._childCount,b,x,S,$;if(g!==0){for(this._resetBounds(),b=0;b=0;b--)x=g[b],x._icon&&(x._setPos(l),x.clusterHide())},function(u){var g=u._childClusters,b,x;for(b=g.length-1;b>=0;b--)x=g[b],x._icon&&(x._setPos(l),x.clusterHide())})},_recursivelyAnimateChildrenInAndAddSelfToMap:function(a,l,c,u){this._recursively(a,u,l,function(g){g._recursivelyAnimateChildrenIn(a,g._group._map.latLngToLayerPoint(g.getLatLng()).round(),c),g._isSingleParent()&&c-1===u?(g.clusterShow(),g._recursivelyRemoveChildrenFromMap(a,l,c)):g.clusterHide(),g._addToMap()})},_recursivelyBecomeVisible:function(a,l){this._recursively(a,this._group._map.getMinZoom(),l,null,function(c){c.clusterShow()})},_recursivelyAddChildrenToMap:function(a,l,c){this._recursively(c,this._group._map.getMinZoom()-1,l,function(u){if(l!==u._zoom)for(var g=u._markers.length-1;g>=0;g--){var b=u._markers[g];!c.contains(b._latlng)||(a&&(b._backupLatlng=b.getLatLng(),b.setLatLng(a),b.clusterHide&&b.clusterHide()),u._group._featureGroup.addLayer(b))}},function(u){u._addToMap(a)})},_recursivelyRestoreChildPositions:function(a){for(var l=this._markers.length-1;l>=0;l--){var c=this._markers[l];c._backupLatlng&&(c.setLatLng(c._backupLatlng),delete c._backupLatlng)}if(a-1===this._zoom)for(var u=this._childClusters.length-1;u>=0;u--)this._childClusters[u]._restorePosition();else for(var g=this._childClusters.length-1;g>=0;g--)this._childClusters[g]._recursivelyRestoreChildPositions(a)},_restorePosition:function(){this._backupLatlng&&(this.setLatLng(this._backupLatlng),delete this._backupLatlng)},_recursivelyRemoveChildrenFromMap:function(a,l,c,u){var g,b;this._recursively(a,l-1,c-1,function(x){for(b=x._markers.length-1;b>=0;b--)g=x._markers[b],(!u||!u.contains(g._latlng))&&(x._group._featureGroup.removeLayer(g),g.clusterShow&&g.clusterShow())},function(x){for(b=x._childClusters.length-1;b>=0;b--)g=x._childClusters[b],(!u||!u.contains(g._latlng))&&(x._group._featureGroup.removeLayer(g),g.clusterShow&&g.clusterShow())})},_recursively:function(a,l,c,u,g){var b=this._childClusters,x=this._zoom,S,$;if(l<=x&&(u&&u(this),g&&x===c&&g(this)),x=0;S--)$=b[S],$._boundsNeedUpdate&&$._recalculateBounds(),a.intersects($._bounds)&&$._recursively(a,l,c,u,g)},_isSingleParent:function(){return this._childClusters.length>0&&this._childClusters[0]._childCount===this._childCount}});L.Marker.include({clusterHide:function(){var a=this.options.opacity;return this.setOpacity(0),this.options.opacity=a,this},clusterShow:function(){return this.setOpacity(this.options.opacity)}}),L.DistanceGrid=function(a){this._cellSize=a,this._sqCellSize=a*a,this._grid={},this._objectPoint={}},L.DistanceGrid.prototype={addObject:function(a,l){var c=this._getCoord(l.x),u=this._getCoord(l.y),g=this._grid,b=g[u]=g[u]||{},x=b[c]=b[c]||[],S=L.Util.stamp(a);this._objectPoint[S]=l,x.push(a)},updateObject:function(a,l){this.removeObject(a),this.addObject(a,l)},removeObject:function(a,l){var c=this._getCoord(l.x),u=this._getCoord(l.y),g=this._grid,b=g[u]=g[u]||{},x=b[c]=b[c]||[],S,$;for(delete this._objectPoint[L.Util.stamp(a)],S=0,$=x.length;S<$;S++)if(x[S]===a)return x.splice(S,1),$===1&&delete b[c],!0},eachObject:function(a,l){var c,u,g,b,x,S,$,k=this._grid;for(c in k){x=k[c];for(u in x)for(S=x[u],g=0,b=S.length;g=0;b--){if(x=l[b],S=this.getDistant(x,a),S>0)g.push(x);else continue;S>c&&(c=S,u=x)}return{maxPoint:u,newPoints:g}},buildConvexHull:function(a,l){var c=[],u=this.findMostDistantPointFromBaseLine(a,l);return u.maxPoint?(c=c.concat(this.buildConvexHull([a[0],u.maxPoint],u.newPoints)),c=c.concat(this.buildConvexHull([u.maxPoint,a[1]],u.newPoints)),c):[a[0]]},getConvexHull:function(a){var l=!1,c=!1,u=!1,g=!1,b=null,x=null,S=null,$=null,k=null,T=null,D;for(D=a.length-1;D>=0;D--){var I=a[D];(l===!1||I.lat>l)&&(b=I,l=I.lat),(c===!1||I.latu)&&(S=I,u=I.lng),(g===!1||I.lng=0;u--)c=a[u].getLatLng(),l.push(c);return L.QuickHull.getConvexHull(l)}}),L.MarkerCluster.include({_2PI:Math.PI*2,_circleFootSeparation:25,_circleStartAngle:0,_spiralFootSeparation:28,_spiralLengthStart:11,_spiralLengthFactor:5,_circleSpiralSwitchover:9,spiderfy:function(){if(!(this._group._spiderfied===this||this._group._inZoomAnimation)){var a=this.getAllChildMarkers(null,!0),l=this._group,c=l._map,u=c.latLngToLayerPoint(this._latlng),g;this._group._unspiderfy(),this._group._spiderfied=this,this._group.options.spiderfyShapePositions?g=this._group.options.spiderfyShapePositions(a.length,u):a.length>=this._circleSpiralSwitchover?g=this._generatePointsSpiral(a.length,u):(u.y+=10,g=this._generatePointsCircle(a.length,u)),this._animationSpiderfy(a,g)}},unspiderfy:function(a){this._group._inZoomAnimation||(this._animationUnspiderfy(a),this._group._spiderfied=null)},_generatePointsCircle:function(a,l){var c=this._group.options.spiderfyDistanceMultiplier*this._circleFootSeparation*(2+a),u=c/this._2PI,g=this._2PI/a,b=[],x,S;for(u=Math.max(u,35),b.length=a,x=0;x=0;$--)$=0;b--)g=u[b],c.removeLayer(g),g._preSpiderfyLatlng&&(g.setLatLng(g._preSpiderfyLatlng),delete g._preSpiderfyLatlng),g.setZIndexOffset&&g.setZIndexOffset(0),g._spiderLeg&&(l.removeLayer(g._spiderLeg),delete g._spiderLeg);a.fire("unspiderfied",{cluster:this,markers:u}),a._ignoreMove=!1,a._spiderfied=null}}),L.MarkerClusterNonAnimated=L.MarkerCluster.extend({_animationSpiderfy:function(a,l){var c=this._group,u=c._map,g=c._featureGroup,b=this._group.options.spiderLegPolylineOptions,x,S,$,k;for(c._ignoreMove=!0,x=0;x=0;D--)ne=g.layerPointToLatLng(l[D]),I=a[D],I._preSpiderfyLatlng=I._latlng,I.setLatLng(ne),I.clusterShow&&I.clusterShow(),$&&(O=I._spiderLeg,N=O._path,N.style.strokeDashoffset=0,O.setStyle({opacity:T}));this.setOpacity(.3),u._ignoreMove=!1,setTimeout(function(){u._animationEnd(),u.fire("spiderfied",{cluster:c,markers:a})},200)},_animationUnspiderfy:function(a){var l=this,c=this._group,u=c._map,g=c._featureGroup,b=a?u._latLngToNewLayerPoint(this._latlng,a.zoom,a.center):u.latLngToLayerPoint(this._latlng),x=this.getAllChildMarkers(null,!0),S=L.Path.SVG,$,k,T,D,I,O;for(c._ignoreMove=!0,c._animationStart(),this.setOpacity(1),k=x.length-1;k>=0;k--)$=x[k],$._preSpiderfyLatlng&&($.closePopup(),$.setLatLng($._preSpiderfyLatlng),delete $._preSpiderfyLatlng,O=!0,$._setPos&&($._setPos(b),O=!1),$.clusterHide&&($.clusterHide(),O=!1),O&&g.removeLayer($),S&&(T=$._spiderLeg,D=T._path,I=D.getTotalLength()+.1,D.style.strokeDashoffset=I,T.setStyle({opacity:0})));c._ignoreMove=!1,setTimeout(function(){var N=0;for(k=x.length-1;k>=0;k--)$=x[k],$._spiderLeg&&N++;for(k=x.length-1;k>=0;k--)$=x[k],$._spiderLeg&&($.clusterShow&&$.clusterShow(),$.setZIndexOffset&&$.setZIndexOffset(0),N>1&&g.removeLayer($),u.removeLayer($._spiderLeg),delete $._spiderLeg);c._animationEnd(),c.fire("unspiderfied",{cluster:l,markers:x})},200)}}),L.MarkerClusterGroup.include({_spiderfied:null,unspiderfy:function(){this._unspiderfy.apply(this,arguments)},_spiderfierOnAdd:function(){this._map.on("click",this._unspiderfyWrapper,this),this._map.options.zoomAnimation&&this._map.on("zoomstart",this._unspiderfyZoomStart,this),this._map.on("zoomend",this._noanimationUnspiderfy,this),L.Browser.touch||this._map.getRenderer(this)},_spiderfierOnRemove:function(){this._map.off("click",this._unspiderfyWrapper,this),this._map.off("zoomstart",this._unspiderfyZoomStart,this),this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._map.off("zoomend",this._noanimationUnspiderfy,this),this._noanimationUnspiderfy()},_unspiderfyZoomStart:function(){!this._map||this._map.on("zoomanim",this._unspiderfyZoomAnim,this)},_unspiderfyZoomAnim:function(a){L.DomUtil.hasClass(this._map._mapPane,"leaflet-touching")||(this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._unspiderfy(a))},_unspiderfyWrapper:function(){this._unspiderfy()},_unspiderfy:function(a){this._spiderfied&&this._spiderfied.unspiderfy(a)},_noanimationUnspiderfy:function(){this._spiderfied&&this._spiderfied._noanimationUnspiderfy()},_unspiderfyLayer:function(a){a._spiderLeg&&(this._featureGroup.removeLayer(a),a.clusterShow&&a.clusterShow(),a.setZIndexOffset&&a.setZIndexOffset(0),this._map.removeLayer(a._spiderLeg),delete a._spiderLeg)}}),L.MarkerClusterGroup.include({refreshClusters:function(a){return a?a instanceof L.MarkerClusterGroup?a=a._topClusterLevel.getAllChildMarkers():a instanceof L.LayerGroup?a=a._layers:a instanceof L.MarkerCluster?a=a.getAllChildMarkers():a instanceof L.Marker&&(a=[a]):a=this._topClusterLevel.getAllChildMarkers(),this._flagParentsIconsNeedUpdate(a),this._refreshClustersIcons(),this.options.singleMarkerMode&&this._refreshSingleMarkerModeMarkers(a),this},_flagParentsIconsNeedUpdate:function(a){var l,c;for(l in a)for(c=a[l].__parent;c;)c._iconNeedsUpdate=!0,c=c.__parent},_refreshSingleMarkerModeMarkers:function(a){var l,c;for(l in a)c=a[l],this.hasLayer(c)&&c.setIcon(this._overrideMarkerIcon(c))}}),L.Marker.include({refreshIconOptions:function(a,l){var c=this.options.icon;return L.setOptions(c,a),this.setIcon(c),l&&this.__parent&&this.__parent._group.refreshClusters(this),this}}),r.MarkerClusterGroup=n,r.MarkerCluster=o,Object.defineProperty(r,"__esModule",{value:!0})})})(leaflet_markerclusterSrc,leaflet_markerclusterSrc.exports);const MarkerCluster_Default="",MarkerCluster="",airtemp={label:"Airtemp",unit:"\u2103"},airtempavg={label:"AvgAirtemp",unit:"\u2103"},airtempmax={label:"MaxAirtemp",unit:"\u2103"},airtempmin={label:"MinAirtemp",unit:"\u2103"},co={label:"CO",name:{en:"Carbon monoxide",ru:"\u0423\u0433\u0430\u0440\u043D\u044B\u0439 \u0433\u0430\u0437"},unit:"mg/m3",chartColor:"#c1c1c1",colors:["#60bc2a","#ff9d00","#fc0202"],range:[0,2,4,14],zones:[{value:0,color:"#60bc2a",label:{en:"Good",ru:"\u0425\u043E\u0440\u043E\u0448\u043E"}},{value:2,color:"#12bfcc",label:{en:"Satisfyingly",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{value:4,color:"#ff9d00",label:{en:"Poor",ru:"\u041F\u043B\u043E\u0445\u043E"}},{color:"#7a00da",label:{en:"Very poor",ru:"\u041E\u0447\u0435\u043D\u044C \u043F\u043B\u043E\u0445\u043E"}}],calculate:function(e){return converterPpmToMgm3(e,28.01)},info:"\u0421arbon monoxide. It is formed during the incomplete decomposition of organic compounds and during the combustion of biomass during forest fires."},gc={label:"GC",name:{en:"Radiation",ru:"\u0420\u0430\u0434\u0438\u0430\u0446\u0438\u044F"},unit:"\u03BCR/h",chartColor:"#e99152",range:[2,10,100,1e3],zones:[{value:2,color:"#60bc2a",label:{en:"Background",ru:"\u0424\u043E\u043D\u043E\u0432\u0430\u044F"}},{value:10,color:"#03a5ed",label:{en:"Moderate",ru:"\u041D\u0435\u0432\u044B\u0441\u043E\u043A\u0430\u044F"}},{value:100,color:"#ff9d00",label:{en:"Elevated",ru:"\u041F\u043E\u0432\u044B\u0448\u0435\u043D\u043D\u0430\u044F"}},{color:"#ff4d00",label:{en:"High",ru:"\u0412\u044B\u0441\u043E\u043A\u0430\u044F"}}]},humidity={label:"Hm",name:{en:"Humidity",ru:"\u0412\u043B\u0430\u0436\u043D\u043E\u0441\u0442\u044C"},unit:"%",chartColor:"#6fd3ff",range:[30,40,60,70],zones:[{value:30,color:"#ff4d00",label:{en:"Very dry",ru:"\u041E\u0447\u0435\u043D\u044C \u0441\u0443\u0445\u043E"}},{value:40,color:"#ff9d00",label:{en:"Dry",ru:"\u0421\u0443\u0445\u043E"}},{value:60,color:"#03a5ed",label:{en:"Comfortable",ru:"\u041A\u043E\u043C\u0444\u043E\u0440\u0442\u043D\u043E"}},{value:70,color:"#2a5cbc",label:{en:"Humid",ru:"\u0412\u043B\u0430\u0436\u043D\u043E"}},{color:"#7a00da",label:{en:"Very humid",ru:"\u041E\u0447\u0435\u043D\u044C \u0432\u043B\u0430\u0436\u043D\u043E"}}]},nh3={label:"NH3",name:{en:"Ammonia",ru:"\u0410\u043C\u043C\u0438\u0430\u043A"},unit:"mg/m3",icon:"vial-virus",chartColor:"#a1e37a",colors:["#60bc2a","#ff9d00","#fc0202"],range:[0,15,40],zones:[{value:15,color:"#60bc2a",label:{en:"Good",ru:"\u0425\u043E\u0440\u043E\u0448\u043E"}},{value:40,color:"#ff9d00",label:{en:"Satisfyingly",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{color:"#fc0202",label:{en:"Poor",ru:"\u041F\u043B\u043E\u0445\u043E"}}],calculate:function(e){return converterPpmToMgm3(e,17.03)}},no2={label:"NO2",name:{en:"Nitrogen Dioxide",ru:"\u0414\u0438\u043E\u043A\u0441\u0438\u0434 \u0430\u0437\u043E\u0442\u0430"},unit:"mg/m3",chartColor:"#d4dd53",colors:["#60bc2a","#ff9d00","#fc0202"],range:[0,1,5],zones:[{value:1,color:"#60bc2a",label:{en:"Good",ru:"\u0425\u043E\u0440\u043E\u0448\u043E"}},{value:5,color:"#ff9d00",label:{en:"Satisfyingly",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{color:"#fc0202",label:{en:"Poor",ru:"\u041F\u043B\u043E\u0445\u043E"}}],calculate:function(e){return converterPpmToMgm3(e,46.01)}},noiseavg={label:"Noise Avg.",unit:"dB",range:[0,40,70,80,100],zones:[{value:40,color:"#60bc2a",label:{en:"Faint",ru:"\u0422\u0438\u0445\u043E"}},{value:70,color:"#12bfcc",label:{en:"Moderate",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{value:80,color:"#ff9d00",label:{en:"Loud",ru:"\u0428\u0443\u043C\u043D\u043E"}},{value:100,color:"#ff4d00",label:{en:"Very loud",ru:"\u041E\u0447\u0435\u043D\u044C \u0448\u0443\u043C\u043D\u043E"}},{color:"#7a00da",label:{en:"Extremely loud",ru:"\u042D\u043A\u0441\u0442\u0440\u0435\u043C\u0430\u043B\u044C\u043D\u043E \u0448\u0443\u043C\u043D\u043E"}}],calculate:function(e){return toFixed(e)},info:"Noise is what your ears or noise sensor can sense. Measured in Decibel (dB)."},noisemax={label:"Noise Max.",unit:"dB",range:[0,40,70,80,100],zones:[{value:40,color:"#60bc2a",label:{en:"Faint",ru:"\u0422\u0438\u0445\u043E"}},{value:70,color:"#12bfcc",label:{en:"Moderate",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{value:80,color:"#ff9d00",label:{en:"Loud",ru:"\u0428\u0443\u043C\u043D\u043E"}},{value:100,color:"#ff4d00",label:{en:"Very loud",ru:"\u041E\u0447\u0435\u043D\u044C \u0448\u0443\u043C\u043D\u043E"}},{color:"#7a00da",label:{en:"Extremely loud",ru:"\u042D\u043A\u0441\u0442\u0440\u0435\u043C\u0430\u043B\u044C\u043D\u043E \u0448\u0443\u043C\u043D\u043E"}}],calculate:function(e){return toFixed(e)},info:"Noise is what your ears or noise sensor can sense. Measured in Decibel (dB)."},pm1={label:"PM1",unit:"\u03BCg/m3",chartColor:"#ff99e9"},pm10={label:"PM10",unit:"\u03BCg/m3",chartColor:"#e8b738",colors:["#60bc2a","#ff9d00","#fc0202"],range:[0,51,101,251,350],zones:[{value:50,color:"#60bc2a",label:{en:"Good",ru:"\u0425\u043E\u0440\u043E\u0448\u043E"}},{value:100,color:"#12bfcc",label:{en:"Satisfyingly",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{value:250,color:"#ff9d00",label:{en:"Poor",ru:"\u041F\u043B\u043E\u0445\u043E"}},{value:350,color:"#ff4d00",label:{en:"Very poor",ru:"\u041E\u0447\u0435\u043D\u044C \u043F\u043B\u043E\u0445\u043E"}},{color:"#7a00da",label:{en:"Unacceptable",ru:"\u041D\u0435\u043F\u0440\u0438\u0435\u043C\u043B\u0435\u043C\u043E"}}],calculate:function(e){return toFixed(e)},info:"PM10 - suspended particles (PM - particulate matter) of a substance with a diameter of less than 10 micrometers (\u03BCm). Pollen and other allergens."},pm25={label:"PM2.5",unit:"\u03BCg/m3",chartColor:"#89b268",colors:["#60bc2a","#ff9d00","#fc0202"],range:[0,36,70,151,251],zones:[{value:36,color:"#60bc2a",label:{en:"Good",ru:"\u0425\u043E\u0440\u043E\u0448\u043E"}},{value:70,color:"#12bfcc",label:{en:"Satisfyingly",ru:"\u0423\u0434\u043E\u0432\u043B\u0435\u0442\u0432\u043E\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u043E"}},{value:150,color:"#ff9d00",label:{en:"Poor",ru:"\u041F\u043B\u043E\u0445\u043E"}},{value:250,color:"#ff4d00",label:{en:"Very poor",ru:"\u041E\u0447\u0435\u043D\u044C \u043F\u043B\u043E\u0445\u043E"}},{color:"#7a00da",label:{en:"Unacceptable",ru:"\u041D\u0435\u043F\u0440\u0438\u0435\u043C\u043B\u0435\u043C\u043E"}}],calculate:function(e){return toFixed(e)},info:"Suspended, solid and liquid particles with a diameter of 2.5 microns are an air pollutant."},pressure={label:"Pr",name:{en:"Atmospheric pressure",ru:"\u0410\u0442\u043C\u043E\u0441\u0444\u0435\u0440\u043D\u043E\u0435 \u0434\u0430\u0432\u043B\u0435\u043D\u0438\u0435"},unit:"mmHg"},rainfall={label:"Rainfall",unit:"mm"},sat10={label:"Sat10",unit:""},sat5={label:"Sat5",unit:""},soiltemp={label:"Soiltemp",unit:"\u2103"},temperature={label:"Tmp",name:{en:"Temperature",ru:"\u0422\u0435\u043C\u043F\u0435\u0440\u0430\u0442\u0443\u0440\u0430"},unit:"\u2103",chartColor:"#2d7ac7",colors:["#fc0202","#ff9d00","#60bc2a","#ff9d00","#fc0202"],range:[-10,0,10,25],zones:[{value:-9,color:"#7a00da",label:{en:"Very cold",ru:"\u041E\u0447\u0435\u043D\u044C \u0445\u043E\u043B\u043E\u0434\u043D\u043E"}},{value:0,color:"#2a5cbc",label:{en:"Cold",ru:"\u0425\u043E\u043B\u043E\u0434\u043D\u043E"}},{value:10,color:"#03a5ed",label:{en:"Cool",ru:"\u041F\u0440\u043E\u0445\u043B\u0430\u0434\u043D\u043E"}},{value:25,color:"#60bc2a",label:{en:"Warm",ru:"\u0422\u0435\u043F\u043B\u043E"}},{value:9999,color:"#ff9d00",label:{en:"Very warm",ru:"\u041E\u0447\u0435\u043D\u044C \u0442\u0435\u043F\u043B\u043E"}}],states:["danger","attention","good","attention","danger","neutral"],calculate:function(e){return toFixed(e)},info:"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u0435\u043B\u044C \u0442\u0435\u043C\u043F\u0435\u0440\u0430\u0442\u0443\u0440\u044B \u0432\u043E\u0437\u0434\u0443\u0445\u0430"},windang={label:"Windang",unit:"\xB0",icon:"wind"},windspeed={label:"Windspeed",unit:"m/s",icon:"wind"},windspeedmax={label:"Windspeedmax",unit:"m/s"},measurements={airtemp,airtempavg,airtempmax,airtempmin,co,gc,humidity,nh3,no2,noiseavg,noisemax,pm1,pm10,pm25,pressure,rainfall,sat10,sat5,soiltemp,temperature,windang,windspeed,windspeedmax};function toFixed(e,t=4){return+(+e||0).toFixed(t)}function converterPpmToMgm3(e,t){return toFixed(e*t/24.05526)}const states=["good","attention","danger","neutral"];function getMeasurementByName(e){return measurements[e]||measurements.pm10}const artesiantlt=""+new URL("artesiantlt.b6bada62.jpg",import.meta.url).href,atc=""+new URL("atc.09cec0ab.png",import.meta.url).href,dolinatlt=""+new URL("dolinatlt.9bfd5fdc.jpg",import.meta.url).href,ekovoz=""+new URL("ekovoz.af7d8a74.png",import.meta.url).href,panorama="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACGVBMVEUAAACz00SfykaQuUWZx0ZQnEyax0aBu0iBu0iBvElgmUhpsExosEtgm0irz0SawkWrz0aTxUiTxEd2rkeTw0d4uUp6uUp6uEp6uUl6uUpwoUZhrUxTnkuly0ZGnE1Jok6lzUaLwUiNwUiNwEdko0hztUp0tUpztkpcn0lam0qHtUZbqk1ooEebw0ZytUpytUlTmks7iktytkp0tUxAnVBBnk9Ank9Bn088lk8vf0wueUote0s/mk9AnU0sbEgobUl9q0Ztn0d6qUaYw0aeyUaCskeAskdzo0Ztnkeax0eaxkeKu0dknEdRkklYoUtRm0tWnUpPkUlknUeSwUebx0eCu0qCu0mBu0lkoklBhUpAhUpqp0qCvElUmEpiqEtpsExpr0tpsEtYn0pZn0tmrUtVlkl4qUZLjkpJmExQpE5GlkxHlkxIl0xQkkproUeiyEWTw0iTw0dSkkk1iU0ziU0zjE45iUtZmEl3rEeSw0d6uEp6t0pvrkpQkklMjUp0s0pgm0lPlkpirExhrExUnEtWnktdl0ily0aUwEZblkhHjUpClExBlE1JoU5Hnk1EjktgmUiFs0alzEaMwEhloElEjEovf0wvgk1FjEpemkiGukh0tUt0tEpXmUp0tUpvsUpcl0hNkEpUoExbqk1bqUxPm0xPmktbqU1RnEtJjklytUpBi0s8jUxCm048kk1CnE5AiktcoUv///8iSiW7AAAAQHRSTlMAf/7+f/7+f/7+f/7+f3/+f3/+/v5//v7+f3/+/n/+/n9//v5//v7+/n9//v5/f/7v/v5/YL+/v7+/3++/YEA/+66NsgAAAAFiS0dEsq1qz+gAAAEDSURBVBjTY2B0cHRydnFxdWNycXb3YGZkYPH08vbx9fNnDQgMCmYLYWFg5wgNC+eMiIyKDguLieFkZ+CKjYtP4E5MSuaJT0xISeVl4ONPS8/IzMzKzszMyc3LF2AQLCgUEi4qLiktK68QEqkUZBCtqharqqqprasXrxITk5BkkGpolG5qbm6RaZJukm5tk2KQbe/o7JKT7+7p7eufMHGSAoPi5MlKk6dMnTZ9xsxZk5WUFRlUZs9Rna2mrjF3tursebPnazJoLVi4SHvxkqXLli/XXrFSR5dBb5W+weo1a9etW2+4YaPRKmMGE1MzU3MLSytrSxtTILBlgAI7ewZUABcAAE5TTddsyTFjAAAAAElFTkSuQmCC",qvantorium=""+new URL("qvantorium.d5858788.jpg",import.meta.url).href,sun=""+new URL("sun.d26ef6d1.png",import.meta.url).href,beon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAAAAAAYplnuAAAElUlEQVR42u3b3XXiOhAH8P/ec19FAasGTAFRA04BuAFTAG4ACogbMAXgW4ApAAq42gJQA9oCUAG7D4R4ZL6MoxBxzswTjh38syONRrLzI8HzxT/fDWB0zMFoRjM6gmA0oxkdQTCa0YyOIBjNaEZHEIxmNKMjCEYzmtERBKMZzegIgtGMZnQEwWhGMzqCYDSjGR1BMJrRjI4gGM3oK/Fvn4N+Xt71O1r09tpOZ/dmZ8wj0T/6vD+9u32I1Uv7dGgAevEodsCOqDZz8XRoIG/k86EhVw9RB87T8u0J0VD5E6JRPKAz9hpcaJQGwN4dNiQSmfrNWKTr+NBGkw0LjVK9eWwVIfo09OtKUfT5o4QYCwDWBRjwA6CBYksa8rmk9/Kq2pFXm+aT8CBo11zLGSKfep1TqdxW68+cL0z2uFKciNn2NKHIcjP5djStlJy356U5nwNluRk+eIZBj8hn767P6os0uRr8X4Vh0Cn5TDvZrLjyS7LJvhMt6dnrnmYAbwPvdQi0XJEN3bbvW2agHtauP5/yROZ1tbK9lo7Z7JwYSe/mirfpQ9DJH7IxEnKsvOywbJs0vf9w9eqQVuSMtiU1WQ9AB5wjAoBpRZOS/FwXbSaUFTmnfR2ADluaajIy0saxnpLsbbOm3ZDpzS/9YvSS2Cakj9m5f1xJBqMhk4aQ6IrcQdCW2+1tbtF+VgMmDSHRxaatrAWpULcn6yGaFOUD2kfYNp2tjgTav9fdw0RCmrjC3RGkNG1DVtXyhPK/5x0nyhtSxt+OBgosAe9OG3fJe7jOB6DNvnvSzlmLXxpe3bcHhJIquaAb0BHvHlymurtXjCdeuWYzB5Bq2enrGeL+9hGgIzq9eKX1qOykXpFeNjtTL3B3hGnTNq/JXyxb9rrWnTF62OJwoI7oSlIeyeTGbNtpO9QbEg1tST9TBrsL3c4aq81nF9+DpTyqTM4+QLLaWO36f+MD0FQz6lazVhuzC+INi6bNQQC/6PVkgR/GBKs9aLZ1gCXpXNwqP8VspXd6NXk0Oqe52AKgY1B+ppKbtDky3RZKQKje6zeB0IlX5lsANW3C5Yl6VlZHYVodL1j2fNAUBC1mjbdtADg6rxXV3OO8rIqPh0qSXK/o98jm7tpj3qk9pBylnZL4MFkVW3/0brbv+S5R779gM4fu6shpaRMC3SPKwyJTPu/usBaQo/ZaTO6AxhPU5a1vxxfU04B9f/5fdyunkyo2mS/8OU7P6voL3vf4mGtXNxf8s5M/Rq/qOjx6+fGihctvqlMBf+DpNWwGR5cVEeT19YPt1HU6zBY9IjDaTj2mK8trt26bWeA/70d9kkdYtFu+dk9aZ83Fo8vCwV8DQb83XcKlPLdZn79N/jrpx+HHZVT66sJ6jj4RAu32Zm/0lU4nVerPbZ1uSGV9vCpX3egCd6GvJ89+dWcy/iklALe3v3fdC5SpEtY0fSvuXujY4ilfJmQ0oxkdQTCa0YyOIBjNaEZHEIxmNKMjCEYzmtERBKMZzegIgtGMZnQEwWhGMzqCYDSjGR1BMJrRjI4gGM1oRkcQjGY0oyOIp0T/BRrCOxyOfITTAAAAAElFTkSuQmCC",owlcat=""+new URL("owlcatgames.ae9238f4.jpg",import.meta.url).href,sensors={"7e071fd9b023ed8f18458a73613a0834f6220bd5cc50357ba3493c6040a9ea8c":{icon:ekovoz,link:"http://ekovoz.ru/"},"162ebfac08a69bc96c0bd569c95026c6750cbecca7a61731dfe1a985a9391176":{icon:atc,link:"http://atcgaz.ru/"},"7c7ffabc786c46ff40d8ca922b1248e1261baefec702eea160001140063f8c53":{icon:atc,link:"http://atcgaz.ru/"},"7cdeafa03331cb330c3993ff0381457f0713a8fd6d0b3dbe93ea24affe5676ac":{icon:artesiantlt,link:"https://www.artesiantlt.ru/"},"217a9ae639e48a9b99de7895c496b224ad6a80f9b679d516557561aedd47c58b":{icon:qvantorium,link:"https://vk.com/kvantoriumtlt"},f5cf0ec44b696400af9b280cb5bedc9e10893f5f961159658a218286f8e97372:{icon:dolinatlt,link:"https://dolinatlt.ru/"},"5bd528a4d708304254d2417b83f8b5c997ed08ccf956fa4e538fc6cfa40f86c0":{icon:panorama,link:"https://panorama-park63.ru/"},e4871acd155431c63fbbc54b89d015bc17bc5fbe44d5846502f7e58566e24a8e:{link:"https://airalab.org/"},"62c86fb3712e2c8e3d8a7a79f62c1cb0dbd4ad2980606dbf8fcf96ce9ed46c8d":{icon:sun},"3d10918f84c47d7134be14136d3af157ebc3335fe72e8dafd26fbeb01e3116fd":{icon:beon,link:"The most technologically advanced office in Cyprus. https://beon.center/"},"28695c0354e91eb0a31744641356c5d3f6868f02b01148762f467c3687ede97b":{icon:owlcat,link:"https://owlcat.games"}};var chroma$1={exports:{}};/** * chroma.js - JavaScript library for color conversions * * Copyright (c) 2011-2019, Gregor Aisch @@ -86,7 +86,7 @@ hooks.version="2.29.4";setHookCallback(createLocal);hooks.fn=proto;hooks.min=min * http://www.w3.org/TR/css3-color/#svg-color * * @preserve - */(function(e,t){(function(r,n){e.exports=n()})(commonjsGlobal$2,function(){for(var r=function(ke,Ne,Ge){return Ne===void 0&&(Ne=0),Ge===void 0&&(Ge=1),keGe?Ge:ke},n=r,o=function(ke){ke._clipped=!1,ke._unclipped=ke.slice(0);for(var Ne=0;Ne<=3;Ne++)Ne<3?((ke[Ne]<0||ke[Ne]>255)&&(ke._clipped=!0),ke[Ne]=n(ke[Ne],0,255)):Ne===3&&(ke[Ne]=n(ke[Ne],0,1));return ke},a={},l=0,c=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];l=3?Array.prototype.slice.call(ke):b(ke[0])=="object"&&Ne?Ne.split("").filter(function(Ge){return ke[0][Ge]!==void 0}).map(function(Ge){return ke[0][Ge]}):ke[0]},S=g,$=function(ke){if(ke.length<2)return null;var Ne=ke.length-1;return S(ke[Ne])=="string"?ke[Ne].toLowerCase():null},k=Math.PI,T={clip_rgb:o,limit:r,type:g,unpack:x,last:$,PI:k,TWOPI:k*2,PITHIRD:k/3,DEG2RAD:k/180,RAD2DEG:180/k},D={format:{},autodetect:[]},I=T.last,O=T.clip_rgb,N=T.type,ee=D,ne=function(){for(var Ne=[],Ge=arguments.length;Ge--;)Ne[Ge]=arguments[Ge];var ot=this;if(N(Ne[0])==="object"&&Ne[0].constructor&&Ne[0].constructor===this.constructor)return Ne[0];var dt=I(Ne),ft=!1;if(!dt){ft=!0,ee.sorted||(ee.autodetect=ee.autodetect.sort(function(Ct,Pt){return Pt.p-Ct.p}),ee.sorted=!0);for(var ht=0,mt=ee.autodetect;ht4?ke[4]:1;return ft===1?[0,0,0,ht]:[Ge>=1?0:255*(1-Ge)*(1-ft),ot>=1?0:255*(1-ot)*(1-ft),dt>=1?0:255*(1-dt)*(1-ft),ht]},ie=ae,pe=fe,ue=B,ge=D,ye=T.unpack,Ae=T.type,Re=_e;ue.prototype.cmyk=function(){return Re(this._rgb)},pe.cmyk=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(ue,[null].concat(ke,["cmyk"])))},ge.format.cmyk=ie,ge.autodetect.push({p:2,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=ye(ke,"cmyk"),Ae(ke)==="array"&&ke.length===4)return"cmyk"}});var We=T.unpack,Pe=T.last,Ue=function(ke){return Math.round(ke*100)/100},Oe=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=We(ke,"hsla"),ot=Pe(ke)||"lsa";return Ge[0]=Ue(Ge[0]||0),Ge[1]=Ue(Ge[1]*100)+"%",Ge[2]=Ue(Ge[2]*100)+"%",ot==="hsla"||Ge.length>3&&Ge[3]<1?(Ge[3]=Ge.length>3?Ge[3]:1,ot="hsla"):Ge.length=3,ot+"("+Ge.join(",")+")"},Be=Oe,Ye=T.unpack,Se=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=Ye(ke,"rgba");var Ge=ke[0],ot=ke[1],dt=ke[2];Ge/=255,ot/=255,dt/=255;var ft=Math.min(Ge,ot,dt),ht=Math.max(Ge,ot,dt),mt=(ht+ft)/2,yt,wt;return ht===ft?(yt=0,wt=Number.NaN):yt=mt<.5?(ht-ft)/(ht+ft):(ht-ft)/(2-ht-ft),Ge==ht?wt=(ot-dt)/(ht-ft):ot==ht?wt=2+(dt-Ge)/(ht-ft):dt==ht&&(wt=4+(Ge-ot)/(ht-ft)),wt*=60,wt<0&&(wt+=360),ke.length>3&&ke[3]!==void 0?[wt,yt,mt,ke[3]]:[wt,yt,mt]},Te=Se,$e=T.unpack,Ve=T.last,oe=Be,te=Te,se=Math.round,me=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=$e(ke,"rgba"),ot=Ve(ke)||"rgb";return ot.substr(0,3)=="hsl"?oe(te(Ge),ot):(Ge[0]=se(Ge[0]),Ge[1]=se(Ge[1]),Ge[2]=se(Ge[2]),(ot==="rgba"||Ge.length>3&&Ge[3]<1)&&(Ge[3]=Ge.length>3?Ge[3]:1,ot="rgba"),ot+"("+Ge.slice(0,ot==="rgb"?3:4).join(",")+")")},Ee=me,Le=T.unpack,He=Math.round,ze=function(){for(var ke,Ne=[],Ge=arguments.length;Ge--;)Ne[Ge]=arguments[Ge];Ne=Le(Ne,"hsl");var ot=Ne[0],dt=Ne[1],ft=Ne[2],ht,mt,yt;if(dt===0)ht=mt=yt=ft*255;else{var wt=[0,0,0],Ct=[0,0,0],Pt=ft<.5?ft*(1+dt):ft+dt-ft*dt,kt=2*ft-Pt,It=ot/360;wt[0]=It+1/3,wt[1]=It,wt[2]=It-1/3;for(var $t=0;$t<3;$t++)wt[$t]<0&&(wt[$t]+=1),wt[$t]>1&&(wt[$t]-=1),6*wt[$t]<1?Ct[$t]=kt+(Pt-kt)*6*wt[$t]:2*wt[$t]<1?Ct[$t]=Pt:3*wt[$t]<2?Ct[$t]=kt+(Pt-kt)*(2/3-wt[$t])*6:Ct[$t]=kt;ke=[He(Ct[0]*255),He(Ct[1]*255),He(Ct[2]*255)],ht=ke[0],mt=ke[1],yt=ke[2]}return Ne.length>3?[ht,mt,yt,Ne[3]]:[ht,mt,yt,1]},Qe=ze,rt=Qe,Ke=D,Ie=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,Fe=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,je=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,Ze=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Ce=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,ce=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,de=Math.round,De=function(ke){ke=ke.toLowerCase().trim();var Ne;if(Ke.format.named)try{return Ke.format.named(ke)}catch{}if(Ne=ke.match(Ie)){for(var Ge=Ne.slice(1,4),ot=0;ot<3;ot++)Ge[ot]=+Ge[ot];return Ge[3]=1,Ge}if(Ne=ke.match(Fe)){for(var dt=Ne.slice(1,5),ft=0;ft<4;ft++)dt[ft]=+dt[ft];return dt}if(Ne=ke.match(je)){for(var ht=Ne.slice(1,4),mt=0;mt<3;mt++)ht[mt]=de(ht[mt]*2.55);return ht[3]=1,ht}if(Ne=ke.match(Ze)){for(var yt=Ne.slice(1,5),wt=0;wt<3;wt++)yt[wt]=de(yt[wt]*2.55);return yt[3]=+yt[3],yt}if(Ne=ke.match(Ce)){var Ct=Ne.slice(1,4);Ct[1]*=.01,Ct[2]*=.01;var Pt=rt(Ct);return Pt[3]=1,Pt}if(Ne=ke.match(ce)){var kt=Ne.slice(1,4);kt[1]*=.01,kt[2]*=.01;var It=rt(kt);return It[3]=+Ne[4],It}};De.test=function(ke){return Ie.test(ke)||Fe.test(ke)||je.test(ke)||Ze.test(ke)||Ce.test(ke)||ce.test(ke)};var qe=De,nt=fe,lt=B,pt=D,bt=T.type,St=Ee,Et=qe;lt.prototype.css=function(ke){return St(this._rgb,ke)},nt.css=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(lt,[null].concat(ke,["css"])))},pt.format.css=Et,pt.autodetect.push({p:5,test:function(ke){for(var Ne=[],Ge=arguments.length-1;Ge-- >0;)Ne[Ge]=arguments[Ge+1];if(!Ne.length&&bt(ke)==="string"&&Et.test(ke))return"css"}});var vt=B,Nt=fe,Ft=D,qt=T.unpack;Ft.format.gl=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=qt(ke,"rgba");return Ge[0]*=255,Ge[1]*=255,Ge[2]*=255,Ge},Nt.gl=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(vt,[null].concat(ke,["gl"])))},vt.prototype.gl=function(){var ke=this._rgb;return[ke[0]/255,ke[1]/255,ke[2]/255,ke[3]]};var Zt=T.unpack,mr=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Zt(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=Math.min(ot,dt,ft),mt=Math.max(ot,dt,ft),yt=mt-ht,wt=yt*100/255,Ct=ht/(255-yt)*100,Pt;return yt===0?Pt=Number.NaN:(ot===mt&&(Pt=(dt-ft)/yt),dt===mt&&(Pt=2+(ft-ot)/yt),ft===mt&&(Pt=4+(ot-dt)/yt),Pt*=60,Pt<0&&(Pt+=360)),[Pt,wt,Ct]},nr=mr,ur=T.unpack,Mr=Math.floor,Pr=function(){for(var ke,Ne,Ge,ot,dt,ft,ht=[],mt=arguments.length;mt--;)ht[mt]=arguments[mt];ht=ur(ht,"hcg");var yt=ht[0],wt=ht[1],Ct=ht[2],Pt,kt,It;Ct=Ct*255;var $t=wt*255;if(wt===0)Pt=kt=It=Ct;else{yt===360&&(yt=0),yt>360&&(yt-=360),yt<0&&(yt+=360),yt/=60;var Ut=Mr(yt),Wt=yt-Ut,Yt=Ct*(1-wt),Xt=Yt+$t*(1-Wt),br=Yt+$t*Wt,_r=Yt+$t;switch(Ut){case 0:ke=[_r,br,Yt],Pt=ke[0],kt=ke[1],It=ke[2];break;case 1:Ne=[Xt,_r,Yt],Pt=Ne[0],kt=Ne[1],It=Ne[2];break;case 2:Ge=[Yt,_r,br],Pt=Ge[0],kt=Ge[1],It=Ge[2];break;case 3:ot=[Yt,Xt,_r],Pt=ot[0],kt=ot[1],It=ot[2];break;case 4:dt=[br,Yt,_r],Pt=dt[0],kt=dt[1],It=dt[2];break;case 5:ft=[_r,Yt,Xt],Pt=ft[0],kt=ft[1],It=ft[2];break}}return[Pt,kt,It,ht.length>3?ht[3]:1]},fr=Pr,hr=T.unpack,$r=T.type,Bi=fe,li=B,Mn=D,Sr=nr;li.prototype.hcg=function(){return Sr(this._rgb)},Bi.hcg=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(li,[null].concat(ke,["hcg"])))},Mn.format.hcg=fr,Mn.autodetect.push({p:1,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=hr(ke,"hcg"),$r(ke)==="array"&&ke.length===3)return"hcg"}});var Lt=T.unpack,On=T.last,Ur=Math.round,Dn=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Lt(ke,"rgba"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=Ge[3],mt=On(ke)||"auto";ht===void 0&&(ht=1),mt==="auto"&&(mt=ht<1?"rgba":"rgb"),ot=Ur(ot),dt=Ur(dt),ft=Ur(ft);var yt=ot<<16|dt<<8|ft,wt="000000"+yt.toString(16);wt=wt.substr(wt.length-6);var Ct="0"+Ur(ht*255).toString(16);switch(Ct=Ct.substr(Ct.length-2),mt.toLowerCase()){case"rgba":return"#"+wt+Ct;case"argb":return"#"+Ct+wt;default:return"#"+wt}},tn=Dn,rn=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,Nn=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,Ir=function(ke){if(ke.match(rn)){(ke.length===4||ke.length===7)&&(ke=ke.substr(1)),ke.length===3&&(ke=ke.split(""),ke=ke[0]+ke[0]+ke[1]+ke[1]+ke[2]+ke[2]);var Ne=parseInt(ke,16),Ge=Ne>>16,ot=Ne>>8&255,dt=Ne&255;return[Ge,ot,dt,1]}if(ke.match(Nn)){(ke.length===5||ke.length===9)&&(ke=ke.substr(1)),ke.length===4&&(ke=ke.split(""),ke=ke[0]+ke[0]+ke[1]+ke[1]+ke[2]+ke[2]+ke[3]+ke[3]);var ft=parseInt(ke,16),ht=ft>>24&255,mt=ft>>16&255,yt=ft>>8&255,wt=Math.round((ft&255)/255*100)/100;return[ht,mt,yt,wt]}throw new Error("unknown hex color: "+ke)},qr=Ir,ci=fe,nn=B,xo=T.type,_s=D,vs=tn;nn.prototype.hex=function(ke){return vs(this._rgb,ke)},ci.hex=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(nn,[null].concat(ke,["hex"])))},_s.format.hex=qr,_s.autodetect.push({p:4,test:function(ke){for(var Ne=[],Ge=arguments.length-1;Ge-- >0;)Ne[Ge]=arguments[Ge+1];if(!Ne.length&&xo(ke)==="string"&&[3,4,5,6,7,8,9].indexOf(ke.length)>=0)return"hex"}});var Eo=T.unpack,Bn=T.TWOPI,So=Math.min,Co=Math.sqrt,ko=Math.acos,Ao=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Eo(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2];ot/=255,dt/=255,ft/=255;var ht,mt=So(ot,dt,ft),yt=(ot+dt+ft)/3,wt=yt>0?1-mt/yt:0;return wt===0?ht=NaN:(ht=(ot-dt+(ot-ft))/2,ht/=Co((ot-dt)*(ot-dt)+(ot-ft)*(dt-ft)),ht=ko(ht),ft>dt&&(ht=Bn-ht),ht/=Bn),[ht*360,wt,yt]},To=Ao,Fi=T.unpack,sn=T.limit,an=T.TWOPI,ui=T.PITHIRD,Or=Math.cos,Kt=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=Fi(ke,"hsi");var Ge=ke[0],ot=ke[1],dt=ke[2],ft,ht,mt;return isNaN(Ge)&&(Ge=0),isNaN(ot)&&(ot=0),Ge>360&&(Ge-=360),Ge<0&&(Ge+=360),Ge/=360,Ge<1/3?(mt=(1-ot)/3,ft=(1+ot*Or(an*Ge)/Or(ui-an*Ge))/3,ht=1-(mt+ft)):Ge<2/3?(Ge-=1/3,ft=(1-ot)/3,ht=(1+ot*Or(an*Ge)/Or(ui-an*Ge))/3,mt=1-(ft+ht)):(Ge-=2/3,ht=(1-ot)/3,mt=(1+ot*Or(an*Ge)/Or(ui-an*Ge))/3,ft=1-(ht+mt)),ft=sn(dt*ft*3),ht=sn(dt*ht*3),mt=sn(dt*mt*3),[ft*255,ht*255,mt*255,ke.length>3?ke[3]:1]},ar=Kt,hi=T.unpack,En=T.type,Sn=fe,di=B,Bt=D,cr=To;di.prototype.hsi=function(){return cr(this._rgb)},Sn.hsi=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(di,[null].concat(ke,["hsi"])))},Bt.format.hsi=ar,Bt.autodetect.push({p:2,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=hi(ke,"hsi"),En(ke)==="array"&&ke.length===3)return"hsi"}});var Ui=T.unpack,fi=T.type,kr=fe,bs=B,Fn=D,ln=Te;bs.prototype.hsl=function(){return ln(this._rgb)},kr.hsl=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(bs,[null].concat(ke,["hsl"])))},Fn.format.hsl=Qe,Fn.autodetect.push({p:2,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Ui(ke,"hsl"),fi(ke)==="array"&&ke.length===3)return"hsl"}});var dr=T.unpack,cn=Math.min,Un=Math.max,Vn=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=dr(ke,"rgb");var Ge=ke[0],ot=ke[1],dt=ke[2],ft=cn(Ge,ot,dt),ht=Un(Ge,ot,dt),mt=ht-ft,yt,wt,Ct;return Ct=ht/255,ht===0?(yt=Number.NaN,wt=0):(wt=mt/ht,Ge===ht&&(yt=(ot-dt)/mt),ot===ht&&(yt=2+(dt-Ge)/mt),dt===ht&&(yt=4+(Ge-ot)/mt),yt*=60,yt<0&&(yt+=360)),[yt,wt,Ct]},Vi=Vn,Hn=T.unpack,Hi=Math.floor,zi=function(){for(var ke,Ne,Ge,ot,dt,ft,ht=[],mt=arguments.length;mt--;)ht[mt]=arguments[mt];ht=Hn(ht,"hsv");var yt=ht[0],wt=ht[1],Ct=ht[2],Pt,kt,It;if(Ct*=255,wt===0)Pt=kt=It=Ct;else{yt===360&&(yt=0),yt>360&&(yt-=360),yt<0&&(yt+=360),yt/=60;var $t=Hi(yt),Ut=yt-$t,Wt=Ct*(1-wt),Yt=Ct*(1-wt*Ut),Xt=Ct*(1-wt*(1-Ut));switch($t){case 0:ke=[Ct,Xt,Wt],Pt=ke[0],kt=ke[1],It=ke[2];break;case 1:Ne=[Yt,Ct,Wt],Pt=Ne[0],kt=Ne[1],It=Ne[2];break;case 2:Ge=[Wt,Ct,Xt],Pt=Ge[0],kt=Ge[1],It=Ge[2];break;case 3:ot=[Wt,Yt,Ct],Pt=ot[0],kt=ot[1],It=ot[2];break;case 4:dt=[Xt,Wt,Ct],Pt=dt[0],kt=dt[1],It=dt[2];break;case 5:ft=[Ct,Wt,Yt],Pt=ft[0],kt=ft[1],It=ft[2];break}}return[Pt,kt,It,ht.length>3?ht[3]:1]},pi=zi,Wi=T.unpack,ji=T.type,mi=fe,Ki=B,gi=D,Po=Vi;Ki.prototype.hsv=function(){return Po(this._rgb)},mi.hsv=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(Ki,[null].concat(ke,["hsv"])))},gi.format.hsv=pi,gi.autodetect.push({p:2,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Wi(ke,"hsv"),ji(ke)==="array"&&ke.length===3)return"hsv"}});var Ot={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},vr=Ot,tr=T.unpack,Yi=Math.pow,Gi=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=tr(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=un(ot,dt,ft),mt=ht[0],yt=ht[1],wt=ht[2],Ct=116*yt-16;return[Ct<0?0:Ct,500*(mt-yt),200*(yt-wt)]},zn=function(ke){return(ke/=255)<=.04045?ke/12.92:Yi((ke+.055)/1.055,2.4)},Wn=function(ke){return ke>vr.t3?Yi(ke,1/3):ke/vr.t2+vr.t0},un=function(ke,Ne,Ge){ke=zn(ke),Ne=zn(Ne),Ge=zn(Ge);var ot=Wn((.4124564*ke+.3575761*Ne+.1804375*Ge)/vr.Xn),dt=Wn((.2126729*ke+.7151522*Ne+.072175*Ge)/vr.Yn),ft=Wn((.0193339*ke+.119192*Ne+.9503041*Ge)/vr.Zn);return[ot,dt,ft]},yi=Gi,Dr=Ot,gr=T.unpack,hn=Math.pow,ws=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=gr(ke,"lab");var Ge=ke[0],ot=ke[1],dt=ke[2],ft,ht,mt,yt,wt,Ct;return ht=(Ge+16)/116,ft=isNaN(ot)?ht:ht+ot/500,mt=isNaN(dt)?ht:ht-dt/200,ht=Dr.Yn*qi(ht),ft=Dr.Xn*qi(ft),mt=Dr.Zn*qi(mt),yt=_i(3.2404542*ft-1.5371385*ht-.4985314*mt),wt=_i(-.969266*ft+1.8760108*ht+.041556*mt),Ct=_i(.0556434*ft-.2040259*ht+1.0572252*mt),[yt,wt,Ct,ke.length>3?ke[3]:1]},_i=function(ke){return 255*(ke<=.00304?12.92*ke:1.055*hn(ke,1/2.4)-.055)},qi=function(ke){return ke>Dr.t1?ke*ke*ke:Dr.t2*(ke-Dr.t0)},Zi=ws,Xi=T.unpack,$o=T.type,xs=fe,zt=B,Es=D,Lr=yi;zt.prototype.lab=function(){return Lr(this._rgb)},xs.lab=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(zt,[null].concat(ke,["lab"])))},Es.format.lab=Zi,Es.autodetect.push({p:2,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Xi(ke,"lab"),$o(ke)==="array"&&ke.length===3)return"lab"}});var jn=T.unpack,Ss=T.RAD2DEG,Io=Math.sqrt,Qi=Math.atan2,Lo=Math.round,Cs=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=jn(ke,"lab"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=Io(dt*dt+ft*ft),mt=(Qi(ft,dt)*Ss+360)%360;return Lo(ht*1e4)===0&&(mt=Number.NaN),[ot,ht,mt]},ks=Cs,Ro=T.unpack,Ji=yi,Mo=ks,Nr=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Ro(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=Ji(ot,dt,ft),mt=ht[0],yt=ht[1],wt=ht[2];return Mo(mt,yt,wt)},Oo=Nr,As=T.unpack,Zr=T.DEG2RAD,Ts=Math.sin,Ps=Math.cos,Do=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=As(ke,"lch"),ot=Ge[0],dt=Ge[1],ft=Ge[2];return isNaN(ft)&&(ft=0),ft=ft*Zr,[ot,Ps(ft)*dt,Ts(ft)*dt]},$s=Do,es=T.unpack,No=$s,Is=Zi,Ls=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=es(ke,"lch");var Ge=ke[0],ot=ke[1],dt=ke[2],ft=No(Ge,ot,dt),ht=ft[0],mt=ft[1],yt=ft[2],wt=Is(ht,mt,yt),Ct=wt[0],Pt=wt[1],kt=wt[2];return[Ct,Pt,kt,ke.length>3?ke[3]:1]},Kn=Ls,dn=T.unpack,Bo=Kn,Yn=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=dn(ke,"hcl").reverse();return Bo.apply(void 0,Ge)},Ar=Yn,Rs=T.unpack,Ms=T.type,Os=fe,Gn=B,vi=D,Ds=Oo;Gn.prototype.lch=function(){return Ds(this._rgb)},Gn.prototype.hcl=function(){return Ds(this._rgb).reverse()},Os.lch=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(Gn,[null].concat(ke,["lch"])))},Os.hcl=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(Gn,[null].concat(ke,["hcl"])))},vi.format.lch=Kn,vi.format.hcl=Ar,["lch","hcl"].forEach(function(ke){return vi.autodetect.push({p:2,test:function(){for(var Ne=[],Ge=arguments.length;Ge--;)Ne[Ge]=arguments[Ge];if(Ne=Rs(Ne,ke),Ms(Ne)==="array"&&Ne.length===3)return ke}})});var ts={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},bi=ts,Fo=B,Ns=D,Bs=T.type,qn=bi,Rr=qr,Cn=tn;Fo.prototype.name=function(){for(var ke=Cn(this._rgb,"rgb"),Ne=0,Ge=Object.keys(qn);Ne0;)Ne[Ge]=arguments[Ge+1];if(!Ne.length&&Bs(ke)==="string"&&qn[ke.toLowerCase()])return"named"}});var Uo=T.unpack,fn=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Uo(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2];return(ot<<16)+(dt<<8)+ft},Vo=fn,kn=T.type,Ho=function(ke){if(kn(ke)=="number"&&ke>=0&&ke<=16777215){var Ne=ke>>16,Ge=ke>>8&255,ot=ke&255;return[Ne,Ge,ot,1]}throw new Error("unknown num color: "+ke)},Zn=Ho,Fs=fe,Xn=B,Us=D,Xr=T.type,wi=Vo;Xn.prototype.num=function(){return wi(this._rgb)},Fs.num=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(Xn,[null].concat(ke,["num"])))},Us.format.num=Zn,Us.autodetect.push({p:5,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke.length===1&&Xr(ke[0])==="number"&&ke[0]>=0&&ke[0]<=16777215)return"num"}});var zo=fe,Qn=B,Vs=D,Br=T.unpack,Hs=T.type,pn=Math.round;Qn.prototype.rgb=function(ke){return ke===void 0&&(ke=!0),ke===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(pn)},Qn.prototype.rgba=function(ke){return ke===void 0&&(ke=!0),this._rgb.slice(0,4).map(function(Ne,Ge){return Ge<3?ke===!1?Ne:pn(Ne):Ne})},zo.rgb=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(Qn,[null].concat(ke,["rgb"])))},Vs.format.rgb=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Br(ke,"rgba");return Ge[3]===void 0&&(Ge[3]=1),Ge},Vs.autodetect.push({p:3,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Br(ke,"rgba"),Hs(ke)==="array"&&(ke.length===3||ke.length===4&&Hs(ke[3])=="number"&&ke[3]>=0&&ke[3]<=1))return"rgb"}});var xi=Math.log,Vr=function(ke){var Ne=ke/100,Ge,ot,dt;return Ne<66?(Ge=255,ot=Ne<6?0:-155.25485562709179-.44596950469579133*(ot=Ne-2)+104.49216199393888*xi(ot),dt=Ne<20?0:-254.76935184120902+.8274096064007395*(dt=Ne-10)+115.67994401066147*xi(dt)):(Ge=351.97690566805693+.114206453784165*(Ge=Ne-55)-40.25366309332127*xi(Ge),ot=325.4494125711974+.07943456536662342*(ot=Ne-50)-28.0852963507957*xi(ot),dt=255),[Ge,ot,dt,1]},Jn=Vr,zs=Jn,rs=T.unpack,Ei=Math.round,ns=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];for(var Ge=rs(ke,"rgb"),ot=Ge[0],dt=Ge[2],ft=1e3,ht=4e4,mt=.4,yt;ht-ft>mt;){yt=(ht+ft)*.5;var wt=zs(yt);wt[2]/wt[0]>=dt/ot?ht=yt:ft=yt}return Ei(yt)},Si=ns,Qr=fe,mn=B,ei=D,Ws=Si;mn.prototype.temp=mn.prototype.kelvin=mn.prototype.temperature=function(){return Ws(this._rgb)},Qr.temp=Qr.kelvin=Qr.temperature=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(mn,[null].concat(ke,["temp"])))},ei.format.temp=ei.format.kelvin=ei.format.temperature=Jn;var Wo=T.unpack,An=Math.cbrt,jo=Math.pow,js=Math.sign,Ko=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Wo(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=[ss(ot/255),ss(dt/255),ss(ft/255)],mt=ht[0],yt=ht[1],wt=ht[2],Ct=An(.4122214708*mt+.5363325363*yt+.0514459929*wt),Pt=An(.2119034982*mt+.6806995451*yt+.1073969566*wt),kt=An(.0883024619*mt+.2817188376*yt+.6299787005*wt);return[.2104542553*Ct+.793617785*Pt-.0040720468*kt,1.9779984951*Ct-2.428592205*Pt+.4505937099*kt,.0259040371*Ct+.7827717662*Pt-.808675766*kt]},is=Ko;function ss(ke){var Ne=Math.abs(ke);return Ne<.04045?ke/12.92:(js(ke)||1)*jo((Ne+.055)/1.055,2.4)}var Fr=T.unpack,gn=Math.pow,Yo=Math.sign,Ci=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=Fr(ke,"lab");var Ge=ke[0],ot=ke[1],dt=ke[2],ft=gn(Ge+.3963377774*ot+.2158037573*dt,3),ht=gn(Ge-.1055613458*ot-.0638541728*dt,3),mt=gn(Ge-.0894841775*ot-1.291485548*dt,3);return[255*ki(4.0767416621*ft-3.3077115913*ht+.2309699292*mt),255*ki(-1.2684380046*ft+2.6097574011*ht-.3413193965*mt),255*ki(-.0041960863*ft-.7034186147*ht+1.707614701*mt),ke.length>3?ke[3]:1]},Ks=Ci;function ki(ke){var Ne=Math.abs(ke);return Ne>.0031308?(Yo(ke)||1)*(1.055*gn(Ne,1/2.4)-.055):ke*12.92}var Go=T.unpack,ti=T.type,qo=fe,yn=B,os=D,Ys=is;yn.prototype.oklab=function(){return Ys(this._rgb)},qo.oklab=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(yn,[null].concat(ke,["oklab"])))},os.format.oklab=Ks,os.autodetect.push({p:3,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Go(ke,"oklab"),ti(ke)==="array"&&ke.length===3)return"oklab"}});var Zo=T.unpack,Hr=is,Gs=ks,qs=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Zo(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=Hr(ot,dt,ft),mt=ht[0],yt=ht[1],wt=ht[2];return Gs(mt,yt,wt)},ri=qs,Xo=T.unpack,Ai=$s,ni=Ks,Zs=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=Xo(ke,"lch");var Ge=ke[0],ot=ke[1],dt=ke[2],ft=Ai(Ge,ot,dt),ht=ft[0],mt=ft[1],yt=ft[2],wt=ni(ht,mt,yt),Ct=wt[0],Pt=wt[1],kt=wt[2];return[Ct,Pt,kt,ke.length>3?ke[3]:1]},Xs=Zs,Qo=T.unpack,Qs=T.type,Js=fe,ls=B,cs=D,eo=ri;ls.prototype.oklch=function(){return eo(this._rgb)},Js.oklch=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(ls,[null].concat(ke,["oklch"])))},cs.format.oklch=Xs,cs.autodetect.push({p:3,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Qo(ke,"oklch"),Qs(ke)==="array"&&ke.length===3)return"oklch"}});var ro=B,no=T.type;ro.prototype.alpha=function(ke,Ne){return Ne===void 0&&(Ne=!1),ke!==void 0&&no(ke)==="number"?Ne?(this._rgb[3]=ke,this):new ro([this._rgb[0],this._rgb[1],this._rgb[2],ke],"rgb"):this._rgb[3]};var so=B;so.prototype.clipped=function(){return this._rgb._clipped||!1};var _n=B,_=Ot;_n.prototype.darken=function(ke){ke===void 0&&(ke=1);var Ne=this,Ge=Ne.lab();return Ge[0]-=_.Kn*ke,new _n(Ge,"lab").alpha(Ne.alpha(),!0)},_n.prototype.brighten=function(ke){return ke===void 0&&(ke=1),this.darken(-ke)},_n.prototype.darker=_n.prototype.darken,_n.prototype.brighter=_n.prototype.brighten;var E=B;E.prototype.get=function(ke){var Ne=ke.split("."),Ge=Ne[0],ot=Ne[1],dt=this[Ge]();if(ot){var ft=Ge.indexOf(ot)-(Ge.substr(0,2)==="ok"?2:0);if(ft>-1)return dt[ft];throw new Error("unknown channel "+ot+" in mode "+Ge)}else return dt};var H=B,be=T.type,Me=Math.pow,Je=1e-7,ct=20;H.prototype.luminance=function(ke){if(ke!==void 0&&be(ke)==="number"){if(ke===0)return new H([0,0,0,this._rgb[3]],"rgb");if(ke===1)return new H([255,255,255,this._rgb[3]],"rgb");var Ne=this.luminance(),Ge="rgb",ot=ct,dt=function(ht,mt){var yt=ht.interpolate(mt,.5,Ge),wt=yt.luminance();return Math.abs(ke-wt)ke?dt(ht,yt):dt(yt,mt)},ft=(Ne>ke?dt(new H([0,0,0]),this):dt(this,new H([255,255,255]))).rgb();return new H(ft.concat([this._rgb[3]]))}return gt.apply(void 0,this._rgb.slice(0,3))};var gt=function(ke,Ne,Ge){return ke=_t(ke),Ne=_t(Ne),Ge=_t(Ge),.2126*ke+.7152*Ne+.0722*Ge},_t=function(ke){return ke/=255,ke<=.03928?ke/12.92:Me((ke+.055)/1.055,2.4)},xt={},Tt=B,Mt=T.type,Dt=xt,Cr=function(ke,Ne,Ge){Ge===void 0&&(Ge=.5);for(var ot=[],dt=arguments.length-3;dt-- >0;)ot[dt]=arguments[dt+3];var ft=ot[0]||"lrgb";if(!Dt[ft]&&!ot.length&&(ft=Object.keys(Dt)[0]),!Dt[ft])throw new Error("interpolation mode "+ft+" is not defined");return Mt(ke)!=="object"&&(ke=new Tt(ke)),Mt(Ne)!=="object"&&(Ne=new Tt(Ne)),Dt[ft](ke,Ne,Ge).alpha(ke.alpha()+Ge*(Ne.alpha()-ke.alpha()))},Jr=B,Ti=Cr;Jr.prototype.mix=Jr.prototype.interpolate=function(ke,Ne){Ne===void 0&&(Ne=.5);for(var Ge=[],ot=arguments.length-2;ot-- >0;)Ge[ot]=arguments[ot+2];return Ti.apply(void 0,[this,ke,Ne].concat(Ge))};var zr=B;zr.prototype.premultiply=function(ke){ke===void 0&&(ke=!1);var Ne=this._rgb,Ge=Ne[3];return ke?(this._rgb=[Ne[0]*Ge,Ne[1]*Ge,Ne[2]*Ge,Ge],this):new zr([Ne[0]*Ge,Ne[1]*Ge,Ne[2]*Ge,Ge],"rgb")};var ii=B,Jo=Ot;ii.prototype.saturate=function(ke){ke===void 0&&(ke=1);var Ne=this,Ge=Ne.lch();return Ge[1]+=Jo.Kn*ke,Ge[1]<0&&(Ge[1]=0),new ii(Ge,"lch").alpha(Ne.alpha(),!0)},ii.prototype.desaturate=function(ke){return ke===void 0&&(ke=1),this.saturate(-ke)};var oo=B,ao=T.type;oo.prototype.set=function(ke,Ne,Ge){Ge===void 0&&(Ge=!1);var ot=ke.split("."),dt=ot[0],ft=ot[1],ht=this[dt]();if(ft){var mt=dt.indexOf(ft)-(dt.substr(0,2)==="ok"?2:0);if(mt>-1){if(ao(Ne)=="string")switch(Ne.charAt(0)){case"+":ht[mt]+=+Ne;break;case"-":ht[mt]+=+Ne;break;case"*":ht[mt]*=+Ne.substr(1);break;case"/":ht[mt]/=+Ne.substr(1);break;default:ht[mt]=+Ne}else if(ao(Ne)==="number")ht[mt]=Ne;else throw new Error("unsupported value for Color.set");var yt=new oo(ht,dt);return Ge?(this._rgb=yt._rgb,this):yt}throw new Error("unknown channel "+ft+" in mode "+dt)}else return ht};var lo=B,ea=function(ke,Ne,Ge){var ot=ke._rgb,dt=Ne._rgb;return new lo(ot[0]+Ge*(dt[0]-ot[0]),ot[1]+Ge*(dt[1]-ot[1]),ot[2]+Ge*(dt[2]-ot[2]),"rgb")};xt.rgb=ea;var uo=B,lr=Math.sqrt,Wr=Math.pow,ta=function(ke,Ne,Ge){var ot=ke._rgb,dt=ot[0],ft=ot[1],ht=ot[2],mt=Ne._rgb,yt=mt[0],wt=mt[1],Ct=mt[2];return new uo(lr(Wr(dt,2)*(1-Ge)+Wr(yt,2)*Ge),lr(Wr(ft,2)*(1-Ge)+Wr(wt,2)*Ge),lr(Wr(ht,2)*(1-Ge)+Wr(Ct,2)*Ge),"rgb")};xt.lrgb=ta;var ra=B,na=function(ke,Ne,Ge){var ot=ke.lab(),dt=Ne.lab();return new ra(ot[0]+Ge*(dt[0]-ot[0]),ot[1]+Ge*(dt[1]-ot[1]),ot[2]+Ge*(dt[2]-ot[2]),"lab")};xt.lab=na;var Pi=B,vn=function(ke,Ne,Ge,ot){var dt,ft,ht,mt;ot==="hsl"?(ht=ke.hsl(),mt=Ne.hsl()):ot==="hsv"?(ht=ke.hsv(),mt=Ne.hsv()):ot==="hcg"?(ht=ke.hcg(),mt=Ne.hcg()):ot==="hsi"?(ht=ke.hsi(),mt=Ne.hsi()):ot==="lch"||ot==="hcl"?(ot="hcl",ht=ke.hcl(),mt=Ne.hcl()):ot==="oklch"&&(ht=ke.oklch().reverse(),mt=Ne.oklch().reverse());var yt,wt,Ct,Pt,kt,It;(ot.substr(0,1)==="h"||ot==="oklch")&&(dt=ht,yt=dt[0],Ct=dt[1],kt=dt[2],ft=mt,wt=ft[0],Pt=ft[1],It=ft[2]);var $t,Ut,Wt,Yt;return!isNaN(yt)&&!isNaN(wt)?(wt>yt&&wt-yt>180?Yt=wt-(yt+360):wt180?Yt=wt+360-yt:Yt=wt-yt,Ut=yt+Ge*Yt):isNaN(yt)?isNaN(wt)?Ut=Number.NaN:(Ut=wt,(kt==1||kt==0)&&ot!="hsv"&&($t=Pt)):(Ut=yt,(It==1||It==0)&&ot!="hsv"&&($t=Ct)),$t===void 0&&($t=Ct+Ge*(Pt-Ct)),Wt=kt+Ge*(It-kt),ot==="oklch"?new Pi([Wt,$t,Ut],ot):new Pi([Ut,$t,Wt],ot)},ia=vn,xa=function(ke,Ne,Ge){return ia(ke,Ne,Ge,"lch")};xt.lch=xa,xt.hcl=xa;var Wa=B,ja=function(ke,Ne,Ge){var ot=ke.num(),dt=Ne.num();return new Wa(ot+Ge*(dt-ot),"num")};xt.num=ja;var Ka=vn,Ya=function(ke,Ne,Ge){return Ka(ke,Ne,Ge,"hcg")};xt.hcg=Ya;var Ga=vn,qa=function(ke,Ne,Ge){return Ga(ke,Ne,Ge,"hsi")};xt.hsi=qa;var Za=vn,Xa=function(ke,Ne,Ge){return Za(ke,Ne,Ge,"hsl")};xt.hsl=Xa;var Qa=vn,Ja=function(ke,Ne,Ge){return Qa(ke,Ne,Ge,"hsv")};xt.hsv=Ja;var el=B,tl=function(ke,Ne,Ge){var ot=ke.oklab(),dt=Ne.oklab();return new el(ot[0]+Ge*(dt[0]-ot[0]),ot[1]+Ge*(dt[1]-ot[1]),ot[2]+Ge*(dt[2]-ot[2]),"oklab")};xt.oklab=tl;var rl=vn,nl=function(ke,Ne,Ge){return rl(ke,Ne,Ge,"oklch")};xt.oklch=nl;var sa=B,il=T.clip_rgb,oa=Math.pow,aa=Math.sqrt,la=Math.PI,Ea=Math.cos,Sa=Math.sin,sl=Math.atan2,ol=function(ke,Ne,Ge){Ne===void 0&&(Ne="lrgb"),Ge===void 0&&(Ge=null);var ot=ke.length;Ge||(Ge=Array.from(new Array(ot)).map(function(){return 1}));var dt=ot/Ge.reduce(function(Ut,Wt){return Ut+Wt});if(Ge.forEach(function(Ut,Wt){Ge[Wt]*=dt}),ke=ke.map(function(Ut){return new sa(Ut)}),Ne==="lrgb")return al(ke,Ge);for(var ft=ke.shift(),ht=ft.get(Ne),mt=[],yt=0,wt=0,Ct=0;Ct=360;)$t-=360;ht[It]=$t}else ht[It]=ht[It]/mt[It];return kt/=ot,new sa(ht,Ne).alpha(kt>.99999?1:kt,!0)},al=function(ke,Ne){for(var Ge=ke.length,ot=[0,0,0,0],dt=0;dt.9999999&&(ot[3]=1),new sa(il(ot))},jr=fe,$i=T.type,ll=Math.pow,ca=function(ke){var Ne="rgb",Ge=jr("#ccc"),ot=0,dt=[0,1],ft=[],ht=[0,0],mt=!1,yt=[],wt=!1,Ct=0,Pt=1,kt=!1,It={},$t=!0,Ut=1,Wt=function(At){if(At=At||["#fff","#000"],At&&$i(At)==="string"&&jr.brewer&&jr.brewer[At.toLowerCase()]&&(At=jr.brewer[At.toLowerCase()]),$i(At)==="array"){At.length===1&&(At=[At[0],At[0]]),At=At.slice(0);for(var Rt=0;Rt=mt[Ht];)Ht++;return Ht-1}return 0},Xt=function(At){return At},br=function(At){return At},_r=function(At,Rt){var Ht,Vt;if(Rt==null&&(Rt=!1),isNaN(At)||At===null)return Ge;if(Rt)Vt=At;else if(mt&&mt.length>2){var wr=Yt(At);Vt=wr/(mt.length-2)}else Pt!==Ct?Vt=(At-Ct)/(Pt-Ct):Vt=1;Vt=br(Vt),Rt||(Vt=Xt(Vt)),Ut!==1&&(Vt=ll(Vt,Ut)),Vt=ht[0]+Vt*(1-ht[0]-ht[1]),Vt=Math.min(1,Math.max(0,Vt));var sr=Math.floor(Vt*1e4);if($t&&It[sr])Ht=It[sr];else{if($i(yt)==="array")for(var Gt=0;Gt=Qt&&Gt===ft.length-1){Ht=yt[Gt];break}if(Vt>Qt&&Vt2){var Gt=At.map(function(Jt,er){return er/(At.length-1)}),Qt=At.map(function(Jt){return(Jt-Ct)/(Pt-Ct)});Qt.every(function(Jt,er){return Gt[er]===Jt})||(br=function(Jt){if(Jt<=0||Jt>=1)return Jt;for(var er=0;Jt>=Qt[er+1];)er++;var Yr=(Jt-Qt[er])/(Qt[er+1]-Qt[er]),$n=Gt[er]+Yr*(Gt[er+1]-Gt[er]);return $n})}}return dt=[Ct,Pt],jt},jt.mode=function(At){return arguments.length?(Ne=At,Tr(),jt):Ne},jt.range=function(At,Rt){return Wt(At),jt},jt.out=function(At){return wt=At,jt},jt.spread=function(At){return arguments.length?(ot=At,jt):ot},jt.correctLightness=function(At){return At==null&&(At=!0),kt=At,Tr(),kt?Xt=function(Rt){for(var Ht=_r(0,!0).lab()[0],Vt=_r(1,!0).lab()[0],wr=Ht>Vt,sr=_r(Rt,!0).lab()[0],Gt=Ht+(Vt-Ht)*Rt,Qt=sr-Gt,Jt=0,er=1,Yr=20;Math.abs(Qt)>.01&&Yr-- >0;)(function(){return wr&&(Qt*=-1),Qt<0?(Jt=Rt,Rt+=(er-Rt)*.5):(er=Rt,Rt+=(Jt-Rt)*.5),sr=_r(Rt,!0).lab()[0],Qt=sr-Gt})();return Rt}:Xt=function(Rt){return Rt},jt},jt.padding=function(At){return At!=null?($i(At)==="number"&&(At=[At,At]),ht=At,jt):ht},jt.colors=function(At,Rt){arguments.length<2&&(Rt="hex");var Ht=[];if(arguments.length===0)Ht=yt.slice(0);else if(At===1)Ht=[jt(.5)];else if(At>1){var Vt=dt[0],wr=dt[1]-Vt;Ht=cl(0,At,!1).map(function(er){return jt(Vt+er/(At-1)*wr)})}else{ke=[];var sr=[];if(mt&&mt.length>2)for(var Gt=1,Qt=mt.length,Jt=1<=Qt;Jt?GtQt;Jt?Gt++:Gt--)sr.push((mt[Gt-1]+mt[Gt])*.5);else sr=dt;Ht=sr.map(function(er){return jt(er)})}return jr[Rt]&&(Ht=Ht.map(function(er){return er[Rt]()})),Ht},jt.cache=function(At){return At!=null?($t=At,jt):$t},jt.gamma=function(At){return At!=null?(Ut=At,jt):Ut},jt.nodata=function(At){return At!=null?(Ge=jr(At),jt):Ge},jt};function cl(ke,Ne,Ge){for(var ot=[],dt=keft;dt?ht++:ht--)ot.push(ht);return ot}var us=B,ul=ca,hl=function(ke){for(var Ne=[1,1],Ge=1;Ge=5){var wt,Ct,Pt;wt=ke.map(function(kt){return kt.lab()}),Pt=ke.length-1,Ct=hl(Pt),dt=function(kt){var It=1-kt,$t=[0,1,2].map(function(Ut){return wt.reduce(function(Wt,Yt,Xt){return Wt+Ct[Xt]*Math.pow(It,Pt-Xt)*Math.pow(kt,Xt)*Yt[Ut]},0)});return new us($t,"lab")}}else throw new RangeError("No point in running bezier with only one color.");return dt},fl=function(ke){var Ne=dl(ke);return Ne.scale=function(){return ul(Ne)},Ne},ua=fe,Kr=function(ke,Ne,Ge){if(!Kr[Ge])throw new Error("unknown blend mode "+Ge);return Kr[Ge](ke,Ne)},Tn=function(ke){return function(Ne,Ge){var ot=ua(Ge).rgb(),dt=ua(Ne).rgb();return ua.rgb(ke(ot,dt))}},Pn=function(ke){return function(Ne,Ge){var ot=[];return ot[0]=ke(Ne[0],Ge[0]),ot[1]=ke(Ne[1],Ge[1]),ot[2]=ke(Ne[2],Ge[2]),ot}},pl=function(ke){return ke},ml=function(ke,Ne){return ke*Ne/255},gl=function(ke,Ne){return ke>Ne?Ne:ke},yl=function(ke,Ne){return ke>Ne?ke:Ne},_l=function(ke,Ne){return 255*(1-(1-ke/255)*(1-Ne/255))},vl=function(ke,Ne){return Ne<128?2*ke*Ne/255:255*(1-2*(1-ke/255)*(1-Ne/255))},bl=function(ke,Ne){return 255*(1-(1-Ne/255)/(ke/255))},wl=function(ke,Ne){return ke===255?255:(ke=255*(Ne/255)/(1-ke/255),ke>255?255:ke)};Kr.normal=Tn(Pn(pl)),Kr.multiply=Tn(Pn(ml)),Kr.screen=Tn(Pn(_l)),Kr.overlay=Tn(Pn(vl)),Kr.darken=Tn(Pn(gl)),Kr.lighten=Tn(Pn(yl)),Kr.dodge=Tn(Pn(wl)),Kr.burn=Tn(Pn(bl));for(var xl=Kr,ha=T.type,El=T.clip_rgb,Sl=T.TWOPI,Cl=Math.pow,kl=Math.sin,Al=Math.cos,Ca=fe,Tl=function(ke,Ne,Ge,ot,dt){ke===void 0&&(ke=300),Ne===void 0&&(Ne=-1.5),Ge===void 0&&(Ge=1),ot===void 0&&(ot=1),dt===void 0&&(dt=[0,1]);var ft=0,ht;ha(dt)==="array"?ht=dt[1]-dt[0]:(ht=0,dt=[dt,dt]);var mt=function(yt){var wt=Sl*((ke+120)/360+Ne*yt),Ct=Cl(dt[0]+ht*yt,ot),Pt=ft!==0?Ge[0]+yt*ft:Ge,kt=Pt*Ct*(1-Ct)/2,It=Al(wt),$t=kl(wt),Ut=Ct+kt*(-.14861*It+1.78277*$t),Wt=Ct+kt*(-.29227*It-.90649*$t),Yt=Ct+kt*(1.97294*It);return Ca(El([Ut*255,Wt*255,Yt*255,1]))};return mt.start=function(yt){return yt==null?ke:(ke=yt,mt)},mt.rotations=function(yt){return yt==null?Ne:(Ne=yt,mt)},mt.gamma=function(yt){return yt==null?ot:(ot=yt,mt)},mt.hue=function(yt){return yt==null?Ge:(Ge=yt,ha(Ge)==="array"?(ft=Ge[1]-Ge[0],ft===0&&(Ge=Ge[1])):ft=0,mt)},mt.lightness=function(yt){return yt==null?dt:(ha(yt)==="array"?(dt=yt,ht=yt[1]-yt[0]):(dt=[yt,yt],ht=0),mt)},mt.scale=function(){return Ca.scale(mt)},mt.hue(Ge),mt},Pl=B,$l="0123456789abcdef",Il=Math.floor,Ll=Math.random,Rl=function(){for(var ke="#",Ne=0;Ne<6;Ne++)ke+=$l.charAt(Il(Ll()*16));return new Pl(ke,"hex")},da=g,ka=Math.log,Ml=Math.pow,Ol=Math.floor,Dl=Math.abs,Aa=function(ke,Ne){Ne===void 0&&(Ne=null);var Ge={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return da(ke)==="object"&&(ke=Object.values(ke)),ke.forEach(function(ot){Ne&&da(ot)==="object"&&(ot=ot[Ne]),ot!=null&&!isNaN(ot)&&(Ge.values.push(ot),Ge.sum+=ot,otGe.max&&(Ge.max=ot),Ge.count+=1)}),Ge.domain=[Ge.min,Ge.max],Ge.limits=function(ot,dt){return Ta(Ge,ot,dt)},Ge},Ta=function(ke,Ne,Ge){Ne===void 0&&(Ne="equal"),Ge===void 0&&(Ge=7),da(ke)=="array"&&(ke=Aa(ke));var ot=ke.min,dt=ke.max,ft=ke.values.sort(function(pa,ma){return pa-ma});if(Ge===1)return[ot,dt];var ht=[];if(Ne.substr(0,1)==="c"&&(ht.push(ot),ht.push(dt)),Ne.substr(0,1)==="e"){ht.push(ot);for(var mt=1;mt 0");var yt=Math.LOG10E*ka(ot),wt=Math.LOG10E*ka(dt);ht.push(ot);for(var Ct=1;Ct200&&(br=!1)}for(var In={},Ii=0;Iiot?(Ge+.05)/(ot+.05):(ot+.05)/(Ge+.05)},Ia=B,bn=Math.sqrt,pr=Math.pow,Bl=Math.min,Fl=Math.max,La=Math.atan2,Ra=Math.abs,ho=Math.cos,Ma=Math.sin,Ul=Math.exp,Oa=Math.PI,Vl=function(ke,Ne,Ge,ot,dt){Ge===void 0&&(Ge=1),ot===void 0&&(ot=1),dt===void 0&&(dt=1);var ft=function(oi){return 360*oi/(2*Oa)},ht=function(oi){return 2*Oa*oi/360};ke=new Ia(ke),Ne=new Ia(Ne);var mt=Array.from(ke.lab()),yt=mt[0],wt=mt[1],Ct=mt[2],Pt=Array.from(Ne.lab()),kt=Pt[0],It=Pt[1],$t=Pt[2],Ut=(yt+kt)/2,Wt=bn(pr(wt,2)+pr(Ct,2)),Yt=bn(pr(It,2)+pr($t,2)),Xt=(Wt+Yt)/2,br=.5*(1-bn(pr(Xt,7)/(pr(Xt,7)+pr(25,7)))),_r=wt*(1+br),Tr=It*(1+br),jt=bn(pr(_r,2)+pr(Ct,2)),At=bn(pr(Tr,2)+pr($t,2)),Rt=(jt+At)/2,Ht=ft(La(Ct,_r)),Vt=ft(La($t,Tr)),wr=Ht>=0?Ht:Ht+360,sr=Vt>=0?Vt:Vt+360,Gt=Ra(wr-sr)>180?(wr+sr+360)/2:(wr+sr)/2,Qt=1-.17*ho(ht(Gt-30))+.24*ho(ht(2*Gt))+.32*ho(ht(3*Gt+6))-.2*ho(ht(4*Gt-63)),Jt=sr-wr;Jt=Ra(Jt)<=180?Jt:sr<=wr?Jt+360:Jt-360,Jt=2*bn(jt*At)*Ma(ht(Jt)/2);var er=kt-yt,Yr=At-jt,$n=1+.015*pr(Ut-50,2)/bn(20+pr(Ut-50,2)),In=1+.045*Rt,Ii=1+.015*Rt*Qt,Li=30*Ul(-pr((Gt-275)/25,2)),wn=2*bn(pr(Rt,7)/(pr(Rt,7)+pr(25,7))),si=-wn*Ma(2*ht(Li)),hs=bn(pr(er/(Ge*$n),2)+pr(Yr/(ot*In),2)+pr(Jt/(dt*Ii),2)+si*(Yr/(ot*In))*(Jt/(dt*Ii)));return Fl(0,Bl(100,hs))},Da=B,Hl=function(ke,Ne,Ge){Ge===void 0&&(Ge="lab"),ke=new Da(ke),Ne=new Da(Ne);var ot=ke.get(Ge),dt=Ne.get(Ge),ft=0;for(var ht in ot){var mt=(ot[ht]||0)-(dt[ht]||0);ft+=mt*mt}return Math.sqrt(ft)},zl=B,Wl=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];try{return new(Function.prototype.bind.apply(zl,[null].concat(ke))),!0}catch{return!1}},Na=fe,Ba=ca,jl={cool:function(){return Ba([Na.hsl(180,1,.9),Na.hsl(250,.7,.4)])},hot:function(){return Ba(["#000","#f00","#ff0","#fff"]).mode("rgb")}},fo={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},fa=0,Fa=Object.keys(fo);fal===o);if(r[a])return r[a]}return r[r.length-1]}const markerIcon2x="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==",markerIcon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",markerShadow="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",queue=new queue$1;let scale,markersLayer,pathsLayer,moveLayer,handlerClickMarker;delete L$2.Icon.Default.prototype._getIconUrl;L$2.Icon.Default.mergeOptions({iconRetinaUrl:markerIcon2x,iconUrl:markerIcon,shadowUrl:markerShadow});const messageTypes={0:"text",1:"air",2:"garbage",3:"water",4:"fire",5:"forest",6:"alert ",7:"notif",8:"recycle",9:"parking",42:"gank"};let messageIconName={},messageIconType={};const messagesLayers=Object.values(messageTypes).reduce((e,t)=>(e[t]=null,e),{});async function init$2(e,t,r){for(const o of Object.keys(messageTypes)){try{messageIconType[o]=(await __variableDynamicImportRuntimeHelper(Object.assign({"../../assets/message/msg-air.png":()=>__vitePreload(()=>import("./msg-air.abb754d3.js"),[]),"../../assets/message/msg-alert.png":()=>__vitePreload(()=>import("./msg-alert.9404c396.js"),[]),"../../assets/message/msg-fire.png":()=>__vitePreload(()=>import("./msg-fire.faa011b0.js"),[]),"../../assets/message/msg-forest.png":()=>__vitePreload(()=>import("./msg-forest.a623a1f9.js"),[]),"../../assets/message/msg-gank.png":()=>__vitePreload(()=>import("./msg-gank.34a748fe.js"),[]),"../../assets/message/msg-garbage.png":()=>__vitePreload(()=>import("./msg-garbage.b797b882.js"),[]),"../../assets/message/msg-notif.png":()=>__vitePreload(()=>import("./msg-notif.d72c5a6f.js"),[]),"../../assets/message/msg-parking.png":()=>__vitePreload(()=>import("./msg-parking.5da4fdeb.js"),[]),"../../assets/message/msg-recycle.png":()=>__vitePreload(()=>import("./msg-recycle.eab79c00.js"),[]),"../../assets/message/msg-text.png":()=>__vitePreload(()=>import("./msg-text.470fee8d.js"),[]),"../../assets/message/msg-water.png":()=>__vitePreload(()=>import("./msg-water.b0066085.js"),[])}),`../../assets/message/msg-${messageTypes[o]}.png`)).default}catch{messageIconType[o]=(await __vitePreload(()=>import("./msg-text.470fee8d.js"),[])).default}messageIconName[messageTypes[o]]=messageIconType[o]}handlerClickMarker=o=>{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?e.setActiveArea({position:"absolute",top:"90px",left:"0px",right:"0px",height:"20%"}):e.setActiveArea({position:"absolute",top:"0px",left:"0px",right:"50%",height:"100%"}),e.panTo(o.latlng),r(o.target.options.data)};const n=getMeasurementByName(t);scale=generate$1(n.colors,n.range),markersLayer=new L$2.MarkerClusterGroup({showCoverageOnHover:!1,maxClusterRadius:120,iconCreateFunction:iconCreate}),e.addLayer(markersLayer),pathsLayer=new L$2.layerGroup,e.addLayer(pathsLayer),moveLayer=new L$2.layerGroup,e.addLayer(moveLayer);for(const o of Object.values(messageTypes))messagesLayers[o]=new L$2.MarkerClusterGroup({showCoverageOnHover:!1,maxClusterRadius:120,iconCreateFunction:a=>iconCreateMsg(a,o)});for(const o of Object.values(messagesLayers))e.addLayer(o)}function isReadyLayers(){return!!(markersLayer&&pathsLayer&&moveLayer)}function iconCreate(e){const t=e.getAllChildMarkers(),r=e.getChildCount();let n=0,o=0;t.forEach(u=>{u.options.data.value===void 0&&u.options.data.value!==""||(n++,o+=Number(u.options.data.value))}),n>0&&(o=o/n);const a=getColorRGB(scale,o),l=getColorDarkenRGB(scale,o),c=scale(o).luminance()<.4;return new L$2.DivIcon({html:`
${r}
`,className:"marker-cluster",iconSize:new L$2.Point(40,40)})}function iconCreateMsg(e,t="text"){const r=e.getChildCount();return new L$2.DivIcon({html:`
${r}
`,className:"marker-cluster",iconSize:new L$2.Point(40,40)})}function findMarker(e){return new Promise(t=>{markersLayer&&markersLayer.eachLayer(r=>{r.options.data.sensor_id===e&&t(r)}),t(!1)})}function createIconBrand(e,t){return L$2.divIcon({html:``,iconSize:[40,40],className:"marker-icon"})}function createIconMsg(e=0){return L$2.divIcon({html:``,iconSize:[40,40],className:"marker-icon"})}function createIconArrow(e,t,r){return L$2.divIcon({className:"",html:`
+ */(function(e,t){(function(r,n){e.exports=n()})(commonjsGlobal$2,function(){for(var r=function(ke,Ne,Ge){return Ne===void 0&&(Ne=0),Ge===void 0&&(Ge=1),keGe?Ge:ke},n=r,o=function(ke){ke._clipped=!1,ke._unclipped=ke.slice(0);for(var Ne=0;Ne<=3;Ne++)Ne<3?((ke[Ne]<0||ke[Ne]>255)&&(ke._clipped=!0),ke[Ne]=n(ke[Ne],0,255)):Ne===3&&(ke[Ne]=n(ke[Ne],0,1));return ke},a={},l=0,c=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];l=3?Array.prototype.slice.call(ke):b(ke[0])=="object"&&Ne?Ne.split("").filter(function(Ge){return ke[0][Ge]!==void 0}).map(function(Ge){return ke[0][Ge]}):ke[0]},S=g,$=function(ke){if(ke.length<2)return null;var Ne=ke.length-1;return S(ke[Ne])=="string"?ke[Ne].toLowerCase():null},k=Math.PI,T={clip_rgb:o,limit:r,type:g,unpack:x,last:$,PI:k,TWOPI:k*2,PITHIRD:k/3,DEG2RAD:k/180,RAD2DEG:180/k},D={format:{},autodetect:[]},I=T.last,O=T.clip_rgb,N=T.type,ee=D,ne=function(){for(var Ne=[],Ge=arguments.length;Ge--;)Ne[Ge]=arguments[Ge];var ot=this;if(N(Ne[0])==="object"&&Ne[0].constructor&&Ne[0].constructor===this.constructor)return Ne[0];var dt=I(Ne),ft=!1;if(!dt){ft=!0,ee.sorted||(ee.autodetect=ee.autodetect.sort(function(Ct,Pt){return Pt.p-Ct.p}),ee.sorted=!0);for(var ht=0,mt=ee.autodetect;ht4?ke[4]:1;return ft===1?[0,0,0,ht]:[Ge>=1?0:255*(1-Ge)*(1-ft),ot>=1?0:255*(1-ot)*(1-ft),dt>=1?0:255*(1-dt)*(1-ft),ht]},ie=ae,pe=fe,ue=B,ge=D,ye=T.unpack,Ae=T.type,Re=_e;ue.prototype.cmyk=function(){return Re(this._rgb)},pe.cmyk=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(ue,[null].concat(ke,["cmyk"])))},ge.format.cmyk=ie,ge.autodetect.push({p:2,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=ye(ke,"cmyk"),Ae(ke)==="array"&&ke.length===4)return"cmyk"}});var We=T.unpack,Pe=T.last,Ue=function(ke){return Math.round(ke*100)/100},Oe=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=We(ke,"hsla"),ot=Pe(ke)||"lsa";return Ge[0]=Ue(Ge[0]||0),Ge[1]=Ue(Ge[1]*100)+"%",Ge[2]=Ue(Ge[2]*100)+"%",ot==="hsla"||Ge.length>3&&Ge[3]<1?(Ge[3]=Ge.length>3?Ge[3]:1,ot="hsla"):Ge.length=3,ot+"("+Ge.join(",")+")"},Be=Oe,Ye=T.unpack,Se=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=Ye(ke,"rgba");var Ge=ke[0],ot=ke[1],dt=ke[2];Ge/=255,ot/=255,dt/=255;var ft=Math.min(Ge,ot,dt),ht=Math.max(Ge,ot,dt),mt=(ht+ft)/2,yt,wt;return ht===ft?(yt=0,wt=Number.NaN):yt=mt<.5?(ht-ft)/(ht+ft):(ht-ft)/(2-ht-ft),Ge==ht?wt=(ot-dt)/(ht-ft):ot==ht?wt=2+(dt-Ge)/(ht-ft):dt==ht&&(wt=4+(Ge-ot)/(ht-ft)),wt*=60,wt<0&&(wt+=360),ke.length>3&&ke[3]!==void 0?[wt,yt,mt,ke[3]]:[wt,yt,mt]},Te=Se,$e=T.unpack,Ve=T.last,oe=Be,te=Te,se=Math.round,me=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=$e(ke,"rgba"),ot=Ve(ke)||"rgb";return ot.substr(0,3)=="hsl"?oe(te(Ge),ot):(Ge[0]=se(Ge[0]),Ge[1]=se(Ge[1]),Ge[2]=se(Ge[2]),(ot==="rgba"||Ge.length>3&&Ge[3]<1)&&(Ge[3]=Ge.length>3?Ge[3]:1,ot="rgba"),ot+"("+Ge.slice(0,ot==="rgb"?3:4).join(",")+")")},Ee=me,Le=T.unpack,He=Math.round,ze=function(){for(var ke,Ne=[],Ge=arguments.length;Ge--;)Ne[Ge]=arguments[Ge];Ne=Le(Ne,"hsl");var ot=Ne[0],dt=Ne[1],ft=Ne[2],ht,mt,yt;if(dt===0)ht=mt=yt=ft*255;else{var wt=[0,0,0],Ct=[0,0,0],Pt=ft<.5?ft*(1+dt):ft+dt-ft*dt,kt=2*ft-Pt,It=ot/360;wt[0]=It+1/3,wt[1]=It,wt[2]=It-1/3;for(var $t=0;$t<3;$t++)wt[$t]<0&&(wt[$t]+=1),wt[$t]>1&&(wt[$t]-=1),6*wt[$t]<1?Ct[$t]=kt+(Pt-kt)*6*wt[$t]:2*wt[$t]<1?Ct[$t]=Pt:3*wt[$t]<2?Ct[$t]=kt+(Pt-kt)*(2/3-wt[$t])*6:Ct[$t]=kt;ke=[He(Ct[0]*255),He(Ct[1]*255),He(Ct[2]*255)],ht=ke[0],mt=ke[1],yt=ke[2]}return Ne.length>3?[ht,mt,yt,Ne[3]]:[ht,mt,yt,1]},Qe=ze,rt=Qe,Ke=D,Ie=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,Fe=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,je=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,Ze=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Ce=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,ce=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,de=Math.round,De=function(ke){ke=ke.toLowerCase().trim();var Ne;if(Ke.format.named)try{return Ke.format.named(ke)}catch{}if(Ne=ke.match(Ie)){for(var Ge=Ne.slice(1,4),ot=0;ot<3;ot++)Ge[ot]=+Ge[ot];return Ge[3]=1,Ge}if(Ne=ke.match(Fe)){for(var dt=Ne.slice(1,5),ft=0;ft<4;ft++)dt[ft]=+dt[ft];return dt}if(Ne=ke.match(je)){for(var ht=Ne.slice(1,4),mt=0;mt<3;mt++)ht[mt]=de(ht[mt]*2.55);return ht[3]=1,ht}if(Ne=ke.match(Ze)){for(var yt=Ne.slice(1,5),wt=0;wt<3;wt++)yt[wt]=de(yt[wt]*2.55);return yt[3]=+yt[3],yt}if(Ne=ke.match(Ce)){var Ct=Ne.slice(1,4);Ct[1]*=.01,Ct[2]*=.01;var Pt=rt(Ct);return Pt[3]=1,Pt}if(Ne=ke.match(ce)){var kt=Ne.slice(1,4);kt[1]*=.01,kt[2]*=.01;var It=rt(kt);return It[3]=+Ne[4],It}};De.test=function(ke){return Ie.test(ke)||Fe.test(ke)||je.test(ke)||Ze.test(ke)||Ce.test(ke)||ce.test(ke)};var qe=De,nt=fe,lt=B,pt=D,bt=T.type,St=Ee,Et=qe;lt.prototype.css=function(ke){return St(this._rgb,ke)},nt.css=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(lt,[null].concat(ke,["css"])))},pt.format.css=Et,pt.autodetect.push({p:5,test:function(ke){for(var Ne=[],Ge=arguments.length-1;Ge-- >0;)Ne[Ge]=arguments[Ge+1];if(!Ne.length&&bt(ke)==="string"&&Et.test(ke))return"css"}});var vt=B,Nt=fe,Ft=D,qt=T.unpack;Ft.format.gl=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=qt(ke,"rgba");return Ge[0]*=255,Ge[1]*=255,Ge[2]*=255,Ge},Nt.gl=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(vt,[null].concat(ke,["gl"])))},vt.prototype.gl=function(){var ke=this._rgb;return[ke[0]/255,ke[1]/255,ke[2]/255,ke[3]]};var Zt=T.unpack,mr=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Zt(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=Math.min(ot,dt,ft),mt=Math.max(ot,dt,ft),yt=mt-ht,wt=yt*100/255,Ct=ht/(255-yt)*100,Pt;return yt===0?Pt=Number.NaN:(ot===mt&&(Pt=(dt-ft)/yt),dt===mt&&(Pt=2+(ft-ot)/yt),ft===mt&&(Pt=4+(ot-dt)/yt),Pt*=60,Pt<0&&(Pt+=360)),[Pt,wt,Ct]},nr=mr,ur=T.unpack,Mr=Math.floor,Pr=function(){for(var ke,Ne,Ge,ot,dt,ft,ht=[],mt=arguments.length;mt--;)ht[mt]=arguments[mt];ht=ur(ht,"hcg");var yt=ht[0],wt=ht[1],Ct=ht[2],Pt,kt,It;Ct=Ct*255;var $t=wt*255;if(wt===0)Pt=kt=It=Ct;else{yt===360&&(yt=0),yt>360&&(yt-=360),yt<0&&(yt+=360),yt/=60;var Ut=Mr(yt),Wt=yt-Ut,Yt=Ct*(1-wt),Xt=Yt+$t*(1-Wt),br=Yt+$t*Wt,_r=Yt+$t;switch(Ut){case 0:ke=[_r,br,Yt],Pt=ke[0],kt=ke[1],It=ke[2];break;case 1:Ne=[Xt,_r,Yt],Pt=Ne[0],kt=Ne[1],It=Ne[2];break;case 2:Ge=[Yt,_r,br],Pt=Ge[0],kt=Ge[1],It=Ge[2];break;case 3:ot=[Yt,Xt,_r],Pt=ot[0],kt=ot[1],It=ot[2];break;case 4:dt=[br,Yt,_r],Pt=dt[0],kt=dt[1],It=dt[2];break;case 5:ft=[_r,Yt,Xt],Pt=ft[0],kt=ft[1],It=ft[2];break}}return[Pt,kt,It,ht.length>3?ht[3]:1]},fr=Pr,hr=T.unpack,$r=T.type,Bi=fe,li=B,Mn=D,Sr=nr;li.prototype.hcg=function(){return Sr(this._rgb)},Bi.hcg=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(li,[null].concat(ke,["hcg"])))},Mn.format.hcg=fr,Mn.autodetect.push({p:1,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=hr(ke,"hcg"),$r(ke)==="array"&&ke.length===3)return"hcg"}});var Lt=T.unpack,On=T.last,Ur=Math.round,Dn=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Lt(ke,"rgba"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=Ge[3],mt=On(ke)||"auto";ht===void 0&&(ht=1),mt==="auto"&&(mt=ht<1?"rgba":"rgb"),ot=Ur(ot),dt=Ur(dt),ft=Ur(ft);var yt=ot<<16|dt<<8|ft,wt="000000"+yt.toString(16);wt=wt.substr(wt.length-6);var Ct="0"+Ur(ht*255).toString(16);switch(Ct=Ct.substr(Ct.length-2),mt.toLowerCase()){case"rgba":return"#"+wt+Ct;case"argb":return"#"+Ct+wt;default:return"#"+wt}},tn=Dn,rn=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,Nn=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,Ir=function(ke){if(ke.match(rn)){(ke.length===4||ke.length===7)&&(ke=ke.substr(1)),ke.length===3&&(ke=ke.split(""),ke=ke[0]+ke[0]+ke[1]+ke[1]+ke[2]+ke[2]);var Ne=parseInt(ke,16),Ge=Ne>>16,ot=Ne>>8&255,dt=Ne&255;return[Ge,ot,dt,1]}if(ke.match(Nn)){(ke.length===5||ke.length===9)&&(ke=ke.substr(1)),ke.length===4&&(ke=ke.split(""),ke=ke[0]+ke[0]+ke[1]+ke[1]+ke[2]+ke[2]+ke[3]+ke[3]);var ft=parseInt(ke,16),ht=ft>>24&255,mt=ft>>16&255,yt=ft>>8&255,wt=Math.round((ft&255)/255*100)/100;return[ht,mt,yt,wt]}throw new Error("unknown hex color: "+ke)},qr=Ir,ci=fe,nn=B,xo=T.type,_s=D,vs=tn;nn.prototype.hex=function(ke){return vs(this._rgb,ke)},ci.hex=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(nn,[null].concat(ke,["hex"])))},_s.format.hex=qr,_s.autodetect.push({p:4,test:function(ke){for(var Ne=[],Ge=arguments.length-1;Ge-- >0;)Ne[Ge]=arguments[Ge+1];if(!Ne.length&&xo(ke)==="string"&&[3,4,5,6,7,8,9].indexOf(ke.length)>=0)return"hex"}});var Eo=T.unpack,Bn=T.TWOPI,So=Math.min,Co=Math.sqrt,ko=Math.acos,Ao=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Eo(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2];ot/=255,dt/=255,ft/=255;var ht,mt=So(ot,dt,ft),yt=(ot+dt+ft)/3,wt=yt>0?1-mt/yt:0;return wt===0?ht=NaN:(ht=(ot-dt+(ot-ft))/2,ht/=Co((ot-dt)*(ot-dt)+(ot-ft)*(dt-ft)),ht=ko(ht),ft>dt&&(ht=Bn-ht),ht/=Bn),[ht*360,wt,yt]},To=Ao,Fi=T.unpack,sn=T.limit,an=T.TWOPI,ui=T.PITHIRD,Or=Math.cos,Kt=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=Fi(ke,"hsi");var Ge=ke[0],ot=ke[1],dt=ke[2],ft,ht,mt;return isNaN(Ge)&&(Ge=0),isNaN(ot)&&(ot=0),Ge>360&&(Ge-=360),Ge<0&&(Ge+=360),Ge/=360,Ge<1/3?(mt=(1-ot)/3,ft=(1+ot*Or(an*Ge)/Or(ui-an*Ge))/3,ht=1-(mt+ft)):Ge<2/3?(Ge-=1/3,ft=(1-ot)/3,ht=(1+ot*Or(an*Ge)/Or(ui-an*Ge))/3,mt=1-(ft+ht)):(Ge-=2/3,ht=(1-ot)/3,mt=(1+ot*Or(an*Ge)/Or(ui-an*Ge))/3,ft=1-(ht+mt)),ft=sn(dt*ft*3),ht=sn(dt*ht*3),mt=sn(dt*mt*3),[ft*255,ht*255,mt*255,ke.length>3?ke[3]:1]},ar=Kt,hi=T.unpack,En=T.type,Sn=fe,di=B,Bt=D,cr=To;di.prototype.hsi=function(){return cr(this._rgb)},Sn.hsi=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(di,[null].concat(ke,["hsi"])))},Bt.format.hsi=ar,Bt.autodetect.push({p:2,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=hi(ke,"hsi"),En(ke)==="array"&&ke.length===3)return"hsi"}});var Ui=T.unpack,fi=T.type,kr=fe,bs=B,Fn=D,ln=Te;bs.prototype.hsl=function(){return ln(this._rgb)},kr.hsl=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(bs,[null].concat(ke,["hsl"])))},Fn.format.hsl=Qe,Fn.autodetect.push({p:2,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Ui(ke,"hsl"),fi(ke)==="array"&&ke.length===3)return"hsl"}});var dr=T.unpack,cn=Math.min,Un=Math.max,Vn=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=dr(ke,"rgb");var Ge=ke[0],ot=ke[1],dt=ke[2],ft=cn(Ge,ot,dt),ht=Un(Ge,ot,dt),mt=ht-ft,yt,wt,Ct;return Ct=ht/255,ht===0?(yt=Number.NaN,wt=0):(wt=mt/ht,Ge===ht&&(yt=(ot-dt)/mt),ot===ht&&(yt=2+(dt-Ge)/mt),dt===ht&&(yt=4+(Ge-ot)/mt),yt*=60,yt<0&&(yt+=360)),[yt,wt,Ct]},Vi=Vn,Hn=T.unpack,Hi=Math.floor,zi=function(){for(var ke,Ne,Ge,ot,dt,ft,ht=[],mt=arguments.length;mt--;)ht[mt]=arguments[mt];ht=Hn(ht,"hsv");var yt=ht[0],wt=ht[1],Ct=ht[2],Pt,kt,It;if(Ct*=255,wt===0)Pt=kt=It=Ct;else{yt===360&&(yt=0),yt>360&&(yt-=360),yt<0&&(yt+=360),yt/=60;var $t=Hi(yt),Ut=yt-$t,Wt=Ct*(1-wt),Yt=Ct*(1-wt*Ut),Xt=Ct*(1-wt*(1-Ut));switch($t){case 0:ke=[Ct,Xt,Wt],Pt=ke[0],kt=ke[1],It=ke[2];break;case 1:Ne=[Yt,Ct,Wt],Pt=Ne[0],kt=Ne[1],It=Ne[2];break;case 2:Ge=[Wt,Ct,Xt],Pt=Ge[0],kt=Ge[1],It=Ge[2];break;case 3:ot=[Wt,Yt,Ct],Pt=ot[0],kt=ot[1],It=ot[2];break;case 4:dt=[Xt,Wt,Ct],Pt=dt[0],kt=dt[1],It=dt[2];break;case 5:ft=[Ct,Wt,Yt],Pt=ft[0],kt=ft[1],It=ft[2];break}}return[Pt,kt,It,ht.length>3?ht[3]:1]},pi=zi,Wi=T.unpack,ji=T.type,mi=fe,Ki=B,gi=D,Po=Vi;Ki.prototype.hsv=function(){return Po(this._rgb)},mi.hsv=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(Ki,[null].concat(ke,["hsv"])))},gi.format.hsv=pi,gi.autodetect.push({p:2,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Wi(ke,"hsv"),ji(ke)==="array"&&ke.length===3)return"hsv"}});var Ot={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},vr=Ot,tr=T.unpack,Yi=Math.pow,Gi=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=tr(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=un(ot,dt,ft),mt=ht[0],yt=ht[1],wt=ht[2],Ct=116*yt-16;return[Ct<0?0:Ct,500*(mt-yt),200*(yt-wt)]},zn=function(ke){return(ke/=255)<=.04045?ke/12.92:Yi((ke+.055)/1.055,2.4)},Wn=function(ke){return ke>vr.t3?Yi(ke,1/3):ke/vr.t2+vr.t0},un=function(ke,Ne,Ge){ke=zn(ke),Ne=zn(Ne),Ge=zn(Ge);var ot=Wn((.4124564*ke+.3575761*Ne+.1804375*Ge)/vr.Xn),dt=Wn((.2126729*ke+.7151522*Ne+.072175*Ge)/vr.Yn),ft=Wn((.0193339*ke+.119192*Ne+.9503041*Ge)/vr.Zn);return[ot,dt,ft]},yi=Gi,Dr=Ot,gr=T.unpack,hn=Math.pow,ws=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=gr(ke,"lab");var Ge=ke[0],ot=ke[1],dt=ke[2],ft,ht,mt,yt,wt,Ct;return ht=(Ge+16)/116,ft=isNaN(ot)?ht:ht+ot/500,mt=isNaN(dt)?ht:ht-dt/200,ht=Dr.Yn*qi(ht),ft=Dr.Xn*qi(ft),mt=Dr.Zn*qi(mt),yt=_i(3.2404542*ft-1.5371385*ht-.4985314*mt),wt=_i(-.969266*ft+1.8760108*ht+.041556*mt),Ct=_i(.0556434*ft-.2040259*ht+1.0572252*mt),[yt,wt,Ct,ke.length>3?ke[3]:1]},_i=function(ke){return 255*(ke<=.00304?12.92*ke:1.055*hn(ke,1/2.4)-.055)},qi=function(ke){return ke>Dr.t1?ke*ke*ke:Dr.t2*(ke-Dr.t0)},Zi=ws,Xi=T.unpack,$o=T.type,xs=fe,zt=B,Es=D,Lr=yi;zt.prototype.lab=function(){return Lr(this._rgb)},xs.lab=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(zt,[null].concat(ke,["lab"])))},Es.format.lab=Zi,Es.autodetect.push({p:2,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Xi(ke,"lab"),$o(ke)==="array"&&ke.length===3)return"lab"}});var jn=T.unpack,Ss=T.RAD2DEG,Io=Math.sqrt,Qi=Math.atan2,Lo=Math.round,Cs=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=jn(ke,"lab"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=Io(dt*dt+ft*ft),mt=(Qi(ft,dt)*Ss+360)%360;return Lo(ht*1e4)===0&&(mt=Number.NaN),[ot,ht,mt]},ks=Cs,Ro=T.unpack,Ji=yi,Mo=ks,Nr=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Ro(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=Ji(ot,dt,ft),mt=ht[0],yt=ht[1],wt=ht[2];return Mo(mt,yt,wt)},Oo=Nr,As=T.unpack,Zr=T.DEG2RAD,Ts=Math.sin,Ps=Math.cos,Do=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=As(ke,"lch"),ot=Ge[0],dt=Ge[1],ft=Ge[2];return isNaN(ft)&&(ft=0),ft=ft*Zr,[ot,Ps(ft)*dt,Ts(ft)*dt]},$s=Do,es=T.unpack,No=$s,Is=Zi,Ls=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=es(ke,"lch");var Ge=ke[0],ot=ke[1],dt=ke[2],ft=No(Ge,ot,dt),ht=ft[0],mt=ft[1],yt=ft[2],wt=Is(ht,mt,yt),Ct=wt[0],Pt=wt[1],kt=wt[2];return[Ct,Pt,kt,ke.length>3?ke[3]:1]},Kn=Ls,dn=T.unpack,Bo=Kn,Yn=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=dn(ke,"hcl").reverse();return Bo.apply(void 0,Ge)},Ar=Yn,Rs=T.unpack,Ms=T.type,Os=fe,Gn=B,vi=D,Ds=Oo;Gn.prototype.lch=function(){return Ds(this._rgb)},Gn.prototype.hcl=function(){return Ds(this._rgb).reverse()},Os.lch=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(Gn,[null].concat(ke,["lch"])))},Os.hcl=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(Gn,[null].concat(ke,["hcl"])))},vi.format.lch=Kn,vi.format.hcl=Ar,["lch","hcl"].forEach(function(ke){return vi.autodetect.push({p:2,test:function(){for(var Ne=[],Ge=arguments.length;Ge--;)Ne[Ge]=arguments[Ge];if(Ne=Rs(Ne,ke),Ms(Ne)==="array"&&Ne.length===3)return ke}})});var ts={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},bi=ts,Fo=B,Ns=D,Bs=T.type,qn=bi,Rr=qr,Cn=tn;Fo.prototype.name=function(){for(var ke=Cn(this._rgb,"rgb"),Ne=0,Ge=Object.keys(qn);Ne0;)Ne[Ge]=arguments[Ge+1];if(!Ne.length&&Bs(ke)==="string"&&qn[ke.toLowerCase()])return"named"}});var Uo=T.unpack,fn=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Uo(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2];return(ot<<16)+(dt<<8)+ft},Vo=fn,kn=T.type,Ho=function(ke){if(kn(ke)=="number"&&ke>=0&&ke<=16777215){var Ne=ke>>16,Ge=ke>>8&255,ot=ke&255;return[Ne,Ge,ot,1]}throw new Error("unknown num color: "+ke)},Zn=Ho,Fs=fe,Xn=B,Us=D,Xr=T.type,wi=Vo;Xn.prototype.num=function(){return wi(this._rgb)},Fs.num=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(Xn,[null].concat(ke,["num"])))},Us.format.num=Zn,Us.autodetect.push({p:5,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke.length===1&&Xr(ke[0])==="number"&&ke[0]>=0&&ke[0]<=16777215)return"num"}});var zo=fe,Qn=B,Vs=D,Br=T.unpack,Hs=T.type,pn=Math.round;Qn.prototype.rgb=function(ke){return ke===void 0&&(ke=!0),ke===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(pn)},Qn.prototype.rgba=function(ke){return ke===void 0&&(ke=!0),this._rgb.slice(0,4).map(function(Ne,Ge){return Ge<3?ke===!1?Ne:pn(Ne):Ne})},zo.rgb=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(Qn,[null].concat(ke,["rgb"])))},Vs.format.rgb=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Br(ke,"rgba");return Ge[3]===void 0&&(Ge[3]=1),Ge},Vs.autodetect.push({p:3,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Br(ke,"rgba"),Hs(ke)==="array"&&(ke.length===3||ke.length===4&&Hs(ke[3])=="number"&&ke[3]>=0&&ke[3]<=1))return"rgb"}});var xi=Math.log,Vr=function(ke){var Ne=ke/100,Ge,ot,dt;return Ne<66?(Ge=255,ot=Ne<6?0:-155.25485562709179-.44596950469579133*(ot=Ne-2)+104.49216199393888*xi(ot),dt=Ne<20?0:-254.76935184120902+.8274096064007395*(dt=Ne-10)+115.67994401066147*xi(dt)):(Ge=351.97690566805693+.114206453784165*(Ge=Ne-55)-40.25366309332127*xi(Ge),ot=325.4494125711974+.07943456536662342*(ot=Ne-50)-28.0852963507957*xi(ot),dt=255),[Ge,ot,dt,1]},Jn=Vr,zs=Jn,rs=T.unpack,Ei=Math.round,ns=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];for(var Ge=rs(ke,"rgb"),ot=Ge[0],dt=Ge[2],ft=1e3,ht=4e4,mt=.4,yt;ht-ft>mt;){yt=(ht+ft)*.5;var wt=zs(yt);wt[2]/wt[0]>=dt/ot?ht=yt:ft=yt}return Ei(yt)},Si=ns,Qr=fe,mn=B,ei=D,Ws=Si;mn.prototype.temp=mn.prototype.kelvin=mn.prototype.temperature=function(){return Ws(this._rgb)},Qr.temp=Qr.kelvin=Qr.temperature=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(mn,[null].concat(ke,["temp"])))},ei.format.temp=ei.format.kelvin=ei.format.temperature=Jn;var Wo=T.unpack,An=Math.cbrt,jo=Math.pow,js=Math.sign,Ko=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Wo(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=[ss(ot/255),ss(dt/255),ss(ft/255)],mt=ht[0],yt=ht[1],wt=ht[2],Ct=An(.4122214708*mt+.5363325363*yt+.0514459929*wt),Pt=An(.2119034982*mt+.6806995451*yt+.1073969566*wt),kt=An(.0883024619*mt+.2817188376*yt+.6299787005*wt);return[.2104542553*Ct+.793617785*Pt-.0040720468*kt,1.9779984951*Ct-2.428592205*Pt+.4505937099*kt,.0259040371*Ct+.7827717662*Pt-.808675766*kt]},is=Ko;function ss(ke){var Ne=Math.abs(ke);return Ne<.04045?ke/12.92:(js(ke)||1)*jo((Ne+.055)/1.055,2.4)}var Fr=T.unpack,gn=Math.pow,Yo=Math.sign,Ci=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=Fr(ke,"lab");var Ge=ke[0],ot=ke[1],dt=ke[2],ft=gn(Ge+.3963377774*ot+.2158037573*dt,3),ht=gn(Ge-.1055613458*ot-.0638541728*dt,3),mt=gn(Ge-.0894841775*ot-1.291485548*dt,3);return[255*ki(4.0767416621*ft-3.3077115913*ht+.2309699292*mt),255*ki(-1.2684380046*ft+2.6097574011*ht-.3413193965*mt),255*ki(-.0041960863*ft-.7034186147*ht+1.707614701*mt),ke.length>3?ke[3]:1]},Ks=Ci;function ki(ke){var Ne=Math.abs(ke);return Ne>.0031308?(Yo(ke)||1)*(1.055*gn(Ne,1/2.4)-.055):ke*12.92}var Go=T.unpack,ti=T.type,qo=fe,yn=B,os=D,Ys=is;yn.prototype.oklab=function(){return Ys(this._rgb)},qo.oklab=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(yn,[null].concat(ke,["oklab"])))},os.format.oklab=Ks,os.autodetect.push({p:3,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Go(ke,"oklab"),ti(ke)==="array"&&ke.length===3)return"oklab"}});var Zo=T.unpack,Hr=is,Gs=ks,qs=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];var Ge=Zo(ke,"rgb"),ot=Ge[0],dt=Ge[1],ft=Ge[2],ht=Hr(ot,dt,ft),mt=ht[0],yt=ht[1],wt=ht[2];return Gs(mt,yt,wt)},ri=qs,Xo=T.unpack,Ai=$s,ni=Ks,Zs=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];ke=Xo(ke,"lch");var Ge=ke[0],ot=ke[1],dt=ke[2],ft=Ai(Ge,ot,dt),ht=ft[0],mt=ft[1],yt=ft[2],wt=ni(ht,mt,yt),Ct=wt[0],Pt=wt[1],kt=wt[2];return[Ct,Pt,kt,ke.length>3?ke[3]:1]},Xs=Zs,Qo=T.unpack,Qs=T.type,Js=fe,ls=B,cs=D,eo=ri;ls.prototype.oklch=function(){return eo(this._rgb)},Js.oklch=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];return new(Function.prototype.bind.apply(ls,[null].concat(ke,["oklch"])))},cs.format.oklch=Xs,cs.autodetect.push({p:3,test:function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];if(ke=Qo(ke,"oklch"),Qs(ke)==="array"&&ke.length===3)return"oklch"}});var ro=B,no=T.type;ro.prototype.alpha=function(ke,Ne){return Ne===void 0&&(Ne=!1),ke!==void 0&&no(ke)==="number"?Ne?(this._rgb[3]=ke,this):new ro([this._rgb[0],this._rgb[1],this._rgb[2],ke],"rgb"):this._rgb[3]};var so=B;so.prototype.clipped=function(){return this._rgb._clipped||!1};var _n=B,_=Ot;_n.prototype.darken=function(ke){ke===void 0&&(ke=1);var Ne=this,Ge=Ne.lab();return Ge[0]-=_.Kn*ke,new _n(Ge,"lab").alpha(Ne.alpha(),!0)},_n.prototype.brighten=function(ke){return ke===void 0&&(ke=1),this.darken(-ke)},_n.prototype.darker=_n.prototype.darken,_n.prototype.brighter=_n.prototype.brighten;var E=B;E.prototype.get=function(ke){var Ne=ke.split("."),Ge=Ne[0],ot=Ne[1],dt=this[Ge]();if(ot){var ft=Ge.indexOf(ot)-(Ge.substr(0,2)==="ok"?2:0);if(ft>-1)return dt[ft];throw new Error("unknown channel "+ot+" in mode "+Ge)}else return dt};var H=B,be=T.type,Me=Math.pow,Je=1e-7,ct=20;H.prototype.luminance=function(ke){if(ke!==void 0&&be(ke)==="number"){if(ke===0)return new H([0,0,0,this._rgb[3]],"rgb");if(ke===1)return new H([255,255,255,this._rgb[3]],"rgb");var Ne=this.luminance(),Ge="rgb",ot=ct,dt=function(ht,mt){var yt=ht.interpolate(mt,.5,Ge),wt=yt.luminance();return Math.abs(ke-wt)ke?dt(ht,yt):dt(yt,mt)},ft=(Ne>ke?dt(new H([0,0,0]),this):dt(this,new H([255,255,255]))).rgb();return new H(ft.concat([this._rgb[3]]))}return gt.apply(void 0,this._rgb.slice(0,3))};var gt=function(ke,Ne,Ge){return ke=_t(ke),Ne=_t(Ne),Ge=_t(Ge),.2126*ke+.7152*Ne+.0722*Ge},_t=function(ke){return ke/=255,ke<=.03928?ke/12.92:Me((ke+.055)/1.055,2.4)},xt={},Tt=B,Mt=T.type,Dt=xt,Cr=function(ke,Ne,Ge){Ge===void 0&&(Ge=.5);for(var ot=[],dt=arguments.length-3;dt-- >0;)ot[dt]=arguments[dt+3];var ft=ot[0]||"lrgb";if(!Dt[ft]&&!ot.length&&(ft=Object.keys(Dt)[0]),!Dt[ft])throw new Error("interpolation mode "+ft+" is not defined");return Mt(ke)!=="object"&&(ke=new Tt(ke)),Mt(Ne)!=="object"&&(Ne=new Tt(Ne)),Dt[ft](ke,Ne,Ge).alpha(ke.alpha()+Ge*(Ne.alpha()-ke.alpha()))},Jr=B,Ti=Cr;Jr.prototype.mix=Jr.prototype.interpolate=function(ke,Ne){Ne===void 0&&(Ne=.5);for(var Ge=[],ot=arguments.length-2;ot-- >0;)Ge[ot]=arguments[ot+2];return Ti.apply(void 0,[this,ke,Ne].concat(Ge))};var zr=B;zr.prototype.premultiply=function(ke){ke===void 0&&(ke=!1);var Ne=this._rgb,Ge=Ne[3];return ke?(this._rgb=[Ne[0]*Ge,Ne[1]*Ge,Ne[2]*Ge,Ge],this):new zr([Ne[0]*Ge,Ne[1]*Ge,Ne[2]*Ge,Ge],"rgb")};var ii=B,Jo=Ot;ii.prototype.saturate=function(ke){ke===void 0&&(ke=1);var Ne=this,Ge=Ne.lch();return Ge[1]+=Jo.Kn*ke,Ge[1]<0&&(Ge[1]=0),new ii(Ge,"lch").alpha(Ne.alpha(),!0)},ii.prototype.desaturate=function(ke){return ke===void 0&&(ke=1),this.saturate(-ke)};var oo=B,ao=T.type;oo.prototype.set=function(ke,Ne,Ge){Ge===void 0&&(Ge=!1);var ot=ke.split("."),dt=ot[0],ft=ot[1],ht=this[dt]();if(ft){var mt=dt.indexOf(ft)-(dt.substr(0,2)==="ok"?2:0);if(mt>-1){if(ao(Ne)=="string")switch(Ne.charAt(0)){case"+":ht[mt]+=+Ne;break;case"-":ht[mt]+=+Ne;break;case"*":ht[mt]*=+Ne.substr(1);break;case"/":ht[mt]/=+Ne.substr(1);break;default:ht[mt]=+Ne}else if(ao(Ne)==="number")ht[mt]=Ne;else throw new Error("unsupported value for Color.set");var yt=new oo(ht,dt);return Ge?(this._rgb=yt._rgb,this):yt}throw new Error("unknown channel "+ft+" in mode "+dt)}else return ht};var lo=B,ea=function(ke,Ne,Ge){var ot=ke._rgb,dt=Ne._rgb;return new lo(ot[0]+Ge*(dt[0]-ot[0]),ot[1]+Ge*(dt[1]-ot[1]),ot[2]+Ge*(dt[2]-ot[2]),"rgb")};xt.rgb=ea;var uo=B,lr=Math.sqrt,Wr=Math.pow,ta=function(ke,Ne,Ge){var ot=ke._rgb,dt=ot[0],ft=ot[1],ht=ot[2],mt=Ne._rgb,yt=mt[0],wt=mt[1],Ct=mt[2];return new uo(lr(Wr(dt,2)*(1-Ge)+Wr(yt,2)*Ge),lr(Wr(ft,2)*(1-Ge)+Wr(wt,2)*Ge),lr(Wr(ht,2)*(1-Ge)+Wr(Ct,2)*Ge),"rgb")};xt.lrgb=ta;var ra=B,na=function(ke,Ne,Ge){var ot=ke.lab(),dt=Ne.lab();return new ra(ot[0]+Ge*(dt[0]-ot[0]),ot[1]+Ge*(dt[1]-ot[1]),ot[2]+Ge*(dt[2]-ot[2]),"lab")};xt.lab=na;var Pi=B,vn=function(ke,Ne,Ge,ot){var dt,ft,ht,mt;ot==="hsl"?(ht=ke.hsl(),mt=Ne.hsl()):ot==="hsv"?(ht=ke.hsv(),mt=Ne.hsv()):ot==="hcg"?(ht=ke.hcg(),mt=Ne.hcg()):ot==="hsi"?(ht=ke.hsi(),mt=Ne.hsi()):ot==="lch"||ot==="hcl"?(ot="hcl",ht=ke.hcl(),mt=Ne.hcl()):ot==="oklch"&&(ht=ke.oklch().reverse(),mt=Ne.oklch().reverse());var yt,wt,Ct,Pt,kt,It;(ot.substr(0,1)==="h"||ot==="oklch")&&(dt=ht,yt=dt[0],Ct=dt[1],kt=dt[2],ft=mt,wt=ft[0],Pt=ft[1],It=ft[2]);var $t,Ut,Wt,Yt;return!isNaN(yt)&&!isNaN(wt)?(wt>yt&&wt-yt>180?Yt=wt-(yt+360):wt180?Yt=wt+360-yt:Yt=wt-yt,Ut=yt+Ge*Yt):isNaN(yt)?isNaN(wt)?Ut=Number.NaN:(Ut=wt,(kt==1||kt==0)&&ot!="hsv"&&($t=Pt)):(Ut=yt,(It==1||It==0)&&ot!="hsv"&&($t=Ct)),$t===void 0&&($t=Ct+Ge*(Pt-Ct)),Wt=kt+Ge*(It-kt),ot==="oklch"?new Pi([Wt,$t,Ut],ot):new Pi([Ut,$t,Wt],ot)},ia=vn,xa=function(ke,Ne,Ge){return ia(ke,Ne,Ge,"lch")};xt.lch=xa,xt.hcl=xa;var Wa=B,ja=function(ke,Ne,Ge){var ot=ke.num(),dt=Ne.num();return new Wa(ot+Ge*(dt-ot),"num")};xt.num=ja;var Ka=vn,Ya=function(ke,Ne,Ge){return Ka(ke,Ne,Ge,"hcg")};xt.hcg=Ya;var Ga=vn,qa=function(ke,Ne,Ge){return Ga(ke,Ne,Ge,"hsi")};xt.hsi=qa;var Za=vn,Xa=function(ke,Ne,Ge){return Za(ke,Ne,Ge,"hsl")};xt.hsl=Xa;var Qa=vn,Ja=function(ke,Ne,Ge){return Qa(ke,Ne,Ge,"hsv")};xt.hsv=Ja;var el=B,tl=function(ke,Ne,Ge){var ot=ke.oklab(),dt=Ne.oklab();return new el(ot[0]+Ge*(dt[0]-ot[0]),ot[1]+Ge*(dt[1]-ot[1]),ot[2]+Ge*(dt[2]-ot[2]),"oklab")};xt.oklab=tl;var rl=vn,nl=function(ke,Ne,Ge){return rl(ke,Ne,Ge,"oklch")};xt.oklch=nl;var sa=B,il=T.clip_rgb,oa=Math.pow,aa=Math.sqrt,la=Math.PI,Ea=Math.cos,Sa=Math.sin,sl=Math.atan2,ol=function(ke,Ne,Ge){Ne===void 0&&(Ne="lrgb"),Ge===void 0&&(Ge=null);var ot=ke.length;Ge||(Ge=Array.from(new Array(ot)).map(function(){return 1}));var dt=ot/Ge.reduce(function(Ut,Wt){return Ut+Wt});if(Ge.forEach(function(Ut,Wt){Ge[Wt]*=dt}),ke=ke.map(function(Ut){return new sa(Ut)}),Ne==="lrgb")return al(ke,Ge);for(var ft=ke.shift(),ht=ft.get(Ne),mt=[],yt=0,wt=0,Ct=0;Ct=360;)$t-=360;ht[It]=$t}else ht[It]=ht[It]/mt[It];return kt/=ot,new sa(ht,Ne).alpha(kt>.99999?1:kt,!0)},al=function(ke,Ne){for(var Ge=ke.length,ot=[0,0,0,0],dt=0;dt.9999999&&(ot[3]=1),new sa(il(ot))},jr=fe,$i=T.type,ll=Math.pow,ca=function(ke){var Ne="rgb",Ge=jr("#ccc"),ot=0,dt=[0,1],ft=[],ht=[0,0],mt=!1,yt=[],wt=!1,Ct=0,Pt=1,kt=!1,It={},$t=!0,Ut=1,Wt=function(At){if(At=At||["#fff","#000"],At&&$i(At)==="string"&&jr.brewer&&jr.brewer[At.toLowerCase()]&&(At=jr.brewer[At.toLowerCase()]),$i(At)==="array"){At.length===1&&(At=[At[0],At[0]]),At=At.slice(0);for(var Rt=0;Rt=mt[Ht];)Ht++;return Ht-1}return 0},Xt=function(At){return At},br=function(At){return At},_r=function(At,Rt){var Ht,Vt;if(Rt==null&&(Rt=!1),isNaN(At)||At===null)return Ge;if(Rt)Vt=At;else if(mt&&mt.length>2){var wr=Yt(At);Vt=wr/(mt.length-2)}else Pt!==Ct?Vt=(At-Ct)/(Pt-Ct):Vt=1;Vt=br(Vt),Rt||(Vt=Xt(Vt)),Ut!==1&&(Vt=ll(Vt,Ut)),Vt=ht[0]+Vt*(1-ht[0]-ht[1]),Vt=Math.min(1,Math.max(0,Vt));var sr=Math.floor(Vt*1e4);if($t&&It[sr])Ht=It[sr];else{if($i(yt)==="array")for(var Gt=0;Gt=Qt&&Gt===ft.length-1){Ht=yt[Gt];break}if(Vt>Qt&&Vt2){var Gt=At.map(function(Jt,er){return er/(At.length-1)}),Qt=At.map(function(Jt){return(Jt-Ct)/(Pt-Ct)});Qt.every(function(Jt,er){return Gt[er]===Jt})||(br=function(Jt){if(Jt<=0||Jt>=1)return Jt;for(var er=0;Jt>=Qt[er+1];)er++;var Yr=(Jt-Qt[er])/(Qt[er+1]-Qt[er]),$n=Gt[er]+Yr*(Gt[er+1]-Gt[er]);return $n})}}return dt=[Ct,Pt],jt},jt.mode=function(At){return arguments.length?(Ne=At,Tr(),jt):Ne},jt.range=function(At,Rt){return Wt(At),jt},jt.out=function(At){return wt=At,jt},jt.spread=function(At){return arguments.length?(ot=At,jt):ot},jt.correctLightness=function(At){return At==null&&(At=!0),kt=At,Tr(),kt?Xt=function(Rt){for(var Ht=_r(0,!0).lab()[0],Vt=_r(1,!0).lab()[0],wr=Ht>Vt,sr=_r(Rt,!0).lab()[0],Gt=Ht+(Vt-Ht)*Rt,Qt=sr-Gt,Jt=0,er=1,Yr=20;Math.abs(Qt)>.01&&Yr-- >0;)(function(){return wr&&(Qt*=-1),Qt<0?(Jt=Rt,Rt+=(er-Rt)*.5):(er=Rt,Rt+=(Jt-Rt)*.5),sr=_r(Rt,!0).lab()[0],Qt=sr-Gt})();return Rt}:Xt=function(Rt){return Rt},jt},jt.padding=function(At){return At!=null?($i(At)==="number"&&(At=[At,At]),ht=At,jt):ht},jt.colors=function(At,Rt){arguments.length<2&&(Rt="hex");var Ht=[];if(arguments.length===0)Ht=yt.slice(0);else if(At===1)Ht=[jt(.5)];else if(At>1){var Vt=dt[0],wr=dt[1]-Vt;Ht=cl(0,At,!1).map(function(er){return jt(Vt+er/(At-1)*wr)})}else{ke=[];var sr=[];if(mt&&mt.length>2)for(var Gt=1,Qt=mt.length,Jt=1<=Qt;Jt?GtQt;Jt?Gt++:Gt--)sr.push((mt[Gt-1]+mt[Gt])*.5);else sr=dt;Ht=sr.map(function(er){return jt(er)})}return jr[Rt]&&(Ht=Ht.map(function(er){return er[Rt]()})),Ht},jt.cache=function(At){return At!=null?($t=At,jt):$t},jt.gamma=function(At){return At!=null?(Ut=At,jt):Ut},jt.nodata=function(At){return At!=null?(Ge=jr(At),jt):Ge},jt};function cl(ke,Ne,Ge){for(var ot=[],dt=keft;dt?ht++:ht--)ot.push(ht);return ot}var us=B,ul=ca,hl=function(ke){for(var Ne=[1,1],Ge=1;Ge=5){var wt,Ct,Pt;wt=ke.map(function(kt){return kt.lab()}),Pt=ke.length-1,Ct=hl(Pt),dt=function(kt){var It=1-kt,$t=[0,1,2].map(function(Ut){return wt.reduce(function(Wt,Yt,Xt){return Wt+Ct[Xt]*Math.pow(It,Pt-Xt)*Math.pow(kt,Xt)*Yt[Ut]},0)});return new us($t,"lab")}}else throw new RangeError("No point in running bezier with only one color.");return dt},fl=function(ke){var Ne=dl(ke);return Ne.scale=function(){return ul(Ne)},Ne},ua=fe,Kr=function(ke,Ne,Ge){if(!Kr[Ge])throw new Error("unknown blend mode "+Ge);return Kr[Ge](ke,Ne)},Tn=function(ke){return function(Ne,Ge){var ot=ua(Ge).rgb(),dt=ua(Ne).rgb();return ua.rgb(ke(ot,dt))}},Pn=function(ke){return function(Ne,Ge){var ot=[];return ot[0]=ke(Ne[0],Ge[0]),ot[1]=ke(Ne[1],Ge[1]),ot[2]=ke(Ne[2],Ge[2]),ot}},pl=function(ke){return ke},ml=function(ke,Ne){return ke*Ne/255},gl=function(ke,Ne){return ke>Ne?Ne:ke},yl=function(ke,Ne){return ke>Ne?ke:Ne},_l=function(ke,Ne){return 255*(1-(1-ke/255)*(1-Ne/255))},vl=function(ke,Ne){return Ne<128?2*ke*Ne/255:255*(1-2*(1-ke/255)*(1-Ne/255))},bl=function(ke,Ne){return 255*(1-(1-Ne/255)/(ke/255))},wl=function(ke,Ne){return ke===255?255:(ke=255*(Ne/255)/(1-ke/255),ke>255?255:ke)};Kr.normal=Tn(Pn(pl)),Kr.multiply=Tn(Pn(ml)),Kr.screen=Tn(Pn(_l)),Kr.overlay=Tn(Pn(vl)),Kr.darken=Tn(Pn(gl)),Kr.lighten=Tn(Pn(yl)),Kr.dodge=Tn(Pn(wl)),Kr.burn=Tn(Pn(bl));for(var xl=Kr,ha=T.type,El=T.clip_rgb,Sl=T.TWOPI,Cl=Math.pow,kl=Math.sin,Al=Math.cos,Ca=fe,Tl=function(ke,Ne,Ge,ot,dt){ke===void 0&&(ke=300),Ne===void 0&&(Ne=-1.5),Ge===void 0&&(Ge=1),ot===void 0&&(ot=1),dt===void 0&&(dt=[0,1]);var ft=0,ht;ha(dt)==="array"?ht=dt[1]-dt[0]:(ht=0,dt=[dt,dt]);var mt=function(yt){var wt=Sl*((ke+120)/360+Ne*yt),Ct=Cl(dt[0]+ht*yt,ot),Pt=ft!==0?Ge[0]+yt*ft:Ge,kt=Pt*Ct*(1-Ct)/2,It=Al(wt),$t=kl(wt),Ut=Ct+kt*(-.14861*It+1.78277*$t),Wt=Ct+kt*(-.29227*It-.90649*$t),Yt=Ct+kt*(1.97294*It);return Ca(El([Ut*255,Wt*255,Yt*255,1]))};return mt.start=function(yt){return yt==null?ke:(ke=yt,mt)},mt.rotations=function(yt){return yt==null?Ne:(Ne=yt,mt)},mt.gamma=function(yt){return yt==null?ot:(ot=yt,mt)},mt.hue=function(yt){return yt==null?Ge:(Ge=yt,ha(Ge)==="array"?(ft=Ge[1]-Ge[0],ft===0&&(Ge=Ge[1])):ft=0,mt)},mt.lightness=function(yt){return yt==null?dt:(ha(yt)==="array"?(dt=yt,ht=yt[1]-yt[0]):(dt=[yt,yt],ht=0),mt)},mt.scale=function(){return Ca.scale(mt)},mt.hue(Ge),mt},Pl=B,$l="0123456789abcdef",Il=Math.floor,Ll=Math.random,Rl=function(){for(var ke="#",Ne=0;Ne<6;Ne++)ke+=$l.charAt(Il(Ll()*16));return new Pl(ke,"hex")},da=g,ka=Math.log,Ml=Math.pow,Ol=Math.floor,Dl=Math.abs,Aa=function(ke,Ne){Ne===void 0&&(Ne=null);var Ge={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return da(ke)==="object"&&(ke=Object.values(ke)),ke.forEach(function(ot){Ne&&da(ot)==="object"&&(ot=ot[Ne]),ot!=null&&!isNaN(ot)&&(Ge.values.push(ot),Ge.sum+=ot,otGe.max&&(Ge.max=ot),Ge.count+=1)}),Ge.domain=[Ge.min,Ge.max],Ge.limits=function(ot,dt){return Ta(Ge,ot,dt)},Ge},Ta=function(ke,Ne,Ge){Ne===void 0&&(Ne="equal"),Ge===void 0&&(Ge=7),da(ke)=="array"&&(ke=Aa(ke));var ot=ke.min,dt=ke.max,ft=ke.values.sort(function(pa,ma){return pa-ma});if(Ge===1)return[ot,dt];var ht=[];if(Ne.substr(0,1)==="c"&&(ht.push(ot),ht.push(dt)),Ne.substr(0,1)==="e"){ht.push(ot);for(var mt=1;mt 0");var yt=Math.LOG10E*ka(ot),wt=Math.LOG10E*ka(dt);ht.push(ot);for(var Ct=1;Ct200&&(br=!1)}for(var In={},Ii=0;Iiot?(Ge+.05)/(ot+.05):(ot+.05)/(Ge+.05)},Ia=B,bn=Math.sqrt,pr=Math.pow,Bl=Math.min,Fl=Math.max,La=Math.atan2,Ra=Math.abs,ho=Math.cos,Ma=Math.sin,Ul=Math.exp,Oa=Math.PI,Vl=function(ke,Ne,Ge,ot,dt){Ge===void 0&&(Ge=1),ot===void 0&&(ot=1),dt===void 0&&(dt=1);var ft=function(oi){return 360*oi/(2*Oa)},ht=function(oi){return 2*Oa*oi/360};ke=new Ia(ke),Ne=new Ia(Ne);var mt=Array.from(ke.lab()),yt=mt[0],wt=mt[1],Ct=mt[2],Pt=Array.from(Ne.lab()),kt=Pt[0],It=Pt[1],$t=Pt[2],Ut=(yt+kt)/2,Wt=bn(pr(wt,2)+pr(Ct,2)),Yt=bn(pr(It,2)+pr($t,2)),Xt=(Wt+Yt)/2,br=.5*(1-bn(pr(Xt,7)/(pr(Xt,7)+pr(25,7)))),_r=wt*(1+br),Tr=It*(1+br),jt=bn(pr(_r,2)+pr(Ct,2)),At=bn(pr(Tr,2)+pr($t,2)),Rt=(jt+At)/2,Ht=ft(La(Ct,_r)),Vt=ft(La($t,Tr)),wr=Ht>=0?Ht:Ht+360,sr=Vt>=0?Vt:Vt+360,Gt=Ra(wr-sr)>180?(wr+sr+360)/2:(wr+sr)/2,Qt=1-.17*ho(ht(Gt-30))+.24*ho(ht(2*Gt))+.32*ho(ht(3*Gt+6))-.2*ho(ht(4*Gt-63)),Jt=sr-wr;Jt=Ra(Jt)<=180?Jt:sr<=wr?Jt+360:Jt-360,Jt=2*bn(jt*At)*Ma(ht(Jt)/2);var er=kt-yt,Yr=At-jt,$n=1+.015*pr(Ut-50,2)/bn(20+pr(Ut-50,2)),In=1+.045*Rt,Ii=1+.015*Rt*Qt,Li=30*Ul(-pr((Gt-275)/25,2)),wn=2*bn(pr(Rt,7)/(pr(Rt,7)+pr(25,7))),si=-wn*Ma(2*ht(Li)),hs=bn(pr(er/(Ge*$n),2)+pr(Yr/(ot*In),2)+pr(Jt/(dt*Ii),2)+si*(Yr/(ot*In))*(Jt/(dt*Ii)));return Fl(0,Bl(100,hs))},Da=B,Hl=function(ke,Ne,Ge){Ge===void 0&&(Ge="lab"),ke=new Da(ke),Ne=new Da(Ne);var ot=ke.get(Ge),dt=Ne.get(Ge),ft=0;for(var ht in ot){var mt=(ot[ht]||0)-(dt[ht]||0);ft+=mt*mt}return Math.sqrt(ft)},zl=B,Wl=function(){for(var ke=[],Ne=arguments.length;Ne--;)ke[Ne]=arguments[Ne];try{return new(Function.prototype.bind.apply(zl,[null].concat(ke))),!0}catch{return!1}},Na=fe,Ba=ca,jl={cool:function(){return Ba([Na.hsl(180,1,.9),Na.hsl(250,.7,.4)])},hot:function(){return Ba(["#000","#f00","#ff0","#fff"]).mode("rgb")}},fo={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},fa=0,Fa=Object.keys(fo);fal===o);if(r[a])return r[a]}return r[r.length-1]}const markerIcon2x="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==",markerIcon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",markerShadow="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",queue=new queue$1;let scale,markersLayer,pathsLayer,moveLayer,handlerClickMarker;delete L$2.Icon.Default.prototype._getIconUrl;L$2.Icon.Default.mergeOptions({iconRetinaUrl:markerIcon2x,iconUrl:markerIcon,shadowUrl:markerShadow});const messageTypes={0:"text",1:"air",2:"garbage",3:"water",4:"fire",5:"forest",6:"alert ",7:"notif",8:"recycle",9:"parking",42:"gank"};let messageIconName={},messageIconType={};const messagesLayers=Object.values(messageTypes).reduce((e,t)=>(e[t]=null,e),{});async function init$2(e,t,r){for(const o of Object.keys(messageTypes)){try{messageIconType[o]=(await __variableDynamicImportRuntimeHelper(Object.assign({"../../assets/message/msg-air.png":()=>__vitePreload(()=>import("./msg-air.abb754d3.js"),[],import.meta.url),"../../assets/message/msg-alert.png":()=>__vitePreload(()=>import("./msg-alert.9404c396.js"),[],import.meta.url),"../../assets/message/msg-fire.png":()=>__vitePreload(()=>import("./msg-fire.faa011b0.js"),[],import.meta.url),"../../assets/message/msg-forest.png":()=>__vitePreload(()=>import("./msg-forest.a623a1f9.js"),[],import.meta.url),"../../assets/message/msg-gank.png":()=>__vitePreload(()=>import("./msg-gank.34a748fe.js"),[],import.meta.url),"../../assets/message/msg-garbage.png":()=>__vitePreload(()=>import("./msg-garbage.b797b882.js"),[],import.meta.url),"../../assets/message/msg-notif.png":()=>__vitePreload(()=>import("./msg-notif.d72c5a6f.js"),[],import.meta.url),"../../assets/message/msg-parking.png":()=>__vitePreload(()=>import("./msg-parking.5da4fdeb.js"),[],import.meta.url),"../../assets/message/msg-recycle.png":()=>__vitePreload(()=>import("./msg-recycle.eab79c00.js"),[],import.meta.url),"../../assets/message/msg-text.png":()=>__vitePreload(()=>import("./msg-text.470fee8d.js"),[],import.meta.url),"../../assets/message/msg-water.png":()=>__vitePreload(()=>import("./msg-water.b0066085.js"),[],import.meta.url)}),`../../assets/message/msg-${messageTypes[o]}.png`)).default}catch{messageIconType[o]=(await __vitePreload(()=>import("./msg-text.470fee8d.js"),[],import.meta.url)).default}messageIconName[messageTypes[o]]=messageIconType[o]}handlerClickMarker=o=>{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?e.setActiveArea({position:"absolute",top:"90px",left:"0px",right:"0px",height:"20%"}):e.setActiveArea({position:"absolute",top:"0px",left:"0px",right:"50%",height:"100%"}),e.panTo(o.latlng),r(o.target.options.data)};const n=getMeasurementByName(t);scale=generate$1(n.colors,n.range),markersLayer=new L$2.MarkerClusterGroup({showCoverageOnHover:!1,maxClusterRadius:120,iconCreateFunction:iconCreate}),e.addLayer(markersLayer),pathsLayer=new L$2.layerGroup,e.addLayer(pathsLayer),moveLayer=new L$2.layerGroup,e.addLayer(moveLayer);for(const o of Object.values(messageTypes))messagesLayers[o]=new L$2.MarkerClusterGroup({showCoverageOnHover:!1,maxClusterRadius:120,iconCreateFunction:a=>iconCreateMsg(a,o)});for(const o of Object.values(messagesLayers))e.addLayer(o)}function isReadyLayers(){return!!(markersLayer&&pathsLayer&&moveLayer)}function iconCreate(e){const t=e.getAllChildMarkers(),r=e.getChildCount();let n=0,o=0;t.forEach(u=>{u.options.data.value===void 0&&u.options.data.value!==""||(n++,o+=Number(u.options.data.value))}),n>0&&(o=o/n);const a=getColorRGB(scale,o),l=getColorDarkenRGB(scale,o),c=scale(o).luminance()<.4;return new L$2.DivIcon({html:`
${r}
`,className:"marker-cluster",iconSize:new L$2.Point(40,40)})}function iconCreateMsg(e,t="text"){const r=e.getChildCount();return new L$2.DivIcon({html:`
${r}
`,className:"marker-cluster",iconSize:new L$2.Point(40,40)})}function findMarker(e){return new Promise(t=>{markersLayer&&markersLayer.eachLayer(r=>{r.options.data.sensor_id===e&&t(r)}),t(!1)})}function createIconBrand(e,t){return L$2.divIcon({html:``,iconSize:[40,40],className:"marker-icon"})}function createIconMsg(e=0){return L$2.divIcon({html:``,iconSize:[40,40],className:"marker-icon"})}function createIconArrow(e,t,r){return L$2.divIcon({className:"",html:`
@@ -124,10 +124,10 @@ hooks.version="2.29.4";setHookCallback(createLocal);hooks.fn=proto;hooks.min=min c1.1-0.9,1.7-2.2,1.7-3.6c0-1.5-0.7-2.8-1.8-3.8c-0.2-0.1-0.4-0.1-0.5,0.1c-0.1,0.2-0.1,0.4,0.1,0.5c1,0.8,1.5,1.9,1.5,3.2 c0,1.2-0.5,2.3-1.4,3c-0.2,0.1-0.2,0.4,0,0.5c0.1,0.1,0.2,0.1,0.3,0.1C37.6,45.8,37.6,45.8,37.7,45.8z M39.2,47.3 c1.5-1.3,2.4-3.2,2.4-5.1c0-2.1-0.9-4-2.6-5.3c-0.2-0.1-0.4-0.1-0.5,0.1c-0.1,0.2-0.1,0.4,0.1,0.5c1.5,1.2,2.3,2.9,2.3,4.7 - c0,1.8-0.8,3.4-2.1,4.6c-0.2,0.1-0.2,0.4,0,0.5c0.1,0.1,0.2,0.1,0.3,0.1C39,47.4,39.1,47.4,39.2,47.3z`})],-1)),_hoisted_3$6=[_hoisted_2$8];function _sfc_render$b(e,t){return openBlock(),createElementBlock("svg",_hoisted_1$9,_hoisted_3$6)}const IconSensor=_export_sfc(_sfc_main$b,[["render",_sfc_render$b],["__scopeId","data-v-1ca21f0d"]]),_imports_0$1="/assets/app-icon-512.a5eb7b3f.png",Header_vue_vue_type_style_index_0_scoped_a4474917_lang="",_sfc_main$a={components:{IconSensor},data(){return{locale:localStorage.getItem("locale")||this.$i18n.locale||"en",store:useStore()}},watch:{locale(e){this.$i18n.locale=e,localStorage.setItem("locale",e)}},computed:{countPoints(){return this.store.sensors.length}}},_withScopeId$5=e=>(pushScopeId("data-v-a4474917"),e=e(),popScopeId(),e),_hoisted_1$8={class:"flexline space-between"},_hoisted_2$7={class:"flexline align-start"},_hoisted_3$5=_withScopeId$5(()=>createBaseVNode("img",{alt:"App logo",src:_imports_0$1},null,-1)),_hoisted_4$4={key:0,class:"sensorscount"},_hoisted_5$4={class:"flexline"},_hoisted_6$4=_withScopeId$5(()=>createBaseVNode("option",{value:"en"},"English",-1)),_hoisted_7$4=_withScopeId$5(()=>createBaseVNode("option",{value:"ru"},"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",-1)),_hoisted_8$4=[_hoisted_6$4,_hoisted_7$4],_hoisted_9$4={id:"about",class:"popover popover-top-right",popover:""},_hoisted_10$3=createStaticVNode('

Web3 \u043E\u0442\u043A\u0440\u044B\u0442\u0430\u044F \u0441\u0435\u0442\u044C \u0434\u0430\u0442\u0447\u0438\u043A\u043E\u0432

\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 \u043E\u0442\u043A\u0440\u044B\u0442\u0443\u044E \u0441\u0435\u0442\u044C \u0434\u0430\u0442\u0447\u0438\u043A\u043E\u0432, \u043A\u043E\u0442\u043E\u0440\u0430\u044F \u043F\u043E\u0441\u0442\u0440\u043E\u0435\u043D\u0430 \u043D\u0430 open-source \u043F\u0440\u0438\u043D\u0446\u0438\u043F\u0430\u0445 \u0438 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F \u044D\u043D\u0442\u0443\u0437\u0438\u0430\u0441\u0442\u0430\u043C\u0438 (\u0441\u043C. the free will of individuals). \u041A\u0430\u0440\u0442\u0430 \u043F\u0440\u0435\u0434\u043B\u0430\u0433\u0430\u0435\u0442 \u0434\u0432\u0430 \u0440\u0430\u0437\u043D\u044B\u0445 \u0443\u0440\u043E\u0432\u043D\u044F \u0434\u0435\u0446\u0435\u043D\u0442\u0440\u0430\u043B\u0438\u0437\u0430\u0446\u0438\u0438: \u043F\u0440\u044F\u043C\u0430\u044F peer-to-peer \u0441\u0432\u044F\u0437\u044C \u0434\u0430\u0442\u0447\u0438\u043A\u043E\u0432 \u0438 \u0431\u043B\u043E\u043A\u0447\u0435\u0439\u043D \u0434\u043B\u044F \u0441\u0431\u043E\u0440\u0430 \u0438 \u0445\u0440\u0430\u043D\u0435\u043D\u0438\u044F \u0438\u0441\u0442\u043E\u0440\u0438\u0438 \u043F\u043E\u043A\u0430\u0437\u0430\u043D\u0438\u0439 \u0441 \u0434\u0430\u0442\u0447\u0438\u043A\u043E\u0432. \u0422\u0443\u0442 \u043C\u043E\u0436\u043D\u043E \u043E\u0437\u043D\u0430\u043A\u043E\u043C\u0438\u0442\u044C\u0441\u044F \u0431\u043E\u043B\u0435\u0435 \u043F\u043E\u0434\u0440\u043E\u0431\u043D\u043E \u0441 \u0442\u0435\u0445\u043D\u0438\u0447\u0435\u0441\u043A\u043E\u0439 \u0441\u0442\u043E\u0440\u043E\u043D\u043E\u0439.

\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u0441\u0432\u043E\u0439 \u0434\u0430\u0442\u0447\u0438\u043A \u043D\u0430 \u043A\u0430\u0440\u0442\u0443

\u0412\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u0441\u043E\u0431\u0440\u0430\u0442\u044C \u0441\u0432\u043E\u0439 \u0434\u0430\u0442\u0447\u0438\u043A, \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u044F \u043A\u043E\u043C\u043F\u043B\u0435\u043A\u0442\u0443\u044E\u0449\u0438\u0435 \u043D\u0430 \u043E\u0442\u043A\u0440\u044B\u0442\u043E\u043C \u0440\u044B\u043D\u043A\u0435 \u044D\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u0438\u043A\u0438, \u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0434\u0430\u0442\u0447\u0438\u043A \u043D\u0430 \u043A\u0430\u0440\u0442\u0443. \u041C\u044B \u0441 \u0440\u0430\u0434\u043E\u0441\u0442\u044C\u044E \u043F\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u043C \u043D\u043E\u0432\u044B\u0445 \u0443\u0447\u0430\u0441\u0442\u043D\u0438\u043A\u043E\u0432 \u0441\u043E\u043E\u0431\u0449\u0435\u0441\u0442\u0432\u0430. \u041F\u0440\u0438\u0441\u043E\u0435\u0434\u0438\u043D\u044F\u0439\u0442\u0435\u0441\u044C!

\u0412\u0438\u0434\u0435\u043E-\u0438\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u044F \u043D\u0430 YouTube

',5),_hoisted_15$2=createStaticVNode('

Web3 public sensors map

Welcome to the decentralized opensource sensors map which operates with the sole intent of serving the free will of individuals, without any beneficiaries. It offers two distinct layers of decentralization at your choise: peer-to-peer connectivity for direct access to sensor data, and the federative concept for accumulating sensor data and displaying measurement history. Click here for further technical details.

Add your sensor on this map

You can assemble your own sensor using components available on the free market. Follow the instructions provided to connect your sensor to the map. We welcome your participation and look forward to expanding our community together. Join us today!

YouTube video guide

',5),_hoisted_20$2=_withScopeId$5(()=>createBaseVNode("hr",null,null,-1)),_hoisted_21$2={class:"navlinks"},_hoisted_22$2={href:"https://github.com/airalab/sensors.robonomics.network",target:"_blank",rel:"noopener"},_hoisted_23$2={class:"popovercontrol",popovertarget:"about"};function _sfc_render$a(e,t,r,n,o,a){const l=resolveComponent("router-link"),c=resolveComponent("IconSensor"),u=resolveComponent("font-awesome-icon");return openBlock(),createElementBlock("header",_hoisted_1$8,[createBaseVNode("div",_hoisted_2$7,[createVNode(l,{to:"/",class:"appicon"},{default:withCtx(()=>[_hoisted_3$5]),_:1}),a.countPoints>0?(openBlock(),createElementBlock("b",_hoisted_4$4,[createVNode(c),createTextVNode(" "+toDisplayString$1(a.countPoints),1)])):createCommentVNode("",!0)]),createBaseVNode("div",_hoisted_5$4,[withDirectives(createBaseVNode("select",{"onUpdate:modelValue":t[0]||(t[0]=g=>o.locale=g)},_hoisted_8$4,512),[[vModelSelect,o.locale]]),createBaseVNode("div",_hoisted_9$4,[o.locale==="ru"?(openBlock(),createElementBlock(Fragment,{key:0},[_hoisted_10$3],64)):(openBlock(),createElementBlock(Fragment,{key:1},[_hoisted_15$2],64)),_hoisted_20$2,createBaseVNode("section",_hoisted_21$2,[createBaseVNode("a",_hoisted_22$2,toDisplayString$1(e.$t("links.github")),1),createVNode(l,{to:"/air-measurements"},{default:withCtx(()=>[createTextVNode(toDisplayString$1(e.$t("links.measurement")),1)]),_:1}),createVNode(l,{to:"/privacy-policy"},{default:withCtx(()=>[createTextVNode(toDisplayString$1(e.$t("links.privacy")),1)]),_:1})])]),createBaseVNode("button",_hoisted_23$2,[createVNode(u,{icon:"fa-solid fa-bars"})])])])}const Header=_export_sfc(_sfc_main$a,[["render",_sfc_render$a],["__scopeId","data-v-a4474917"]]),_imports_0="/assets/sensors-world-app.8a0828bb.png",InstallPWA_vue_vue_type_style_index_0_scoped_b59a209f_lang="",_sfc_main$9={data(){return{deferredPrompt:null,isSupported:!1,db:null,isInstalled:"loading",isBrowserSupport:!0,browsers:{chrome:!1,safari:!1,firefox:!1,edge:!1,opera:!1}}},methods:{async getDb(){return new Promise((e,t)=>{let r=window.indexedDB.open("SensorsDB",1);r.onerror=n=>{console.log("Error opening db",n),t("Error")},r.onsuccess=n=>{e(n.target.result)},r.onupgradeneeded=n=>{n.target.result.createObjectStore("install",{autoIncrement:!0,keyPath:"id"})}})},async getData(){return new Promise(e=>{let t=this.db.transaction(["install"],"readonly");t.oncomplete=()=>{e(n)};let r=t.objectStore("install"),n=null;r.openCursor().onsuccess=o=>{let a=o.target.result;a&&(n=a.value,a.continue())}})},async addDataToDb(e=!1,t=!1){return new Promise(r=>{let n=this.db.transaction(["install"],"readwrite");n.oncomplete=()=>{r()};let o=n.objectStore("install");o.delete(1),o.add({id:1,removed:e,installed:t})})},async installApp(){if(this.addDataToDb(!1,!0),this.deferredPrompt!==null){this.deferredPrompt.prompt();const{outcome:e}=await this.deferredPrompt.userChoice;e==="accepted"&&(this.deferredPrompt=null,this.isSupported=!1,this.isInstalled="installed")}},removeInstall(){this.addDataToDb(!0,!1),this.isInstalled="removed"},checkBrowser(){let e=navigator.userAgent;this.browsers.chrome=e.indexOf("Chrome")>-1,this.browsers.firefox=e.indexOf("Firefox")>-1,this.browsers.safari=e.indexOf("Safari")>-1,this.browsers.chrome&&this.browsers.safari&&(this.browsers.safari=!1),this.browsers.opera=e.indexOf("OP")>-1,this.browsers.chrome&&this.browsers.opera&&(this.browsers.chrome=!1)}},async created(){this.db=await this.getDb(),this.isInstalled=await this.getData()?await this.getData():null},mounted(){window.addEventListener("beforeinstallprompt",e=>{this.isSupported=!0,this.deferredPrompt=e}),window.matchMedia("(display-mode: standalone)").matches?this.isSupported=!0:this.isSupported=!1,this.checkBrowser(),(this.browsers.safari||this.browsers.firefox||this.browsers.opera)&&(this.isBrowserSupport=!1)}},_withScopeId$4=e=>(pushScopeId("data-v-b59a209f"),e=e(),popScopeId(),e),_hoisted_1$7={key:0,class:"container install-pwa__container"},_hoisted_2$6={class:"install-pwa__content"},_hoisted_3$4=_withScopeId$4(()=>createBaseVNode("img",{src:_imports_0,alt:"sensors-cy-app"},null,-1)),_hoisted_4$3={class:"install-pwa__text"},_hoisted_5$3=_withScopeId$4(()=>createBaseVNode("h3",null,"Available as web application (PWA)",-1));function _sfc_render$9(e,t,r,n,o,a){return!o.isInstalled&&o.isBrowserSupport?(openBlock(),createElementBlock("div",_hoisted_1$7,[createBaseVNode("div",_hoisted_2$6,[_hoisted_3$4,createBaseVNode("div",_hoisted_4$3,[_hoisted_5$3,createBaseVNode("button",{onClick:t[0]||(t[0]=(...l)=>a.installApp&&a.installApp(...l)),class:"install-pwa__btn"},"Install")])]),createBaseVNode("button",{onClick:t[1]||(t[1]=(...l)=>a.removeInstall&&a.removeInstall(...l)),class:"install-pwa__remove"})])):createCommentVNode("",!0)}const InstallPWA=_export_sfc(_sfc_main$9,[["render",_sfc_render$9],["__scopeId","data-v-b59a209f"]]),MessagePopup_vue_vue_type_style_index_0_scoped_c5bfb7c2_lang="";function preloadImages(e,t){let r=0;const n={};function o(){if(r++,r==e.length){const a=[],l=[];for(const c of e)n[c]&&n[c]>0?(console.log(`Bad image ${c}`),l.push(c)):a.push(c);t(a,l)}}for(let a of e){let l=document.createElement("img");l.onload=()=>{n[a]=0,o()},l.onerror=()=>{n[a]||(n[a]=0),n[a]++,n[a]<3?l.src=a:o()},l.src=a}}const _sfc_main$8={props:["data"],data(){return{isImages:!1,images:[],badImages:[],imagesLoaded:!1,state:"neutral"}},computed:{dateMsg:function(){return hooks(this.data.timestamp,"X").format("DD.MM.YYYY HH:mm:ss")},classList(){return{["sensor-popup__header"]:!0,[`sensor-popup__header--${this.state}`]:this.state}}},watch:{data(){this.imagesLoad()}},created(){this.imagesLoad()},methods:{replaceWithBr(e){return e.replace(/\n/g,"
")},imagesLoad(){if(this.data.images&&this.data.images.length>0){this.images=[],this.badImages=[],this.imagesLoaded=!1,this.isImages=!0;const e=this.data.images.map(t=>`https://aira.mypinata.cloud/ipfs/${this.data.ipfs}/${t}`);preloadImages(e,(t,r)=>{t.length>0&&(this.images=t),r.length>0&&(this.badImages=r),this.imagesLoaded=!0})}else this.isImages=!1,this.images=[],this.badImages=[],this.imagesLoaded=!1}}},_hoisted_1$6={class:"container sensor-popup sensors-panel sensors-panel--center-right active popup-js"},_hoisted_2$5={class:"sensor-popup__header-icon"},_hoisted_3$3={class:"sensor-popup__header-wrapper"},_hoisted_4$2={class:"sensor-popup--subtitle"},_hoisted_5$2={ref:"content",class:"sensor-popup--content"},_hoisted_6$3=["innerHTML"],_hoisted_7$3={key:0},_hoisted_8$3=["href"],_hoisted_9$3=["src"],_hoisted_10$2=["href"];function _sfc_render$8(e,t,r,n,o,a){const l=resolveComponent("font-awesome-icon");return openBlock(),createElementBlock("div",_hoisted_1$6,[createBaseVNode("div",{class:normalizeClass(a.classList)},[createBaseVNode("div",_hoisted_2$5,[createVNode(l,{icon:"fa-solid fa-face-meh"})]),createBaseVNode("div",_hoisted_3$3,[createBaseVNode("h2",null,toDisplayString$1(e.$t("details.user"))+" "+toDisplayString$1(r.data.username),1),createBaseVNode("div",_hoisted_4$2,[createBaseVNode("span",null,[createVNode(l,{icon:"fa-solid fa-stopwatch"}),createTextVNode(" "+toDisplayString$1(a.dateMsg),1)])])])],2),createBaseVNode("div",_hoisted_5$2,[createBaseVNode("div",{innerHTML:a.replaceWithBr(r.data.message)},null,8,_hoisted_6$3),o.isImages?(openBlock(),createElementBlock(Fragment,{key:0},[createBaseVNode("h2",null,toDisplayString$1(e.$t("details.photos")),1),o.imagesLoaded?(openBlock(),createElementBlock(Fragment,{key:1},[(openBlock(!0),createElementBlock(Fragment,null,renderList(o.images,(c,u)=>(openBlock(),createElementBlock("div",{key:u},[createBaseVNode("a",{href:c,target:"_blank"},[createBaseVNode("img",{style:{"max-width":"400px"},src:c},null,8,_hoisted_9$3)],8,_hoisted_8$3)]))),128)),createBaseVNode("template",null,[(openBlock(!0),createElementBlock(Fragment,null,renderList(o.badImages,(c,u)=>(openBlock(),createElementBlock("a",{key:u,href:c,target:"_blank"},toDisplayString$1(c),9,_hoisted_10$2))),128))])],64)):(openBlock(),createElementBlock("div",_hoisted_7$3,"..."))],64)):createCommentVNode("",!0)],512),createBaseVNode("a",{class:"popup__close",href:"javascript:;",onClick:t[0]||(t[0]=withModifiers(c=>e.$emit("close"),["stop","prevent"]))},[createVNode(l,{icon:"fa-solid fa-xmark"})])])}const MessagePopup=_export_sfc(_sfc_main$8,[["render",_sfc_render$8],["__scopeId","data-v-c5bfb7c2"]]),Bookmark_vue_vue_type_style_index_0_scoped_8cca7f79_lang="",_sfc_main$7={props:["address","link"],data(){return{IsBookmarked:!1,db:null,bookmarks:[],bookmarkid:null,bookmarkname:"",store:useStore()}},computed:{buttonclasses(){return{button:!0,["button-green"]:this.IsBookmarked}}},methods:{async findbookmark(){return(await IDBgettable(this.store.idbBookmarkDbname,this.store.idbBookmarkVDbver,this.store.idbBookmarkVDbtable)).find(t=>t.address===this.$props.address)},async addbookmark(){await this.findbookmark()?this.bookmarkid&&IDBworkflow(this.store.idbBookmarkDbname,this.store.idbBookmarkVDbver,this.store.idbBookmarkVDbtable,"readwrite",r=>{const n=r.get(this.bookmarkid);n.addEventListener("error",o=>{console.log(o)}),n.addEventListener("success",o=>{const a=o.target.result;a.customName=this.bookmarkname;const l=r.put(a);l.addEventListener("error",c=>{console.log(c)}),l.addEventListener("success",c=>{this.IsBookmarked=!0})})}):IDBworkflow(this.store.idbBookmarkDbname,this.store.idbBookmarkVDbver,this.store.idbBookmarkVDbtable,"readwrite",r=>{r.add({customName:this.bookmarkname,address:this.$props.address,link:this.$props.link}),this.IsBookmarked=!0});const t=new BroadcastChannel(this.store.idbWatcherBroadcast);t.postMessage(!0),t.close()}},async mounted(){const e=await this.findbookmark();e&&(this.IsBookmarked=!0,this.bookmarkid=e.id,this.bookmarkname=e.customName)}},_hoisted_1$5=["placeholder"],_hoisted_2$4=["disabled","area-label"];function _sfc_render$7(e,t,r,n,o,a){const l=resolveComponent("font-awesome-icon");return openBlock(),createElementBlock("form",{class:"flexline",onSubmit:t[2]||(t[2]=withModifiers((...c)=>a.addbookmark&&a.addbookmark(...c),["prevent"]))},[withDirectives(createBaseVNode("input",{type:"text","onUpdate:modelValue":t[0]||(t[0]=c=>o.bookmarkname=c),placeholder:e.$t("sensorpopup.bookmarkplaceholder"),onInput:t[1]||(t[1]=c=>o.IsBookmarked=!1)},null,40,_hoisted_1$5),[[vModelText,o.bookmarkname]]),createBaseVNode("button",{class:normalizeClass(a.buttonclasses),disabled:o.IsBookmarked,"area-label":e.$t("sensorpopup.bookmarkbutton")},[o.IsBookmarked?(openBlock(),createBlock(l,{key:1,icon:"fa-solid fa-check"})):(openBlock(),createBlock(l,{key:0,icon:"fa-solid fa-bookmark"}))],10,_hoisted_2$4)],32)}const Bookmark=_export_sfc(_sfc_main$7,[["render",_sfc_render$7],["__scopeId","data-v-8cca7f79"]]);var highchartsVue_min={exports:{}},highcharts={exports:{}},hasRequiredHighcharts;function requireHighcharts(){return hasRequiredHighcharts||(hasRequiredHighcharts=1,function(e){(function(t,r){e.exports?(r.default=r,e.exports=t&&t.document?r(t):r):(t.Highcharts&&t.Highcharts.error(16,!0),t.Highcharts=r(t))})(typeof window<"u"?window:commonjsGlobal$2,function(t){var r={};function n(o,a,l,c){o.hasOwnProperty(a)||(o[a]=c.apply(null,l),typeof CustomEvent=="function"&&t.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:a,module:o[a]}})))}return n(r,"Core/Globals.js",[],function(){var o,a;return(a=o||(o={})).SVG_NS="http://www.w3.org/2000/svg",a.product="Highcharts",a.version="11.4.3",a.win=t!==void 0?t:{},a.doc=a.win.document,a.svg=a.doc&&a.doc.createElementNS&&!!a.doc.createElementNS(a.SVG_NS,"svg").createSVGRect,a.userAgent=a.win.navigator&&a.win.navigator.userAgent||"",a.isChrome=a.userAgent.indexOf("Chrome")!==-1,a.isFirefox=a.userAgent.indexOf("Firefox")!==-1,a.isMS=/(edge|msie|trident)/i.test(a.userAgent)&&!a.win.opera,a.isSafari=!a.isChrome&&a.userAgent.indexOf("Safari")!==-1,a.isTouchDevice=/(Mobile|Android|Windows Phone)/.test(a.userAgent),a.isWebKit=a.userAgent.indexOf("AppleWebKit")!==-1,a.deg2rad=2*Math.PI/360,a.hasBidiBug=a.isFirefox&&4>parseInt(a.userAgent.split("Firefox/")[1],10),a.marginNames=["plotTop","marginRight","marginBottom","plotLeft"],a.noop=function(){},a.supportsPassiveEvents=function(){let l=!1;if(!a.isMS){let c=Object.defineProperty({},"passive",{get:function(){l=!0}});a.win.addEventListener&&a.win.removeEventListener&&(a.win.addEventListener("testPassive",a.noop,c),a.win.removeEventListener("testPassive",a.noop,c))}return l}(),a.charts=[],a.composed=[],a.dateFormats={},a.seriesTypes={},a.symbolSizes={},a.chartCount=0,o}),n(r,"Core/Utilities.js",[r["Core/Globals.js"]],function(o){let a,{charts:l,doc:c,win:u}=o;function g(ae,ie,pe,ue){let ge=ie?"Highcharts error":"Highcharts warning";ae===32&&(ae=`${ge}: Deprecated member`);let ye=D(ae),Ae=ye?`${ge} #${ae}: www.highcharts.com/errors/${ae}/`:ae.toString();if(ue!==void 0){let Re="";ye&&(Ae+="?"),we(ue,function(We,Pe){Re+=` + c0,1.8-0.8,3.4-2.1,4.6c-0.2,0.1-0.2,0.4,0,0.5c0.1,0.1,0.2,0.1,0.3,0.1C39,47.4,39.1,47.4,39.2,47.3z`})],-1)),_hoisted_3$6=[_hoisted_2$8];function _sfc_render$b(e,t){return openBlock(),createElementBlock("svg",_hoisted_1$9,_hoisted_3$6)}const IconSensor=_export_sfc(_sfc_main$b,[["render",_sfc_render$b],["__scopeId","data-v-1ca21f0d"]]),_imports_0$1=""+new URL("app-icon-512.a5eb7b3f.png",import.meta.url).href,Header_vue_vue_type_style_index_0_scoped_a4474917_lang="",_sfc_main$a={components:{IconSensor},data(){return{locale:localStorage.getItem("locale")||this.$i18n.locale||"en",store:useStore()}},watch:{locale(e){this.$i18n.locale=e,localStorage.setItem("locale",e)}},computed:{countPoints(){return this.store.sensors.length}}},_withScopeId$5=e=>(pushScopeId("data-v-a4474917"),e=e(),popScopeId(),e),_hoisted_1$8={class:"flexline space-between"},_hoisted_2$7={class:"flexline align-start"},_hoisted_3$5=_withScopeId$5(()=>createBaseVNode("img",{alt:"App logo",src:_imports_0$1},null,-1)),_hoisted_4$4={key:0,class:"sensorscount"},_hoisted_5$4={class:"flexline"},_hoisted_6$4=_withScopeId$5(()=>createBaseVNode("option",{value:"en"},"English",-1)),_hoisted_7$4=_withScopeId$5(()=>createBaseVNode("option",{value:"ru"},"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",-1)),_hoisted_8$4=[_hoisted_6$4,_hoisted_7$4],_hoisted_9$4={id:"about",class:"popover popover-top-right",popover:""},_hoisted_10$3=createStaticVNode('

Web3 \u043E\u0442\u043A\u0440\u044B\u0442\u0430\u044F \u0441\u0435\u0442\u044C \u0434\u0430\u0442\u0447\u0438\u043A\u043E\u0432

\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 \u043E\u0442\u043A\u0440\u044B\u0442\u0443\u044E \u0441\u0435\u0442\u044C \u0434\u0430\u0442\u0447\u0438\u043A\u043E\u0432, \u043A\u043E\u0442\u043E\u0440\u0430\u044F \u043F\u043E\u0441\u0442\u0440\u043E\u0435\u043D\u0430 \u043D\u0430 open-source \u043F\u0440\u0438\u043D\u0446\u0438\u043F\u0430\u0445 \u0438 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F \u044D\u043D\u0442\u0443\u0437\u0438\u0430\u0441\u0442\u0430\u043C\u0438 (\u0441\u043C. the free will of individuals). \u041A\u0430\u0440\u0442\u0430 \u043F\u0440\u0435\u0434\u043B\u0430\u0433\u0430\u0435\u0442 \u0434\u0432\u0430 \u0440\u0430\u0437\u043D\u044B\u0445 \u0443\u0440\u043E\u0432\u043D\u044F \u0434\u0435\u0446\u0435\u043D\u0442\u0440\u0430\u043B\u0438\u0437\u0430\u0446\u0438\u0438: \u043F\u0440\u044F\u043C\u0430\u044F peer-to-peer \u0441\u0432\u044F\u0437\u044C \u0434\u0430\u0442\u0447\u0438\u043A\u043E\u0432 \u0438 \u0431\u043B\u043E\u043A\u0447\u0435\u0439\u043D \u0434\u043B\u044F \u0441\u0431\u043E\u0440\u0430 \u0438 \u0445\u0440\u0430\u043D\u0435\u043D\u0438\u044F \u0438\u0441\u0442\u043E\u0440\u0438\u0438 \u043F\u043E\u043A\u0430\u0437\u0430\u043D\u0438\u0439 \u0441 \u0434\u0430\u0442\u0447\u0438\u043A\u043E\u0432. \u0422\u0443\u0442 \u043C\u043E\u0436\u043D\u043E \u043E\u0437\u043D\u0430\u043A\u043E\u043C\u0438\u0442\u044C\u0441\u044F \u0431\u043E\u043B\u0435\u0435 \u043F\u043E\u0434\u0440\u043E\u0431\u043D\u043E \u0441 \u0442\u0435\u0445\u043D\u0438\u0447\u0435\u0441\u043A\u043E\u0439 \u0441\u0442\u043E\u0440\u043E\u043D\u043E\u0439.

\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u0441\u0432\u043E\u0439 \u0434\u0430\u0442\u0447\u0438\u043A \u043D\u0430 \u043A\u0430\u0440\u0442\u0443

\u0412\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u0441\u043E\u0431\u0440\u0430\u0442\u044C \u0441\u0432\u043E\u0439 \u0434\u0430\u0442\u0447\u0438\u043A, \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u044F \u043A\u043E\u043C\u043F\u043B\u0435\u043A\u0442\u0443\u044E\u0449\u0438\u0435 \u043D\u0430 \u043E\u0442\u043A\u0440\u044B\u0442\u043E\u043C \u0440\u044B\u043D\u043A\u0435 \u044D\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u0438\u043A\u0438, \u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0434\u0430\u0442\u0447\u0438\u043A \u043D\u0430 \u043A\u0430\u0440\u0442\u0443. \u041C\u044B \u0441 \u0440\u0430\u0434\u043E\u0441\u0442\u044C\u044E \u043F\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u043C \u043D\u043E\u0432\u044B\u0445 \u0443\u0447\u0430\u0441\u0442\u043D\u0438\u043A\u043E\u0432 \u0441\u043E\u043E\u0431\u0449\u0435\u0441\u0442\u0432\u0430. \u041F\u0440\u0438\u0441\u043E\u0435\u0434\u0438\u043D\u044F\u0439\u0442\u0435\u0441\u044C!

\u0412\u0438\u0434\u0435\u043E-\u0438\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u044F \u043D\u0430 YouTube

',5),_hoisted_15$2=createStaticVNode('

Web3 public sensors map

Welcome to the decentralized opensource sensors map which operates with the sole intent of serving the free will of individuals, without any beneficiaries. It offers two distinct layers of decentralization at your choise: peer-to-peer connectivity for direct access to sensor data, and the federative concept for accumulating sensor data and displaying measurement history. Click here for further technical details.

Add your sensor on this map

You can assemble your own sensor using components available on the free market. Follow the instructions provided to connect your sensor to the map. We welcome your participation and look forward to expanding our community together. Join us today!

YouTube video guide

',5),_hoisted_20$2=_withScopeId$5(()=>createBaseVNode("hr",null,null,-1)),_hoisted_21$2={class:"navlinks"},_hoisted_22$2={href:"https://github.com/airalab/sensors.robonomics.network",target:"_blank",rel:"noopener"},_hoisted_23$2={class:"popovercontrol",popovertarget:"about"};function _sfc_render$a(e,t,r,n,o,a){const l=resolveComponent("router-link"),c=resolveComponent("IconSensor"),u=resolveComponent("font-awesome-icon");return openBlock(),createElementBlock("header",_hoisted_1$8,[createBaseVNode("div",_hoisted_2$7,[createVNode(l,{to:"/",class:"appicon"},{default:withCtx(()=>[_hoisted_3$5]),_:1}),a.countPoints>0?(openBlock(),createElementBlock("b",_hoisted_4$4,[createVNode(c),createTextVNode(" "+toDisplayString$1(a.countPoints),1)])):createCommentVNode("",!0)]),createBaseVNode("div",_hoisted_5$4,[withDirectives(createBaseVNode("select",{"onUpdate:modelValue":t[0]||(t[0]=g=>o.locale=g)},_hoisted_8$4,512),[[vModelSelect,o.locale]]),createBaseVNode("div",_hoisted_9$4,[o.locale==="ru"?(openBlock(),createElementBlock(Fragment,{key:0},[_hoisted_10$3],64)):(openBlock(),createElementBlock(Fragment,{key:1},[_hoisted_15$2],64)),_hoisted_20$2,createBaseVNode("section",_hoisted_21$2,[createBaseVNode("a",_hoisted_22$2,toDisplayString$1(e.$t("links.github")),1),createVNode(l,{to:"/air-measurements"},{default:withCtx(()=>[createTextVNode(toDisplayString$1(e.$t("links.measurement")),1)]),_:1}),createVNode(l,{to:"/privacy-policy"},{default:withCtx(()=>[createTextVNode(toDisplayString$1(e.$t("links.privacy")),1)]),_:1})])]),createBaseVNode("button",_hoisted_23$2,[createVNode(u,{icon:"fa-solid fa-bars"})])])])}const Header=_export_sfc(_sfc_main$a,[["render",_sfc_render$a],["__scopeId","data-v-a4474917"]]),_imports_0=""+new URL("sensors-world-app.8a0828bb.png",import.meta.url).href,InstallPWA_vue_vue_type_style_index_0_scoped_b59a209f_lang="",_sfc_main$9={data(){return{deferredPrompt:null,isSupported:!1,db:null,isInstalled:"loading",isBrowserSupport:!0,browsers:{chrome:!1,safari:!1,firefox:!1,edge:!1,opera:!1}}},methods:{async getDb(){return new Promise((e,t)=>{let r=window.indexedDB.open("SensorsDB",1);r.onerror=n=>{console.log("Error opening db",n),t("Error")},r.onsuccess=n=>{e(n.target.result)},r.onupgradeneeded=n=>{n.target.result.createObjectStore("install",{autoIncrement:!0,keyPath:"id"})}})},async getData(){return new Promise(e=>{let t=this.db.transaction(["install"],"readonly");t.oncomplete=()=>{e(n)};let r=t.objectStore("install"),n=null;r.openCursor().onsuccess=o=>{let a=o.target.result;a&&(n=a.value,a.continue())}})},async addDataToDb(e=!1,t=!1){return new Promise(r=>{let n=this.db.transaction(["install"],"readwrite");n.oncomplete=()=>{r()};let o=n.objectStore("install");o.delete(1),o.add({id:1,removed:e,installed:t})})},async installApp(){if(this.addDataToDb(!1,!0),this.deferredPrompt!==null){this.deferredPrompt.prompt();const{outcome:e}=await this.deferredPrompt.userChoice;e==="accepted"&&(this.deferredPrompt=null,this.isSupported=!1,this.isInstalled="installed")}},removeInstall(){this.addDataToDb(!0,!1),this.isInstalled="removed"},checkBrowser(){let e=navigator.userAgent;this.browsers.chrome=e.indexOf("Chrome")>-1,this.browsers.firefox=e.indexOf("Firefox")>-1,this.browsers.safari=e.indexOf("Safari")>-1,this.browsers.chrome&&this.browsers.safari&&(this.browsers.safari=!1),this.browsers.opera=e.indexOf("OP")>-1,this.browsers.chrome&&this.browsers.opera&&(this.browsers.chrome=!1)}},async created(){this.db=await this.getDb(),this.isInstalled=await this.getData()?await this.getData():null},mounted(){window.addEventListener("beforeinstallprompt",e=>{this.isSupported=!0,this.deferredPrompt=e}),window.matchMedia("(display-mode: standalone)").matches?this.isSupported=!0:this.isSupported=!1,this.checkBrowser(),(this.browsers.safari||this.browsers.firefox||this.browsers.opera)&&(this.isBrowserSupport=!1)}},_withScopeId$4=e=>(pushScopeId("data-v-b59a209f"),e=e(),popScopeId(),e),_hoisted_1$7={key:0,class:"container install-pwa__container"},_hoisted_2$6={class:"install-pwa__content"},_hoisted_3$4=_withScopeId$4(()=>createBaseVNode("img",{src:_imports_0,alt:"sensors-cy-app"},null,-1)),_hoisted_4$3={class:"install-pwa__text"},_hoisted_5$3=_withScopeId$4(()=>createBaseVNode("h3",null,"Available as web application (PWA)",-1));function _sfc_render$9(e,t,r,n,o,a){return!o.isInstalled&&o.isBrowserSupport?(openBlock(),createElementBlock("div",_hoisted_1$7,[createBaseVNode("div",_hoisted_2$6,[_hoisted_3$4,createBaseVNode("div",_hoisted_4$3,[_hoisted_5$3,createBaseVNode("button",{onClick:t[0]||(t[0]=(...l)=>a.installApp&&a.installApp(...l)),class:"install-pwa__btn"},"Install")])]),createBaseVNode("button",{onClick:t[1]||(t[1]=(...l)=>a.removeInstall&&a.removeInstall(...l)),class:"install-pwa__remove"})])):createCommentVNode("",!0)}const InstallPWA=_export_sfc(_sfc_main$9,[["render",_sfc_render$9],["__scopeId","data-v-b59a209f"]]),MessagePopup_vue_vue_type_style_index_0_scoped_c5bfb7c2_lang="";function preloadImages(e,t){let r=0;const n={};function o(){if(r++,r==e.length){const a=[],l=[];for(const c of e)n[c]&&n[c]>0?(console.log(`Bad image ${c}`),l.push(c)):a.push(c);t(a,l)}}for(let a of e){let l=document.createElement("img");l.onload=()=>{n[a]=0,o()},l.onerror=()=>{n[a]||(n[a]=0),n[a]++,n[a]<3?l.src=a:o()},l.src=a}}const _sfc_main$8={props:["data"],data(){return{isImages:!1,images:[],badImages:[],imagesLoaded:!1,state:"neutral"}},computed:{dateMsg:function(){return hooks(this.data.timestamp,"X").format("DD.MM.YYYY HH:mm:ss")},classList(){return{["sensor-popup__header"]:!0,[`sensor-popup__header--${this.state}`]:this.state}}},watch:{data(){this.imagesLoad()}},created(){this.imagesLoad()},methods:{replaceWithBr(e){return e.replace(/\n/g,"
")},imagesLoad(){if(this.data.images&&this.data.images.length>0){this.images=[],this.badImages=[],this.imagesLoaded=!1,this.isImages=!0;const e=this.data.images.map(t=>`https://aira.mypinata.cloud/ipfs/${this.data.ipfs}/${t}`);preloadImages(e,(t,r)=>{t.length>0&&(this.images=t),r.length>0&&(this.badImages=r),this.imagesLoaded=!0})}else this.isImages=!1,this.images=[],this.badImages=[],this.imagesLoaded=!1}}},_hoisted_1$6={class:"container sensor-popup sensors-panel sensors-panel--center-right active popup-js"},_hoisted_2$5={class:"sensor-popup__header-icon"},_hoisted_3$3={class:"sensor-popup__header-wrapper"},_hoisted_4$2={class:"sensor-popup--subtitle"},_hoisted_5$2={ref:"content",class:"sensor-popup--content"},_hoisted_6$3=["innerHTML"],_hoisted_7$3={key:0},_hoisted_8$3=["href"],_hoisted_9$3=["src"],_hoisted_10$2=["href"];function _sfc_render$8(e,t,r,n,o,a){const l=resolveComponent("font-awesome-icon");return openBlock(),createElementBlock("div",_hoisted_1$6,[createBaseVNode("div",{class:normalizeClass(a.classList)},[createBaseVNode("div",_hoisted_2$5,[createVNode(l,{icon:"fa-solid fa-face-meh"})]),createBaseVNode("div",_hoisted_3$3,[createBaseVNode("h2",null,toDisplayString$1(e.$t("details.user"))+" "+toDisplayString$1(r.data.username),1),createBaseVNode("div",_hoisted_4$2,[createBaseVNode("span",null,[createVNode(l,{icon:"fa-solid fa-stopwatch"}),createTextVNode(" "+toDisplayString$1(a.dateMsg),1)])])])],2),createBaseVNode("div",_hoisted_5$2,[createBaseVNode("div",{innerHTML:a.replaceWithBr(r.data.message)},null,8,_hoisted_6$3),o.isImages?(openBlock(),createElementBlock(Fragment,{key:0},[createBaseVNode("h2",null,toDisplayString$1(e.$t("details.photos")),1),o.imagesLoaded?(openBlock(),createElementBlock(Fragment,{key:1},[(openBlock(!0),createElementBlock(Fragment,null,renderList(o.images,(c,u)=>(openBlock(),createElementBlock("div",{key:u},[createBaseVNode("a",{href:c,target:"_blank"},[createBaseVNode("img",{style:{"max-width":"400px"},src:c},null,8,_hoisted_9$3)],8,_hoisted_8$3)]))),128)),createBaseVNode("template",null,[(openBlock(!0),createElementBlock(Fragment,null,renderList(o.badImages,(c,u)=>(openBlock(),createElementBlock("a",{key:u,href:c,target:"_blank"},toDisplayString$1(c),9,_hoisted_10$2))),128))])],64)):(openBlock(),createElementBlock("div",_hoisted_7$3,"..."))],64)):createCommentVNode("",!0)],512),createBaseVNode("a",{class:"popup__close",href:"javascript:;",onClick:t[0]||(t[0]=withModifiers(c=>e.$emit("close"),["stop","prevent"]))},[createVNode(l,{icon:"fa-solid fa-xmark"})])])}const MessagePopup=_export_sfc(_sfc_main$8,[["render",_sfc_render$8],["__scopeId","data-v-c5bfb7c2"]]),Bookmark_vue_vue_type_style_index_0_scoped_8cca7f79_lang="",_sfc_main$7={props:["address","link"],data(){return{IsBookmarked:!1,db:null,bookmarks:[],bookmarkid:null,bookmarkname:"",store:useStore()}},computed:{buttonclasses(){return{button:!0,["button-green"]:this.IsBookmarked}}},methods:{async findbookmark(){return(await IDBgettable(this.store.idbBookmarkDbname,this.store.idbBookmarkVDbver,this.store.idbBookmarkVDbtable)).find(t=>t.address===this.$props.address)},async addbookmark(){await this.findbookmark()?this.bookmarkid&&IDBworkflow(this.store.idbBookmarkDbname,this.store.idbBookmarkVDbver,this.store.idbBookmarkVDbtable,"readwrite",r=>{const n=r.get(this.bookmarkid);n.addEventListener("error",o=>{console.log(o)}),n.addEventListener("success",o=>{const a=o.target.result;a.customName=this.bookmarkname;const l=r.put(a);l.addEventListener("error",c=>{console.log(c)}),l.addEventListener("success",c=>{this.IsBookmarked=!0})})}):IDBworkflow(this.store.idbBookmarkDbname,this.store.idbBookmarkVDbver,this.store.idbBookmarkVDbtable,"readwrite",r=>{r.add({customName:this.bookmarkname,address:this.$props.address,link:this.$props.link}),this.IsBookmarked=!0});const t=new BroadcastChannel(this.store.idbWatcherBroadcast);t.postMessage(!0),t.close()}},async mounted(){const e=await this.findbookmark();e&&(this.IsBookmarked=!0,this.bookmarkid=e.id,this.bookmarkname=e.customName)}},_hoisted_1$5=["placeholder"],_hoisted_2$4=["disabled","area-label"];function _sfc_render$7(e,t,r,n,o,a){const l=resolveComponent("font-awesome-icon");return openBlock(),createElementBlock("form",{class:"flexline",onSubmit:t[2]||(t[2]=withModifiers((...c)=>a.addbookmark&&a.addbookmark(...c),["prevent"]))},[withDirectives(createBaseVNode("input",{type:"text","onUpdate:modelValue":t[0]||(t[0]=c=>o.bookmarkname=c),placeholder:e.$t("sensorpopup.bookmarkplaceholder"),onInput:t[1]||(t[1]=c=>o.IsBookmarked=!1)},null,40,_hoisted_1$5),[[vModelText,o.bookmarkname]]),createBaseVNode("button",{class:normalizeClass(a.buttonclasses),disabled:o.IsBookmarked,"area-label":e.$t("sensorpopup.bookmarkbutton")},[o.IsBookmarked?(openBlock(),createBlock(l,{key:1,icon:"fa-solid fa-check"})):(openBlock(),createBlock(l,{key:0,icon:"fa-solid fa-bookmark"}))],10,_hoisted_2$4)],32)}const Bookmark=_export_sfc(_sfc_main$7,[["render",_sfc_render$7],["__scopeId","data-v-8cca7f79"]]);var highchartsVue_min={exports:{}},highcharts={exports:{}},hasRequiredHighcharts;function requireHighcharts(){return hasRequiredHighcharts||(hasRequiredHighcharts=1,function(e){(function(t,r){e.exports?(r.default=r,e.exports=t&&t.document?r(t):r):(t.Highcharts&&t.Highcharts.error(16,!0),t.Highcharts=r(t))})(typeof window<"u"?window:commonjsGlobal$2,function(t){var r={};function n(o,a,l,c){o.hasOwnProperty(a)||(o[a]=c.apply(null,l),typeof CustomEvent=="function"&&t.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:a,module:o[a]}})))}return n(r,"Core/Globals.js",[],function(){var o,a;return(a=o||(o={})).SVG_NS="http://www.w3.org/2000/svg",a.product="Highcharts",a.version="11.4.3",a.win=t!==void 0?t:{},a.doc=a.win.document,a.svg=a.doc&&a.doc.createElementNS&&!!a.doc.createElementNS(a.SVG_NS,"svg").createSVGRect,a.userAgent=a.win.navigator&&a.win.navigator.userAgent||"",a.isChrome=a.userAgent.indexOf("Chrome")!==-1,a.isFirefox=a.userAgent.indexOf("Firefox")!==-1,a.isMS=/(edge|msie|trident)/i.test(a.userAgent)&&!a.win.opera,a.isSafari=!a.isChrome&&a.userAgent.indexOf("Safari")!==-1,a.isTouchDevice=/(Mobile|Android|Windows Phone)/.test(a.userAgent),a.isWebKit=a.userAgent.indexOf("AppleWebKit")!==-1,a.deg2rad=2*Math.PI/360,a.hasBidiBug=a.isFirefox&&4>parseInt(a.userAgent.split("Firefox/")[1],10),a.marginNames=["plotTop","marginRight","marginBottom","plotLeft"],a.noop=function(){},a.supportsPassiveEvents=function(){let l=!1;if(!a.isMS){let c=Object.defineProperty({},"passive",{get:function(){l=!0}});a.win.addEventListener&&a.win.removeEventListener&&(a.win.addEventListener("testPassive",a.noop,c),a.win.removeEventListener("testPassive",a.noop,c))}return l}(),a.charts=[],a.composed=[],a.dateFormats={},a.seriesTypes={},a.symbolSizes={},a.chartCount=0,o}),n(r,"Core/Utilities.js",[r["Core/Globals.js"]],function(o){let a,{charts:l,doc:c,win:u}=o;function g(ae,ie,pe,ue){let ge=ie?"Highcharts error":"Highcharts warning";ae===32&&(ae=`${ge}: Deprecated member`);let ye=D(ae),Ae=ye?`${ge} #${ae}: www.highcharts.com/errors/${ae}/`:ae.toString();if(ue!==void 0){let Re="";ye&&(Ae+="?"),we(ue,function(We,Pe){Re+=` - ${Pe}: ${We}`,ye&&(Ae+=encodeURI(Pe)+"="+encodeURI(We))}),Ae+=Re}_e(o,"displayError",{chart:pe,code:ae,message:Ae,params:ue},function(){if(ie)throw Error(Ae);u.console&&g.messages.indexOf(Ae)===-1&&console.warn(Ae)}),g.messages.push(Ae)}function b(ae,ie){return parseInt(ae,ie||10)}function x(ae){return typeof ae=="string"}function S(ae){let ie=Object.prototype.toString.call(ae);return ie==="[object Array]"||ie==="[object Array Iterator]"}function $(ae,ie){return!!ae&&typeof ae=="object"&&(!ie||!S(ae))}function k(ae){return $(ae)&&typeof ae.nodeType=="number"}function T(ae){let ie=ae&&ae.constructor;return!!($(ae,!0)&&!k(ae)&&ie&&ie.name&&ie.name!=="Object")}function D(ae){return typeof ae=="number"&&!isNaN(ae)&&ae<1/0&&ae>-1/0}function I(ae){return ae!=null}function O(ae,ie,pe){let ue,ge=x(ie)&&!I(pe),ye=(Ae,Re)=>{I(Ae)?ae.setAttribute(Re,Ae):ge?(ue=ae.getAttribute(Re))||Re!=="class"||(ue=ae.getAttribute(Re+"Name")):ae.removeAttribute(Re)};return x(ie)?ye(pe,ie):we(ie,ye),ue}function N(ae){return S(ae)?ae:[ae]}function ee(ae,ie){let pe;for(pe in ae||(ae={}),ie)ae[pe]=ie[pe];return ae}function ne(){let ae=arguments,ie=ae.length;for(let pe=0;pe1e14?ae:parseFloat(ae.toPrecision(ie||14))}(g||(g={})).messages=[],Math.easeInOutSine=function(ae){return-.5*(Math.cos(Math.PI*ae)-1)};let xe=Array.prototype.find?function(ae,ie){return ae.find(ie)}:function(ae,ie){let pe,ue=ae.length;for(pe=0;peRe.order-We.order),ge.forEach(Re=>{Re.fn.call(ae,pe)===!1&&pe.preventDefault()})}ue&&!pe.defaultPrevented&&ue.call(ae,pe)}we({map:"map",each:"forEach",grep:"filter",reduce:"reduce",some:"some"},function(ae,ie){o[ie]=function(pe){return g(32,!1,void 0,{[`Highcharts.${ie}`]:`use Array.${ae}`}),Array.prototype[ae].apply(pe,[].slice.call(arguments,1))}});let ve=function(){let ae=Math.random().toString(36).substring(2,9)+"-",ie=0;return function(){return"highcharts-"+(a?"":ae)+ie++}}();return u.jQuery&&(u.jQuery.fn.highcharts=function(){let ae=[].slice.call(arguments);if(this[0])return ae[0]?(new o[x(ae[0])?ae.shift():"Chart"](this[0],ae[0],ae[1]),this):l[O(this[0],"data-highcharts-chart")]}),{addEvent:function(ae,ie,pe,ue={}){let ge=typeof ae=="function"&&ae.prototype||ae;Object.hasOwnProperty.call(ge,"hcEvents")||(ge.hcEvents={});let ye=ge.hcEvents;o.Point&&ae instanceof o.Point&&ae.series&&ae.series.chart&&(ae.series.chart.runTrackerClick=!0);let Ae=ae.addEventListener;Ae&&Ae.call(ae,ie,pe,!!o.supportsPassiveEvents&&{passive:ue.passive===void 0?ie.indexOf("touch")!==-1:ue.passive,capture:!1}),ye[ie]||(ye[ie]=[]);let Re={fn:pe,order:typeof ue.order=="number"?ue.order:1/0};return ye[ie].push(Re),ye[ie].sort((We,Pe)=>We.order-Pe.order),function(){he(ae,ie,pe)}},arrayMax:function(ae){let ie=ae.length,pe=ae[0];for(;ie--;)ae[ie]>pe&&(pe=ae[ie]);return pe},arrayMin:function(ae){let ie=ae.length,pe=ae[0];for(;ie--;)ae[ie]ie?ae{let ue=ie%2/2,ge=pe?-1:1;return(Math.round(ae*ge-ue)+ue)*ge},css:B,defined:I,destroyObjectProperties:function(ae,ie,pe){we(ae,function(ue,ge){ue!==ie&&ue?.destroy&&ue.destroy(),(ue?.destroy||!pe)&&delete ae[ge]})},diffObjects:function(ae,ie,pe,ue){let ge={};return function ye(Ae,Re,We,Pe){let Ue=pe?Re:Ae;we(Ae,function(Oe,Be){if(!Pe&&ue&&ue.indexOf(Be)>-1&&Re[Be]){Oe=N(Oe),We[Be]=[];for(let Ye=0;Ye{if(Ae.length>1)for(ge=Ae.length-1;ge>0;ge--)(ue=Ae[ge]-Ae[ge-1])<0&&!ye?(ie?.(),ie=void 0):ue&&(pe===void 0||ue=Ae-1&&(Ae=Math.floor(Re)),Math.max(0,Ae-(ae(ie,"padding-left",!0)||0)-(ae(ie,"padding-right",!0)||0))}if(pe==="height")return Math.max(0,Math.min(ie.offsetHeight,ie.scrollHeight)-(ae(ie,"padding-top",!0)||0)-(ae(ie,"padding-bottom",!0)||0));let ye=u.getComputedStyle(ie,void 0);return ye&&(ge=ye.getPropertyValue(pe),ne(ue,pe!=="opacity")&&(ge=b(ge))),ge},inArray:function(ae,ie,pe){return g(32,!1,void 0,{"Highcharts.inArray":"use Array.indexOf"}),ie.indexOf(ae,pe)},insertItem:function(ae,ie){let pe,ue=ae.options.index,ge=ie.length;for(pe=ae.options.isInternal?ge:0;pe=ae))&&(ge||!(Re<=(ie[ye]+(ie[ye+1]||ie[ye]))/2)));ye++);return fe(Ae*pe,-Math.round(Math.log(.001)/Math.LN10))},objectEach:we,offset:function(ae){let ie=c.documentElement,pe=ae.parentElement||ae.parentNode?ae.getBoundingClientRect():{top:0,left:0,width:0,height:0};return{top:pe.top+(u.pageYOffset||ie.scrollTop)-(ie.clientTop||0),left:pe.left+(u.pageXOffset||ie.scrollLeft)-(ie.clientLeft||0),width:pe.width,height:pe.height}},pad:function(ae,ie,pe){return Array((ie||2)+1-String(ae).replace("-","").length).join(pe||"0")+ae},pick:ne,pInt:b,pushUnique:function(ae,ie){return 0>ae.indexOf(ie)&&!!ae.push(ie)},relativeLength:function(ae,ie,pe){return/%$/.test(ae)?ie*parseFloat(ae)/100+(pe||0):parseFloat(ae)},removeEvent:he,replaceNested:function(ae,...ie){let pe,ue;do for(ue of(pe=ae,ie))ae=ae.replace(ue[0],ue[1]);while(ae!==pe);return ae},splat:N,stableSort:function(ae,ie){let pe,ue,ge=ae.length;for(ue=0;ue0?setTimeout(ae,ie,pe):(ae.call(0,pe),-1)},timeUnits:{millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:24192e5,year:314496e5},uniqueKey:ve,useSerialIds:function(ae){return a=ne(ae,a)},wrap:function(ae,ie,pe){let ue=ae[ie];ae[ie]=function(){let ge=arguments,ye=this;return pe.apply(this,[function(){return ue.apply(ye,arguments.length?arguments:ge)}].concat([].slice.call(arguments)))}}}}),n(r,"Core/Chart/ChartDefaults.js",[],function(){return{alignThresholds:!1,panning:{enabled:!1,type:"x"},styledMode:!1,borderRadius:0,colorCount:10,allowMutatingData:!0,ignoreHiddenSeries:!0,spacing:[10,10,15,10],resetZoomButton:{theme:{},position:{}},reflow:!0,type:"line",zooming:{singleTouch:!1,resetButton:{theme:{zIndex:6},position:{align:"right",x:-10,y:10}}},width:null,height:null,borderColor:"#334eff",backgroundColor:"#ffffff",plotBorderColor:"#cccccc"}}),n(r,"Core/Color/Palettes.js",[],function(){return{colors:["#2caffe","#544fc5","#00e272","#fe6a35","#6b8abc","#d568fb","#2ee0ca","#fa4b42","#feb56a","#91e8e1"]}}),n(r,"Core/Time.js",[r["Core/Globals.js"],r["Core/Utilities.js"]],function(o,a){let{win:l}=o,{defined:c,error:u,extend:g,isNumber:b,isObject:x,merge:S,objectEach:$,pad:k,pick:T,splat:D,timeUnits:I}=a,O=o.isSafari&&l.Intl&&l.Intl.DateTimeFormat.prototype.formatRange,N=o.isSafari&&l.Intl&&!l.Intl.DateTimeFormat.prototype.formatRange;class ee{constructor(B){this.options={},this.useUTC=!1,this.variableTimezone=!1,this.Date=l.Date,this.getTimezoneOffset=this.timezoneOffsetFunction(),this.update(B)}get(B,le){if(this.variableTimezone||this.timezoneOffset){let fe=le.getTime(),xe=fe-this.getTimezoneOffset(le);le.setTime(xe);let we=le["getUTC"+B]();return le.setTime(fe),we}return this.useUTC?le["getUTC"+B]():le["get"+B]()}set(B,le,fe){if(this.variableTimezone||this.timezoneOffset){if(B==="Milliseconds"||B==="Seconds"||B==="Minutes"&&this.getTimezoneOffset(le)%36e5==0)return le["setUTC"+B](fe);let xe=this.getTimezoneOffset(le),we=le.getTime()-xe;le.setTime(we),le["setUTC"+B](fe);let he=this.getTimezoneOffset(le);return we=le.getTime()+he,le.setTime(we)}return this.useUTC||O&&B==="FullYear"?le["setUTC"+B](fe):le["set"+B](fe)}update(B={}){let le=T(B.useUTC,!0);this.options=B=S(!0,this.options,B),this.Date=B.Date||l.Date||Date,this.useUTC=le,this.timezoneOffset=le&&B.timezoneOffset||void 0,this.getTimezoneOffset=this.timezoneOffsetFunction(),this.variableTimezone=le&&!!(B.getTimezoneOffset||B.timezone)}makeTime(B,le,fe,xe,we,he){let _e,ve,ae;return this.useUTC?(_e=this.Date.UTC.apply(0,arguments),ve=this.getTimezoneOffset(_e),_e+=ve,ve!==(ae=this.getTimezoneOffset(_e))?_e+=ae-ve:ve-36e5!==this.getTimezoneOffset(_e-36e5)||N||(_e-=36e5)):_e=new this.Date(B,le,T(fe,1),T(xe,0),T(we,0),T(he,0)).getTime(),_e}timezoneOffsetFunction(){let B=this,le=this.options,fe=le.getTimezoneOffset;return this.useUTC?le.timezone?xe=>{try{let we=`shortOffset,${le.timezone||""}`,[he,_e,ve,ae,ie=0]=(ee.formatCache[we]=ee.formatCache[we]||Intl.DateTimeFormat("en",{timeZone:le.timezone,timeZoneName:"shortOffset"})).format(xe).split(/(GMT|:)/).map(Number),pe=-(36e5*(ve+ie/60));if(b(pe))return pe}catch{u(34)}return 0}:this.useUTC&&fe?xe=>6e4*fe(xe.valueOf()):()=>6e4*(B.timezoneOffset||0):xe=>6e4*new Date(xe.toString()).getTimezoneOffset()}dateFormat(B,le,fe){if(!c(le)||isNaN(le))return o.defaultOptions.lang&&o.defaultOptions.lang.invalidDate||"";B=T(B,"%Y-%m-%d %H:%M:%S");let xe=this,we=new this.Date(le),he=this.get("Hours",we),_e=this.get("Day",we),ve=this.get("Date",we),ae=this.get("Month",we),ie=this.get("FullYear",we),pe=o.defaultOptions.lang,ue=pe&&pe.weekdays,ge=pe&&pe.shortWeekdays;return $(g({a:ge?ge[_e]:ue[_e].substr(0,3),A:ue[_e],d:k(ve),e:k(ve,2," "),w:_e,b:pe.shortMonths[ae],B:pe.months[ae],m:k(ae+1),o:ae+1,y:ie.toString().substr(2,2),Y:ie,H:k(he),k:he,I:k(he%12||12),l:he%12||12,M:k(this.get("Minutes",we)),p:he<12?"AM":"PM",P:he<12?"am":"pm",S:k(this.get("Seconds",we)),L:k(Math.floor(le%1e3),3)},o.dateFormats),function(ye,Ae){for(;B.indexOf("%"+Ae)!==-1;)B=B.replace("%"+Ae,typeof ye=="function"?ye.call(xe,le):ye)}),fe?B.substr(0,1).toUpperCase()+B.substr(1):B}resolveDTLFormat(B){return x(B,!0)?B:{main:(B=D(B))[0],from:B[1],to:B[2]}}getTimeTicks(B,le,fe,xe){let we,he,_e,ve,ae=this,ie=ae.Date,pe=[],ue={},ge=new ie(le),ye=B.unitRange,Ae=B.count||1;if(xe=T(xe,1),c(le)){ae.set("Milliseconds",ge,ye>=I.second?0:Ae*Math.floor(ae.get("Milliseconds",ge)/Ae)),ye>=I.second&&ae.set("Seconds",ge,ye>=I.minute?0:Ae*Math.floor(ae.get("Seconds",ge)/Ae)),ye>=I.minute&&ae.set("Minutes",ge,ye>=I.hour?0:Ae*Math.floor(ae.get("Minutes",ge)/Ae)),ye>=I.hour&&ae.set("Hours",ge,ye>=I.day?0:Ae*Math.floor(ae.get("Hours",ge)/Ae)),ye>=I.day&&ae.set("Date",ge,ye>=I.month?1:Math.max(1,Ae*Math.floor(ae.get("Date",ge)/Ae))),ye>=I.month&&(ae.set("Month",ge,ye>=I.year?0:Ae*Math.floor(ae.get("Month",ge)/Ae)),he=ae.get("FullYear",ge)),ye>=I.year&&(he-=he%Ae,ae.set("FullYear",ge,he)),ye===I.week&&(ve=ae.get("Day",ge),ae.set("Date",ge,ae.get("Date",ge)-ve+xe+(ve4*I.month||ae.getTimezoneOffset(le)!==ae.getTimezoneOffset(fe));let Ue=ge.getTime();for(we=1;Ue1?Ue=ae.makeTime(he,Re,We,Pe+we*Ae):Ue+=ye*Ae,we++;pe.push(Ue),ye<=I.hour&&pe.length<1e4&&pe.forEach(function(Oe){Oe%18e5==0&&ae.dateFormat("%H%M%S%L",Oe)==="000000000"&&(ue[Oe]="day")})}return pe.info=g(B,{higherRanks:ue,totalRange:ye*Ae}),pe}getDateFormat(B,le,fe,xe){let we=this.dateFormat("%m-%d %H:%M:%S.%L",le),he="01-01 00:00:00.000",_e={millisecond:15,second:12,minute:9,hour:6,day:3},ve="millisecond",ae=ve;for(ve in I){if(B===I.week&&+this.dateFormat("%w",le)===fe&&we.substr(6)===he.substr(6)){ve="week";break}if(I[ve]>B){ve=ae;break}if(_e[ve]&&we.substr(_e[ve])!==he.substr(_e[ve]))break;ve!=="week"&&(ae=ve)}return this.resolveDTLFormat(xe[ve]).main}}return ee.formatCache={},ee}),n(r,"Core/Defaults.js",[r["Core/Chart/ChartDefaults.js"],r["Core/Globals.js"],r["Core/Color/Palettes.js"],r["Core/Time.js"],r["Core/Utilities.js"]],function(o,a,l,c,u){let{isTouchDevice:g}=a,{fireEvent:b,merge:x}=u,S={colors:l.colors,symbols:["circle","diamond","square","triangle","triangle-down"],lang:{loading:"Loading...",months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],decimalPoint:".",numericSymbols:["k","M","G","T","P","E"],resetZoom:"Reset zoom",resetZoomTitle:"Reset zoom level 1:1",thousandsSep:" "},global:{buttonTheme:{fill:"#f7f7f7",padding:8,r:2,stroke:"#cccccc","stroke-width":1,style:{color:"#333333",cursor:"pointer",fontSize:"0.8em",fontWeight:"normal"},states:{hover:{fill:"#e6e6e6"},select:{fill:"#e6e9ff",style:{color:"#000000",fontWeight:"bold"}},disabled:{style:{color:"#cccccc"}}}}},time:{Date:void 0,getTimezoneOffset:void 0,timezone:void 0,timezoneOffset:0,useUTC:!0},chart:o,title:{style:{color:"#333333",fontWeight:"bold"},text:"Chart title",align:"center",margin:15,widthAdjust:-44},subtitle:{style:{color:"#666666",fontSize:"0.8em"},text:"",align:"center",widthAdjust:-44},caption:{margin:15,style:{color:"#666666",fontSize:"0.8em"},text:"",align:"left",verticalAlign:"bottom"},plotOptions:{},legend:{enabled:!0,align:"center",alignColumns:!0,className:"highcharts-no-tooltip",layout:"horizontal",itemMarginBottom:2,itemMarginTop:2,labelFormatter:function(){return this.name},borderColor:"#999999",borderRadius:0,navigation:{style:{fontSize:"0.8em"},activeColor:"#0022ff",inactiveColor:"#cccccc"},itemStyle:{color:"#333333",cursor:"pointer",fontSize:"0.8em",textDecoration:"none",textOverflow:"ellipsis"},itemHoverStyle:{color:"#000000"},itemHiddenStyle:{color:"#666666",textDecoration:"line-through"},shadow:!1,itemCheckboxStyle:{position:"absolute",width:"13px",height:"13px"},squareSymbol:!0,symbolPadding:5,verticalAlign:"bottom",x:0,y:0,title:{style:{fontSize:"0.8em",fontWeight:"bold"}}},loading:{labelStyle:{fontWeight:"bold",position:"relative",top:"45%"},style:{position:"absolute",backgroundColor:"#ffffff",opacity:.5,textAlign:"center"}},tooltip:{enabled:!0,animation:{duration:300,easing:k=>Math.sqrt(1-Math.pow(k-1,2))},borderRadius:3,dateTimeLabelFormats:{millisecond:"%A, %e %b, %H:%M:%S.%L",second:"%A, %e %b, %H:%M:%S",minute:"%A, %e %b, %H:%M",hour:"%A, %e %b, %H:%M",day:"%A, %e %b %Y",week:"Week from %A, %e %b %Y",month:"%B %Y",year:"%Y"},footerFormat:"",headerShape:"callout",hideDelay:500,padding:8,shape:"callout",shared:!1,snap:g?25:10,headerFormat:'{point.key}
',pointFormat:'\u25CF {series.name}: {point.y}
',backgroundColor:"#ffffff",borderWidth:void 0,shadow:!0,stickOnContact:!1,style:{color:"#333333",cursor:"default",fontSize:"0.8em"},useHTML:!1},credits:{enabled:!0,href:"https://www.highcharts.com?credits",position:{align:"right",x:-10,verticalAlign:"bottom",y:-5},style:{cursor:"pointer",color:"#999999",fontSize:"0.6em"},text:"Highcharts.com"}};S.chart.styledMode=!1;let $=new c(S.time);return{defaultOptions:S,defaultTime:$,getOptions:function(){return S},setOptions:function(k){return b(a,"setOptions",{options:k}),x(!0,S,k),(k.time||k.global)&&(a.time?a.time.update(x(S.global,S.time,k.global,k.time)):a.time=$),S}}}),n(r,"Core/Color/Color.js",[r["Core/Globals.js"],r["Core/Utilities.js"]],function(o,a){let{isNumber:l,merge:c,pInt:u}=a;class g{static parse(x){return x?new g(x):g.None}constructor(x){let S,$,k,T;this.rgba=[NaN,NaN,NaN,NaN],this.input=x;let D=o.Color;if(D&&D!==g)return new D(x);if(typeof x=="object"&&x.stops!==void 0)this.stops=x.stops.map(I=>new g(I[1]));else if(typeof x=="string"){if(this.input=x=g.names[x.toLowerCase()]||x,x.charAt(0)==="#"){let I=x.length,O=parseInt(x.substr(1),16);I===7?$=[(16711680&O)>>16,(65280&O)>>8,255&O,1]:I===4&&($=[(3840&O)>>4|(3840&O)>>8,(240&O)>>4|240&O,(15&O)<<4|15&O,1])}if(!$)for(k=g.parsers.length;k--&&!$;)(S=(T=g.parsers[k]).regex.exec(x))&&($=T.parse(S))}$&&(this.rgba=$)}get(x){let S=this.input,$=this.rgba;if(typeof S=="object"&&this.stops!==void 0){let k=c(S);return k.stops=[].slice.call(k.stops),this.stops.forEach((T,D)=>{k.stops[D]=[k.stops[D][0],T.get(x)]}),k}return $&&l($[0])?x!=="rgb"&&(x||$[3]!==1)?x==="a"?`${$[3]}`:"rgba("+$.join(",")+")":"rgb("+$[0]+","+$[1]+","+$[2]+")":S}brighten(x){let S=this.rgba;if(this.stops)this.stops.forEach(function($){$.brighten(x)});else if(l(x)&&x!==0)for(let $=0;$<3;$++)S[$]+=u(255*x),S[$]<0&&(S[$]=0),S[$]>255&&(S[$]=255);return this}setOpacity(x){return this.rgba[3]=x,this}tweenTo(x,S){let $=this.rgba,k=x.rgba;if(!l($[0])||!l(k[0]))return x.input||"none";let T=k[3]!==1||$[3]!==1;return(T?"rgba(":"rgb(")+Math.round(k[0]+($[0]-k[0])*(1-S))+","+Math.round(k[1]+($[1]-k[1])*(1-S))+","+Math.round(k[2]+($[2]-k[2])*(1-S))+(T?","+(k[3]+($[3]-k[3])*(1-S)):"")+")"}}return g.names={white:"#ffffff",black:"#000000"},g.parsers=[{regex:/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,parse:function(b){return[u(b[1]),u(b[2]),u(b[3]),parseFloat(b[4],10)]}},{regex:/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,parse:function(b){return[u(b[1]),u(b[2]),u(b[3]),1]}}],g.None=new g(""),g}),n(r,"Core/Animation/Fx.js",[r["Core/Color/Color.js"],r["Core/Globals.js"],r["Core/Utilities.js"]],function(o,a,l){let{parse:c}=o,{win:u}=a,{isNumber:g,objectEach:b}=l;class x{constructor($,k,T){this.pos=NaN,this.options=k,this.elem=$,this.prop=T}dSetter(){let $=this.paths,k=$&&$[0],T=$&&$[1],D=this.now||0,I=[];if(D!==1&&k&&T)if(k.length===T.length&&D<1)for(let O=0;O=ee+this.startTime?(this.now=this.end,this.pos=1,this.update(),ne[this.prop]=!0,T=!0,b(ne,function(B){B!==!0&&(T=!1)}),T&&N&&N.call(O),k=!1):(this.pos=I.easing((D-this.startTime)/ee),this.now=this.start+(this.end-this.start)*this.pos,this.update(),k=!0),k}initPath($,k,T){let D=$.startX,I=$.endX,O=T.slice(),N=$.isArea,ee=N?2:1,ne,B,le,fe,xe=k&&k.slice();if(!xe)return[O,O];function we(_e,ve){for(;_e.length{let fe=k(le.options.animation);ne=b(I)&&l(I.defer)?N.defer:Math.max(ne,fe.duration+fe.defer),B=Math.min(N.duration,fe.duration)}),D.renderer.forExport&&(ne=0),{defer:Math.max(0,ne-B),duration:Math.min(ne,B)}},setAnimation:function(D,I){I.renderer.globalAnimation=$(D,I.options.chart.animation,!0)},stop:T}}),n(r,"Core/Renderer/HTML/AST.js",[r["Core/Globals.js"],r["Core/Utilities.js"]],function(o,a){let{SVG_NS:l,win:c}=o,{attr:u,createElement:g,css:b,error:x,isFunction:S,isString:$,objectEach:k,splat:T}=a,{trustedTypes:D}=c,I=D&&S(D.createPolicy)&&D.createPolicy("highcharts",{createHTML:ne=>ne}),O=I?I.createHTML(""):"",N=function(){try{return!!new DOMParser().parseFromString(O,"text/html")}catch{return!1}}();class ee{static filterUserAttributes(B){return k(B,(le,fe)=>{let xe=!0;ee.allowedAttributes.indexOf(fe)===-1&&(xe=!1),["background","dynsrc","href","lowsrc","src"].indexOf(fe)!==-1&&(xe=$(le)&&ee.allowedReferences.some(we=>le.indexOf(we)===0)),xe||(x(33,!1,void 0,{"Invalid attribute in config":`${fe}`}),delete B[fe]),$(le)&&B[fe]&&(B[fe]=le.replace(/{let xe=fe.split(":").map(he=>he.trim()),we=xe.shift();return we&&xe.length&&(le[we.replace(/-([a-z])/g,he=>he[1].toUpperCase())]=xe.join(":")),le},{})}static setElementHTML(B,le){B.innerHTML=ee.emptyHTML,le&&new ee(le).addToDOM(B)}constructor(B){this.nodes=typeof B=="string"?this.parseMarkup(B):B}addToDOM(B){return function le(fe,xe){let we;return T(fe).forEach(function(he){let _e,ve=he.tagName,ae=he.textContent?o.doc.createTextNode(he.textContent):void 0,ie=ee.bypassHTMLFiltering;if(ve)if(ve==="#text")_e=ae;else if(ee.allowedTags.indexOf(ve)!==-1||ie){let pe=ve==="svg"?l:xe.namespaceURI||l,ue=o.doc.createElementNS(pe,ve),ge=he.attributes||{};k(he,function(ye,Ae){Ae!=="tagName"&&Ae!=="attributes"&&Ae!=="children"&&Ae!=="style"&&Ae!=="textContent"&&(ge[Ae]=ye)}),u(ue,ie?ge:ee.filterUserAttributes(ge)),he.style&&b(ue,he.style),ae&&ue.appendChild(ae),le(he.children||[],ue),_e=ue}else x(33,!1,void 0,{"Invalid tagName in config":ve});_e&&xe.appendChild(_e),we=_e}),we}(this.nodes,B)}parseMarkup(B){let le,fe=[];if(B=B.trim().replace(/ style=(["'])/g," data-style=$1"),N)le=new DOMParser().parseFromString(I?I.createHTML(B):B,"text/html");else{let we=g("div");we.innerHTML=B,le={body:we}}let xe=(we,he)=>{let _e=we.nodeName.toLowerCase(),ve={tagName:_e};_e==="#text"&&(ve.textContent=we.textContent||"");let ae=we.attributes;if(ae){let ie={};[].forEach.call(ae,pe=>{pe.name==="data-style"?ve.style=ee.parseStyle(pe.value):ie[pe.name]=pe.value}),ve.attributes=ie}if(we.childNodes.length){let ie=[];[].forEach.call(we.childNodes,pe=>{xe(pe,ie)}),ie.length&&(ve.children=ie)}he.push(ve)};return[].forEach.call(le.body.childNodes,we=>xe(we,fe)),fe}}return ee.allowedAttributes=["alt","aria-controls","aria-describedby","aria-expanded","aria-haspopup","aria-hidden","aria-label","aria-labelledby","aria-live","aria-pressed","aria-readonly","aria-roledescription","aria-selected","class","clip-path","color","colspan","cx","cy","d","dx","dy","disabled","fill","filterUnits","flood-color","flood-opacity","height","href","id","in","markerHeight","markerWidth","offset","opacity","orient","padding","paddingLeft","paddingRight","patternUnits","r","refX","refY","role","scope","slope","src","startOffset","stdDeviation","stroke","stroke-linecap","stroke-width","style","tableValues","result","rowspan","summary","target","tabindex","text-align","text-anchor","textAnchor","textLength","title","type","valign","width","x","x1","x2","xlink:href","y","y1","y2","zIndex"],ee.allowedReferences=["https://","http://","mailto:","/","../","./","#"],ee.allowedTags=["a","abbr","b","br","button","caption","circle","clipPath","code","dd","defs","div","dl","dt","em","feComponentTransfer","feDropShadow","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feOffset","feMerge","feMergeNode","filter","h1","h2","h3","h4","h5","h6","hr","i","img","li","linearGradient","marker","ol","p","path","pattern","pre","rect","small","span","stop","strong","style","sub","sup","svg","table","text","textPath","thead","title","tbody","tspan","td","th","tr","u","ul","#text"],ee.emptyHTML=O,ee.bypassHTMLFiltering=!1,ee}),n(r,"Core/Templating.js",[r["Core/Defaults.js"],r["Core/Utilities.js"]],function(o,a){let{defaultOptions:l,defaultTime:c}=o,{extend:u,getNestedProperty:g,isArray:b,isNumber:x,isObject:S,pick:$,pInt:k}=a,T={add:(O,N)=>O+N,divide:(O,N)=>N!==0?O/N:"",eq:(O,N)=>O==N,each:function(O){let N=arguments[arguments.length-1];return!!b(O)&&O.map((ee,ne)=>D(N.body,u(S(ee)?ee:{"@this":ee},{"@index":ne,"@first":ne===0,"@last":ne===O.length-1}))).join("")},ge:(O,N)=>O>=N,gt:(O,N)=>O>N,if:O=>!!O,le:(O,N)=>O<=N,lt:(O,N)=>OO*N,ne:(O,N)=>O!=N,subtract:(O,N)=>O-N,unless:O=>!O};function D(O="",N,ee){let ne=/\{([a-zA-Z0-9\:\.\,;\-\/<>%_@"'= #\(\)]+)\}/g,B=/\(([a-zA-Z0-9\:\.\,;\-\/<>%_@"'= ]+)\)/g,le=[],fe=/f$/,xe=/\.([0-9])/,we=l.lang,he=ee&&ee.time||c,_e=ee&&ee.numberFormatter||I,ve=(ge="")=>{let ye;return ge==="true"||ge!=="false"&&((ye=Number(ge)).toString()===ge?ye:g(ge,N))},ae,ie,pe=0,ue;for(;(ae=ne.exec(O))!==null;){let ge=B.exec(ae[1]);ge&&(ae=ge,ue=!0),ie&&ie.isBlock||(ie={ctx:N,expression:ae[1],find:ae[0],isBlock:ae[1].charAt(0)==="#",start:ae.index,startInner:ae.index+ae[0].length,length:ae[0].length});let ye=ae[1].split(" ")[0].replace("#","");T[ye]&&(ie.isBlock&&ye===ie.fn&&pe++,ie.fn||(ie.fn=ye));let Ae=ae[1]==="else";if(ie.isBlock&&ie.fn&&(ae[1]===`/${ie.fn}`||Ae))if(pe)!Ae&&pe--;else{let Re=ie.startInner,We=O.substr(Re,ae.index-Re);ie.body===void 0?(ie.body=We,ie.startInner=ae.index+ae[0].length):ie.elseBody=We,ie.find+=We+ae[0],Ae||(le.push(ie),ie=void 0)}else ie.isBlock||le.push(ie);if(ge&&!ie?.isBlock)break}return le.forEach(ge=>{let ye,Ae,{body:Re,elseBody:We,expression:Pe,fn:Ue}=ge;if(Ue){let Oe=[ge],Be=Pe.split(" ");for(Ae=T[Ue].length;Ae--;)Oe.unshift(ve(Be[Ae+1]));ye=T[Ue].apply(N,Oe),ge.isBlock&&typeof ye=="boolean"&&(ye=D(ye?Re:We,N,ee))}else{let Oe=Pe.split(":");if(ye=ve(Oe.shift()||""),Oe.length&&typeof ye=="number"){let Be=Oe.join(":");if(fe.test(Be)){let Ye=parseInt((Be.match(xe)||["","-1"])[1],10);ye!==null&&(ye=_e(ye,Ye,we.decimalPoint,Be.indexOf(",")>-1?we.thousandsSep:""))}else ye=he.dateFormat(Be,ye)}}O=O.replace(ge.find,$(ye,""))}),ue?D(O,N,ee):O}function I(O,N,ee,ne){let B,le;O=+O||0,N=+N;let fe=l.lang,xe=(O.toString().split(".")[1]||"").split("e")[0].length,we=O.toString().split("e"),he=N;N===-1?N=Math.min(xe,20):x(N)?N&&we[1]&&we[1]<0&&((le=N+ +we[1])>=0?(we[0]=(+we[0]).toExponential(le).split("e")[0],N=le):(we[0]=we[0].split(".")[0]||0,O=N<20?(we[0]*Math.pow(10,we[1])).toFixed(N):0,we[1]=0)):N=2;let _e=(Math.abs(we[1]?we[0]:O)+Math.pow(10,-Math.max(N,xe)-1)).toFixed(N),ve=String(k(_e)),ae=ve.length>3?ve.length%3:0;return ee=$(ee,fe.decimalPoint),ne=$(ne,fe.thousandsSep),B=(O<0?"-":"")+(ae?ve.substr(0,ae)+ne:""),0>+we[1]&&!he?B="0":B+=ve.substr(ae).replace(/(\d{3})(?=\d)/g,"$1"+ne),N?B+=ee+_e.slice(-N):+B==0&&(B="0"),we[1]&&+B!=0&&(B+="e"+we[1]),B}return{dateFormat:function(O,N,ee){return c.dateFormat(O,N,ee)},format:D,helpers:T,numberFormat:I}}),n(r,"Core/Renderer/RendererRegistry.js",[r["Core/Globals.js"]],function(o){var a,l;let c;return(l=a||(a={})).rendererTypes={},l.getRendererType=function(u=c){return l.rendererTypes[u]||l.rendererTypes[c]},l.registerRendererType=function(u,g,b){l.rendererTypes[u]=g,(!c||b)&&(c=u,o.Renderer=g)},a}),n(r,"Core/Renderer/RendererUtilities.js",[r["Core/Utilities.js"]],function(o){var a;let{clamp:l,pick:c,pushUnique:u,stableSort:g}=o;return(a||(a={})).distribute=function b(x,S,$){let k=x,T=k.reducedLen||S,D=(ve,ae)=>ve.target-ae.target,I=[],O=x.length,N=[],ee=I.push,ne,B,le,fe=!0,xe,we,he=0,_e;for(ne=O;ne--;)he+=x[ne].size;if(he>T){for(g(x,(ve,ae)=>(ae.rank||0)-(ve.rank||0)),le=(_e=x[0].rank===x[x.length-1].rank)?O/2:-1,B=_e?le:O-1;le&&he>T;)xe=x[ne=Math.floor(B)],u(N,ne)&&(he-=xe.size),B+=le,_e&&B>=x.length&&(le/=2,B=le);N.sort((ve,ae)=>ae-ve).forEach(ve=>ee.apply(I,x.splice(ve,1)))}for(g(x,D),x=x.map(ve=>({size:ve.size,targets:[ve.target],align:c(ve.align,.5)}));fe;){for(ne=x.length;ne--;)xe=x[ne],we=(Math.min.apply(0,xe.targets)+Math.max.apply(0,xe.targets))/2,xe.pos=l(we-xe.size*xe.align,0,S-xe.size);for(ne=x.length,fe=!1;ne--;)ne>0&&x[ne-1].pos+x[ne-1].size>x[ne].pos&&(x[ne-1].size+=x[ne].size,x[ne-1].targets=x[ne-1].targets.concat(x[ne].targets),x[ne-1].align=.5,x[ne-1].pos+x[ne-1].size>S&&(x[ne-1].pos=S-x[ne-1].size),x.splice(ne,1),fe=!0)}return ee.apply(k,I),ne=0,x.some(ve=>{let ae=0;return(ve.targets||[]).some(()=>(k[ne].pos=ve.pos+ae,$!==void 0&&Math.abs(k[ne].pos-k[ne].target)>$?(k.slice(0,ne+1).forEach(ie=>delete ie.pos),k.reducedLen=(k.reducedLen||S)-.1*S,k.reducedLen>.1*S&&b(k,S,$),!0):(ae+=k[ne].size,ne++,!1)))}),g(k,D),k},a}),n(r,"Core/Renderer/SVG/SVGElement.js",[r["Core/Animation/AnimationUtilities.js"],r["Core/Color/Color.js"],r["Core/Globals.js"],r["Core/Utilities.js"]],function(o,a,l,c){let{animate:u,animObject:g,stop:b}=o,{deg2rad:x,doc:S,svg:$,SVG_NS:k,win:T}=l,{addEvent:D,attr:I,createElement:O,crisp:N,css:ee,defined:ne,erase:B,extend:le,fireEvent:fe,isArray:xe,isFunction:we,isObject:he,isString:_e,merge:ve,objectEach:ae,pick:ie,pInt:pe,pushUnique:ue,replaceNested:ge,syncTimeout:ye,uniqueKey:Ae}=c;class Re{_defaultGetter(Pe){let Ue=ie(this[Pe+"Value"],this[Pe],this.element?this.element.getAttribute(Pe):null,0);return/^[\-0-9\.]+$/.test(Ue)&&(Ue=parseFloat(Ue)),Ue}_defaultSetter(Pe,Ue,Oe){Oe.setAttribute(Ue,Pe)}add(Pe){let Ue,Oe=this.renderer,Be=this.element;return Pe&&(this.parentGroup=Pe),this.textStr!==void 0&&this.element.nodeName==="text"&&Oe.buildText(this),this.added=!0,(!Pe||Pe.handleZ||this.zIndex)&&(Ue=this.zIndexSetter()),Ue||(Pe?Pe.element:Oe.box).appendChild(Be),this.onAdd&&this.onAdd(),this}addClass(Pe,Ue){let Oe=Ue?"":this.attr("class")||"";return(Pe=(Pe||"").split(/ /g).reduce(function(Be,Ye){return Oe.indexOf(Ye)===-1&&Be.push(Ye),Be},Oe?[Oe]:[]).join(" "))!==Oe&&this.attr("class",Pe),this}afterSetters(){this.doTransform&&(this.updateTransform(),this.doTransform=!1)}align(Pe,Ue,Oe,Be=!0){let Ye,Se,Te,$e,Ve={},oe=this.renderer,te=oe.alignedObjects,se=!!Pe;Pe?(this.alignOptions=Pe,this.alignByTranslate=Ue,this.alignTo=Oe):(Pe=this.alignOptions||{},Ue=this.alignByTranslate,Oe=this.alignTo);let me=!Oe||_e(Oe)?Oe||"renderer":void 0;me&&(se&&ue(te,this),Oe=void 0);let Ee=ie(Oe,oe[me],oe),Le=Pe.align,He=Pe.verticalAlign;return Ye=(Ee.x||0)+(Pe.x||0),Se=(Ee.y||0)+(Pe.y||0),Le==="right"?Te=1:Le==="center"&&(Te=2),Te&&(Ye+=((Ee.width||0)-(Pe.width||0))/Te),Ve[Ue?"translateX":"x"]=Math.round(Ye),He==="bottom"?$e=1:He==="middle"&&($e=2),$e&&(Se+=((Ee.height||0)-(Pe.height||0))/$e),Ve[Ue?"translateY":"y"]=Math.round(Se),Be&&(this[this.placed?"animate":"attr"](Ve),this.placed=!0),this.alignAttr=Ve,this}alignSetter(Pe){let Ue={left:"start",center:"middle",right:"end"};Ue[Pe]&&(this.alignValue=Pe,this.element.setAttribute("text-anchor",Ue[Pe]))}animate(Pe,Ue,Oe){let Be=g(ie(Ue,this.renderer.globalAnimation,!0)),Ye=Be.defer;return S.hidden&&(Be.duration=0),Be.duration!==0?(Oe&&(Be.complete=Oe),ye(()=>{this.element&&u(this,Pe,Be)},Ye)):(this.attr(Pe,void 0,Oe||Be.complete),ae(Pe,function(Se,Te){Be.step&&Be.step.call(this,Se,{prop:Te,pos:1,elem:this})},this)),this}applyTextOutline(Pe){let Ue=this.element;Pe.indexOf("contrast")!==-1&&(Pe=Pe.replace(/contrast/g,this.renderer.getContrast(Ue.style.fill)));let Oe=Pe.split(" "),Be=Oe[Oe.length-1],Ye=Oe[0];if(Ye&&Ye!=="none"&&l.svg){this.fakeTS=!0,Ye=Ye.replace(/(^[\d\.]+)(.*?)$/g,function(oe,te,se){return 2*Number(te)+se}),this.removeTextOutline();let Se=S.createElementNS(k,"tspan");I(Se,{class:"highcharts-text-outline",fill:Be,stroke:Be,"stroke-width":Ye,"stroke-linejoin":"round"});let Te=Ue.querySelector("textPath")||Ue;[].forEach.call(Te.childNodes,oe=>{let te=oe.cloneNode(!0);te.removeAttribute&&["fill","stroke","stroke-width","stroke"].forEach(se=>te.removeAttribute(se)),Se.appendChild(te)});let $e=0;[].forEach.call(Te.querySelectorAll("text tspan"),oe=>{$e+=Number(oe.getAttribute("dy"))});let Ve=S.createElementNS(k,"tspan");Ve.textContent="\u200B",I(Ve,{x:Number(Ue.getAttribute("x")),dy:-$e}),Se.appendChild(Ve),Te.insertBefore(Se,Te.firstChild)}}attr(Pe,Ue,Oe,Be){let{element:Ye}=this,Se=Re.symbolCustomAttribs,Te,$e,Ve=this,oe;return typeof Pe=="string"&&Ue!==void 0&&(Te=Pe,(Pe={})[Te]=Ue),typeof Pe=="string"?Ve=(this[Pe+"Getter"]||this._defaultGetter).call(this,Pe,Ye):(ae(Pe,function(te,se){oe=!1,Be||b(this,se),this.symbolName&&Se.indexOf(se)!==-1&&($e||(this.symbolAttr(Pe),$e=!0),oe=!0),this.rotation&&(se==="x"||se==="y")&&(this.doTransform=!0),oe||(this[se+"Setter"]||this._defaultSetter).call(this,te,se,Ye)},this),this.afterSetters()),Oe&&Oe.call(this),Ve}clip(Pe){if(Pe&&!Pe.clipPath){let Ue=Ae()+"-",Oe=this.renderer.createElement("clipPath").attr({id:Ue}).add(this.renderer.defs);le(Pe,{clipPath:Oe,id:Ue,count:0}),Pe.add(Oe)}return this.attr("clip-path",Pe?`url(${this.renderer.url}#${Pe.id})`:"none")}crisp(Pe,Ue){Ue=Math.round(Ue||Pe.strokeWidth||0);let Oe=Pe.x||this.x||0,Be=Pe.y||this.y||0,Ye=(Pe.width||this.width||0)+Oe,Se=(Pe.height||this.height||0)+Be,Te=N(Oe,Ue),$e=N(Be,Ue);return le(Pe,{x:Te,y:$e,width:N(Ye,Ue)-Te,height:N(Se,Ue)-$e}),ne(Pe.strokeWidth)&&(Pe.strokeWidth=Ue),Pe}complexColor(Pe,Ue,Oe){let Be=this.renderer,Ye,Se,Te,$e,Ve,oe,te,se,me,Ee,Le=[],He;fe(this.renderer,"complexColor",{args:arguments},function(){if(Pe.radialGradient?Se="radialGradient":Pe.linearGradient&&(Se="linearGradient"),Se){if(Te=Pe[Se],Ve=Be.gradients,oe=Pe.stops,me=Oe.radialReference,xe(Te)&&(Pe[Se]=Te={x1:Te[0],y1:Te[1],x2:Te[2],y2:Te[3],gradientUnits:"userSpaceOnUse"}),Se==="radialGradient"&&me&&!ne(Te.gradientUnits)&&($e=Te,Te=ve(Te,Be.getRadialAttr(me,$e),{gradientUnits:"userSpaceOnUse"})),ae(Te,function(ze,Qe){Qe!=="id"&&Le.push(Qe,ze)}),ae(oe,function(ze){Le.push(ze)}),Ve[Le=Le.join(",")])Ee=Ve[Le].attr("id");else{Te.id=Ee=Ae();let ze=Ve[Le]=Be.createElement(Se).attr(Te).add(Be.defs);ze.radAttr=$e,ze.stops=[],oe.forEach(function(Qe){Qe[1].indexOf("rgba")===0?(te=(Ye=a.parse(Qe[1])).get("rgb"),se=Ye.get("a")):(te=Qe[1],se=1);let rt=Be.createElement("stop").attr({offset:Qe[0],"stop-color":te,"stop-opacity":se}).add(ze);ze.stops.push(rt)})}He="url("+Be.url+"#"+Ee+")",Oe.setAttribute(Ue,He),Oe.gradient=Le,Pe.toString=function(){return He}}})}css(Pe){let Ue=this.styles,Oe={},Be=this.element,Ye,Se=!Ue;if(Ue&&ae(Pe,function(Te,$e){Ue&&Ue[$e]!==Te&&(Oe[$e]=Te,Se=!0)}),Se){Ue&&(Pe=le(Ue,Oe)),Pe.width===null||Pe.width==="auto"?delete this.textWidth:Be.nodeName.toLowerCase()==="text"&&Pe.width&&(Ye=this.textWidth=pe(Pe.width)),le(this.styles,Pe),Ye&&!$&&this.renderer.forExport&&delete Pe.width;let Te=ve(Pe);Be.namespaceURI===this.SVG_NS&&(["textOutline","textOverflow","width"].forEach($e=>Te&&delete Te[$e]),Te.color&&(Te.fill=Te.color)),ee(Be,Te)}return this.added&&(this.element.nodeName==="text"&&this.renderer.buildText(this),Pe.textOutline&&this.applyTextOutline(Pe.textOutline)),this}dashstyleSetter(Pe){let Ue,Oe=this["stroke-width"];if(Oe==="inherit"&&(Oe=1),Pe=Pe&&Pe.toLowerCase()){let Be=Pe.replace("shortdashdotdot","3,1,1,1,1,1,").replace("shortdashdot","3,1,1,1").replace("shortdot","1,1,").replace("shortdash","3,1,").replace("longdash","8,3,").replace(/dot/g,"1,3,").replace("dash","4,3,").replace(/,$/,"").split(",");for(Ue=Be.length;Ue--;)Be[Ue]=""+pe(Be[Ue])*ie(Oe,NaN);Pe=Be.join(",").replace(/NaN/g,"none"),this.element.setAttribute("stroke-dasharray",Pe)}}destroy(){let Pe=this,Ue=Pe.element||{},Oe=Pe.renderer,Be=Ue.ownerSVGElement,Ye=Ue.nodeName==="SPAN"&&Pe.parentGroup||void 0,Se,Te;if(Ue.onclick=Ue.onmouseout=Ue.onmouseover=Ue.onmousemove=Ue.point=null,b(Pe),Pe.clipPath&&Be){let $e=Pe.clipPath;[].forEach.call(Be.querySelectorAll("[clip-path],[CLIP-PATH]"),function(Ve){Ve.getAttribute("clip-path").indexOf($e.element.id)>-1&&Ve.removeAttribute("clip-path")}),Pe.clipPath=$e.destroy()}if(Pe.connector=Pe.connector?.destroy(),Pe.stops){for(Te=0;TeYe&&Ye.join?(Se?Be+" ":"")+Ye.join(" "):(Ye||"").toString(),"")),/(NaN| {2}|^$)/.test(Pe)&&(Pe="M 0 0"),this[Ue]!==Pe&&(Oe.setAttribute(Ue,Pe),this[Ue]=Pe)}fillSetter(Pe,Ue,Oe){typeof Pe=="string"?Oe.setAttribute(Ue,Pe):Pe&&this.complexColor(Pe,Ue,Oe)}hrefSetter(Pe,Ue,Oe){Oe.setAttributeNS("http://www.w3.org/1999/xlink",Ue,Pe)}getBBox(Pe,Ue){let Oe,Be,Ye,Se,{alignValue:Te,element:$e,renderer:Ve,styles:oe,textStr:te}=this,{cache:se,cacheKeys:me}=Ve,Ee=$e.namespaceURI===this.SVG_NS,Le=ie(Ue,this.rotation,0),He=Ve.styledMode?$e&&Re.prototype.getStyle.call($e,"font-size"):oe.fontSize;if(ne(te)&&((Se=te.toString()).indexOf("<")===-1&&(Se=Se.replace(/[0-9]/g,"0")),Se+=["",Ve.rootFontSize,He,Le,this.textWidth,Te,oe.textOverflow,oe.fontWeight].join(",")),Se&&!Pe&&(Oe=se[Se]),!Oe){if(Ee||Ve.forExport){try{Ye=this.fakeTS&&function(ze){let Qe=$e.querySelector(".highcharts-text-outline");Qe&&ee(Qe,{display:ze})},we(Ye)&&Ye("none"),Oe=$e.getBBox?le({},$e.getBBox()):{width:$e.offsetWidth,height:$e.offsetHeight,x:0,y:0},we(Ye)&&Ye("")}catch{}(!Oe||Oe.width<0)&&(Oe={x:0,y:0,width:0,height:0})}else Oe=this.htmlGetBBox();Be=Oe.height,Ee&&(Oe.height=Be={"11px,17":14,"13px,20":16}[`${He||""},${Math.round(Be)}`]||Be),Le&&(Oe=this.getRotatedBox(Oe,Le))}if(Se&&(te===""||Oe.height>0)){for(;me.length>250;)delete se[me.shift()];se[Se]||me.push(Se),se[Se]=Oe}return Oe}getRotatedBox(Pe,Ue){let{x:Oe,y:Be,width:Ye,height:Se}=Pe,{alignValue:Te,translateY:$e,rotationOriginX:Ve=0,rotationOriginY:oe=0}=this,te={right:1,center:.5}[Te||0]||0,se=Number(this.element.getAttribute("y")||0)-($e?0:Be),me=Ue*x,Ee=(Ue-90)*x,Le=Math.cos(me),He=Math.sin(me),ze=Ye*Le,Qe=Ye*He,rt=Math.cos(Ee),Ke=Math.sin(Ee),[[Ie,Fe],[je,Ze]]=[Ve,oe].map(Nt=>[Nt-Nt*Le,Nt*He]),Ce=Oe+te*(Ye-ze)+Ie+Ze+se*rt,ce=Ce+ze,de=ce-Se*rt,De=de-ze,qe=Be+se-te*Qe-Fe+je+se*Ke,nt=qe+Qe,lt=nt-Se*Ke,pt=lt-Qe,bt=Math.min(Ce,ce,de,De),St=Math.min(qe,nt,lt,pt),Et=Math.max(Ce,ce,de,De)-bt,vt=Math.max(qe,nt,lt,pt)-St;return{x:bt,y:St,width:Et,height:vt}}getStyle(Pe){return T.getComputedStyle(this.element||this,"").getPropertyValue(Pe)}hasClass(Pe){return(""+this.attr("class")).split(" ").indexOf(Pe)!==-1}hide(){return this.attr({visibility:"hidden"})}htmlGetBBox(){return{height:0,width:0,x:0,y:0}}constructor(Pe,Ue){this.onEvents={},this.opacity=1,this.SVG_NS=k,this.element=Ue==="span"||Ue==="body"?O(Ue):S.createElementNS(this.SVG_NS,Ue),this.renderer=Pe,this.styles={},fe(this,"afterInit")}on(Pe,Ue){let{onEvents:Oe}=this;return Oe[Pe]&&Oe[Pe](),Oe[Pe]=D(this.element,Pe,Ue),this}opacitySetter(Pe,Ue,Oe){let Be=Number(Number(Pe).toFixed(3));this.opacity=Be,Oe.setAttribute(Ue,Be)}reAlign(){this.alignOptions?.width&&this.alignOptions.align!=="left"&&(this.alignOptions.width=this.getBBox().width,this.placed=!1,this.align())}removeClass(Pe){return this.attr("class",(""+this.attr("class")).replace(_e(Pe)?RegExp(`(^| )${Pe}( |$)`):Pe," ").replace(/ +/g," ").trim())}removeTextOutline(){let Pe=this.element.querySelector("tspan.highcharts-text-outline");Pe&&this.safeRemoveChild(Pe)}safeRemoveChild(Pe){let Ue=Pe.parentNode;Ue&&Ue.removeChild(Pe)}setRadialReference(Pe){let Ue=this.element.gradient&&this.renderer.gradients[this.element.gradient];return this.element.radialReference=Pe,Ue&&Ue.radAttr&&Ue.animate(this.renderer.getRadialAttr(Pe,Ue.radAttr)),this}setTextPath(Pe,Ue){Ue=ve(!0,{enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},Ue);let Oe=this.renderer.url,Be=this.text||this,Ye=Be.textPath,{attributes:Se,enabled:Te}=Ue;if(Pe=Pe||Ye&&Ye.path,Ye&&Ye.undo(),Pe&&Te){let $e=D(Be,"afterModifyTree",Ve=>{if(Pe&&Te){let oe=Pe.attr("id");oe||Pe.attr("id",oe=Ae());let te={x:0,y:0};ne(Se.dx)&&(te.dx=Se.dx,delete Se.dx),ne(Se.dy)&&(te.dy=Se.dy,delete Se.dy),Be.attr(te),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let se=Ve.nodes.slice(0);Ve.nodes.length=0,Ve.nodes[0]={tagName:"textPath",attributes:le(Se,{"text-anchor":Se.textAnchor,href:`${Oe}#${oe}`}),children:se}}});Be.textPath={path:Pe,undo:$e}}else Be.attr({dx:0,dy:0}),delete Be.textPath;return this.added&&(Be.textCache="",this.renderer.buildText(Be)),this}shadow(Pe){let{renderer:Ue}=this,Oe=ve(this.parentGroup?.rotation===90?{offsetX:-1,offsetY:-1}:{},he(Pe)?Pe:{}),Be=Ue.shadowDefinition(Oe);return this.attr({filter:Pe?`url(${Ue.url}#${Be})`:"none"})}show(Pe=!0){return this.attr({visibility:Pe?"inherit":"visible"})}"stroke-widthSetter"(Pe,Ue,Oe){this[Ue]=Pe,Oe.setAttribute(Ue,Pe)}strokeWidth(){if(!this.renderer.styledMode)return this["stroke-width"]||0;let Pe=this.getStyle("stroke-width"),Ue=0,Oe;return/px$/.test(Pe)?Ue=pe(Pe):Pe!==""&&(I(Oe=S.createElementNS(k,"rect"),{width:Pe,"stroke-width":0}),this.element.parentNode.appendChild(Oe),Ue=Oe.getBBox().width,Oe.parentNode.removeChild(Oe)),Ue}symbolAttr(Pe){let Ue=this;Re.symbolCustomAttribs.forEach(function(Oe){Ue[Oe]=ie(Pe[Oe],Ue[Oe])}),Ue.attr({d:Ue.renderer.symbols[Ue.symbolName](Ue.x,Ue.y,Ue.width,Ue.height,Ue)})}textSetter(Pe){Pe!==this.textStr&&(delete this.textPxLength,this.textStr=Pe,this.added&&this.renderer.buildText(this),this.reAlign())}titleSetter(Pe){let Ue=this.element,Oe=Ue.getElementsByTagName("title")[0]||S.createElementNS(this.SVG_NS,"title");Ue.insertBefore?Ue.insertBefore(Oe,Ue.firstChild):Ue.appendChild(Oe),Oe.textContent=ge(ie(Pe,""),[/<[^>]*>/g,""]).replace(/</g,"<").replace(/>/g,">")}toFront(){let Pe=this.element;return Pe.parentNode.appendChild(Pe),this}translate(Pe,Ue){return this.attr({translateX:Pe,translateY:Ue})}updateTransform(Pe="transform"){let{element:Ue,matrix:Oe,rotation:Be=0,rotationOriginX:Ye,rotationOriginY:Se,scaleX:Te,scaleY:$e,translateX:Ve=0,translateY:oe=0}=this,te=["translate("+Ve+","+oe+")"];ne(Oe)&&te.push("matrix("+Oe.join(",")+")"),Be&&(te.push("rotate("+Be+" "+ie(Ye,Ue.getAttribute("x"),0)+" "+ie(Se,Ue.getAttribute("y")||0)+")"),this.text?.element.tagName==="SPAN"&&this.text.attr({rotation:Be,rotationOriginX:(Ye||0)-this.padding,rotationOriginY:(Se||0)-this.padding})),(ne(Te)||ne($e))&&te.push("scale("+ie(Te,1)+" "+ie($e,1)+")"),te.length&&!(this.text||this).textPath&&Ue.setAttribute(Pe,te.join(" "))}visibilitySetter(Pe,Ue,Oe){Pe==="inherit"?Oe.removeAttribute(Ue):this[Ue]!==Pe&&Oe.setAttribute(Ue,Pe),this[Ue]=Pe}xGetter(Pe){return this.element.nodeName==="circle"&&(Pe==="x"?Pe="cx":Pe==="y"&&(Pe="cy")),this._defaultGetter(Pe)}zIndexSetter(Pe,Ue){let Oe=this.renderer,Be=this.parentGroup,Ye=(Be||Oe).element||Oe.box,Se=this.element,Te=Ye===Oe.box,$e,Ve,oe,te=!1,se,me=this.added,Ee;if(ne(Pe)?(Se.setAttribute("data-z-index",Pe),Pe=+Pe,this[Ue]===Pe&&(me=!1)):ne(this[Ue])&&Se.removeAttribute("data-z-index"),this[Ue]=Pe,me){for((Pe=this.zIndex)&&Be&&(Be.handleZ=!0),Ee=($e=Ye.childNodes).length-1;Ee>=0&&!te;Ee--)se=!ne(oe=(Ve=$e[Ee]).getAttribute("data-z-index")),Ve!==Se&&(Pe<0&&se&&!Te&&!Ee?(Ye.insertBefore(Se,$e[Ee]),te=!0):(pe(oe)<=Pe||se&&(!ne(Pe)||Pe>=0))&&(Ye.insertBefore(Se,$e[Ee+1]),te=!0));te||(Ye.insertBefore(Se,$e[Te?3:0]),te=!0)}return te}}return Re.symbolCustomAttribs=["anchorX","anchorY","clockwise","end","height","innerR","r","start","width","x","y"],Re.prototype.strokeSetter=Re.prototype.fillSetter,Re.prototype.yGetter=Re.prototype.xGetter,Re.prototype.matrixSetter=Re.prototype.rotationOriginXSetter=Re.prototype.rotationOriginYSetter=Re.prototype.rotationSetter=Re.prototype.scaleXSetter=Re.prototype.scaleYSetter=Re.prototype.translateXSetter=Re.prototype.translateYSetter=Re.prototype.verticalAlignSetter=function(We,Pe){this[Pe]=We,this.doTransform=!0},Re}),n(r,"Core/Renderer/SVG/SVGLabel.js",[r["Core/Renderer/SVG/SVGElement.js"],r["Core/Utilities.js"]],function(o,a){let{defined:l,extend:c,isNumber:u,merge:g,pick:b,removeEvent:x}=a;class S extends o{constructor(k,T,D,I,O,N,ee,ne,B,le){let fe;super(k,"g"),this.paddingLeftSetter=this.paddingSetter,this.paddingRightSetter=this.paddingSetter,this.textStr=T,this.x=D,this.y=I,this.anchorX=N,this.anchorY=ee,this.baseline=B,this.className=le,this.addClass(le==="button"?"highcharts-no-tooltip":"highcharts-label"),le&&this.addClass("highcharts-"+le),this.text=k.text(void 0,0,0,ne).attr({zIndex:1}),typeof O=="string"&&((fe=/^url\((.*?)\)$/.test(O))||this.renderer.symbols[O])&&(this.symbolKey=O),this.bBox=S.emptyBBox,this.padding=3,this.baselineOffset=0,this.needsBox=k.styledMode||fe,this.deferredAttr={},this.alignFactor=0}alignSetter(k){let T={left:0,center:.5,right:1}[k];T!==this.alignFactor&&(this.alignFactor=T,this.bBox&&u(this.xSetting)&&this.attr({x:this.xSetting}))}anchorXSetter(k,T){this.anchorX=k,this.boxAttr(T,Math.round(k)-this.getCrispAdjust()-this.xSetting)}anchorYSetter(k,T){this.anchorY=k,this.boxAttr(T,k-this.ySetting)}boxAttr(k,T){this.box?this.box.attr(k,T):this.deferredAttr[k]=T}css(k){if(k){let T={};k=g(k),S.textProps.forEach(D=>{k[D]!==void 0&&(T[D]=k[D],delete k[D])}),this.text.css(T),"fontSize"in T||"fontWeight"in T?this.updateTextPadding():("width"in T||"textOverflow"in T)&&this.updateBoxSize()}return o.prototype.css.call(this,k)}destroy(){x(this.element,"mouseenter"),x(this.element,"mouseleave"),this.text&&this.text.destroy(),this.box&&(this.box=this.box.destroy()),o.prototype.destroy.call(this)}fillSetter(k,T){k&&(this.needsBox=!0),this.fill=k,this.boxAttr(T,k)}getBBox(k,T){this.textStr&&this.bBox.width===0&&this.bBox.height===0&&this.updateBoxSize();let{padding:D,height:I=0,translateX:O=0,translateY:N=0,width:ee=0}=this,ne=b(this.paddingLeft,D),B=T??(this.rotation||0),le={width:ee,height:I,x:O+this.bBox.x-ne,y:N+this.bBox.y-D+this.baselineOffset};return B&&(le=this.getRotatedBox(le,B)),le}getCrispAdjust(){return(this.renderer.styledMode&&this.box?this.box.strokeWidth():this["stroke-width"]?parseInt(this["stroke-width"],10):0)%2/2}heightSetter(k){this.heightSetting=k}onAdd(){this.text.add(this),this.attr({text:b(this.textStr,""),x:this.x||0,y:this.y||0}),this.box&&l(this.anchorX)&&this.attr({anchorX:this.anchorX,anchorY:this.anchorY})}paddingSetter(k,T){u(k)?k!==this[T]&&(this[T]=k,this.updateTextPadding()):this[T]=void 0}rSetter(k,T){this.boxAttr(T,k)}strokeSetter(k,T){this.stroke=k,this.boxAttr(T,k)}"stroke-widthSetter"(k,T){k&&(this.needsBox=!0),this["stroke-width"]=k,this.boxAttr(T,k)}"text-alignSetter"(k){this.textAlign=k}textSetter(k){k!==void 0&&this.text.attr({text:k}),this.updateTextPadding(),this.reAlign()}updateBoxSize(){let k,T=this.text,D={},I=this.padding,O=this.bBox=(!u(this.widthSetting)||!u(this.heightSetting)||this.textAlign)&&l(T.textStr)?T.getBBox(void 0,0):S.emptyBBox;this.width=this.getPaddedWidth(),this.height=(this.heightSetting||O.height||0)+2*I;let N=this.renderer.fontMetrics(T);if(this.baselineOffset=I+Math.min((this.text.firstLineMetrics||N).b,O.height||1/0),this.heightSetting&&(this.baselineOffset+=(this.heightSetting-N.h)/2),this.needsBox&&!T.textPath){if(!this.box){let ee=this.box=this.symbolKey?this.renderer.symbol(this.symbolKey):this.renderer.rect();ee.addClass((this.className==="button"?"":"highcharts-label-box")+(this.className?" highcharts-"+this.className+"-box":"")),ee.add(this)}k=this.getCrispAdjust(),D.x=k,D.y=(this.baseline?-this.baselineOffset:0)+k,D.width=Math.round(this.width),D.height=Math.round(this.height),this.box.attr(c(D,this.deferredAttr)),this.deferredAttr={}}}updateTextPadding(){let k=this.text;if(!k.textPath){this.updateBoxSize();let T=this.baseline?0:this.baselineOffset,D=b(this.paddingLeft,this.padding);l(this.widthSetting)&&this.bBox&&(this.textAlign==="center"||this.textAlign==="right")&&(D+={center:.5,right:1}[this.textAlign]*(this.widthSetting-this.bBox.width)),(D!==k.x||T!==k.y)&&(k.attr("x",D),k.hasBoxWidthChanged&&(this.bBox=k.getBBox(!0)),T!==void 0&&k.attr("y",T)),k.x=D,k.y=T}}widthSetter(k){this.widthSetting=u(k)?k:void 0}getPaddedWidth(){let k=this.padding,T=b(this.paddingLeft,k),D=b(this.paddingRight,k);return(this.widthSetting||this.bBox.width||0)+T+D}xSetter(k){this.x=k,this.alignFactor&&(k-=this.alignFactor*this.getPaddedWidth(),this["forceAnimate:x"]=!0),this.xSetting=Math.round(k),this.attr("translateX",this.xSetting)}ySetter(k){this.ySetting=this.y=Math.round(k),this.attr("translateY",this.ySetting)}}return S.emptyBBox={width:0,height:0,x:0,y:0},S.textProps=["color","direction","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textDecoration","textOutline","textOverflow","whiteSpace","width"],S}),n(r,"Core/Renderer/SVG/Symbols.js",[r["Core/Utilities.js"]],function(o){let{defined:a,isNumber:l,pick:c}=o;function u(x,S,$,k,T){let D=[];if(T){let I=T.start||0,O=c(T.r,$),N=c(T.r,k||$),ee=2e-4/Math.max(O,1),ne=Math.abs((T.end||0)-I-2*Math.PI)0&&N0)return ee;if(x+O>$-I)if(N>S+I&&NS+I&&N0){let ne=Nk&&O<$-I?ee.splice(5,1,["L",O+6,S+k],["L",O,S+k+6],["L",O-6,S+k],["L",x+D,S+k]):N<0&&O>I&&ee.splice(1,1,["L",O-6,S],["L",O,S-6],["L",O+6,S],["L",$-D,S]);return ee},circle:function(x,S,$,k){return u(x+$/2,S+k/2,$/2,k/2,{start:.5*Math.PI,end:2.5*Math.PI,open:!1})},diamond:function(x,S,$,k){return[["M",x+$/2,S],["L",x+$,S+k/2],["L",x+$/2,S+k],["L",x,S+k/2],["Z"]]},rect:g,roundedRect:b,square:g,triangle:function(x,S,$,k){return[["M",x+$/2,S],["L",x+$,S+k],["L",x,S+k],["Z"]]},"triangle-down":function(x,S,$,k){return[["M",x,S],["L",x+$,S],["L",x+$/2,S+k],["Z"]]}}}),n(r,"Core/Renderer/SVG/TextBuilder.js",[r["Core/Renderer/HTML/AST.js"],r["Core/Globals.js"],r["Core/Utilities.js"]],function(o,a,l){let{doc:c,SVG_NS:u,win:g}=a,{attr:b,extend:x,fireEvent:S,isString:$,objectEach:k,pick:T}=l;return class{constructor(D){let I=D.styles;this.renderer=D.renderer,this.svgElement=D,this.width=D.textWidth,this.textLineHeight=I&&I.lineHeight,this.textOutline=I&&I.textOutline,this.ellipsis=!!(I&&I.textOverflow==="ellipsis"),this.noWrap=!!(I&&I.whiteSpace==="nowrap")}buildSVG(){let D=this.svgElement,I=D.element,O=D.renderer,N=T(D.textStr,"").toString(),ee=N.indexOf("<")!==-1,ne=I.childNodes,B=!D.added&&O.box,le=[N,this.ellipsis,this.noWrap,this.textLineHeight,this.textOutline,D.getStyle("font-size"),this.width].join(",");if(le!==D.textCache){D.textCache=le,delete D.actualWidth;for(let fe=ne.length;fe--;)I.removeChild(ne[fe]);if(ee||this.ellipsis||this.width||D.textPath||N.indexOf(" ")!==-1&&(!this.noWrap||//g.test(N))){if(N!==""){B&&B.appendChild(I);let fe=new o(N);this.modifyTree(fe.nodes),fe.addToDOM(I),this.modifyDOM(),this.ellipsis&&(I.textContent||"").indexOf("\u2026")!==-1&&D.attr("title",this.unescapeEntities(D.textStr||"",["<",">"])),B&&B.removeChild(I)}}else I.appendChild(c.createTextNode(this.unescapeEntities(N)));$(this.textOutline)&&D.applyTextOutline&&D.applyTextOutline(this.textOutline)}}modifyDOM(){let D,I=this.svgElement,O=b(I.element,"x");for(I.firstLineMetrics=void 0;(D=I.element.firstChild)&&/^[\s\u200B]*$/.test(D.textContent||" ");)I.element.removeChild(D);[].forEach.call(I.element.querySelectorAll("tspan.highcharts-br"),(B,le)=>{B.nextSibling&&B.previousSibling&&(le===0&&B.previousSibling.nodeType===1&&(I.firstLineMetrics=I.renderer.fontMetrics(B.previousSibling)),b(B,{dy:this.getLineHeight(B.nextSibling),x:O}))});let N=this.width||0;if(!N)return;let ee=(B,le)=>{let fe=B.textContent||"",xe=fe.replace(/([^\^])-/g,"$1- ").split(" "),we=!this.noWrap&&(xe.length>1||I.element.childNodes.length>1),he=this.getLineHeight(le),_e=0,ve=I.actualWidth;if(this.ellipsis)fe&&this.truncate(B,fe,void 0,0,Math.max(0,N-.8*he),(ae,ie)=>ae.substring(0,ie)+"\u2026");else if(we){let ae=[],ie=[];for(;le.firstChild&&le.firstChild!==B;)ie.push(le.firstChild),le.removeChild(le.firstChild);for(;xe.length;)xe.length&&!this.noWrap&&_e>0&&(ae.push(B.textContent||""),B.textContent=xe.join(" ").replace(/- /g,"-")),this.truncate(B,void 0,xe,_e===0&&ve||0,N,(pe,ue)=>xe.slice(0,ue).join(" ").replace(/- /g,"-")),ve=I.actualWidth,_e++;ie.forEach(pe=>{le.insertBefore(pe,B)}),ae.forEach(pe=>{le.insertBefore(c.createTextNode(pe),B);let ue=c.createElementNS(u,"tspan");ue.textContent="\u200B",b(ue,{dy:he,x:O}),le.insertBefore(ue,B)})}},ne=B=>{[].slice.call(B.childNodes).forEach(le=>{le.nodeType===g.Node.TEXT_NODE?ee(le,B):(le.className.baseVal.indexOf("highcharts-br")!==-1&&(I.actualWidth=0),ne(le))})};ne(I.element)}getLineHeight(D){let I=D.nodeType===g.Node.TEXT_NODE?D.parentElement:D;return this.textLineHeight?parseInt(this.textLineHeight.toString(),10):this.renderer.fontMetrics(I||this.svgElement.element).h}modifyTree(D){let I=(O,N)=>{let{attributes:ee={},children:ne,style:B={},tagName:le}=O,fe=this.renderer.styledMode;if(le==="b"||le==="strong"?fe?ee.class="highcharts-strong":B.fontWeight="bold":(le==="i"||le==="em")&&(fe?ee.class="highcharts-emphasized":B.fontStyle="italic"),B&&B.color&&(B.fill=B.color),le==="br"){ee.class="highcharts-br",O.textContent="\u200B";let xe=D[N+1];xe&&xe.textContent&&(xe.textContent=xe.textContent.replace(/^ +/gm,""))}else le==="a"&&ne&&ne.some(xe=>xe.tagName==="#text")&&(O.children=[{children:ne,tagName:"tspan"}]);le!=="#text"&&le!=="a"&&(O.tagName="tspan"),x(O,{attributes:ee,style:B}),ne&&ne.filter(xe=>xe.tagName!=="#text").forEach(I)};D.forEach(I),S(this.svgElement,"afterModifyTree",{nodes:D})}truncate(D,I,O,N,ee,ne){let B,le,fe=this.svgElement,{rotation:xe}=fe,we=[],he=O?1:0,_e=(I||O||"").length,ve=_e,ae=function(ie,pe){let ue=pe||ie,ge=D.parentNode;if(ge&&we[ue]===void 0&&ge.getSubStringLength)try{we[ue]=N+ge.getSubStringLength(0,O?ue+1:ue)}catch{}return we[ue]};if(fe.rotation=0,N+(le=ae(D.textContent.length))>ee){for(;he<=_e;)ve=Math.ceil((he+_e)/2),O&&(B=ne(O,ve)),le=ae(ve,B&&B.length-1),he===_e?he=_e+1:le>ee?_e=ve-1:he=ve;_e===0?D.textContent="":I&&_e===I.length-1||(D.textContent=B||ne(I||O,ve))}O&&O.splice(0,ve),fe.actualWidth=le,fe.rotation=xe}unescapeEntities(D,I){return k(this.renderer.escapes,function(O,N){I&&I.indexOf(O)!==-1||(D=D.toString().replace(RegExp(O,"g"),N))}),D}}}),n(r,"Core/Renderer/SVG/SVGRenderer.js",[r["Core/Renderer/HTML/AST.js"],r["Core/Defaults.js"],r["Core/Color/Color.js"],r["Core/Globals.js"],r["Core/Renderer/RendererRegistry.js"],r["Core/Renderer/SVG/SVGElement.js"],r["Core/Renderer/SVG/SVGLabel.js"],r["Core/Renderer/SVG/Symbols.js"],r["Core/Renderer/SVG/TextBuilder.js"],r["Core/Utilities.js"]],function(o,a,l,c,u,g,b,x,S,$){let k,{defaultOptions:T}=a,{charts:D,deg2rad:I,doc:O,isFirefox:N,isMS:ee,isWebKit:ne,noop:B,SVG_NS:le,symbolSizes:fe,win:xe}=c,{addEvent:we,attr:he,createElement:_e,crisp:ve,css:ae,defined:ie,destroyObjectProperties:pe,extend:ue,isArray:ge,isNumber:ye,isObject:Ae,isString:Re,merge:We,pick:Pe,pInt:Ue,replaceNested:Oe,uniqueKey:Be}=$;class Ye{constructor(Te,$e,Ve,oe,te,se,me){let Ee,Le,He=this.createElement("svg").attr({version:"1.1",class:"highcharts-root"}),ze=He.element;me||He.css(this.getStyle(oe||{})),Te.appendChild(ze),he(Te,"dir","ltr"),Te.innerHTML.indexOf("xmlns")===-1&&he(ze,"xmlns",this.SVG_NS),this.box=ze,this.boxWrapper=He,this.alignedObjects=[],this.url=this.getReferenceURL(),this.createElement("desc").add().element.appendChild(O.createTextNode("Created with Highcharts 11.4.3")),this.defs=this.createElement("defs").add(),this.allowHTML=se,this.forExport=te,this.styledMode=me,this.gradients={},this.cache={},this.cacheKeys=[],this.imgCount=0,this.rootFontSize=He.getStyle("font-size"),this.setSize($e,Ve,!1),N&&Te.getBoundingClientRect&&((Ee=function(){ae(Te,{left:0,top:0}),Le=Te.getBoundingClientRect(),ae(Te,{left:Math.ceil(Le.left)-Le.left+"px",top:Math.ceil(Le.top)-Le.top+"px"})})(),this.unSubPixelFix=we(xe,"resize",Ee))}definition(Te){return new o([Te]).addToDOM(this.defs.element)}getReferenceURL(){if((N||ne)&&O.getElementsByTagName("base").length){if(!ie(k)){let Te=Be(),$e=new o([{tagName:"svg",attributes:{width:8,height:8},children:[{tagName:"defs",children:[{tagName:"clipPath",attributes:{id:Te},children:[{tagName:"rect",attributes:{width:4,height:4}}]}]},{tagName:"rect",attributes:{id:"hitme",width:8,height:8,"clip-path":`url(#${Te})`,fill:"rgba(0,0,0,0.001)"}}]}]).addToDOM(O.body);ae($e,{position:"fixed",top:0,left:0,zIndex:9e5});let Ve=O.elementFromPoint(6,6);k=(Ve&&Ve.id)==="hitme",O.body.removeChild($e)}if(k)return Oe(xe.location.href.split("#")[0],[/<[^>]*>/g,""],[/([\('\)])/g,"\\$1"],[/ /g,"%20"])}return""}getStyle(Te){return this.style=ue({fontFamily:"Helvetica, Arial, sans-serif",fontSize:"1rem"},Te),this.style}setStyle(Te){this.boxWrapper.css(this.getStyle(Te))}isHidden(){return!this.boxWrapper.getBBox().width}destroy(){let Te=this.defs;return this.box=null,this.boxWrapper=this.boxWrapper.destroy(),pe(this.gradients||{}),this.gradients=null,this.defs=Te.destroy(),this.unSubPixelFix&&this.unSubPixelFix(),this.alignedObjects=null,null}createElement(Te){return new this.Element(this,Te)}getRadialAttr(Te,$e){return{cx:Te[0]-Te[2]/2+($e.cx||0)*Te[2],cy:Te[1]-Te[2]/2+($e.cy||0)*Te[2],r:($e.r||0)*Te[2]}}shadowDefinition(Te){let $e=[`highcharts-drop-shadow-${this.chartIndex}`,...Object.keys(Te).map(oe=>`${oe}-${Te[oe]}`)].join("-").toLowerCase().replace(/[^a-z0-9\-]/g,""),Ve=We({color:"#000000",offsetX:1,offsetY:1,opacity:.15,width:5},Te);return this.defs.element.querySelector(`#${$e}`)||this.definition({tagName:"filter",attributes:{id:$e,filterUnits:Ve.filterUnits},children:[{tagName:"feDropShadow",attributes:{dx:Ve.offsetX,dy:Ve.offsetY,"flood-color":Ve.color,"flood-opacity":Math.min(5*Ve.opacity,1),stdDeviation:Ve.width/2}}]}),$e}buildText(Te){new S(Te).buildSVG()}getContrast(Te){let $e=l.parse(Te).rgba.map(oe=>{let te=oe/255;return te<=.03928?te/12.92:Math.pow((te+.055)/1.055,2.4)}),Ve=.2126*$e[0]+.7152*$e[1]+.0722*$e[2];return 1.05/(Ve+.05)>(Ve+.05)/.05?"#FFFFFF":"#000000"}button(Te,$e,Ve,oe,te={},se,me,Ee,Le,He){let ze=this.label(Te,$e,Ve,Le,void 0,void 0,He,void 0,"button"),Qe=this.styledMode,rt=arguments,Ke=0;te=We(T.global.buttonTheme,te),Qe&&(delete te.fill,delete te.stroke,delete te["stroke-width"]);let Ie=te.states||{},Fe=te.style||{};delete te.states,delete te.style;let je=[o.filterUserAttributes(te)],Ze=[Fe];return Qe||["hover","select","disabled"].forEach((Ce,ce)=>{je.push(We(je[0],o.filterUserAttributes(rt[ce+5]||Ie[Ce]||{}))),Ze.push(je[ce+1].style),delete je[ce+1].style}),we(ze.element,ee?"mouseover":"mouseenter",function(){Ke!==3&&ze.setState(1)}),we(ze.element,ee?"mouseout":"mouseleave",function(){Ke!==3&&ze.setState(Ke)}),ze.setState=(Ce=0)=>{if(Ce!==1&&(ze.state=Ke=Ce),ze.removeClass(/highcharts-button-(normal|hover|pressed|disabled)/).addClass("highcharts-button-"+["normal","hover","pressed","disabled"][Ce]),!Qe){ze.attr(je[Ce]);let ce=Ze[Ce];Ae(ce)&&ze.css(ce)}},ze.attr(je[0]),!Qe&&(ze.css(ue({cursor:"default"},Fe)),He&&ze.text.css({pointerEvents:"none"})),ze.on("touchstart",Ce=>Ce.stopPropagation()).on("click",function(Ce){Ke!==3&&oe.call(ze,Ce)})}crispLine(Te,$e){let[Ve,oe]=Te;return ie(Ve[1])&&Ve[1]===oe[1]&&(Ve[1]=oe[1]=ve(Ve[1],$e)),ie(Ve[2])&&Ve[2]===oe[2]&&(Ve[2]=oe[2]=ve(Ve[2],$e)),Te}path(Te){let $e=this.styledMode?{}:{fill:"none"};return ge(Te)?$e.d=Te:Ae(Te)&&ue($e,Te),this.createElement("path").attr($e)}circle(Te,$e,Ve){let oe=Ae(Te)?Te:Te===void 0?{}:{x:Te,y:$e,r:Ve},te=this.createElement("circle");return te.xSetter=te.ySetter=function(se,me,Ee){Ee.setAttribute("c"+me,se)},te.attr(oe)}arc(Te,$e,Ve,oe,te,se){let me;Ae(Te)?($e=(me=Te).y,Ve=me.r,oe=me.innerR,te=me.start,se=me.end,Te=me.x):me={innerR:oe,start:te,end:se};let Ee=this.symbol("arc",Te,$e,Ve,Ve,me);return Ee.r=Ve,Ee}rect(Te,$e,Ve,oe,te,se){let me=Ae(Te)?Te:Te===void 0?{}:{x:Te,y:$e,r:te,width:Math.max(Ve||0,0),height:Math.max(oe||0,0)},Ee=this.createElement("rect");return this.styledMode||(se!==void 0&&(me["stroke-width"]=se,ue(me,Ee.crisp(me))),me.fill="none"),Ee.rSetter=function(Le,He,ze){Ee.r=Le,he(ze,{rx:Le,ry:Le})},Ee.rGetter=function(){return Ee.r||0},Ee.attr(me)}roundedRect(Te){return this.symbol("roundedRect").attr(Te)}setSize(Te,$e,Ve){this.width=Te,this.height=$e,this.boxWrapper.animate({width:Te,height:$e},{step:function(){this.attr({viewBox:"0 0 "+this.attr("width")+" "+this.attr("height")})},duration:Pe(Ve,!0)?void 0:0}),this.alignElements()}g(Te){let $e=this.createElement("g");return Te?$e.attr({class:"highcharts-"+Te}):$e}image(Te,$e,Ve,oe,te,se){let me={preserveAspectRatio:"none"};ye($e)&&(me.x=$e),ye(Ve)&&(me.y=Ve),ye(oe)&&(me.width=oe),ye(te)&&(me.height=te);let Ee=this.createElement("image").attr(me),Le=function(He){Ee.attr({href:Te}),se.call(Ee,He)};if(se){Ee.attr({href:"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="});let He=new xe.Image;we(He,"load",Le),He.src=Te,He.complete&&Le({})}else Ee.attr({href:Te});return Ee}symbol(Te,$e,Ve,oe,te,se){let me,Ee,Le,He,ze=this,Qe=/^url\((.*?)\)$/,rt=Qe.test(Te),Ke=!rt&&(this.symbols[Te]?Te:"circle"),Ie=Ke&&this.symbols[Ke];if(Ie)typeof $e=="number"&&(Ee=Ie.call(this.symbols,$e||0,Ve||0,oe||0,te||0,se)),me=this.path(Ee),ze.styledMode||me.attr("fill","none"),ue(me,{symbolName:Ke||void 0,x:$e,y:Ve,width:oe,height:te}),se&&ue(me,se);else if(rt){Le=Te.match(Qe)[1];let Fe=me=this.image(Le);Fe.imgwidth=Pe(se&&se.width,fe[Le]&&fe[Le].width),Fe.imgheight=Pe(se&&se.height,fe[Le]&&fe[Le].height),He=je=>je.attr({width:je.width,height:je.height}),["width","height"].forEach(je=>{Fe[`${je}Setter`]=function(Ze,Ce){this[Ce]=Ze;let{alignByTranslate:ce,element:de,width:De,height:qe,imgwidth:nt,imgheight:lt}=this,pt=Ce==="width"?nt:lt,bt=1;se&&se.backgroundSize==="within"&&De&&qe&&nt&<?(bt=Math.min(De/nt,qe/lt),he(de,{width:Math.round(nt*bt),height:Math.round(lt*bt)})):de&&pt&&de.setAttribute(Ce,pt),!ce&&nt&<&&this.translate(((De||0)-nt*bt)/2,((qe||0)-lt*bt)/2)}}),ie($e)&&Fe.attr({x:$e,y:Ve}),Fe.isImg=!0,ie(Fe.imgwidth)&&ie(Fe.imgheight)?He(Fe):(Fe.attr({width:0,height:0}),_e("img",{onload:function(){let je=D[ze.chartIndex];this.width===0&&(ae(this,{position:"absolute",top:"-999em"}),O.body.appendChild(this)),fe[Le]={width:this.width,height:this.height},Fe.imgwidth=this.width,Fe.imgheight=this.height,Fe.element&&He(Fe),this.parentNode&&this.parentNode.removeChild(this),ze.imgCount--,ze.imgCount||!je||je.hasLoaded||je.onload()},src:Le}),this.imgCount++)}return me}clipRect(Te,$e,Ve,oe){return this.rect(Te,$e,Ve,oe,0)}text(Te,$e,Ve,oe){let te={};if(oe&&(this.allowHTML||!this.forExport))return this.html(Te,$e,Ve);te.x=Math.round($e||0),Ve&&(te.y=Math.round(Ve)),ie(Te)&&(te.text=Te);let se=this.createElement("text").attr(te);return oe&&(!this.forExport||this.allowHTML)||(se.xSetter=function(me,Ee,Le){let He=Le.getElementsByTagName("tspan"),ze=Le.getAttribute(Ee);for(let Qe=0,rt;QeTe.align())}}return ue(Ye.prototype,{Element:g,SVG_NS:le,escapes:{"&":"&","<":"<",">":">","'":"'",'"':"""},symbols:x,draw:B}),u.registerRendererType("svg",Ye,!0),Ye}),n(r,"Core/Renderer/HTML/HTMLElement.js",[r["Core/Renderer/HTML/AST.js"],r["Core/Globals.js"],r["Core/Renderer/SVG/SVGElement.js"],r["Core/Utilities.js"]],function(o,a,l,c){let{composed:u}=a,{attr:g,css:b,createElement:x,defined:S,extend:$,pInt:k,pushUnique:T}=c;function D(ee,ne,B){let le=this.div?.style||B.style;l.prototype[`${ne}Setter`].call(this,ee,ne,B),le&&(le[ne]=ee)}let I=(ee,ne)=>{if(!ee.div){let B=g(ee.element,"class"),le=ee.css,fe=x("div",B?{className:B}:void 0,{position:"absolute",left:`${ee.translateX||0}px`,top:`${ee.translateY||0}px`,...ee.styles,display:ee.display,opacity:ee.opacity,visibility:ee.visibility},ee.parentGroup?.div||ne);ee.classSetter=(xe,we,he)=>{he.setAttribute("class",xe),fe.className=xe},ee.translateXSetter=ee.translateYSetter=(xe,we)=>{ee[we]=xe,fe.style[we==="translateX"?"left":"top"]=`${xe}px`,ee.doTransform=!0},ee.opacitySetter=ee.visibilitySetter=D,ee.css=xe=>(le.call(ee,xe),xe.cursor&&(fe.style.cursor=xe.cursor),xe.pointerEvents&&(fe.style.pointerEvents=xe.pointerEvents),ee),ee.on=function(){return l.prototype.on.apply({element:fe,onEvents:ee.onEvents},arguments),ee},ee.div=fe}return ee.div};class O extends l{static compose(ne){T(u,this.compose)&&(ne.prototype.html=function(B,le,fe){return new O(this,"span").attr({text:B,x:Math.round(le),y:Math.round(fe)})})}constructor(ne,B){super(ne,B),this.css({position:"absolute",...ne.styledMode?{}:{fontFamily:ne.style.fontFamily,fontSize:ne.style.fontSize}}),this.element.style.whiteSpace="nowrap"}getSpanCorrection(ne,B,le){this.xCorr=-ne*le,this.yCorr=-B}css(ne){let B,{element:le}=this,fe=le.tagName==="SPAN"&&ne&&"width"in ne,xe=fe&&ne.width;return fe&&(delete ne.width,this.textWidth=k(xe)||void 0,B=!0),ne?.textOverflow==="ellipsis"&&(ne.whiteSpace="nowrap",ne.overflow="hidden"),$(this.styles,ne),b(le,ne),B&&this.updateTransform(),this}htmlGetBBox(){let{element:ne}=this;return{x:ne.offsetLeft,y:ne.offsetTop,width:ne.offsetWidth,height:ne.offsetHeight}}updateTransform(){if(!this.added){this.alignOnAdd=!0;return}let{element:ne,renderer:B,rotation:le,rotationOriginX:fe,rotationOriginY:xe,styles:we,textAlign:he="left",textWidth:_e,translateX:ve=0,translateY:ae=0,x:ie=0,y:pe=0}=this,ue=we.whiteSpace;if(b(ne,{marginLeft:`${ve}px`,marginTop:`${ae}px`}),ne.tagName==="SPAN"){let ge=[le,he,ne.innerHTML,_e,this.textAlign].join(","),ye=-(this.parentGroup?.padding*1)||0,Ae,Re=!1;if(_e!==this.oldTextWidth){let Be=this.textPxLength?this.textPxLength:(b(ne,{width:"",whiteSpace:ue||"nowrap"}),ne.offsetWidth),Ye=_e||0;(Ye>this.oldTextWidth||Be>Ye)&&(/[ \-]/.test(ne.textContent||ne.innerText)||ne.style.textOverflow==="ellipsis")&&(b(ne,{width:Be>Ye||le?_e+"px":"auto",display:"block",whiteSpace:ue||"normal"}),this.oldTextWidth=_e,Re=!0)}this.hasBoxWidthChanged=Re,ge!==this.cTT&&(Ae=B.fontMetrics(ne).b,S(le)&&(le!==(this.oldRotation||0)||he!==this.oldAlign)&&this.setSpanRotation(le,ye,ye),this.getSpanCorrection(!S(le)&&this.textPxLength||ne.offsetWidth,Ae,{left:0,center:.5,right:1}[he]));let{xCorr:We=0,yCorr:Pe=0}=this,Ue=(fe??ie)-We-ie-ye,Oe=(xe??pe)-Pe-pe-ye;b(ne,{left:`${ie+We}px`,top:`${pe+Pe}px`,transformOrigin:`${Ue}px ${Oe}px`}),this.cTT=ge,this.oldRotation=le,this.oldAlign=he}}setSpanRotation(ne,B,le){b(this.element,{transform:`rotate(${ne}deg)`,transformOrigin:`${B}% ${le}px`})}add(ne){let B,le=this.renderer.box.parentNode,fe=[];if(this.parentGroup=ne,ne&&!(B=ne.div)){let xe=ne;for(;xe;)fe.push(xe),xe=xe.parentGroup;for(let we of fe.reverse())B=I(we,le)}return(B||le).appendChild(this.element),this.added=!0,this.alignOnAdd&&this.updateTransform(),this}textSetter(ne){ne!==this.textStr&&(delete this.bBox,delete this.oldTextWidth,o.setElementHTML(this.element,ne??""),this.textStr=ne,this.doTransform=!0)}alignSetter(ne){this.alignValue=this.textAlign=ne,this.doTransform=!0}xSetter(ne,B){this[B]=ne,this.doTransform=!0}}let N=O.prototype;return N.visibilitySetter=N.opacitySetter=D,N.ySetter=N.rotationSetter=N.rotationOriginXSetter=N.rotationOriginYSetter=N.xSetter,O}),n(r,"Core/Axis/AxisDefaults.js",[],function(){var o,a;return(a=o||(o={})).xAxis={alignTicks:!0,allowDecimals:void 0,panningEnabled:!0,zIndex:2,zoomEnabled:!0,dateTimeLabelFormats:{millisecond:{main:"%H:%M:%S.%L",range:!1},second:{main:"%H:%M:%S",range:!1},minute:{main:"%H:%M",range:!1},hour:{main:"%H:%M",range:!1},day:{main:"%e %b"},week:{main:"%e %b"},month:{main:"%b '%y"},year:{main:"%Y"}},endOnTick:!1,gridLineDashStyle:"Solid",gridZIndex:1,labels:{autoRotationLimit:80,distance:15,enabled:!0,indentation:10,overflow:"justify",reserveSpace:void 0,rotation:void 0,staggerLines:0,step:0,useHTML:!1,zIndex:7,style:{color:"#333333",cursor:"default",fontSize:"0.8em"}},maxPadding:.01,minorGridLineDashStyle:"Solid",minorTickLength:2,minorTickPosition:"outside",minorTicksPerMajor:5,minPadding:.01,offset:void 0,reversed:void 0,reversedStacks:!1,showEmpty:!0,showFirstLabel:!0,showLastLabel:!0,startOfWeek:1,startOnTick:!1,tickLength:10,tickPixelInterval:100,tickmarkPlacement:"between",tickPosition:"outside",title:{align:"middle",useHTML:!1,x:0,y:0,style:{color:"#666666",fontSize:"0.8em"}},type:"linear",uniqueNames:!0,visible:!0,minorGridLineColor:"#f2f2f2",minorGridLineWidth:1,minorTickColor:"#999999",lineColor:"#333333",lineWidth:1,gridLineColor:"#e6e6e6",gridLineWidth:void 0,tickColor:"#333333"},a.yAxis={reversedStacks:!0,endOnTick:!0,maxPadding:.05,minPadding:.05,tickPixelInterval:72,showLastLabel:!0,labels:{x:void 0},startOnTick:!0,title:{text:"Values"},stackLabels:{animation:{},allowOverlap:!1,enabled:!1,crop:!0,overflow:"justify",formatter:function(){let{numberFormatter:l}=this.axis.chart;return l(this.total||0,-1)},style:{color:"#000000",fontSize:"0.7em",fontWeight:"bold",textOutline:"1px contrast"}},gridLineWidth:1,lineWidth:0},o}),n(r,"Core/Foundation.js",[r["Core/Utilities.js"]],function(o){var a;let{addEvent:l,isFunction:c,objectEach:u,removeEvent:g}=o;return(a||(a={})).registerEventOptions=function(b,x){b.eventOptions=b.eventOptions||{},u(x.events,function(S,$){b.eventOptions[$]!==S&&(b.eventOptions[$]&&(g(b,$,b.eventOptions[$]),delete b.eventOptions[$]),c(S)&&(b.eventOptions[$]=S,l(b,$,S,{order:0})))})},a}),n(r,"Core/Axis/Tick.js",[r["Core/Templating.js"],r["Core/Globals.js"],r["Core/Utilities.js"]],function(o,a,l){let{deg2rad:c}=a,{clamp:u,correctFloat:g,defined:b,destroyObjectProperties:x,extend:S,fireEvent:$,isNumber:k,merge:T,objectEach:D,pick:I}=l;return class{constructor(O,N,ee,ne,B){this.isNew=!0,this.isNewLabel=!0,this.axis=O,this.pos=N,this.type=ee||"",this.parameters=B||{},this.tickmarkOffset=this.parameters.tickmarkOffset,this.options=this.parameters.options,$(this,"init"),ee||ne||this.addLabel()}addLabel(){let O=this,N=O.axis,ee=N.options,ne=N.chart,B=N.categories,le=N.logarithmic,fe=N.names,xe=O.pos,we=I(O.options&&O.options.labels,ee.labels),he=N.tickPositions,_e=xe===he[0],ve=xe===he[he.length-1],ae=(!we.step||we.step===1)&&N.tickInterval===1,ie=he.info,pe=O.label,ue,ge,ye,Ae=this.parameters.category||(B?I(B[xe],fe[xe],xe):xe);le&&k(Ae)&&(Ae=g(le.lin2log(Ae))),N.dateTime&&(ie?ue=(ge=ne.time.resolveDTLFormat(ee.dateTimeLabelFormats[!ee.grid&&ie.higherRanks[xe]||ie.unitName])).main:k(Ae)&&(ue=N.dateTime.getXDateFormat(Ae,ee.dateTimeLabelFormats||{}))),O.isFirst=_e,O.isLast=ve;let Re={axis:N,chart:ne,dateTimeLabelFormat:ue,isFirst:_e,isLast:ve,pos:xe,tick:O,tickPositionInfo:ie,value:Ae};$(this,"labelFormat",Re);let We=Oe=>we.formatter?we.formatter.call(Oe,Oe):we.format?(Oe.text=N.defaultLabelFormatter.call(Oe),o.format(we.format,Oe,ne)):N.defaultLabelFormatter.call(Oe),Pe=We.call(Re,Re),Ue=ge&&ge.list;Ue?O.shortenLabel=function(){for(ye=0;ye0&&ne+_e*ve>xe&&(Ae=Math.round((B-ne)/Math.cos(he*c))):(ge=ne-_e*ve,ye=ne+(1-_e)*ve,gexe&&(pe=xe-O.x+pe*_e,ue=-1),(pe=Math.min(ae,pe))pe||N.autoRotation&&(we.styles||{}).width)&&(Ae=pe)),Ae&&(this.shortenLabel?this.shortenLabel():(ie.width=Math.floor(Ae)+"px",(ee.style||{}).textOverflow||(ie.textOverflow="ellipsis"),we.css(ie)))}moveLabel(O,N){let ee=this,ne=ee.label,B=ee.axis,le=!1,fe;ne&&ne.textStr===O?(ee.movedLabel=ne,le=!0,delete ee.label):D(B.ticks,function(xe){le||xe.isNew||xe===ee||!xe.label||xe.label.textStr!==O||(ee.movedLabel=xe.label,le=!0,xe.labelPos=ee.movedLabel.xy,delete xe.label)}),!le&&(ee.labelPos||ne)&&(fe=ee.labelPos||ne.xy,ee.movedLabel=ee.createLabel(O,N,fe),ee.movedLabel&&ee.movedLabel.attr({opacity:0}))}render(O,N,ee){let ne=this.axis,B=ne.horiz,le=this.pos,fe=I(this.tickmarkOffset,ne.tickmarkOffset),xe=this.getPosition(B,le,fe,N),we=xe.x,he=xe.y,_e=ne.pos,ve=_e+ne.len,ae=B?we:he;!ne.chart.polar&&this.isNew&&(g(ae)<_e||ae>ve)&&(ee=0);let ie=I(ee,this.label&&this.label.newOpacity,1);ee=I(ee,1),this.isActive=!0,this.renderGridLine(N,ee),this.renderMark(xe,ee),this.renderLabel(xe,N,ie,O),this.isNew=!1,$(this,"afterRender")}renderGridLine(O,N){let ee=this.axis,ne=ee.options,B={},le=this.pos,fe=this.type,xe=I(this.tickmarkOffset,ee.tickmarkOffset),we=ee.chart.renderer,he=this.gridLine,_e,ve=ne.gridLineWidth,ae=ne.gridLineColor,ie=ne.gridLineDashStyle;this.type==="minor"&&(ve=ne.minorGridLineWidth,ae=ne.minorGridLineColor,ie=ne.minorGridLineDashStyle),he||(ee.chart.styledMode||(B.stroke=ae,B["stroke-width"]=ve||0,B.dashstyle=ie),fe||(B.zIndex=1),O&&(N=0),this.gridLine=he=we.path().attr(B).addClass("highcharts-"+(fe?fe+"-":"")+"grid-line").add(ee.gridGroup)),he&&(_e=ee.getPlotLinePath({value:le+xe,lineWidth:he.strokeWidth(),force:"pass",old:O,acrossPanes:!1}))&&he[O||this.isNew?"attr":"animate"]({d:_e,opacity:N})}renderMark(O,N){let ee=this.axis,ne=ee.options,B=ee.chart.renderer,le=this.type,fe=ee.tickSize(le?le+"Tick":"tick"),xe=O.x,we=O.y,he=I(ne[le!=="minor"?"tickWidth":"minorTickWidth"],!le&&ee.isXAxis?1:0),_e=ne[le!=="minor"?"tickColor":"minorTickColor"],ve=this.mark,ae=!ve;fe&&(ee.opposite&&(fe[0]=-fe[0]),ve||(this.mark=ve=B.path().addClass("highcharts-"+(le?le+"-":"")+"tick").add(ee.axisGroup),ee.chart.styledMode||ve.attr({stroke:_e,"stroke-width":he})),ve[ae?"attr":"animate"]({d:this.getMarkPath(xe,we,fe[0],ve.strokeWidth(),ee.horiz,B),opacity:N}))}renderLabel(O,N,ee,ne){let B=this.axis,le=B.horiz,fe=B.options,xe=this.label,we=fe.labels,he=we.step,_e=I(this.tickmarkOffset,B.tickmarkOffset),ve=O.x,ae=O.y,ie=!0;xe&&k(ve)&&(xe.xy=O=this.getLabelPosition(ve,ae,xe,le,we,_e,ne,he),(!this.isFirst||this.isLast||fe.showFirstLabel)&&(!this.isLast||this.isFirst||fe.showLastLabel)?!le||we.step||we.rotation||N||ee===0||this.handleOverflow(O):ie=!1,he&&ne%he&&(ie=!1),ie&&k(O.y)?(O.opacity=ee,xe[this.isNewLabel?"attr":"animate"](O).show(!0),this.isNewLabel=!1):(xe.hide(),this.isNewLabel=!0))}replaceMovedLabel(){let O=this.label,N=this.axis;O&&!this.isNew&&(O.animate({opacity:0},void 0,O.destroy),delete this.label),N.isDirty=!0,this.label=this.movedLabel,delete this.movedLabel}}}),n(r,"Core/Axis/Axis.js",[r["Core/Animation/AnimationUtilities.js"],r["Core/Axis/AxisDefaults.js"],r["Core/Color/Color.js"],r["Core/Defaults.js"],r["Core/Foundation.js"],r["Core/Globals.js"],r["Core/Axis/Tick.js"],r["Core/Utilities.js"]],function(o,a,l,c,u,g,b,x){let{animObject:S}=o,{xAxis:$,yAxis:k}=a,{defaultOptions:T}=c,{registerEventOptions:D}=u,{deg2rad:I}=g,{arrayMax:O,arrayMin:N,clamp:ee,correctFloat:ne,defined:B,destroyObjectProperties:le,erase:fe,error:xe,extend:we,fireEvent:he,getClosestDistance:_e,insertItem:ve,isArray:ae,isNumber:ie,isString:pe,merge:ue,normalizeTickInterval:ge,objectEach:ye,pick:Ae,relativeLength:Re,removeEvent:We,splat:Pe,syncTimeout:Ue}=x,Oe=(Ye,Se)=>ge(Se,void 0,void 0,Ae(Ye.options.allowDecimals,Se<.5||Ye.tickAmount!==void 0),!!Ye.tickAmount);we(T,{xAxis:$,yAxis:ue($,k)});class Be{constructor(Se,Te,$e){this.init(Se,Te,$e)}init(Se,Te,$e=this.coll){let Ve=$e==="xAxis",oe=this.isZAxis||(Se.inverted?!Ve:Ve);this.chart=Se,this.horiz=oe,this.isXAxis=Ve,this.coll=$e,he(this,"init",{userOptions:Te}),this.opposite=Ae(Te.opposite,this.opposite),this.side=Ae(Te.side,this.side,oe?this.opposite?0:2:this.opposite?1:3),this.setOptions(Te);let te=this.options,se=te.labels,me=te.type;this.userOptions=Te,this.minPixelPadding=0,this.reversed=Ae(te.reversed,this.reversed),this.visible=te.visible,this.zoomEnabled=te.zoomEnabled,this.hasNames=me==="category"||te.categories===!0,this.categories=ae(te.categories)&&te.categories||(this.hasNames?[]:void 0),this.names||(this.names=[],this.names.keys={}),this.plotLinesAndBandsGroups={},this.positiveValuesOnly=!!this.logarithmic,this.isLinked=B(te.linkedTo),this.ticks={},this.labelEdge=[],this.minorTicks={},this.plotLinesAndBands=[],this.alternateBands={},this.len??(this.len=0),this.minRange=this.userMinRange=te.minRange||te.maxZoom,this.range=te.range,this.offset=te.offset||0,this.max=void 0,this.min=void 0;let Ee=Ae(te.crosshair,Pe(Se.options.tooltip.crosshairs)[Ve?0:1]);this.crosshair=Ee===!0?{}:Ee,Se.axes.indexOf(this)===-1&&(Ve?Se.axes.splice(Se.xAxis.length,0,this):Se.axes.push(this),ve(this,Se[this.coll])),Se.orderItems(this.coll),this.series=this.series||[],Se.inverted&&!this.isZAxis&&Ve&&!B(this.reversed)&&(this.reversed=!0),this.labelRotation=ie(se.rotation)?se.rotation:void 0,D(this,te),he(this,"afterInit")}setOptions(Se){let Te=this.horiz?{labels:{autoRotation:[-45],padding:4},margin:15}:{labels:{padding:1},title:{rotation:90*this.side}};this.options=ue(Te,T[this.coll],Se),he(this,"afterSetOptions",{userOptions:Se})}defaultLabelFormatter(){let Se=this.axis,{numberFormatter:Te}=this.chart,$e=ie(this.value)?this.value:NaN,Ve=Se.chart.time,oe=Se.categories,te=this.dateTimeLabelFormat,se=T.lang,me=se.numericSymbols,Ee=se.numericSymbolMagnitude||1e3,Le=Se.logarithmic?Math.abs($e):Se.tickInterval,He=me&&me.length,ze,Qe;if(oe)Qe=`${this.value}`;else if(te)Qe=Ve.dateFormat(te,$e);else if(He&&me&&Le>=1e3)for(;He--&&Qe===void 0;)Le>=(ze=Math.pow(Ee,He+1))&&10*$e%ze==0&&me[He]!==null&&$e!==0&&(Qe=Te($e/ze,-1)+me[He]);return Qe===void 0&&(Qe=Math.abs($e)>=1e4?Te($e,-1):Te($e,-1,void 0,"")),Qe}getSeriesExtremes(){let Se,Te=this;he(this,"getSeriesExtremes",null,function(){Te.hasVisibleSeries=!1,Te.dataMin=Te.dataMax=Te.threshold=void 0,Te.softThreshold=!Te.isXAxis,Te.series.forEach($e=>{if($e.reserveSpace()){let Ve=$e.options,oe,te=Ve.threshold,se,me;if(Te.hasVisibleSeries=!0,Te.positiveValuesOnly&&0>=(te||0)&&(te=void 0),Te.isXAxis)(oe=$e.xData)&&oe.length&&(oe=Te.logarithmic?oe.filter(Ee=>Ee>0):oe,se=(Se=$e.getXExtremes(oe)).min,me=Se.max,ie(se)||se instanceof Date||(oe=oe.filter(ie),se=(Se=$e.getXExtremes(oe)).min,me=Se.max),oe.length&&(Te.dataMin=Math.min(Ae(Te.dataMin,se),se),Te.dataMax=Math.max(Ae(Te.dataMax,me),me)));else{let Ee=$e.applyExtremes();ie(Ee.dataMin)&&(se=Ee.dataMin,Te.dataMin=Math.min(Ae(Te.dataMin,se),se)),ie(Ee.dataMax)&&(me=Ee.dataMax,Te.dataMax=Math.max(Ae(Te.dataMax,me),me)),B(te)&&(Te.threshold=te),(!Ve.softThreshold||Te.positiveValuesOnly)&&(Te.softThreshold=!1)}}})}),he(this,"afterGetSeriesExtremes")}translate(Se,Te,$e,Ve,oe,te){let se=this.linkedParent||this,me=Ve&&se.old?se.old.min:se.min;if(!ie(me))return NaN;let Ee=se.minPixelPadding,Le=(se.isOrdinal||se.brokenAxis?.hasBreaks||se.logarithmic&&oe)&&se.lin2val,He=1,ze=0,Qe=Ve&&se.old?se.old.transA:se.transA,rt=0;return Qe||(Qe=se.transA),$e&&(He*=-1,ze=se.len),se.reversed&&(He*=-1,ze-=He*(se.sector||se.len)),Te?(rt=(Se=Se*He+ze-Ee)/Qe+me,Le&&(rt=se.lin2val(rt))):(Le&&(Se=se.val2lin(Se)),rt=He*(Se-me)*Qe+ze+He*Ee+(ie(te)?Qe*te:0),se.isRadial||(rt=ne(rt))),rt}toPixels(Se,Te){return this.translate(Se,!1,!this.horiz,void 0,!0)+(Te?0:this.pos)}toValue(Se,Te){return this.translate(Se-(Te?0:this.pos),!0,!this.horiz,void 0,!0)}getPlotLinePath(Se){let Te=this,$e=Te.chart,Ve=Te.left,oe=Te.top,te=Se.old,se=Se.value,me=Se.lineWidth,Ee=te&&$e.oldChartHeight||$e.chartHeight,Le=te&&$e.oldChartWidth||$e.chartWidth,He=Te.transB,ze=Se.translatedValue,Qe=Se.force,rt,Ke,Ie,Fe,je;function Ze(ce,de,De){return Qe!=="pass"&&(ceDe)&&(Qe?ce=ee(ce,de,De):je=!0),ce}let Ce={value:se,lineWidth:me,old:te,force:Qe,acrossPanes:Se.acrossPanes,translatedValue:ze};return he(this,"getPlotLinePath",Ce,function(ce){rt=Ie=(ze=ee(ze=Ae(ze,Te.translate(se,void 0,void 0,te)),-1e5,1e5))+He,Ke=Fe=Ee-ze-He,ie(ze)?Te.horiz?(Ke=oe,Fe=Ee-Te.bottom+($e.scrollablePixelsY||0),rt=Ie=Ze(rt,Ve,Ve+Te.width)):(rt=Ve,Ie=Le-Te.right+($e.scrollablePixelsX||0),Ke=Fe=Ze(Ke,oe,oe+Te.height)):(je=!0,Qe=!1),ce.path=je&&!Qe?void 0:$e.renderer.crispLine([["M",rt,Ke],["L",Ie,Fe]],me||1)}),Ce.path}getLinearTickPositions(Se,Te,$e){let Ve,oe,te,se=ne(Math.floor(Te/Se)*Se),me=ne(Math.ceil($e/Se)*Se),Ee=[];if(ne(se+Se)===se&&(te=20),this.single)return[Te];for(Ve=se;Ve<=me&&(Ee.push(Ve),(Ve=ne(Ve+Se,te))!==oe);)oe=Ve;return Ee}getMinorTickInterval(){let{minorTicks:Se,minorTickInterval:Te}=this.options;return Se===!0?Ae(Te,"auto"):Se!==!1?Te:void 0}getMinorTickPositions(){let Se=this.options,Te=this.tickPositions,$e=this.minorTickInterval,Ve=this.pointRangePadding||0,oe=(this.min||0)-Ve,te=(this.max||0)+Ve,se=te-oe,me=[],Ee;if(se&&se/$e(Le.xIncrement?Le.xData?.slice(0,2):Le.xData)||[]))||0),this.dataMax-this.dataMin)),ie($e)&&ie(Ve)&&ie(oe)&&$e-Ve=oe,te=(oe-$e+Ve)/2,me=[Ve-te,Ae(Se.min,Ve-te)],se&&(me[2]=Te?Te.log2lin(this.dataMin):this.dataMin),Ee=[(Ve=O(me))+oe,Ae(Se.max,Ve+oe)],se&&(Ee[2]=Te?Te.log2lin(this.dataMax):this.dataMax),($e=N(Ee))-VeVe-oe),Se=_e([$e]))}return Se&&Te?Math.min(Se,Te):Se||Te}nameToX(Se){let Te=ae(this.options.categories),$e=Te?this.categories:this.names,Ve=Se.options.x,oe;return Se.series.requireSorting=!1,B(Ve)||(Ve=this.options.uniqueNames&&$e?Te?$e.indexOf(Se.name):Ae($e.keys[Se.name],-1):Se.series.autoIncrement()),Ve===-1?!Te&&$e&&(oe=$e.length):oe=Ve,oe!==void 0?(this.names[oe]=Se.name,this.names.keys[Se.name]=oe):Se.x&&(oe=Se.x),oe}updateNames(){let Se=this,Te=this.names;Te.length>0&&(Object.keys(Te.keys).forEach(function($e){delete Te.keys[$e]}),Te.length=0,this.minRange=this.userMinRange,(this.series||[]).forEach($e=>{$e.xIncrement=null,(!$e.points||$e.isDirtyData)&&(Se.max=Math.max(Se.max,$e.xData.length-1),$e.processData(),$e.generatePoints()),$e.data.forEach(function(Ve,oe){let te;Ve?.options&&Ve.name!==void 0&&(te=Se.nameToX(Ve))!==void 0&&te!==Ve.x&&(Ve.x=te,$e.xData[oe]=te)})}))}setAxisTranslation(){let Se=this,Te=Se.max-Se.min,$e=Se.linkedParent,Ve=!!Se.categories,oe=Se.isXAxis,te=Se.axisPointRange||0,se,me=0,Ee=0,Le,He=Se.transA;(oe||Ve||te)&&(se=Se.getClosest(),$e?(me=$e.minPointOffset,Ee=$e.pointRangePadding):Se.series.forEach(function(ze){let Qe=Ve?1:oe?Ae(ze.options.pointRange,se,0):Se.axisPointRange||0,rt=ze.options.pointPlacement;if(te=Math.max(te,Qe),!Se.single||Ve){let Ke=ze.is("xrange")?!oe:oe;me=Math.max(me,Ke&&pe(rt)?0:Qe/2),Ee=Math.max(Ee,Ke&&rt==="on"?0:Qe)}}),Le=Se.ordinal&&Se.ordinal.slope&&se?Se.ordinal.slope/se:1,Se.minPointOffset=me*=Le,Se.pointRangePadding=Ee*=Le,Se.pointRange=Math.min(te,Se.single&&Ve?1:Te),oe&&se&&(Se.closestPointRange=se)),Se.translationSlope=Se.transA=He=Se.staticScale||Se.len/(Te+Ee||1),Se.transB=Se.horiz?Se.left:Se.bottom,Se.minPixelPadding=He*me,he(this,"afterSetAxisTranslation")}minFromRange(){let{max:Se,min:Te}=this;return ie(Se)&&ie(Te)&&Se-Te||void 0}setTickInterval(Se){let{categories:Te,chart:$e,dataMax:Ve,dataMin:oe,dateTime:te,isXAxis:se,logarithmic:me,options:Ee,softThreshold:Le}=this,He=ie(this.threshold)?this.threshold:void 0,ze=this.minRange||0,{ceiling:Qe,floor:rt,linkedTo:Ke,softMax:Ie,softMin:Fe}=Ee,je=ie(Ke)&&$e[this.coll]?.[Ke],Ze=Ee.tickPixelInterval,Ce=Ee.maxPadding,ce=Ee.minPadding,de=0,De,qe=ie(Ee.tickInterval)&&Ee.tickInterval>=0?Ee.tickInterval:void 0,nt,lt,pt,bt;if(te||Te||je||this.getTickAmount(),pt=Ae(this.userMin,Ee.min),bt=Ae(this.userMax,Ee.max),je?(this.linkedParent=je,De=je.getExtremes(),this.min=Ae(De.min,De.dataMin),this.max=Ae(De.max,De.dataMax),Ee.type!==je.options.type&&xe(11,!0,$e)):(Le&&B(He)&&ie(Ve)&&ie(oe)&&(oe>=He?(nt=He,ce=0):Ve<=He&&(lt=He,Ce=0)),this.min=Ae(pt,nt,oe),this.max=Ae(bt,lt,Ve)),ie(this.max)&&ie(this.min)&&(me&&(this.positiveValuesOnly&&!Se&&0>=Math.min(this.min,Ae(oe,this.min))&&xe(10,!0,$e),this.min=ne(me.log2lin(this.min),16),this.max=ne(me.log2lin(this.max),16)),this.range&&ie(oe)&&(this.userMin=this.min=pt=Math.max(oe,this.minFromRange()||0),this.userMax=bt=this.max,this.range=void 0)),he(this,"foundExtremes"),this.adjustForMinRange(),ie(this.min)&&ie(this.max)){if(!ie(this.userMin)&&ie(Fe)&&Fethis.max&&(this.max=bt=Ie),Te||this.axisPointRange||this.stacking?.usePercentage||je||!(de=this.max-this.min)||(!B(pt)&&ce&&(this.min-=de*ce),B(bt)||!Ce||(this.max+=de*Ce)),!ie(this.userMin)&&ie(rt)&&(this.min=Math.max(this.min,rt)),!ie(this.userMax)&&ie(Qe)&&(this.max=Math.min(this.max,Qe)),Le&&ie(oe)&&ie(Ve)){let Et=He||0;!B(pt)&&this.min=Et?this.min=Ee.minRange?Math.min(Et,this.max-ze):Et:!B(bt)&&this.max>Et&&Ve<=Et&&(this.max=Ee.minRange?Math.max(Et,this.min+ze):Et)}!$e.polar&&this.min>this.max&&(B(Ee.min)?this.max=this.min:B(Ee.max)&&(this.min=this.max)),de=this.max-this.min}if(this.min!==this.max&&ie(this.min)&&ie(this.max)?je&&!qe&&Ze===je.options.tickPixelInterval?this.tickInterval=qe=je.tickInterval:this.tickInterval=Ae(qe,this.tickAmount?de/Math.max(this.tickAmount-1,1):void 0,Te?1:de*Ze/Math.max(this.len,Ze)):this.tickInterval=1,se&&!Se){let Et=this.min!==this.old?.min||this.max!==this.old?.max;this.series.forEach(function(vt){vt.forceCrop=vt.forceCropping?.(),vt.processData(Et)}),he(this,"postProcessData",{hasExtremesChanged:Et})}this.setAxisTranslation(),he(this,"initialAxisTranslation"),this.pointRange&&!qe&&(this.tickInterval=Math.max(this.pointRange,this.tickInterval));let St=Ae(Ee.minTickInterval,te&&!this.series.some(Et=>Et.noSharedTooltip)?this.closestPointRange:0);!qe&&this.tickIntervalMath.max(2*this.len,200))me=[this.min,this.max],xe(19,!1,this.chart);else if(this.dateTime)me=this.getTimeTicks(this.dateTime.normalizeTimeTickInterval(this.tickInterval,Se.units),this.min,this.max,Se.startOfWeek,this.ordinal?.positions,this.closestPointRange,!0);else if(this.logarithmic)me=this.logarithmic.getLogTickPositions(this.tickInterval,this.min,this.max);else{let Le=this.tickInterval,He=Le;for(;He<=2*Le&&(me=this.getLinearTickPositions(this.tickInterval,this.min,this.max),this.tickAmount&&me.length>this.tickAmount);)this.tickInterval=Oe(this,He*=1.1)}me.length>this.len&&(me=[me[0],me[me.length-1]])[0]===me[1]&&(me.length=1),$e&&(this.tickPositions=me,(Ee=$e.apply(this,[this.min,this.max]))&&(me=Ee))}this.tickPositions=me,this.paddedTicks=me.slice(0),this.trimTicks(me,te,se),!this.isLinked&&ie(this.min)&&ie(this.max)&&(this.single&&me.length<2&&!this.categories&&!this.series.some(Le=>Le.is("heatmap")&&Le.options.pointPlacement==="between")&&(this.min-=.5,this.max+=.5),Te||Ee||this.adjustTickAmount()),he(this,"afterSetTickPositions")}trimTicks(Se,Te,$e){let Ve=Se[0],oe=Se[Se.length-1],te=!this.isOrdinal&&this.minPointOffset||0;if(he(this,"trimTicks"),!this.isLinked){if(Te&&Ve!==-1/0)this.min=Ve;else for(;this.min-te>Se[0];)Se.shift();if($e)this.max=oe;else for(;this.max+te{let{horiz:ze,options:Qe}=He;return[ze?Qe.left:Qe.top,Qe.width,Qe.height,Qe.pane].join(",")},Le=Ee(this);$e[this.coll].forEach(function(He){let{series:ze}=He;ze.length&&ze.some(Qe=>Qe.visible)&&He!==Te&&Ee(He)===Le&&(Se=!0,Ve.push(He))})}if(Se&&se){Ve.forEach(Le=>{let He=Le.getThresholdAlignment(Te);ie(He)&&me.push(He)});let Ee=me.length>1?me.reduce((Le,He)=>Le+=He,0)/me.length:void 0;Ve.forEach(Le=>{Le.thresholdAlignment=Ee})}return Se}getThresholdAlignment(Se){if((!ie(this.dataMin)||this!==Se&&this.series.some(Te=>Te.isDirty||Te.isDirtyData))&&this.getSeriesExtremes(),ie(this.threshold)){let Te=ee((this.threshold-(this.dataMin||0))/((this.dataMax||0)-(this.dataMin||0)),0,1);return this.options.reversed&&(Te=1-Te),Te}}getTickAmount(){let Se=this.options,Te=Se.tickPixelInterval,$e=Se.tickAmount;B(Se.tickInterval)||$e||!(this.lente.push(ne(te[te.length-1]+Qe)),Ie=()=>te.unshift(ne(te[0]-Qe));if(ie(me)&&(rt=me<.5?Math.ceil(me*(se-1)):Math.floor(me*(se-1)),oe.reversed&&(rt=se-1-rt)),Se.hasData()&&ie(Ve)&&ie($e)){let Fe=()=>{Se.transA*=(Ee-1)/(se-1),Se.min=oe.startOnTick?te[0]:Math.min(Ve,te[0]),Se.max=oe.endOnTick?te[te.length-1]:Math.max($e,te[te.length-1])};if(ie(rt)&&ie(Se.threshold)){for(;te[rt]!==Le||te.length!==se||te[0]>Ve||te[te.length-1]<$e;){for(te.length=0,te.push(Se.threshold);te.lengthSe.threshold?Ie():Ke();if(Qe>8*Se.tickInterval)break;Qe*=2}Fe()}else if(Ee0&&ze{$e=$e||te.isDirtyData||te.isDirty,Ve=Ve||te.xAxis&&te.xAxis.isDirty||!1}),this.setAxisSize();let oe=this.len!==(this.old&&this.old.len);oe||$e||Ve||this.isLinked||this.forceRedraw||this.userMin!==(this.old&&this.old.userMin)||this.userMax!==(this.old&&this.old.userMax)||this.alignToOthers()?(Te&&Se==="yAxis"&&Te.buildStacks(),this.forceRedraw=!1,this.userMinRange||(this.minRange=void 0),this.getSeriesExtremes(),this.setTickInterval(),Te&&Se==="xAxis"&&Te.buildStacks(),this.isDirty||(this.isDirty=oe||this.min!==this.old?.min||this.max!==this.old?.max)):Te&&Te.cleanStacks(),$e&&delete this.allExtremes,he(this,"afterSetScale")}setExtremes(Se,Te,$e=!0,Ve,oe){this.series.forEach(te=>{delete te.kdTree}),he(this,"setExtremes",oe=we(oe,{min:Se,max:Te}),te=>{this.userMin=te.min,this.userMax=te.max,this.eventArgs=te,$e&&this.chart.redraw(Ve)})}setAxisSize(){let Se=this.chart,Te=this.options,$e=Te.offsets||[0,0,0,0],Ve=this.horiz,oe=this.width=Math.round(Re(Ae(Te.width,Se.plotWidth-$e[3]+$e[1]),Se.plotWidth)),te=this.height=Math.round(Re(Ae(Te.height,Se.plotHeight-$e[0]+$e[2]),Se.plotHeight)),se=this.top=Math.round(Re(Ae(Te.top,Se.plotTop+$e[0]),Se.plotHeight,Se.plotTop)),me=this.left=Math.round(Re(Ae(Te.left,Se.plotLeft+$e[3]),Se.plotWidth,Se.plotLeft));this.bottom=Se.chartHeight-te-se,this.right=Se.chartWidth-oe-me,this.len=Math.max(Ve?oe:te,0),this.pos=Ve?me:se}getExtremes(){let Se=this.logarithmic;return{min:Se?ne(Se.lin2log(this.min)):this.min,max:Se?ne(Se.lin2log(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}}getThreshold(Se){let Te=this.logarithmic,$e=Te?Te.lin2log(this.min):this.min,Ve=Te?Te.lin2log(this.max):this.max;return Se===null||Se===-1/0?Se=$e:Se===1/0?Se=Ve:$e>Se?Se=$e:Ve15&&Te<165?Ve.align="right":Te>195&&Te<345&&(Ve.align="left")}),$e.align}tickSize(Se){let Te=this.options,$e=Ae(Te[Se==="tick"?"tickWidth":"minorTickWidth"],Se==="tick"&&this.isXAxis&&!this.categories?1:0),Ve=Te[Se==="tick"?"tickLength":"minorTickLength"],oe;$e&&Ve&&(Te[Se+"Position"]==="inside"&&(Ve=-Ve),oe=[Ve,$e]);let te={tickSize:oe};return he(this,"afterTickSize",te),te.tickSize}labelMetrics(){let Se=this.chart.renderer,Te=this.ticks,$e=Te[Object.keys(Te)[0]]||{};return this.chart.renderer.fontMetrics($e.label||$e.movedLabel||Se.box)}unsquish(){let Se=this.options.labels,Te=Se.padding||0,$e=this.horiz,Ve=this.tickInterval,oe=this.len/(((this.categories?1:0)+this.max-this.min)/Ve),te=Se.rotation,se=ne(.8*this.labelMetrics().h),me=Math.max(this.max-this.min,0),Ee=function(rt){let Ke=(rt+2*Te)/(oe||1);return(Ke=Ke>1?Math.ceil(Ke):1)*Ve>me&&rt!==1/0&&oe!==1/0&&me&&(Ke=Math.ceil(me/Ve)),ne(Ke*Ve)},Le=Ve,He,ze=Number.MAX_VALUE,Qe;if($e){if(!Se.staggerLines&&(ie(te)?Qe=[te]:oe=-90&&Ie<=90)&&(Ke=(rt=Ee(Math.abs(se/Math.sin(I*Ie))))+Math.abs(Ie/360))Ke&&(Ke=Ze.label.textPxLength)}),this.maxLabelLength=Ke,this.autoRotation)Ke>Ee&&Ke>He.h?Le.rotation=this.labelRotation:this.labelRotation=0;else if(me&&(Qe=Ee,!ze))for(rt="clip",Fe=$e.length;!se&&Fe--;)(Ie=Ve[$e[Fe]].label)&&(Ie.styles.textOverflow==="ellipsis"?Ie.css({textOverflow:"clip"}):Ie.textPxLength>me&&Ie.css({width:me+"px"}),Ie.getBBox().height>this.len/$e.length-(He.h-He.f)&&(Ie.specificTextOverflow="ellipsis"));Le.rotation&&(Qe=Ke>.5*Se.chartHeight?.33*Se.chartHeight:Ke,ze||(rt="ellipsis")),this.labelAlign=oe.align||this.autoLabelAlign(this.labelRotation),this.labelAlign&&(Le.align=this.labelAlign),$e.forEach(function(je){let Ze=Ve[je],Ce=Ze&&Ze.label,ce=te.width,de={};Ce&&(Ce.attr(Le),Ze.shortenLabel?Ze.shortenLabel():Qe&&!ce&&te.whiteSpace!=="nowrap"&&(Qeoe.g(se).attr({zIndex:Ee}).addClass(`highcharts-${$e.toLowerCase()}${me} `+(this.isRadial?`highcharts-radial-axis${me} `:"")+(Ve.className||"")).add(Se);this.axisGroup||(this.gridGroup=te("grid","-grid",Ve.gridZIndex),this.axisGroup=te("axis","",Ve.zIndex),this.labelGroup=te("axis-labels","-labels",Ve.labels.zIndex))}getOffset(){let Se=this,{chart:Te,horiz:$e,options:Ve,side:oe,ticks:te,tickPositions:se,coll:me}=Se,Ee=Te.inverted&&!Se.isZAxis?[1,0,3,2][oe]:oe,Le=Se.hasData(),He=Ve.title,ze=Ve.labels,Qe=ie(Ve.crossing),rt=Te.axisOffset,Ke=Te.clipOffset,Ie=[-1,1,1,-1][oe],Fe,je=0,Ze,Ce=0,ce=0,de,De;if(Se.showAxis=Fe=Le||Ve.showEmpty,Se.staggerLines=Se.horiz&&ze.staggerLines||void 0,Se.createGroups(),Le||Se.isLinked?(se.forEach(function(qe){Se.generateTick(qe)}),Se.renderUnsquish(),Se.reserveSpaceDefault=oe===0||oe===2||{1:"left",3:"right"}[oe]===Se.labelAlign,Ae(ze.reserveSpace,!Qe&&null,Se.labelAlign==="center"||null,Se.reserveSpaceDefault)&&se.forEach(function(qe){ce=Math.max(te[qe].getLabelSize(),ce)}),Se.staggerLines&&(ce*=Se.staggerLines),Se.labelOffset=ce*(Se.opposite?-1:1)):ye(te,function(qe,nt){qe.destroy(),delete te[nt]}),He?.text&&He.enabled!==!1&&(Se.addTitle(Fe),Fe&&!Qe&&He.reserveSpace!==!1&&(Se.titleOffset=je=Se.axisTitle.getBBox()[$e?"height":"width"],Ce=B(Ze=He.offset)?0:Ae(He.margin,$e?5:10))),Se.renderLine(),Se.offset=Ie*Ae(Ve.offset,rt[oe]?rt[oe]+(Ve.margin||0):0),Se.tickRotCorr=Se.tickRotCorr||{x:0,y:0},De=oe===0?-Se.labelMetrics().h:oe===2?Se.tickRotCorr.y:0,de=Math.abs(ce)+Ce,ce&&(de-=De,de+=Ie*($e?Ae(ze.y,Se.tickRotCorr.y+Ie*ze.distance):Ae(ze.x,Ie*ze.distance))),Se.axisTitleMargin=Ae(Ze,de),Se.getMaxLabelDimensions&&(Se.maxLabelDimensions=Se.getMaxLabelDimensions(te,se)),me!=="colorAxis"&&Ke){let qe=this.tickSize("tick");rt[oe]=Math.max(rt[oe],(Se.axisTitleMargin||0)+je+Ie*Se.offset,de,se&&se.length&&qe?qe[0]+Ie*Se.offset:0);let nt=!Se.axisLine||Ve.offset?0:Se.axisLine.strokeWidth()/2;Ke[Ee]=Math.max(Ke[Ee],nt)}he(this,"afterGetOffset")}getLinePath(Se){let Te=this.chart,$e=this.opposite,Ve=this.offset,oe=this.horiz,te=this.left+($e?this.width:0)+Ve,se=Te.chartHeight-this.bottom-($e?this.height:0)+Ve;return $e&&(Se*=-1),Te.renderer.crispLine([["M",oe?this.left:te,oe?se:this.top],["L",oe?Te.chartWidth-this.right:te,oe?se:Te.chartHeight-this.bottom]],Se)}renderLine(){this.axisLine||(this.axisLine=this.chart.renderer.path().addClass("highcharts-axis-line").add(this.axisGroup),this.chart.styledMode||this.axisLine.attr({stroke:this.options.lineColor,"stroke-width":this.options.lineWidth,zIndex:7}))}getTitlePosition(Se){let Te=this.horiz,$e=this.left,Ve=this.top,oe=this.len,te=this.options.title,se=Te?$e:Ve,me=this.opposite,Ee=this.offset,Le=te.x,He=te.y,ze=this.chart.renderer.fontMetrics(Se),Qe=Se?Math.max(Se.getBBox(!1,0).height-ze.h-1,0):0,rt={low:se+(Te?0:oe),middle:se+oe/2,high:se+(Te?oe:0)}[te.align],Ke=(Te?Ve+this.height:$e)+(Te?1:-1)*(me?-1:1)*(this.axisTitleMargin||0)+[-Qe,Qe,ze.f,-Qe][this.side],Ie={x:Te?rt+Le:Ke+(me?this.width:0)+Ee+Le,y:Te?Ke+He-(me?this.height:0)+Ee:rt+He};return he(this,"afterGetTitlePosition",{titlePosition:Ie}),Ie}renderMinorTick(Se,Te){let $e=this.minorTicks;$e[Se]||($e[Se]=new b(this,Se,"minor")),Te&&$e[Se].isNew&&$e[Se].render(null,!0),$e[Se].render(null,!1,1)}renderTick(Se,Te,$e){let Ve=this.isLinked,oe=this.ticks;(!Ve||Se>=this.min&&Se<=this.max||this.grid&&this.grid.isColumn)&&(oe[Se]||(oe[Se]=new b(this,Se)),$e&&oe[Se].isNew&&oe[Se].render(Te,!0,-1),oe[Se].render(Te))}render(){let Se,Te,$e=this,Ve=$e.chart,oe=$e.logarithmic,te=Ve.renderer,se=$e.options,me=$e.isLinked,Ee=$e.tickPositions,Le=$e.axisTitle,He=$e.ticks,ze=$e.minorTicks,Qe=$e.alternateBands,rt=se.stackLabels,Ke=se.alternateGridColor,Ie=se.crossing,Fe=$e.tickmarkOffset,je=$e.axisLine,Ze=$e.showAxis,Ce=S(te.globalAnimation);if($e.labelEdge.length=0,$e.overlap=!1,[He,ze,Qe].forEach(function(ce){ye(ce,function(de){de.isActive=!1})}),ie(Ie)){let ce=this.isXAxis?Ve.yAxis[0]:Ve.xAxis[0],de=[1,-1,-1,1][this.side];if(ce){let De=ce.toPixels(Ie,!0);$e.horiz&&(De=ce.len-De),$e.offset=de*De}}if($e.hasData()||me){let ce=$e.chart.hasRendered&&$e.old&&ie($e.old.min);$e.minorTickInterval&&!$e.categories&&$e.getMinorTickPositions().forEach(function(de){$e.renderMinorTick(de,ce)}),Ee.length&&(Ee.forEach(function(de,De){$e.renderTick(de,De,ce)}),Fe&&($e.min===0||$e.single)&&(He[-1]||(He[-1]=new b($e,-1,null,!0)),He[-1].render(-1))),Ke&&Ee.forEach(function(de,De){Te=Ee[De+1]!==void 0?Ee[De+1]+Fe:$e.max-Fe,De%2==0&&de<$e.max&&Te<=$e.max+(Ve.polar?-Fe:Fe)&&(Qe[de]||(Qe[de]=new g.PlotLineOrBand($e,{})),Se=de+Fe,Qe[de].options={from:oe?oe.lin2log(Se):Se,to:oe?oe.lin2log(Te):Te,color:Ke,className:"highcharts-alternate-grid"},Qe[de].render(),Qe[de].isActive=!0)}),$e._addedPlotLB||($e._addedPlotLB=!0,(se.plotLines||[]).concat(se.plotBands||[]).forEach(function(de){$e.addPlotBandOrLine(de)}))}[He,ze,Qe].forEach(function(ce){let de=[],De=Ce.duration;ye(ce,function(qe,nt){qe.isActive||(qe.render(nt,!1,0),qe.isActive=!1,de.push(nt))}),Ue(function(){let qe=de.length;for(;qe--;)ce[de[qe]]&&!ce[de[qe]].isActive&&(ce[de[qe]].destroy(),delete ce[de[qe]])},ce!==Qe&&Ve.hasRendered&&De?De:0)}),je&&(je[je.isPlaced?"animate":"attr"]({d:this.getLinePath(je.strokeWidth())}),je.isPlaced=!0,je[Ze?"show":"hide"](Ze)),Le&&Ze&&(Le[Le.isNew?"attr":"animate"]($e.getTitlePosition(Le)),Le.isNew=!1),rt&&rt.enabled&&$e.stacking&&$e.stacking.renderStackTotals(),$e.old={len:$e.len,max:$e.max,min:$e.min,transA:$e.transA,userMax:$e.userMax,userMin:$e.userMin},$e.isDirty=!1,he(this,"afterRender")}redraw(){this.visible&&(this.render(),this.plotLinesAndBands.forEach(function(Se){Se.render()})),this.series.forEach(function(Se){Se.isDirty=!0})}getKeepProps(){return this.keepProps||Be.keepProps}destroy(Se){let Te=this,$e=Te.plotLinesAndBands,Ve=this.eventOptions;if(he(this,"destroy",{keepEvents:Se}),Se||We(Te),[Te.ticks,Te.minorTicks,Te.alternateBands].forEach(function(oe){le(oe)}),$e){let oe=$e.length;for(;oe--;)$e[oe].destroy()}for(let oe in["axisLine","axisTitle","axisGroup","gridGroup","labelGroup","cross","scrollbar"].forEach(function(te){Te[te]&&(Te[te]=Te[te].destroy())}),Te.plotLinesAndBandsGroups)Te.plotLinesAndBandsGroups[oe]=Te.plotLinesAndBandsGroups[oe].destroy();ye(Te,function(oe,te){Te.getKeepProps().indexOf(te)===-1&&delete Te[te]}),this.eventOptions=Ve}drawCrosshair(Se,Te){let $e=this.crosshair,Ve=Ae($e&&$e.snap,!0),oe=this.chart,te,se,me,Ee=this.cross,Le;if(he(this,"drawCrosshair",{e:Se,point:Te}),Se||(Se=this.cross&&this.cross.e),$e&&(B(Te)||!Ve)!==!1){if(Ve?B(Te)&&(se=Ae(this.coll!=="colorAxis"?Te.crosshairPos:null,this.isXAxis?Te.plotX:this.len-Te.plotY)):se=Se&&(this.horiz?Se.chartX-this.pos:this.len-Se.chartY+this.pos),B(se)&&(Le={value:Te&&(this.isXAxis?Te.x:Ae(Te.stackY,Te.y)),translatedValue:se},oe.polar&&we(Le,{isCrosshair:!0,chartX:Se&&Se.chartX,chartY:Se&&Se.chartY,point:Te}),te=this.getPlotLinePath(Le)||null),!B(te)){this.hideCrosshair();return}me=this.categories&&!this.isRadial,Ee||(this.cross=Ee=oe.renderer.path().addClass("highcharts-crosshair highcharts-crosshair-"+(me?"category ":"thin ")+($e.className||"")).attr({zIndex:Ae($e.zIndex,2)}).add(),!oe.styledMode&&(Ee.attr({stroke:$e.color||(me?l.parse("#ccd3ff").setOpacity(.25).get():"#cccccc"),"stroke-width":Ae($e.width,1)}).css({"pointer-events":"none"}),$e.dashStyle&&Ee.attr({dashstyle:$e.dashStyle}))),Ee.show().attr({d:te}),me&&!$e.width&&Ee.attr({"stroke-width":this.transA}),this.cross.e=Se}else this.hideCrosshair();he(this,"afterDrawCrosshair",{e:Se,point:Te})}hideCrosshair(){this.cross&&this.cross.hide(),he(this,"afterHideCrosshair")}update(Se,Te){let $e=this.chart;Se=ue(this.userOptions,Se),this.destroy(!0),this.init($e,Se),$e.isDirtyBox=!0,Ae(Te,!0)&&$e.redraw()}remove(Se){let Te=this.chart,$e=this.coll,Ve=this.series,oe=Ve.length;for(;oe--;)Ve[oe]&&Ve[oe].remove(!1);fe(Te.axes,this),fe(Te[$e]||[],this),Te.orderItems($e),this.destroy(),Te.isDirtyBox=!0,Ae(Se,!0)&&Te.redraw()}setTitle(Se,Te){this.update({title:Se},Te)}setCategories(Se,Te){this.update({categories:Se},Te)}}return Be.keepProps=["coll","extKey","hcEvents","len","names","series","userMax","userMin"],Be}),n(r,"Core/Axis/DateTimeAxis.js",[r["Core/Utilities.js"]],function(o){var a;let{addEvent:l,getMagnitude:c,normalizeTickInterval:u,timeUnits:g}=o;return function(b){function x(){return this.chart.time.getTimeTicks.apply(this.chart.time,arguments)}function S(){if(this.options.type!=="datetime"){this.dateTime=void 0;return}this.dateTime||(this.dateTime=new $(this))}b.compose=function(k){return k.keepProps.includes("dateTime")||(k.keepProps.push("dateTime"),k.prototype.getTimeTicks=x,l(k,"afterSetOptions",S)),k};class ${constructor(T){this.axis=T}normalizeTimeTickInterval(T,D){let I=D||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]],O=I[I.length-1],N=g[O[0]],ee=O[1],ne;for(ne=0;ne=.5)k=Math.round(k),ne=O.getLinearTickPositions(k,T,D);else if(k>=.08){let B,le,fe,xe,we,he,_e,ve=Math.floor(T);for(B=k>.3?[1,2,4]:k>.15?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9],le=ve;leT&&(!I||he<=D)&&he!==void 0&&ne.push(he),he>D&&(_e=!0),he=we}else{let B=this.lin2log(T),le=this.lin2log(D),fe=I?O.getMinorTickInterval():ee.tickInterval,xe=ee.tickPixelInterval/(I?5:1),we=I?N/O.tickPositions.length:N;k=c(k=u(fe==="auto"?null:fe,this.minorAutoInterval,(le-B)*xe/(we||1))),ne=O.getLinearTickPositions(k,B,le).map(this.log2lin),I||(this.minorAutoInterval=k/5)}return I||(O.tickInterval=k),ne}lin2log(k){return Math.pow(10,k)}log2lin(k){return Math.log(k)/Math.LN10}}g.Additions=S}(a||(a={})),a}),n(r,"Core/Axis/PlotLineOrBand/PlotLineOrBandAxis.js",[r["Core/Utilities.js"]],function(o){var a;let{erase:l,extend:c,isNumber:u}=o;return function(g){let b;function x(O){return this.addPlotBandOrLine(O,"plotBands")}function S(O,N){let ee=this.userOptions,ne=new b(this,O);if(this.visible&&(ne=ne.render()),ne){if(this._addedPlotLB||(this._addedPlotLB=!0,(ee.plotLines||[]).concat(ee.plotBands||[]).forEach(B=>{this.addPlotBandOrLine(B)})),N){let B=ee[N]||[];B.push(O),ee[N]=B}this.plotLinesAndBands.push(ne)}return ne}function $(O){return this.addPlotBandOrLine(O,"plotLines")}function k(O,N,ee){ee=ee||this.options;let ne=this.getPlotLinePath({value:N,force:!0,acrossPanes:ee.acrossPanes}),B=[],le=this.horiz,fe=!u(this.min)||!u(this.max)||Othis.max&&N>this.max,xe=this.getPlotLinePath({value:O,force:!0,acrossPanes:ee.acrossPanes}),we,he=1,_e;if(xe&&ne)for(fe&&(_e=xe.toString()===ne.toString(),he=0),we=0;we{pe?.on(Oe,Be=>{B[Oe].apply(this,[Be])})}),this.eventsAdded=!0),(Re||!pe.d)&&ue?.length?pe.attr({d:ue}):pe&&(ue?(pe.show(),pe.animate({d:ue})):pe.d&&(pe.hide(),ie&&(this.label=ie=ie.destroy()))),ae&&(u(ae.text)||u(ae.formatter))&&ue?.length&&I.width>0&&I.height>0&&!ue.isFlat?(ae=S({align:N&&ye?"center":void 0,x:N?!ye&&4:10,verticalAlign:!N&&ye?"middle":void 0,y:N?ye?16:10:ye?6:-4,rotation:N&&!ye?90:0},ae),this.renderLabel(ae,ue,ye,le)):ie&&ie.hide(),this}renderLabel(I,O,N,ee){let ne=this.axis,B=ne.chart.renderer,le=this.label;le||(this.label=le=B.text(this.getLabelText(I),0,0,I.useHTML).attr({align:I.textAlign||I.align,rotation:I.rotation,class:"highcharts-plot-"+(N?"band":"line")+"-label "+(I.className||""),zIndex:ee}),ne.chart.styledMode||le.css(S({fontSize:"0.8em",textOverflow:"ellipsis"},I.style)),le.add());let fe=O.xBounds||[O[0][1],O[1][1],N?O[2][1]:O[0][1]],xe=O.yBounds||[O[0][2],O[1][2],N?O[2][2]:O[0][2]],we=c(fe),he=c(xe);if(le.align(I,!1,{x:we,y:he,width:l(fe)-we,height:l(xe)-he}),!le.alignValue||le.alignValue==="left"){let _e=I.clip?ne.width:ne.chart.chartWidth;le.css({width:(le.rotation===90?ne.height-(le.alignAttr.y-ne.top):_e-(le.alignAttr.x-ne.left))+"px"})}le.show(!0)}getLabelText(I){return u(I.formatter)?I.formatter.call(this):I.text}destroy(){b(this.axis.plotLinesAndBands,this),delete this.axis,g(this)}}return T}),n(r,"Core/Tooltip.js",[r["Core/Animation/AnimationUtilities.js"],r["Core/Templating.js"],r["Core/Globals.js"],r["Core/Renderer/RendererUtilities.js"],r["Core/Renderer/RendererRegistry.js"],r["Core/Utilities.js"]],function(o,a,l,c,u,g){var b;let{animObject:x}=o,{format:S}=a,{composed:$,doc:k,isSafari:T}=l,{distribute:D}=c,{addEvent:I,clamp:O,css:N,discardElement:ee,extend:ne,fireEvent:B,isArray:le,isNumber:fe,isString:xe,merge:we,pick:he,pushUnique:_e,splat:ve,syncTimeout:ae}=g;class ie{constructor(ue,ge,ye){this.allowShared=!0,this.crosshairs=[],this.distance=0,this.isHidden=!0,this.isSticky=!1,this.options={},this.outside=!1,this.chart=ue,this.init(ue,ge),this.pointer=ye}bodyFormatter(ue){return ue.map(function(ge){let ye=ge.series.tooltipOptions;return(ye[(ge.point.formatPrefix||"point")+"Formatter"]||ge.point.tooltipFormatter).call(ge.point,ye[(ge.point.formatPrefix||"point")+"Format"]||"")})}cleanSplit(ue){this.chart.series.forEach(function(ge){let ye=ge&&ge.tt;ye&&(!ye.isActive||ue?ge.tt=ye.destroy():ye.isActive=!1)})}defaultFormatter(ue){let ge,ye=this.points||ve(this);return(ge=(ge=[ue.tooltipFooterHeaderFormatter(ye[0])]).concat(ue.bodyFormatter(ye))).push(ue.tooltipFooterHeaderFormatter(ye[0],!0)),ge}destroy(){this.label&&(this.label=this.label.destroy()),this.split&&(this.cleanSplit(!0),this.tt&&(this.tt=this.tt.destroy())),this.renderer&&(this.renderer=this.renderer.destroy(),ee(this.container)),g.clearTimeout(this.hideTimer)}getAnchor(ue,ge){let ye,{chart:Ae,pointer:Re}=this,We=Ae.inverted,Pe=Ae.plotTop,Ue=Ae.plotLeft;if((ue=ve(ue))[0].series&&ue[0].series.yAxis&&!ue[0].series.yAxis.options.reversedStacks&&(ue=ue.slice().reverse()),this.followPointer&&ge)ge.chartX===void 0&&(ge=Re.normalize(ge)),ye=[ge.chartX-Ue,ge.chartY-Pe];else if(ue[0].tooltipPos)ye=ue[0].tooltipPos;else{let Oe=0,Be=0;ue.forEach(function(Ye){let Se=Ye.pos(!0);Se&&(Oe+=Se[0],Be+=Se[1])}),Oe/=ue.length,Be/=ue.length,this.shared&&ue.length>1&&ge&&(We?Oe=ge.chartX:Be=ge.chartY),ye=[Oe-Ue,Be-Pe]}return ye.map(Math.round)}getClassName(ue,ge,ye){let Ae=this.options,Re=ue.series,We=Re.options;return[Ae.className,"highcharts-label",ye&&"highcharts-tooltip-header",ge?"highcharts-tooltip-box":"highcharts-tooltip",!ye&&"highcharts-color-"+he(ue.colorIndex,Re.colorIndex),We&&We.className].filter(xe).join(" ")}getLabel(){let ue=this,ge=this.chart.styledMode,ye=this.options,Ae=this.split&&this.allowShared,Re=this.container,We=this.chart.renderer;if(this.label){let Pe=!this.label.hasClass("highcharts-label");(!Ae&&Pe||Ae&&!Pe)&&this.destroy()}if(!this.label){if(this.outside){let Pe=this.chart.options.chart.style,Ue=u.getRendererType();this.container=Re=l.doc.createElement("div"),Re.className="highcharts-tooltip-container",N(Re,{position:"absolute",top:"1px",pointerEvents:"none",zIndex:Math.max(this.options.style.zIndex||0,(Pe&&Pe.zIndex||0)+3)}),this.renderer=We=new Ue(Re,0,0,Pe,void 0,void 0,We.styledMode)}if(Ae?this.label=We.g("tooltip"):(this.label=We.label("",0,0,ye.shape,void 0,void 0,ye.useHTML,void 0,"tooltip").attr({padding:ye.padding,r:ye.borderRadius}),ge||this.label.attr({fill:ye.backgroundColor,"stroke-width":ye.borderWidth||0}).css(ye.style).css({pointerEvents:ye.style.pointerEvents||(this.shouldStickOnContact()?"auto":"none")})),ue.outside){let Pe=this.label;[Pe.xSetter,Pe.ySetter].forEach((Ue,Oe)=>{Pe[Oe?"ySetter":"xSetter"]=Be=>{Ue.call(Pe,ue.distance),Pe[Oe?"y":"x"]=Be,Re&&(Re.style[Oe?"top":"left"]=`${Be}px`)}})}this.label.attr({zIndex:8}).shadow(ye.shadow).add()}return Re&&!Re.parentElement&&l.doc.body.appendChild(Re),this.label}getPlayingField(){let{body:ue,documentElement:ge}=k,{chart:ye,distance:Ae,outside:Re}=this;return{width:Re?Math.max(ue.scrollWidth,ge.scrollWidth,ue.offsetWidth,ge.offsetWidth,ge.clientWidth)-2*Ae:ye.chartWidth,height:Re?Math.max(ue.scrollHeight,ge.scrollHeight,ue.offsetHeight,ge.offsetHeight,ge.clientHeight):ye.chartHeight}}getPosition(ue,ge,ye){let{distance:Ae,chart:Re,outside:We,pointer:Pe}=this,{inverted:Ue,plotLeft:Oe,plotTop:Be,polar:Ye}=Re,{plotX:Se=0,plotY:Te=0}=ye,$e={},Ve=Ue&&ye.h||0,{height:oe,width:te}=this.getPlayingField(),se=Pe.getChartPosition(),me=Ce=>Ce*se.scaleX,Ee=Ce=>Ce*se.scaleY,Le=Ce=>{let ce=Ce==="x";return[Ce,ce?te:oe,ce?ue:ge].concat(We?[ce?me(ue):Ee(ge),ce?se.left-Ae+me(Se+Oe):se.top-Ae+Ee(Te+Be),0,ce?te:oe]:[ce?ue:ge,ce?Se+Oe:Te+Be,ce?Oe:Be,ce?Oe+Re.plotWidth:Be+Re.plotHeight])},He=Le("y"),ze=Le("x"),Qe,rt=!!ye.negative;!Ye&&Re.hoverSeries?.yAxis?.reversed&&(rt=!rt);let Ke=!this.followPointer&&he(ye.ttBelow,!Ye&&!Ue===rt),Ie=function(Ce,ce,de,De,qe,nt,lt){let pt=We?Ce==="y"?Ee(Ae):me(Ae):Ae,bt=(de-De)/2,St=Dece?Nt:Nt+Ve)}},Fe=function(Ce,ce,de,De,qe){if(qece-Ae)return!1;qece-De/2?$e[Ce]=ce-De-2:$e[Ce]=qe-de/2},je=function(Ce){[He,ze]=[ze,He],Qe=Ce},Ze=()=>{Ie.apply(0,He)!==!1?Fe.apply(0,ze)!==!1||Qe||(je(!0),Ze()):Qe?$e.x=$e.y=0:(je(!0),Ze())};return(Ue&&!Ye||this.len>1)&&je(),Ze(),$e}hide(ue){let ge=this;g.clearTimeout(this.hideTimer),ue=he(ue,this.options.hideDelay),this.isHidden||(this.hideTimer=ae(function(){let ye=ge.getLabel();ge.getLabel().animate({opacity:0},{duration:ue&&150,complete:()=>{ye.hide(),ge.container&&ge.container.remove()}}),ge.isHidden=!0},ue))}init(ue,ge){this.chart=ue,this.options=ge,this.crosshairs=[],this.isHidden=!0,this.split=ge.split&&!ue.inverted&&!ue.polar,this.shared=ge.shared||this.split,this.outside=he(ge.outside,!!(ue.scrollablePixelsX||ue.scrollablePixelsY))}shouldStickOnContact(ue){return!!(!this.followPointer&&this.options.stickOnContact&&(!ue||this.pointer.inClass(ue.target,"highcharts-tooltip")))}move(ue,ge,ye,Ae){let Re=this,We=x(!Re.isHidden&&Re.options.animation),Pe=Re.followPointer||(Re.len||0)>1,Ue={x:ue,y:ge};Pe||(Ue.anchorX=ye,Ue.anchorY=Ae),We.step=()=>Re.drawTracker(),Re.getLabel().animate(Ue,We)}refresh(ue,ge){let{chart:ye,options:Ae,pointer:Re,shared:We}=this,Pe=ve(ue),Ue=Pe[0],Oe=[],Be=Ae.format,Ye=Ae.formatter||this.defaultFormatter,Se=ye.styledMode,Te={};if(!Ae.enabled||!Ue.series)return;g.clearTimeout(this.hideTimer),this.allowShared=!(!le(ue)&&ue.series&&ue.series.noSharedTooltip),this.followPointer=!this.split&&Ue.series.tooltipOptions.followPointer;let $e=this.getAnchor(ue,ge),Ve=$e[0],oe=$e[1];We&&this.allowShared?(Re.applyInactiveState(Pe),Pe.forEach(function(me){me.setState("hover"),Oe.push(me.getLabelConfig())}),(Te=Ue.getLabelConfig()).points=Oe):Te=Ue.getLabelConfig(),this.len=Oe.length;let te=xe(Be)?S(Be,Te,ye):Ye.call(Te,this),se=Ue.series;if(this.distance=he(se.tooltipOptions.distance,16),te===!1)this.hide();else{if(this.split&&this.allowShared)this.renderSplit(te,Pe);else{let me=Ve,Ee=oe;if(ge&&Re.isDirectTouch&&(me=ge.chartX-ye.plotLeft,Ee=ge.chartY-ye.plotTop),ye.polar||se.options.clip===!1||Pe.some(Le=>Re.isDirectTouch||Le.series.shouldShowTooltip(me,Ee))){let Le=this.getLabel();(!Ae.style.width||Se)&&Le.css({width:(this.outside?this.getPlayingField():ye.spacingBox).width+"px"}),Le.attr({text:te&&te.join?te.join(""):te}),Le.addClass(this.getClassName(Ue),!0),Se||Le.attr({stroke:Ae.borderColor||Ue.color||se.color||"#666666"}),this.updatePosition({plotX:Ve,plotY:oe,negative:Ue.negative,ttBelow:Ue.ttBelow,h:$e[2]||0})}else{this.hide();return}}this.isHidden&&this.label&&this.label.attr({opacity:1}).show(),this.isHidden=!1}B(this,"refresh")}renderSplit(ue,ge){let ye=this,{chart:Ae,chart:{chartWidth:Re,chartHeight:We,plotHeight:Pe,plotLeft:Ue,plotTop:Oe,scrollablePixelsY:Be=0,scrollablePixelsX:Ye,styledMode:Se},distance:Te,options:$e,options:{positioner:Ve},pointer:oe}=ye,{scrollLeft:te=0,scrollTop:se=0}=Ae.scrollablePlotArea?.scrollingContainer||{},me=ye.outside&&typeof Ye!="number"?k.documentElement.getBoundingClientRect():{left:te,right:te+Re,top:se,bottom:se+We},Ee=ye.getLabel(),Le=this.renderer||Ae.renderer,He=!!(Ae.xAxis[0]&&Ae.xAxis[0].opposite),{left:ze,top:Qe}=oe.getChartPosition(),rt=Oe+se,Ke=0,Ie=Pe-Be;function Fe(De,qe,nt,lt,pt=!0){let bt,St;return nt?(bt=He?0:Ie,St=O(De-lt/2,me.left,me.right-lt-(ye.outside?ze:0))):(bt=qe-rt,St=O(St=pt?De-lt-Te:De+Te,pt?St:me.left,me.right)),{x:St,y:bt}}xe(ue)&&(ue=[!1,ue]);let je=ue.slice(0,ge.length+1).reduce(function(De,qe,nt){if(qe!==!1&&qe!==""){let lt=ge[nt-1]||{isHeader:!0,plotX:ge[0].plotX,plotY:Pe,series:{}},pt=lt.isHeader,bt=pt?ye:lt.series,St=bt.tt=function(qt,Zt,mr){let nr=qt,{isHeader:ur,series:Mr}=Zt;if(!nr){let Pr={padding:$e.padding,r:$e.borderRadius};Se||(Pr.fill=$e.backgroundColor,Pr["stroke-width"]=$e.borderWidth??1),nr=Le.label("",0,0,$e[ur?"headerShape":"shape"],void 0,void 0,$e.useHTML).addClass(ye.getClassName(Zt,!0,ur)).attr(Pr).add(Ee)}return nr.isActive=!0,nr.attr({text:mr}),Se||nr.css($e.style).attr({stroke:$e.borderColor||Zt.color||Mr.color||"#333333"}),nr}(bt.tt,lt,qe.toString()),Et=St.getBBox(),vt=Et.width+St.strokeWidth();pt&&(Ke=Et.height,Ie+=Ke,He&&(rt-=Ke));let{anchorX:Nt,anchorY:Ft}=function(qt){let Zt,mr,{isHeader:nr,plotX:ur=0,plotY:Mr=0,series:Pr}=qt;if(nr)Zt=Math.max(Ue+ur,Ue),mr=Oe+Pe/2;else{let{xAxis:fr,yAxis:hr}=Pr;Zt=fr.pos+O(ur,-Te,fr.len+Te),Pr.shouldShowTooltip(0,hr.pos-Oe+Mr,{ignoreX:!0})&&(mr=hr.pos+Mr)}return{anchorX:Zt=O(Zt,me.left-Te,me.right+Te),anchorY:mr}}(lt);if(typeof Ft=="number"){let qt=Et.height+1,Zt=Ve?Ve.call(ye,vt,qt,lt):Fe(Nt,Ft,pt,vt);De.push({align:Ve?0:void 0,anchorX:Nt,anchorY:Ft,boxWidth:vt,point:lt,rank:he(Zt.rank,pt?1:0),size:qt,target:Zt.y,tt:St,x:Zt.x})}else St.isActive=!1}return De},[]);!Ve&&je.some(De=>{let{outside:qe}=ye,nt=(qe?ze:0)+De.anchorX;return ntnt})&&(je=je.map(De=>{let{x:qe,y:nt}=Fe(De.anchorX,De.anchorY,De.point.isHeader,De.boxWidth,!1);return ne(De,{target:nt,x:qe})})),ye.cleanSplit(),D(je,Ie);let Ze={left:ze,right:ze};je.forEach(function(De){let{x:qe,boxWidth:nt,isHeader:lt}=De;!lt&&(ye.outside&&ze+qeZe.right&&(Ze.right=ze+qe))}),je.forEach(function(De){let{x:qe,anchorX:nt,anchorY:lt,pos:pt,point:{isHeader:bt}}=De,St={visibility:pt===void 0?"hidden":"inherit",x:qe,y:(pt||0)+rt,anchorX:nt,anchorY:lt};if(ye.outside&&qe0&&(bt||(St.x=qe+Et,St.anchorX=nt+Et),bt&&(St.x=(Ze.right-Ze.left)/2,St.anchorX=nt+Et))}De.tt.attr(St)});let{container:Ce,outside:ce,renderer:de}=ye;if(ce&&Ce&&de){let{width:De,height:qe,x:nt,y:lt}=Ee.getBBox();de.setSize(De+nt,qe+lt,!1),Ce.style.left=Ze.left+"px",Ce.style.top=Qe+"px"}T&&Ee.attr({opacity:Ee.opacity===1?.999:1})}drawTracker(){if(!this.shouldStickOnContact()){this.tracker&&(this.tracker=this.tracker.destroy());return}let ue=this.chart,ge=this.label,ye=this.shared?ue.hoverPoints:ue.hoverPoint;if(!ge||!ye)return;let Ae={x:0,y:0,width:0,height:0},Re=this.getAnchor(ye),We=ge.getBBox();Re[0]+=ue.plotLeft-(ge.translateX||0),Re[1]+=ue.plotTop-(ge.translateY||0),Ae.x=Math.min(0,Re[0]),Ae.y=Math.min(0,Re[1]),Ae.width=Re[0]<0?Math.max(Math.abs(Re[0]),We.width-Re[0]):Math.max(Math.abs(Re[0]),We.width),Ae.height=Re[1]<0?Math.max(Math.abs(Re[1]),We.height-Math.abs(Re[1])):Math.max(Math.abs(Re[1]),We.height),this.tracker?this.tracker.attr(Ae):(this.tracker=ge.renderer.rect(Ae).addClass("highcharts-tracker").add(ge),ue.styledMode||this.tracker.attr({fill:"rgba(0,0,0,0)"}))}styledModeFormat(ue){return ue.replace('style="font-size: 0.8em"','class="highcharts-header"').replace(/style="color:{(point|series)\.color}"/g,'class="highcharts-color-{$1.colorIndex} {series.options.className} {point.options.className}"')}tooltipFooterHeaderFormatter(ue,ge){let ye=ue.series,Ae=ye.tooltipOptions,Re=ye.xAxis,We=Re&&Re.dateTime,Pe={isFooter:ge,labelConfig:ue},Ue=Ae.xDateFormat,Oe=Ae[ge?"footerFormat":"headerFormat"];return B(this,"headerFormatter",Pe,function(Be){We&&!Ue&&fe(ue.key)&&(Ue=We.getXDateFormat(ue.key,Ae.dateTimeLabelFormats)),We&&Ue&&(ue.point&&ue.point.tooltipDateKeys||["key"]).forEach(function(Ye){Oe=Oe.replace("{point."+Ye+"}","{point."+Ye+":"+Ue+"}")}),ye.chart.styledMode&&(Oe=this.styledModeFormat(Oe)),Be.text=S(Oe,{point:ue,series:ye},this.chart)}),Pe.text}update(ue){this.destroy(),this.init(this.chart,we(!0,this.options,ue))}updatePosition(ue){let{chart:ge,container:ye,distance:Ae,options:Re,pointer:We,renderer:Pe}=this,{height:Ue=0,width:Oe=0}=this.getLabel(),{left:Be,top:Ye,scaleX:Se,scaleY:Te}=We.getChartPosition(),$e=(Re.positioner||this.getPosition).call(this,Oe,Ue,ue),Ve=(ue.plotX||0)+ge.plotLeft,oe=(ue.plotY||0)+ge.plotTop,te;Pe&&ye&&(Re.positioner&&($e.x+=Be-Ae,$e.y+=Ye-Ae),te=(Re.borderWidth||0)+2*Ae+2,Pe.setSize(Oe+te,Ue+te,!1),(Se!==1||Te!==1)&&(N(ye,{transform:`scale(${Se}, ${Te})`}),Ve*=Se,oe*=Te),Ve+=Be-$e.x,oe+=Ye-$e.y),this.move(Math.round($e.x),Math.round($e.y||0),Ve,oe)}}return(b=ie||(ie={})).compose=function(pe){_e($,"Core.Tooltip")&&I(pe,"afterInit",function(){let ue=this.chart;ue.options.tooltip&&(ue.tooltip=new b(ue,ue.options.tooltip,this))})},ie}),n(r,"Core/Series/Point.js",[r["Core/Renderer/HTML/AST.js"],r["Core/Animation/AnimationUtilities.js"],r["Core/Defaults.js"],r["Core/Templating.js"],r["Core/Utilities.js"]],function(o,a,l,c,u){let{animObject:g}=a,{defaultOptions:b}=l,{format:x}=c,{addEvent:S,crisp:$,erase:k,extend:T,fireEvent:D,getNestedProperty:I,isArray:O,isFunction:N,isNumber:ee,isObject:ne,merge:B,pick:le,syncTimeout:fe,removeEvent:xe,uniqueKey:we}=u;class he{animateBeforeDestroy(){let ve=this,ae={x:ve.startXPos,opacity:0},ie=ve.getGraphicalProps();ie.singular.forEach(function(pe){ve[pe]=ve[pe].animate(pe==="dataLabel"?{x:ve[pe].startXPos,y:ve[pe].startYPos,opacity:0}:ae)}),ie.plural.forEach(function(pe){ve[pe].forEach(function(ue){ue.element&&ue.animate(T({x:ve.startXPos},ue.startYPos?{x:ue.startXPos,y:ue.startYPos}:{}))})})}applyOptions(ve,ae){let ie=this.series,pe=ie.options.pointValKey||ie.pointValKey;return T(this,ve=he.prototype.optionsToObject.call(this,ve)),this.options=this.options?T(this.options,ve):ve,ve.group&&delete this.group,ve.dataLabels&&delete this.dataLabels,pe&&(this.y=he.prototype.getNestedProperty.call(this,pe)),this.selected&&(this.state="select"),"name"in this&&ae===void 0&&ie.xAxis&&ie.xAxis.hasNames&&(this.x=ie.xAxis.nameToX(this)),this.x===void 0&&ie?ae===void 0?this.x=ie.autoIncrement():this.x=ae:ee(ve.x)&&ie.options.relativeXValue&&(this.x=ie.autoIncrement(ve.x)),this.isNull=this.isValid&&!this.isValid(),this.formatPrefix=this.isNull?"null":"point",this}destroy(){if(!this.destroyed){let ve=this,ae=ve.series,ie=ae.chart,pe=ae.options.dataSorting,ue=ie.hoverPoints,ge=g(ve.series.chart.renderer.globalAnimation),ye=()=>{for(let Ae in(ve.graphic||ve.graphics||ve.dataLabel||ve.dataLabels)&&(xe(ve),ve.destroyElements()),ve)delete ve[Ae]};ve.legendItem&&ie.legend.destroyItem(ve),ue&&(ve.setState(),k(ue,ve),ue.length||(ie.hoverPoints=null)),ve===ie.hoverPoint&&ve.onMouseOut(),pe&&pe.enabled?(this.animateBeforeDestroy(),fe(ye,ge.duration)):ye(),ie.pointCount--}this.destroyed=!0}destroyElements(ve){let ae=this,ie=ae.getGraphicalProps(ve);ie.singular.forEach(function(pe){ae[pe]=ae[pe].destroy()}),ie.plural.forEach(function(pe){ae[pe].forEach(function(ue){ue&&ue.element&&ue.destroy()}),delete ae[pe]})}firePointEvent(ve,ae,ie){let pe=this,ue=this.series.options;pe.manageEvent(ve),ve==="click"&&ue.allowPointSelect&&(ie=function(ge){!pe.destroyed&&pe.select&&pe.select(null,ge.ctrlKey||ge.metaKey||ge.shiftKey)}),D(pe,ve,ae,ie)}getClassName(){return"highcharts-point"+(this.selected?" highcharts-point-select":"")+(this.negative?" highcharts-negative":"")+(this.isNull?" highcharts-null-point":"")+(this.colorIndex!==void 0?" highcharts-color-"+this.colorIndex:"")+(this.options.className?" "+this.options.className:"")+(this.zone&&this.zone.className?" "+this.zone.className.replace("highcharts-negative",""):"")}getGraphicalProps(ve){let ae,ie,pe=this,ue=[],ge={singular:[],plural:[]};for((ve=ve||{graphic:1,dataLabel:1}).graphic&&ue.push("graphic","connector"),ve.dataLabel&&ue.push("dataLabel","dataLabelPath","dataLabelUpper"),ie=ue.length;ie--;)pe[ae=ue[ie]]&&ge.singular.push(ae);return["graphic","dataLabel"].forEach(function(ye){let Ae=ye+"s";ve[ye]&&pe[Ae]&&ge.plural.push(Ae)}),ge}getLabelConfig(){return{x:this.category,y:this.y,color:this.color,colorIndex:this.colorIndex,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}}getNestedProperty(ve){return ve?ve.indexOf("custom.")===0?I(ve,this.options):this[ve]:void 0}getZone(){let ve=this.series,ae=ve.zones,ie=ve.zoneAxis||"y",pe,ue=0;for(pe=ae[0];this[ie]>=pe.value;)pe=ae[++ue];return this.nonZonedColor||(this.nonZonedColor=this.color),pe&&pe.color&&!this.options.color?this.color=pe.color:this.color=this.nonZonedColor,pe}hasNewShapeType(){return(this.graphic&&(this.graphic.symbolName||this.graphic.element.nodeName))!==this.shapeType}constructor(ve,ae,ie){this.formatPrefix="point",this.visible=!0,this.series=ve,this.applyOptions(ae,ie),this.id??(this.id=we()),this.resolveColor(),ve.chart.pointCount++,D(this,"afterInit")}isValid(){return(ee(this.x)||this.x instanceof Date)&&ee(this.y)}optionsToObject(ve){let ae=this.series,ie=ae.options.keys,pe=ie||ae.pointArrayMap||["y"],ue=pe.length,ge={},ye,Ae=0,Re=0;if(ee(ve)||ve===null)ge[pe[0]]=ve;else if(O(ve))for(!ie&&ve.length>ue&&((ye=typeof ve[0])=="string"?ge.name=ve[0]:ye==="number"&&(ge.x=ve[0]),Ae++);Re0?he.prototype.setNestedProperty(ge,ve[Ae],pe[Re]):ge[pe[Re]]=ve[Ae]),Ae++,Re++;else typeof ve=="object"&&(ge=ve,ve.dataLabels&&(ae.hasDataLabels=()=>!0),ve.marker&&(ae._hasPointMarkers=!0));return ge}pos(ve,ae=this.plotY){if(!this.destroyed){let{plotX:ie,series:pe}=this,{chart:ue,xAxis:ge,yAxis:ye}=pe,Ae=0,Re=0;if(ee(ie)&&ee(ae))return ve&&(Ae=ge?ge.pos:ue.plotLeft,Re=ye?ye.pos:ue.plotTop),ue.inverted&&ge&&ye?[ye.len-ae+Re,ge.len-ie+Ae]:[ie+Ae,ae+Re]}}resolveColor(){let ve=this.series,ae=ve.chart.options.chart,ie=ve.chart.styledMode,pe,ue,ge=ae.colorCount,ye;delete this.nonZonedColor,ve.options.colorByPoint?(ie||(pe=(ue=ve.options.colors||ve.chart.options.colors)[ve.colorCounter],ge=ue.length),ye=ve.colorCounter,ve.colorCounter++,ve.colorCounter===ge&&(ve.colorCounter=0)):(ie||(pe=ve.color),ye=ve.colorIndex),this.colorIndex=le(this.options.colorIndex,ye),this.color=le(this.options.color,pe)}setNestedProperty(ve,ae,ie){return ie.split(".").reduce(function(pe,ue,ge,ye){let Ae=ye.length-1===ge;return pe[ue]=Ae?ae:ne(pe[ue],!0)?pe[ue]:{},pe[ue]},ve),ve}shouldDraw(){return!this.isNull}tooltipFormatter(ve){let ae=this.series,ie=ae.tooltipOptions,pe=le(ie.valueDecimals,""),ue=ie.valuePrefix||"",ge=ie.valueSuffix||"";return ae.chart.styledMode&&(ve=ae.chart.tooltip.styledModeFormat(ve)),(ae.pointArrayMap||["y"]).forEach(function(ye){ye="{point."+ye,(ue||ge)&&(ve=ve.replace(RegExp(ye+"}","g"),ue+ye+"}"+ge)),ve=ve.replace(RegExp(ye+"}","g"),ye+":,."+pe+"f}")}),x(ve,{point:this,series:this.series},ae.chart)}update(ve,ae,ie,pe){let ue,ge=this,ye=ge.series,Ae=ge.graphic,Re=ye.chart,We=ye.options;function Pe(){ge.applyOptions(ve);let Ue=Ae&&ge.hasMockGraphic,Oe=ge.y===null?!Ue:Ue;Ae&&Oe&&(ge.graphic=Ae.destroy(),delete ge.hasMockGraphic),ne(ve,!0)&&(Ae&&Ae.element&&ve&&ve.marker&&ve.marker.symbol!==void 0&&(ge.graphic=Ae.destroy()),ve?.dataLabels&&ge.dataLabel&&(ge.dataLabel=ge.dataLabel.destroy())),ue=ge.index,ye.updateParallelArrays(ge,ue),We.data[ue]=ne(We.data[ue],!0)||ne(ve,!0)?ge.options:le(ve,We.data[ue]),ye.isDirty=ye.isDirtyData=!0,!ye.fixedBox&&ye.hasCartesianSeries&&(Re.isDirtyBox=!0),We.legendType==="point"&&(Re.isDirtyLegend=!0),ae&&Re.redraw(ie)}ae=le(ae,!0),pe===!1?Pe():ge.firePointEvent("update",{options:ve},Pe)}remove(ve,ae){this.series.removePoint(this.series.data.indexOf(this),ve,ae)}select(ve,ae){let ie=this,pe=ie.series,ue=pe.chart;ve=le(ve,!ie.selected),this.selectedStaging=ve,ie.firePointEvent(ve?"select":"unselect",{accumulate:ae},function(){ie.selected=ie.options.selected=ve,pe.options.data[pe.data.indexOf(ie)]=ie.options,ie.setState(ve&&"select"),ae||ue.getSelectedPoints().forEach(function(ge){let ye=ge.series;ge.selected&&ge!==ie&&(ge.selected=ge.options.selected=!1,ye.options.data[ye.data.indexOf(ge)]=ge.options,ge.setState(ue.hoverPoints&&ye.options.inactiveOtherPoints?"inactive":""),ge.firePointEvent("unselect"))})}),delete this.selectedStaging}onMouseOver(ve){let{inverted:ae,pointer:ie}=this.series.chart;ie&&(ve=ve?ie.normalize(ve):ie.getChartCoordinatesFromPoint(this,ae),ie.runPointActions(ve,this))}onMouseOut(){let ve=this.series.chart;this.firePointEvent("mouseOut"),this.series.options.inactiveOtherPoints||(ve.hoverPoints||[]).forEach(function(ae){ae.setState()}),ve.hoverPoints=ve.hoverPoint=null}manageEvent(ve){let ae=B(this.series.options.point,this.options),ie=ae.events?.[ve];N(ie)&&(!this.hcEvents?.[ve]||this.hcEvents?.[ve]?.map(pe=>pe.fn).indexOf(ie)===-1)?(S(this,ve,ie),this.hasImportedEvents=!0):this.hasImportedEvents&&!ie&&this.hcEvents?.[ve]&&(xe(this,ve),delete this.hcEvents[ve],Object.keys(this.hcEvents)||(this.hasImportedEvents=!1))}setState(ve,ae){let ie=this.series,pe=this.state,ue=ie.options.states[ve||"normal"]||{},ge=b.plotOptions[ie.type].marker&&ie.options.marker,ye=ge&&ge.enabled===!1,Ae=ge&&ge.states&&ge.states[ve||"normal"]||{},Re=Ae.enabled===!1,We=this.marker||{},Pe=ie.chart,Ue=ge&&ie.markerAttribs,Oe=ie.halo,Be,Ye,Se,Te=ie.stateMarkerGraphic,$e;if((ve=ve||"")===this.state&&!ae||this.selected&&ve!=="select"||ue.enabled===!1||ve&&(Re||ye&&Ae.enabled===!1)||ve&&We.states&&We.states[ve]&&We.states[ve].enabled===!1)return;if(this.state=ve,Ue&&(Be=ie.markerAttribs(this,ve)),this.graphic&&!this.hasMockGraphic){if(pe&&this.graphic.removeClass("highcharts-point-"+pe),ve&&this.graphic.addClass("highcharts-point-"+ve),!Pe.styledMode){Ye=ie.pointAttribs(this,ve),Se=le(Pe.options.chart.animation,ue.animation);let se=Ye.opacity;ie.options.inactiveOtherPoints&&ee(se)&&(this.dataLabels||[]).forEach(function(me){me&&!me.hasClass("highcharts-data-label-hidden")&&(me.animate({opacity:se},Se),me.connector&&me.connector.animate({opacity:se},Se))}),this.graphic.animate(Ye,Se)}Be&&this.graphic.animate(Be,le(Pe.options.chart.animation,Ae.animation,ge.animation)),Te&&Te.hide()}else ve&&Ae&&($e=We.symbol||ie.symbol,Te&&Te.currentSymbol!==$e&&(Te=Te.destroy()),Be&&(Te?Te[ae?"animate":"attr"]({x:Be.x,y:Be.y}):$e&&(ie.stateMarkerGraphic=Te=Pe.renderer.symbol($e,Be.x,Be.y,Be.width,Be.height).add(ie.markerGroup),Te.currentSymbol=$e)),!Pe.styledMode&&Te&&this.state!=="inactive"&&Te.attr(ie.pointAttribs(this,ve))),Te&&(Te[ve&&this.isInside?"show":"hide"](),Te.element.point=this,Te.addClass(this.getClassName(),!0));let Ve=ue.halo,oe=this.graphic||Te,te=oe&&oe.visibility||"inherit";Ve&&Ve.size&&oe&&te!=="hidden"&&!this.isCluster?(Oe||(ie.halo=Oe=Pe.renderer.path().add(oe.parentGroup)),Oe.show()[ae?"animate":"attr"]({d:this.haloPath(Ve.size)}),Oe.attr({class:"highcharts-halo highcharts-color-"+le(this.colorIndex,ie.colorIndex)+(this.className?" "+this.className:""),visibility:te,zIndex:-1}),Oe.point=this,Pe.styledMode||Oe.attr(T({fill:this.color||ie.color,"fill-opacity":Ve.opacity},o.filterUserAttributes(Ve.attributes||{})))):Oe?.point?.haloPath&&!Oe.point.destroyed&&Oe.animate({d:Oe.point.haloPath(0)},null,Oe.hide),D(this,"afterSetState",{state:ve})}haloPath(ve){let ae=this.pos();return ae?this.series.chart.renderer.symbols.circle($(ae[0],1)-ve,ae[1]-ve,2*ve,2*ve):[]}}return he}),n(r,"Core/Pointer.js",[r["Core/Color/Color.js"],r["Core/Globals.js"],r["Core/Utilities.js"]],function(o,a,l){var c;let{parse:u}=o,{charts:g,composed:b,isTouchDevice:x}=a,{addEvent:S,attr:$,css:k,extend:T,find:D,fireEvent:I,isNumber:O,isObject:N,objectEach:ee,offset:ne,pick:B,pushUnique:le,splat:fe}=l;class xe{applyInactiveState(he){let _e=[],ve;(he||[]).forEach(function(ae){ve=ae.series,_e.push(ve),ve.linkedParent&&_e.push(ve.linkedParent),ve.linkedSeries&&(_e=_e.concat(ve.linkedSeries)),ve.navigatorSeries&&_e.push(ve.navigatorSeries)}),this.chart.series.forEach(function(ae){_e.indexOf(ae)===-1?ae.setState("inactive",!0):ae.options.inactiveOtherPoints&&ae.setAllPointsToState("inactive")})}destroy(){let he=this;this.eventsToUnbind.forEach(_e=>_e()),this.eventsToUnbind=[],!a.chartCount&&(xe.unbindDocumentMouseUp&&(xe.unbindDocumentMouseUp=xe.unbindDocumentMouseUp()),xe.unbindDocumentTouchEnd&&(xe.unbindDocumentTouchEnd=xe.unbindDocumentTouchEnd())),clearInterval(he.tooltipTimeout),ee(he,function(_e,ve){he[ve]=void 0})}getSelectionMarkerAttrs(he,_e){let ve={args:{chartX:he,chartY:_e},attrs:{},shapeType:"rect"};return I(this,"getSelectionMarkerAttrs",ve,ae=>{let ie,{chart:pe,zoomHor:ue,zoomVert:ge}=this,{mouseDownX:ye=0,mouseDownY:Ae=0}=pe,Re=ae.attrs;Re.x=pe.plotLeft,Re.y=pe.plotTop,Re.width=ue?1:pe.plotWidth,Re.height=ge?1:pe.plotHeight,ue&&(ie=he-ye,Re.width=Math.max(1,Math.abs(ie)),Re.x=(ie>0?0:ie)+ye),ge&&(ie=_e-Ae,Re.height=Math.max(1,Math.abs(ie)),Re.y=(ie>0?0:ie)+Ae)}),ve}drag(he){let{chart:_e}=this,{mouseDownX:ve=0,mouseDownY:ae=0}=_e,{panning:ie,panKey:pe,selectionMarkerFill:ue}=_e.options.chart,ge=_e.plotLeft,ye=_e.plotTop,Ae=_e.plotWidth,Re=_e.plotHeight,We=N(ie)?ie.enabled:ie,Pe=pe&&he[`${pe}Key`],Ue=he.chartX,Oe=he.chartY,Be,Ye=this.selectionMarker;if((!Ye||!Ye.touch)&&(Uege+Ae&&(Ue=ge+Ae),Oeye+Re&&(Oe=ye+Re),this.hasDragged=Math.sqrt(Math.pow(ve-Ue,2)+Math.pow(ae-Oe,2)),this.hasDragged>10)){Be=_e.isInsidePlot(ve-ge,ae-ye,{visiblePlotOnly:!0});let{shapeType:Se,attrs:Te}=this.getSelectionMarkerAttrs(Ue,Oe);(_e.hasCartesianSeries||_e.mapView)&&this.hasZoom&&Be&&!Pe&&!Ye&&(this.selectionMarker=Ye=_e.renderer[Se](),Ye.attr({class:"highcharts-selection-marker",zIndex:7}).add(),_e.styledMode||Ye.attr({fill:ue||u("#334eff").setOpacity(.25).get()})),Ye&&Ye.attr(Te),Be&&!Ye&&We&&_e.pan(he,ie)}}dragStart(he){let _e=this.chart;_e.mouseIsDown=he.type,_e.cancelClick=!1,_e.mouseDownX=he.chartX,_e.mouseDownY=he.chartY}getSelectionBox(he){let _e={args:{marker:he},result:he.getBBox()};return I(this,"getSelectionBox",_e),_e.result}drop(he){let _e,{chart:ve,selectionMarker:ae}=this;for(let ie of ve.axes)ie.isPanning&&(ie.isPanning=!1,(ie.options.startOnTick||ie.options.endOnTick||ie.series.some(pe=>pe.boosted))&&(ie.forceRedraw=!0,ie.setExtremes(ie.userMin,ie.userMax,!1),_e=!0));if(_e&&ve.redraw(),ae&&he){if(this.hasDragged){let ie=this.getSelectionBox(ae);ve.transform({axes:ve.axes.filter(pe=>pe.zoomEnabled&&(pe.coll==="xAxis"&&this.zoomX||pe.coll==="yAxis"&&this.zoomY)),selection:{originalEvent:he,xAxis:[],yAxis:[],...ie},from:ie})}O(ve.index)&&(this.selectionMarker=ae.destroy())}ve&&O(ve.index)&&(k(ve.container,{cursor:ve._cursor}),ve.cancelClick=this.hasDragged>10,ve.mouseIsDown=!1,this.hasDragged=0,this.pinchDown=[])}findNearestKDPoint(he,_e,ve){let ae;return he.forEach(function(ie){let pe=!(ie.noSharedTooltip&&_e)&&0>ie.options.findNearestPointBy.indexOf("y"),ue=ie.searchPoint(ve,pe);N(ue,!0)&&ue.series&&(!N(ae,!0)||function(ge,ye){let Ae=ge.distX-ye.distX,Re=ge.dist-ye.dist,We=ye.series.group?.zIndex-ge.series.group?.zIndex;return Ae!==0&&_e?Ae:Re!==0?Re:We!==0?We:ge.series.index>ye.series.index?-1:1}(ae,ue)>0)&&(ae=ue)}),ae}getChartCoordinatesFromPoint(he,_e){let{xAxis:ve,yAxis:ae}=he.series,ie=he.shapeArgs;if(ve&&ae){let pe=he.clientX??he.plotX??0,ue=he.plotY||0;return he.isNode&&ie&&O(ie.x)&&O(ie.y)&&(pe=ie.x,ue=ie.y),_e?{chartX:ae.len+ae.pos-ue,chartY:ve.len+ve.pos-pe}:{chartX:pe+ve.pos,chartY:ue+ae.pos}}if(ie&&ie.x&&ie.y)return{chartX:ie.x,chartY:ie.y}}getChartPosition(){if(this.chartPosition)return this.chartPosition;let{container:he}=this.chart,_e=ne(he);this.chartPosition={left:_e.left,top:_e.top,scaleX:1,scaleY:1};let{offsetHeight:ve,offsetWidth:ae}=he;return ae>2&&ve>2&&(this.chartPosition.scaleX=_e.width/ae,this.chartPosition.scaleY=_e.height/ve),this.chartPosition}getCoordinates(he){let _e={xAxis:[],yAxis:[]};for(let ve of this.chart.axes)_e[ve.isXAxis?"xAxis":"yAxis"].push({axis:ve,value:ve.toValue(he[ve.horiz?"chartX":"chartY"])});return _e}getHoverData(he,_e,ve,ae,ie,pe){let ue=[],ge=function(Pe){return Pe.visible&&!(!ie&&Pe.directTouch)&&B(Pe.options.enableMouseTracking,!0)},ye=_e,Ae,Re={chartX:pe?pe.chartX:void 0,chartY:pe?pe.chartY:void 0,shared:ie};I(this,"beforeGetHoverData",Re),Ae=ye&&!ye.stickyTracking?[ye]:ve.filter(Pe=>Pe.stickyTracking&&(Re.filter||ge)(Pe));let We=ae&&he||!pe?he:this.findNearestKDPoint(Ae,ie,pe);return ye=We&&We.series,We&&(ie&&!ye.noSharedTooltip?(Ae=ve.filter(function(Pe){return Re.filter?Re.filter(Pe):ge(Pe)&&!Pe.noSharedTooltip})).forEach(function(Pe){let Ue=D(Pe.points,function(Oe){return Oe.x===We.x&&!Oe.isNull});N(Ue)&&(Pe.boosted&&Pe.boost&&(Ue=Pe.boost.getPoint(Ue)),ue.push(Ue))}):ue.push(We)),I(this,"afterGetHoverData",Re={hoverPoint:We}),{hoverPoint:Re.hoverPoint,hoverSeries:ye,hoverPoints:ue}}getPointFromEvent(he){let _e=he.target,ve;for(;_e&&!ve;)ve=_e.point,_e=_e.parentNode;return ve}onTrackerMouseOut(he){let _e=this.chart,ve=he.relatedTarget,ae=_e.hoverSeries;this.isDirectTouch=!1,!ae||!ve||ae.stickyTracking||this.inClass(ve,"highcharts-tooltip")||this.inClass(ve,"highcharts-series-"+ae.index)&&this.inClass(ve,"highcharts-tracker")||ae.onMouseOut()}inClass(he,_e){let ve=he,ae;for(;ve;){if(ae=$(ve,"class")){if(ae.indexOf(_e)!==-1)return!0;if(ae.indexOf("highcharts-container")!==-1)return!1}ve=ve.parentElement}}constructor(he,_e){this.hasDragged=0,this.pointerCaptureEventsToUnbind=[],this.eventsToUnbind=[],this.options=_e,this.chart=he,this.runChartClick=!!_e.chart.events?.click,this.pinchDown=[],this.setDOMEvents(),I(this,"afterInit")}normalize(he,_e){let ve=he.touches,ae=ve?ve.length?ve.item(0):B(ve.changedTouches,he.changedTouches)[0]:he;_e||(_e=this.getChartPosition());let ie=ae.pageX-_e.left,pe=ae.pageY-_e.top;return T(he,{chartX:Math.round(ie/=_e.scaleX),chartY:Math.round(pe/=_e.scaleY)})}onContainerClick(he){let _e=this.chart,ve=_e.hoverPoint,ae=this.normalize(he),ie=_e.plotLeft,pe=_e.plotTop;!_e.cancelClick&&(ve&&this.inClass(ae.target,"highcharts-tracker")?(I(ve.series,"click",T(ae,{point:ve})),_e.hoverPoint&&ve.firePointEvent("click",ae)):(T(ae,this.getCoordinates(ae)),_e.isInsidePlot(ae.chartX-ie,ae.chartY-pe,{visiblePlotOnly:!0})&&I(_e,"click",ae)))}onContainerMouseDown(he){let _e=(1&(he.buttons||he.button))==1;he=this.normalize(he),a.isFirefox&&he.button!==0&&this.onContainerMouseMove(he),(he.button===void 0||_e)&&(this.zoomOption(he),_e&&he.preventDefault?.(),this.dragStart(he))}onContainerMouseLeave(he){let{pointer:_e}=g[B(xe.hoverChartIndex,-1)]||{};he=this.normalize(he),this.onContainerMouseMove(he),_e&&he.relatedTarget&&!this.inClass(he.relatedTarget,"highcharts-tooltip")&&(_e.reset(),_e.chartPosition=void 0)}onContainerMouseEnter(){delete this.chartPosition}onContainerMouseMove(he){let _e=this.chart,ve=_e.tooltip,ae=this.normalize(he);this.setHoverChartIndex(he),(_e.mouseIsDown==="mousedown"||this.touchSelect(ae))&&this.drag(ae),!_e.openMenu&&(this.inClass(ae.target,"highcharts-tracker")||_e.isInsidePlot(ae.chartX-_e.plotLeft,ae.chartY-_e.plotTop,{visiblePlotOnly:!0}))&&!(ve&&ve.shouldStickOnContact(ae))&&(this.inClass(ae.target,"highcharts-no-tooltip")?this.reset(!1,0):this.runPointActions(ae))}onDocumentTouchEnd(he){this.onDocumentMouseUp(he)}onContainerTouchMove(he){this.touchSelect(he)?this.onContainerMouseMove(he):this.touch(he)}onContainerTouchStart(he){this.touchSelect(he)?this.onContainerMouseDown(he):(this.zoomOption(he),this.touch(he,!0))}onDocumentMouseMove(he){let _e=this.chart,ve=_e.tooltip,ae=this.chartPosition,ie=this.normalize(he,ae);!ae||_e.isInsidePlot(ie.chartX-_e.plotLeft,ie.chartY-_e.plotTop,{visiblePlotOnly:!0})||ve&&ve.shouldStickOnContact(ie)||this.inClass(ie.target,"highcharts-tracker")||this.reset()}onDocumentMouseUp(he){g[B(xe.hoverChartIndex,-1)]?.pointer?.drop(he)}pinch(he){let _e=this,{chart:ve,hasZoom:ae,lastTouches:ie}=_e,pe=[].map.call(he.touches||[],Re=>_e.normalize(Re)),ue=pe.length,ge=ue===1&&(_e.inClass(he.target,"highcharts-tracker")&&ve.runTrackerClick||_e.runChartClick),ye=ve.tooltip,Ae=ue===1&&B(ye?.options.followTouchMove,!0);ue>1?_e.initiated=!0:Ae&&(_e.initiated=!1),ae&&_e.initiated&&!ge&&he.cancelable!==!1&&he.preventDefault(),he.type==="touchstart"?(_e.pinchDown=pe,_e.res=!0):Ae?this.runPointActions(_e.normalize(he)):ie&&(I(ve,"touchpan",{originalEvent:he,touches:pe},()=>{let Re=We=>{let Pe=We[0],Ue=We[1]||Pe;return{x:Pe.chartX,y:Pe.chartY,width:Ue.chartX-Pe.chartX,height:Ue.chartY-Pe.chartY}};ve.transform({axes:ve.axes.filter(We=>We.zoomEnabled&&(this.zoomHor&&We.horiz||this.zoomVert&&!We.horiz)),to:Re(pe),from:Re(ie),trigger:he.type})}),_e.res&&(_e.res=!1,this.reset(!1,0))),_e.lastTouches=pe}reset(he,_e){let ve=this.chart,ae=ve.hoverSeries,ie=ve.hoverPoint,pe=ve.hoverPoints,ue=ve.tooltip,ge=ue&&ue.shared?pe:ie;he&&ge&&fe(ge).forEach(function(ye){ye.series.isCartesian&&ye.plotX===void 0&&(he=!1)}),he?ue&&ge&&fe(ge).length&&(ue.refresh(ge),ue.shared&&pe?pe.forEach(function(ye){ye.setState(ye.state,!0),ye.series.isCartesian&&(ye.series.xAxis.crosshair&&ye.series.xAxis.drawCrosshair(null,ye),ye.series.yAxis.crosshair&&ye.series.yAxis.drawCrosshair(null,ye))}):ie&&(ie.setState(ie.state,!0),ve.axes.forEach(function(ye){ye.crosshair&&ie.series[ye.coll]===ye&&ye.drawCrosshair(null,ie)}))):(ie&&ie.onMouseOut(),pe&&pe.forEach(function(ye){ye.setState()}),ae&&ae.onMouseOut(),ue&&ue.hide(_e),this.unDocMouseMove&&(this.unDocMouseMove=this.unDocMouseMove()),ve.axes.forEach(function(ye){ye.hideCrosshair()}),ve.hoverPoints=ve.hoverPoint=void 0)}runPointActions(he,_e,ve){let ae=this.chart,ie=ae.series,pe=ae.tooltip&&ae.tooltip.options.enabled?ae.tooltip:void 0,ue=!!pe&&pe.shared,ge=_e||ae.hoverPoint,ye=ge&&ge.series||ae.hoverSeries,Ae=(!he||he.type!=="touchmove")&&(!!_e||ye&&ye.directTouch&&this.isDirectTouch),Re=this.getHoverData(ge,ye,ie,Ae,ue,he);ge=Re.hoverPoint,ye=Re.hoverSeries;let We=Re.hoverPoints,Pe=ye&&ye.tooltipOptions.followPointer&&!ye.tooltipOptions.split,Ue=ue&&ye&&!ye.noSharedTooltip;if(ge&&(ve||ge!==ae.hoverPoint||pe&&pe.isHidden)){if((ae.hoverPoints||[]).forEach(function(Oe){We.indexOf(Oe)===-1&&Oe.setState()}),ae.hoverSeries!==ye&&ye.onMouseOver(),this.applyInactiveState(We),(We||[]).forEach(function(Oe){Oe.setState("hover")}),ae.hoverPoint&&ae.hoverPoint.firePointEvent("mouseOut"),!ge.series)return;ae.hoverPoints=We,ae.hoverPoint=ge,ge.firePointEvent("mouseOver",void 0,()=>{pe&&ge&&pe.refresh(Ue?We:ge,he)})}else if(Pe&&pe&&!pe.isHidden){let Oe=pe.getAnchor([{}],he);ae.isInsidePlot(Oe[0],Oe[1],{visiblePlotOnly:!0})&&pe.updatePosition({plotX:Oe[0],plotY:Oe[1]})}this.unDocMouseMove||(this.unDocMouseMove=S(ae.container.ownerDocument,"mousemove",Oe=>g[xe.hoverChartIndex??-1]?.pointer?.onDocumentMouseMove(Oe)),this.eventsToUnbind.push(this.unDocMouseMove)),ae.axes.forEach(function(Oe){let Be,Ye=B((Oe.crosshair||{}).snap,!0);!Ye||(Be=ae.hoverPoint)&&Be.series[Oe.coll]===Oe||(Be=D(We,Se=>Se.series&&Se.series[Oe.coll]===Oe)),Be||!Ye?Oe.drawCrosshair(he,Be):Oe.hideCrosshair()})}setDOMEvents(){let he=this.chart.container,_e=he.ownerDocument;he.onmousedown=this.onContainerMouseDown.bind(this),he.onmousemove=this.onContainerMouseMove.bind(this),he.onclick=this.onContainerClick.bind(this),this.eventsToUnbind.push(S(he,"mouseenter",this.onContainerMouseEnter.bind(this)),S(he,"mouseleave",this.onContainerMouseLeave.bind(this))),xe.unbindDocumentMouseUp||(xe.unbindDocumentMouseUp=S(_e,"mouseup",this.onDocumentMouseUp.bind(this)));let ve=this.chart.renderTo.parentElement;for(;ve&&ve.tagName!=="BODY";)this.eventsToUnbind.push(S(ve,"scroll",()=>{delete this.chartPosition})),ve=ve.parentElement;this.eventsToUnbind.push(S(he,"touchstart",this.onContainerTouchStart.bind(this),{passive:!1}),S(he,"touchmove",this.onContainerTouchMove.bind(this),{passive:!1})),xe.unbindDocumentTouchEnd||(xe.unbindDocumentTouchEnd=S(_e,"touchend",this.onDocumentTouchEnd.bind(this),{passive:!1})),this.setPointerCapture(),S(this.chart,"redraw",this.setPointerCapture.bind(this))}setPointerCapture(){if(!x)return;let he=this.pointerCaptureEventsToUnbind,_e=this.chart,ve=_e.container,ae=B(_e.options.tooltip?.followTouchMove,!0)&&_e.series.some(ie=>ie.options.findNearestPointBy.indexOf("y")>-1);!this.hasPointerCapture&&ae?(he.push(S(ve,"pointerdown",ie=>{ie.target?.hasPointerCapture(ie.pointerId)&&ie.target?.releasePointerCapture(ie.pointerId)}),S(ve,"pointermove",ie=>{_e.pointer?.getPointFromEvent(ie)?.onMouseOver(ie)})),_e.styledMode||k(ve,{"touch-action":"none"}),ve.className+=" highcharts-no-touch-action",this.hasPointerCapture=!0):this.hasPointerCapture&&!ae&&(he.forEach(ie=>ie()),he.length=0,_e.styledMode||k(ve,{"touch-action":B(_e.options.chart.style?.["touch-action"],"manipulation")}),ve.className=ve.className.replace(" highcharts-no-touch-action",""),this.hasPointerCapture=!1)}setHoverChartIndex(he){let _e=this.chart,ve=a.charts[B(xe.hoverChartIndex,-1)];ve&&ve!==_e&&ve.pointer?.onContainerMouseLeave(he||{relatedTarget:_e.container}),ve&&ve.mouseIsDown||(xe.hoverChartIndex=_e.index)}touch(he,_e){let ve,{chart:ae,pinchDown:ie=[]}=this;this.setHoverChartIndex(),he.touches.length===1?(he=this.normalize(he),ae.isInsidePlot(he.chartX-ae.plotLeft,he.chartY-ae.plotTop,{visiblePlotOnly:!0})&&!ae.openMenu?(_e&&this.runPointActions(he),he.type==="touchmove"&&(ve=!!ie[0]&&Math.pow(ie[0].chartX-he.chartX,2)+Math.pow(ie[0].chartY-he.chartY,2)>=16),B(ve,!0)&&this.pinch(he)):_e&&this.reset()):he.touches.length===2&&this.pinch(he)}touchSelect(he){return!!(this.chart.zooming.singleTouch&&he.touches&&he.touches.length===1)}zoomOption(he){let _e=this.chart,ve=_e.inverted,ae=_e.zooming.type||"",ie,pe;/touch/.test(he.type)&&(ae=B(_e.zooming.pinchType,ae)),this.zoomX=ie=/x/.test(ae),this.zoomY=pe=/y/.test(ae),this.zoomHor=ie&&!ve||pe&&ve,this.zoomVert=pe&&!ve||ie&&ve,this.hasZoom=ie||pe}}return(c=xe||(xe={})).compose=function(we){le(b,"Core.Pointer")&&S(we,"beforeRender",function(){this.pointer=new c(this,this.options)})},xe}),n(r,"Core/Legend/Legend.js",[r["Core/Animation/AnimationUtilities.js"],r["Core/Templating.js"],r["Core/Globals.js"],r["Core/Series/Point.js"],r["Core/Renderer/RendererUtilities.js"],r["Core/Utilities.js"]],function(o,a,l,c,u,g){var b;let{animObject:x,setAnimation:S}=o,{format:$}=a,{composed:k,marginNames:T}=l,{distribute:D}=u,{addEvent:I,createElement:O,css:N,defined:ee,discardElement:ne,find:B,fireEvent:le,isNumber:fe,merge:xe,pick:we,pushUnique:he,relativeLength:_e,stableSort:ve,syncTimeout:ae}=g;class ie{constructor(ue,ge){this.allItems=[],this.initialItemY=0,this.itemHeight=0,this.itemMarginBottom=0,this.itemMarginTop=0,this.itemX=0,this.itemY=0,this.lastItemY=0,this.lastLineHeight=0,this.legendHeight=0,this.legendWidth=0,this.maxItemWidth=0,this.maxLegendWidth=0,this.offsetWidth=0,this.padding=0,this.pages=[],this.symbolHeight=0,this.symbolWidth=0,this.titleHeight=0,this.totalItemWidth=0,this.widthOption=0,this.chart=ue,this.setOptions(ge),ge.enabled&&(this.render(),I(this.chart,"endResize",function(){this.legend.positionCheckboxes()})),I(this.chart,"render",()=>{this.options.enabled&&this.proximate&&(this.proximatePositions(),this.positionItems())})}setOptions(ue){let ge=we(ue.padding,8);this.options=ue,this.chart.styledMode||(this.itemStyle=ue.itemStyle,this.itemHiddenStyle=xe(this.itemStyle,ue.itemHiddenStyle)),this.itemMarginTop=ue.itemMarginTop,this.itemMarginBottom=ue.itemMarginBottom,this.padding=ge,this.initialItemY=ge-5,this.symbolWidth=we(ue.symbolWidth,16),this.pages=[],this.proximate=ue.layout==="proximate"&&!this.chart.inverted,this.baseline=void 0}update(ue,ge){let ye=this.chart;this.setOptions(xe(!0,this.options,ue)),this.destroy(),ye.isDirtyLegend=ye.isDirtyBox=!0,we(ge,!0)&&ye.redraw(),le(this,"afterUpdate",{redraw:ge})}colorizeItem(ue,ge){let{area:ye,group:Ae,label:Re,line:We,symbol:Pe}=ue.legendItem||{};if(Ae?.[ge?"removeClass":"addClass"]("highcharts-legend-item-hidden"),!this.chart.styledMode){let{itemHiddenStyle:Ue={}}=this,Oe=Ue.color,{fillColor:Be,fillOpacity:Ye,lineColor:Se,marker:Te}=ue.options,$e=Ve=>(!ge&&(Ve.fill&&(Ve.fill=Oe),Ve.stroke&&(Ve.stroke=Oe)),Ve);Re?.css(xe(ge?this.itemStyle:Ue)),We?.attr($e({stroke:Se||ue.color})),Pe&&Pe.attr($e(Te&&Pe.isMarker?ue.pointAttribs():{fill:ue.color})),ye?.attr($e({fill:Be||ue.color,"fill-opacity":Be?1:Ye??.75}))}le(this,"afterColorizeItem",{item:ue,visible:ge})}positionItems(){this.allItems.forEach(this.positionItem,this),this.chart.isResizing||this.positionCheckboxes()}positionItem(ue){let{group:ge,x:ye=0,y:Ae=0}=ue.legendItem||{},Re=this.options,We=Re.symbolPadding,Pe=!Re.rtl,Ue=ue.checkbox;if(ge&&ge.element){let Oe={translateX:Pe?ye:this.legendWidth-ye-2*We-4,translateY:Ae};ge[ee(ge.translateY)?"animate":"attr"](Oe,void 0,()=>{le(this,"afterPositionItem",{item:ue})})}Ue&&(Ue.x=ye,Ue.y=Ae)}destroyItem(ue){let ge=ue.checkbox,ye=ue.legendItem||{};for(let Ae of["group","label","line","symbol"])ye[Ae]&&(ye[Ae]=ye[Ae].destroy());ge&&ne(ge),ue.legendItem=void 0}destroy(){for(let ue of this.getAllItems())this.destroyItem(ue);for(let ue of["clipRect","up","down","pager","nav","box","title","group"])this[ue]&&(this[ue]=this[ue].destroy());this.display=null}positionCheckboxes(){let ue,ge=this.group&&this.group.alignAttr,ye=this.clipHeight||this.legendHeight,Ae=this.titleHeight;ge&&(ue=ge.translateY,this.allItems.forEach(function(Re){let We,Pe=Re.checkbox;Pe&&(We=ue+Ae+Pe.y+(this.scrollOffset||0)+3,N(Pe,{left:ge.translateX+Re.checkboxOffset+Pe.x-20+"px",top:We+"px",display:this.proximate||We>ue-6&&We1.5*He?Le.height:He))}layoutItem(ue){let ge=this.options,ye=this.padding,Ae=ge.layout==="horizontal",Re=ue.itemHeight,We=this.itemMarginBottom,Pe=this.itemMarginTop,Ue=Ae?we(ge.itemDistance,20):0,Oe=this.maxLegendWidth,Be=ge.alignColumns&&this.totalItemWidth>Oe?this.maxItemWidth:ue.itemWidth,Ye=ue.legendItem||{};Ae&&this.itemX-ye+Be>Oe&&(this.itemX=ye,this.lastLineHeight&&(this.itemY+=Pe+this.lastLineHeight+We),this.lastLineHeight=0),this.lastItemY=Pe+this.itemY+We,this.lastLineHeight=Math.max(Re,this.lastLineHeight),Ye.x=this.itemX,Ye.y=this.itemY,Ae?this.itemX+=Be:(this.itemY+=Pe+Re+We,this.lastLineHeight=Re),this.offsetWidth=this.widthOption||Math.max((Ae?this.itemX-ye-(ue.checkbox?0:Ue):Be)+ye,this.offsetWidth)}getAllItems(){let ue=[];return this.chart.series.forEach(function(ge){let ye=ge&&ge.options;ge&&we(ye.showInLegend,!ee(ye.linkedTo)&&void 0,!0)&&(ue=ue.concat((ge.legendItem||{}).labels||(ye.legendType==="point"?ge.data:ge)))}),le(this,"afterGetAllItems",{allItems:ue}),ue}getAlignment(){let ue=this.options;return this.proximate?ue.align.charAt(0)+"tv":ue.floating?"":ue.align.charAt(0)+ue.verticalAlign.charAt(0)+ue.layout.charAt(0)}adjustMargins(ue,ge){let ye=this.chart,Ae=this.options,Re=this.getAlignment();Re&&[/(lth|ct|rth)/,/(rtv|rm|rbv)/,/(rbh|cb|lbh)/,/(lbv|lm|ltv)/].forEach(function(We,Pe){We.test(Re)&&!ee(ue[Pe])&&(ye[T[Pe]]=Math.max(ye[T[Pe]],ye.legend[(Pe+1)%2?"legendHeight":"legendWidth"]+[1,-1,-1,1][Pe]*Ae[Pe%2?"x":"y"]+we(Ae.margin,12)+ge[Pe]+(ye.titleOffset[Pe]||0)))})}proximatePositions(){let ue,ge=this.chart,ye=[],Ae=this.options.align==="left";for(let Re of(this.allItems.forEach(function(We){let Pe,Ue,Oe=Ae,Be,Ye;We.yAxis&&(We.xAxis.options.reversed&&(Oe=!Oe),We.points&&(Pe=B(Oe?We.points:We.points.slice(0).reverse(),function(Se){return fe(Se.plotY)})),Ue=this.itemMarginTop+We.legendItem.label.getBBox().height+this.itemMarginBottom,Ye=We.yAxis.top-ge.plotTop,Be=We.visible?(Pe?Pe.plotY:We.yAxis.height)+(Ye-.3*Ue):Ye+We.yAxis.height,ye.push({target:Be,size:Ue,item:We}))},this),D(ye,ge.plotHeight)))ue=Re.item.legendItem||{},fe(Re.pos)&&(ue.y=ge.plotTop-ge.spacing[0]+Re.pos)}render(){let ue=this.chart,ge=ue.renderer,ye=this.options,Ae=this.padding,Re=this.getAllItems(),We,Pe,Ue,Oe=this.group,Be,Ye=this.box;this.itemX=Ae,this.itemY=this.initialItemY,this.offsetWidth=0,this.lastItemY=0,this.widthOption=_e(ye.width,ue.spacingBox.width-Ae),Be=ue.spacingBox.width-2*Ae-ye.x,["rm","lm"].indexOf(this.getAlignment().substring(0,2))>-1&&(Be/=2),this.maxLegendWidth=this.widthOption||Be,Oe||(this.group=Oe=ge.g("legend").addClass(ye.className||"").attr({zIndex:7}).add(),this.contentGroup=ge.g().attr({zIndex:1}).add(Oe),this.scrollGroup=ge.g().add(this.contentGroup)),this.renderTitle(),ve(Re,(Se,Te)=>(Se.options&&Se.options.legendIndex||0)-(Te.options&&Te.options.legendIndex||0)),ye.reversed&&Re.reverse(),this.allItems=Re,this.display=We=!!Re.length,this.lastLineHeight=0,this.maxItemWidth=0,this.totalItemWidth=0,this.itemHeight=0,Re.forEach(this.renderItem,this),Re.forEach(this.layoutItem,this),Pe=(this.widthOption||this.offsetWidth)+Ae,Ue=this.lastItemY+this.lastLineHeight+this.titleHeight,Ue=this.handleOverflow(Ue)+Ae,Ye||(this.box=Ye=ge.rect().addClass("highcharts-legend-box").attr({r:ye.borderRadius}).add(Oe)),ue.styledMode||Ye.attr({stroke:ye.borderColor,"stroke-width":ye.borderWidth||0,fill:ye.backgroundColor||"none"}).shadow(ye.shadow),Pe>0&&Ue>0&&Ye[Ye.placed?"animate":"attr"](Ye.crisp.call({},{x:0,y:0,width:Pe,height:Ue},Ye.strokeWidth())),Oe[We?"show":"hide"](),ue.styledMode&&Oe.getStyle("display")==="none"&&(Pe=Ue=0),this.legendWidth=Pe,this.legendHeight=Ue,We&&this.align(),this.proximate||this.positionItems(),le(this,"afterRender")}align(ue=this.chart.spacingBox){let ge=this.chart,ye=this.options,Ae=ue.y;/(lth|ct|rth)/.test(this.getAlignment())&&ge.titleOffset[0]>0?Ae+=ge.titleOffset[0]:/(lbh|cb|rbh)/.test(this.getAlignment())&&ge.titleOffset[2]>0&&(Ae-=ge.titleOffset[2]),Ae!==ue.y&&(ue=xe(ue,{y:Ae})),ge.hasRendered||(this.group.placed=!1),this.group.align(xe(ye,{width:this.legendWidth,height:this.legendHeight,verticalAlign:this.proximate?"top":ye.verticalAlign}),!0,ue)}handleOverflow(ue){let ge=this,ye=this.chart,Ae=ye.renderer,Re=this.options,We=Re.y,Pe=Re.verticalAlign==="top",Ue=this.padding,Oe=Re.maxHeight,Be=Re.navigation,Ye=we(Be.animation,!0),Se=Be.arrowSize||12,Te=this.pages,$e=this.allItems,Ve=function(ze){typeof ze=="number"?He.attr({height:ze}):He&&(ge.clipRect=He.destroy(),ge.contentGroup.clip()),ge.contentGroup.div&&(ge.contentGroup.div.style.clip=ze?"rect("+Ue+"px,9999px,"+(Ue+ze)+"px,0)":"auto")},oe=function(ze){return ge[ze]=Ae.circle(0,0,1.3*Se).translate(Se/2,Se/2).add(Le),ye.styledMode||ge[ze].attr("fill","rgba(0,0,0,0.0001)"),ge[ze]},te,se,me,Ee=ye.spacingBox.height+(Pe?-We:We)-Ue,Le=this.nav,He=this.clipRect;return Re.layout!=="horizontal"||Re.verticalAlign==="middle"||Re.floating||(Ee/=2),Oe&&(Ee=Math.min(Ee,Oe)),Te.length=0,ue&&Ee>0&&ue>Ee&&Be.enabled!==!1?(this.clipHeight=te=Math.max(Ee-20-this.titleHeight-Ue,0),this.currentPage=we(this.currentPage,1),this.fullHeight=ue,$e.forEach((ze,Qe)=>{let rt=(me=ze.legendItem||{}).y||0,Ke=Math.round(me.label.getBBox().height),Ie=Te.length;(!Ie||rt-Te[Ie-1]>te&&(se||rt)!==Te[Ie-1])&&(Te.push(se||rt),Ie++),me.pageIx=Ie-1,se&&(($e[Qe-1].legendItem||{}).pageIx=Ie-1),Qe===$e.length-1&&rt+Ke-Te[Ie-1]>te&&rt>Te[Ie-1]&&(Te.push(rt),me.pageIx=Ie),rt!==se&&(se=rt)}),He||(He=ge.clipRect=Ae.clipRect(0,Ue-2,9999,0),ge.contentGroup.clip(He)),Ve(te),Le||(this.nav=Le=Ae.g().attr({zIndex:1}).add(this.group),this.up=Ae.symbol("triangle",0,0,Se,Se).add(Le),oe("upTracker").on("click",function(){ge.scroll(-1,Ye)}),this.pager=Ae.text("",15,10).addClass("highcharts-legend-navigation"),!ye.styledMode&&Be.style&&this.pager.css(Be.style),this.pager.add(Le),this.down=Ae.symbol("triangle-down",0,0,Se,Se).add(Le),oe("downTracker").on("click",function(){ge.scroll(1,Ye)})),ge.scroll(0),ue=Ee):Le&&(Ve(),this.nav=Le.destroy(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0),ue}scroll(ue,ge){let ye=this.chart,Ae=this.pages,Re=Ae.length,We=this.clipHeight,Pe=this.options.navigation,Ue=this.pager,Oe=this.padding,Be=this.currentPage+ue;Be>Re&&(Be=Re),Be>0&&(ge!==void 0&&S(ge,ye),this.nav.attr({translateX:Oe,translateY:We+this.padding+7+this.titleHeight,visibility:"inherit"}),[this.up,this.upTracker].forEach(function(Ye){Ye.attr({class:Be===1?"highcharts-legend-nav-inactive":"highcharts-legend-nav-active"})}),Ue.attr({text:Be+"/"+Re}),[this.down,this.downTracker].forEach(function(Ye){Ye.attr({x:18+this.pager.getBBox().width,class:Be===Re?"highcharts-legend-nav-inactive":"highcharts-legend-nav-active"})},this),ye.styledMode||(this.up.attr({fill:Be===1?Pe.inactiveColor:Pe.activeColor}),this.upTracker.css({cursor:Be===1?"default":"pointer"}),this.down.attr({fill:Be===Re?Pe.inactiveColor:Pe.activeColor}),this.downTracker.css({cursor:Be===Re?"default":"pointer"})),this.scrollOffset=-Ae[Be-1]+this.initialItemY,this.scrollGroup.animate({translateY:this.scrollOffset}),this.currentPage=Be,this.positionCheckboxes(),ae(()=>{le(this,"afterScroll",{currentPage:Be})},x(we(ge,ye.renderer.globalAnimation,!0)).duration))}setItemEvents(ue,ge,ye){let Ae=this,Re=ue.legendItem||{},We=Ae.chart.renderer.boxWrapper,Pe=ue instanceof c,Ue="highcharts-legend-"+(Pe?"point":"series")+"-active",Oe=Ae.chart.styledMode,Be=ye?[ge,Re.symbol]:[Re.group],Ye=Se=>{Ae.allItems.forEach(Te=>{ue!==Te&&[Te].concat(Te.linkedSeries||[]).forEach($e=>{$e.setState(Se,!Pe)})})};for(let Se of Be)Se&&Se.on("mouseover",function(){ue.visible&&Ye("inactive"),ue.setState("hover"),ue.visible&&We.addClass(Ue),Oe||ge.css(Ae.options.itemHoverStyle)}).on("mouseout",function(){Ae.chart.styledMode||ge.css(xe(ue.visible?Ae.itemStyle:Ae.itemHiddenStyle)),Ye(""),We.removeClass(Ue),ue.setState()}).on("click",function(Te){let $e="legendItemClick",Ve=function(){ue.setVisible&&ue.setVisible(),Ye(ue.visible?"inactive":"")};We.removeClass(Ue),Te={browserEvent:Te},ue.firePointEvent?ue.firePointEvent($e,Te,Ve):le(ue,$e,Te,Ve)})}createCheckboxForItem(ue){ue.checkbox=O("input",{type:"checkbox",className:"highcharts-legend-checkbox",checked:ue.selected,defaultChecked:ue.selected},this.options.itemCheckboxStyle,this.chart.container),I(ue.checkbox,"click",function(ge){let ye=ge.target;le(ue.series||ue,"checkboxClick",{checked:ye.checked,item:ue},function(){ue.select()})})}}return(b=ie||(ie={})).compose=function(pe){he(k,"Core.Legend")&&I(pe,"beforeMargins",function(){this.legend=new b(this,this.options.legend)})},ie}),n(r,"Core/Legend/LegendSymbol.js",[r["Core/Utilities.js"]],function(o){var a;let{extend:l,merge:c,pick:u}=o;return function(g){function b(x,S,$){let k=this.legendItem=this.legendItem||{},{chart:T,options:D}=this,{baseline:I=0,symbolWidth:O,symbolHeight:N}=x,ee=this.symbol||"circle",ne=N/2,B=T.renderer,le=k.group,fe=I-Math.round(N*($?.4:.3)),xe={},we,he=D.marker,_e=0;if(T.styledMode||(xe["stroke-width"]=Math.min(D.lineWidth||0,24),D.dashStyle?xe.dashstyle=D.dashStyle:D.linecap==="square"||(xe["stroke-linecap"]="round")),k.line=B.path().addClass("highcharts-graph").attr(xe).add(le),$&&(k.area=B.path().addClass("highcharts-area").add(le)),xe["stroke-linecap"]&&(_e=Math.min(k.line.strokeWidth(),O)/2),O){let ve=[["M",_e,fe],["L",O-_e,fe]];k.line.attr({d:ve}),k.area?.attr({d:[...ve,["L",O-_e,I],["L",_e,I]]})}if(he&&he.enabled!==!1&&O){let ve=Math.min(u(he.radius,ne),ne);ee.indexOf("url")===0&&(he=c(he,{width:N,height:N}),ve=0),k.symbol=we=B.symbol(ee,O/2-ve,fe-ve,2*ve,2*ve,l({context:"legend"},he)).addClass("highcharts-point").add(le),we.isMarker=!0}}g.areaMarker=function(x,S){b.call(this,x,S,!0)},g.lineMarker=b,g.rectangle=function(x,S){let $=S.legendItem||{},k=x.options,T=x.symbolHeight,D=k.squareSymbol,I=D?T:x.symbolWidth;$.symbol=this.chart.renderer.rect(D?(x.symbolWidth-T)/2:0,x.baseline-T+1,I,T,u(x.options.symbolRadius,T/2)).addClass("highcharts-point").attr({zIndex:3}).add($.group)}}(a||(a={})),a}),n(r,"Core/Series/SeriesDefaults.js",[],function(){return{lineWidth:2,allowPointSelect:!1,crisp:!0,showCheckbox:!1,animation:{duration:1e3},enableMouseTracking:!0,events:{},marker:{enabledThreshold:2,lineColor:"#ffffff",lineWidth:0,radius:4,states:{normal:{animation:!0},hover:{animation:{duration:150},enabled:!0,radiusPlus:2,lineWidthPlus:1},select:{fillColor:"#cccccc",lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:{animation:{},align:"center",borderWidth:0,defer:!0,formatter:function(){let{numberFormatter:o}=this.series.chart;return typeof this.y!="number"?"":o(this.y,-1)},padding:5,style:{fontSize:"0.7em",fontWeight:"bold",color:"contrast",textOutline:"1px contrast"},verticalAlign:"bottom",x:0,y:0},cropThreshold:300,opacity:1,pointRange:0,softThreshold:!0,states:{normal:{animation:!0},hover:{animation:{duration:150},lineWidthPlus:1,marker:{},halo:{size:10,opacity:.25}},select:{animation:{duration:0}},inactive:{animation:{duration:150},opacity:.2}},stickyTracking:!0,turboThreshold:1e3,findNearestPointBy:"x"}}),n(r,"Core/Series/SeriesRegistry.js",[r["Core/Globals.js"],r["Core/Defaults.js"],r["Core/Series/Point.js"],r["Core/Utilities.js"]],function(o,a,l,c){var u;let{defaultOptions:g}=a,{extend:b,extendClass:x,merge:S}=c;return function($){function k(T,D){let I=g.plotOptions||{},O=D.defaultOptions,N=D.prototype;return N.type=T,N.pointClass||(N.pointClass=l),!$.seriesTypes[T]&&(O&&(I[T]=O),$.seriesTypes[T]=D,!0)}$.seriesTypes=o.seriesTypes,$.registerSeriesType=k,$.seriesType=function(T,D,I,O,N){let ee=g.plotOptions||{};if(D=D||"",ee[T]=S(ee[D],I),delete $.seriesTypes[T],k(T,x($.seriesTypes[D]||function(){},O)),$.seriesTypes[T].prototype.type=T,N){class ne extends l{}b(ne.prototype,N),$.seriesTypes[T].prototype.pointClass=ne}return $.seriesTypes[T]}}(u||(u={})),u}),n(r,"Core/Series/Series.js",[r["Core/Animation/AnimationUtilities.js"],r["Core/Defaults.js"],r["Core/Foundation.js"],r["Core/Globals.js"],r["Core/Legend/LegendSymbol.js"],r["Core/Series/Point.js"],r["Core/Series/SeriesDefaults.js"],r["Core/Series/SeriesRegistry.js"],r["Core/Renderer/SVG/SVGElement.js"],r["Core/Utilities.js"]],function(o,a,l,c,u,g,b,x,S,$){let{animObject:k,setAnimation:T}=o,{defaultOptions:D}=a,{registerEventOptions:I}=l,{svg:O,win:N}=c,{seriesTypes:ee}=x,{arrayMax:ne,arrayMin:B,clamp:le,correctFloat:fe,crisp:xe,defined:we,destroyObjectProperties:he,diffObjects:_e,erase:ve,error:ae,extend:ie,find:pe,fireEvent:ue,getClosestDistance:ge,getNestedProperty:ye,insertItem:Ae,isArray:Re,isNumber:We,isString:Pe,merge:Ue,objectEach:Oe,pick:Be,removeEvent:Ye,splat:Se,syncTimeout:Te}=$;class $e{constructor(){this.zoneAxis="y"}init(oe,te){let se;ue(this,"init",{options:te});let me=this,Ee=oe.series;this.eventsToUnbind=[],me.chart=oe,me.options=me.setOptions(te);let Le=me.options,He=Le.visible!==!1;me.linkedSeries=[],me.bindAxes(),ie(me,{name:Le.name,state:"",visible:He,selected:Le.selected===!0}),I(this,Le);let ze=Le.events;(ze&&ze.click||Le.point&&Le.point.events&&Le.point.events.click||Le.allowPointSelect)&&(oe.runTrackerClick=!0),me.getColor(),me.getSymbol(),me.parallelArrays.forEach(function(Qe){me[Qe+"Data"]||(me[Qe+"Data"]=[])}),me.isCartesian&&(oe.hasCartesianSeries=!0),Ee.length&&(se=Ee[Ee.length-1]),me._i=Be(se&&se._i,-1)+1,me.opacity=me.options.opacity,oe.orderItems("series",Ae(this,Ee)),Le.dataSorting&&Le.dataSorting.enabled?me.setDataSortingOptions():me.points||me.data||me.setData(Le.data,!1),ue(this,"afterInit")}is(oe){return ee[oe]&&this instanceof ee[oe]}bindAxes(){let oe,te=this,se=te.options,me=te.chart;ue(this,"bindAxes",null,function(){(te.axisTypes||[]).forEach(function(Ee){(me[Ee]||[]).forEach(function(Le){oe=Le.options,(Be(se[Ee],0)===Le.index||se[Ee]!==void 0&&se[Ee]===oe.id)&&(Ae(te,Le.series),te[Ee]=Le,Le.isDirty=!0)}),te[Ee]||te.optionalAxis===Ee||ae(18,!0,me)})}),ue(this,"afterBindAxes")}updateParallelArrays(oe,te,se){let me=oe.series,Ee=We(te)?function(Le){let He=Le==="y"&&me.toYData?me.toYData(oe):oe[Le];me[Le+"Data"][te]=He}:function(Le){Array.prototype[te].apply(me[Le+"Data"],se)};me.parallelArrays.forEach(Ee)}hasData(){return this.visible&&this.dataMax!==void 0&&this.dataMin!==void 0||this.visible&&this.yData&&this.yData.length>0}hasMarkerChanged(oe,te){let se=oe.marker,me=te.marker||{};return se&&(me.enabled&&!se.enabled||me.symbol!==se.symbol||me.height!==se.height||me.width!==se.width)}autoIncrement(oe){let te=this.options,se=te.pointIntervalUnit,me=te.relativeXValue,Ee=this.chart.time,Le=this.xIncrement,He,ze;return Le=Be(Le,te.pointStart,0),this.pointInterval=ze=Be(this.pointInterval,te.pointInterval,1),me&&We(oe)&&(ze*=oe),se&&(He=new Ee.Date(Le),se==="day"?Ee.set("Date",He,Ee.get("Date",He)+ze):se==="month"?Ee.set("Month",He,Ee.get("Month",He)+ze):se==="year"&&Ee.set("FullYear",He,Ee.get("FullYear",He)+ze),ze=He.getTime()-Le),me&&We(oe)?Le+ze:(this.xIncrement=Le+ze,Le)}setDataSortingOptions(){let oe=this.options;ie(this,{requireSorting:!1,sorted:!1,enabledDataSorting:!0,allowDG:!1}),we(oe.pointRange)||(oe.pointRange=1)}setOptions(oe){let te,se=this.chart,me=se.options.plotOptions,Ee=se.userOptions||{},Le=Ue(oe),He=se.styledMode,ze={plotOptions:me,userOptions:Le};ue(this,"setOptions",ze);let Qe=ze.plotOptions[this.type],rt=Ee.plotOptions||{},Ke=rt.series||{},Ie=D.plotOptions[this.type]||{},Fe=rt[this.type]||{};this.userOptions=ze.userOptions;let je=Ue(Qe,me.series,Fe,Le);this.tooltipOptions=Ue(D.tooltip,D.plotOptions.series?.tooltip,Ie?.tooltip,se.userOptions.tooltip,rt.series?.tooltip,Fe.tooltip,Le.tooltip),this.stickyTracking=Be(Le.stickyTracking,Fe.stickyTracking,Ke.stickyTracking,!!this.tooltipOptions.shared&&!this.noSharedTooltip||je.stickyTracking),Qe.marker===null&&delete je.marker,this.zoneAxis=je.zoneAxis||"y";let Ze=this.zones=(je.zones||[]).map(Ce=>({...Ce}));return(je.negativeColor||je.negativeFillColor)&&!je.zones&&(te={value:je[this.zoneAxis+"Threshold"]||je.threshold||0,className:"highcharts-negative"},He||(te.color=je.negativeColor,te.fillColor=je.negativeFillColor),Ze.push(te)),Ze.length&&we(Ze[Ze.length-1].value)&&Ze.push(He?{}:{color:this.color,fillColor:this.fillColor}),ue(this,"afterSetOptions",{options:je}),je}getName(){return Be(this.options.name,"Series "+(this.index+1))}getCyclic(oe,te,se){let me,Ee,Le=this.chart,He=`${oe}Index`,ze=`${oe}Counter`,Qe=se?.length||Le.options.chart.colorCount;!te&&(we(Ee=Be(oe==="color"?this.options.colorIndex:void 0,this[He]))?me=Ee:(Le.series.length||(Le[ze]=0),me=Le[ze]%Qe,Le[ze]+=1),se&&(te=se[me])),me!==void 0&&(this[He]=me),this[oe]=te}getColor(){this.chart.styledMode?this.getCyclic("color"):this.options.colorByPoint?this.color="#cccccc":this.getCyclic("color",this.options.color||D.plotOptions[this.type].color,this.chart.options.colors)}getPointsCollection(){return(this.hasGroupedData?this.points:this.data)||[]}getSymbol(){let oe=this.options.marker;this.getCyclic("symbol",oe.symbol,this.chart.options.symbols)}findPointIndex(oe,te){let se,me,Ee,Le=oe.id,He=oe.x,ze=this.points,Qe=this.options.dataSorting;if(Le){let rt=this.chart.get(Le);rt instanceof g&&(se=rt)}else if(this.linkedParent||this.enabledDataSorting||this.options.relativeXValue){let rt=Ke=>!Ke.touched&&Ke.index===oe.index;if(Qe&&Qe.matchByName?rt=Ke=>!Ke.touched&&Ke.name===oe.name:this.options.relativeXValue&&(rt=Ke=>!Ke.touched&&Ke.options.x===oe.x),!(se=pe(ze,rt)))return}return se&&(Ee=se&&se.index)!==void 0&&(me=!0),Ee===void 0&&We(He)&&(Ee=this.xData.indexOf(He,te)),Ee!==-1&&Ee!==void 0&&this.cropped&&(Ee=Ee>=this.cropStart?Ee-this.cropStart:Ee),!me&&We(Ee)&&ze[Ee]&&ze[Ee].touched&&(Ee=void 0),Ee}updateData(oe,te){let se=this.options,me=se.dataSorting,Ee=this.points,Le=[],He=this.requireSorting,ze=oe.length===Ee.length,Qe,rt,Ke,Ie,Fe=!0;if(this.xIncrement=null,oe.forEach(function(je,Ze){let Ce,ce=we(je)&&this.pointClass.prototype.optionsToObject.call({series:this},je)||{},de=ce.x;ce.id||We(de)?((Ce=this.findPointIndex(ce,Ie))===-1||Ce===void 0?Le.push(je):Ee[Ce]&&je!==se.data[Ce]?(Ee[Ce].update(je,!1,null,!1),Ee[Ce].touched=!0,He&&(Ie=Ce+1)):Ee[Ce]&&(Ee[Ce].touched=!0),(!ze||Ze!==Ce||me&&me.enabled||this.hasDerivedData)&&(Qe=!0)):Le.push(je)},this),Qe)for(rt=Ee.length;rt--;)(Ke=Ee[rt])&&!Ke.touched&&Ke.remove&&Ke.remove(!1,te);else!ze||me&&me.enabled?Fe=!1:(oe.forEach(function(je,Ze){je===Ee[Ze].y||Ee[Ze].destroyed||Ee[Ze].update(je,!1,null,!1)}),Le.length=0);return Ee.forEach(function(je){je&&(je.touched=!1)}),!!Fe&&(Le.forEach(function(je){this.addPoint(je,!1,null,null,!1)},this),this.xIncrement===null&&this.xData&&this.xData.length&&(this.xIncrement=ne(this.xData),this.autoIncrement()),!0)}setData(oe,te=!0,se,me){let Ee=this,Le=Ee.points,He=Le&&Le.length||0,ze=Ee.options,Qe=Ee.chart,rt=ze.dataSorting,Ke=Ee.xAxis,Ie=ze.turboThreshold,Fe=this.xData,je=this.yData,Ze=Ee.pointArrayMap,Ce=Ze&&Ze.length,ce=ze.keys,de,De,qe,nt=0,lt=1,pt=null,bt;Qe.options.chart.allowMutatingData||(ze.data&&delete Ee.options.data,Ee.userOptions.data&&delete Ee.userOptions.data,bt=Ue(!0,oe));let St=(oe=bt||oe||[]).length;if(rt&&rt.enabled&&(oe=this.sortData(oe)),Qe.options.chart.allowMutatingData&&me!==!1&&St&&He&&!Ee.cropped&&!Ee.hasGroupedData&&Ee.visible&&!Ee.boosted&&(qe=this.updateData(oe,se)),!qe){if(Ee.xIncrement=null,Ee.colorCounter=0,this.parallelArrays.forEach(function(Et){Ee[Et+"Data"].length=0}),Ie&&St>Ie)if(We(pt=Ee.getFirstValidPoint(oe)))for(de=0;de=0?nt:0,lt=lt>=0?lt:1),pt.length===1&&(lt=0),nt===lt)for(de=0;de{let He=ye(se,Ee),ze=ye(se,Le);return zeHe?1:0}).forEach(function(Ee,Le){Ee.x=Le},this),te.linkedSeries&&te.linkedSeries.forEach(function(Ee){let Le=Ee.options,He=Le.data;Le.dataSorting&&Le.dataSorting.enabled||!He||(He.forEach(function(ze,Qe){He[Qe]=me(Ee,ze),oe[Qe]&&(He[Qe].x=oe[Qe].x,He[Qe].index=Qe)}),Ee.setData(He,!1))}),oe}getProcessedData(oe){let te=this,se=te.xAxis,me=te.options.cropThreshold,Ee=se?.logarithmic,Le=te.isCartesian,He,ze,Qe=0,rt,Ke,Ie,Fe=te.xData,je=te.yData,Ze=!1,Ce=Fe.length;se&&(Ke=(rt=se.getExtremes()).min,Ie=rt.max,Ze=!!(se.categories&&!se.names.length)),Le&&te.sorted&&!oe&&(!me||Ce>me||te.forceCrop)&&(Fe[Ce-1]Ie?(Fe=[],je=[]):te.yData&&(Fe[0]Ie)&&(Fe=(He=this.cropData(te.xData,te.yData,Ke,Ie)).xData,je=He.yData,Qe=He.start,ze=!0));let ce=ge([Ee?Fe.map(Ee.log2lin):Fe],()=>te.requireSorting&&!Ze&&ae(15,!1,te.chart));return{xData:Fe,yData:je,cropped:ze,cropStart:Qe,closestPointRange:ce}}processData(oe){let te=this.xAxis;if(this.isCartesian&&!this.isDirty&&!te.isDirty&&!this.yAxis.isDirty&&!oe)return!1;let se=this.getProcessedData();this.cropped=se.cropped,this.cropStart=se.cropStart,this.processedXData=se.xData,this.processedYData=se.yData,this.closestPointRange=this.basePointRange=se.closestPointRange,ue(this,"afterProcessData")}cropData(oe,te,se,me){let Ee=oe.length,Le,He,ze=0,Qe=Ee;for(Le=0;Le=se){ze=Math.max(0,Le-1);break}for(He=Le;Heme){Qe=He+1;break}return{xData:oe.slice(ze,Qe),yData:te.slice(ze,Qe),start:ze,end:Qe}}generatePoints(){let oe=this.options,te=this.processedData||oe.data,se=this.processedXData,me=this.processedYData,Ee=this.pointClass,Le=se.length,He=this.cropStart||0,ze=this.hasGroupedData,Qe=oe.keys,rt=[],Ke=oe.dataGrouping&&oe.dataGrouping.groupAll?He:0,Ie,Fe,je,Ze,Ce=this.data;if(!Ce&&!ze){let ce=[];ce.length=te.length,Ce=this.data=ce}for(Qe&&ze&&(this.options.keys=!1),Ze=0;Ze0:Ze.length)||!He),Fe=te||this.getExtremesFromAll||this.options.getExtremesFromAll||this.cropped||!se||(lt[Ce+Le]||je)>=de&&(lt[Ce-Le]||je)<=De,Ie&&Fe)if(ce=Ze.length)for(;ce--;)We(Ze[ce])&&(Ee[qe++]=Ze[ce]);else Ee[qe++]=Ze;let pt={activeYData:Ee,dataMin:B(Ee),dataMax:ne(Ee)};return ue(this,"afterGetExtremes",{dataExtremes:pt}),pt}applyExtremes(){let oe=this.getExtremes();return this.dataMin=oe.dataMin,this.dataMax=oe.dataMax,oe}getFirstValidPoint(oe){let te=oe.length,se=0,me=null;for(;me===null&&se1)&&(Le.step=function(Ie,Fe){Ke&&Ke.apply(Fe,arguments),Fe.prop==="width"&&Qe?.element&&Qe.attr(Ee?"height":"width",Ie+99)}),ze.addClass("highcharts-animating").animate(rt,Le)}}afterAnimate(){this.setClip(),Oe(this.chart.sharedClips,(oe,te,se)=>{oe&&!this.chart.container.querySelector(`[clip-path="url(#${oe.id})"]`)&&(oe.destroy(),delete se[te])}),this.finishedAnimating=!0,ue(this,"afterAnimate")}drawPoints(oe=this.points){let te,se,me,Ee,Le,He,ze,Qe=this.chart,rt=Qe.styledMode,{colorAxis:Ke,options:Ie}=this,Fe=Ie.marker,je=this[this.specialGroup||"markerGroup"],Ze=this.xAxis,Ce=Be(Fe.enabled,!Ze||!!Ze.isRadial||null,this.closestPointRangePx>=Fe.enabledThreshold*Fe.radius);if(Fe.enabled!==!1||this._hasPointMarkers)for(te=0;te0||se.hasImage)&&(se.graphic=me=Qe.renderer.symbol(ce,ze.x,ze.y,ze.width,ze.height,He?Le:Fe).add(je),this.enabledDataSorting&&Qe.hasRendered&&(me.attr({x:se.startXPos}),Ee="animate")),me&&Ee==="animate"&&me[de?"show":"hide"](de).animate(ze),me){let De=this.pointAttribs(se,rt||!se.selected?void 0:"select");rt?Ke&&me.css({fill:De.fill}):me[Ee](De)}me&&me.addClass(se.getClassName(),!0)}else me&&(se.graphic=me.destroy())}markerAttribs(oe,te){let se=this.options,me=se.marker,Ee=oe.marker||{},Le=Ee.symbol||me.symbol,He={},ze,Qe,rt=Be(Ee.radius,me&&me.radius);te&&(ze=me.states[te],rt=Be((Qe=Ee.states&&Ee.states[te])&&Qe.radius,ze&&ze.radius,rt&&rt+(ze&&ze.radiusPlus||0))),oe.hasImage=Le&&Le.indexOf("url")===0,oe.hasImage&&(rt=0);let Ke=oe.pos();return We(rt)&&Ke&&(se.crisp&&(Ke[0]=xe(Ke[0],oe.hasImage?0:Le==="rect"?me?.lineWidth||0:1)),He.x=Ke[0]-rt,He.y=Ke[1]-rt),rt&&(He.width=He.height=2*rt),He}pointAttribs(oe,te){let se=this.options.marker,me=oe&&oe.options,Ee=me&&me.marker||{},Le=me&&me.color,He=oe&&oe.color,ze=oe&&oe.zone&&oe.zone.color,Qe,rt,Ke=this.color,Ie,Fe,je=Be(Ee.lineWidth,se.lineWidth),Ze=1;return Ke=Le||ze||He||Ke,Ie=Ee.fillColor||se.fillColor||Ke,Fe=Ee.lineColor||se.lineColor||Ke,te=te||"normal",Qe=se.states[te]||{},je=Be((rt=Ee.states&&Ee.states[te]||{}).lineWidth,Qe.lineWidth,je+Be(rt.lineWidthPlus,Qe.lineWidthPlus,0)),Ie=rt.fillColor||Qe.fillColor||Ie,{stroke:Fe=rt.lineColor||Qe.lineColor||Fe,"stroke-width":je,fill:Ie,opacity:Ze=Be(rt.opacity,Qe.opacity,Ze)}}destroy(oe){let te,se,me,Ee=this,Le=Ee.chart,He=/AppleWebKit\/533/.test(N.navigator.userAgent),ze=Ee.data||[];for(ue(Ee,"destroy",{keepEventsForUpdate:oe}),this.removeEvents(oe),(Ee.axisTypes||[]).forEach(function(Qe){(me=Ee[Qe])&&me.series&&(ve(me.series,Ee),me.isDirty=me.forceRedraw=!0)}),Ee.legendItem&&Ee.chart.legend.destroyItem(Ee),te=ze.length;te--;)(se=ze[te])&&se.destroy&&se.destroy();for(let Qe of Ee.zones)he(Qe,void 0,!0);$.clearTimeout(Ee.animationTimeout),Oe(Ee,function(Qe,rt){Qe instanceof S&&!Qe.survive&&Qe[He&&rt==="group"?"hide":"destroy"]()}),Le.hoverSeries===Ee&&(Le.hoverSeries=void 0),ve(Le.series,Ee),Le.orderItems("series"),Oe(Ee,function(Qe,rt){oe&&rt==="hcEvents"||delete Ee[rt]})}applyZones(){let{area:oe,chart:te,graph:se,zones:me,points:Ee,xAxis:Le,yAxis:He,zoneAxis:ze}=this,{inverted:Qe,renderer:rt}=te,Ke=this[`${ze}Axis`],{isXAxis:Ie,len:Fe=0}=Ke||{},je=(se?.strokeWidth()||0)/2+1,Ze=(Ce,ce=0,de=0)=>{Qe&&(de=Fe-de);let{translated:De=0,lineClip:qe}=Ce,nt=de-De;qe?.push(["L",ce,Math.abs(nt){qe.forEach((nt,lt)=>{(nt[0]==="M"||nt[0]==="L")&&(qe[lt]=[nt[0],Ie?Fe-nt[1]:nt[1],Ie?nt[2]:Fe-nt[2]])})};if(me.forEach(qe=>{qe.lineClip=[],qe.translated=le(Ke.toPixels(Be(qe.value,Ce),!0)||0,0,Fe)}),se&&!this.showLine&&se.hide(),oe&&oe.hide(),ze==="y"&&Ee.length{let nt=qe.lineClip||[],lt=Math.round(qe.translated||0);Le.reversed&&nt.reverse();let{clip:pt,simpleClip:bt}=qe,St=0,Et=0,vt=Le.len,Nt=He.len;Ie?(St=lt,vt=De):(Et=lt,Nt=De);let Ft=[["M",St,Et],["L",vt,Et],["L",vt,Nt],["L",St,Nt],["Z"]],qt=[Ft[0],...nt,Ft[1],Ft[2],...de,Ft[3],Ft[4]];de=nt.reverse(),De=lt,Qe&&(ce(qt),oe&&ce(Ft)),pt?(pt.animate({d:qt}),bt?.animate({d:Ft})):(pt=qe.clip=rt.path(qt),oe&&(bt=qe.simpleClip=rt.path(Ft))),se&&qe.graph?.clip(pt),oe&&qe.area?.clip(bt)})}else this.visible&&(se&&se.show(),oe&&oe.show())}plotGroup(oe,te,se,me,Ee){let Le=this[oe],He=!Le,ze={visibility:se,zIndex:me||.1};return we(this.opacity)&&!this.chart.styledMode&&this.state!=="inactive"&&(ze.opacity=this.opacity),Le||(this[oe]=Le=this.chart.renderer.g().add(Ee)),Le.addClass("highcharts-"+te+" highcharts-series-"+this.index+" highcharts-"+this.type+"-series "+(we(this.colorIndex)?"highcharts-color-"+this.colorIndex+" ":"")+(this.options.className||"")+(Le.hasClass("highcharts-tracker")?" highcharts-tracker":""),!0),Le.attr(ze)[He?"attr":"animate"](this.getPlotBox(te)),Le}getPlotBox(oe){let te=this.xAxis,se=this.yAxis,me=this.chart,Ee=me.inverted&&!me.polar&&te&&this.invertible&&oe==="series";return me.inverted&&(te=se,se=this.xAxis),{translateX:te?te.left:me.plotLeft,translateY:se?se.top:me.plotTop,rotation:Ee?90:0,rotationOriginX:Ee?(te.len-se.len)/2:0,rotationOriginY:Ee?(te.len+se.len)/2:0,scaleX:Ee?-1:1,scaleY:1}}removeEvents(oe){let{eventsToUnbind:te}=this;oe||Ye(this),te.length&&(te.forEach(se=>{se()}),te.length=0)}render(){let oe=this,{chart:te,options:se,hasRendered:me}=oe,Ee=k(se.animation),Le=oe.visible?"inherit":"hidden",He=se.zIndex,ze=te.seriesGroup,Qe=oe.finishedAnimating?0:Ee.duration;ue(this,"render"),oe.plotGroup("group","series",Le,He,ze),oe.markerGroup=oe.plotGroup("markerGroup","markers",Le,He,ze),se.clip!==!1&&oe.setClip(),Qe&&oe.animate?.(!0),oe.drawGraph&&(oe.drawGraph(),oe.applyZones()),oe.visible&&oe.drawPoints(),oe.drawDataLabels?.(),oe.redrawPoints?.(),se.enableMouseTracking&&oe.drawTracker?.(),Qe&&oe.animate?.(),me||(Qe&&Ee.defer&&(Qe+=Ee.defer),oe.animationTimeout=Te(()=>{oe.afterAnimate()},Qe||0)),oe.isDirty=!1,oe.hasRendered=!0,ue(oe,"afterRender")}redraw(){let oe=this.isDirty||this.isDirtyData;this.translate(),this.render(),oe&&delete this.kdTree}reserveSpace(){return this.visible||!this.chart.options.chart.ignoreHiddenSeries}searchPoint(oe,te){let{xAxis:se,yAxis:me}=this,Ee=this.chart.inverted;return this.searchKDTree({clientX:Ee?se.len-oe.chartY+se.pos:oe.chartX-se.pos,plotY:Ee?me.len-oe.chartX+me.pos:oe.chartY-me.pos},te,oe)}buildKDTree(oe){this.buildingKdTree=!0;let te=this,se=te.options.findNearestPointBy.indexOf("y")>-1?2:1;delete te.kdTree,Te(function(){te.kdTree=function me(Ee,Le,He){let ze,Qe,rt=Ee?.length;if(rt)return ze=te.kdAxisArray[Le%He],Ee.sort((Ke,Ie)=>(Ke[ze]||0)-(Ie[ze]||0)),{point:Ee[Qe=Math.floor(rt/2)],left:me(Ee.slice(0,Qe),Le+1,He),right:me(Ee.slice(Qe+1),Le+1,He)}}(te.getValidPoints(void 0,!te.directTouch),se,se),te.buildingKdTree=!1},te.options.kdNow||oe?.type==="touchstart"?0:1)}searchKDTree(oe,te,se){let me=this,[Ee,Le]=this.kdAxisArray,He=te?"distX":"dist",ze=(me.options.findNearestPointBy||"").indexOf("y")>-1?2:1,Qe=!!me.isBubble;if(this.kdTree||this.buildingKdTree||this.buildKDTree(se),this.kdTree)return function rt(Ke,Ie,Fe,je){let Ze=Ie.point,Ce=me.kdAxisArray[Fe%je],ce,de,De=Ze;(function(pt,bt){let St=pt[Ee],Et=bt[Ee],vt=we(St)&&we(Et)?St-Et:null,Nt=pt[Le],Ft=bt[Le],qt=we(Nt)&&we(Ft)?Nt-Ft:0,Zt=Qe&&bt.marker?.radius||0;bt.dist=Math.sqrt((vt&&vt*vt||0)+qt*qt)-Zt,bt.distX=we(vt)?Math.abs(vt)-Zt:Number.MAX_VALUE})(Ke,Ze);let qe=(Ke[Ce]||0)-(Ze[Ce]||0)+(Qe&&Ze.marker?.radius||0),nt=qe<0?"left":"right",lt=qe<0?"right":"left";return Ie[nt]&&(De=(ce=rt(Ke,Ie[nt],Fe+1,je))[He]=0&&Le<=(me?me.len:te.plotHeight)&&Ee>=0&&Ee<=(se?se.len:te.plotWidth)}drawTracker(){let oe=this,te=oe.options,se=te.trackByArea,me=[].concat((se?oe.areaPath:oe.graphPath)||[]),Ee=oe.chart,Le=Ee.pointer,He=Ee.renderer,ze=Ee.options.tooltip?.snap||0,Qe=()=>{te.enableMouseTracking&&Ee.hoverSeries!==oe&&oe.onMouseOver()},rt="rgba(192,192,192,"+(O?1e-4:.002)+")",Ke=oe.tracker;Ke?Ke.attr({d:me}):oe.graph&&(oe.tracker=Ke=He.path(me).attr({visibility:oe.visible?"inherit":"hidden",zIndex:2}).addClass(se?"highcharts-tracker-area":"highcharts-tracker-line").add(oe.group),Ee.styledMode||Ke.attr({"stroke-linecap":"round","stroke-linejoin":"round",stroke:rt,fill:se?rt:"none","stroke-width":oe.graph.strokeWidth()+(se?0:2*ze)}),[oe.tracker,oe.markerGroup,oe.dataLabelsGroup].forEach(Ie=>{Ie&&(Ie.addClass("highcharts-tracker").on("mouseover",Qe).on("mouseout",Fe=>{Le?.onTrackerMouseOut(Fe)}),te.cursor&&!Ee.styledMode&&Ie.css({cursor:te.cursor}),Ie.on("touchstart",Qe))})),ue(this,"afterDrawTracker")}addPoint(oe,te,se,me,Ee){let Le,He,ze=this.options,Qe=this.data,rt=this.chart,Ke=this.xAxis,Ie=Ke&&Ke.hasNames&&Ke.names,Fe=ze.data,je=this.xData;te=Be(te,!0);let Ze={series:this};this.pointClass.prototype.applyOptions.apply(Ze,[oe]);let Ce=Ze.x;if(He=je.length,this.requireSorting&&CeCe;)He--;this.updateParallelArrays(Ze,"splice",[He,0,0]),this.updateParallelArrays(Ze,He),Ie&&Ze.name&&(Ie[Ce]=Ze.name),Fe.splice(He,0,oe),(Le||this.processedData)&&(this.data.splice(He,0,null),this.processData()),ze.legendType==="point"&&this.generatePoints(),se&&(Qe[0]&&Qe[0].remove?Qe[0].remove(!1):(Qe.shift(),this.updateParallelArrays(Ze,"shift"),Fe.shift())),Ee!==!1&&ue(this,"addPoint",{point:Ze}),this.isDirty=!0,this.isDirtyData=!0,te&&rt.redraw(me)}removePoint(oe,te,se){let me=this,Ee=me.data,Le=Ee[oe],He=me.points,ze=me.chart,Qe=function(){He&&He.length===Ee.length&&He.splice(oe,1),Ee.splice(oe,1),me.options.data.splice(oe,1),me.updateParallelArrays(Le||{series:me},"splice",[oe,1]),Le&&Le.destroy(),me.isDirty=!0,me.isDirtyData=!0,te&&ze.redraw()};T(se,ze),te=Be(te,!0),Le?Le.firePointEvent("remove",null,Qe):Qe()}remove(oe,te,se,me){let Ee=this,Le=Ee.chart;function He(){Ee.destroy(me),Le.isDirtyLegend=Le.isDirtyBox=!0,Le.linkSeries(me),Be(oe,!0)&&Le.redraw(te)}se!==!1?ue(Ee,"remove",null,He):He()}update(oe,te){ue(this,"update",{options:oe=_e(oe,this.userOptions)});let se=this,me=se.chart,Ee=se.userOptions,Le=se.initialType||se.type,He=me.options.plotOptions,ze=ee[Le].prototype,Qe=se.finishedAnimating&&{animation:!1},rt={},Ke,Ie,Fe=["colorIndex","eventOptions","navigatorSeries","symbolIndex","baseSeries"],je=oe.type||Ee.type||me.options.chart.type,Ze=!(this.hasDerivedData||je&&je!==this.type||oe.pointStart!==void 0||oe.pointInterval!==void 0||oe.relativeXValue!==void 0||oe.joinBy||oe.mapData||["dataGrouping","pointStart","pointInterval","pointIntervalUnit","keys"].some(ce=>se.hasOptionChanged(ce)));je=je||Le,Ze&&(Fe.push("data","isDirtyData","isDirtyCanvas","points","processedData","processedXData","processedYData","xIncrement","cropped","_hasPointMarkers","hasDataLabels","nodes","layout","level","mapMap","mapData","minY","maxY","minX","maxX","transformGroups"),oe.visible!==!1&&Fe.push("area","graph"),se.parallelArrays.forEach(function(ce){Fe.push(ce+"Data")}),oe.data&&(oe.dataSorting&&ie(se.options.dataSorting,oe.dataSorting),this.setData(oe.data,!1))),oe=Ue(Ee,{index:Ee.index===void 0?se.index:Ee.index,pointStart:He?.series?.pointStart??Ee.pointStart??se.xData?.[0]},!Ze&&{data:se.options.data},oe,Qe),Ze&&oe.data&&(oe.data=se.options.data),(Fe=["group","markerGroup","dataLabelsGroup","transformGroup"].concat(Fe)).forEach(function(ce){Fe[ce]=se[ce],delete se[ce]});let Ce=!1;if(ee[je]){if(Ce=je!==se.type,se.remove(!1,!1,!1,!0),Ce)if(me.propFromSeries(),Object.setPrototypeOf)Object.setPrototypeOf(se,ee[je].prototype);else{let ce=Object.hasOwnProperty.call(se,"hcEvents")&&se.hcEvents;for(Ie in ze)se[Ie]=void 0;ie(se,ee[je].prototype),ce?se.hcEvents=ce:delete se.hcEvents}}else ae(17,!0,me,{missingModuleFor:je});if(Fe.forEach(function(ce){se[ce]=Fe[ce]}),se.init(me,oe),Ze&&this.points)for(let ce of((Ke=se.options).visible===!1?(rt.graphic=1,rt.dataLabel=1):(this.hasMarkerChanged(Ke,Ee)&&(rt.graphic=1),se.hasDataLabels?.()||(rt.dataLabel=1)),this.points))ce&&ce.series&&(ce.resolveColor(),Object.keys(rt).length&&ce.destroyElements(rt),Ke.showInLegend===!1&&ce.legendItem&&me.legend.destroyItem(ce));se.initialType=Le,me.linkSeries(),me.setSortedData(),Ce&&se.linkedSeries.length&&(se.isDirtyData=!0),ue(this,"afterUpdate"),Be(te,!0)&&me.redraw(!!Ze&&void 0)}setName(oe){this.name=this.options.name=this.userOptions.name=oe,this.chart.isDirtyLegend=!0}hasOptionChanged(oe){let te=this.chart,se=this.options[oe],me=te.options.plotOptions,Ee=this.userOptions[oe],Le=Be(me?.[this.type]?.[oe],me?.series?.[oe]);return Ee&&!we(Le)?se!==Ee:se!==Be(Le,se)}onMouseOver(){let oe=this.chart,te=oe.hoverSeries;oe.pointer?.setHoverChartIndex(),te&&te!==this&&te.onMouseOut(),this.options.events.mouseOver&&ue(this,"mouseOver"),this.setState("hover"),oe.hoverSeries=this}onMouseOut(){let oe=this.options,te=this.chart,se=te.tooltip,me=te.hoverPoint;te.hoverSeries=null,me&&me.onMouseOut(),this&&oe.events.mouseOut&&ue(this,"mouseOut"),se&&!this.stickyTracking&&(!se.shared||this.noSharedTooltip)&&se.hide(),te.series.forEach(function(Ee){Ee.setState("",!0)})}setState(oe,te){let se=this,me=se.options,Ee=se.graph,Le=me.inactiveOtherPoints,He=me.states,ze=Be(He[oe||"normal"]&&He[oe||"normal"].animation,se.chart.options.chart.animation),Qe=me.lineWidth,rt=me.opacity;if(oe=oe||"",se.state!==oe&&([se.group,se.markerGroup,se.dataLabelsGroup].forEach(function(Ke){Ke&&(se.state&&Ke.removeClass("highcharts-series-"+se.state),oe&&Ke.addClass("highcharts-series-"+oe))}),se.state=oe,!se.chart.styledMode)){if(He[oe]&&He[oe].enabled===!1)return;if(oe&&(Qe=He[oe].lineWidth||Qe+(He[oe].lineWidthPlus||0),rt=Be(He[oe].opacity,rt)),Ee&&!Ee.dashstyle&&We(Qe))for(let Ke of[Ee,...this.zones.map(Ie=>Ie.graph)])Ke?.animate({"stroke-width":Qe},ze);Le||[se.group,se.markerGroup,se.dataLabelsGroup,se.labelBySeries].forEach(function(Ke){Ke&&Ke.animate({opacity:rt},ze)})}te&&Le&&se.points&&se.setAllPointsToState(oe||void 0)}setAllPointsToState(oe){this.points.forEach(function(te){te.setState&&te.setState(oe)})}setVisible(oe,te){let se=this,me=se.chart,Ee=me.options.chart.ignoreHiddenSeries,Le=se.visible;se.visible=oe=se.options.visible=se.userOptions.visible=oe===void 0?!Le:oe;let He=oe?"show":"hide";["group","dataLabelsGroup","markerGroup","tracker","tt"].forEach(ze=>{se[ze]?.[He]()}),(me.hoverSeries===se||me.hoverPoint?.series===se)&&se.onMouseOut(),se.legendItem&&me.legend.colorizeItem(se,oe),se.isDirty=!0,se.options.stacking&&me.series.forEach(ze=>{ze.options.stacking&&ze.visible&&(ze.isDirty=!0)}),se.linkedSeries.forEach(ze=>{ze.setVisible(oe,!1)}),Ee&&(me.isDirtyBox=!0),ue(se,He),te!==!1&&me.redraw()}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}select(oe){this.selected=oe=this.options.selected=oe===void 0?!this.selected:oe,this.checkbox&&(this.checkbox.checked=oe),ue(this,oe?"select":"unselect")}shouldShowTooltip(oe,te,se={}){return se.series=this,se.visiblePlotOnly=!0,this.chart.isInsidePlot(oe,te,se)}drawLegendSymbol(oe,te){u[this.options.legendSymbol||"rectangle"]?.call(this,oe,te)}}return $e.defaultOptions=b,$e.types=x.seriesTypes,$e.registerType=x.registerSeriesType,ie($e.prototype,{axisTypes:["xAxis","yAxis"],coll:"series",colorCounter:0,directTouch:!1,invertible:!0,isCartesian:!0,kdAxisArray:["clientX","plotY"],parallelArrays:["x","y"],pointClass:g,requireSorting:!0,sorted:!0}),x.series=$e,$e}),n(r,"Core/Chart/Chart.js",[r["Core/Animation/AnimationUtilities.js"],r["Core/Axis/Axis.js"],r["Core/Defaults.js"],r["Core/Templating.js"],r["Core/Foundation.js"],r["Core/Globals.js"],r["Core/Renderer/RendererRegistry.js"],r["Core/Series/Series.js"],r["Core/Series/SeriesRegistry.js"],r["Core/Renderer/SVG/SVGRenderer.js"],r["Core/Time.js"],r["Core/Utilities.js"],r["Core/Renderer/HTML/AST.js"],r["Core/Axis/Tick.js"]],function(o,a,l,c,u,g,b,x,S,$,k,T,D,I){let{animate:O,animObject:N,setAnimation:ee}=o,{defaultOptions:ne,defaultTime:B}=l,{numberFormat:le}=c,{registerEventOptions:fe}=u,{charts:xe,doc:we,marginNames:he,svg:_e,win:ve}=g,{seriesTypes:ae}=S,{addEvent:ie,attr:pe,createElement:ue,css:ge,defined:ye,diffObjects:Ae,discardElement:Re,erase:We,error:Pe,extend:Ue,find:Oe,fireEvent:Be,getStyle:Ye,isArray:Se,isNumber:Te,isObject:$e,isString:Ve,merge:oe,objectEach:te,pick:se,pInt:me,relativeLength:Ee,removeEvent:Le,splat:He,syncTimeout:ze,uniqueKey:Qe}=T;class rt{static chart(Ie,Fe,je){return new rt(Ie,Fe,je)}constructor(Ie,Fe,je){this.sharedClips={};let Ze=[...arguments];(Ve(Ie)||Ie.nodeName)&&(this.renderTo=Ze.shift()),this.init(Ze[0],Ze[1])}setZoomOptions(){let Ie=this.options.chart,Fe=Ie.zooming;this.zooming={...Fe,type:se(Ie.zoomType,Fe.type),key:se(Ie.zoomKey,Fe.key),pinchType:se(Ie.pinchType,Fe.pinchType),singleTouch:se(Ie.zoomBySingleTouch,Fe.singleTouch,!1),resetButton:oe(Fe.resetButton,Ie.resetZoomButton)}}init(Ie,Fe){Be(this,"init",{args:arguments},function(){let je=oe(ne,Ie),Ze=je.chart;this.userOptions=Ue({},Ie),this.margin=[],this.spacing=[],this.labelCollectors=[],this.callback=Fe,this.isResizing=0,this.options=je,this.axes=[],this.series=[],this.time=Ie.time&&Object.keys(Ie.time).length?new k(Ie.time):g.time,this.numberFormatter=Ze.numberFormatter||le,this.styledMode=Ze.styledMode,this.hasCartesianSeries=Ze.showAxes,this.index=xe.length,xe.push(this),g.chartCount++,fe(this,Ze),this.xAxis=[],this.yAxis=[],this.pointCount=this.colorCounter=this.symbolCounter=0,this.setZoomOptions(),Be(this,"afterInit"),this.firstRender()})}initSeries(Ie){let Fe=this.options.chart,je=Ie.type||Fe.type,Ze=ae[je];Ze||Pe(17,!0,this,{missingModuleFor:je});let Ce=new Ze;return typeof Ce.init=="function"&&Ce.init(this,Ie),Ce}setSortedData(){this.getSeriesOrderByLinks().forEach(function(Ie){Ie.points||Ie.data||!Ie.enabledDataSorting||Ie.setData(Ie.options.data,!1)})}getSeriesOrderByLinks(){return this.series.concat().sort(function(Ie,Fe){return Ie.linkedSeries.length||Fe.linkedSeries.length?Fe.linkedSeries.length-Ie.linkedSeries.length:0})}orderItems(Ie,Fe=0){let je=this[Ie],Ze=this.options[Ie]=He(this.options[Ie]).slice(),Ce=this.userOptions[Ie]=this.userOptions[Ie]?He(this.userOptions[Ie]).slice():[];if(this.hasRendered&&(Ze.splice(Fe),Ce.splice(Fe)),je)for(let ce=Fe,de=je.length;ce=Math.max(qe+ce,vt.pos)&&Nt<=Math.min(qe+ce+pt.width,vt.pos+vt.len)||(Et.isInsidePlot=!1)}if(!je.ignoreY&&Et.isInsidePlot){let vt=!Ze&&je.axis&&!je.axis.isXAxis&&je.axis||lt&&(Ze?lt.xAxis:lt.yAxis)||{pos:de,len:1/0},Nt=je.paneCoordinates?vt.pos+St:de+St;Nt>=Math.max(nt+de,vt.pos)&&Nt<=Math.min(nt+de+pt.height,vt.pos+vt.len)||(Et.isInsidePlot=!1)}return Be(this,"afterIsInsidePlot",Et),Et.isInsidePlot}redraw(Ie){Be(this,"beforeRedraw");let Fe=this.hasCartesianSeries?this.axes:this.colorAxis||[],je=this.series,Ze=this.pointer,Ce=this.legend,ce=this.userOptions.legend,de=this.renderer,De=de.isHidden(),qe=[],nt,lt,pt,bt=this.isDirtyBox,St=this.isDirtyLegend,Et;for(de.rootFontSize=de.boxWrapper.getStyle("font-size"),this.setResponsive&&this.setResponsive(!1),ee(!!this.hasRendered&&Ie,this),De&&this.temporaryDisplay(),this.layOutTitles(!1),pt=je.length;pt--;)if(((Et=je[pt]).options.stacking||Et.options.centerInCategory)&&(lt=!0,Et.isDirty)){nt=!0;break}if(nt)for(pt=je.length;pt--;)(Et=je[pt]).options.stacking&&(Et.isDirty=!0);je.forEach(function(vt){vt.isDirty&&(vt.options.legendType==="point"?(typeof vt.updateTotals=="function"&&vt.updateTotals(),St=!0):ce&&(ce.labelFormatter||ce.labelFormat)&&(St=!0)),vt.isDirtyData&&Be(vt,"updatedData")}),St&&Ce&&Ce.options.enabled&&(Ce.render(),this.isDirtyLegend=!1),lt&&this.getStacks(),Fe.forEach(function(vt){vt.updateNames(),vt.setScale()}),this.getMargins(),Fe.forEach(function(vt){vt.isDirty&&(bt=!0)}),Fe.forEach(function(vt){let Nt=vt.min+","+vt.max;vt.extKey!==Nt&&(vt.extKey=Nt,qe.push(function(){Be(vt,"afterSetExtremes",Ue(vt.eventArgs,vt.getExtremes())),delete vt.eventArgs})),(bt||lt)&&vt.redraw()}),bt&&this.drawChartBox(),Be(this,"predraw"),je.forEach(function(vt){(bt||vt.isDirty)&&vt.visible&&vt.redraw(),vt.isDirtyData=!1}),Ze&&Ze.reset(!0),de.draw(),Be(this,"redraw"),Be(this,"render"),De&&this.temporaryDisplay(!0),qe.forEach(function(vt){vt.call()})}get(Ie){let Fe=this.series;function je(Ce){return Ce.id===Ie||Ce.options&&Ce.options.id===Ie}let Ze=Oe(this.axes,je)||Oe(this.series,je);for(let Ce=0;!Ze&&Ce(Fe.getPointsCollection().forEach(je=>{se(je.selectedStaging,je.selected)&&Ie.push(je)}),Ie),[])}getSelectedSeries(){return this.series.filter(function(Ie){return Ie.selected})}setTitle(Ie,Fe,je){this.applyDescription("title",Ie),this.applyDescription("subtitle",Fe),this.applyDescription("caption",void 0),this.layOutTitles(je)}applyDescription(Ie,Fe){let je=this,Ze=this.options[Ie]=oe(this.options[Ie],Fe),Ce=this[Ie];Ce&&Fe&&(this[Ie]=Ce=Ce.destroy()),Ze&&!Ce&&((Ce=this.renderer.text(Ze.text,0,0,Ze.useHTML).attr({align:Ze.align,class:"highcharts-"+Ie,zIndex:Ze.zIndex||4}).add()).update=function(ce,de){je.applyDescription(Ie,ce),je.layOutTitles(de)},this.styledMode||Ce.css(Ue(Ie==="title"?{fontSize:this.options.isStock?"1em":"1.2em"}:{},Ze.style)),this[Ie]=Ce)}layOutTitles(Ie=!0){let Fe=[0,0,0],je=this.renderer,Ze=this.spacingBox;["title","subtitle","caption"].forEach(function(ce){let de=this[ce],De=this.options[ce],qe=De.verticalAlign||"top",nt=ce==="title"?qe==="top"?-3:0:qe==="top"?Fe[0]+2:0;if(de){de.css({width:(De.width||Ze.width+(De.widthAdjust||0))+"px"});let lt=je.fontMetrics(de).b,pt=Math.round(de.getBBox(De.useHTML).height);de.align(Ue({y:qe==="bottom"?lt:nt+lt,height:pt},De),!1,"spacingBox"),De.floating||(qe==="top"?Fe[0]=Math.ceil(Fe[0]+pt):qe==="bottom"&&(Fe[2]=Math.ceil(Fe[2]+pt)))}},this),Fe[0]&&(this.options.title.verticalAlign||"top")==="top"&&(Fe[0]+=this.options.title.margin),Fe[2]&&this.options.caption.verticalAlign==="bottom"&&(Fe[2]+=this.options.caption.margin);let Ce=!this.titleOffset||this.titleOffset.join(",")!==Fe.join(",");this.titleOffset=Fe,Be(this,"afterLayOutTitles"),!this.isDirtyBox&&Ce&&(this.isDirtyBox=this.isDirtyLegend=Ce,this.hasRendered&&Ie&&this.isDirtyBox&&this.redraw())}getContainerBox(){return{width:Ye(this.renderTo,"width",!0)||0,height:Ye(this.renderTo,"height",!0)||0}}getChartSize(){let Ie=this.options.chart,Fe=Ie.width,je=Ie.height,Ze=this.getContainerBox();this.chartWidth=Math.max(0,Fe||Ze.width||600),this.chartHeight=Math.max(0,Ee(je,this.chartWidth)||(Ze.height>1?Ze.height:400)),this.containerBox=Ze}temporaryDisplay(Ie){let Fe=this.renderTo,je;if(Ie)for(;Fe&&Fe.style;)Fe.hcOrigStyle&&(ge(Fe,Fe.hcOrigStyle),delete Fe.hcOrigStyle),Fe.hcOrigDetached&&(we.body.removeChild(Fe),Fe.hcOrigDetached=!1),Fe=Fe.parentNode;else for(;Fe&&Fe.style&&(we.body.contains(Fe)||Fe.parentNode||(Fe.hcOrigDetached=!0,we.body.appendChild(Fe)),(Ye(Fe,"display",!1)==="none"||Fe.hcOricDetached)&&(Fe.hcOrigStyle={display:Fe.style.display,height:Fe.style.height,overflow:Fe.style.overflow},je={display:"block",overflow:"hidden"},Fe!==this.renderTo&&(je.height=0),ge(Fe,je),Fe.offsetWidth||Fe.style.setProperty("display","block","important")),(Fe=Fe.parentNode)!==we.body););}setClassName(Ie){this.container.className="highcharts-container "+(Ie||"")}getContainer(){let Ie=this.options,Fe=Ie.chart,je="data-highcharts-chart",Ze=Qe(),Ce,ce=this.renderTo;ce||(this.renderTo=ce=Fe.renderTo),Ve(ce)&&(this.renderTo=ce=we.getElementById(ce)),ce||Pe(13,!0,this);let de=me(pe(ce,je));Te(de)&&xe[de]&&xe[de].hasRendered&&xe[de].destroy(),pe(ce,je,this.index),ce.innerHTML=D.emptyHTML,Fe.skipClone||ce.offsetWidth||this.temporaryDisplay(),this.getChartSize();let De=this.chartHeight,qe=this.chartWidth;ge(ce,{overflow:"hidden"}),this.styledMode||(Ce=Ue({position:"relative",overflow:"hidden",width:qe+"px",height:De+"px",textAlign:"left",lineHeight:"normal",zIndex:0,"-webkit-tap-highlight-color":"rgba(0,0,0,0)",userSelect:"none","touch-action":"manipulation",outline:"none"},Fe.style||{}));let nt=ue("div",{id:Ze},Ce,ce);this.container=nt,this.getChartSize(),qe===this.chartWidth||(qe=this.chartWidth,this.styledMode||ge(nt,{width:se(Fe.style?.width,qe+"px")})),this.containerBox=this.getContainerBox(),this._cursor=nt.style.cursor;let lt=Fe.renderer||!_e?b.getRendererType(Fe.renderer):$;if(this.renderer=new lt(nt,qe,De,void 0,Fe.forExport,Ie.exporting&&Ie.exporting.allowHTML,this.styledMode),ee(void 0,this),this.setClassName(Fe.className),this.styledMode)for(let pt in Ie.defs)this.renderer.definition(Ie.defs[pt]);else this.renderer.setStyle(Fe.style);this.renderer.chartIndex=this.index,Be(this,"afterGetContainer")}getMargins(Ie){let{spacing:Fe,margin:je,titleOffset:Ze}=this;this.resetMargins(),Ze[0]&&!ye(je[0])&&(this.plotTop=Math.max(this.plotTop,Ze[0]+Fe[0])),Ze[2]&&!ye(je[2])&&(this.marginBottom=Math.max(this.marginBottom,Ze[2]+Fe[2])),this.legend&&this.legend.display&&this.legend.adjustMargins(je,Fe),Be(this,"getMargins"),Ie||this.getAxisMargins()}getAxisMargins(){let Ie=this,Fe=Ie.axisOffset=[0,0,0,0],je=Ie.colorAxis,Ze=Ie.margin,Ce=function(ce){ce.forEach(function(de){de.visible&&de.getOffset()})};Ie.hasCartesianSeries?Ce(Ie.axes):je&&je.length&&Ce(je),he.forEach(function(ce,de){ye(Ze[de])||(Ie[ce]+=Fe[de])}),Ie.setChartSize()}getOptions(){return Ae(this.userOptions,ne)}reflow(Ie){let Fe=this,je=Fe.containerBox,Ze=Fe.getContainerBox();delete Fe.pointer?.chartPosition,!Fe.isPrinting&&!Fe.isResizing&&je&&Ze.width&&((Ze.width!==je.width||Ze.height!==je.height)&&(T.clearTimeout(Fe.reflowTimeout),Fe.reflowTimeout=ze(function(){Fe.container&&Fe.setSize(void 0,void 0,!1)},Ie?100:0)),Fe.containerBox=Ze)}setReflow(){let Ie=this,Fe=je=>{Ie.options?.chart.reflow&&Ie.hasLoaded&&Ie.reflow(je)};if(typeof ResizeObserver=="function")new ResizeObserver(Fe).observe(Ie.renderTo);else{let je=ie(ve,"resize",Fe);ie(this,"destroy",je)}}setSize(Ie,Fe,je){let Ze=this,Ce=Ze.renderer;Ze.isResizing+=1,ee(je,Ze);let ce=Ce.globalAnimation;Ze.oldChartHeight=Ze.chartHeight,Ze.oldChartWidth=Ze.chartWidth,Ie!==void 0&&(Ze.options.chart.width=Ie),Fe!==void 0&&(Ze.options.chart.height=Fe),Ze.getChartSize();let{chartWidth:de,chartHeight:De,scrollablePixelsX:qe=0,scrollablePixelsY:nt=0}=Ze;(Ze.isDirtyBox||de!==Ze.oldChartWidth||De!==Ze.oldChartHeight)&&(Ze.styledMode||(ce?O:ge)(Ze.container,{width:`${de+qe}px`,height:`${De+nt}px`},ce),Ze.setChartSize(!0),Ce.setSize(de,De,ce),Ze.axes.forEach(function(lt){lt.isDirty=!0,lt.setScale()}),Ze.isDirtyLegend=!0,Ze.isDirtyBox=!0,Ze.layOutTitles(),Ze.getMargins(),Ze.redraw(ce),Ze.oldChartHeight=void 0,Be(Ze,"resize"),setTimeout(()=>{Ze&&Be(Ze,"endResize")},N(ce).duration)),Ze.isResizing-=1}setChartSize(Ie){let Fe,je,Ze,Ce,{chartHeight:ce,chartWidth:de,inverted:De,spacing:qe,renderer:nt}=this,lt=this.clipOffset,pt=Math[De?"floor":"round"];this.plotLeft=Fe=Math.round(this.plotLeft),this.plotTop=je=Math.round(this.plotTop),this.plotWidth=Ze=Math.max(0,Math.round(de-Fe-this.marginRight)),this.plotHeight=Ce=Math.max(0,Math.round(ce-je-this.marginBottom)),this.plotSizeX=De?Ce:Ze,this.plotSizeY=De?Ze:Ce,this.spacingBox=nt.spacingBox={x:qe[3],y:qe[0],width:de-qe[3]-qe[1],height:ce-qe[0]-qe[2]},this.plotBox=nt.plotBox={x:Fe,y:je,width:Ze,height:Ce},lt&&(this.clipBox={x:pt(lt[3]),y:pt(lt[0]),width:pt(this.plotSizeX-lt[1]-lt[3]),height:pt(this.plotSizeY-lt[0]-lt[2])}),Ie||(this.axes.forEach(function(bt){bt.setAxisSize(),bt.setAxisTranslation()}),nt.alignElements()),Be(this,"afterSetChartSize",{skipAxes:Ie})}resetMargins(){Be(this,"resetMargins");let Ie=this,Fe=Ie.options.chart,je=Fe.plotBorderWidth||0,Ze=je/2;["margin","spacing"].forEach(function(Ce){let ce=Fe[Ce],de=$e(ce)?ce:[ce,ce,ce,ce];["Top","Right","Bottom","Left"].forEach(function(De,qe){Ie[Ce][qe]=se(Fe[Ce+De],de[qe])})}),he.forEach(function(Ce,ce){Ie[Ce]=se(Ie.margin[ce],Ie.spacing[ce])}),Ie.axisOffset=[0,0,0,0],Ie.clipOffset=[Ze,Ze,Ze,Ze],Ie.plotBorderWidth=je}drawChartBox(){let Ie=this.options.chart,Fe=this.renderer,je=this.chartWidth,Ze=this.chartHeight,Ce=this.styledMode,ce=this.plotBGImage,de=Ie.backgroundColor,De=Ie.plotBackgroundColor,qe=Ie.plotBackgroundImage,nt=this.plotLeft,lt=this.plotTop,pt=this.plotWidth,bt=this.plotHeight,St=this.plotBox,Et=this.clipRect,vt=this.clipBox,Nt=this.chartBackground,Ft=this.plotBackground,qt=this.plotBorder,Zt,mr,nr,ur="animate";Nt||(this.chartBackground=Nt=Fe.rect().addClass("highcharts-background").add(),ur="attr"),Ce?Zt=mr=Nt.strokeWidth():(mr=(Zt=Ie.borderWidth||0)+(Ie.shadow?8:0),nr={fill:de||"none"},(Zt||Nt["stroke-width"])&&(nr.stroke=Ie.borderColor,nr["stroke-width"]=Zt),Nt.attr(nr).shadow(Ie.shadow)),Nt[ur]({x:mr/2,y:mr/2,width:je-mr-Zt%2,height:Ze-mr-Zt%2,r:Ie.borderRadius}),ur="animate",Ft||(ur="attr",this.plotBackground=Ft=Fe.rect().addClass("highcharts-plot-background").add()),Ft[ur](St),!Ce&&(Ft.attr({fill:De||"none"}).shadow(Ie.plotShadow),qe&&(ce?(qe!==ce.attr("href")&&ce.attr("href",qe),ce.animate(St)):this.plotBGImage=Fe.image(qe,nt,lt,pt,bt).add())),Et?Et.animate({width:vt.width,height:vt.height}):this.clipRect=Fe.clipRect(vt),ur="animate",qt||(ur="attr",this.plotBorder=qt=Fe.rect().addClass("highcharts-plot-border").attr({zIndex:1}).add()),Ce||qt.attr({stroke:Ie.plotBorderColor,"stroke-width":Ie.plotBorderWidth||0,fill:"none"}),qt[ur](qt.crisp({x:nt,y:lt,width:pt,height:bt},-qt.strokeWidth())),this.isDirtyBox=!1,Be(this,"afterDrawChartBox")}propFromSeries(){let Ie,Fe,je,Ze=this,Ce=Ze.options.chart,ce=Ze.options.series;["inverted","angular","polar"].forEach(function(de){for(Fe=ae[Ce.type],je=Ce[de]||Fe&&Fe.prototype[de],Ie=ce&&ce.length;!je&&Ie--;)(Fe=ae[ce[Ie].type])&&Fe.prototype[de]&&(je=!0);Ze[de]=je})}linkSeries(Ie){let Fe=this,je=Fe.series;je.forEach(function(Ze){Ze.linkedSeries.length=0}),je.forEach(function(Ze){let{linkedTo:Ce}=Ze.options;if(Ve(Ce)){let ce;(ce=Ce===":previous"?Fe.series[Ze.index-1]:Fe.get(Ce))&&ce.linkedParent!==Ze&&(ce.linkedSeries.push(Ze),Ze.linkedParent=ce,ce.enabledDataSorting&&Ze.setDataSortingOptions(),Ze.visible=se(Ze.options.visible,ce.options.visible,Ze.visible))}}),Be(this,"afterLinkSeries",{isUpdating:Ie})}renderSeries(){this.series.forEach(function(Ie){Ie.translate(),Ie.render()})}render(){let Ie=this.axes,Fe=this.colorAxis,je=this.renderer,Ze=this.options.chart.axisLayoutRuns||2,Ce=nt=>{nt.forEach(lt=>{lt.visible&<.render()})},ce=0,de=!0,De,qe=0;for(let nt of(this.setTitle(),Be(this,"beforeMargins"),this.getStacks?.(),this.getMargins(!0),this.setChartSize(),Ie)){let{options:lt}=nt,{labels:pt}=lt;if(this.hasCartesianSeries&&nt.horiz&&nt.visible&&pt.enabled&&nt.series.length&&nt.coll!=="colorAxis"&&!this.polar){ce=lt.tickLength,nt.createGroups();let bt=new I(nt,0,"",!0),St=bt.createLabel("x",pt);if(bt.destroy(),St&&se(pt.reserveSpace,!Te(lt.crossing))&&(ce=St.getBBox().height+pt.distance+Math.max(lt.offset||0,0)),ce){St?.destroy();break}}}for(this.plotHeight=Math.max(this.plotHeight-ce,0);(de||De||Ze>1)&&qe(qe?1:1.1),De=lt/this.plotHeight>(qe?1:1.05),qe++}this.drawChartBox(),this.hasCartesianSeries?Ce(Ie):Fe&&Fe.length&&Ce(Fe),this.seriesGroup||(this.seriesGroup=je.g("series-group").attr({zIndex:3}).shadow(this.options.chart.seriesGroupShadow).add()),this.renderSeries(),this.addCredits(),this.setResponsive&&this.setResponsive(),this.hasRendered=!0}addCredits(Ie){let Fe=this,je=oe(!0,this.options.credits,Ie);je.enabled&&!this.credits&&(this.credits=this.renderer.text(je.text+(this.mapCredits||""),0,0).addClass("highcharts-credits").on("click",function(){je.href&&(ve.location.href=je.href)}).attr({align:je.position.align,zIndex:8}),Fe.styledMode||this.credits.css(je.style),this.credits.add().align(je.position),this.credits.update=function(Ze){Fe.credits=Fe.credits.destroy(),Fe.addCredits(Ze)})}destroy(){let Ie,Fe=this,je=Fe.axes,Ze=Fe.series,Ce=Fe.container,ce=Ce&&Ce.parentNode;for(Be(Fe,"destroy"),Fe.renderer.forExport?We(xe,Fe):xe[Fe.index]=void 0,g.chartCount--,Fe.renderTo.removeAttribute("data-highcharts-chart"),Le(Fe),Ie=je.length;Ie--;)je[Ie]=je[Ie].destroy();for(this.scroller&&this.scroller.destroy&&this.scroller.destroy(),Ie=Ze.length;Ie--;)Ze[Ie]=Ze[Ie].destroy();["title","subtitle","chartBackground","plotBackground","plotBGImage","plotBorder","seriesGroup","clipRect","credits","pointer","rangeSelector","legend","resetZoomButton","tooltip","renderer"].forEach(function(de){let De=Fe[de];De&&De.destroy&&(Fe[de]=De.destroy())}),Ce&&(Ce.innerHTML=D.emptyHTML,Le(Ce),ce&&Re(Ce)),te(Fe,function(de,De){delete Fe[De]})}firstRender(){let Ie=this,Fe=Ie.options;Ie.getContainer(),Ie.resetMargins(),Ie.setChartSize(),Ie.propFromSeries(),Ie.getAxes();let je=Se(Fe.series)?Fe.series:[];Fe.series=[],je.forEach(function(Ze){Ie.initSeries(Ze)}),Ie.linkSeries(),Ie.setSortedData(),Be(Ie,"beforeRender"),Ie.render(),Ie.pointer?.getChartPosition(),Ie.renderer.imgCount||Ie.hasLoaded||Ie.onload(),Ie.temporaryDisplay(!0)}onload(){this.callbacks.concat([this.callback]).forEach(function(Ie){Ie&&this.index!==void 0&&Ie.apply(this,[this])},this),Be(this,"load"),Be(this,"render"),ye(this.index)&&this.setReflow(),this.warnIfA11yModuleNotLoaded(),this.hasLoaded=!0}warnIfA11yModuleNotLoaded(){let{options:Ie,title:Fe}=this;!Ie||this.accessibility||(this.renderer.boxWrapper.attr({role:"img","aria-label":(Fe&&Fe.element.textContent||"").replace(/this.transform({reset:!0,trigger:"zoom"}))}pan(Ie,Fe){let je=this,Ze=typeof Fe=="object"?Fe:{enabled:Fe,type:"x"},Ce=Ze.type,ce=Ce&&je[{x:"xAxis",xy:"axes",y:"yAxis"}[Ce]].filter(De=>De.options.panningEnabled&&!De.options.isInternal),de=je.options.chart;de?.panning&&(de.panning=Ze),Be(this,"pan",{originalEvent:Ie},()=>{je.transform({axes:ce,event:Ie,to:{x:Ie.chartX-(je.mouseDownX||0),y:Ie.chartY-(je.mouseDownY||0)},trigger:"pan"}),ge(je.container,{cursor:"move"})})}transform(Ie){let{axes:Fe=this.axes,event:je,from:Ze={},reset:Ce,selection:ce,to:de={},trigger:De}=Ie,{inverted:qe}=this,nt=!1,lt;for(let pt of(this.hoverPoints?.forEach(bt=>bt.setState()),Fe)){let{horiz:bt,len:St,minPointOffset:Et=0,options:vt,reversed:Nt}=pt,Ft=bt?"width":"height",qt=bt?"x":"y",Zt=se(de[Ft],pt.len),mr=se(Ze[Ft],pt.len),nr=10>Math.abs(Zt)?1:Zt/mr,ur=(Ze[qt]||0)+mr/2-pt.pos,Mr=ur-((de[qt]??pt.pos)+Zt/2-pt.pos)/nr,Pr=Nt&&!qe||!Nt&&qe?-1:1;if(!Ce&&(ur<0||ur>pt.len))continue;let fr=pt.toValue(Mr,!0)+(ce?0:Et*Pr),hr=pt.toValue(Mr+St/nr,!0)-(ce?0:Et*Pr||0),$r=pt.allExtremes;if(fr>hr&&([fr,hr]=[hr,fr]),nr===1&&!Ce&&pt.coll==="yAxis"&&!$r){for(let ci of pt.series){let nn=ci.getExtremes(ci.getProcessedData(!0).yData,!0);$r??($r={dataMin:Number.MAX_VALUE,dataMax:-Number.MAX_VALUE}),Te(nn.dataMin)&&Te(nn.dataMax)&&($r.dataMin=Math.min(nn.dataMin,$r.dataMin),$r.dataMax=Math.max(nn.dataMax,$r.dataMax))}pt.allExtremes=$r}let{dataMin:Bi,dataMax:li,min:Mn,max:Sr}=Ue(pt.getExtremes(),$r||{}),Lt=Bi??vt.min,On=li??vt.max,Ur=hr-fr,Dn=pt.categories?0:Math.min(Ur,On-Lt),tn=Lt-Dn*(ye(vt.min)?0:vt.minPadding),rn=On+Dn*(ye(vt.max)?0:vt.maxPadding),Nn=pt.allowZoomOutside||nr===1||De!=="zoom"&&nr>1,Ir=Math.min(vt.min??tn,tn,Nn?Mn:tn),qr=Math.max(vt.max??rn,rn,Nn?Sr:rn);(!pt.isOrdinal||nr!==1||Ce)&&(fr=1&&(hr=fr+Ur)),hr>qr&&(hr=qr,nr>=1&&(fr=hr-Ur)),(Ce||pt.series.length&&(fr!==Mn||hr!==Sr)&&fr>=Ir&&hr<=qr)&&(ce?ce[pt.coll].push({axis:pt,min:fr,max:hr}):(pt.isPanning=De!=="zoom",pt.setExtremes(Ce?void 0:fr,Ce?void 0:hr,!1,!1,{move:Mr,trigger:De,scale:nr}),!Ce&&(fr>Ir||hr{delete Ie.selection,Ie.trigger="zoom",this.transform(Ie)}):(lt&&!this.resetZoomButton?this.showResetZoom():!lt&&this.resetZoomButton&&(this.resetZoomButton=this.resetZoomButton.destroy()),this.redraw(De==="zoom"&&(this.options.chart.animation??this.pointCount<100)))),nt}}return Ue(rt.prototype,{callbacks:[],collectionsWithInit:{xAxis:[rt.prototype.addAxis,[!0]],yAxis:[rt.prototype.addAxis,[!1]],series:[rt.prototype.addSeries]},collectionsWithUpdate:["xAxis","yAxis","series"],propsRequireDirtyBox:["backgroundColor","borderColor","borderWidth","borderRadius","plotBackgroundColor","plotBackgroundImage","plotBorderColor","plotBorderWidth","plotShadow","shadow"],propsRequireReflow:["margin","marginTop","marginRight","marginBottom","marginLeft","spacing","spacingTop","spacingRight","spacingBottom","spacingLeft"],propsRequireUpdateSeries:["chart.inverted","chart.polar","chart.ignoreHiddenSeries","chart.type","colors","plotOptions","time","tooltip"]}),rt}),n(r,"Extensions/ScrollablePlotArea.js",[r["Core/Animation/AnimationUtilities.js"],r["Core/Globals.js"],r["Core/Renderer/RendererRegistry.js"],r["Core/Utilities.js"]],function(o,a,l,c){let{stop:u}=o,{composed:g}=a,{addEvent:b,createElement:x,css:S,defined:$,merge:k,pushUnique:T}=c;function D(){let N=this.scrollablePlotArea;(this.scrollablePixelsX||this.scrollablePixelsY)&&!N&&(this.scrollablePlotArea=N=new O(this)),N?.applyFixed()}function I(){this.chart.scrollablePlotArea&&(this.chart.scrollablePlotArea.isDirty=!0)}class O{static compose(ee,ne,B){T(g,this.compose)&&(b(ee,"afterInit",I),b(ne,"afterSetChartSize",le=>this.afterSetSize(le.target,le)),b(ne,"render",D),b(B,"show",I))}static afterSetSize(ee,ne){let B,le,fe,{minWidth:xe,minHeight:we}=ee.options.chart.scrollablePlotArea||{},{clipBox:he,plotBox:_e,inverted:ve,renderer:ae}=ee;if(!ae.forExport&&(xe?(ee.scrollablePixelsX=B=Math.max(0,xe-ee.chartWidth),B&&(ee.scrollablePlotBox=k(ee.plotBox),_e.width=ee.plotWidth+=B,he[ve?"height":"width"]+=B,fe=!0)):we&&(ee.scrollablePixelsY=le=Math.max(0,we-ee.chartHeight),$(le)&&(ee.scrollablePlotBox=k(ee.plotBox),_e.height=ee.plotHeight+=le,he[ve?"width":"height"]+=le,fe=!1)),$(fe)&&!ne.skipAxes))for(let ie of ee.axes)ie.horiz===fe&&(ie.setAxisSize(),ie.setAxisTranslation())}constructor(ee){let ne,B=ee.options.chart,le=l.getRendererType(),fe=B.scrollablePlotArea||{},xe=this.moveFixedElements.bind(this),we={WebkitOverflowScrolling:"touch",overflowX:"hidden",overflowY:"hidden"};ee.scrollablePixelsX&&(we.overflowX="auto"),ee.scrollablePixelsY&&(we.overflowY="auto"),this.chart=ee;let he=this.parentDiv=x("div",{className:"highcharts-scrolling-parent"},{position:"relative"},ee.renderTo),_e=this.scrollingContainer=x("div",{className:"highcharts-scrolling"},we,he),ve=this.innerContainer=x("div",{className:"highcharts-inner-container"},void 0,_e),ae=this.fixedDiv=x("div",{className:"highcharts-fixed"},{position:"absolute",overflow:"hidden",pointerEvents:"none",zIndex:(B.style?.zIndex||0)+2,top:0},void 0,!0),ie=this.fixedRenderer=new le(ae,ee.chartWidth,ee.chartHeight,B.style);this.mask=ie.path().attr({fill:B.backgroundColor||"#fff","fill-opacity":fe.opacity??.85,zIndex:-1}).addClass("highcharts-scrollable-mask").add(),_e.parentNode.insertBefore(ae,_e),S(ee.renderTo,{overflow:"visible"}),b(ee,"afterShowResetZoom",xe),b(ee,"afterApplyDrilldown",xe),b(ee,"afterLayOutTitles",xe),b(_e,"scroll",()=>{let{pointer:pe,hoverPoint:ue}=ee;pe&&(delete pe.chartPosition,ue&&(ne=ue),pe.runPointActions(void 0,ne,!0))}),ve.appendChild(ee.container)}applyFixed(){let{chart:ee,fixedRenderer:ne,isDirty:B,scrollingContainer:le}=this,{axisOffset:fe,chartWidth:xe,chartHeight:we,container:he,plotHeight:_e,plotLeft:ve,plotTop:ae,plotWidth:ie,scrollablePixelsX:pe=0,scrollablePixelsY:ue=0}=ee,{scrollPositionX:ge=0,scrollPositionY:ye=0}=ee.options.chart.scrollablePlotArea||{},Ae=xe+pe,Re=we+ue;ne.setSize(xe,we),(B??!0)&&(this.isDirty=!1,this.moveFixedElements()),u(ee.container),S(he,{width:`${Ae}px`,height:`${Re}px`}),ee.renderer.boxWrapper.attr({width:Ae,height:Re,viewBox:[0,0,Ae,Re].join(" ")}),ee.chartBackground?.attr({width:Ae,height:Re}),S(le,{width:`${xe}px`,height:`${we}px`}),$(B)||(le.scrollLeft=pe*ge,le.scrollTop=ue*ye);let We=ae-fe[0]-1,Pe=ve-fe[3]-1,Ue=ae+_e+fe[2]+1,Oe=ve+ie+fe[1]+1,Be=ve+ie-pe,Ye=ae+_e-ue,Se=[["M",0,0]];pe?Se=[["M",0,We],["L",ve-1,We],["L",ve-1,Ue],["L",0,Ue],["Z"],["M",Be,We],["L",xe,We],["L",xe,Ue],["L",Be,Ue],["Z"]]:ue&&(Se=[["M",Pe,0],["L",Pe,ae-1],["L",Oe,ae-1],["L",Oe,0],["Z"],["M",Pe,Ye],["L",Pe,we],["L",Oe,we],["L",Oe,Ye],["Z"]]),ee.redrawTrigger!=="adjustHeight"&&this.mask.attr({d:Se})}moveFixedElements(){let ee,{container:ne,inverted:B,scrollablePixelsX:le,scrollablePixelsY:fe}=this.chart,xe=this.fixedRenderer,we=O.fixedSelectors;for(let he of(le&&!B?ee=".highcharts-yaxis":le&&B||fe&&!B?ee=".highcharts-xaxis":fe&&B&&(ee=".highcharts-yaxis"),ee&&we.push(`${ee}:not(.highcharts-radial-axis)`,`${ee}-labels:not(.highcharts-radial-axis-labels)`),we))[].forEach.call(ne.querySelectorAll(he),_e=>{(_e.namespaceURI===xe.SVG_NS?xe.box:xe.box.parentNode).appendChild(_e),_e.style.pointerEvents="auto"})}}return O.fixedSelectors=[".highcharts-breadcrumbs-group",".highcharts-contextbutton",".highcharts-caption",".highcharts-credits",".highcharts-drillup-button",".highcharts-legend",".highcharts-legend-checkbox",".highcharts-navigator-series",".highcharts-navigator-xaxis",".highcharts-navigator-yaxis",".highcharts-navigator",".highcharts-range-selector-group",".highcharts-reset-zoom",".highcharts-scrollbar",".highcharts-subtitle",".highcharts-title"],O}),n(r,"Core/Axis/Stacking/StackItem.js",[r["Core/Templating.js"],r["Core/Series/SeriesRegistry.js"],r["Core/Utilities.js"]],function(o,a,l){let{format:c}=o,{series:u}=a,{destroyObjectProperties:g,fireEvent:b,isNumber:x,pick:S}=l;return class{constructor($,k,T,D,I){let O=$.chart.inverted,N=$.reversed;this.axis=$;let ee=this.isNegative=!!T!=!!N;this.options=k=k||{},this.x=D,this.total=null,this.cumulative=null,this.points={},this.hasValidPoints=!1,this.stack=I,this.leftCliff=0,this.rightCliff=0,this.alignOptions={align:k.align||(O?ee?"left":"right":"center"),verticalAlign:k.verticalAlign||(O?"middle":ee?"bottom":"top"),y:k.y,x:k.x},this.textAlign=k.textAlign||(O?ee?"right":"left":"center")}destroy(){g(this,this.axis)}render($){let k=this.axis.chart,T=this.options,D=T.format,I=D?c(D,this,k):T.formatter.call(this);if(this.label)this.label.attr({text:I,visibility:"hidden"});else{this.label=k.renderer.label(I,null,void 0,T.shape,void 0,void 0,T.useHTML,!1,"stack-labels");let O={r:T.borderRadius||0,text:I,padding:S(T.padding,5),visibility:"hidden"};k.styledMode||(O.fill=T.backgroundColor,O.stroke=T.borderColor,O["stroke-width"]=T.borderWidth,this.label.css(T.style||{})),this.label.attr(O),this.label.added||this.label.add($)}this.label.labelrank=k.plotSizeY,b(this,"afterRender")}setOffset($,k,T,D,I,O){let{alignOptions:N,axis:ee,label:ne,options:B,textAlign:le}=this,fe=ee.chart,xe=this.getStackBox({xOffset:$,width:k,boxBottom:T,boxTop:D,defaultX:I,xAxis:O}),{verticalAlign:we}=N;if(ne&&xe){let he=ne.getBBox(void 0,0),_e=ne.padding,ve=S(B.overflow,"justify")==="justify",ae;N.x=B.x||0,N.y=B.y||0;let{x:ie,y:pe}=this.adjustStackPosition({labelBox:he,verticalAlign:we,textAlign:le});xe.x-=ie,xe.y-=pe,ne.align(N,!1,xe),(ae=fe.isInsidePlot(ne.alignAttr.x+N.x+ie,ne.alignAttr.y+N.y+pe))||(ve=!1),ve&&u.prototype.justifyDataLabel.call(ee,ne,N,ne.alignAttr,he,xe),ne.attr({x:ne.alignAttr.x,y:ne.alignAttr.y,rotation:B.rotation,rotationOriginX:he.width*{left:0,center:.5,right:1}[B.textAlign||"center"],rotationOriginY:he.height/2}),S(!ve&&B.crop,!0)&&(ae=x(ne.x)&&x(ne.y)&&fe.isInsidePlot(ne.x-_e+(ne.width||0),ne.y)&&fe.isInsidePlot(ne.x+_e,ne.y)),ne[ae?"show":"hide"]()}b(this,"afterSetOffset",{xOffset:$,width:k})}adjustStackPosition({labelBox:$,verticalAlign:k,textAlign:T}){let D={bottom:0,middle:1,top:2,right:1,center:0,left:-1},I=D[k],O=D[T];return{x:$.width/2+$.width/2*O,y:$.height/2*I}}getStackBox($){let k=this.axis,T=k.chart,{boxTop:D,defaultX:I,xOffset:O,width:N,boxBottom:ee}=$,ne=k.stacking.usePercentage?100:S(D,this.total,0),B=k.toPixels(ne),le=$.xAxis||T.xAxis[0],fe=S(I,le.translate(this.x))+O,xe=Math.abs(B-k.toPixels(ee||x(k.min)&&k.logarithmic&&k.logarithmic.lin2log(k.min)||0)),we=T.inverted,he=this.isNegative;return we?{x:(he?B:B-xe)-T.plotLeft,y:le.height-fe-N,width:xe,height:N}:{x:fe+le.transB-T.plotLeft,y:(he?B-xe:B)-T.plotTop,width:N,height:xe}}}}),n(r,"Core/Axis/Stacking/StackingAxis.js",[r["Core/Animation/AnimationUtilities.js"],r["Core/Axis/Axis.js"],r["Core/Series/SeriesRegistry.js"],r["Core/Axis/Stacking/StackItem.js"],r["Core/Utilities.js"]],function(o,a,l,c,u){var g;let{getDeferredAnimation:b}=o,{series:{prototype:x}}=l,{addEvent:S,correctFloat:$,defined:k,destroyObjectProperties:T,fireEvent:D,isArray:I,isNumber:O,objectEach:N,pick:ee}=u;function ne(){let ae=this.inverted;this.axes.forEach(ie=>{ie.stacking&&ie.stacking.stacks&&ie.hasVisibleSeries&&(ie.stacking.oldStacks=ie.stacking.stacks)}),this.series.forEach(ie=>{let pe=ie.xAxis&&ie.xAxis.options||{};ie.options.stacking&&ie.reserveSpace()&&(ie.stackKey=[ie.type,ee(ie.options.stack,""),ae?pe.top:pe.left,ae?pe.height:pe.width].join(","))})}function B(){let ae=this.stacking;if(ae){let ie=ae.stacks;N(ie,(pe,ue)=>{T(pe),delete ie[ue]}),ae.stackTotalGroup?.destroy()}}function le(){this.stacking||(this.stacking=new ve(this))}function fe(ae,ie,pe,ue){return!k(ae)||ae.x!==ie||ue&&ae.stackKey!==ue?ae={x:ie,index:0,key:ue,stackKey:ue}:ae.index++,ae.key=[pe,ie,ae.index].join(","),ae}function xe(){let ae,ie=this,pe=ie.yAxis,ue=ie.stackKey||"",ge=pe.stacking.stacks,ye=ie.processedXData,Ae=ie.options.stacking,Re=ie[Ae+"Stacker"];Re&&[ue,"-"+ue].forEach(We=>{let Pe=ye.length,Ue,Oe,Be;for(;Pe--;)Ue=ye[Pe],ae=ie.getStackIndicator(ae,Ue,ie.index,We),Oe=ge[We]?.[Ue],(Be=Oe?.points[ae.key||""])&&Re.call(ie,Be,Oe,Pe)})}function we(ae,ie,pe){let ue=ie.total?100/ie.total:0;ae[0]=$(ae[0]*ue),ae[1]=$(ae[1]*ue),this.stackedYData[pe]=ae[1]}function he(ae){(this.is("column")||this.is("columnrange"))&&(this.options.centerInCategory&&!this.options.stacking&&this.chart.series.length>1?x.setStackedPoints.call(this,ae,"group"):ae.stacking.resetStacks())}function _e(ae,ie){let pe,ue,ge,ye,Ae,Re,We,Pe,Ue,Oe=ie||this.options.stacking;if(!Oe||!this.reserveSpace()||({group:"xAxis"}[Oe]||"yAxis")!==ae.coll)return;let Be=this.processedXData,Ye=this.processedYData,Se=[],Te=Ye.length,$e=this.options,Ve=$e.threshold||0,oe=$e.startFromThreshold?Ve:0,te=$e.stack,se=ie?`${this.type},${Oe}`:this.stackKey||"",me="-"+se,Ee=this.negStacks,Le=ae.stacking,He=Le.stacks,ze=Le.oldStacks;for(Le.stacksTouched+=1,We=0;We0&&this.singleStacks===!1&&(ge.points[Re][0]=ge.points[this.index+","+Pe+",0"][0])):(delete ge.points[Re],delete ge.points[this.index]);let Qe=ge.total||0;Oe==="percent"?(ye=ue?se:me,Qe=Ee&&He[ye]?.[Pe]?(ye=He[ye][Pe]).total=Math.max(ye.total||0,Qe)+Math.abs(Ue)||0:$(Qe+(Math.abs(Ue)||0))):Oe==="group"?(I(Ue)&&(Ue=Ue[0]),Ue!==null&&Qe++):Qe=$(Qe+(Ue||0)),Oe==="group"?ge.cumulative=(Qe||1)-1:ge.cumulative=$(ee(ge.cumulative,oe)+(Ue||0)),ge.total=Qe,Ue!==null&&(ge.points[Re].push(ge.cumulative),Se[We]=ge.cumulative,ge.hasValidPoints=!0)}Oe==="percent"&&(Le.usePercentage=!0),Oe!=="group"&&(this.stackedYData=Se),Le.oldStacks={}}class ve{constructor(ie){this.oldStacks={},this.stacks={},this.stacksTouched=0,this.axis=ie}buildStacks(){let ie,pe,ue=this.axis,ge=ue.series,ye=ue.coll==="xAxis",Ae=ue.options.reversedStacks,Re=ge.length;for(this.resetStacks(),this.usePercentage=!1,pe=Re;pe--;)ie=ge[Ae?pe:Re-pe-1],ye&&ie.setGroupedPoints(ue),ie.setStackedPoints(ue);if(!ye)for(pe=0;pe{N(ie,pe=>{pe.cumulative=pe.total})}))}resetStacks(){N(this.stacks,ie=>{N(ie,(pe,ue)=>{O(pe.touched)&&pe.touched{N(Re,We=>{We.render(Ae)})}),Ae.animate({opacity:1},ye)}}return(g||(g={})).compose=function(ae,ie,pe){let ue=ie.prototype,ge=pe.prototype;ue.getStacks||(S(ae,"init",le),S(ae,"destroy",B),ue.getStacks=ne,ge.getStackIndicator=fe,ge.modifyStacks=xe,ge.percentStacker=we,ge.setGroupedPoints=he,ge.setStackedPoints=_e)},g}),n(r,"Series/Line/LineSeries.js",[r["Core/Series/Series.js"],r["Core/Series/SeriesRegistry.js"],r["Core/Utilities.js"]],function(o,a,l){let{defined:c,merge:u,isObject:g}=l;class b extends o{drawGraph(){let S=this.options,$=(this.gappedPath||this.getGraphPath).call(this),k=this.chart.styledMode;[this,...this.zones].forEach((T,D)=>{let I,O=T.graph,N=O?"animate":"attr",ee=T.dashStyle||S.dashStyle;O?(O.endX=this.preventGraphAnimation?null:$.xMap,O.animate({d:$})):$.length&&(T.graph=O=this.chart.renderer.path($).addClass("highcharts-graph"+(D?` highcharts-zone-graph-${D-1} `:" ")+(D&&T.className||"")).attr({zIndex:1}).add(this.group)),O&&!k&&(I={stroke:!D&&S.lineColor||T.color||this.color||"#cccccc","stroke-width":S.lineWidth||0,fill:this.fillGraph&&this.color||"none"},ee?I.dashstyle=ee:S.linecap!=="square"&&(I["stroke-linecap"]=I["stroke-linejoin"]="round"),O[N](I).shadow(D<2&&S.shadow&&u({filterUnits:"userSpaceOnUse"},g(S.shadow)?S.shadow:{}))),O&&(O.startX=$.xMap,O.isArea=$.isArea)})}getGraphPath(S,$,k){let T=this,D=T.options,I=[],O=[],N,ee=D.step,ne=(S=S||T.points).reversed;return ne&&S.reverse(),(ee={right:1,center:2}[ee]||ee&&3)&&ne&&(ee=4-ee),(S=this.getValidPoints(S,!1,!(D.connectNulls&&!$&&!k))).forEach(function(B,le){let fe,xe=B.plotX,we=B.plotY,he=S[le-1],_e=B.isNull||typeof we!="number";(B.leftCliff||he&&he.rightCliff)&&!k&&(N=!0),_e&&!c($)&&le>0?N=!D.connectNulls:_e&&!$?N=!0:(le===0||N?fe=[["M",B.plotX,B.plotY]]:T.getPointSpline?fe=[T.getPointSpline(S,B,le)]:ee?(fe=ee===1?[["L",he.plotX,we]]:ee===2?[["L",(he.plotX+xe)/2,he.plotY],["L",(he.plotX+xe)/2,we]]:[["L",xe,he.plotY]]).push(["L",xe,we]):fe=[["L",xe,we]],O.push(B.x),ee&&(O.push(B.x),ee===2&&O.push(B.x)),I.push.apply(I,fe),N=!1)}),I.xMap=O,T.graphPath=I,I}}return b.defaultOptions=u(o.defaultOptions,{legendSymbol:"lineMarker"}),a.registerSeriesType("line",b),b}),n(r,"Series/Area/AreaSeriesDefaults.js",[],function(){return{threshold:0,legendSymbol:"areaMarker"}}),n(r,"Series/Area/AreaSeries.js",[r["Series/Area/AreaSeriesDefaults.js"],r["Core/Series/SeriesRegistry.js"],r["Core/Utilities.js"]],function(o,a,l){let{seriesTypes:{line:c}}=a,{extend:u,merge:g,objectEach:b,pick:x}=l;class S extends c{drawGraph(){this.areaPath=[],super.drawGraph.apply(this);let{areaPath:k,options:T}=this;[this,...this.zones].forEach((D,I)=>{let O={},N=D.fillColor||T.fillColor,ee=D.area,ne=ee?"animate":"attr";ee?(ee.endX=this.preventGraphAnimation?null:k.xMap,ee.animate({d:k})):(O.zIndex=0,(ee=D.area=this.chart.renderer.path(k).addClass("highcharts-area"+(I?` highcharts-zone-area-${I-1} `:" ")+(I&&D.className||"")).add(this.group)).isArea=!0),this.chart.styledMode||(O.fill=N||D.color||this.color,O["fill-opacity"]=N?1:T.fillOpacity??.75,ee.css({pointerEvents:this.stickyTracking?"none":"auto"})),ee[ne](O),ee.startX=k.xMap,ee.shiftUnit=T.step?2:1})}getGraphPath(k){let T,D,I,O=c.prototype.getGraphPath,N=this.options,ee=N.stacking,ne=this.yAxis,B=[],le=[],fe=this.index,xe=ne.stacking.stacks[this.stackKey],we=N.threshold,he=Math.round(ne.getThreshold(N.threshold)),_e=x(N.connectNulls,ee==="percent"),ve=function(ye,Ae,Re){let We=k[ye],Pe=ee&&xe[We.x].points[fe],Ue=We[Re+"Null"]||0,Oe=We[Re+"Cliff"]||0,Be,Ye,Se=!0;Oe||Ue?(Be=(Ue?Pe[0]:Pe[1])+Oe,Ye=Pe[0]+Oe,Se=!!Ue):!ee&&k[Ae]&&k[Ae].isNull&&(Be=Ye=we),Be!==void 0&&(le.push({plotX:T,plotY:Be===null?he:ne.getThreshold(Be),isNull:Se,isCliff:!0}),B.push({plotX:T,plotY:Ye===null?he:ne.getThreshold(Ye),doCurve:!1}))};k=k||this.points,ee&&(k=this.getStackPoints(k));for(let ye=0,Ae=k.length;yehe.visible);I.forEach(function(he,_e){let ve=0,ae,ie;if(ne[he]&&!ne[he].isNull)D.push(ne[he]),[-1,1].forEach(function(pe){let ue=pe===1?"rightNull":"leftNull",ge=ee[I[_e+pe]],ye=0;if(ge){let Ae=xe;for(;Ae>=0&&Ae=0&&pexe&&T>N?(T=Math.max(xe,N),I=2*N-T):The&&I>N?(I=Math.max(he,N),T=2*N-I):I1){let ae=this.xAxis.series.filter(ge=>ge.visible).map(ge=>ge.index),ie=0,pe=0;le(this.xAxis.stacking?.stacks,ge=>{if(typeof _e.x=="number"){let ye=ge[_e.x.toString()];if(ye&&N(ye.points[this.index])){let Ae=Object.keys(ye.points).filter(Re=>!Re.match(",")&&ye.points[Re]&&ye.points[Re].length>1).map(parseFloat).filter(Re=>ae.indexOf(Re)!==-1).sort((Re,We)=>We-Re);ie=Ae.indexOf(this.index),pe=Ae.length}}}),ie=this.xAxis.reversed?pe-1-ie:ie;let ue=(pe-1)*ve.paddedWidth+he;we=(_e.plotX||0)+ue/2-he-ie*ve.paddedWidth}return we}translate(){let we=this,he=we.chart,_e=we.options,ve=we.dense=we.closestPointRange*we.xAxis.transA<2,ae=we.borderWidth=B(_e.borderWidth,ve?0:1),ie=we.xAxis,pe=we.yAxis,ue=_e.threshold,ge=B(_e.minPointLength,5),ye=we.getColumnMetrics(),Ae=ye.width,Re=we.pointXOffset=ye.offset,We=we.dataMin,Pe=we.dataMax,Ue=we.translatedThreshold=pe.getThreshold(ue),Oe=we.barW=Math.max(Ae,1+2*ae);_e.pointPadding&&(Oe=Math.ceil(Oe)),u.prototype.translate.apply(we),we.points.forEach(function(Be){let Ye=B(Be.yBottom,Ue),Se=999+Math.abs(Ye),Te=Be.plotX||0,$e=k(Be.plotY,-Se,pe.len+Se),Ve,oe=Math.min($e,Ye),te=Math.max($e,Ye)-oe,se=Ae,me=Te+Re,Ee=Oe;ge&&Math.abs(te)ge?Ye-ge:Ue-(Ve?ge:0)),D(Be.options.pointWidth)&&(me-=Math.round(((se=Ee=Math.ceil(Be.options.pointWidth))-Ae)/2)),_e.centerInCategory&&!_e.stacking&&(me=we.adjustForMissingColumns(me,se,Be,ye)),Be.barX=me,Be.pointWidth=se,Be.tooltipPos=he.inverted?[k(pe.len+pe.pos-he.plotLeft-$e,pe.pos-he.plotLeft,pe.len+pe.pos-he.plotLeft),ie.len+ie.pos-he.plotTop-me-Ee/2,te]:[ie.left-he.plotLeft+me+Ee/2,k($e+pe.pos-he.plotTop,pe.pos-he.plotTop,pe.len+pe.pos-he.plotTop),te],Be.shapeType=we.pointClass.prototype.shapeType||"roundedRect",Be.shapeArgs=we.crispCol(me,Be.isNull?Ue:oe,Ee,Be.isNull?0:te)}),O(this,"afterColumnTranslate")}drawGraph(){this.group[this.dense?"addClass":"removeClass"]("highcharts-dense-data")}pointAttribs(we,he){let _e=this.options,ve=this.pointAttrToOptions||{},ae=ve.stroke||"borderColor",ie=ve["stroke-width"]||"borderWidth",pe,ue,ge,ye=we&&we.color||this.color,Ae=we&&we[ae]||_e[ae]||ye,Re=we&&we.options.dashStyle||_e.dashStyle,We=we&&we[ie]||_e[ie]||this[ie]||0,Pe=B(we&&we.opacity,_e.opacity,1);we&&this.zones.length&&(ue=we.getZone(),ye=we.options.color||ue&&(ue.color||we.nonZonedColor)||this.color,ue&&(Ae=ue.borderColor||Ae,Re=ue.dashStyle||Re,We=ue.borderWidth||We)),he&&we&&(ge=(pe=ne(_e.states[he],we.options.states&&we.options.states[he]||{})).brightness,ye=pe.color||ge!==void 0&&S(ye).brighten(pe.brightness).get()||ye,Ae=pe[ae]||Ae,We=pe[ie]||We,Re=pe.dashStyle||Re,Pe=B(pe.opacity,Pe));let Ue={fill:ye,stroke:Ae,"stroke-width":We,opacity:Pe};return Re&&(Ue.dashstyle=Re),Ue}drawPoints(we=this.points){let he,_e=this,ve=this.chart,ae=_e.options,ie=ve.renderer,pe=ae.animationLimit||250;we.forEach(function(ue){let ge=ue.plotY,ye=ue.graphic,Ae=!!ye,Re=ye&&ve.pointCountae?.enabled)}function B(ae,ie,pe,ue,ge){let{chart:ye,enabledDataSorting:Ae}=this,Re=this.isCartesian&&ye.inverted,We=ae.plotX,Pe=ae.plotY,Ue=pe.rotation||0,Oe=b(We)&&b(Pe)&&ye.isInsidePlot(We,Math.round(Pe),{inverted:Re,paneCoordinates:!0,series:this}),Be=Ue===0&&I(pe.overflow,Ae?"none":"justify")==="justify",Ye=this.visible&&ae.visible!==!1&&b(We)&&(ae.series.forceDL||Ae&&!Be||Oe||I(pe.inside,!!this.options.stacking)&&ue&&ye.isInsidePlot(We,Re?ue.x+1:ue.y+ue.height-1,{inverted:Re,paneCoordinates:!0,series:this})),Se=ae.pos();if(Ye&&Se){var Te;let $e=ie.getBBox(),Ve=ie.getBBox(void 0,0),oe={right:1,center:.5}[pe.align||0]||0,te={bottom:1,middle:.5}[pe.verticalAlign||0]||0;if(ue=x({x:Se[0],y:Math.round(Se[1]),width:0,height:0},ue||{}),pe.alignTo==="plotEdges"&&this.isCartesian&&(ue[Re?"x":"y"]=0,ue[Re?"width":"height"]=this.yAxis?.len||0),x(pe,{width:$e.width,height:$e.height}),Te=ue,Ae&&this.xAxis&&!Be&&this.setDataLabelStartPos(ae,ie,ge,Oe,Te),ie.align(T(pe,{width:Ve.width,height:Ve.height}),!1,ue,!1),ie.alignAttr.x+=oe*(Ve.width-$e.width),ie.alignAttr.y+=te*(Ve.height-$e.height),ie[ie.placed?"animate":"attr"]({x:ie.alignAttr.x+($e.width-Ve.width)/2,y:ie.alignAttr.y+($e.height-Ve.height)/2,rotationOriginX:(ie.width||0)/2,rotationOriginY:(ie.height||0)/2}),Be&&ue.height>=0)this.justifyDataLabel(ie,pe,ie.alignAttr,$e,ue,ge);else if(I(pe.crop,!0)){let{x:se,y:me}=ie.alignAttr;Ye=ye.isInsidePlot(se,me,{paneCoordinates:!0,series:this})&&ye.isInsidePlot(se+$e.width-1,me+$e.height-1,{paneCoordinates:!0,series:this})}pe.shape&&!Ue&&ie[ge?"attr":"animate"]({anchorX:Se[0],anchorY:Se[1]})}ge&&Ae&&(ie.placed=!1),Ye||Ae&&!Be?(ie.show(),ie.placed=!0):(ie.hide(),ie.placed=!1)}function le(){return this.plotGroup("dataLabelsGroup","data-labels",this.hasRendered?"inherit":"hidden",this.options.dataLabels.zIndex||6)}function fe(ae){let ie=this.hasRendered||0,pe=this.initDataLabelsGroup().attr({opacity:+ie});return!ie&&pe&&(this.visible&&pe.show(),this.options.animation?pe.animate({opacity:1},ae):pe.attr({opacity:1})),pe}function xe(ae){let ie;ae=ae||this.points;let pe=this,ue=pe.chart,ge=pe.options,ye=ue.renderer,{backgroundColor:Ae,plotBackgroundColor:Re}=ue.options.chart,We=ye.getContrast(k(Re)&&Re||k(Ae)&&Ae||"#000000"),Pe=_e(pe),{animation:Ue,defer:Oe}=Pe[0],Be=Oe?u(ue,Ue,pe):{defer:0,duration:0};S(this,"drawDataLabels"),pe.hasDataLabels?.()&&(ie=this.initDataLabels(Be),ae.forEach(Ye=>{let Se=Ye.dataLabels||[];N(he(Pe,Ye.dlOptions||Ye.options?.dataLabels)).forEach(($e,Ve)=>{let oe=$e.enabled&&(Ye.visible||Ye.dataLabelOnHidden)&&(!Ye.isNull||Ye.dataLabelOnNull)&&function(je,Ze){let Ce=Ze.filter;if(Ce){let ce=Ce.operator,de=je[Ce.property],De=Ce.value;return ce===">"&&de>De||ce==="<"&&de="&&de>=De||ce==="<="&&de<=De||ce==="=="&&de==De||ce==="==="&&de===De||ce==="!="&&de!=De||ce==="!=="&&de!==De}return!0}(Ye,$e),{backgroundColor:te,borderColor:se,distance:me,style:Ee={}}=$e,Le,He,ze,Qe,rt={},Ke=Se[Ve],Ie=!Ke,Fe;if(oe&&(He=I($e[Ye.formatPrefix+"Format"],$e.format),Le=Ye.getLabelConfig(),ze=b(He)?g(He,Le,ue):($e[Ye.formatPrefix+"Formatter"]||$e.formatter).call(Le,$e),Qe=$e.rotation,!ue.styledMode&&(Ee.color=I($e.color,Ee.color,k(pe.color)?pe.color:void 0,"#000000"),Ee.color==="contrast"?(te!=="none"&&(Fe=te),Ye.contrastColor=ye.getContrast(Fe!=="auto"&&Fe||Ye.color||pe.color),Ee.color=Fe||!b(me)&&$e.inside||0>O(me||0)||ge.stacking?Ye.contrastColor:We):delete Ye.contrastColor,ge.cursor&&(Ee.cursor=ge.cursor)),rt={r:$e.borderRadius||0,rotation:Qe,padding:$e.padding,zIndex:1},ue.styledMode||(rt.fill=te==="auto"?Ye.color:te,rt.stroke=se==="auto"?Ye.color:se,rt["stroke-width"]=$e.borderWidth),D(rt,(je,Ze)=>{je===void 0&&delete rt[Ze]})),!Ke||oe&&b(ze)&&!!Ke.div==!!$e.useHTML&&(Ke.rotation&&$e.rotation||Ke.rotation===$e.rotation)||(Ke=void 0,Ie=!0),oe&&b(ze)&&(Ke?rt.text=ze:(Ke=ye.label(ze,0,0,$e.shape,void 0,void 0,$e.useHTML,void 0,"data-label")).addClass(" highcharts-data-label-color-"+Ye.colorIndex+" "+($e.className||"")+($e.useHTML?" highcharts-tracker":"")),Ke)){Ke.options=$e,Ke.attr(rt),ue.styledMode||Ke.css(Ee).shadow($e.shadow);let je=$e[Ye.formatPrefix+"TextPath"]||$e.textPath;je&&!$e.useHTML&&(Ke.setTextPath(Ye.getDataLabelPath?.(Ke)||Ye.graphic,je),Ye.dataLabelPath&&!je.enabled&&(Ye.dataLabelPath=Ye.dataLabelPath.destroy())),Ke.added||Ke.add(ie),pe.alignDataLabel(Ye,Ke,$e,void 0,Ie),Ke.isActive=!0,Se[Ve]&&Se[Ve]!==Ke&&Se[Ve].destroy(),Se[Ve]=Ke}});let Te=Se.length;for(;Te--;)Se[Te]&&Se[Te].isActive?Se[Te].isActive=!1:(Se[Te]?.destroy(),Se.splice(Te,1));Ye.dataLabel=Se[0],Ye.dataLabels=Se})),S(this,"afterDrawDataLabels")}function we(ae,ie,pe,ue,ge,ye){let Ae=this.chart,Re=ie.align,We=ie.verticalAlign,Pe=ae.box?0:ae.padding||0,Ue=Ae.inverted?this.yAxis:this.xAxis,Oe=Ue?Ue.left-Ae.plotLeft:0,Be=Ae.inverted?this.xAxis:this.yAxis,Ye=Be?Be.top-Ae.plotTop:0,{x:Se=0,y:Te=0}=ie,$e,Ve;return($e=(pe.x||0)+Pe+Oe)<0&&(Re==="right"&&Se>=0?(ie.align="left",ie.inside=!0):Se-=$e,Ve=!0),($e=(pe.x||0)+ue.width-Pe+Oe)>Ae.plotWidth&&(Re==="left"&&Se<=0?(ie.align="right",ie.inside=!0):Se+=Ae.plotWidth-$e,Ve=!0),($e=pe.y+Pe+Ye)<0&&(We==="bottom"&&Te>=0?(ie.verticalAlign="top",ie.inside=!0):Te-=$e,Ve=!0),($e=(pe.y||0)+ue.height-Pe+Ye)>Ae.plotHeight&&(We==="top"&&Te<=0?(ie.verticalAlign="bottom",ie.inside=!0):Te+=Ae.plotHeight-$e,Ve=!0),Ve&&(ie.x=Se,ie.y=Te,ae.placed=!ye,ae.align(ie,void 0,ge)),Ve}function he(ae,ie){let pe=[],ue;if($(ae)&&!$(ie))pe=ae.map(function(ge){return T(ge,ie)});else if($(ie)&&!$(ae))pe=ie.map(function(ge){return T(ae,ge)});else if($(ae)||$(ie)){if($(ae)&&$(ie))for(ue=Math.max(ae.length,ie.length);ue--;)pe[ue]=T(ae[ue],ie[ue])}else pe=T(ae,ie);return pe}function _e(ae){let ie=ae.chart.options.plotOptions;return N(he(he(ie?.series?.dataLabels,ie?.[ae.type]?.dataLabels),ae.options.dataLabels))}function ve(ae,ie,pe,ue,ge){let ye=this.chart,Ae=ye.inverted,Re=this.xAxis,We=Re.reversed,Pe=((Ae?ie.height:ie.width)||0)/2,Ue=ae.pointWidth,Oe=Ue?Ue/2:0;ie.startXPos=Ae?ge.x:We?-Pe-Oe:Re.width-Pe+Oe,ie.startYPos=Ae?We?this.yAxis.height-Pe+Oe:-Pe-Oe:ge.y,ue?ie.visibility==="hidden"&&(ie.show(),ie.attr({opacity:0}).animate({opacity:1})):ie.attr({opacity:1}).animate({opacity:0},void 0,ie.hide),ye.hasRendered&&(pe&&ie.attr({x:ie.startXPos,y:ie.startYPos}),ie.placed=!0)}ee.compose=function(ae){let ie=ae.prototype;ie.initDataLabels||(ie.initDataLabels=fe,ie.initDataLabelsGroup=le,ie.alignDataLabel=B,ie.drawDataLabels=xe,ie.justifyDataLabel=we,ie.setDataLabelStartPos=ve,ie.hasDataLabels=ne)}}(c||(c={})),c}),n(r,"Series/Column/ColumnDataLabel.js",[r["Core/Series/DataLabel.js"],r["Core/Globals.js"],r["Core/Series/SeriesRegistry.js"],r["Core/Utilities.js"]],function(o,a,l,c){var u;let{composed:g}=a,{series:b}=l,{merge:x,pick:S,pushUnique:$}=c;return function(k){function T(D,I,O,N,ee){let ne=this.chart.inverted,B=D.series,le=(B.xAxis?B.xAxis.len:this.chart.plotSizeX)||0,fe=(B.yAxis?B.yAxis.len:this.chart.plotSizeY)||0,xe=D.dlBox||D.shapeArgs,we=S(D.below,D.plotY>S(this.translatedThreshold,fe)),he=S(O.inside,!!this.options.stacking);if(xe){if(N=x(xe),!(O.overflow==="allow"&&O.crop===!1)){N.y<0&&(N.height+=N.y,N.y=0);let _e=N.y+N.height-fe;_e>0&&_e\u25CF {series.name}
',pointFormat:"x: {point.x}
y: {point.y}
"}}}),n(r,"Series/Scatter/ScatterSeries.js",[r["Series/Scatter/ScatterSeriesDefaults.js"],r["Core/Series/SeriesRegistry.js"],r["Core/Utilities.js"]],function(o,a,l){let{column:c,line:u}=a.seriesTypes,{addEvent:g,extend:b,merge:x}=l;class S extends u{applyJitter(){let k=this,T=this.options.jitter,D=this.points.length;T&&this.points.forEach(function(I,O){["x","y"].forEach(function(N,ee){if(T[N]&&!I.isNull){let ne=`plot${N.toUpperCase()}`,B=k[`${N}Axis`],le=T[N]*B.transA;if(B&&!B.logarithmic){let fe=Math.max(0,(I[ne]||0)-le),xe=Math.min(B.len,(I[ne]||0)+le);I[ne]=fe+(xe-fe)*function(we){let he=1e4*Math.sin(we);return he-Math.floor(he)}(O+ee*D),N==="x"&&(I.clientX=I.plotX)}}})})}drawGraph(){this.options.lineWidth?super.drawGraph():this.graph&&(this.graph=this.graph.destroy())}}return S.defaultOptions=x(u.defaultOptions,o),b(S.prototype,{drawTracker:c.prototype.drawTracker,sorted:!1,requireSorting:!1,noSharedTooltip:!0,trackerGroups:["group","markerGroup","dataLabelsGroup"]}),g(S,"afterTranslate",function(){this.applyJitter()}),a.registerSeriesType("scatter",S),S}),n(r,"Series/CenteredUtilities.js",[r["Core/Globals.js"],r["Core/Series/Series.js"],r["Core/Utilities.js"]],function(o,a,l){var c,u;let{deg2rad:g}=o,{fireEvent:b,isNumber:x,pick:S,relativeLength:$}=l;return(u=c||(c={})).getCenter=function(){let k=this.options,T=this.chart,D=2*(k.slicedOffset||0),I=T.plotWidth-2*D,O=T.plotHeight-2*D,N=k.center,ee=Math.min(I,O),ne=k.thickness,B,le=k.size,fe=k.innerSize||0,xe,we;typeof le=="string"&&(le=parseFloat(le)),typeof fe=="string"&&(fe=parseFloat(fe));let he=[S(N[0],"50%"),S(N[1],"50%"),S(le&&le<0?void 0:k.size,"100%"),S(fe&&fe<0?void 0:k.innerSize||0,"0%")];for(!T.angular||this instanceof a||(he[3]=0),xe=0;xe<4;++xe)we=he[xe],B=xe<2||xe===2&&/%$/.test(we),he[xe]=$(we,[I,O,ee,he[2]][xe])+(B?D:0);return he[3]>he[2]&&(he[3]=he[2]),x(ne)&&2*ne0&&(he[3]=he[2]-2*ne),b(this,"afterGetCenter",{positions:he}),he},u.getStartAndEndRadians=function(k,T){let D=x(k)?k:0,I=x(T)&&T>D&&T-D<360?T:D+360;return{start:g*(D+-90),end:g*(I+-90)}},c}),n(r,"Series/Pie/PiePoint.js",[r["Core/Animation/AnimationUtilities.js"],r["Core/Series/Point.js"],r["Core/Utilities.js"]],function(o,a,l){let{setAnimation:c}=o,{addEvent:u,defined:g,extend:b,isNumber:x,pick:S,relativeLength:$}=l;class k extends a{getConnectorPath(D){let I=D.dataLabelPosition,O=D.options||{},N=O.connectorShape,ee=this.connectorShapes[N]||N;return I&&ee.call(this,{...I.computed,alignment:I.alignment},I.connectorPosition,O)||[]}getTranslate(){return this.sliced&&this.slicedTranslation||{translateX:0,translateY:0}}haloPath(D){let I=this.shapeArgs;return this.sliced||!this.visible?[]:this.series.chart.renderer.symbols.arc(I.x,I.y,I.r+D,I.r+D,{innerR:I.r-1,start:I.start,end:I.end,borderRadius:I.borderRadius})}constructor(D,I,O){super(D,I,O),this.half=0,this.name??(this.name="Slice");let N=ee=>{this.slice(ee.type==="select")};u(this,"select",N),u(this,"unselect",N)}isValid(){return x(this.y)&&this.y>=0}setVisible(D,I=!0){D!==this.visible&&this.update({visible:D??!this.visible},I,void 0,!1)}slice(D,I,O){let N=this.series;c(O,N.chart),I=S(I,!0),this.sliced=this.options.sliced=D=g(D)?D:!this.sliced,N.options.data[N.data.indexOf(this)]=this.options,this.graphic&&this.graphic.animate(this.getTranslate())}}return b(k.prototype,{connectorShapes:{fixedOffset:function(T,D,I){let O=D.breakAt,N=D.touchingSliceAt,ee=I.softConnector?["C",T.x+(T.alignment==="left"?-5:5),T.y,2*O.x-N.x,2*O.y-N.y,O.x,O.y]:["L",O.x,O.y];return[["M",T.x,T.y],ee,["L",N.x,N.y]]},straight:function(T,D){let I=D.touchingSliceAt;return[["M",T.x,T.y],["L",I.x,I.y]]},crookedLine:function(T,D,I){let{breakAt:O,touchingSliceAt:N}=D,{series:ee}=this,[ne,B,le]=ee.center,fe=le/2,{plotLeft:xe,plotWidth:we}=ee.chart,he=T.alignment==="left",{x:_e,y:ve}=T,ae=O.x;if(I.crookDistance){let pe=$(I.crookDistance,1);ae=he?ne+fe+(we+xe-ne-fe)*(1-pe):xe+(ne-fe)*pe}else ae=ne+(B-ve)*Math.tan((this.angle||0)-Math.PI/2);let ie=[["M",_e,ve]];return(he?ae<=_e&&ae>=O.x:ae>=_e&&ae<=O.x)&&ie.push(["L",ae,ve]),ie.push(["L",O.x,O.y],["L",N.x,N.y]),ie}}}),k}),n(r,"Series/Pie/PieSeriesDefaults.js",[],function(){return{borderRadius:3,center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{connectorPadding:5,connectorShape:"crookedLine",crookDistance:void 0,distance:30,enabled:!0,formatter:function(){return this.point.isNull?void 0:this.point.name},softConnector:!0,x:0},fillColor:void 0,ignoreHiddenPoint:!0,inactiveOtherPoints:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,stickyTracking:!1,tooltip:{followPointer:!0},borderColor:"#ffffff",borderWidth:1,lineWidth:void 0,states:{hover:{brightness:.1}}}}),n(r,"Series/Pie/PieSeries.js",[r["Series/CenteredUtilities.js"],r["Series/Column/ColumnSeries.js"],r["Core/Globals.js"],r["Series/Pie/PiePoint.js"],r["Series/Pie/PieSeriesDefaults.js"],r["Core/Series/Series.js"],r["Core/Series/SeriesRegistry.js"],r["Core/Renderer/SVG/Symbols.js"],r["Core/Utilities.js"]],function(o,a,l,c,u,g,b,x,S){let{getStartAndEndRadians:$}=o,{noop:k}=l,{clamp:T,extend:D,fireEvent:I,merge:O,pick:N}=S;class ee extends g{animate(B){let le=this,fe=le.points,xe=le.startAngleRad;B||fe.forEach(function(we){let he=we.graphic,_e=we.shapeArgs;he&&_e&&(he.attr({r:N(we.startR,le.center&&le.center[3]/2),start:xe,end:xe}),he.animate({r:_e.r,start:_e.start,end:_e.end},le.options.animation))})}drawEmpty(){let B,le,fe=this.startAngleRad,xe=this.endAngleRad,we=this.options;this.total===0&&this.center?(B=this.center[0],le=this.center[1],this.graph||(this.graph=this.chart.renderer.arc(B,le,this.center[1]/2,0,fe,xe).addClass("highcharts-empty-series").add(this.group)),this.graph.attr({d:x.arc(B,le,this.center[2]/2,0,{start:fe,end:xe,innerR:this.center[3]/2})}),this.chart.styledMode||this.graph.attr({"stroke-width":we.borderWidth,fill:we.fillColor||"none",stroke:we.color||"#cccccc"})):this.graph&&(this.graph=this.graph.destroy())}drawPoints(){let B=this.chart.renderer;this.points.forEach(function(le){le.graphic&&le.hasNewShapeType()&&(le.graphic=le.graphic.destroy()),le.graphic||(le.graphic=B[le.shapeType](le.shapeArgs).add(le.series.group),le.delayedRendering=!0)})}generatePoints(){super.generatePoints(),this.updateTotals()}getX(B,le,fe,xe){let we=this.center,he=this.radii?this.radii[fe.index]||0:we[2]/2,_e=xe.dataLabelPosition,ve=_e?.distance||0,ae=Math.asin(T((B-we[1])/(he+ve),-1,1));return we[0]+Math.cos(ae)*(he+ve)*(le?-1:1)+(ve>0?(le?-1:1)*(xe.padding||0):0)}hasData(){return!!this.processedXData.length}redrawPoints(){let B,le,fe,xe,we=this,he=we.chart;this.drawEmpty(),we.group&&!he.styledMode&&we.group.shadow(we.options.shadow),we.points.forEach(function(_e){let ve={};le=_e.graphic,!_e.isNull&&le?(xe=_e.shapeArgs,B=_e.getTranslate(),he.styledMode||(fe=we.pointAttribs(_e,_e.selected&&"select")),_e.delayedRendering?(le.setRadialReference(we.center).attr(xe).attr(B),he.styledMode||le.attr(fe).attr({"stroke-linejoin":"round"}),_e.delayedRendering=!1):(le.setRadialReference(we.center),he.styledMode||O(!0,ve,fe),O(!0,ve,xe,B),le.animate(ve)),le.attr({visibility:_e.visible?"inherit":"hidden"}),le.addClass(_e.getClassName(),!0)):le&&(_e.graphic=le.destroy())})}sortByAngle(B,le){B.sort(function(fe,xe){return fe.angle!==void 0&&(xe.angle-fe.angle)*le})}translate(B){I(this,"translate"),this.generatePoints();let le=this.options,fe=le.slicedOffset,xe=$(le.startAngle,le.endAngle),we=this.startAngleRad=xe.start,he=(this.endAngleRad=xe.end)-we,_e=this.points,ve=le.ignoreHiddenPoint,ae=_e.length,ie,pe,ue,ge,ye,Ae,Re,We=0;for(B||(this.center=B=this.getCenter()),Ae=0;Ae1.5*Math.PI?ue-=2*Math.PI:ue<-Math.PI/2&&(ue+=2*Math.PI),Re.slicedTranslation={translateX:Math.round(Math.cos(ue)*fe),translateY:Math.round(Math.sin(ue)*fe)},ge=Math.cos(ue)*B[2]/2,ye=Math.sin(ue)*B[2]/2,Re.tooltipPos=[B[0]+.7*ge,B[1]+.7*ye],Re.half=ue<-Math.PI/2||ue>Math.PI/2?1:0,Re.angle=ue}I(this,"afterTranslate")}updateTotals(){let B=this.points,le=B.length,fe=this.options.ignoreHiddenPoint,xe,we,he=0;for(xe=0;xe0&&(we.visible||!fe)?we.y/he*100:0,we.total=he}}return ee.defaultOptions=O(g.defaultOptions,u),D(ee.prototype,{axisTypes:[],directTouch:!0,drawGraph:void 0,drawTracker:a.prototype.drawTracker,getCenter:o.getCenter,getSymbol:k,invertible:!1,isCartesian:!1,noSharedTooltip:!0,pointAttribs:a.prototype.pointAttribs,pointClass:c,requireSorting:!1,searchPoint:k,trackerGroups:["group","dataLabelsGroup"]}),b.registerSeriesType("pie",ee),ee}),n(r,"Series/Pie/PieDataLabel.js",[r["Core/Series/DataLabel.js"],r["Core/Globals.js"],r["Core/Renderer/RendererUtilities.js"],r["Core/Series/SeriesRegistry.js"],r["Core/Utilities.js"]],function(o,a,l,c,u){var g;let{composed:b,noop:x}=a,{distribute:S}=l,{series:$}=c,{arrayMax:k,clamp:T,defined:D,pick:I,pushUnique:O,relativeLength:N}=u;return function(ee){let ne={radialDistributionY:function(we,he){return(he.dataLabelPosition?.top||0)+we.distributeBox.pos},radialDistributionX:function(we,he,_e,ve,ae){let ie=ae.dataLabelPosition;return we.getX(_e<(ie?.top||0)+2||_e>(ie?.bottom||0)-2?ve:_e,he.half,he,ae)},justify:function(we,he,_e,ve){return ve[0]+(we.half?-1:1)*(_e+(he.dataLabelPosition?.distance||0))},alignToPlotEdges:function(we,he,_e,ve){let ae=we.getBBox().width;return he?ae+ve:_e-ae-ve},alignToConnectors:function(we,he,_e,ve){let ae=0,ie;return we.forEach(function(pe){(ie=pe.dataLabel.getBBox().width)>ae&&(ae=ie)}),he?ae+ve:_e-ae-ve}};function B(we,he){let{center:_e,options:ve}=this,ae=_e[2]/2,ie=we.angle||0,pe=Math.cos(ie),ue=Math.sin(ie),ge=_e[0]+pe*ae,ye=_e[1]+ue*ae,Ae=Math.min((ve.slicedOffset||0)+(ve.borderWidth||0),he/5);return{natural:{x:ge+pe*he,y:ye+ue*he},computed:{},alignment:he<0?"center":we.half?"right":"left",connectorPosition:{breakAt:{x:ge+pe*Ae,y:ye+ue*Ae},touchingSliceAt:{x:ge,y:ye}},distance:he}}function le(){let we=this,he=we.points,_e=we.chart,ve=_e.plotWidth,ae=_e.plotHeight,ie=_e.plotLeft,pe=Math.round(_e.chartWidth/3),ue=we.center,ge=ue[2]/2,ye=ue[1],Ae=[[],[]],Re=[0,0,0,0],We=we.dataLabelPositioners,Pe,Ue,Oe,Be=0;we.visible&&we.hasDataLabels?.()&&(he.forEach(Ye=>{(Ye.dataLabels||[]).forEach(Se=>{Se.shortened&&(Se.attr({width:"auto"}).css({width:"auto",textOverflow:"clip"}),Se.shortened=!1)})}),$.prototype.drawDataLabels.apply(we),he.forEach(Ye=>{(Ye.dataLabels||[]).forEach((Se,Te)=>{let $e=ue[2]/2,Ve=Se.options,oe=N(Ve?.distance||0,$e);Te===0&&Ae[Ye.half].push(Ye),!D(Ve?.style?.width)&&Se.getBBox().width>pe&&(Se.css({width:Math.round(.7*pe)+"px"}),Se.shortened=!0),Se.dataLabelPosition=this.getDataLabelPosition(Ye,oe),Be=Math.max(Be,oe)})}),Ae.forEach((Ye,Se)=>{let Te=Ye.length,$e=[],Ve,oe,te=0,se;Te&&(we.sortByAngle(Ye,Se-.5),Be>0&&(Ve=Math.max(0,ye-ge-Be),oe=Math.min(ye+ge+Be,_e.plotHeight),Ye.forEach(me=>{(me.dataLabels||[]).forEach(Ee=>{let Le=Ee.dataLabelPosition;Le&&Le.distance>0&&(Le.top=Math.max(0,ye-ge-Le.distance),Le.bottom=Math.min(ye+ge+Le.distance,_e.plotHeight),te=Ee.getBBox().height||21,me.distributeBox={target:(Ee.dataLabelPosition?.natural.y||0)-Le.top+te/2,size:te,rank:me.y},$e.push(me.distributeBox))})}),S($e,se=oe+te-Ve,se/5)),Ye.forEach(me=>{(me.dataLabels||[]).forEach(Ee=>{let Le=Ee.options||{},He=me.distributeBox,ze=Ee.dataLabelPosition,Qe=ze?.natural.y||0,rt=Le.connectorPadding||0,Ke=0,Ie=Qe,Fe="inherit";if(ze){if($e&&D(He)&&ze.distance>0&&(He.pos===void 0?Fe="hidden":(Oe=He.size,Ie=We.radialDistributionY(me,Ee))),Le.justify)Ke=We.justify(me,Ee,ge,ue);else switch(Le.alignTo){case"connectors":Ke=We.alignToConnectors(Ye,Se,ve,ie);break;case"plotEdges":Ke=We.alignToPlotEdges(Ee,Se,ve,ie);break;default:Ke=We.radialDistributionX(we,me,Ie,Qe,Ee)}if(ze.attribs={visibility:Fe,align:ze.alignment},ze.posAttribs={x:Ke+(Le.x||0)+({left:rt,right:-rt}[ze.alignment]||0),y:Ie+(Le.y||0)-Ee.getBBox().height/2},ze.computed.x=Ke,ze.computed.y=Ie,I(Le.crop,!0)){let je;Ke-(Ue=Ee.getBBox().width)ve-rt&&Se===0&&(je=Math.round(Ke+Ue-ve+rt),Re[1]=Math.max(je,Re[1])),Ie-Oe/2<0?Re[0]=Math.max(Math.round(-Ie+Oe/2),Re[0]):Ie+Oe/2>ae&&(Re[2]=Math.max(Math.round(Ie+Oe/2-ae),Re[2])),ze.sideOverflow=je}}})}))}),(k(Re)===0||this.verifyDataLabelOverflow(Re))&&(this.placeDataLabels(),this.points.forEach(Ye=>{(Ye.dataLabels||[]).forEach(Se=>{let{connectorColor:Te,connectorWidth:$e=1}=Se.options||{},Ve=Se.dataLabelPosition;if($e){let oe;Pe=Se.connector,Ve&&Ve.distance>0?(oe=!Pe,Pe||(Se.connector=Pe=_e.renderer.path().addClass("highcharts-data-label-connector highcharts-color-"+Ye.colorIndex+(Ye.className?" "+Ye.className:"")).add(we.dataLabelsGroup)),_e.styledMode||Pe.attr({"stroke-width":$e,stroke:Te||Ye.color||"#666666"}),Pe[oe?"attr":"animate"]({d:Ye.getConnectorPath(Se)}),Pe.attr({visibility:Ve.attribs?.visibility})):Pe&&(Se.connector=Pe.destroy())}})})))}function fe(){this.points.forEach(we=>{(we.dataLabels||[]).forEach(he=>{let _e=he.dataLabelPosition;_e?(_e.sideOverflow&&(he.css({width:Math.max(he.getBBox().width-_e.sideOverflow,0)+"px",textOverflow:(he.options?.style||{}).textOverflow||"ellipsis"}),he.shortened=!0),he.attr(_e.attribs),he[he.moved?"animate":"attr"](_e.posAttribs),he.moved=!0):he&&he.attr({y:-9999})}),delete we.distributeBox},this)}function xe(we){let he=this.center,_e=this.options,ve=_e.center,ae=_e.minSize||80,ie=ae,pe=_e.size!==null;return!pe&&(ve[0]!==null?ie=Math.max(he[2]-Math.max(we[1],we[3]),ae):(ie=Math.max(he[2]-we[1]-we[3],ae),he[0]+=(we[3]-we[1])/2),ve[1]!==null?ie=T(ie,ae,he[2]-Math.max(we[0],we[2])):(ie=T(ie,ae,he[2]-we[0]-we[2]),he[1]+=(we[0]-we[2])/2),ie!(B.x>=ne.x+ne.width||B.x+B.width<=ne.x||B.y>=ne.y+ne.height||B.y+B.height<=ne.y),T,D,I,O,N,ee=!1;for(let ne=0;ne<$;ne++)(T=S[ne])&&(T.oldOpacity=T.opacity,T.newOpacity=1,T.absoluteBox=function(B){if(B&&(!B.alignAttr||B.placed)){let le=B.box?0:B.padding||0,fe=B.alignAttr||{x:B.attr("x"),y:B.attr("y")},xe=B.getBBox();return B.width=xe.width,B.height=xe.height,{x:fe.x+(B.parentGroup?.translateX||0)+le,y:fe.y+(B.parentGroup?.translateY||0)+le,width:(B.width||0)-2*le,height:(B.height||0)-2*le}}}(T));S.sort((ne,B)=>(B.labelrank||0)-(ne.labelrank||0));for(let ne=0;ne<$;++ne){O=(D=S[ne])&&D.absoluteBox;for(let B=ne+1;B<$;++B)N=(I=S[B])&&I.absoluteBox,O&&N&&D!==I&&D.newOpacity!==0&&I.newOpacity!==0&&D.visibility!=="hidden"&&I.visibility!=="hidden"&&k(O,N)&&((D.labelrank{c(T,D=>{D.label&&$.push(D.label)})});for(let k of S.series||[])if(k.visible&&k.hasDataLabels?.()){let T=D=>{for(let I of D)I.visible&&(I.dataLabels||[]).forEach(O=>{let N=O.options||{};O.labelrank=u(N.labelrank,I.labelrank,I.shapeArgs?.height),N.allowOverlap??Number(N.distance)>0?(O.oldOpacity=O.opacity,O.newOpacity=1,b(O,S)):$.push(O)})};T(k.nodes||[]),T(k.points)}this.hideOverlappingLabels($)}return{compose:function(S){let $=S.prototype;$.hideOverlappingLabels||($.hideOverlappingLabels=g,a(S,"render",x))}}}),n(r,"Extensions/BorderRadius.js",[r["Core/Defaults.js"],r["Core/Globals.js"],r["Core/Utilities.js"]],function(o,a,l){let{defaultOptions:c}=o,{noop:u}=a,{addEvent:g,extend:b,isObject:x,merge:S,relativeLength:$}=l,k={radius:0,scope:"stack",where:void 0},T=u,D=u;function I(B,le,fe,xe,we={}){let he=T(B,le,fe,xe,we),{innerR:_e=0,r:ve=fe,start:ae=0,end:ie=0}=we;if(we.open||!we.borderRadius)return he;let pe=ie-ae,ue=Math.sin(pe/2),ge=Math.max(Math.min($(we.borderRadius||0,ve-_e),(ve-_e)/2,ve*ue/(1+ue)),0),ye=Math.min(ge,pe/Math.PI*2*_e),Ae=he.length-1;for(;Ae--;)(function(Re,We,Pe){let Ue,Oe,Be,Ye=Re[We],Se=Re[We+1];if(Se[0]==="Z"&&(Se=Re[0]),(Ye[0]==="M"||Ye[0]==="L")&&Se[0]==="A"?(Ue=Ye,Oe=Se,Be=!0):Ye[0]==="A"&&(Se[0]==="M"||Se[0]==="L")&&(Ue=Se,Oe=Ye),Ue&&Oe&&Oe.params){let Te=Oe[1],$e=Oe[5],Ve=Oe.params,{start:oe,end:te,cx:se,cy:me}=Ve,Ee=$e?Te-Pe:Te+Pe,Le=Ee?Math.asin(Pe/Ee):0,He=$e?Le:-Le,ze=Math.cos(Le)*Ee;Be?(Ve.start=oe+He,Ue[1]=se+ze*Math.cos(oe),Ue[2]=me+ze*Math.sin(oe),Re.splice(We+1,0,["A",Pe,Pe,0,0,1,se+Te*Math.cos(Ve.start),me+Te*Math.sin(Ve.start)])):(Ve.end=te-He,Oe[6]=se+Te*Math.cos(Ve.end),Oe[7]=me+Te*Math.sin(Ve.end),Re.splice(We+1,0,["A",Pe,Pe,0,0,1,se+ze*Math.cos(te),me+ze*Math.sin(te)])),Oe[4]=Math.abs(Ve.end-Ve.start)1?ye:ge);return he}function O(){if(this.options.borderRadius&&!(this.chart.is3d&&this.chart.is3d())){let{options:B,yAxis:le}=this,fe=B.stacking==="percent",xe=c.plotOptions?.[this.type]?.borderRadius,we=N(B.borderRadius,x(xe)?xe:{}),he=le.options.reversed;for(let _e of this.points){let{shapeArgs:ve}=_e;if(_e.shapeType==="roundedRect"&&ve){let{width:ae=0,height:ie=0,y:pe=0}=ve,ue=pe,ge=ie;if(we.scope==="stack"&&_e.stackTotal){let We=le.translate(fe?100:_e.stackTotal,!1,!0,!1,!0),Pe=le.translate(B.threshold||0,!1,!0,!1,!0),Ue=this.crispCol(0,Math.min(We,Pe),0,Math.abs(We-Pe));ue=Ue.y,ge=Ue.height}let ye=(_e.negative?-1:1)*(he?-1:1)==-1,Ae=we.where;!Ae&&this.is("waterfall")&&Math.abs((_e.yBottom||0)-(this.translatedThreshold||0))>this.borderWidth&&(Ae="all"),Ae||(Ae="end");let Re=Math.min($(we.radius,ae),ae/2,Ae==="all"?ie/2:1/0)||0;Ae==="end"&&(ye&&(ue-=Re),ge+=Re),b(ve,{brBoxHeight:ge,brBoxY:ue,r:Re})}}}}function N(B,le){return x(B)||(B={radius:B||0}),S(k,le,B)}function ee(){let B=N(this.options.borderRadius);for(let le of this.points){let fe=le.shapeArgs;fe&&(fe.borderRadius=$(B.radius,(fe.r||0)-(fe.innerR||0)))}}function ne(B,le,fe,xe,we={}){let he=D(B,le,fe,xe,we),{r:_e=0,brBoxHeight:ve=xe,brBoxY:ae=le}=we,ie=le-ae,pe=ae+ve-(le+xe),ue=ie-_e>-.1?0:_e,ge=pe-_e>-.1?0:_e,ye=Math.max(ue&&ie,0),Ae=Math.max(ge&&pe,0),Re=[B+ue,le],We=[B+fe-ue,le],Pe=[B+fe,le+ue],Ue=[B+fe,le+xe-ge],Oe=[B+fe-ge,le+xe],Be=[B+ge,le+xe],Ye=[B,le+xe-ge],Se=[B,le+ue],Te=($e,Ve)=>Math.sqrt(Math.pow($e,2)-Math.pow(Ve,2));if(ye){let $e=Te(ue,ue-ye);Re[0]-=$e,We[0]+=$e,Pe[1]=Se[1]=le+ue-ye}if(xe=b(I.minWidth,0)&&this.chartHeight>=b(I.minHeight,0)}).call(this)&&D.push(T._id)}function k(T,D){let I=this.options.responsive,O=this.currentResponsive,N=[],ee;!D&&I&&I.rules&&I.rules.forEach(le=>{le._id===void 0&&(le._id=x()),this.matchResponsiveRule(le,N)},this);let ne=g(...N.map(le=>u((I||{}).rules||[],fe=>fe._id===le)).map(le=>le&&le.chartOptions));ne.isResponsiveOptions=!0,N=N.toString()||void 0;let B=O&&O.ruleIds;N!==B&&(O&&this.update(O.undoOptions,T,!0),N?((ee=l(ne,this.options,!0,this.collectionsWithUpdate)).isResponsiveOptions=!0,this.currentResponsive={ruleIds:N,mergedOptions:ne,undoOptions:ee},this.update(ne,T,!0)):this.currentResponsive=void 0)}S.compose=function(T){let D=T.prototype;return D.matchResponsiveRule||c(D,{matchResponsiveRule:$,setResponsive:k}),T}}(a||(a={})),a}),n(r,"masters/highcharts.src.js",[r["Core/Globals.js"],r["Core/Utilities.js"],r["Core/Defaults.js"],r["Core/Animation/Fx.js"],r["Core/Animation/AnimationUtilities.js"],r["Core/Renderer/HTML/AST.js"],r["Core/Templating.js"],r["Core/Renderer/RendererRegistry.js"],r["Core/Renderer/RendererUtilities.js"],r["Core/Renderer/SVG/SVGElement.js"],r["Core/Renderer/SVG/SVGRenderer.js"],r["Core/Renderer/HTML/HTMLElement.js"],r["Core/Axis/Axis.js"],r["Core/Axis/DateTimeAxis.js"],r["Core/Axis/LogarithmicAxis.js"],r["Core/Axis/PlotLineOrBand/PlotLineOrBand.js"],r["Core/Axis/Tick.js"],r["Core/Tooltip.js"],r["Core/Series/Point.js"],r["Core/Pointer.js"],r["Core/Legend/Legend.js"],r["Core/Legend/LegendSymbol.js"],r["Core/Chart/Chart.js"],r["Extensions/ScrollablePlotArea.js"],r["Core/Axis/Stacking/StackingAxis.js"],r["Core/Axis/Stacking/StackItem.js"],r["Core/Series/Series.js"],r["Core/Series/SeriesRegistry.js"],r["Series/Column/ColumnDataLabel.js"],r["Series/Pie/PieDataLabel.js"],r["Core/Series/DataLabel.js"],r["Extensions/OverlappingDataLabels.js"],r["Extensions/BorderRadius.js"],r["Core/Responsive.js"],r["Core/Color/Color.js"],r["Core/Time.js"]],function(o,a,l,c,u,g,b,x,S,$,k,T,D,I,O,N,ee,ne,B,le,fe,xe,we,he,_e,ve,ae,ie,pe,ue,ge,ye,Ae,Re,We,Pe){return o.AST=g,o.Axis=D,o.Chart=we,o.Color=We,o.DataLabel=ge,o.Fx=c,o.HTMLElement=T,o.Legend=fe,o.LegendSymbol=xe,o.OverlappingDataLabels=o.OverlappingDataLabels||ye,o.PlotLineOrBand=N,o.Point=B,o.Pointer=le,o.RendererRegistry=x,o.Series=ae,o.SeriesRegistry=ie,o.StackItem=ve,o.SVGElement=$,o.SVGRenderer=k,o.Templating=b,o.Tick=ee,o.Time=Pe,o.Tooltip=ne,o.animate=u.animate,o.animObject=u.animObject,o.chart=we.chart,o.color=We.parse,o.dateFormat=b.dateFormat,o.defaultOptions=l.defaultOptions,o.distribute=S.distribute,o.format=b.format,o.getDeferredAnimation=u.getDeferredAnimation,o.getOptions=l.getOptions,o.numberFormat=b.numberFormat,o.seriesType=ie.seriesType,o.setAnimation=u.setAnimation,o.setOptions=l.setOptions,o.stop=u.stop,o.time=l.defaultTime,o.timers=c.timers,Ae.compose(o.Series,o.SVGElement,o.SVGRenderer),pe.compose(o.Series.types.column),ge.compose(o.Series),I.compose(o.Axis),T.compose(o.SVGRenderer),fe.compose(o.Chart),O.compose(o.Axis),ye.compose(o.Chart),ue.compose(o.Series.types.pie),N.compose(o.Axis),le.compose(o.Chart),Re.compose(o.Chart),he.compose(o.Axis,o.Chart,o.Series),_e.compose(o.Axis,o.Chart,o.Series),ne.compose(o.Pointer),a.extend(o,a),o}),r["masters/highcharts.src.js"]._modules=r,r["masters/highcharts.src.js"]})}(highcharts)),highcharts.exports}const require$$1=getAugmentedNamespace(vue_runtime_esmBundler);(function(e,t){(function(r,n){e.exports=n(requireHighcharts(),require$$1)})(self,(r,n)=>(()=>{var o={879:u=>{u.exports=r},744:u=>{u.exports=n}},a={};function l(u){var g=a[u];if(g!==void 0)return g.exports;var b=a[u]={exports:{}};return o[u](b,b.exports,l),b.exports}l.n=u=>{var g=u&&u.__esModule?()=>u.default:()=>u;return l.d(g,{a:g}),g},l.d=(u,g)=>{for(var b in g)l.o(g,b)&&!l.o(u,b)&&Object.defineProperty(u,b,{enumerable:!0,get:g[b]})},l.o=(u,g)=>Object.prototype.hasOwnProperty.call(u,g),l.r=u=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})};var c={};return(()=>{l.r(c),l.d(c,{Chart:()=>T,default:()=>D});var u=l(879),g=l.n(u),b=function I(O,N){var ee=g().isArray(O)?[]:{};function ne(B,le){!g().isObject(B,!N)||g().isClass(B)||g().isDOMElement(B)?ee[le]=B:ee[le]=I(B,N)}return g().isArray(O)?O.forEach(function(B,le){return ne(B,le)}):g().objectEach(O,ne),ee},x=l(744);function S(I){return function(O){if(Array.isArray(O))return $(O)}(I)||function(O){if(typeof Symbol<"u"&&O[Symbol.iterator]!=null||O["@@iterator"]!=null)return Array.from(O)}(I)||function(O,N){if(!!O){if(typeof O=="string")return $(O,N);var ee=Object.prototype.toString.call(O).slice(8,-1);if(ee==="Object"&&O.constructor&&(ee=O.constructor.name),ee==="Map"||ee==="Set")return Array.from(O);if(ee==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(ee))return $(O,N)}}(I)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function $(I,O){(O==null||O>I.length)&&(O=I.length);for(var N=0,ee=new Array(O);N1&&arguments[1]!==void 0?arguments[1]:{};I.component(O.tagName||"highcharts",k(O.highcharts||g()))}})(),c})())})(highchartsVue_min);const Chart_vue_vue_type_style_index_0_lang="",_sfc_main$6={components:{Chart:highchartsVue_min.exports.Chart},props:["point","log"],data(){return{chartOptions:{},provider:this.$route.params.provider,chartObj:null}},computed:{series(){const e=this.log.map(r=>[r.timestamp,r.data]);let t=[];return e.forEach(r=>{const n=r[0]??null;for(const[o,a]of Object.entries(r[1])){t.find(c=>c.name.toLowerCase()===o.toLowerCase())||t.push({name:o.toLowerCase()});const l=t.findIndex(c=>c.name.toLowerCase()===o.toLowerCase());if(l>-1&&a){t[l]?.data||(t[l].data=[]),t[l].data.push([n*1e3,parseFloat(a)]);for(const[c,u]of Object.entries(measurements))o.toLowerCase()===c.toLowerCase()&&u?.zones&&!t[l]?.zones&&(t[l].zones=u.zones)}}}),t},startpoint(){if(this.provider==="realtime")return Date.now();{let e=new Date;return e.setHours(0,0,0,0),e}}},watch:{series(e){e.forEach((t,r)=>{this.chartObj.series[r].setData(t.data,!1)}),this.chartObj.redraw()}},mounted(){const{chart:e}=this.$refs.chart;this.chartObj=e,this.chartOptions={chart:{type:"spline",height:400},title:{text:""},time:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},series:this.series,xAxis:{title:!1,type:"datetime",labels:{overflow:"justify",format:"{value: %H:%M }"}},yAxis:{title:!1},plotOptions:{series:{lineWidth:2,states:{hover:{lineWidth:3}},pointStart:this.startpoint,dataLabels:{enabled:!0,allowOverlap:!0,formatter(){if(this.point.index==this.series.points.length-1)return`${this.series.name}`}}}}}}};function _sfc_render$6(e,t,r,n,o,a){const l=resolveComponent("Chart",!0);return openBlock(),createBlock(l,{options:o.chartOptions,ref:"chart"},null,8,["options"])}const Chart=_export_sfc(_sfc_main$6,[["render",_sfc_render$6]]),Copy_vue_vue_type_style_index_0_scoped_951f909f_lang="",_sfc_main$5={props:["msg","title","notify"],data(){return{successCopy:!1}},methods:{success(){this.$notify({position:"top right",text:this.notify})},showSuccessesCopy(){this.successCopy=!0,setTimeout(()=>{this.successCopy=!1},2e3)}}},_hoisted_1$4=["title"];function _sfc_render$5(e,t,r,n,o,a){const l=resolveComponent("font-awesome-icon"),c=resolveDirective("clipboard");return withDirectives((openBlock(),createElementBlock("a",{class:"nowrap copy",title:r.title},[renderSlot(e.$slots,"default",{},void 0,!0),o.successCopy?createCommentVNode("",!0):(openBlock(),createElementBlock("button",{key:0,class:"copy-btn",onClick:t[0]||(t[0]=(...u)=>a.showSuccessesCopy&&a.showSuccessesCopy(...u))})),o.successCopy?(openBlock(),createBlock(l,{key:1,icon:"fa-solid fa-check"})):createCommentVNode("",!0)],8,_hoisted_1$4)),[[c,r.msg,"copy"],[c,a.success,"success"]])}const Copy=_export_sfc(_sfc_main$5,[["render",_sfc_render$5],["__scopeId","data-v-951f909f"]]),SensorPopup_vue_vue_type_style_index_0_scoped_cf7806f0_lang="",_sfc_main$4={emits:["close"],props:["type","point"],components:{Chart,Copy,Bookmark},data(){return{select:"",measurement:this.type,isShowPath:!1,store:useStore(),start:hooks().format("YYYY-MM-DD"),maxDate:hooks().format("YYYY-MM-DD"),provider:this.$route.params.provider,rttime:null,rtdata:[]}},computed:{locale(){return localStorage.getItem("locale")||this.$i18n.locale||"en"},address(){return this.point.address},donated_by(){return this.point.donated_by},geo(){return this.point.geo},log(){return this.point?.log},model(){return this.point.model},sender(){return this.point.sender},sensor_id(){return this.point.sensor_id},realtime(){return this.provider==="realtime"},addressformatted(){let e="";return this.address.country&&(e+=this.address.country),this.address.address.length>0&&(e+=", "+this.address.address.join(", ")),e},isLocationRussion(){return this.address.country==="\u0420\u043E\u0441\u0441\u0438\u044F"||this.address.country==="Russia"},measure(){return this.items.find(e=>this.select===e.text)},scale(){return generate$1(measurements[this.type.toLowerCase()].colors,measurements[this.type.toLowerCase()].range)},hasIcon(){return e=>measurements[e.toLowerCase()]&&measurements[e.toLowerCase()].icon},icon:function(){return e=>this.hasIcon(e)?measurements[e.toLowerCase()].icon:"vial"},items(){const e=[];for(const t of Object.keys(this.last.data)){let r=null;measurements[t.toLowerCase()]&&measurements[t.toLowerCase()].colors&&(r=generate$1(measurements[t.toLowerCase()].colors,measurements[t.toLowerCase()].range)),e.push({id:t,title:this.$filters.measurementFormat(this.last.data[t],t),text:this.$filters.measurement(t),state:getState(r,this.last.data[t],measurements[t.toLowerCase()]?measurements[t.toLowerCase()].states:void 0)})}return e},measurementFilter(e){return measurements[e.toLowerCase()]?.label||e},measurementFormat(e,t){return measurements[t.toLowerCase()]?`${toFixed(e)} ${measurements[t.toLowerCase()].unit}`:toFixed(e)},collapse(e){return e?e.slice(0,6)+"..."+e.slice(-4):""},linkSensor:function(){const e=this.$router.resolve({name:"main",params:{provider:getTypeProvider(),type:this.$route.params.type||"pm10",zoom:this.$route.params.zoom||config$2.MAP.zoom,lat:this.geo.lat,lng:this.geo.lng,sensor:this.sensor_id}});return new URL(e.href,window.location.origin).href},link:function(){return sensors[this.sensor_id]?sensors[this.sensor_id].link:""},icon:function(){return sensors[this.sensor_id]?sensors[this.sensor_id].icon:""},last:function(){return this.log[this.log.length-1]},date:function(){return hooks(this.last.timestamp,"X").format("DD.MM.YYYY HH:mm:ss")},startTimestamp:function(){return Number(hooks(this.start+" 00:00:00","YYYY-MM-DD HH:mm:ss").format("X"))},endTimestamp:function(){return Number(hooks(this.start+" 23:59:59","YYYY-MM-DD HH:mm:ss").format("X"))},sharable:function(){return navigator.share&&navigator.canShare},units(){let e=[];return Object.values(this.log).forEach(t=>{Object.keys(t.data).forEach(r=>{e.push(r)})}),[...new Set(e.flat())]},scales:function(){let e=[];return Object.keys(measurements).forEach(t=>{this.units.some(r=>r===t)&&e.push(measurements[t])}),e}},methods:{shareData(){navigator.share({title:"Public Sensor Map",url:this.linkSensor?this.linkSensor:this.link}).then(()=>{console.log("Shared")}).catch(console.error)},getHistory(){this.realtime||this.$emit("history",{sensor_id:this.sensor_id,start:this.startTimestamp,end:this.endTimestamp})},updatert(){if(this.realtime){const e=this.log[this.log.length-1].timestamp*1e3;e&&(this.rttime=new Date(e).toLocaleString());const t=this.log[this.log.length-1].data;let r={};t&&(this.rtdata=[],Object.keys(measurements).forEach(n=>{Object.keys(t).forEach(o=>{n===o&&(r={},r.key=o,r.measure=t[o],r.label=measurements[n].label,r.unit=measurements[n].unit,measurements[n].zones.find(a=>r.measurer.measuremeasurements[n].zones[measurements[n].zones.length-2].value&&(r.color=measurements[n].zones[measurements[n].zones.length-1].color),this.rtdata.push(r))})}))}},closesensor(){const e=window.location.href;if(e.includes(this.sensor_id)){const t=e.replace(this.sensor_id,"");window.location.href=t}this.$emit("close")}},watch:{sensor_id(){this.isShowPath=!1},isShowPath(){this.isShowPath?showPath(this.sensor_id):hidePath(this.sensor_id)},start(){this.getHistory()},log(){this.updatert()}},mounted(){this.updatert()}},_withScopeId$3=e=>(pushScopeId("data-v-cf7806f0"),e=e(),popScopeId(),e),_hoisted_1$3={class:"popup-js active"},_hoisted_2$3={class:"flexline clipoverflow"},_hoisted_3$2=["src"],_hoisted_4$1={class:"scrollable-y"},_hoisted_5$1={class:"flexline space-between"},_hoisted_6$2={class:"flexline"},_hoisted_7$2=["max"],_hoisted_8$2={key:0,class:"flexline"},_hoisted_9$2=_withScopeId$3(()=>createBaseVNode("div",{class:"rt-title"},"Realtime view mode",-1)),_hoisted_10$1={key:0,class:"rt-time"},_hoisted_11$1={class:"rt-unit"},_hoisted_12$1={key:0,class:"infoline flexline"},_hoisted_13$1={class:"infoline-title"},_hoisted_14$1={class:"infoline-info"},_hoisted_15$1={key:1,class:"infoline flexline"},_hoisted_16$1={class:"infoline-title"},_hoisted_17$1={class:"infoline-info"},_hoisted_18$1={key:2,class:"infoline flexline"},_hoisted_19$1={class:"infoline-title"},_hoisted_20$1={class:"infoline-info"},_hoisted_21$1=["href"],_hoisted_22$1={key:3,class:"infoline flexline"},_hoisted_23$1={class:"infoline-title"},_hoisted_24$1={class:"infoline-info"},_hoisted_25$1={key:4,class:"infoline flexline"},_hoisted_26$1={class:"infoline-title"},_hoisted_27$1=_withScopeId$3(()=>createBaseVNode("label",{for:"realtime"},null,-1)),_hoisted_28$1={class:"sensors-switcher-text"},_hoisted_29$1={class:"infoline-info"},_hoisted_30$1={key:1},_hoisted_31$1={class:"scalegrid"},_hoisted_32$1={key:0},_hoisted_33$1={key:1},_hoisted_34$1={class:"textsmall"};function _sfc_render$4(e,t,r,n,o,a){const l=resolveComponent("font-awesome-icon"),c=resolveComponent("Bookmark"),u=resolveComponent("Chart"),g=resolveComponent("Copy");return openBlock(),createElementBlock("div",_hoisted_1$3,[createBaseVNode("section",null,[createBaseVNode("h3",_hoisted_2$3,[a.icon?(openBlock(),createElementBlock("img",{key:0,src:a.icon,class:"icontitle"},null,8,_hoisted_3$2)):(openBlock(),createBlock(l,{key:1,icon:"fa-solid fa-location-dot"})),createTextVNode(" "+toDisplayString$1(a.addressformatted),1)])]),createBaseVNode("div",_hoisted_4$1,[createBaseVNode("section",_hoisted_5$1,[createBaseVNode("div",_hoisted_6$2,[a.realtime?createCommentVNode("",!0):withDirectives((openBlock(),createElementBlock("input",{key:0,type:"date","onUpdate:modelValue":t[0]||(t[0]=b=>o.start=b),max:o.maxDate},null,8,_hoisted_7$2)),[[vModelText,o.start]]),createVNode(c,{address:a.address?.address&&a.address?.address.join(", "),link:a.linkSensor},null,8,["address","link"])]),a.sharable?(openBlock(),createElementBlock("button",{key:0,onClick:t[1]||(t[1]=(...b)=>a.shareData&&a.shareData(...b)),class:"button"},[createVNode(l,{icon:"fa-solid fa-share-from-square"})])):createCommentVNode("",!0)]),a.realtime?(openBlock(),createElementBlock("section",_hoisted_8$2,[createBaseVNode("div",null,[_hoisted_9$2,o.rttime?(openBlock(),createElementBlock("div",_hoisted_10$1,toDisplayString$1(o.rttime),1)):createCommentVNode("",!0)]),o.rtdata?(openBlock(!0),createElementBlock(Fragment,{key:0},renderList(o.rtdata,b=>(openBlock(),createElementBlock("div",{key:b},[createBaseVNode("div",_hoisted_11$1,toDisplayString$1(b.label),1),createBaseVNode("div",{class:"rt-number",style:normalizeStyle(b.color?"color:"+b.color:"")},toDisplayString$1(b.measure)+" "+toDisplayString$1(b.unit),5)]))),128)):createCommentVNode("",!0)])):createCommentVNode("",!0),createBaseVNode("section",null,[createVNode(u,{point:r.point,log:a.log},null,8,["point","log"])]),createBaseVNode("section",null,[createBaseVNode("h3",null,toDisplayString$1(e.$t("sensorpopup.infotitle")),1),a.sensor_id?(openBlock(),createElementBlock("div",_hoisted_12$1,[createBaseVNode("div",_hoisted_13$1,toDisplayString$1(e.$t("sensorpopup.infosensorid"))+":",1),createBaseVNode("div",_hoisted_14$1,[createTextVNode(toDisplayString$1(e.$filters.collapse(a.sensor_id))+" ",1),createVNode(g,{msg:a.sensor_id,title:`Sensor id: ${a.sensor_id}`,notify:e.$t("details.copied")},null,8,["msg","title","notify"])])])):createCommentVNode("",!0),a.geo?(openBlock(),createElementBlock("div",_hoisted_15$1,[createBaseVNode("div",_hoisted_16$1,toDisplayString$1(e.$t("sensorpopup.infosensorgeo"))+":",1),createBaseVNode("div",_hoisted_17$1,toDisplayString$1(a.geo.lat)+", "+toDisplayString$1(a.geo.lng),1)])):createCommentVNode("",!0),a.link?(openBlock(),createElementBlock("div",_hoisted_18$1,[createBaseVNode("div",_hoisted_19$1,toDisplayString$1(e.$t("sensorpopup.infosensorowner"))+":",1),createBaseVNode("div",_hoisted_20$1,[createBaseVNode("a",{href:a.link,rel:"noopener",target:"_blank"},toDisplayString$1(a.link),9,_hoisted_21$1)])])):createCommentVNode("",!0),a.donated_by?(openBlock(),createElementBlock("div",_hoisted_22$1,[createBaseVNode("div",_hoisted_23$1,toDisplayString$1(e.$t("sensorpopup.infosensordonated"))+":",1),createBaseVNode("div",_hoisted_24$1,toDisplayString$1(a.donated_by),1)])):createCommentVNode("",!0),a.model===3?(openBlock(),createElementBlock("div",_hoisted_25$1,[createBaseVNode("div",_hoisted_26$1,[_hoisted_27$1,createBaseVNode("span",_hoisted_28$1,toDisplayString$1(e.$t("details.showpath")),1),createTextVNode(": ")]),createBaseVNode("div",_hoisted_29$1,[withDirectives(createBaseVNode("input",{type:"checkbox",id:"realtime","onUpdate:modelValue":t[2]||(t[2]=b=>o.isShowPath=b)},null,512),[[vModelCheckbox,o.isShowPath]])])])):createCommentVNode("",!0)]),a.units&&a.scales&&a.scales.length>0?(openBlock(),createElementBlock("section",_hoisted_30$1,[createBaseVNode("h3",null,toDisplayString$1(e.$t("scales.title")),1),createBaseVNode("div",_hoisted_31$1,[(openBlock(!0),createElementBlock(Fragment,null,renderList(a.scales,b=>(openBlock(),createElementBlock("div",{key:b.label},[b?.zones&&(b.name||b.label)?(openBlock(),createElementBlock(Fragment,{key:0},[createBaseVNode("p",null,[b.name?(openBlock(),createElementBlock("b",_hoisted_32$1,toDisplayString$1(a.locale==="en"?b.name.en:b.name.ru),1)):(openBlock(),createElementBlock("b",_hoisted_33$1,toDisplayString$1(b.label),1)),createTextVNode(" ("+toDisplayString$1(b.unit)+") ",1)]),(openBlock(!0),createElementBlock(Fragment,null,renderList(b.zones,x=>(openBlock(),createElementBlock(Fragment,{key:x.color},[x.color&&x.label?(openBlock(),createElementBlock("div",{key:0,class:"scales-color",style:normalizeStyle(`--color: ${x.color}`)},[createBaseVNode("b",null,toDisplayString$1(a.locale==="en"?x.label.en:x.label.ru),1),createTextVNode(" ("),x.value?(openBlock(),createElementBlock(Fragment,{key:0},[createTextVNode(toDisplayString$1(e.$t("scales.upto"))+" "+toDisplayString$1(x.value),1)],64)):(openBlock(),createElementBlock(Fragment,{key:1},[createTextVNode(toDisplayString$1(e.$t("scales.above")),1)],64)),createTextVNode(") ")],4)):createCommentVNode("",!0)],64))),128))],64)):createCommentVNode("",!0)]))),128))])])):createCommentVNode("",!0),createBaseVNode("div",_hoisted_34$1,[a.isLocationRussion?(openBlock(),createElementBlock(Fragment,{key:0},[createTextVNode(toDisplayString$1(e.$t("notice_with_fz")),1)],64)):(openBlock(),createElementBlock(Fragment,{key:1},[createTextVNode(toDisplayString$1(e.$t("notice_without_fz")),1)],64))])]),createBaseVNode("button",{onClick:t[3]||(t[3]=withModifiers((...b)=>a.closesensor&&a.closesensor(...b),["prevent"])),"aria-label":"Close sensor",class:"close"},[createVNode(l,{icon:"fa-solid fa-xmark"})])])}const SensorPopup=_export_sfc(_sfc_main$4,[["render",_sfc_render$4],["__scopeId","data-v-cf7806f0"]]);function asUint8Array(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function alloc(e=0){return globalThis.Buffer?.alloc!=null?asUint8Array(globalThis.Buffer.alloc(e)):new Uint8Array(e)}function allocUnsafe$2(e=0){return globalThis.Buffer?.allocUnsafe!=null?asUint8Array(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}const N1$2=Math.pow(2,7),N2$2=Math.pow(2,14),N3$2=Math.pow(2,21),N4$2=Math.pow(2,28),N5$2=Math.pow(2,35),N6$2=Math.pow(2,42),N7$2=Math.pow(2,49),MSB$4=128,REST$4=127;function encodingLength$2(e){if(eNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function encodeUint8Array(e,t,r=0){switch(encodingLength$2(e)){case 8:t[r++]=e&255|MSB$4,e/=128;case 7:t[r++]=e&255|MSB$4,e/=128;case 6:t[r++]=e&255|MSB$4,e/=128;case 5:t[r++]=e&255|MSB$4,e/=128;case 4:t[r++]=e&255|MSB$4,e>>>=7;case 3:t[r++]=e&255|MSB$4,e>>>=7;case 2:t[r++]=e&255|MSB$4,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function encodeUint8ArrayList(e,t,r=0){switch(encodingLength$2(e)){case 8:t.set(r++,e&255|MSB$4),e/=128;case 7:t.set(r++,e&255|MSB$4),e/=128;case 6:t.set(r++,e&255|MSB$4),e/=128;case 5:t.set(r++,e&255|MSB$4),e/=128;case 4:t.set(r++,e&255|MSB$4),e>>>=7;case 3:t.set(r++,e&255|MSB$4),e>>>=7;case 2:t.set(r++,e&255|MSB$4),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function decodeUint8Array(e,t){let r=e[t],n=0;if(n+=r&REST$4,ro+a.length,0));const r=allocUnsafe$2(t);let n=0;for(const o of e)r.set(o,n),n+=o.length;return asUint8Array(r)}function equals$2(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(const n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(isUint8ArrayList(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(const n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(isUint8ArrayList(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){const r=findBufAndOffset(this.bufs,t);return r.buf[r.index]}set(t,r){const n=findBufAndOffset(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){const{bufs:n,length:o}=this._subList(t,r);return concat$1(n,o)}subarray(t,r){const{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:concat$1(n,o)}sublist(t,r){const{bufs:n,length:o}=this._subList(t,r),a=new Uint8ArrayList;return a.length=o,a.bufs=n,a}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};const n=[];let o=0;for(let a=0;a=u)continue;const g=t>=c&&tc&&r<=u;if(g&&b){if(t===c&&r===u){n.push(l);break}const x=t-c;n.push(l.subarray(x,x+(r-t)));break}if(g){if(t===0){n.push(l);continue}n.push(l.subarray(t-c));continue}if(b){if(r===u){n.push(l);break}n.push(l.subarray(0,r-c));break}n.push(l)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!isUint8ArrayList(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');const n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;const o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");const a=256,l=new Int32Array(a);for(let x=0;x=0;S--){const $=this.get(x+S);if(n[S]!==$){b=Math.max(1,S-c[$]);break}}if(b===0)return x}return-1}getInt8(t){const r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){const n=allocUnsafe$2(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){const n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){const o=alloc(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){const n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){const o=alloc(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){const n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){const o=alloc(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){const r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){const n=allocUnsafe$2(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){const n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){const o=alloc(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){const n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){const o=alloc(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){const n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){const o=alloc(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){const n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){const o=alloc(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){const n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){const o=alloc(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof Uint8ArrayList)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;ro+a.byteLength,0)),n.length=r,n}}function isAsyncIterable$a(e){return e[Symbol.asyncIterator]!=null}const defaultEncoder=e=>{const t=encodingLength$2(e),r=allocUnsafe$2(t);return encode$d(e,r),defaultEncoder.bytes=t,r};defaultEncoder.bytes=0;function encode$c(e,t){t=t??{};const r=t.lengthEncoder??defaultEncoder;function*n(o){const a=r(o.byteLength);a instanceof Uint8Array?yield a:yield*a,o instanceof Uint8Array?yield o:yield*o}return isAsyncIterable$a(e)?async function*(){for await(const o of e)yield*n(o)}():function*(){for(const o of e)yield*n(o)}()}encode$c.single=(e,t)=>{t=t??{};const r=t.lengthEncoder??defaultEncoder;return new Uint8ArrayList(r(e.byteLength),e)};function assign$1(e,t){for(const r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}function createError(e,t,r){if(!e||typeof e=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof t=="object"&&(r=t,t=""),t&&(r.code=t);try{return assign$1(e,r)}catch{r.message=e.message,r.stack=e.stack;const o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(e)),assign$1(new o,r)}}var errCode=createError;const MAX_LENGTH_LENGTH=8,MAX_DATA_LENGTH=1024*1024*4;var ReadMode;(function(e){e[e.LENGTH=0]="LENGTH",e[e.DATA=1]="DATA"})(ReadMode||(ReadMode={}));const defaultDecoder=e=>{const t=decode$b(e);return defaultDecoder.bytes=encodingLength$2(t),t};defaultDecoder.bytes=0;function decode$a(e,t){const r=new Uint8ArrayList;let n=ReadMode.LENGTH,o=-1;const a=t?.lengthDecoder??defaultDecoder,l=t?.maxLengthLength??MAX_LENGTH_LENGTH,c=t?.maxDataLength??MAX_DATA_LENGTH;function*u(){for(;r.byteLength>0;){if(n===ReadMode.LENGTH)try{if(o=a(r),o<0)throw errCode(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>c)throw errCode(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");const g=a.bytes;r.consume(g),t?.onLength!=null&&t.onLength(o),n=ReadMode.DATA}catch(g){if(g instanceof RangeError){if(r.byteLength>l)throw errCode(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw g}if(n===ReadMode.DATA){if(r.byteLength0)throw errCode(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(const g of e)r.append(g),yield*u();if(r.byteLength>0)throw errCode(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}decode$a.fromReader=(e,t)=>{let r=1;const n=async function*(){for(;;)try{const{done:a,value:l}=await e.next(r);if(a===!0)return;l!=null&&(yield l)}catch(a){if(a.code==="ERR_UNDER_READ")return{done:!0,value:null};throw a}finally{r=1}}();return decode$a(n,{...t??{},onLength:a=>{r=a}})};function pDefer(){const e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}class FixedFIFO{constructor(t){Xe(this,"buffer");Xe(this,"mask");Xe(this,"top");Xe(this,"btm");Xe(this,"next");if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){const t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}}class FIFO{constructor(t={}){Xe(this,"size");Xe(this,"hwm");Xe(this,"head");Xe(this,"tail");this.hwm=t.splitLimit??16,this.head=new FixedFIFO(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){const r=this.head;this.head=r.next=new FixedFIFO(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){const r=this.tail.next;this.tail.next=null,this.tail=r,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}}class AbortError$6 extends Error{constructor(r,n){super(r??"The operation was aborted");Xe(this,"type");Xe(this,"code");this.type="aborted",this.code=n??"ABORT_ERR"}}function pushable(e={}){return _pushable(r=>{const n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},e)}function pushableV(e={}){return _pushable(r=>{let n;const o=[];for(;!r.isEmpty()&&(n=r.shift(),n!=null);){if(n.error!=null)throw n.error;n.done===!1&&o.push(n.value)}return n==null?{done:!0}:{done:n.done===!0,value:o}},e)}function _pushable(e,t){t=t??{};let r=t.onEnd,n=new FIFO,o,a,l,c=pDefer();const u=async()=>{try{return n.isEmpty()?l?{done:!0}:await new Promise((D,I)=>{a=O=>{a=null,n.push(O);try{D(e(n))}catch(N){I(N)}return o}}):e(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=pDefer()})}},g=D=>a!=null?a(D):(n.push(D),o),b=D=>(n=new FIFO,a!=null?a({error:D}):(n.push({error:D}),o)),x=D=>{if(l)return o;if(t?.objectMode!==!0&&D?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return g({done:!1,value:D})},S=D=>l?o:(l=!0,D!=null?b(D):g({done:!0})),$=()=>(n=new FIFO,S(),{done:!0}),k=D=>(S(D),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:u,return:$,throw:k,push:x,end:S,get readableLength(){return n.size},onEmpty:async D=>{const I=D?.signal;if(I?.throwIfAborted(),n.isEmpty())return;let O,N;I!=null&&(O=new Promise((ee,ne)=>{N=()=>{ne(new AbortError$6)},I.addEventListener("abort",N)}));try{await Promise.race([c.promise,O])}finally{N!=null&&I!=null&&I?.removeEventListener("abort",N)}}},r==null)return o;const T=o;return o={[Symbol.asyncIterator](){return this},next(){return T.next()},throw(D){return T.throw(D),r!=null&&(r(D),r=void 0),{done:!0}},return(){return T.return(),r!=null&&(r(),r=void 0),{done:!0}},push:x,end(D){return T.end(D),r!=null&&(r(D),r=void 0),o},get readableLength(){return T.readableLength}},o}class CodeError$2 extends Error{constructor(r,n){super(r);Xe(this,"code");this.code=n}}class AbortError$5 extends CodeError$2{constructor(r){super(r,"ABORT_ERR");Xe(this,"type");this.type="aborted"}}function byteStream(e){const t=pushable();e.sink(t).catch(a=>{t.end(a)}),e.sink=async a=>{for await(const l of a)t.push(l);t.end()};let r=e.source;e.source[Symbol.iterator]!=null?r=e.source[Symbol.iterator]():e.source[Symbol.asyncIterator]!=null&&(r=e.source[Symbol.asyncIterator]());const n=new Uint8ArrayList;return{read:async(a,l)=>{l?.signal?.throwIfAborted();let c;const u=new Promise((g,b)=>{c=()=>{b(new AbortError$5("Read aborted"))},l?.signal?.addEventListener("abort",c)});try{if(a==null){const{done:b,value:x}=await Promise.race([r.next(),u]);return b===!0?new Uint8ArrayList:x}for(;n.byteLength{l?.signal?.throwIfAborted(),a instanceof Uint8Array?t.push(a):t.push(a.subarray()),await t.onEmpty(l)},unwrap:()=>{const a=e.source;return e.source=async function*(){yield*n,yield*a}(),e}}}class CodeError$1 extends Error{constructor(r,n){super(r);Xe(this,"code");this.code=n}}const defaultLengthDecoder=e=>decode$b(e);defaultLengthDecoder.bytes=0;function lpStream(e,t){const r=byteStream(e);return{read:async o=>{let a=-1;const l=new Uint8ArrayList,c=t?.lengthDecoder??defaultLengthDecoder;for(;;){l.append(await r.read(1,o));try{a=c(l)}catch(u){if(u instanceof RangeError)continue;throw u}if(a>-1)break;if(t?.maxLengthLength!=null&&l.byteLength>t.maxLengthLength)throw new CodeError$1("message length length too long","ERR_MSG_LENGTH_TOO_LONG")}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new CodeError$1("message length too long","ERR_MSG_DATA_TOO_LONG");return r.read(a,o)},write:async(o,a)=>{await r.write(encode$c.single(o,t),a)},unwrap:()=>r.unwrap()}}function pair(){const e=pDefer();let t=!1;return{sink:async r=>{if(t)throw new Error("already piped");t=!0,e.resolve(r)},source:async function*(){yield*await e.promise}()}}function duplexPair(){const e=pair(),t=pair();return[{source:e.source,sink:t.sink},{source:t.source,sink:e.sink}]}function isAsyncIterable$9(e){return e[Symbol.asyncIterator]!=null}function merge$1(...e){const t=[];for(const r of e)isAsyncIterable$9(r)||t.push(r);return t.length===e.length?function*(){for(const r of t)yield*r}():async function*(){const r=pushable({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(e.map(async n=>{for await(const o of n)r.push(o)})),r.end()}catch(n){r.end(n)}}),yield*r}()}function pipe(e,...t){if(e==null)throw new Error("Empty pipeline");if(isDuplex(e)){const n=e;e=()=>n.source}else if(isIterable(e)||isAsyncIterable$8(e)){const n=e;e=()=>n}const r=[e,...t];if(r.length>1&&isDuplex(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n{let t;for(;e.length>0;)t=e.shift()(t);return t},isAsyncIterable$8=e=>e?.[Symbol.asyncIterator]!=null,isIterable=e=>e?.[Symbol.iterator]!=null,isDuplex=e=>e==null?!1:e.sink!=null&&e.source!=null,duplexPipelineFn=e=>t=>{const r=e.sink(t);if(r?.then!=null){const n=pushable({objectMode:!0});r.then(()=>{n.end()},l=>{n.end(l)});let o;const a=e.source;if(isAsyncIterable$8(a))o=async function*(){yield*a,n.end()};else if(isIterable(a))o=function*(){yield*a,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return merge$1(n,o())}return e.source},NOISE_MSG_MAX_LENGTH_BYTES=65535,NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=NOISE_MSG_MAX_LENGTH_BYTES-16,DUMP_SESSION_KEYS=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS);/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const u8a$2=e=>e instanceof Uint8Array,u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),createView$1=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),isLE$1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!isLE$1)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes$2(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function toBytes$2(e){if(typeof e=="string"&&(e=utf8ToBytes$2(e)),!u8a$2(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}const isPlainObject$1=e=>Object.prototype.toString.call(e)==="[object Object]"&&e.constructor===Object;function checkOpts(e,t){if(t!==void 0&&(typeof t!="object"||!isPlainObject$1(t)))throw new Error("options must be object or undefined");return Object.assign(e,t)}function ensureBytes$1(e,t){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");if(typeof t=="number"&&e.length!==t)throw new Error(`Uint8Array length ${t} expected`)}function equalBytes$1(e,t){if(e.length!==t.length)throw new Error("equalBytes: Different size of Uint8Arrays");let r=!0;for(let n=0;n>o&a),c=Number(r&a),u=n?4:0,g=n?0:4;e.setUint32(t+u,l,n),e.setUint32(t+g,c,n)}function number$3(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function bytes$1(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$2(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("hash must be wrapped by utils.wrapConstructor");number$3(e.outputLen),number$3(e.blockLen)}function exists$1(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$1(e,t){bytes$1(e);const r=t.outputLen;if(e.lengthe[t++]&255|(e[t++]&255)<<8;class Poly1305{constructor(t){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,t=toBytes$2(t),ensureBytes$1(t,32);const r=u8to16(t,0),n=u8to16(t,2),o=u8to16(t,4),a=u8to16(t,6),l=u8to16(t,8),c=u8to16(t,10),u=u8to16(t,12),g=u8to16(t,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|o<<6)&7939,this.r[3]=(o>>>7|a<<9)&8191,this.r[4]=(a>>>4|l<<12)&255,this.r[5]=l>>>1&8190,this.r[6]=(l>>>14|c<<2)&8191,this.r[7]=(c>>>11|u<<5)&8065,this.r[8]=(u>>>8|g<<8)&8191,this.r[9]=g>>>5&127;for(let b=0;b<8;b++)this.pad[b]=u8to16(t,16+2*b)}process(t,r,n=!1){const o=n?0:2048,{h:a,r:l}=this,c=l[0],u=l[1],g=l[2],b=l[3],x=l[4],S=l[5],$=l[6],k=l[7],T=l[8],D=l[9],I=u8to16(t,r+0),O=u8to16(t,r+2),N=u8to16(t,r+4),ee=u8to16(t,r+6),ne=u8to16(t,r+8),B=u8to16(t,r+10),le=u8to16(t,r+12),fe=u8to16(t,r+14);let xe=a[0]+(I&8191),we=a[1]+((I>>>13|O<<3)&8191),he=a[2]+((O>>>10|N<<6)&8191),_e=a[3]+((N>>>7|ee<<9)&8191),ve=a[4]+((ee>>>4|ne<<12)&8191),ae=a[5]+(ne>>>1&8191),ie=a[6]+((ne>>>14|B<<2)&8191),pe=a[7]+((B>>>11|le<<5)&8191),ue=a[8]+((le>>>8|fe<<8)&8191),ge=a[9]+(fe>>>5|o),ye=0,Ae=ye+xe*c+we*(5*D)+he*(5*T)+_e*(5*k)+ve*(5*$);ye=Ae>>>13,Ae&=8191,Ae+=ae*(5*S)+ie*(5*x)+pe*(5*b)+ue*(5*g)+ge*(5*u),ye+=Ae>>>13,Ae&=8191;let Re=ye+xe*u+we*c+he*(5*D)+_e*(5*T)+ve*(5*k);ye=Re>>>13,Re&=8191,Re+=ae*(5*$)+ie*(5*S)+pe*(5*x)+ue*(5*b)+ge*(5*g),ye+=Re>>>13,Re&=8191;let We=ye+xe*g+we*u+he*c+_e*(5*D)+ve*(5*T);ye=We>>>13,We&=8191,We+=ae*(5*k)+ie*(5*$)+pe*(5*S)+ue*(5*x)+ge*(5*b),ye+=We>>>13,We&=8191;let Pe=ye+xe*b+we*g+he*u+_e*c+ve*(5*D);ye=Pe>>>13,Pe&=8191,Pe+=ae*(5*T)+ie*(5*k)+pe*(5*$)+ue*(5*S)+ge*(5*x),ye+=Pe>>>13,Pe&=8191;let Ue=ye+xe*x+we*b+he*g+_e*u+ve*c;ye=Ue>>>13,Ue&=8191,Ue+=ae*(5*D)+ie*(5*T)+pe*(5*k)+ue*(5*$)+ge*(5*S),ye+=Ue>>>13,Ue&=8191;let Oe=ye+xe*S+we*x+he*b+_e*g+ve*u;ye=Oe>>>13,Oe&=8191,Oe+=ae*c+ie*(5*D)+pe*(5*T)+ue*(5*k)+ge*(5*$),ye+=Oe>>>13,Oe&=8191;let Be=ye+xe*$+we*S+he*x+_e*b+ve*g;ye=Be>>>13,Be&=8191,Be+=ae*u+ie*c+pe*(5*D)+ue*(5*T)+ge*(5*k),ye+=Be>>>13,Be&=8191;let Ye=ye+xe*k+we*$+he*S+_e*x+ve*b;ye=Ye>>>13,Ye&=8191,Ye+=ae*g+ie*u+pe*c+ue*(5*D)+ge*(5*T),ye+=Ye>>>13,Ye&=8191;let Se=ye+xe*T+we*k+he*$+_e*S+ve*x;ye=Se>>>13,Se&=8191,Se+=ae*b+ie*g+pe*u+ue*c+ge*(5*D),ye+=Se>>>13,Se&=8191;let Te=ye+xe*D+we*T+he*k+_e*$+ve*S;ye=Te>>>13,Te&=8191,Te+=ae*x+ie*b+pe*g+ue*u+ge*c,ye+=Te>>>13,Te&=8191,ye=(ye<<2)+ye|0,ye=ye+Ae|0,Ae=ye&8191,ye=ye>>>13,Re+=ye,a[0]=Ae,a[1]=Re,a[2]=We,a[3]=Pe,a[4]=Ue,a[5]=Oe,a[6]=Be,a[7]=Ye,a[8]=Se,a[9]=Te}finalize(){const{h:t,pad:r}=this,n=new Uint16Array(10);let o=t[1]>>>13;t[1]&=8191;for(let c=2;c<10;c++)t[c]+=o,o=t[c]>>>13,t[c]&=8191;t[0]+=o*5,o=t[0]>>>13,t[0]&=8191,t[1]+=o,o=t[1]>>>13,t[1]&=8191,t[2]+=o,n[0]=t[0]+5,o=n[0]>>>13,n[0]&=8191;for(let c=1;c<10;c++)n[c]=t[c]+o,o=n[c]>>>13,n[c]&=8191;n[9]-=1<<13;let a=(o^1)-1;for(let c=0;c<10;c++)n[c]&=a;a=~a;for(let c=0;c<10;c++)t[c]=t[c]&a|n[c];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let l=t[0]+r[0];t[0]=l&65535;for(let c=1;c<8;c++)l=(t[c]+r[c]|0)+(l>>>16)|0,t[c]=l&65535}update(t){assert.exists(this);const{buffer:r,blockLen:n}=this;t=toBytes$2(t);const o=t.length;for(let a=0;a>>0,t[a++]=n[l]>>>8;return t}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}}function wrapConstructorWithKey(e){const t=(n,o)=>e(o).update(toBytes$2(n)).digest(),r=e(new Uint8Array(32));return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}const poly1305=wrapConstructorWithKey(e=>new Poly1305(e)),sigma16=utf8ToBytes$2("expand 16-byte k"),sigma32=utf8ToBytes$2("expand 32-byte k"),sigma16_32=u32(sigma16),sigma32_32=u32(sigma32),isAligned32=e=>!(e.byteOffset%4),salsaBasic=e=>{const{core:t,rounds:r,counterRight:n,counterLen:o,allow128bitKeys:a,extendNonceFn:l,blockLen:c}=checkOpts({rounds:20,counterRight:!1,counterLen:8,allow128bitKeys:!0,blockLen:64},e);assert.number(o),assert.number(r),assert.number(c),assert.bool(n),assert.bool(a);const u=c/4;if(c%4!==0)throw new Error("Salsa/ChaCha: blockLen must be aligned to 4 bytes");return(g,b,x,S,$=0)=>{if(assert.bytes(g),assert.bytes(b),assert.bytes(x),S||(S=new Uint8Array(x.length)),assert.bytes(S),assert.number($),$<0||$>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");if(S.length=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");const he=Math.min(c,fe-xe);if(he===c&&le&&B){const _e=xe/4;if(xe%4!==0)throw new Error("Salsa/ChaCha: invalid block position");for(let ve=0;vee<>>32-t;function chachaCore(e,t,r,n,o,a=20){let l=e[0],c=e[1],u=e[2],g=e[3],b=t[0],x=t[1],S=t[2],$=t[3],k=t[4],T=t[5],D=t[6],I=t[7],O=o,N=r[0],ee=r[1],ne=r[2],B=l,le=c,fe=u,xe=g,we=b,he=x,_e=S,ve=$,ae=k,ie=T,pe=D,ue=I,ge=O,ye=N,Ae=ee,Re=ne;for(let Pe=0;Pe{e.update(t);const r=t.length%16;r&&e.update(ZERO.subarray(r))},computeTag=(e,t,r,n,o)=>{const a=e(t,r,new Uint8Array(32)),l=poly1305.create(a);o&&updatePadded(l,o),updatePadded(l,n);const c=new Uint8Array(16),u=createView$1(c);setBigUint64$1(u,0,BigInt(o?o.length:0),!0),setBigUint64$1(u,8,BigInt(n.length),!0),l.update(c);const g=l.digest();return a.fill(0),g},_poly1305_aead=e=>(t,r,n)=>(ensureBytes$1(t,32),ensureBytes$1(r),{tagLength:16,encrypt:(a,l)=>{const c=a.length,u=c+16;l?ensureBytes$1(l,u):l=new Uint8Array(u),e(t,r,a,l,1);const g=computeTag(e,t,r,l.subarray(0,-16),n);return l.set(g,c),l},decrypt:(a,l)=>{const c=a.length,u=c-16;if(c<16)throw new Error(`encrypted data must be at least ${16} bytes`);l?ensureBytes$1(l,u):l=new Uint8Array(u);const g=a.subarray(0,-16),b=a.subarray(-16),x=computeTag(e,t,r,g,n);if(!equalBytes$1(b,x))throw new Error("invalid tag");return e(t,r,g,l,1),l}}),chacha20poly1305=_poly1305_aead(chacha20);function number$2(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bytes(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$1(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");number$2(e.outputLen),number$2(e.blockLen)}function exists(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output(e,t){bytes(e);const r=t.outputLen;if(e.lengthe instanceof Uint8Array,createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr=(e,t)=>e<<32-t|e>>>t,isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!isLE)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes$1(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function toBytes$1(e){if(typeof e=="string"&&(e=utf8ToBytes$1(e)),!u8a$1(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}function concatBytes$1(...e){const t=new Uint8Array(e.reduce((n,o)=>n+o.length,0));let r=0;return e.forEach(n=>{if(!u8a$1(n))throw new Error("Uint8Array expected");t.set(n,r),r+=n.length}),t}class Hash{clone(){return this._cloneInto()}}function wrapConstructor(e){const t=n=>e().update(toBytes$1(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function randomBytes$1(e=32){if(crypto$3&&typeof crypto$3.getRandomValues=="function")return crypto$3.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const o=BigInt(32),a=BigInt(4294967295),l=Number(r>>o&a),c=Number(r&a),u=n?4:0,g=n?0:4;e.setUint32(t+u,l,n),e.setUint32(t+g,c,n)}class SHA2 extends Hash{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=createView(this.buffer)}update(t){exists(this);const{view:r,buffer:n,blockLen:o}=this;t=toBytes$1(t);const a=t.length;for(let l=0;lo-l&&(this.process(n,0),l=0);for(let x=l;xb.length)throw new Error("_sha2: outputLen bigger than state");for(let x=0;x>_32n&U32_MASK64)}:{h:Number(e>>_32n&U32_MASK64)|0,l:Number(e&U32_MASK64)|0}}function split(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let o=0;oBigInt(e>>>0)<<_32n|BigInt(t>>>0),shrSH=(e,t,r)=>e>>>r,shrSL=(e,t,r)=>e<<32-r|t>>>r,rotrSH=(e,t,r)=>e>>>r|t<<32-r,rotrSL=(e,t,r)=>e<<32-r|t>>>r,rotrBH=(e,t,r)=>e<<64-r|t>>>r-32,rotrBL=(e,t,r)=>e>>>r-32|t<<64-r,rotr32H=(e,t)=>t,rotr32L=(e,t)=>e,rotlSH=(e,t,r)=>e<>>32-r,rotlSL=(e,t,r)=>t<>>32-r,rotlBH=(e,t,r)=>t<>>64-r,rotlBL=(e,t,r)=>e<>>64-r;function add(e,t,r,n){const o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}const add3L=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,add4L=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),add4H=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,add5L=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),add5H=(e,t,r,n,o,a)=>t+r+n+o+a+(e/2**32|0)|0,u64={fromBig,split,toBig,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,rotr32H,rotr32L,rotlSH,rotlSL,rotlBH,rotlBL,add,add3L,add3H,add4L,add4H,add5H,add5L},u64$1=u64,[SHA512_Kh,SHA512_Kl]=(()=>u64$1.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);class SHA512 extends SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:r,Bh:n,Bl:o,Ch:a,Cl:l,Dh:c,Dl:u,Eh:g,El:b,Fh:x,Fl:S,Gh:$,Gl:k,Hh:T,Hl:D}=this;return[t,r,n,o,a,l,c,u,g,b,x,S,$,k,T,D]}set(t,r,n,o,a,l,c,u,g,b,x,S,$,k,T,D){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=a|0,this.Cl=l|0,this.Dh=c|0,this.Dl=u|0,this.Eh=g|0,this.El=b|0,this.Fh=x|0,this.Fl=S|0,this.Gh=$|0,this.Gl=k|0,this.Hh=T|0,this.Hl=D|0}process(t,r){for(let N=0;N<16;N++,r+=4)SHA512_W_H[N]=t.getUint32(r),SHA512_W_L[N]=t.getUint32(r+=4);for(let N=16;N<80;N++){const ee=SHA512_W_H[N-15]|0,ne=SHA512_W_L[N-15]|0,B=u64$1.rotrSH(ee,ne,1)^u64$1.rotrSH(ee,ne,8)^u64$1.shrSH(ee,ne,7),le=u64$1.rotrSL(ee,ne,1)^u64$1.rotrSL(ee,ne,8)^u64$1.shrSL(ee,ne,7),fe=SHA512_W_H[N-2]|0,xe=SHA512_W_L[N-2]|0,we=u64$1.rotrSH(fe,xe,19)^u64$1.rotrBH(fe,xe,61)^u64$1.shrSH(fe,xe,6),he=u64$1.rotrSL(fe,xe,19)^u64$1.rotrBL(fe,xe,61)^u64$1.shrSL(fe,xe,6),_e=u64$1.add4L(le,he,SHA512_W_L[N-7],SHA512_W_L[N-16]),ve=u64$1.add4H(_e,B,we,SHA512_W_H[N-7],SHA512_W_H[N-16]);SHA512_W_H[N]=ve|0,SHA512_W_L[N]=_e|0}let{Ah:n,Al:o,Bh:a,Bl:l,Ch:c,Cl:u,Dh:g,Dl:b,Eh:x,El:S,Fh:$,Fl:k,Gh:T,Gl:D,Hh:I,Hl:O}=this;for(let N=0;N<80;N++){const ee=u64$1.rotrSH(x,S,14)^u64$1.rotrSH(x,S,18)^u64$1.rotrBH(x,S,41),ne=u64$1.rotrSL(x,S,14)^u64$1.rotrSL(x,S,18)^u64$1.rotrBL(x,S,41),B=x&$^~x&T,le=S&k^~S&D,fe=u64$1.add5L(O,ne,le,SHA512_Kl[N],SHA512_W_L[N]),xe=u64$1.add5H(fe,I,ee,B,SHA512_Kh[N],SHA512_W_H[N]),we=fe|0,he=u64$1.rotrSH(n,o,28)^u64$1.rotrBH(n,o,34)^u64$1.rotrBH(n,o,39),_e=u64$1.rotrSL(n,o,28)^u64$1.rotrBL(n,o,34)^u64$1.rotrBL(n,o,39),ve=n&a^n&c^a&c,ae=o&l^o&u^l&u;I=T|0,O=D|0,T=$|0,D=k|0,$=x|0,k=S|0,{h:x,l:S}=u64$1.add(g|0,b|0,xe|0,we|0),g=c|0,b=u|0,c=a|0,u=l|0,a=n|0,l=o|0;const ie=u64$1.add3L(we,_e,ae);n=u64$1.add3H(ie,xe,he,ve),o=ie|0}({h:n,l:o}=u64$1.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:a,l}=u64$1.add(this.Bh|0,this.Bl|0,a|0,l|0),{h:c,l:u}=u64$1.add(this.Ch|0,this.Cl|0,c|0,u|0),{h:g,l:b}=u64$1.add(this.Dh|0,this.Dl|0,g|0,b|0),{h:x,l:S}=u64$1.add(this.Eh|0,this.El|0,x|0,S|0),{h:$,l:k}=u64$1.add(this.Fh|0,this.Fl|0,$|0,k|0),{h:T,l:D}=u64$1.add(this.Gh|0,this.Gl|0,T|0,D|0),{h:I,l:O}=u64$1.add(this.Hh|0,this.Hl|0,I|0,O|0),this.set(n,o,a,l,c,u,g,b,x,S,$,k,T,D,I,O)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const sha512$3=wrapConstructor(()=>new SHA512);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$5=BigInt(0),_1n$7=BigInt(1),_2n$4=BigInt(2),u8a=e=>e instanceof Uint8Array,hexes=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex(e){if(!u8a(e))throw new Error("Uint8Array expected");let t="";for(let r=0;rn+o.length,0));let r=0;return e.forEach(n=>{if(!u8a(n))throw new Error("Uint8Array expected");t.set(n,r),r+=n.length}),t}function equalBytes(e,t){if(e.length!==t.length)return!1;for(let r=0;r_0n$5;e>>=_1n$7,t+=1);return t}function bitGet(e,t){return e>>BigInt(t)&_1n$7}const bitSet=(e,t,r)=>e|(r?_1n$7:_0n$5)<(_2n$4<new Uint8Array(e),u8fr=e=>Uint8Array.from(e);function createHmacDrbg(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=u8n(e),o=u8n(e),a=0;const l=()=>{n.fill(1),o.fill(0),a=0},c=(...x)=>r(o,n,...x),u=(x=u8n())=>{o=c(u8fr([0]),x),n=c(),x.length!==0&&(o=c(u8fr([1]),x),n=c())},g=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let x=0;const S=[];for(;x{l(),u(x);let $;for(;!($=S(g()));)u();return l(),$}}const validatorFns={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function validateObject(e,t,r={}){const n=(o,a,l)=>{const c=validatorFns[a];if(typeof c!="function")throw new Error(`Invalid validator "${a}", expected function`);const u=e[o];if(!(l&&u===void 0)&&!c(u,e))throw new Error(`Invalid param ${String(o)}=${u} (${typeof u}), expected ${a}`)};for(const[o,a]of Object.entries(t))n(o,a,!1);for(const[o,a]of Object.entries(r))n(o,a,!0);return e}const ut=Object.freeze(Object.defineProperty({__proto__:null,bytesToHex,numberToHexUnpadded,hexToNumber,hexToBytes,bytesToNumberBE,bytesToNumberLE,numberToBytesBE,numberToBytesLE,numberToVarBytesBE,ensureBytes,concatBytes,equalBytes,utf8ToBytes,bitLen,bitGet,bitSet,bitMask,createHmacDrbg,validateObject},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$4=BigInt(0),_1n$6=BigInt(1),_2n$3=BigInt(2),_3n$1=BigInt(3),_4n=BigInt(4),_5n$1=BigInt(5),_8n$1=BigInt(8);BigInt(9);BigInt(16);function mod(e,t){const r=e%t;return r>=_0n$4?r:t+r}function pow(e,t,r){if(r<=_0n$4||t<_0n$4)throw new Error("Expected power/modulo > 0");if(r===_1n$6)return _0n$4;let n=_1n$6;for(;t>_0n$4;)t&_1n$6&&(n=n*e%r),e=e*e%r,t>>=_1n$6;return n}function pow2(e,t,r){let n=e;for(;t-- >_0n$4;)n*=n,n%=r;return n}function invert(e,t){if(e===_0n$4||t<=_0n$4)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=mod(e,t),n=t,o=_0n$4,a=_1n$6;for(;r!==_0n$4;){const c=n/r,u=n%r,g=o-a*c;n=r,r=u,o=a,a=g}if(n!==_1n$6)throw new Error("invert: does not exist");return mod(o,t)}function tonelliShanks(e){const t=(e-_1n$6)/_2n$3;let r,n,o;for(r=e-_1n$6,n=0;r%_2n$3===_0n$4;r/=_2n$3,n++);for(o=_2n$3;o(mod(e,t)&_1n$6)===_1n$6,FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=FIELD_FIELDS.reduce((n,o)=>(n[o]="function",n),t);return validateObject(e,r)}function FpPow(e,t,r){if(r<_0n$4)throw new Error("Expected power > 0");if(r===_0n$4)return e.ONE;if(r===_1n$6)return t;let n=e.ONE,o=t;for(;r>_0n$4;)r&_1n$6&&(n=e.mul(n,o)),o=e.sqr(o),r>>=_1n$6;return n}function FpInvertBatch(e,t){const r=new Array(t.length),n=t.reduce((a,l,c)=>e.is0(l)?a:(r[c]=a,e.mul(a,l)),e.ONE),o=e.inv(n);return t.reduceRight((a,l,c)=>e.is0(l)?a:(r[c]=e.mul(a,r[c]),e.mul(a,l)),o),r}function nLength(e,t){const r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Field(e,t,r=!1,n={}){if(e<=_0n$4)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:a}=nLength(e,t);if(a>2048)throw new Error("Field lengths over 2048 bytes are not supported");const l=FpSqrt(e),c=Object.freeze({ORDER:e,BITS:o,BYTES:a,MASK:bitMask(o),ZERO:_0n$4,ONE:_1n$6,create:u=>mod(u,e),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return _0n$4<=u&&uu===_0n$4,isOdd:u=>(u&_1n$6)===_1n$6,neg:u=>mod(-u,e),eql:(u,g)=>u===g,sqr:u=>mod(u*u,e),add:(u,g)=>mod(u+g,e),sub:(u,g)=>mod(u-g,e),mul:(u,g)=>mod(u*g,e),pow:(u,g)=>FpPow(c,u,g),div:(u,g)=>mod(u*invert(g,e),e),sqrN:u=>u*u,addN:(u,g)=>u+g,subN:(u,g)=>u-g,mulN:(u,g)=>u*g,inv:u=>invert(u,e),sqrt:n.sqrt||(u=>l(c,u)),invertBatch:u=>FpInvertBatch(c,u),cmov:(u,g,b)=>b?g:u,toBytes:u=>r?numberToBytesLE(u,a):numberToBytesBE(u,a),fromBytes:u=>{if(u.length!==a)throw new Error(`Fp.fromBytes: expected ${a}, got ${u.length}`);return r?bytesToNumberLE(u):bytesToNumberBE(u)}});return Object.freeze(c)}function FpSqrtEven(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r}function getFieldBytesLength(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function getMinHashLength(e){const t=getFieldBytesLength(e);return t+Math.ceil(t/2)}function mapHashToField(e,t,r=!1){const n=e.length,o=getFieldBytesLength(t),a=getMinHashLength(t);if(n<16||n1024)throw new Error(`expected ${a}-1024 bytes of input, got ${n}`);const l=r?bytesToNumberBE(e):bytesToNumberLE(e),c=mod(l,t-_1n$6)+_1n$6;return r?numberToBytesLE(c,o):numberToBytesBE(c,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$3=BigInt(0),_1n$5=BigInt(1);function wNAF(e,t){const r=(o,a)=>{const l=a.negate();return o?l:a},n=o=>{const a=Math.ceil(t/o)+1,l=2**(o-1);return{windows:a,windowSize:l}};return{constTimeNegate:r,unsafeLadder(o,a){let l=e.ZERO,c=o;for(;a>_0n$3;)a&_1n$5&&(l=l.add(c)),c=c.double(),a>>=_1n$5;return l},precomputeWindow(o,a){const{windows:l,windowSize:c}=n(a),u=[];let g=o,b=g;for(let x=0;x>=$,D>u&&(D-=S,l+=_1n$5);const I=T,O=T+Math.abs(D)-1,N=k%2!==0,ee=D<0;D===0?b=b.add(r(N,a[I])):g=g.add(r(ee,a[O]))}return{p:g,f:b}},wNAFCached(o,a,l,c){const u=o._WINDOW_SIZE||1;let g=a.get(o);return g||(g=this.precomputeWindow(o,u),u!==1&&a.set(o,c(g))),this.wNAF(u,g,l)}}}function validateBasic(e){return validateField(e.Fp),validateObject(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$4=BigInt(1),_2n$2=BigInt(2),_8n=BigInt(8),VERIFY_DEFAULT={zip215:!0};function validateOpts$2(e){const t=validateBasic(e);return validateObject(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function twistedEdwards(e){const t=validateOpts$2(e),{Fp:r,n,prehash:o,hash:a,randomBytes:l,nByteLength:c,h:u}=t,g=_2n$2<{try{return{isValid:!0,value:r.sqrt(ge*r.inv(ye))}}catch{return{isValid:!1,value:_0n$2}}}),S=t.adjustScalarBytes||(ge=>ge),$=t.domain||((ge,ye,Ae)=>{if(ye.length||Ae)throw new Error("Contexts/pre-hash are not supported");return ge}),k=ge=>typeof ge=="bigint"&&_0n$2k(ge)&&k(ye)&&gege===_0n$2||T(ge,g);function I(ge,ye){if(T(ge,ye))return ge;throw new Error(`Expected valid scalar < ${ye}, got ${typeof ge} ${ge}`)}function O(ge){return ge===_0n$2?ge:I(ge,n)}const N=new Map;function ee(ge){if(!(ge instanceof ne))throw new Error("ExtendedPoint expected")}class ne{constructor(ye,Ae,Re,We){if(this.ex=ye,this.ey=Ae,this.ez=Re,this.et=We,!D(ye))throw new Error("x required");if(!D(Ae))throw new Error("y required");if(!D(Re))throw new Error("z required");if(!D(We))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(ye){if(ye instanceof ne)throw new Error("extended point not allowed");const{x:Ae,y:Re}=ye||{};if(!D(Ae)||!D(Re))throw new Error("invalid affine point");return new ne(Ae,Re,_1n$4,b(Ae*Re))}static normalizeZ(ye){const Ae=r.invertBatch(ye.map(Re=>Re.ez));return ye.map((Re,We)=>Re.toAffine(Ae[We])).map(ne.fromAffine)}_setWindowSize(ye){this._WINDOW_SIZE=ye,N.delete(this)}assertValidity(){const{a:ye,d:Ae}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:Re,ey:We,ez:Pe,et:Ue}=this,Oe=b(Re*Re),Be=b(We*We),Ye=b(Pe*Pe),Se=b(Ye*Ye),Te=b(Oe*ye),$e=b(Ye*b(Te+Be)),Ve=b(Se+b(Ae*b(Oe*Be)));if($e!==Ve)throw new Error("bad point: equation left != right (1)");const oe=b(Re*We),te=b(Pe*Ue);if(oe!==te)throw new Error("bad point: equation left != right (2)")}equals(ye){ee(ye);const{ex:Ae,ey:Re,ez:We}=this,{ex:Pe,ey:Ue,ez:Oe}=ye,Be=b(Ae*Oe),Ye=b(Pe*We),Se=b(Re*Oe),Te=b(Ue*We);return Be===Ye&&Se===Te}is0(){return this.equals(ne.ZERO)}negate(){return new ne(b(-this.ex),this.ey,this.ez,b(-this.et))}double(){const{a:ye}=t,{ex:Ae,ey:Re,ez:We}=this,Pe=b(Ae*Ae),Ue=b(Re*Re),Oe=b(_2n$2*b(We*We)),Be=b(ye*Pe),Ye=Ae+Re,Se=b(b(Ye*Ye)-Pe-Ue),Te=Be+Ue,$e=Te-Oe,Ve=Be-Ue,oe=b(Se*$e),te=b(Te*Ve),se=b(Se*Ve),me=b($e*Te);return new ne(oe,te,me,se)}add(ye){ee(ye);const{a:Ae,d:Re}=t,{ex:We,ey:Pe,ez:Ue,et:Oe}=this,{ex:Be,ey:Ye,ez:Se,et:Te}=ye;if(Ae===BigInt(-1)){const Ke=b((Pe-We)*(Ye+Be)),Ie=b((Pe+We)*(Ye-Be)),Fe=b(Ie-Ke);if(Fe===_0n$2)return this.double();const je=b(Ue*_2n$2*Te),Ze=b(Oe*_2n$2*Se),Ce=Ze+je,ce=Ie+Ke,de=Ze-je,De=b(Ce*Fe),qe=b(ce*de),nt=b(Ce*de),lt=b(Fe*ce);return new ne(De,qe,lt,nt)}const $e=b(We*Be),Ve=b(Pe*Ye),oe=b(Oe*Re*Te),te=b(Ue*Se),se=b((We+Pe)*(Be+Ye)-$e-Ve),me=te-oe,Ee=te+oe,Le=b(Ve-Ae*$e),He=b(se*me),ze=b(Ee*Le),Qe=b(se*Le),rt=b(me*Ee);return new ne(He,ze,rt,Qe)}subtract(ye){return this.add(ye.negate())}wNAF(ye){return fe.wNAFCached(this,N,ye,ne.normalizeZ)}multiply(ye){const{p:Ae,f:Re}=this.wNAF(I(ye,n));return ne.normalizeZ([Ae,Re])[0]}multiplyUnsafe(ye){let Ae=O(ye);return Ae===_0n$2?le:this.equals(le)||Ae===_1n$4?this:this.equals(B)?this.wNAF(Ae).p:fe.unsafeLadder(this,Ae)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return fe.unsafeLadder(this,n).is0()}toAffine(ye){const{ex:Ae,ey:Re,ez:We}=this,Pe=this.is0();ye==null&&(ye=Pe?_8n:r.inv(We));const Ue=b(Ae*ye),Oe=b(Re*ye),Be=b(We*ye);if(Pe)return{x:_0n$2,y:_1n$4};if(Be!==_1n$4)throw new Error("invZ was invalid");return{x:Ue,y:Oe}}clearCofactor(){const{h:ye}=t;return ye===_1n$4?this:this.multiplyUnsafe(ye)}static fromHex(ye,Ae=!1){const{d:Re,a:We}=t,Pe=r.BYTES;ye=ensureBytes("pointHex",ye,Pe);const Ue=ye.slice(),Oe=ye[Pe-1];Ue[Pe-1]=Oe&-129;const Be=bytesToNumberLE(Ue);Be===_0n$2||(Ae?I(Be,g):I(Be,r.ORDER));const Ye=b(Be*Be),Se=b(Ye-_1n$4),Te=b(Re*Ye-We);let{isValid:$e,value:Ve}=x(Se,Te);if(!$e)throw new Error("Point.fromHex: invalid y coordinate");const oe=(Ve&_1n$4)===_1n$4,te=(Oe&128)!==0;if(!Ae&&Ve===_0n$2&&te)throw new Error("Point.fromHex: x=0 and x_0=1");return te!==oe&&(Ve=b(-Ve)),ne.fromAffine({x:Ve,y:Be})}static fromPrivateKey(ye){return he(ye).point}toRawBytes(){const{x:ye,y:Ae}=this.toAffine(),Re=numberToBytesLE(Ae,r.BYTES);return Re[Re.length-1]|=ye&_1n$4?128:0,Re}toHex(){return bytesToHex(this.toRawBytes())}}ne.BASE=new ne(t.Gx,t.Gy,_1n$4,b(t.Gx*t.Gy)),ne.ZERO=new ne(_0n$2,_1n$4,_1n$4,_0n$2);const{BASE:B,ZERO:le}=ne,fe=wNAF(ne,c*8);function xe(ge){return mod(ge,n)}function we(ge){return xe(bytesToNumberLE(ge))}function he(ge){const ye=c;ge=ensureBytes("private key",ge,ye);const Ae=ensureBytes("hashed private key",a(ge),2*ye),Re=S(Ae.slice(0,ye)),We=Ae.slice(ye,2*ye),Pe=we(Re),Ue=B.multiply(Pe),Oe=Ue.toRawBytes();return{head:Re,prefix:We,scalar:Pe,point:Ue,pointBytes:Oe}}function _e(ge){return he(ge).pointBytes}function ve(ge=new Uint8Array,...ye){const Ae=concatBytes(...ye);return we(a($(Ae,ensureBytes("context",ge),!!o)))}function ae(ge,ye,Ae={}){ge=ensureBytes("message",ge),o&&(ge=o(ge));const{prefix:Re,scalar:We,pointBytes:Pe}=he(ye),Ue=ve(Ae.context,Re,ge),Oe=B.multiply(Ue).toRawBytes(),Be=ve(Ae.context,Oe,Pe,ge),Ye=xe(Ue+Be*We);O(Ye);const Se=concatBytes(Oe,numberToBytesLE(Ye,r.BYTES));return ensureBytes("result",Se,c*2)}const ie=VERIFY_DEFAULT;function pe(ge,ye,Ae,Re=ie){const{context:We,zip215:Pe}=Re,Ue=r.BYTES;ge=ensureBytes("signature",ge,2*Ue),ye=ensureBytes("message",ye),o&&(ye=o(ye));const Oe=bytesToNumberLE(ge.slice(Ue,2*Ue));let Be,Ye,Se;try{Be=ne.fromHex(Ae,Pe),Ye=ne.fromHex(ge.slice(0,Ue),Pe),Se=B.multiplyUnsafe(Oe)}catch{return!1}if(!Pe&&Be.isSmallOrder())return!1;const Te=ve(We,Ye.toRawBytes(),Be.toRawBytes(),ye);return Ye.add(Be.multiplyUnsafe(Te)).subtract(Se).clearCofactor().equals(ne.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:_e,sign:ae,verify:pe,ExtendedPoint:ne,utils:{getExtendedPublicKey:he,randomPrivateKey:()=>l(r.BYTES),precompute(ge=8,ye=ne.BASE){return ye._setWindowSize(ge),ye.multiply(BigInt(3)),ye}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$3=BigInt(1);function validateOpts$1(e){return validateObject(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}function montgomery(e){const t=validateOpts$1(e),{P:r}=t,n=N=>mod(N,r),o=t.montgomeryBits,a=Math.ceil(o/8),l=t.nByteLength,c=t.adjustScalarBytes||(N=>N),u=t.powPminus2||(N=>pow(N,r-BigInt(2),r));function g(N,ee,ne){const B=n(N*(ee-ne));return ee=n(ee-B),ne=n(ne+B),[ee,ne]}function b(N){if(typeof N=="bigint"&&_0n$1<=N&&N=_0n$1;ie--){const pe=B>>ie&_1n$3;_e^=pe,ve=g(_e,fe,we),fe=ve[0],we=ve[1],ve=g(_e,xe,he),xe=ve[0],he=ve[1],_e=pe;const ue=fe+xe,ge=n(ue*ue),ye=fe-xe,Ae=n(ye*ye),Re=ge-Ae,We=we+he,Pe=we-he,Ue=n(Pe*ue),Oe=n(We*ye),Be=Ue+Oe,Ye=Ue-Oe;we=n(Be*Be),he=n(le*n(Ye*Ye)),fe=n(ge*Ae),xe=n(Re*(ge+n(x*Re)))}ve=g(_e,fe,we),fe=ve[0],we=ve[1],ve=g(_e,xe,he),xe=ve[0],he=ve[1];const ae=u(xe);return n(fe*ae)}function $(N){return numberToBytesLE(n(N),a)}function k(N){const ee=ensureBytes("u coordinate",N,a);return l===a&&(ee[l-1]&=127),bytesToNumberLE(ee)}function T(N){const ee=ensureBytes("scalar",N);if(ee.length!==a&&ee.length!==l)throw new Error(`Expected ${a} or ${l} bytes, got ${ee.length}`);return bytesToNumberLE(c(ee))}function D(N,ee){const ne=k(ee),B=T(N),le=S(ne,B);if(le===_0n$1)throw new Error("Invalid private or public key received");return $(le)}const I=$(t.Gu);function O(N){return D(N,I)}return{scalarMult:D,scalarMultBase:O,getSharedSecret:(N,ee)=>D(N,ee),getPublicKey:N=>O(N),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:I}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ED25519_P=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const _1n$2=BigInt(1),_2n$1=BigInt(2),_5n=BigInt(5),_10n=BigInt(10),_20n=BigInt(20),_40n=BigInt(40),_80n=BigInt(80);function ed25519_pow_2_252_3(e){const t=ED25519_P,n=e*e%t*e%t,o=pow2(n,_2n$1,t)*n%t,a=pow2(o,_1n$2,t)*e%t,l=pow2(a,_5n,t)*a%t,c=pow2(l,_10n,t)*l%t,u=pow2(c,_20n,t)*c%t,g=pow2(u,_40n,t)*u%t,b=pow2(g,_80n,t)*g%t,x=pow2(b,_80n,t)*g%t,S=pow2(x,_10n,t)*l%t;return{pow_p_5_8:pow2(S,_2n$1,t)*e%t,b2:n}}function adjustScalarBytes(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function uvRatio(e,t){const r=ED25519_P,n=mod(t*t*t,r),o=mod(n*n*t,r),a=ed25519_pow_2_252_3(e*o).pow_p_5_8;let l=mod(e*n*a,r);const c=mod(t*l*l,r),u=l,g=mod(l*ED25519_SQRT_M1,r),b=c===e,x=c===mod(-e,r),S=c===mod(-e*ED25519_SQRT_M1,r);return b&&(l=u),(x||S)&&(l=g),isNegativeLE(l,r)&&(l=mod(-l,r)),{isValid:b||x,value:l}}const Fp$1=Field(ED25519_P,void 0,!0),ed25519Defaults={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Fp$1,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sha512$3,randomBytes:randomBytes$1,adjustScalarBytes,uvRatio},ed25519=twistedEdwards(ed25519Defaults);function ed25519_domain(e,t,r){if(t.length>255)throw new Error("Context is too big");return concatBytes$1(utf8ToBytes$1("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}({...ed25519Defaults});({...ed25519Defaults});const x25519=(()=>montgomery({P:ED25519_P,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=ED25519_P,{pow_p_5_8:r,b2:n}=ed25519_pow_2_252_3(e);return mod(pow2(r,BigInt(3),t)*n,t)},adjustScalarBytes,randomBytes:randomBytes$1}))(),ELL2_C1=(Fp$1.ORDER+BigInt(3))/BigInt(8);Fp$1.pow(_2n$1,ELL2_C1);Fp$1.sqrt(Fp$1.neg(Fp$1.ONE));(Fp$1.ORDER-BigInt(5))/BigInt(8);BigInt(486662);FpSqrtEven(Fp$1,Fp$1.neg(BigInt(486664)));BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235");BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578");BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838");BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class HMAC extends Hash{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,hash$1(t);const n=toBytes$1(r);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,a=new Uint8Array(o);a.set(n.length>o?t.create().update(n).digest():n);for(let l=0;lnew HMAC(e,t).update(r).digest();hmac$1.create=(e,t)=>new HMAC(e,t);function extract(e,t,r){return hash$1(e),r===void 0&&(r=new Uint8Array(e.outputLen)),hmac$1(e,toBytes$1(r),toBytes$1(t))}const HKDF_COUNTER=new Uint8Array([0]),EMPTY_BUFFER=new Uint8Array;function expand(e,t,r,n=32){if(hash$1(e),number$2(n),n>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(n/e.outputLen);r===void 0&&(r=EMPTY_BUFFER);const a=new Uint8Array(o*e.outputLen),l=hmac$1.create(e,t),c=l._cloneInto(),u=new Uint8Array(l.outputLen);for(let g=0;ge&t^~e&r,Maj=(e,t,r)=>e&t^e&r^t&r,SHA256_K=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),IV=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W=new Uint32Array(64);class SHA256 extends SHA2{constructor(){super(64,32,8,!1),this.A=IV[0]|0,this.B=IV[1]|0,this.C=IV[2]|0,this.D=IV[3]|0,this.E=IV[4]|0,this.F=IV[5]|0,this.G=IV[6]|0,this.H=IV[7]|0}get(){const{A:t,B:r,C:n,D:o,E:a,F:l,G:c,H:u}=this;return[t,r,n,o,a,l,c,u]}set(t,r,n,o,a,l,c,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=a|0,this.F=l|0,this.G=c|0,this.H=u|0}process(t,r){for(let x=0;x<16;x++,r+=4)SHA256_W[x]=t.getUint32(r,!1);for(let x=16;x<64;x++){const S=SHA256_W[x-15],$=SHA256_W[x-2],k=rotr(S,7)^rotr(S,18)^S>>>3,T=rotr($,17)^rotr($,19)^$>>>10;SHA256_W[x]=T+SHA256_W[x-7]+k+SHA256_W[x-16]|0}let{A:n,B:o,C:a,D:l,E:c,F:u,G:g,H:b}=this;for(let x=0;x<64;x++){const S=rotr(c,6)^rotr(c,11)^rotr(c,25),$=b+S+Chi(c,u,g)+SHA256_K[x]+SHA256_W[x]|0,T=(rotr(n,2)^rotr(n,13)^rotr(n,22))+Maj(n,o,a)|0;b=g,g=u,u=c,c=l+$|0,l=a,a=o,o=n,n=$+T|0}n=n+this.A|0,o=o+this.B|0,a=a+this.C|0,l=l+this.D|0,c=c+this.E|0,u=u+this.F|0,g=g+this.G|0,b=b+this.H|0,this.set(n,o,a,l,c,u,g,b)}roundClean(){SHA256_W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const sha256$3=wrapConstructor(()=>new SHA256),pureJsCrypto={hashSHA256(e){return sha256$3(e)},getHKDF(e,t){const r=extract(sha256$3,t,e),o=expand(sha256$3,r,void 0,96),a=o.subarray(0,32),l=o.subarray(32,64),c=o.subarray(64,96);return[a,l,c]},generateX25519KeyPair(){const e=x25519.utils.randomPrivateKey();return{publicKey:x25519.getPublicKey(e),privateKey:e}},generateX25519KeyPairFromSeed(e){return{publicKey:x25519.getPublicKey(e),privateKey:e}},generateX25519SharedKey(e,t){return x25519.getSharedSecret(e,t)},chaCha20Poly1305Encrypt(e,t,r,n){return chacha20poly1305(n,t,r).encrypt(e)},chaCha20Poly1305Decrypt(e,t,r,n,o){return chacha20poly1305(n,t,r).decrypt(e,o)}},allocUnsafe$1=e=>globalThis.Buffer?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e),uint16BEEncode=e=>{const t=allocUnsafe$1(2);return new DataView(t.buffer,t.byteOffset,t.byteLength).setUint16(0,e,!1),t};uint16BEEncode.bytes=2;const uint16BEDecode=e=>{if(e.length<2)throw RangeError("Could not decode int16BE");return e instanceof Uint8Array?new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!1):e.getUint16(0)};uint16BEDecode.bytes=2;function encode0(e){return concat$1([e.ne,e.ciphertext],e.ne.length+e.ciphertext.length)}function encode1(e){return concat$1([e.ne,e.ns,e.ciphertext],e.ne.length+e.ns.length+e.ciphertext.length)}function encode2(e){return concat$1([e.ns,e.ciphertext],e.ns.length+e.ciphertext.length)}function decode0(e){if(e.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:e.subarray(0,32),ciphertext:e.subarray(32,e.length),ns:new Uint8Array(0)}}function decode1(e){if(e.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:e.subarray(0,32),ns:e.subarray(32,80),ciphertext:e.subarray(80,e.length)}}function decode2(e){if(e.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:new Uint8Array(0),ns:e.subarray(0,48),ciphertext:e.subarray(48,e.length)}}const CHACHA_TAG_LENGTH=16;function encryptStream(e,t){return async function*(r){for await(const n of r)for(let o=0;on.length&&(a=n.length);const l=e.encrypt(n.subarray(o,a),e.session);t?.encryptedPackets.increment(),yield uint16BEEncode(l.byteLength),yield l}}}function decryptStream(e,t){return async function*(r){for await(const n of r)for(let o=0;on.length&&(a=n.length),a-CHACHA_TAG_LENGTH0;)c.push(g%a),g=g/a|0}for(o=0;e[o]===0&&o=0;--o)n+=t[c[o]]}if(r){var b=new RegExp(".{1,"+r+"}","g");n=n.match(b).join(`\r -`)}return n};api$2.decode=function(e,t){if(typeof e!="string")throw new TypeError('"input" must be a string.');if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');var r=_reverseAlphabets[t];if(!r){r=_reverseAlphabets[t]=[];for(var n=0;n>=8;for(;g>0;)l.push(g&255),g>>=8}for(var b=0;e[b]===a&&b0;)a.push(c%n),c=c/n|0}var u="";for(r=0;e.at(r)===0&&r=0;--r)u+=t[a[r]];return u}var forge$l=forge$m,baseN=baseN$1,util$6=util$7.exports=forge$l.util=forge$l.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){util$6.nextTick=process.nextTick,typeof setImmediate=="function"?util$6.setImmediate=setImmediate:util$6.setImmediate=util$6.nextTick;return}if(typeof setImmediate=="function"){util$6.setImmediate=function(){return setImmediate.apply(void 0,arguments)},util$6.nextTick=function(c){return setImmediate(c)};return}if(util$6.setImmediate=function(c){setTimeout(c,0)},typeof window<"u"&&typeof window.postMessage=="function"){let c=function(u){if(u.source===window&&u.data===e){u.stopPropagation();var g=t.slice();t.length=0,g.forEach(function(b){b()})}};var l=c,e="forge.setImmediate",t=[];util$6.setImmediate=function(u){t.push(u),t.length===1&&window.postMessage(e,"*")},window.addEventListener("message",c,!0)}if(typeof MutationObserver<"u"){var r=Date.now(),n=!0,o=document.createElement("div"),t=[];new MutationObserver(function(){var u=t.slice();t.length=0,u.forEach(function(g){g()})}).observe(o,{attributes:!0});var a=util$6.setImmediate;util$6.setImmediate=function(u){Date.now()-r>15?(r=Date.now(),a(u)):(t.push(u),t.length===1&&o.setAttribute("a",n=!n))}}util$6.nextTick=util$6.setImmediate})();util$6.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;util$6.globalScope=function(){return util$6.isNodejs?commonjsGlobal$2:typeof self>"u"?window:self}();util$6.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};util$6.isArrayBuffer=function(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer};util$6.isArrayBufferView=function(e){return e&&util$6.isArrayBuffer(e.buffer)&&e.byteLength!==void 0};function _checkBitsParam(e){if(!(e===8||e===16||e===24||e===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}util$6.ByteBuffer=ByteStringBuffer;function ByteStringBuffer(e){if(this.data="",this.read=0,typeof e=="string")this.data=e;else if(util$6.isArrayBuffer(e)||util$6.isArrayBufferView(e))if(typeof Buffer<"u"&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch{for(var r=0;r_MAX_CONSTRUCTED_STRING_LENGTH&&(this.data.substr(0,1),this._constructedStringLength=0)};util$6.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};util$6.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};util$6.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))};util$6.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)t&1&&(r+=e),t>>>=1,t>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this};util$6.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this};util$6.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(util$6.encodeUtf8(e))};util$6.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};util$6.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};util$6.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};util$6.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))};util$6.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))};util$6.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))};util$6.ByteStringBuffer.prototype.putInt=function(e,t){_checkBitsParam(t);var r="";do t-=8,r+=String.fromCharCode(e>>t&255);while(t>0);return this.putBytes(r)};util$6.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t};util$6.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t};util$6.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};util$6.ByteStringBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};util$6.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)};util$6.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this};util$6.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};util$6.ByteStringBuffer.prototype.copy=function(){var e=util$6.createBuffer(this.data);return e.read=this.read,e};util$6.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};util$6.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};util$6.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this};util$6.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this};util$6.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this};util$6.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this};util$6.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this};util$6.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this};util$6.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this};util$6.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this};util$6.DataBuffer.prototype.putInt=function(e,t){_checkBitsParam(t),this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,e>>t&255);while(t>0);return this};util$6.DataBuffer.prototype.putSignedInt=function(e,t){return _checkBitsParam(t),this.accommodate(t/8),e<0&&(e+=2<0);return t};util$6.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t};util$6.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};util$6.DataBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};util$6.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)};util$6.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this};util$6.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};util$6.DataBuffer.prototype.copy=function(){return new util$6.DataBuffer(this)};util$6.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this};util$6.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};util$6.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this};util$6.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)t&1&&(r+=e),t>>>=1,t>0&&(e+=e);return r};util$6.xorBytes=function(e,t,r){for(var n="",o="",a="",l=0,c=0;r>0;--r,++l)o=e.charCodeAt(l)^t.charCodeAt(l),c>=10&&(n+=a,a="",c=0),a+=String.fromCharCode(o),++c;return n+=a,n};util$6.hexToBytes=function(e){var t="",r=0;for(e.length&!0&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var _base64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_base64Idx=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],_base58="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";util$6.encode64=function(e,t){for(var r="",n="",o,a,l,c=0;c>2),r+=_base64.charAt((o&3)<<4|a>>4),isNaN(a)?r+="==":(r+=_base64.charAt((a&15)<<2|l>>6),r+=isNaN(l)?"=":_base64.charAt(l&63)),t&&r.length>t&&(n+=r.substr(0,t)+`\r +`)}return n};api$2.decode=function(e,t){if(typeof e!="string")throw new TypeError('"input" must be a string.');if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');var r=_reverseAlphabets[t];if(!r){r=_reverseAlphabets[t]=[];for(var n=0;n>=8;for(;g>0;)l.push(g&255),g>>=8}for(var b=0;e[b]===a&&b0;)a.push(c%n),c=c/n|0}var u="";for(r=0;e.at(r)===0&&r=0;--r)u+=t[a[r]];return u}var forge$l=forge$m,baseN=baseN$1,util$6=util$7.exports=forge$l.util=forge$l.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){util$6.nextTick=process.nextTick,typeof setImmediate=="function"?util$6.setImmediate=setImmediate:util$6.setImmediate=util$6.nextTick;return}if(typeof setImmediate=="function"){util$6.setImmediate=function(){return setImmediate.apply(void 0,arguments)},util$6.nextTick=function(l){return setImmediate(l)};return}if(util$6.setImmediate=function(l){setTimeout(l,0)},typeof window<"u"&&typeof window.postMessage=="function"){let l=function(c){if(c.source===window&&c.data===e){c.stopPropagation();var u=t.slice();t.length=0,u.forEach(function(g){g()})}};var e="forge.setImmediate",t=[];util$6.setImmediate=function(c){t.push(c),t.length===1&&window.postMessage(e,"*")},window.addEventListener("message",l,!0)}if(typeof MutationObserver<"u"){var r=Date.now(),n=!0,o=document.createElement("div"),t=[];new MutationObserver(function(){var c=t.slice();t.length=0,c.forEach(function(u){u()})}).observe(o,{attributes:!0});var a=util$6.setImmediate;util$6.setImmediate=function(c){Date.now()-r>15?(r=Date.now(),a(c)):(t.push(c),t.length===1&&o.setAttribute("a",n=!n))}}util$6.nextTick=util$6.setImmediate})();util$6.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;util$6.globalScope=function(){return util$6.isNodejs?commonjsGlobal$2:typeof self>"u"?window:self}();util$6.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};util$6.isArrayBuffer=function(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer};util$6.isArrayBufferView=function(e){return e&&util$6.isArrayBuffer(e.buffer)&&e.byteLength!==void 0};function _checkBitsParam(e){if(!(e===8||e===16||e===24||e===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}util$6.ByteBuffer=ByteStringBuffer;function ByteStringBuffer(e){if(this.data="",this.read=0,typeof e=="string")this.data=e;else if(util$6.isArrayBuffer(e)||util$6.isArrayBufferView(e))if(typeof Buffer<"u"&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch{for(var r=0;r_MAX_CONSTRUCTED_STRING_LENGTH&&(this.data.substr(0,1),this._constructedStringLength=0)};util$6.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};util$6.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};util$6.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))};util$6.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)t&1&&(r+=e),t>>>=1,t>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this};util$6.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this};util$6.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(util$6.encodeUtf8(e))};util$6.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};util$6.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};util$6.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};util$6.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))};util$6.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))};util$6.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))};util$6.ByteStringBuffer.prototype.putInt=function(e,t){_checkBitsParam(t);var r="";do t-=8,r+=String.fromCharCode(e>>t&255);while(t>0);return this.putBytes(r)};util$6.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t};util$6.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t};util$6.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};util$6.ByteStringBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};util$6.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)};util$6.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this};util$6.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};util$6.ByteStringBuffer.prototype.copy=function(){var e=util$6.createBuffer(this.data);return e.read=this.read,e};util$6.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};util$6.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};util$6.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this};util$6.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this};util$6.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this};util$6.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this};util$6.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this};util$6.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this};util$6.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this};util$6.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this};util$6.DataBuffer.prototype.putInt=function(e,t){_checkBitsParam(t),this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,e>>t&255);while(t>0);return this};util$6.DataBuffer.prototype.putSignedInt=function(e,t){return _checkBitsParam(t),this.accommodate(t/8),e<0&&(e+=2<0);return t};util$6.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t};util$6.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};util$6.DataBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};util$6.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)};util$6.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this};util$6.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};util$6.DataBuffer.prototype.copy=function(){return new util$6.DataBuffer(this)};util$6.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this};util$6.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};util$6.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this};util$6.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)t&1&&(r+=e),t>>>=1,t>0&&(e+=e);return r};util$6.xorBytes=function(e,t,r){for(var n="",o="",a="",l=0,c=0;r>0;--r,++l)o=e.charCodeAt(l)^t.charCodeAt(l),c>=10&&(n+=a,a="",c=0),a+=String.fromCharCode(o),++c;return n+=a,n};util$6.hexToBytes=function(e){var t="",r=0;for(e.length&!0&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var _base64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_base64Idx=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],_base58="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";util$6.encode64=function(e,t){for(var r="",n="",o,a,l,c=0;c>2),r+=_base64.charAt((o&3)<<4|a>>4),isNaN(a)?r+="==":(r+=_base64.charAt((a&15)<<2|l>>6),r+=isNaN(l)?"=":_base64.charAt(l&63)),t&&r.length>t&&(n+=r.substr(0,t)+`\r `,r=r.substr(t));return n+=r,n};util$6.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t="",r,n,o,a,l=0;l>4),o!==64&&(t+=String.fromCharCode((n&15)<<4|o>>2),a!==64&&(t+=String.fromCharCode((o&3)<<6|a)));return t};util$6.encodeUtf8=function(e){return unescape(encodeURIComponent(e))};util$6.decodeUtf8=function(e){return decodeURIComponent(escape(e))};util$6.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:baseN.encode,decode:baseN.decode}};util$6.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)};util$6.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length)),r=r||0;for(var o=r,a=0;a>2),r+=_base64.charAt((o&3)<<4|a>>4),isNaN(a)?r+="==":(r+=_base64.charAt((a&15)<<2|l>>6),r+=isNaN(l)?"=":_base64.charAt(l&63)),t&&r.length>t&&(n+=r.substr(0,t)+`\r `,r=r.substr(t));return n+=r,n};util$6.binary.base64.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/4)*3)),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,""),r=r||0;for(var o,a,l,c,u=0,g=r;u>4,l!==64&&(n[g++]=(a&15)<<4|l>>2,c!==64&&(n[g++]=(l&3)<<6|c));return t?g-r:n.subarray(0,g)};util$6.binary.base58.encode=function(e,t){return util$6.binary.baseN.encode(e,_base58,t)};util$6.binary.base58.decode=function(e,t){return util$6.binary.baseN.decode(e,_base58,t)};util$6.text={utf8:{},utf16:{}};util$6.text.utf8.encode=function(e,t,r){e=util$6.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length)),r=r||0;for(var o=r,a=0;a"u"&&(r=["web","flash"]);var o,a=!1,l=null;for(var c in r){o=r[c];try{if(o==="flash"||o==="both"){if(t[0]===null)throw new Error("Flash local storage not available.");n=e.apply(this,t),a=o==="flash"}(o==="web"||o==="both")&&(t[0]=localStorage,n=e.apply(this,t),a=!0)}catch(u){l=u}if(a)break}if(!a)throw l;return n};util$6.setItem=function(e,t,r,n,o){_callStorageFunction(_setItem,arguments,o)};util$6.getItem=function(e,t,r,n){return _callStorageFunction(_getItem,arguments,n)};util$6.removeItem=function(e,t,r,n){_callStorageFunction(_removeItem,arguments,n)};util$6.clearItems=function(e,t,r){_callStorageFunction(_clearItems,arguments,r)};util$6.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0};util$6.format=function(e){for(var t=/%./g,r,n,o=0,a=[],l=0;r=t.exec(e);){n=e.substring(l,t.lastIndex-2),n.length>0&&a.push(n),l=t.lastIndex;var c=r[0][1];switch(c){case"s":case"o":o");break;case"%":a.push("%");break;default:a.push("<%"+c+"?>")}}return a.push(e.substring(l)),a.join("")};util$6.formatNumber=function(e,t,r,n){var o=e,a=isNaN(t=Math.abs(t))?2:t,l=r===void 0?",":r,c=n===void 0?".":n,u=o<0?"-":"",g=parseInt(o=Math.abs(+o||0).toFixed(a),10)+"",b=g.length>3?g.length%3:0;return u+(b?g.substr(0,b)+c:"")+g.substr(b).replace(/(\d{3})(?=\d)/g,"$1"+c)+(a?l+Math.abs(o-g).toFixed(a).slice(2):"")};util$6.formatSize=function(e){return e>=1073741824?e=util$6.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?e=util$6.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?e=util$6.formatNumber(e/1024,0)+" KiB":e=util$6.formatNumber(e,0)+" bytes",e};util$6.bytesFromIP=function(e){return e.indexOf(".")!==-1?util$6.bytesFromIPv4(e):e.indexOf(":")!==-1?util$6.bytesFromIPv6(e):null};util$6.bytesFromIPv4=function(e){if(e=e.split("."),e.length!==4)return null;for(var t=util$6.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1))}t.push(a)}if(r.length>0){var u=r[n];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),u.start===0&&t.unshift(""),u.end===7&&t.push(""))}return t.join(":")};util$6.estimateCores=function(e,t){if(typeof e=="function"&&(t=e,e={}),e=e||{},"cores"in util$6&&!e.update)return t(null,util$6.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return util$6.cores=navigator.hardwareConcurrency,t(null,util$6.cores);if(typeof Worker>"u")return util$6.cores=1,t(null,util$6.cores);if(typeof Blob>"u")return util$6.cores=2,t(null,util$6.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(l){var c=Date.now(),u=c+4;self.postMessage({st:c,et:u})})}.toString(),")()"],{type:"application/javascript"}));n([],5,16);function n(l,c,u){if(c===0){var g=Math.floor(l.reduce(function(b,x){return b+x},0)/l.length);return util$6.cores=Math.max(1,g),URL.revokeObjectURL(r),t(null,util$6.cores)}o(u,function(b,x){l.push(a(u,x)),n(l,c-1,u)})}function o(l,c){for(var u=[],g=[],b=0;b$.st&&b.st<$.et||$.st>b.st&&$.stt){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}var _getValueLength=function(e,t){var r=e.getByte();if(t--,r!==128){var n,o=r&128;if(!o)n=r;else{var a=r&127;_checkBufferLength(e,t,a),n=e.getInt(a<<3)}if(n<0)throw new Error("Negative length: "+n);return n}};asn1$2.fromDer=function(e,t){t===void 0&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof t=="boolean"&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),typeof e=="string"&&(e=forge$j.util.createBuffer(e));var r=e.length(),n=_fromDer(e,e.length(),0,t);if(t.parseAllBytes&&e.length()!==0){var o=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw o.byteCount=r,o.remaining=e.length(),o}return n};function _fromDer(e,t,r,n){var o;_checkBufferLength(e,t,2);var a=e.getByte();t--;var l=a&192,c=a&31;o=e.length();var u=_getValueLength(e,t);if(t-=o-e.length(),u!==void 0&&u>t){if(n.strict){var g=new Error("Too few bytes to read ASN.1 value.");throw g.available=e.length(),g.remaining=t,g.requested=u,g}u=t}var b,x,S=(a&32)===32;if(S)if(b=[],u===void 0)for(;;){if(_checkBufferLength(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}o=e.length(),b.push(_fromDer(e,t,r+1,n)),t-=o-e.length()}else for(;u>0;)o=e.length(),b.push(_fromDer(e,u,r+1,n)),t-=o-e.length(),u-=o-e.length();if(b===void 0&&l===asn1$2.Class.UNIVERSAL&&c===asn1$2.Type.BITSTRING&&(x=e.bytes(u)),b===void 0&&n.decodeBitStrings&&l===asn1$2.Class.UNIVERSAL&&c===asn1$2.Type.BITSTRING&&u>1){var $=e.read,k=t,T=0;if(c===asn1$2.Type.BITSTRING&&(_checkBufferLength(e,t,1),T=e.getByte(),t--),T===0)try{o=e.length();var D={strict:!0,decodeBitStrings:!0},I=_fromDer(e,t,r+1,D),O=o-e.length();t-=O,c==asn1$2.Type.BITSTRING&&O++;var N=I.tagClass;O===u&&(N===asn1$2.Class.UNIVERSAL||N===asn1$2.Class.CONTEXT_SPECIFIC)&&(b=[I])}catch{}b===void 0&&(e.read=$,t=k)}if(b===void 0){if(u===void 0){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");u=t}if(c===asn1$2.Type.BMPSTRING)for(b="";u>0;u-=2)_checkBufferLength(e,t,2),b+=String.fromCharCode(e.getInt16()),t-=2;else b=e.getBytes(u),t-=u}var ee=x===void 0?null:{bitStringContents:x};return asn1$2.create(l,c,S,b,ee)}asn1$2.toDer=function(e){var t=forge$j.util.createBuffer(),r=e.tagClass|e.type,n=forge$j.util.createBuffer(),o=!1;if("bitStringContents"in e&&(o=!0,e.original&&(o=asn1$2.equals(e,e.original))),o)n.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:n.putByte(0);for(var a=0;a1&&(e.value.charCodeAt(0)===0&&(e.value.charCodeAt(1)&128)===0||e.value.charCodeAt(0)===255&&(e.value.charCodeAt(1)&128)===128)?n.putBytes(e.value.substr(1)):n.putBytes(e.value);if(t.putByte(r),n.length()<=127)t.putByte(n.length()&127);else{var l=n.length(),c="";do c+=String.fromCharCode(l&255),l=l>>>8;while(l>0);t.putByte(c.length|128);for(var a=c.length-1;a>=0;--a)t.putByte(c.charCodeAt(a))}return t.putBuffer(n),t};asn1$2.oidToDer=function(e){var t=e.split("."),r=forge$j.util.createBuffer();r.putByte(40*parseInt(t[0],10)+parseInt(t[1],10));for(var n,o,a,l,c=2;c>>7,n||(l|=128),o.push(l),n=!1;while(a>0);for(var u=o.length-1;u>=0;--u)r.putByte(o[u])}return r};asn1$2.derToOid=function(e){var t;typeof e=="string"&&(e=forge$j.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var n=0;e.length()>0;)r=e.getByte(),n=n<<7,r&128?n+=r&127:(t+="."+(n+r),n=0);return t};asn1$2.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,o=parseInt(e.substr(4,2),10),a=parseInt(e.substr(6,2),10),l=parseInt(e.substr(8,2),10),c=0;if(e.length>11){var u=e.charAt(10),g=10;u!=="+"&&u!=="-"&&(c=parseInt(e.substr(10,2),10),g+=2)}if(t.setUTCFullYear(r,n,o),t.setUTCHours(a,l,c,0),g&&(u=e.charAt(g),u==="+"||u==="-")){var b=parseInt(e.substr(g+1,2),10),x=parseInt(e.substr(g+4,2),10),S=b*60+x;S*=6e4,u==="+"?t.setTime(+t-S):t.setTime(+t+S)}return t};asn1$2.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,o=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),l=parseInt(e.substr(10,2),10),c=parseInt(e.substr(12,2),10),u=0,g=0,b=!1;e.charAt(e.length-1)==="Z"&&(b=!0);var x=e.length-5,S=e.charAt(x);if(S==="+"||S==="-"){var $=parseInt(e.substr(x+1,2),10),k=parseInt(e.substr(x+4,2),10);g=$*60+k,g*=6e4,S==="+"&&(g*=-1),b=!0}return e.charAt(14)==="."&&(u=parseFloat(e.substr(14),10)*1e3),b?(t.setUTCFullYear(r,n,o),t.setUTCHours(a,l,c,u),t.setTime(+t+g)):(t.setFullYear(r,n,o),t.setHours(a,l,c,u)),t};asn1$2.dateToUtcTime=function(e){if(typeof e=="string")return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r};asn1$2.derToInteger=function(e){typeof e=="string"&&(e=forge$j.util.createBuffer(e));var t=e.length()*8;if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)};asn1$2.validate=function(e,t,r,n){var o=!1;if((e.tagClass===t.tagClass||typeof t.tagClass>"u")&&(e.type===t.type||typeof t.type>"u"))if(e.constructed===t.constructed||typeof t.constructed>"u"){if(o=!0,t.value&&forge$j.util.isArray(t.value))for(var a=0,l=0;o&&l0&&(n+=` `);for(var o="",a=0;a65&&l!==-1){var c=t[l];c===","?(++l,t=t.substr(0,l)+`\r `+t.substr(l)):t=t.substr(0,l)+`\r -`+c+t.substr(l+1),a=o-l-1,l=-1,++o}else(t[o]===" "||t[o]===" "||t[o]===",")&&(l=o);return t}function ltrim(e){return e.replace(/^\s+/,"")}var forge$a=forge$m,sha256$2=forge$a.sha256=forge$a.sha256||{};forge$a.md.sha256=forge$a.md.algorithms.sha256=sha256$2;sha256$2.create=function(){_initialized$2||_init$2();var e=null,t=forge$a.util.createBuffer(),r=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var o=n.messageLengthSize/4,a=0;a>>0,l>>>0];for(var c=n.fullMessageLength.length-1;c>=0;--c)n.fullMessageLength[c]+=l[1],l[1]=l[0]+(n.fullMessageLength[c]/4294967296>>>0),n.fullMessageLength[c]=n.fullMessageLength[c]>>>0,l[0]=l[1]/4294967296>>>0;return t.putBytes(o),_update$2(e,r,t),(t.read>2048||t.length()===0)&&t.compact(),n},n.digest=function(){var o=forge$a.util.createBuffer();o.putBytes(t.bytes());var a=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,l=a&n.blockLength-1;o.putBytes(_padding$2.substr(0,n.blockLength-l));for(var c,u,g=n.fullMessageLength[0]*8,b=0;b>>0,g+=u,o.putInt32(g>>>0),g=c>>>0;o.putInt32(g);var x={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};_update$2(x,r,o);var S=forge$a.util.createBuffer();return S.putInt32(x.h0),S.putInt32(x.h1),S.putInt32(x.h2),S.putInt32(x.h3),S.putInt32(x.h4),S.putInt32(x.h5),S.putInt32(x.h6),S.putInt32(x.h7),S},n};var _padding$2=null,_initialized$2=!1,_k$1=null;function _init$2(){_padding$2=String.fromCharCode(128),_padding$2+=forge$a.util.fillString(String.fromCharCode(0),64),_k$1=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],_initialized$2=!0}function _update$2(e,t,r){for(var n,o,a,l,c,u,g,b,x,S,$,k,T,D,I,O=r.length();O>=64;){for(g=0;g<16;++g)t[g]=r.getInt32();for(;g<64;++g)n=t[g-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,o=t[g-15],o=(o>>>7|o<<25)^(o>>>18|o<<14)^o>>>3,t[g]=n+t[g-7]+o+t[g-16]|0;for(b=e.h0,x=e.h1,S=e.h2,$=e.h3,k=e.h4,T=e.h5,D=e.h6,I=e.h7,g=0;g<64;++g)l=(k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7),c=D^k&(T^D),a=(b>>>2|b<<30)^(b>>>13|b<<19)^(b>>>22|b<<10),u=b&x|S&(b^x),n=I+l+c+_k$1[g]+t[g],o=a+u,I=D,D=T,T=k,k=$+n>>>0,$=S,S=x,x=b,b=n+o>>>0;e.h0=e.h0+b|0,e.h1=e.h1+x|0,e.h2=e.h2+S|0,e.h3=e.h3+$|0,e.h4=e.h4+k|0,e.h5=e.h5+T|0,e.h6=e.h6+D|0,e.h7=e.h7+I|0,O-=64}}var forge$9=forge$m,_crypto$1=null;forge$9.util.isNodejs&&!forge$9.options.usePureJavaScript&&!process.versions["node-webkit"]&&(_crypto$1=require$$6);var prng=forge$9.prng=forge$9.prng||{};prng.create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,n=new Array(32),o=0;o<32;++o)n[o]=r.create();t.pools=n,t.pool=0,t.generate=function(g,b){if(!b)return t.generateSync(g);var x=t.plugin.cipher,S=t.plugin.increment,$=t.plugin.formatKey,k=t.plugin.formatSeed,T=forge$9.util.createBuffer();t.key=null,D();function D(I){if(I)return b(I);if(T.length()>=g)return b(null,T.getBytes(g));if(t.generated>1048575&&(t.key=null),t.key===null)return forge$9.util.nextTick(function(){a(D)});var O=x(t.key,t.seed);t.generated+=O.length,T.putBytes(O),t.key=$(x(t.key,S(t.seed))),t.seed=k(x(t.key,t.seed)),forge$9.util.setImmediate(D)}},t.generateSync=function(g){var b=t.plugin.cipher,x=t.plugin.increment,S=t.plugin.formatKey,$=t.plugin.formatSeed;t.key=null;for(var k=forge$9.util.createBuffer();k.length()1048575&&(t.key=null),t.key===null&&l();var T=b(t.key,t.seed);t.generated+=T.length,k.putBytes(T),t.key=S(b(t.key,x(t.seed))),t.seed=$(b(t.key,t.seed))}return k.getBytes(g)};function a(g){if(t.pools[0].messageLength>=32)return c(),g();var b=32-t.pools[0].messageLength<<5;t.seedFile(b,function(x,S){if(x)return g(x);t.collect(S),c(),g()})}function l(){if(t.pools[0].messageLength>=32)return c();var g=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(g)),c()}function c(){t.reseeds=t.reseeds===4294967295?0:t.reseeds+1;var g=t.plugin.md.create();g.update(t.keyBytes);for(var b=1,x=0;x<32;++x)t.reseeds%b===0&&(g.update(t.pools[x].digest().getBytes()),t.pools[x].start()),b=b<<1;t.keyBytes=g.digest().getBytes(),g.start(),g.update(t.keyBytes);var S=g.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(S),t.generated=0}function u(g){var b=null,x=forge$9.util.globalScope,S=x.crypto||x.msCrypto;S&&S.getRandomValues&&(b=function(ne){return S.getRandomValues(ne)});var $=forge$9.util.createBuffer();if(b)for(;$.length()>16),O+=(I&32767)<<16,O+=I>>15,O=(O&2147483647)+(O>>31),ee=O&4294967295;for(var D=0;D<3;++D)N=ee>>>(D<<3),N^=Math.floor(Math.random()*256),$.putByte(N&255)}return $.getBytes(g)}return _crypto$1?(t.seedFile=function(g,b){_crypto$1.randomBytes(g,function(x,S){if(x)return b(x);b(null,S.toString())})},t.seedFileSync=function(g){return _crypto$1.randomBytes(g).toString()}):(t.seedFile=function(g,b){try{b(null,u(g))}catch(x){b(x)}},t.seedFileSync=u),t.collect=function(g){for(var b=g.length,x=0;x>S&255);t.collect(x)},t.registerWorker=function(g){if(g===self)t.seedFile=function(x,S){function $(k){var T=k.data;T.forge&&T.forge.prng&&(self.removeEventListener("message",$),S(T.forge.prng.err,T.forge.prng.bytes))}self.addEventListener("message",$),self.postMessage({forge:{prng:{needed:x}}})};else{var b=function(x){var S=x.data;S.forge&&S.forge.prng&&t.seedFile(S.forge.prng.needed,function($,k){g.postMessage({forge:{prng:{err:$,bytes:k}}})})};g.addEventListener("message",b)}},t};var forge$8=forge$m;(function(){forge$8.random&&forge$8.random.getBytes||function(e){var t={},r=new Array(4),n=forge$8.util.createBuffer();t.formatKey=function(x){var S=forge$8.util.createBuffer(x);return x=new Array(4),x[0]=S.getInt32(),x[1]=S.getInt32(),x[2]=S.getInt32(),x[3]=S.getInt32(),forge$8.aes._expandKey(x,!1)},t.formatSeed=function(x){var S=forge$8.util.createBuffer(x);return x=new Array(4),x[0]=S.getInt32(),x[1]=S.getInt32(),x[2]=S.getInt32(),x[3]=S.getInt32(),x},t.cipher=function(x,S){return forge$8.aes._updateBlock(x,S,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},t.increment=function(x){return++x[3],x},t.md=forge$8.md.sha256;function o(){var x=forge$8.prng.create(t);return x.getBytes=function(S,$){return x.generate(S,$)},x.getBytesSync=function(S){return x.generate(S)},x}var a=o(),l=null,c=forge$8.util.globalScope,u=c.crypto||c.msCrypto;if(u&&u.getRandomValues&&(l=function(x){return u.getRandomValues(x)}),!forge$8.util.isNodejs&&!l){if(a.collectInt(+new Date,32),typeof navigator<"u"){var g="";for(var b in navigator)try{typeof navigator[b]=="string"&&(g+=navigator[b])}catch{}a.collect(g),g=null}e&&(e().mousemove(function(x){a.collectInt(x.clientX,16),a.collectInt(x.clientY,16)}),e().keypress(function(x){a.collectInt(x.charCode,8)}))}if(!forge$8.random)forge$8.random=a;else for(var b in a)forge$8.random[b]=a[b];forge$8.random.createInstance=o}(typeof jQuery<"u"?jQuery:null)})();var forge$7=forge$m,piTable=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],s$4=[1,2,3,5],rol=function(e,t){return e<>16-t},ror=function(e,t){return(e&65535)>>t|e<<16-t&65535};forge$7.rc2=forge$7.rc2||{};forge$7.rc2.expandKey=function(e,t){typeof e=="string"&&(e=forge$7.util.createBuffer(e)),t=t||128;var r=e,n=e.length(),o=t,a=Math.ceil(o/8),l=255>>(o&7),c;for(c=n;c<128;c++)r.putByte(piTable[r.at(c-1)+r.at(c-n)&255]);for(r.setAt(128-a,piTable[r.at(128-a)&l]),c=127-a;c>=0;c--)r.setAt(c,piTable[r.at(c+1)^r.at(c+a)]);return r};var createCipher=function(e,t,r){var n=!1,o=null,a=null,l=null,c,u,g,b,x=[];for(e=forge$7.rc2.expandKey(e,t),g=0;g<64;g++)x.push(e.getInt16Le());r?(c=function(k){for(g=0;g<4;g++)k[g]+=x[b]+(k[(g+3)%4]&k[(g+2)%4])+(~k[(g+3)%4]&k[(g+1)%4]),k[g]=rol(k[g],s$4[g]),b++},u=function(k){for(g=0;g<4;g++)k[g]+=x[k[(g+3)%4]&63]}):(c=function(k){for(g=3;g>=0;g--)k[g]=ror(k[g],s$4[g]),k[g]-=x[b]+(k[(g+3)%4]&k[(g+2)%4])+(~k[(g+3)%4]&k[(g+1)%4]),b--},u=function(k){for(g=3;g>=0;g--)k[g]-=x[k[(g+3)%4]&63]});var S=function(k){var T=[];for(g=0;g<4;g++){var D=o.getInt16Le();l!==null&&(r?D^=l.getInt16Le():l.putInt16Le(D)),T.push(D&65535)}b=r?0:63;for(var I=0;I=8;)S([[5,c],[1,u],[6,c],[1,u],[5,c]])},finish:function(k){var T=!0;if(r)if(k)T=k(8,o,!r);else{var D=o.length()===8?8:8-o.length();o.fillWithByte(D,D)}if(T&&(n=!0,$.update()),!r&&(T=o.length()===0,T))if(k)T=k(8,a,!r);else{var I=a.length(),O=a.at(I-1);O>I?T=!1:a.truncate(O)}return T}},$};forge$7.rc2.startEncrypting=function(e,t,r){var n=forge$7.rc2.createEncryptionCipher(e,128);return n.start(t,r),n};forge$7.rc2.createEncryptionCipher=function(e,t){return createCipher(e,t,!0)};forge$7.rc2.startDecrypting=function(e,t,r){var n=forge$7.rc2.createDecryptionCipher(e,128);return n.start(t,r),n};forge$7.rc2.createDecryptionCipher=function(e,t){return createCipher(e,t,!1)};var forge$6=forge$m;forge$6.jsbn=forge$6.jsbn||{};var dbits;function BigInteger$2(e,t,r){this.data=[],e!=null&&(typeof e=="number"?this.fromNumber(e,t,r):t==null&&typeof e!="string"?this.fromString(e,256):this.fromString(e,t))}forge$6.jsbn.BigInteger=BigInteger$2;function nbi(){return new BigInteger$2(null)}function am1(e,t,r,n,o,a){for(;--a>=0;){var l=t*this.data[e++]+r.data[n]+o;o=Math.floor(l/67108864),r.data[n++]=l&67108863}return o}function am2(e,t,r,n,o,a){for(var l=t&32767,c=t>>15;--a>=0;){var u=this.data[e]&32767,g=this.data[e++]>>15,b=c*u+g*l;u=l*u+((b&32767)<<15)+r.data[n]+(o&1073741823),o=(u>>>30)+(b>>>15)+c*g+(o>>>30),r.data[n++]=u&1073741823}return o}function am3(e,t,r,n,o,a){for(var l=t&16383,c=t>>14;--a>=0;){var u=this.data[e]&16383,g=this.data[e++]>>14,b=c*u+g*l;u=l*u+((b&16383)<<14)+r.data[n]+o,o=(u>>28)+(b>>14)+c*g,r.data[n++]=u&268435455}return o}typeof navigator>"u"?(BigInteger$2.prototype.am=am3,dbits=28):navigator.appName=="Microsoft Internet Explorer"?(BigInteger$2.prototype.am=am2,dbits=30):navigator.appName!="Netscape"?(BigInteger$2.prototype.am=am1,dbits=26):(BigInteger$2.prototype.am=am3,dbits=28);BigInteger$2.prototype.DB=dbits;BigInteger$2.prototype.DM=(1<=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s}function bnpFromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0}function nbv(e){var t=nbi();return t.fromInt(e),t}function bnpFromString(e,t){var r;if(t==16)r=4;else if(t==8)r=3;else if(t==256)r=8;else if(t==2)r=1;else if(t==32)r=5;else if(t==4)r=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var n=e.length,o=!1,a=0;--n>=0;){var l=r==8?e[n]&255:intAt(e,n);if(l<0){e.charAt(n)=="-"&&(o=!0);continue}o=!1,a==0?this.data[this.t++]=l:a+r>this.DB?(this.data[this.t-1]|=(l&(1<>this.DB-a):this.data[this.t-1]|=l<=this.DB&&(a-=this.DB)}r==8&&(e[0]&128)!=0&&(this.s=-1,a>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t}function bnToString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var r=(1<0)for(c>c)>0&&(o=!0,a=int2char(n));l>=0;)c>(c+=this.DB-t)):(n=this.data[l]>>(c-=t)&r,c<=0&&(c+=this.DB,--l)),n>0&&(o=!0),o&&(a+=int2char(n));return o?a:"0"}function bnNegate(){var e=nbi();return BigInteger$2.ZERO.subTo(this,e),e}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(e){var t=this.s-e.s;if(t!=0)return t;var r=this.t;if(t=r-e.t,t!=0)return this.s<0?-t:t;for(;--r>=0;)if((t=this.data[r]-e.data[r])!=0)return t;return 0}function nbits(e){var t=1,r;return(r=e>>>16)!=0&&(e=r,t+=16),(r=e>>8)!=0&&(e=r,t+=8),(r=e>>4)!=0&&(e=r,t+=4),(r=e>>2)!=0&&(e=r,t+=2),(r=e>>1)!=0&&(e=r,t+=1),t}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this.data[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s}function bnpDRShiftTo(e,t){for(var r=e;r=0;--c)t.data[c+a+1]=this.data[c]>>n|l,l=(this.data[c]&o)<=0;--c)t.data[c]=0;t.data[a]=l,t.t=this.t+a+1,t.s=this.s,t.clamp()}function bnpRShiftTo(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t){t.t=0;return}var n=e%this.DB,o=this.DB-n,a=(1<>n;for(var l=r+1;l>n;n>0&&(t.data[this.t-r-1]|=(this.s&a)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()}function bnpMultiplyTo(e,t){var r=this.abs(),n=e.abs(),o=r.t;for(t.t=o+n.t;--o>=0;)t.data[o]=0;for(o=0;o=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()}function bnpDivRemTo(e,t,r){var n=e.abs();if(!(n.t<=0)){var o=this.abs();if(o.t0?(n.lShiftTo(u,a),o.lShiftTo(u,r)):(n.copyTo(a),o.copyTo(r));var g=a.t,b=a.data[g-1];if(b!=0){var x=b*(1<1?a.data[g-2]>>this.F2:0),S=this.FV/x,$=(1<=0&&(r.data[r.t++]=1,r.subTo(I,r)),BigInteger$2.ONE.dlShiftTo(g,I),I.subTo(a,a);a.t=0;){var O=r.data[--T]==b?this.DM:Math.floor(r.data[T]*S+(r.data[T-1]+k)*$);if((r.data[T]+=a.am(0,O,r,D,0,g))0&&r.rShiftTo(u,r),l<0&&BigInteger$2.ZERO.subTo(r,r)}}}function bnMod(e){var t=nbi();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(BigInteger$2.ZERO)>0&&e.subTo(t,t),t}function Classic(e){this.m=e}function cConvert(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function cRevert(e){return e}function cReduce(e){e.divRemTo(this.m,null,e)}function cMulTo(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function cSqrTo(e,t){e.squareTo(t),this.reduce(t)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1)return 0;var e=this.data[0];if((e&1)==0)return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Montgomery(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(t,t),t}function montRevert(e){var t=nbi();return e.copyTo(t),this.reduce(t),t}function montReduce(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function montSqrTo(e,t){e.squareTo(t),this.reduce(t)}function montMulTo(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return(this.t>0?this.data[0]&1:this.s)==0}function bnpExp(e,t){if(e>4294967295||e<1)return BigInteger$2.ONE;var r=nbi(),n=nbi(),o=t.convert(this),a=nbits(e)-1;for(o.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,o,r);else{var l=r;r=n,n=l}return t.revert(r)}function bnModPowInt(e,t){var r;return e<256||t.isEven()?r=new Classic(t):r=new Montgomery(t),this.exp(e,r)}BigInteger$2.prototype.copyTo=bnpCopyTo;BigInteger$2.prototype.fromInt=bnpFromInt;BigInteger$2.prototype.fromString=bnpFromString;BigInteger$2.prototype.clamp=bnpClamp;BigInteger$2.prototype.dlShiftTo=bnpDLShiftTo;BigInteger$2.prototype.drShiftTo=bnpDRShiftTo;BigInteger$2.prototype.lShiftTo=bnpLShiftTo;BigInteger$2.prototype.rShiftTo=bnpRShiftTo;BigInteger$2.prototype.subTo=bnpSubTo;BigInteger$2.prototype.multiplyTo=bnpMultiplyTo;BigInteger$2.prototype.squareTo=bnpSquareTo;BigInteger$2.prototype.divRemTo=bnpDivRemTo;BigInteger$2.prototype.invDigit=bnpInvDigit;BigInteger$2.prototype.isEven=bnpIsEven;BigInteger$2.prototype.exp=bnpExp;BigInteger$2.prototype.toString=bnToString;BigInteger$2.prototype.negate=bnNegate;BigInteger$2.prototype.abs=bnAbs;BigInteger$2.prototype.compareTo=bnCompareTo;BigInteger$2.prototype.bitLength=bnBitLength;BigInteger$2.prototype.mod=bnMod;BigInteger$2.prototype.modPowInt=bnModPowInt;BigInteger$2.ZERO=nbv(0);BigInteger$2.ONE=nbv(1);function bnClone(){var e=nbi();return this.copyTo(e),e}function bnIntValue(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return this.t==0?this.s:this.data[0]<<16>>16}function bnpChunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function bnSigNum(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function bnpToRadix(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=nbv(r),o=nbi(),a=nbi(),l="";for(this.divRemTo(n,o,a);o.signum()>0;)l=(r+a.intValue()).toString(e).substr(1)+l,o.divRemTo(n,o,a);return a.intValue().toString(e)+l}function bnpFromRadix(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),o=!1,a=0,l=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(l,0),a=0,l=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(l,0)),o&&BigInteger$2.ZERO.subTo(this,this)}function bnpFromNumber(e,t,r){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(BigInteger$2.ONE.shiftLeft(e-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(BigInteger$2.ONE.shiftLeft(e-1),this);else{var n=new Array,o=e&7;n.length=(e>>3)+1,t.nextBytes(n),o>0?n[0]&=(1<0)for(r>r)!=(this.s&this.DM)>>r&&(t[o++]=n|this.s<=0;)r<8?(n=(this.data[e]&(1<>(r+=this.DB-8)):(n=this.data[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),(n&128)!=0&&(n|=-256),o==0&&(this.s&128)!=(n&128)&&++o,(o>0||n!=this.s)&&(t[o++]=n);return t}function bnEquals(e){return this.compareTo(e)==0}function bnMin(e){return this.compareTo(e)<0?this:e}function bnMax(e){return this.compareTo(e)>0?this:e}function bnpBitwiseTo(e,t,r){var n,o,a=Math.min(e.t,this.t);for(n=0;n>=16,t+=16),(e&255)==0&&(e>>=8,t+=8),(e&15)==0&&(e>>=4,t+=4),(e&3)==0&&(e>>=2,t+=2),(e&1)==0&&++t,t}function bnGetLowestSetBit(){for(var e=0;e=this.t?this.s!=0:(this.data[t]&1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()}function bnAdd(e){var t=nbi();return this.addTo(e,t),t}function bnSubtract(e){var t=nbi();return this.subTo(e,t),t}function bnMultiply(e){var t=nbi();return this.multiplyTo(e,t),t}function bnDivide(e){var t=nbi();return this.divRemTo(e,t,null),t}function bnRemainder(e){var t=nbi();return this.divRemTo(e,null,t),t}function bnDivideAndRemainder(e){var t=nbi(),r=nbi();return this.divRemTo(e,t,r),new Array(t,r)}function bnpDMultiply(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(e,t){if(e!=0){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}}function NullExp(){}function nNop(e){return e}function nMulTo(e,t,r){e.multiplyTo(t,r)}function nSqrTo(e,t){e.squareTo(t)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(e){return this.exp(e,new NullExp)}function bnpMultiplyLowerTo(e,t,r){var n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;var o;for(o=r.t-this.t;n=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=nbi();return e.copyTo(t),this.reduce(t),t}function barrettRevert(e){return e}function barrettReduce(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function barrettSqrTo(e,t){e.squareTo(t),this.reduce(t)}function barrettMulTo(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(e,t){var r=e.bitLength(),n,o=nbv(1),a;if(r<=0)return o;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?a=new Classic(t):t.isEven()?a=new Barrett(t):a=new Montgomery(t);var l=new Array,c=3,u=n-1,g=(1<1){var b=nbi();for(a.sqrTo(l[1],b);c<=g;)l[c]=nbi(),a.mulTo(b,l[c-2],l[c]),c+=2}var x=e.t-1,S,$=!0,k=nbi(),T;for(r=nbits(e.data[x])-1;x>=0;){for(r>=u?S=e.data[x]>>r-u&g:(S=(e.data[x]&(1<0&&(S|=e.data[x-1]>>this.DB+r-u)),c=n;(S&1)==0;)S>>=1,--c;if((r-=c)<0&&(r+=this.DB,--x),$)l[S].copyTo(o),$=!1;else{for(;c>1;)a.sqrTo(o,k),a.sqrTo(k,o),c-=2;c>0?a.sqrTo(o,k):(T=o,o=k,k=T),a.mulTo(k,l[S],o)}for(;x>=0&&(e.data[x]&1<0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(o=t.getLowestSetBit())>0&&t.rShiftTo(o,t),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r}function bnpModInt(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(t==0)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r}function bnModInverse(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return BigInteger$2.ZERO;for(var r=e.clone(),n=this.clone(),o=nbv(1),a=nbv(0),l=nbv(0),c=nbv(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),t?((!o.isEven()||!a.isEven())&&(o.addTo(this,o),a.subTo(e,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?((!l.isEven()||!c.isEven())&&(l.addTo(this,l),c.subTo(e,c)),l.rShiftTo(1,l)):c.isEven()||c.subTo(e,c),c.rShiftTo(1,c);r.compareTo(n)>=0?(r.subTo(n,r),t&&o.subTo(l,o),a.subTo(c,a)):(n.subTo(r,n),t&&l.subTo(o,l),c.subTo(a,c))}if(n.compareTo(BigInteger$2.ONE)!=0)return BigInteger$2.ZERO;if(c.compareTo(e)>=0)return c.subtract(e);if(c.signum()<0)c.addTo(e,c);else return c;return c.signum()<0?c.add(e):c}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var t,r=this.abs();if(r.t==1&&r.data[0]<=lowprimes[lowprimes.length-1]){for(t=0;t=0);var c=a.modPow(n,this);if(c.compareTo(BigInteger$2.ONE)!=0&&c.compareTo(t)!=0){for(var u=1;u++>>0,l>>>0];for(var c=n.fullMessageLength.length-1;c>=0;--c)n.fullMessageLength[c]+=l[1],l[1]=l[0]+(n.fullMessageLength[c]/4294967296>>>0),n.fullMessageLength[c]=n.fullMessageLength[c]>>>0,l[0]=l[1]/4294967296>>>0;return t.putBytes(o),_update$1(e,r,t),(t.read>2048||t.length()===0)&&t.compact(),n},n.digest=function(){var o=forge$5.util.createBuffer();o.putBytes(t.bytes());var a=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,l=a&n.blockLength-1;o.putBytes(_padding$1.substr(0,n.blockLength-l));for(var c,u,g=n.fullMessageLength[0]*8,b=0;b>>0,g+=u,o.putInt32(g>>>0),g=c>>>0;o.putInt32(g);var x={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};_update$1(x,r,o);var S=forge$5.util.createBuffer();return S.putInt32(x.h0),S.putInt32(x.h1),S.putInt32(x.h2),S.putInt32(x.h3),S.putInt32(x.h4),S},n};var _padding$1=null,_initialized$1=!1;function _init$1(){_padding$1=String.fromCharCode(128),_padding$1+=forge$5.util.fillString(String.fromCharCode(0),64),_initialized$1=!0}function _update$1(e,t,r){for(var n,o,a,l,c,u,g,b,x=r.length();x>=64;){for(o=e.h0,a=e.h1,l=e.h2,c=e.h3,u=e.h4,b=0;b<16;++b)n=r.getInt32(),t[b]=n,g=c^a&(l^c),n=(o<<5|o>>>27)+g+u+1518500249+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;for(;b<20;++b)n=t[b-3]^t[b-8]^t[b-14]^t[b-16],n=n<<1|n>>>31,t[b]=n,g=c^a&(l^c),n=(o<<5|o>>>27)+g+u+1518500249+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;for(;b<32;++b)n=t[b-3]^t[b-8]^t[b-14]^t[b-16],n=n<<1|n>>>31,t[b]=n,g=a^l^c,n=(o<<5|o>>>27)+g+u+1859775393+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;for(;b<40;++b)n=t[b-6]^t[b-16]^t[b-28]^t[b-32],n=n<<2|n>>>30,t[b]=n,g=a^l^c,n=(o<<5|o>>>27)+g+u+1859775393+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;for(;b<60;++b)n=t[b-6]^t[b-16]^t[b-28]^t[b-32],n=n<<2|n>>>30,t[b]=n,g=a&l|c&(a^l),n=(o<<5|o>>>27)+g+u+2400959708+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;for(;b<80;++b)n=t[b-6]^t[b-16]^t[b-28]^t[b-32],n=n<<2|n>>>30,t[b]=n,g=a^l^c,n=(o<<5|o>>>27)+g+u+3395469782+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;e.h0=e.h0+o|0,e.h1=e.h1+a|0,e.h2=e.h2+l|0,e.h3=e.h3+c|0,e.h4=e.h4+u|0,x-=64}}var forge$4=forge$m,pkcs1=forge$4.pkcs1=forge$4.pkcs1||{};pkcs1.encode_rsa_oaep=function(e,t,r){var n,o,a,l;typeof r=="string"?(n=r,o=arguments[3]||void 0,a=arguments[4]||void 0):r&&(n=r.label||void 0,o=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(l=r.mgf1.md)),a?a.start():a=forge$4.md.sha1.create(),l||(l=a);var c=Math.ceil(e.n.bitLength()/8),u=c-2*a.digestLength-2;if(t.length>u){var g=new Error("RSAES-OAEP input message length is too long.");throw g.length=t.length,g.maxLength=u,g}n||(n=""),a.update(n,"raw");for(var b=a.digest(),x="",S=u-t.length,$=0;$>24&255,a>>16&255,a>>8&255,a&255);r.start(),r.update(e+l),n+=r.digest().getBytes()}return n.substring(0,t)}var forge$3=forge$m;(function(){if(forge$3.prime)return;var e=forge$3.prime=forge$3.prime||{},t=forge$3.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new t(null);n.fromInt(30);var o=function(x,S){return x|S};e.generateProbablePrime=function(x,S,$){typeof S=="function"&&($=S,S={}),S=S||{};var k=S.algorithm||"PRIMEINC";typeof k=="string"&&(k={name:k}),k.options=k.options||{};var T=S.prng||forge$3.random,D={nextBytes:function(I){for(var O=T.getBytesSync(I.length),N=0;NS&&(x=g(S,$)),x.isProbablePrime(T))return I(null,x);x.dAddOffset(r[k++%8],0)}while(D<0||+new Date-O"u")return l(x,S,$,k);var T=g(x,S),D=$.workers,I=$.workLoad||100,O=I*30/8,N=$.workerScript||"forge/prime.worker.js";if(D===-1)return forge$3.util.estimateCores(function(ne,B){ne&&(B=2),D=B-1,ee()});ee();function ee(){D=Math.max(1,D);for(var ne=[],B=0;Bx&&(T=g(x,S));var _e=T.toString(16);xe.target.postMessage({hex:_e,workLoad:I}),T.dAddOffset(O,0)}}}}function g(x,S){var $=new t(x,S),k=x-1;return $.testBit(k)||$.bitwiseTo(t.ONE.shiftLeft(k),o,$),$.dAddOffset(31-$.mod(n).byteValue(),0),$}function b(x){return x<=100?27:x<=150?18:x<=200?15:x<=250?12:x<=300?9:x<=350?8:x<=400?7:x<=500?6:x<=600?5:x<=800?4:x<=1250?3:2}})();var forge$2=forge$m;if(typeof BigInteger$1>"u")var BigInteger$1=forge$2.jsbn.BigInteger;var _crypto=forge$2.util.isNodejs?require$$6:null,asn1$1=forge$2.asn1,util$5=forge$2.util;forge$2.pki=forge$2.pki||{};forge$2.pki.rsa=forge$2.rsa=forge$2.rsa||{};var pki$1=forge$2.pki,GCD_30_DELTA=[6,4,2,4,2,4,6,2],privateKeyValidator={name:"PrivateKeyInfo",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},rsaPrivateKeyValidator={name:"RSAPrivateKey",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},rsaPublicKeyValidator={name:"RSAPublicKey",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},publicKeyValidator=forge$2.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},digestInfoValidator={name:"DigestInfo",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},emsaPkcs1v15encode=function(e){var t;if(e.algorithm in pki$1.oids)t=pki$1.oids[e.algorithm];else{var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}var n=asn1$1.oidToDer(t).getBytes(),o=asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[]),a=asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[]);a.value.push(asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.OID,!1,n)),a.value.push(asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.NULL,!1,""));var l=asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.OCTETSTRING,!1,e.digest().getBytes());return o.value.push(a),o.value.push(l),asn1$1.toDer(o).getBytes()},_modPow=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);t.dP||(t.dP=t.d.mod(t.p.subtract(BigInteger$1.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(BigInteger$1.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));var n;do n=new BigInteger$1(forge$2.util.bytesToHex(forge$2.random.getBytes(t.n.bitLength()/8)),16);while(n.compareTo(t.n)>=0||!n.gcd(t.n).equals(BigInteger$1.ONE));e=e.multiply(n.modPow(t.e,t.n)).mod(t.n);for(var o=e.mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);o.compareTo(a)<0;)o=o.add(t.p);var l=o.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return l=l.multiply(n.modInverse(t.n)).mod(t.n),l};pki$1.rsa.encrypt=function(e,t,r){var n=r,o,a=Math.ceil(t.n.bitLength()/8);r!==!1&&r!==!0?(n=r===2,o=_encodePkcs1_v1_5(e,t,r)):(o=forge$2.util.createBuffer(),o.putBytes(e));for(var l=new BigInteger$1(o.toHex(),16),c=_modPow(l,t,n),u=c.toString(16),g=forge$2.util.createBuffer(),b=a-Math.ceil(u.length/2);b>0;)g.putByte(0),--b;return g.putBytes(forge$2.util.hexToBytes(u)),g.getBytes()};pki$1.rsa.decrypt=function(e,t,r,n){var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=o,a}var l=new BigInteger$1(forge$2.util.createBuffer(e).toHex(),16);if(l.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var c=_modPow(l,t,r),u=c.toString(16),g=forge$2.util.createBuffer(),b=o-Math.ceil(u.length/2);b>0;)g.putByte(0),--b;return g.putBytes(forge$2.util.hexToBytes(u)),n!==!1?_decodePkcs1_v1_5(g.getBytes(),t,r):g.getBytes()};pki$1.rsa.createKeyPairGenerationState=function(e,t,r){typeof e=="string"&&(e=parseInt(e,10)),e=e||2048,r=r||{};var n=r.prng||forge$2.random,o={nextBytes:function(c){for(var u=n.getBytesSync(c.length),g=0;g>1,pBits:e-(e>>1),pqState:0,num:null,keys:null},l.e.fromInt(l.eInt);else throw new Error("Invalid key generation algorithm: "+a);return l};pki$1.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new BigInteger$1(null);r.fromInt(30);for(var n=0,o=function(x,S){return x|S},a=+new Date,l,c=0;e.keys===null&&(t<=0||cu?e.pqState=0:e.num.isProbablePrime(_getMillerRabinTests(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(GCD_30_DELTA[n++%8],0):e.pqState===2?e.pqState=e.num.subtract(BigInteger$1.ONE).gcd(e.e).compareTo(BigInteger$1.ONE)===0?3:0:e.pqState===3&&(e.pqState=0,e.p===null?e.p=e.num:e.q=e.num,e.p!==null&&e.q!==null&&++e.state,e.num=null)}else if(e.state===1)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(e.state===2)e.p1=e.p.subtract(BigInteger$1.ONE),e.q1=e.q.subtract(BigInteger$1.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(e.state===3)e.phi.gcd(e.e).compareTo(BigInteger$1.ONE)===0?++e.state:(e.p=null,e.q=null,e.state=0);else if(e.state===4)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(e.state===5){var b=e.e.modInverse(e.phi);e.keys={privateKey:pki$1.rsa.setPrivateKey(e.n,e.e,b,e.p,e.q,b.mod(e.p1),b.mod(e.q1),e.q.modInverse(e.p)),publicKey:pki$1.rsa.setPublicKey(e.n,e.e)}}l=+new Date,c+=l-a,a=l}return e.keys!==null};pki$1.rsa.generateKeyPair=function(e,t,r,n){if(arguments.length===1?typeof e=="object"?(r=e,e=void 0):typeof e=="function"&&(n=e,e=void 0):arguments.length===2?typeof e=="number"?typeof t=="function"?(n=t,t=void 0):typeof t!="number"&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):arguments.length===3&&(typeof t=="number"?typeof r=="function"&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},e===void 0&&(e=r.bits||2048),t===void 0&&(t=r.e||65537),!r.prng&&e>=256&&e<=16384&&(t===65537||t===3)){if(n){if(_detectNodeCrypto("generateKeyPair"))return _crypto.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(c,u,g){if(c)return n(c);n(null,{privateKey:pki$1.privateKeyFromPem(g),publicKey:pki$1.publicKeyFromPem(u)})});if(_detectSubtleCrypto("generateKey")&&_detectSubtleCrypto("exportKey"))return util$5.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:_intToUint8Array(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(c){return util$5.globalScope.crypto.subtle.exportKey("pkcs8",c.privateKey)}).then(void 0,function(c){n(c)}).then(function(c){if(c){var u=pki$1.privateKeyFromAsn1(asn1$1.fromDer(forge$2.util.createBuffer(c)));n(null,{privateKey:u,publicKey:pki$1.setRsaPublicKey(u.n,u.e)})}});if(_detectSubtleMsCrypto("generateKey")&&_detectSubtleMsCrypto("exportKey")){var o=util$5.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:_intToUint8Array(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);o.oncomplete=function(c){var u=c.target.result,g=util$5.globalScope.msCrypto.subtle.exportKey("pkcs8",u.privateKey);g.oncomplete=function(b){var x=b.target.result,S=pki$1.privateKeyFromAsn1(asn1$1.fromDer(forge$2.util.createBuffer(x)));n(null,{privateKey:S,publicKey:pki$1.setRsaPublicKey(S.n,S.e)})},g.onerror=function(b){n(b)}},o.onerror=function(c){n(c)};return}}else if(_detectNodeCrypto("generateKeyPairSync")){var a=_crypto.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:pki$1.privateKeyFromPem(a.privateKey),publicKey:pki$1.publicKeyFromPem(a.publicKey)}}}var l=pki$1.rsa.createKeyPairGenerationState(e,t,r);if(!n)return pki$1.rsa.stepKeyPairGenerationState(l,0),l.keys;_generateKeyPair(l,r,n)};pki$1.setRsaPublicKey=pki$1.rsa.setPublicKey=function(e,t){var r={n:e,e:t};return r.encrypt=function(n,o,a){if(typeof o=="string"?o=o.toUpperCase():o===void 0&&(o="RSAES-PKCS1-V1_5"),o==="RSAES-PKCS1-V1_5")o={encode:function(c,u,g){return _encodePkcs1_v1_5(c,u,2).getBytes()}};else if(o==="RSA-OAEP"||o==="RSAES-OAEP")o={encode:function(c,u){return forge$2.pkcs1.encode_rsa_oaep(u,c,a)}};else if(["RAW","NONE","NULL",null].indexOf(o)!==-1)o={encode:function(c){return c}};else if(typeof o=="string")throw new Error('Unsupported encryption scheme: "'+o+'".');var l=o.encode(n,r,!0);return pki$1.rsa.encrypt(l,r,!0)},r.verify=function(n,o,a,l){typeof a=="string"?a=a.toUpperCase():a===void 0&&(a="RSASSA-PKCS1-V1_5"),l===void 0&&(l={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in l||(l._parseAllDigestBytes=!0),a==="RSASSA-PKCS1-V1_5"?a={verify:function(u,g){g=_decodePkcs1_v1_5(g,r,!0);var b=asn1$1.fromDer(g,{parseAllBytes:l._parseAllDigestBytes}),x={},S=[];if(!asn1$1.validate(b,digestInfoValidator,x,S)){var $=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw $.errors=S,$}var k=asn1$1.derToOid(x.algorithmIdentifier);if(!(k===forge$2.oids.md2||k===forge$2.oids.md5||k===forge$2.oids.sha1||k===forge$2.oids.sha224||k===forge$2.oids.sha256||k===forge$2.oids.sha384||k===forge$2.oids.sha512||k===forge$2.oids["sha512-224"]||k===forge$2.oids["sha512-256"])){var $=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw $.oid=k,$}if((k===forge$2.oids.md2||k===forge$2.oids.md5)&&!("parameters"in x))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return u===x.digest}}:(a==="NONE"||a==="NULL"||a===null)&&(a={verify:function(u,g){return g=_decodePkcs1_v1_5(g,r,!0),u===g}});var c=pki$1.rsa.decrypt(o,r,!0,!1);return a.verify(n,c,r.n.bitLength())},r};pki$1.setRsaPrivateKey=pki$1.rsa.setPrivateKey=function(e,t,r,n,o,a,l,c){var u={n:e,e:t,d:r,p:n,q:o,dP:a,dQ:l,qInv:c};return u.decrypt=function(g,b,x){typeof b=="string"?b=b.toUpperCase():b===void 0&&(b="RSAES-PKCS1-V1_5");var S=pki$1.rsa.decrypt(g,u,!1,!1);if(b==="RSAES-PKCS1-V1_5")b={decode:_decodePkcs1_v1_5};else if(b==="RSA-OAEP"||b==="RSAES-OAEP")b={decode:function($,k){return forge$2.pkcs1.decode_rsa_oaep(k,$,x)}};else if(["RAW","NONE","NULL",null].indexOf(b)!==-1)b={decode:function($){return $}};else throw new Error('Unsupported encryption scheme: "'+b+'".');return b.decode(S,u,!1)},u.sign=function(g,b){var x=!1;typeof b=="string"&&(b=b.toUpperCase()),b===void 0||b==="RSASSA-PKCS1-V1_5"?(b={encode:emsaPkcs1v15encode},x=1):(b==="NONE"||b==="NULL"||b===null)&&(b={encode:function(){return g}},x=1);var S=b.encode(g,u.n.bitLength());return pki$1.rsa.encrypt(S,u,x)},u};pki$1.wrapRsaPrivateKey=function(e){return asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,asn1$1.integerToDer(0).getBytes()),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.OID,!1,asn1$1.oidToDer(pki$1.oids.rsaEncryption).getBytes()),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.NULL,!1,"")]),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.OCTETSTRING,!1,asn1$1.toDer(e).getBytes())])};pki$1.privateKeyFromAsn1=function(e){var t={},r=[];if(asn1$1.validate(e,privateKeyValidator,t,r)&&(e=asn1$1.fromDer(forge$2.util.createBuffer(t.privateKey))),t={},r=[],!asn1$1.validate(e,rsaPrivateKeyValidator,t,r)){var n=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw n.errors=r,n}var o,a,l,c,u,g,b,x;return o=forge$2.util.createBuffer(t.privateKeyModulus).toHex(),a=forge$2.util.createBuffer(t.privateKeyPublicExponent).toHex(),l=forge$2.util.createBuffer(t.privateKeyPrivateExponent).toHex(),c=forge$2.util.createBuffer(t.privateKeyPrime1).toHex(),u=forge$2.util.createBuffer(t.privateKeyPrime2).toHex(),g=forge$2.util.createBuffer(t.privateKeyExponent1).toHex(),b=forge$2.util.createBuffer(t.privateKeyExponent2).toHex(),x=forge$2.util.createBuffer(t.privateKeyCoefficient).toHex(),pki$1.setRsaPrivateKey(new BigInteger$1(o,16),new BigInteger$1(a,16),new BigInteger$1(l,16),new BigInteger$1(c,16),new BigInteger$1(u,16),new BigInteger$1(g,16),new BigInteger$1(b,16),new BigInteger$1(x,16))};pki$1.privateKeyToAsn1=pki$1.privateKeyToRSAPrivateKey=function(e){return asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,asn1$1.integerToDer(0).getBytes()),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.n)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.e)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.d)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.p)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.q)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.dP)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.dQ)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.qInv))])};pki$1.publicKeyFromAsn1=function(e){var t={},r=[];if(asn1$1.validate(e,publicKeyValidator,t,r)){var n=asn1$1.derToOid(t.publicKeyOid);if(n!==pki$1.oids.rsaEncryption){var o=new Error("Cannot read public key. Unknown OID.");throw o.oid=n,o}e=t.rsaPublicKey}if(r=[],!asn1$1.validate(e,rsaPublicKeyValidator,t,r)){var o=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw o.errors=r,o}var a=forge$2.util.createBuffer(t.publicKeyModulus).toHex(),l=forge$2.util.createBuffer(t.publicKeyExponent).toHex();return pki$1.setRsaPublicKey(new BigInteger$1(a,16),new BigInteger$1(l,16))};pki$1.publicKeyToAsn1=pki$1.publicKeyToSubjectPublicKeyInfo=function(e){return asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.OID,!1,asn1$1.oidToDer(pki$1.oids.rsaEncryption).getBytes()),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.NULL,!1,"")]),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.BITSTRING,!1,[pki$1.publicKeyToRSAPublicKey(e)])])};pki$1.publicKeyToRSAPublicKey=function(e){return asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.n)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.e))])};function _encodePkcs1_v1_5(e,t,r){var n=forge$2.util.createBuffer(),o=Math.ceil(t.n.bitLength()/8);if(e.length>o-11){var a=new Error("Message is too long for PKCS#1 v1.5 padding.");throw a.length=e.length,a.max=o-11,a}n.putByte(0),n.putByte(r);var l=o-3-e.length,c;if(r===0||r===1){c=r===0?0:255;for(var u=0;u0;){for(var g=0,b=forge$2.random.getBytes(l),u=0;u"u")throw new Error("Encryption block is invalid.");var u=0;if(c===0){u=o-3-n;for(var g=0;g1;){if(a.getByte()!==255){--a.read;break}++u}else if(c===2)for(u=0;a.length()>1;){if(a.getByte()===0){--a.read;break}++u}var b=a.getByte();if(b!==0||u!==o-3-a.length())throw new Error("Encryption block is invalid.");return a.getBytes()}function _generateKeyPair(e,t,r){typeof t=="function"&&(r=t,t={}),t=t||{};var n={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(n.prng=t.prng),o();function o(){a(e.pBits,function(c,u){if(c)return r(c);if(e.p=u,e.q!==null)return l(c,e.q);a(e.qBits,l)})}function a(c,u){forge$2.prime.generateProbablePrime(c,n,u)}function l(c,u){if(c)return r(c);if(e.q=u,e.p.compareTo(e.q)<0){var g=e.p;e.p=e.q,e.q=g}if(e.p.subtract(BigInteger$1.ONE).gcd(e.e).compareTo(BigInteger$1.ONE)!==0){e.p=null,o();return}if(e.q.subtract(BigInteger$1.ONE).gcd(e.e).compareTo(BigInteger$1.ONE)!==0){e.q=null,a(e.qBits,l);return}if(e.p1=e.p.subtract(BigInteger$1.ONE),e.q1=e.q.subtract(BigInteger$1.ONE),e.phi=e.p1.multiply(e.q1),e.phi.gcd(e.e).compareTo(BigInteger$1.ONE)!==0){e.p=e.q=null,o();return}if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits){e.q=null,a(e.qBits,l);return}var b=e.e.modInverse(e.phi);e.keys={privateKey:pki$1.rsa.setPrivateKey(e.n,e.e,b,e.p,e.q,b.mod(e.p1),b.mod(e.q1),e.q.modInverse(e.p)),publicKey:pki$1.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}}function _bnToBytes(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=forge$2.util.hexToBytes(t);return r.length>1&&(r.charCodeAt(0)===0&&(r.charCodeAt(1)&128)===0||r.charCodeAt(0)===255&&(r.charCodeAt(1)&128)===128)?r.substr(1):r}function _getMillerRabinTests(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function _detectNodeCrypto(e){return forge$2.util.isNodejs&&typeof _crypto[e]=="function"}function _detectSubtleCrypto(e){return typeof util$5.globalScope<"u"&&typeof util$5.globalScope.crypto=="object"&&typeof util$5.globalScope.crypto.subtle=="object"&&typeof util$5.globalScope.crypto.subtle[e]=="function"}function _detectSubtleMsCrypto(e){return typeof util$5.globalScope<"u"&&typeof util$5.globalScope.msCrypto=="object"&&typeof util$5.globalScope.msCrypto.subtle=="object"&&typeof util$5.globalScope.msCrypto.subtle[e]=="function"}function _intToUint8Array(e){for(var t=forge$2.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n"u")var BigInteger=forge$1.jsbn.BigInteger;var asn1=forge$1.asn1,pki=forge$1.pki=forge$1.pki||{};pki.pbe=forge$1.pbe=forge$1.pbe||{};var oids=pki.oids,encryptedPrivateKeyValidator={name:"EncryptedPrivateKeyInfo",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},PBES2AlgorithmsValidator={name:"PBES2Algorithms",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},pkcs12PbeParamsValidator={name:"pkcs-12PbeParams",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:!1,capture:"iterations"}]};pki.encryptPrivateKeyInfo=function(e,t,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n=forge$1.random.getBytesSync(r.saltSize),o=r.count,a=asn1.integerToDer(o),l,c,u;if(r.algorithm.indexOf("aes")===0||r.algorithm==="des"){var g,b,x;switch(r.algorithm){case"aes128":l=16,g=16,b=oids["aes128-CBC"],x=forge$1.aes.createEncryptionCipher;break;case"aes192":l=24,g=16,b=oids["aes192-CBC"],x=forge$1.aes.createEncryptionCipher;break;case"aes256":l=32,g=16,b=oids["aes256-CBC"],x=forge$1.aes.createEncryptionCipher;break;case"des":l=8,g=8,b=oids.desCBC,x=forge$1.des.createEncryptionCipher;break;default:var S=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw S.algorithm=r.algorithm,S}var $="hmacWith"+r.prfAlgorithm.toUpperCase(),k=prfAlgorithmToMessageDigest($),T=forge$1.pkcs5.pbkdf2(t,n,o,l,k),D=forge$1.random.getBytesSync(g),I=x(T);I.start(D),I.update(asn1.toDer(e)),I.finish(),u=I.output.getBytes();var O=createPbkdf2Params(n,a,l,$);c=asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,!1,asn1.oidToDer(oids.pkcs5PBES2).getBytes()),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,!1,asn1.oidToDer(oids.pkcs5PBKDF2).getBytes()),O]),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,!1,asn1.oidToDer(b).getBytes()),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OCTETSTRING,!1,D)])])])}else if(r.algorithm==="3des"){l=24;var N=new forge$1.util.ByteBuffer(n),T=pki.pbe.generatePkcs12Key(t,N,1,o,l),D=pki.pbe.generatePkcs12Key(t,N,2,o,l),I=forge$1.des.createEncryptionCipher(T);I.start(D),I.update(asn1.toDer(e)),I.finish(),u=I.output.getBytes(),c=asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,!1,asn1.oidToDer(oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OCTETSTRING,!1,n),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.INTEGER,!1,a.getBytes())])])}else{var S=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw S.algorithm=r.algorithm,S}var ee=asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[c,asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OCTETSTRING,!1,u)]);return ee};pki.decryptPrivateKeyInfo=function(e,t){var r=null,n={},o=[];if(!asn1.validate(e,encryptedPrivateKeyValidator,n,o)){var a=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=o,a}var l=asn1.derToOid(n.encryptionOid),c=pki.pbe.getCipher(l,n.encryptionParams,t),u=forge$1.util.createBuffer(n.encryptedData);return c.update(u),c.finish()&&(r=asn1.fromDer(c.output)),r};pki.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:asn1.toDer(e).getBytes()};return forge$1.pem.encode(r,{maxline:t})};pki.encryptedPrivateKeyFromPem=function(e){var t=forge$1.pem.decode(e)[0];if(t.type!=="ENCRYPTED PRIVATE KEY"){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return asn1.fromDer(t.body)};pki.encryptRsaPrivateKey=function(e,t,r){if(r=r||{},!r.legacy){var n=pki.wrapRsaPrivateKey(pki.privateKeyToAsn1(e));return n=pki.encryptPrivateKeyInfo(n,t,r),pki.encryptedPrivateKeyToPem(n)}var o,a,l,c;switch(r.algorithm){case"aes128":o="AES-128-CBC",l=16,a=forge$1.random.getBytesSync(16),c=forge$1.aes.createEncryptionCipher;break;case"aes192":o="AES-192-CBC",l=24,a=forge$1.random.getBytesSync(16),c=forge$1.aes.createEncryptionCipher;break;case"aes256":o="AES-256-CBC",l=32,a=forge$1.random.getBytesSync(16),c=forge$1.aes.createEncryptionCipher;break;case"3des":o="DES-EDE3-CBC",l=24,a=forge$1.random.getBytesSync(8),c=forge$1.des.createEncryptionCipher;break;case"des":o="DES-CBC",l=8,a=forge$1.random.getBytesSync(8),c=forge$1.des.createEncryptionCipher;break;default:var u=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw u.algorithm=r.algorithm,u}var g=forge$1.pbe.opensslDeriveBytes(t,a.substr(0,8),l),b=c(g);b.start(a),b.update(asn1.toDer(pki.privateKeyToAsn1(e))),b.finish();var x={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:o,parameters:forge$1.util.bytesToHex(a).toUpperCase()},body:b.output.getBytes()};return forge$1.pem.encode(x)};pki.decryptRsaPrivateKey=function(e,t){var r=null,n=forge$1.pem.decode(e)[0];if(n.type!=="ENCRYPTED PRIVATE KEY"&&n.type!=="PRIVATE KEY"&&n.type!=="RSA PRIVATE KEY"){var o=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw o.headerType=o,o}if(n.procType&&n.procType.type==="ENCRYPTED"){var a,l;switch(n.dekInfo.algorithm){case"DES-CBC":a=8,l=forge$1.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,l=forge$1.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,l=forge$1.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,l=forge$1.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,l=forge$1.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,l=function(x){return forge$1.rc2.createDecryptionCipher(x,40)};break;case"RC2-64-CBC":a=8,l=function(x){return forge$1.rc2.createDecryptionCipher(x,64)};break;case"RC2-128-CBC":a=16,l=function(x){return forge$1.rc2.createDecryptionCipher(x,128)};break;default:var o=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".');throw o.algorithm=n.dekInfo.algorithm,o}var c=forge$1.util.hexToBytes(n.dekInfo.parameters),u=forge$1.pbe.opensslDeriveBytes(t,c.substr(0,8),a),g=l(u);if(g.start(c),g.update(forge$1.util.createBuffer(n.body)),g.finish())r=g.output.getBytes();else return r}else r=n.body;return n.type==="ENCRYPTED PRIVATE KEY"?r=pki.decryptPrivateKeyInfo(asn1.fromDer(r),t):r=asn1.fromDer(r),r!==null&&(r=pki.privateKeyFromAsn1(r)),r};pki.pbe.generatePkcs12Key=function(e,t,r,n,o,a){var l,c;if(typeof a>"u"||a===null){if(!("sha1"in forge$1.md))throw new Error('"sha1" hash algorithm unavailable.');a=forge$1.md.sha1.create()}var u=a.digestLength,g=a.blockLength,b=new forge$1.util.ByteBuffer,x=new forge$1.util.ByteBuffer;if(e!=null){for(c=0;c=0;c--)_e=_e>>8,_e+=fe.at(c)+he.at(c),he.setAt(c,_e&255);we.putBuffer(he)}N=we,b.putBuffer(B)}return b.truncate(b.length()-o),b};pki.pbe.getCipher=function(e,t,r){switch(e){case pki.oids.pkcs5PBES2:return pki.pbe.getCipherForPBES2(e,t,r);case pki.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case pki.oids["pbewithSHAAnd40BitRC2-CBC"]:return pki.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}};pki.pbe.getCipherForPBES2=function(e,t,r){var n={},o=[];if(!asn1.validate(t,PBES2AlgorithmsValidator,n,o)){var a=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=o,a}if(e=asn1.derToOid(n.kdfOid),e!==pki.oids.pkcs5PBKDF2){var a=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw a.oid=e,a.supportedOids=["pkcs5PBKDF2"],a}if(e=asn1.derToOid(n.encOid),e!==pki.oids["aes128-CBC"]&&e!==pki.oids["aes192-CBC"]&&e!==pki.oids["aes256-CBC"]&&e!==pki.oids["des-EDE3-CBC"]&&e!==pki.oids.desCBC){var a=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw a.oid=e,a.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],a}var l=n.kdfSalt,c=forge$1.util.createBuffer(n.kdfIterationCount);c=c.getInt(c.length()<<3);var u,g;switch(pki.oids[e]){case"aes128-CBC":u=16,g=forge$1.aes.createDecryptionCipher;break;case"aes192-CBC":u=24,g=forge$1.aes.createDecryptionCipher;break;case"aes256-CBC":u=32,g=forge$1.aes.createDecryptionCipher;break;case"des-EDE3-CBC":u=24,g=forge$1.des.createDecryptionCipher;break;case"desCBC":u=8,g=forge$1.des.createDecryptionCipher;break}var b=prfOidToMessageDigest(n.prfOid),x=forge$1.pkcs5.pbkdf2(r,l,c,u,b),S=n.encIv,$=g(x);return $.start(S),$};pki.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},o=[];if(!asn1.validate(t,pkcs12PbeParamsValidator,n,o)){var a=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=o,a}var l=forge$1.util.createBuffer(n.salt),c=forge$1.util.createBuffer(n.iterations);c=c.getInt(c.length()<<3);var u,g,b;switch(e){case pki.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:u=24,g=8,b=forge$1.des.startDecrypting;break;case pki.oids["pbewithSHAAnd40BitRC2-CBC"]:u=5,g=8,b=function(T,D){var I=forge$1.rc2.createDecryptionCipher(T,40);return I.start(D,null),I};break;default:var a=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw a.oid=e,a}var x=prfOidToMessageDigest(n.prfOid),S=pki.pbe.generatePkcs12Key(r,l,1,c,u,x);x.start();var $=pki.pbe.generatePkcs12Key(r,l,2,c,g,x);return b(S,$)};pki.pbe.opensslDeriveBytes=function(e,t,r,n){if(typeof n>"u"||n===null){if(!("md5"in forge$1.md))throw new Error('"md5" hash algorithm unavailable.');n=forge$1.md.md5.create()}t===null&&(t="");for(var o=[hash(n,e+t)],a=16,l=1;a=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,ee=new Uint8Array(N);I!==O;){for(var ne=k[I],B=0,le=N-1;(ne!==0||B>>0,ee[le]=ne%c>>>0,ne=ne/c>>>0;if(ne!==0)throw new Error("Non-zero carry");D=B,I++}for(var fe=N-D;fe!==N&&ee[fe]===0;)fe++;for(var xe=u.repeat(T);fe>>0,N=new Uint8Array(O);k[T];){var ee=r[k.charCodeAt(T)];if(ee===255)return;for(var ne=0,B=O-1;(ee!==0||ne>>0,N[B]=ee%256>>>0,ee=ee/256>>>0;if(ee!==0)throw new Error("Non-zero carry");I=ne,T++}if(k[T]!==" "){for(var le=O-I;le!==O&&N[le]===0;)le++;for(var fe=new Uint8Array(D+(O-le)),xe=D;le!==O;)fe[xe++]=N[le++];return fe}}}function $(k){var T=S(k);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:x,decodeUnsafe:S,decode:$}}var src$3=base$4,_brrp__multiformats_scope_baseX$1=src$3;const equals$1=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},fromString$2=e=>new TextEncoder().encode(e),toString$6=e=>new TextDecoder().decode(e);class Encoder$2{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class Decoder$2{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return or$3(this,t)}}class ComposedDecoder$1{constructor(t){this.decoders=t}or(t){return or$3(this,t)}decode(t){const r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const or$3=(e,t)=>new ComposedDecoder$1({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Codec$1{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Encoder$2(t,r,n),this.decoder=new Decoder$2(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const from$3=({name:e,prefix:t,encode:r,decode:n})=>new Codec$1(e,t,r,n),baseX$2=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=_brrp__multiformats_scope_baseX$1(r,t);return from$3({prefix:e,name:t,encode:n,decode:a=>coerce$2(o(a))})},decode$9=(e,t,r,n)=>{const o={};for(let b=0;b=8&&(c-=8,l[g++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return l},encode$b=(e,t,r)=>{const n=t[t.length-1]==="=",o=(1<r;)l-=r,a+=t[o&c>>l];if(l&&(a+=t[o&c<from$3({prefix:t,name:e,encode(o){return encode$b(o,n,r)},decode(o){return decode$9(o,n,r,e)}}),base10$2=baseX$2({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$3=Object.freeze(Object.defineProperty({__proto__:null,base10:base10$2},Symbol.toStringTag,{value:"Module"})),base16$2=rfc4648$3({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper$1=rfc4648$3({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$3=Object.freeze(Object.defineProperty({__proto__:null,base16:base16$2,base16upper:base16upper$1},Symbol.toStringTag,{value:"Module"})),base2$2=rfc4648$3({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$3=Object.freeze(Object.defineProperty({__proto__:null,base2:base2$2},Symbol.toStringTag,{value:"Module"})),alphabet$2=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),alphabetBytesToChars$1=alphabet$2.reduce((e,t,r)=>(e[r]=t,e),[]),alphabetCharsToBytes$1=alphabet$2.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function encode$a(e){return e.reduce((t,r)=>(t+=alphabetBytesToChars$1[r],t),"")}function decode$8(e){const t=[];for(const r of e){const n=alphabetCharsToBytes$1[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n)}return new Uint8Array(t)}const base256emoji$2=from$3({prefix:"\u{1F680}",name:"base256emoji",encode:encode$a,decode:decode$8}),base256emoji$3=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$2},Symbol.toStringTag,{value:"Module"})),base32$2=rfc4648$3({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$1=rfc4648$3({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$1=rfc4648$3({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$1=rfc4648$3({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$1=rfc4648$3({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$1=rfc4648$3({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$1=rfc4648$3({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$1=rfc4648$3({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$1=rfc4648$3({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$3=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$2,base32upper:base32upper$1,base32pad:base32pad$1,base32padupper:base32padupper$1,base32hex:base32hex$1,base32hexupper:base32hexupper$1,base32hexpad:base32hexpad$1,base32hexpadupper:base32hexpadupper$1,base32z:base32z$1},Symbol.toStringTag,{value:"Module"})),base36$2=baseX$2({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$1=baseX$2({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$3=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$2,base36upper:base36upper$1},Symbol.toStringTag,{value:"Module"})),base58btc$1=baseX$2({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$1=baseX$2({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$1=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$1,base58flickr:base58flickr$1},Symbol.toStringTag,{value:"Module"})),base64$4=rfc4648$3({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$1=rfc4648$3({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$1=rfc4648$3({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$1=rfc4648$3({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$5=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$4,base64pad:base64pad$1,base64url:base64url$1,base64urlpad:base64urlpad$1},Symbol.toStringTag,{value:"Module"})),base8$2=rfc4648$3({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$3=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$2},Symbol.toStringTag,{value:"Module"})),identity$6=from$3({prefix:"\0",name:"identity",encode:e=>toString$6(e),decode:e=>fromString$2(e)}),identityBase$1=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$6},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;var encode_1$1=encode$9,MSB$3=128,REST$3=127,MSBALL$1=~REST$3,INT$1=Math.pow(2,31);function encode$9(e,t,r){t=t||[],r=r||0;for(var n=r;e>=INT$1;)t[r++]=e&255|MSB$3,e/=128;for(;e&MSBALL$1;)t[r++]=e&255|MSB$3,e>>>=7;return t[r]=e|0,encode$9.bytes=r-n+1,t}var decode$7=read$2,MSB$1$1=128,REST$1$1=127;function read$2(e,n){var r=0,n=n||0,o=0,a=n,l,c=e.length;do{if(a>=c)throw read$2.bytes=0,new RangeError("Could not decode varint");l=e[a++],r+=o<28?(l&REST$1$1)<=MSB$1$1);return read$2.bytes=a-n,r}var N1$1=Math.pow(2,7),N2$1=Math.pow(2,14),N3$1=Math.pow(2,21),N4$1=Math.pow(2,28),N5$1=Math.pow(2,35),N6$1=Math.pow(2,42),N7$1=Math.pow(2,49),N8$1=Math.pow(2,56),N9$1=Math.pow(2,63),length$2=function(e){return e[_brrp_varint$1.decode(e,t),_brrp_varint$1.decode.bytes],encodeTo$1=(e,t,r=0)=>(_brrp_varint$1.encode(e,t,r),t),encodingLength$1=e=>_brrp_varint$1.encodingLength(e),create$4=(e,t)=>{const r=t.byteLength,n=encodingLength$1(e),o=n+encodingLength$1(r),a=new Uint8Array(o+r);return encodeTo$1(e,a,0),encodeTo$1(r,a,n),a.set(t,o),new Digest$1(e,r,t,a)},decode$5=e=>{const t=coerce$2(e),[r,n]=decode$6(t),[o,a]=decode$6(t.subarray(n)),l=t.subarray(n+a);if(l.byteLength!==o)throw new Error("Incorrect length");return new Digest$1(r,o,l,t)},equals=(e,t)=>{if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&equals$1(e.bytes,r.bytes)}};class Digest$1{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}}const code$3=0,name$1="identity",encode$8=coerce$2,digest$1=e=>create$4(code$3,encode$8(e)),identity$4={code:code$3,name:name$1,encode:encode$8,digest:digest$1},identity$5=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$4},Symbol.toStringTag,{value:"Module"})),from$2=({name:e,code:t,encode:r})=>new Hasher$1(e,t,r);class Hasher$1{constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){const r=this.encode(t);return r instanceof Uint8Array?create$4(this.code,r):r.then(n=>create$4(this.code,n))}else throw Error("Unknown type, must be binary type")}}const sha$1=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),sha256$1=from$2({name:"sha2-256",code:18,encode:sha$1("SHA-256")}),sha512$2=from$2({name:"sha2-512",code:19,encode:sha$1("SHA-512")}),sha2$1=Object.freeze(Object.defineProperty({__proto__:null,sha256:sha256$1,sha512:sha512$2},Symbol.toStringTag,{value:"Module"})),format$3=(e,t)=>{const{bytes:r,version:n}=e;switch(n){case 0:return toStringV0(r,baseCache(e),t||base58btc$1.encoder);default:return toStringV1(r,baseCache(e),t||base32$2.encoder)}},cache$2=new WeakMap,baseCache=e=>{const t=cache$2.get(e);if(t==null){const r=new Map;return cache$2.set(e,r),r}return t};class CID{constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{const{code:t,multihash:r}=this;if(t!==DAG_PB_CODE)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==SHA_256_CODE)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return CID.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{const{code:t,digest:r}=this.multihash,n=create$4(t,r);return CID.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return CID.equals(this,t)}static equals(t,r){const n=r;return n&&t.code===n.code&&t.version===n.version&&equals(t.multihash,n.multihash)}toString(t){return format$3(this,t)}toJSON(){return{"/":format$3(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;const r=t;if(r instanceof CID)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){const{version:n,code:o,multihash:a,bytes:l}=r;return new CID(n,o,a,l||encodeCID(n,o,a.bytes))}else if(r[cidSymbol]===!0){const{version:n,multihash:o,code:a}=r,l=decode$5(o);return CID.create(n,a,l)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==DAG_PB_CODE)throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);return new CID(t,r,n,n.bytes)}case 1:{const o=encodeCID(t,r,n.bytes);return new CID(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return CID.create(0,DAG_PB_CODE,t)}static createV1(t,r){return CID.create(1,t,r)}static decode(t){const[r,n]=CID.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(t){const r=CID.inspectBytes(t),n=r.size-r.multihashSize,o=coerce$2(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");const a=o.subarray(r.multihashSize-r.digestSize),l=new Digest$1(r.multihashCode,r.digestSize,a,o);return[r.version===0?CID.createV0(l):CID.createV1(r.codec,l),t.subarray(r.size)]}static inspectBytes(t){let r=0;const n=()=>{const[x,S]=decode$6(t.subarray(r));return r+=S,x};let o=n(),a=DAG_PB_CODE;if(o===18?(o=0,r=0):a=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);const l=r,c=n(),u=n(),g=r+u,b=g-l;return{version:o,codec:a,multihashCode:c,digestSize:u,multihashSize:b,size:g}}static parse(t,r){const[n,o]=parseCIDtoBytes(t,r),a=CID.decode(o);if(a.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache(a).set(n,t),a}}const parseCIDtoBytes=(e,t)=>{switch(e[0]){case"Q":{const r=t||base58btc$1;return[base58btc$1.prefix,r.decode(`${base58btc$1.prefix}${e}`)]}case base58btc$1.prefix:{const r=t||base58btc$1;return[base58btc$1.prefix,r.decode(e)]}case base32$2.prefix:{const r=t||base32$2;return[base32$2.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},toStringV0=(e,t,r)=>{const{prefix:n}=r;if(n!==base58btc$1.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const o=t.get(n);if(o==null){const a=r.encode(e).slice(1);return t.set(n,a),a}else return o},toStringV1=(e,t,r)=>{const{prefix:n}=r,o=t.get(n);if(o==null){const a=r.encode(e);return t.set(n,a),a}else return o},DAG_PB_CODE=112,SHA_256_CODE=18,encodeCID=(e,t,r)=>{const n=encodingLength$1(e),o=n+encodingLength$1(t),a=new Uint8Array(o+r.byteLength);return encodeTo$1(e,a,0),encodeTo$1(t,a,n),a.set(r,o),a},cidSymbol=Symbol.for("@ipld/js-cid/CID"),bases={...identityBase$1,...base2$3,...base8$3,...base10$3,...base16$3,...base32$3,...base36$3,...base58$1,...base64$5,...base256emoji$3};({...sha2$1,...identity$5});function createCodec$1(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const string$1=createCodec$1("utf8","u",e=>{const t=new TextDecoder("utf8");return"u"+t.decode(e)},e=>new TextEncoder().encode(e.substring(1))),ascii=createCodec$1("ascii","a",e=>{let t="a";for(let r=0;r{e=e.substring(1);const t=allocUnsafe$2(e.length);for(let r=0;r1&&c.charAt(u)==="=";)++g;return Math.ceil(c.length*3)/4-g};for(var r=new Array(64),n=new Array(123),o=0;o<64;)n[r[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;t.encode=function(c,u,g){for(var b=null,x=[],S=0,$=0,k;u>2],k=(T&3)<<4,$=1;break;case 1:x[S++]=r[k|T>>4],k=(T&15)<<2,$=2;break;case 2:x[S++]=r[k|T>>6],x[S++]=r[T&63],$=0;break}S>8191&&((b||(b=[])).push(String.fromCharCode.apply(String,x)),S=0)}return $&&(x[S++]=r[k],x[S++]=61,$===1&&(x[S++]=61)),b?(S&&b.push(String.fromCharCode.apply(String,x.slice(0,S))),b.join("")):String.fromCharCode.apply(String,x.slice(0,S))};var a="invalid encoding";t.decode=function(c,u,g){for(var b=g,x=0,S,$=0;$1)break;if((k=n[k])===void 0)throw Error(a);switch(x){case 0:S=k,x=1;break;case 1:u[g++]=S<<2|(k&48)>>4,S=k,x=2;break;case 2:u[g++]=(S&15)<<4|(k&60)>>2,S=k,x=3;break;case 3:u[g++]=(S&3)<<6|k,x=0;break}}if(x===1)throw Error(a);return g-b},t.test=function(c){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(c)}})(base64$3);var eventemitter=EventEmitter$3;function EventEmitter$3(){this._listeners={}}EventEmitter$3.prototype.on=function(t,r,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:r,ctx:n||this}),this};EventEmitter$3.prototype.off=function(t,r){if(t===void 0)this._listeners={};else if(r===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],o=0;o0?0:2147483648,a,l);else if(isNaN(o))n(2143289344,a,l);else if(o>34028234663852886e22)n((c<<31|2139095040)>>>0,a,l);else if(o<11754943508222875e-54)n((c<<31|Math.round(o/1401298464324817e-60))>>>0,a,l);else{var u=Math.floor(Math.log(o)/Math.LN2),g=Math.round(o*Math.pow(2,-u)*8388608)&8388607;n((c<<31|u+127<<23|g)>>>0,a,l)}}e.writeFloatLE=t.bind(null,writeUintLE),e.writeFloatBE=t.bind(null,writeUintBE);function r(n,o,a){var l=n(o,a),c=(l>>31)*2+1,u=l>>>23&255,g=l&8388607;return u===255?g?NaN:c*(1/0):u===0?c*1401298464324817e-60*g:c*Math.pow(2,u-150)*(g+8388608)}e.readFloatLE=r.bind(null,readUintLE),e.readFloatBE=r.bind(null,readUintBE)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=r[7]===128;function o(u,g,b){t[0]=u,g[b]=r[0],g[b+1]=r[1],g[b+2]=r[2],g[b+3]=r[3],g[b+4]=r[4],g[b+5]=r[5],g[b+6]=r[6],g[b+7]=r[7]}function a(u,g,b){t[0]=u,g[b]=r[7],g[b+1]=r[6],g[b+2]=r[5],g[b+3]=r[4],g[b+4]=r[3],g[b+5]=r[2],g[b+6]=r[1],g[b+7]=r[0]}e.writeDoubleLE=n?o:a,e.writeDoubleBE=n?a:o;function l(u,g){return r[0]=u[g],r[1]=u[g+1],r[2]=u[g+2],r[3]=u[g+3],r[4]=u[g+4],r[5]=u[g+5],r[6]=u[g+6],r[7]=u[g+7],t[0]}function c(u,g){return r[7]=u[g],r[6]=u[g+1],r[5]=u[g+2],r[4]=u[g+3],r[3]=u[g+4],r[2]=u[g+5],r[1]=u[g+6],r[0]=u[g+7],t[0]}e.readDoubleLE=n?l:c,e.readDoubleBE=n?c:l}():function(){function t(n,o,a,l,c,u){var g=l<0?1:0;if(g&&(l=-l),l===0)n(0,c,u+o),n(1/l>0?0:2147483648,c,u+a);else if(isNaN(l))n(0,c,u+o),n(2146959360,c,u+a);else if(l>17976931348623157e292)n(0,c,u+o),n((g<<31|2146435072)>>>0,c,u+a);else{var b;if(l<22250738585072014e-324)b=l/5e-324,n(b>>>0,c,u+o),n((g<<31|b/4294967296)>>>0,c,u+a);else{var x=Math.floor(Math.log(l)/Math.LN2);x===1024&&(x=1023),b=l*Math.pow(2,-x),n(b*4503599627370496>>>0,c,u+o),n((g<<31|x+1023<<20|b*1048576&1048575)>>>0,c,u+a)}}}e.writeDoubleLE=t.bind(null,writeUintLE,0,4),e.writeDoubleBE=t.bind(null,writeUintBE,4,0);function r(n,o,a,l,c){var u=n(l,c+o),g=n(l,c+a),b=(g>>31)*2+1,x=g>>>20&2047,S=4294967296*(g&1048575)+u;return x===2047?S?NaN:b*(1/0):x===0?b*5e-324*S:b*Math.pow(2,x-1075)*(S+4503599627370496)}e.readDoubleLE=r.bind(null,readUintLE,0,4),e.readDoubleBE=r.bind(null,readUintBE,4,0)}(),e}function writeUintLE(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function writeUintBE(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=e&255}function readUintLE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function readUintBE(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}var utf8$3={};(function(e){var t=e;t.length=function(n){for(var o=0,a=0,l=0;l191&&b<224?u[g++]=(b&31)<<6|n[o++]&63:b>239&&b<365?(b=((b&7)<<18|(n[o++]&63)<<12|(n[o++]&63)<<6|n[o++]&63)-65536,u[g++]=55296+(b>>10),u[g++]=56320+(b&1023)):u[g++]=(b&15)<<12|(n[o++]&63)<<6|n[o++]&63,g>8191&&((c||(c=[])).push(String.fromCharCode.apply(String,u)),g=0);return c?(g&&c.push(String.fromCharCode.apply(String,u.slice(0,g))),c.join("")):String.fromCharCode.apply(String,u.slice(0,g))},t.write=function(n,o,a){for(var l=a,c,u,g=0;g>6|192,o[a++]=c&63|128):(c&64512)===55296&&((u=n.charCodeAt(g+1))&64512)===56320?(c=65536+((c&1023)<<10)+(u&1023),++g,o[a++]=c>>18|240,o[a++]=c>>12&63|128,o[a++]=c>>6&63|128,o[a++]=c&63|128):(o[a++]=c>>12|224,o[a++]=c>>6&63|128,o[a++]=c&63|128);return a-l}})(utf8$3);var pool_1=pool;function pool(e,t,r){var n=r||8192,o=n>>>1,a=null,l=n;return function(u){if(u<1||u>o)return e(u);l+u>n&&(a=e(n),l=0);var g=t.call(a,l,l+=u);return l&7&&(l=(l|7)+1),g}}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=t;var e=requireMinimal();function t(a,l){this.lo=a>>>0,this.hi=l>>>0}var r=t.zero=new t(0,0);r.toNumber=function(){return 0},r.zzEncode=r.zzDecode=function(){return this},r.length=function(){return 1};var n=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(l){if(l===0)return r;var c=l<0;c&&(l=-l);var u=l>>>0,g=(l-u)/4294967296>>>0;return c&&(g=~g>>>0,u=~u>>>0,++u>4294967295&&(u=0,++g>4294967295&&(g=0))),new t(u,g)},t.from=function(l){if(typeof l=="number")return t.fromNumber(l);if(e.isString(l))if(e.Long)l=e.Long.fromString(l);else return t.fromNumber(parseInt(l,10));return l.low||l.high?new t(l.low>>>0,l.high>>>0):r},t.prototype.toNumber=function(l){if(!l&&this.hi>>>31){var c=~this.lo+1>>>0,u=~this.hi>>>0;return c||(u=u+1>>>0),-(c+u*4294967296)}return this.lo+this.hi*4294967296},t.prototype.toLong=function(l){return e.Long?new e.Long(this.lo|0,this.hi|0,Boolean(l)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(l)}};var o=String.prototype.charCodeAt;return t.fromHash=function(l){return l===n?r:new t((o.call(l,0)|o.call(l,1)<<8|o.call(l,2)<<16|o.call(l,3)<<24)>>>0,(o.call(l,4)|o.call(l,5)<<8|o.call(l,6)<<16|o.call(l,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var l=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^l)>>>0,this.lo=(this.lo<<1^l)>>>0,this},t.prototype.zzDecode=function(){var l=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^l)>>>0,this.hi=(this.hi>>>1^l)>>>0,this},t.prototype.length=function(){var l=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,u=this.hi>>>24;return u===0?c===0?l<16384?l<128?1:2:l<2097152?3:4:c<16384?c<128?5:6:c<2097152?7:8:u<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(e){var t=e;t.asPromise=aspromise,t.base64=base64$3,t.EventEmitter=eventemitter,t.float=float,t.inquire=inquire_1,t.utf8=utf8$3,t.pool=pool_1,t.LongBits=requireLongbits(),t.isNode=Boolean(typeof commonjsGlobal$2<"u"&&commonjsGlobal$2&&commonjsGlobal$2.process&&commonjsGlobal$2.process.versions&&commonjsGlobal$2.process.versions.node),t.global=t.isNode&&commonjsGlobal$2||typeof window<"u"&&window||typeof self<"u"&&self||commonjsGlobal$2,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(a){return typeof a=="number"&&isFinite(a)&&Math.floor(a)===a},t.isString=function(a){return typeof a=="string"||a instanceof String},t.isObject=function(a){return a&&typeof a=="object"},t.isset=t.isSet=function(a,l){var c=a[l];return c!=null&&a.hasOwnProperty(l)?typeof c!="object"||(Array.isArray(c)?c.length:Object.keys(c).length)>0:!1},t.Buffer=function(){try{var o=t.inquire("buffer").Buffer;return o.prototype.utf8Write?o:null}catch{return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(a){return typeof a=="number"?t.Buffer?t._Buffer_allocUnsafe(a):new t.Array(a):t.Buffer?t._Buffer_from(a):typeof Uint8Array>"u"?a:new Uint8Array(a)},t.Array=typeof Uint8Array<"u"?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(a){return a?t.LongBits.from(a).toHash():t.LongBits.zeroHash},t.longFromHash=function(a,l){var c=t.LongBits.fromHash(a);return t.Long?t.Long.fromBits(c.lo,c.hi,l):c.toNumber(Boolean(l))};function r(o,a,l){for(var c=Object.keys(a),u=0;u-1;--g)if(l[u[g]]===1&&this[u[g]]!==void 0&&this[u[g]]!==null)return u[g]}},t.oneOfSetter=function(a){return function(l){for(var c=0;c "+e.len)}function Reader$1(e){this.buf=e,this.pos=0,this.len=e.length}var create_array=typeof Uint8Array<"u"?function e(t){if(t instanceof Uint8Array||Array.isArray(t))return new Reader$1(t);throw Error("illegal buffer")}:function e(t){if(Array.isArray(t))return new Reader$1(t);throw Error("illegal buffer")},create$2=function e(){return util$4.Buffer?function(r){return(Reader$1.create=function(o){return util$4.Buffer.isBuffer(o)?new BufferReader$1(o):create_array(o)})(r)}:create_array};Reader$1.create=create$2();Reader$1.prototype._slice=util$4.Array.prototype.subarray||util$4.Array.prototype.slice;Reader$1.prototype.uint32=function e(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return t}}();Reader$1.prototype.int32=function e(){return this.uint32()|0};Reader$1.prototype.sint32=function e(){var t=this.uint32();return t>>>1^-(t&1)|0};function readLongVarint(){var e=new LongBits$1(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}Reader$1.prototype.bool=function e(){return this.uint32()!==0};function readFixed32_end(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}Reader$1.prototype.fixed32=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)};Reader$1.prototype.sfixed32=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)|0};function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits$1(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader$1.prototype.float=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var t=util$4.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};Reader$1.prototype.double=function e(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var t=util$4.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};Reader$1.prototype.bytes=function e(){var t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw indexOutOfRange(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(r,n);if(r===n){var o=util$4.Buffer;return o?o.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,r,n)};Reader$1.prototype.string=function e(){var t=this.bytes();return utf8$2.read(t,0,t.length)};Reader$1.prototype.skip=function e(t){if(typeof t=="number"){if(this.pos+t>this.len)throw indexOutOfRange(this,t);this.pos+=t}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this};Reader$1.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this};Reader$1._configure=function(e){BufferReader$1=e,Reader$1.create=create$2(),BufferReader$1._configure();var t=util$4.Long?"toLong":"toNumber";util$4.merge(Reader$1.prototype,{int64:function(){return readLongVarint.call(this)[t](!1)},uint64:function(){return readLongVarint.call(this)[t](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[t](!1)},fixed64:function(){return readFixed64.call(this)[t](!0)},sfixed64:function(){return readFixed64.call(this)[t](!1)}})};var reader_buffer=BufferReader,Reader=reader$2;(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util$3=requireMinimal();function BufferReader(e){Reader.call(this,e)}BufferReader._configure=function(){util$3.Buffer&&(BufferReader.prototype._slice=util$3.Buffer.prototype.slice)};BufferReader.prototype.string=function e(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};BufferReader._configure();var minimalExports=requireMinimal(),writer$1=Writer$1,util$2=requireMinimal(),BufferWriter$1,LongBits=util$2.LongBits,base64$2=util$2.base64,utf8$1=util$2.utf8;function Op(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function noop$4(){}function State(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function Writer$1(){this.len=0,this.head=new Op(noop$4,0,0),this.tail=this.head,this.states=null}var create$1=function e(){return util$2.Buffer?function(){return(Writer$1.create=function(){return new BufferWriter$1})()}:function(){return new Writer$1}};Writer$1.create=create$1();Writer$1.alloc=function e(t){return new util$2.Array(t)};util$2.Array!==Array&&(Writer$1.alloc=util$2.pool(Writer$1.alloc,util$2.Array.prototype.subarray));Writer$1.prototype._push=function e(t,r,n){return this.tail=this.tail.next=new Op(t,r,n),this.len+=r,this};function writeByte(e,t,r){t[r]=e&255}function writeVarint32(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}function VarintOp(e,t){this.len=e,this.next=void 0,this.val=t}VarintOp.prototype=Object.create(Op.prototype);VarintOp.prototype.fn=writeVarint32;Writer$1.prototype.uint32=function e(t){return this.len+=(this.tail=this.tail.next=new VarintOp((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};Writer$1.prototype.int32=function e(t){return t<0?this._push(writeVarint64,10,LongBits.fromNumber(t)):this.uint32(t)};Writer$1.prototype.sint32=function e(t){return this.uint32((t<<1^t>>31)>>>0)};function writeVarint64(e,t,r){for(;e.hi;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}Writer$1.prototype.uint64=function e(t){var r=LongBits.from(t);return this._push(writeVarint64,r.length(),r)};Writer$1.prototype.int64=Writer$1.prototype.uint64;Writer$1.prototype.sint64=function e(t){var r=LongBits.from(t).zzEncode();return this._push(writeVarint64,r.length(),r)};Writer$1.prototype.bool=function e(t){return this._push(writeByte,1,t?1:0)};function writeFixed32(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}Writer$1.prototype.fixed32=function e(t){return this._push(writeFixed32,4,t>>>0)};Writer$1.prototype.sfixed32=Writer$1.prototype.fixed32;Writer$1.prototype.fixed64=function e(t){var r=LongBits.from(t);return this._push(writeFixed32,4,r.lo)._push(writeFixed32,4,r.hi)};Writer$1.prototype.sfixed64=Writer$1.prototype.fixed64;Writer$1.prototype.float=function e(t){return this._push(util$2.float.writeFloatLE,4,t)};Writer$1.prototype.double=function e(t){return this._push(util$2.float.writeDoubleLE,8,t)};var writeBytes=util$2.Array.prototype.set?function e(t,r,n){r.set(t,n)}:function e(t,r,n){for(var o=0;o>>0;if(!r)return this._push(writeByte,1,0);if(util$2.isString(t)){var n=Writer$1.alloc(r=base64$2.length(t));base64$2.decode(t,n,0),t=n}return this.uint32(r)._push(writeBytes,r,t)};Writer$1.prototype.string=function e(t){var r=utf8$1.length(t);return r?this.uint32(r)._push(utf8$1.write,r,t):this._push(writeByte,1,0)};Writer$1.prototype.fork=function e(){return this.states=new State(this),this.head=this.tail=new Op(noop$4,0,0),this.len=0,this};Writer$1.prototype.reset=function e(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop$4,0,0),this.len=0),this};Writer$1.prototype.ldelim=function e(){var t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=r,this.len+=n),this};Writer$1.prototype.finish=function e(){for(var t=this.head.next,r=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r};Writer$1._configure=function(e){BufferWriter$1=e,Writer$1.create=create$1(),BufferWriter$1._configure()};var writer_buffer=BufferWriter,Writer=writer$1;(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util$1=requireMinimal();function BufferWriter(){Writer.call(this)}BufferWriter._configure=function(){BufferWriter.alloc=util$1._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util$1.Buffer&&util$1.Buffer.prototype instanceof Uint8Array&&util$1.Buffer.prototype.set.name==="set"?function(t,r,n){r.set(t,n)}:function(t,r,n){if(t.copy)t.copy(r,n,0,t.length);else for(var o=0;o>>0;return this.uint32(r),r&&this._push(BufferWriter.writeBytesBuffer,r,t),this};function writeStringBuffer(e,t,r){e.length<40?util$1.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}BufferWriter.prototype.string=function e(t){var r=util$1.Buffer.byteLength(t);return this.uint32(r),r&&this._push(writeStringBuffer,r,t),this};BufferWriter._configure();function configure(){minimalExports._configure(),reader$2._configure(reader_buffer),writer$1._configure(writer_buffer)}configure();const methods=["uint64","int64","sint64","fixed64","sfixed64"];function patchReader(e){for(const t of methods){if(e[t]==null)continue;const r=e[t];e[t]=function(){return BigInt(r.call(this).toString())}}return e}function reader$1(e){return patchReader(new reader$2(e))}function patchWriter(e){for(const t of methods){if(e[t]==null)continue;const r=e[t];e[t]=function(n){return r.call(this,n.toString())}}return e}function writer(){return patchWriter(writer$1.create())}function decodeMessage(e,t){const r=reader$1(e instanceof Uint8Array?e:e.subarray());return t.decode(r)}function encodeMessage(e,t){const r=writer();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var CODEC_TYPES;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(CODEC_TYPES||(CODEC_TYPES={}));function createCodec(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function enumeration(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}const r=function(a,l){const c=t(a);l.int32(c)},n=function(a){const l=a.int32();return t(l)};return createCodec("enum",CODEC_TYPES.VARINT,r,n)}function message(e,t){return createCodec("message",CODEC_TYPES.LENGTH_DELIMITED,e,t)}var KeyType;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"})(KeyType||(KeyType={}));var __KeyTypeValues;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"})(__KeyTypeValues||(__KeyTypeValues={}));(function(e){e.codec=()=>enumeration(__KeyTypeValues)})(KeyType||(KeyType={}));var PublicKey;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),KeyType.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.Type=KeyType.codec().decode(r);break;case 2:o.Data=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(PublicKey||(PublicKey={}));var PrivateKey;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),KeyType.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.Type=KeyType.codec().decode(r);break;case 2:o.Data=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(PrivateKey||(PrivateKey={}));class Ed25519PublicKey{constructor(t){Xe(this,"_key");this._key=ensureKey(t,PUBLIC_KEY_BYTE_LENGTH)}async verify(t,r){return hashAndVerify$2(this._key,r,t)}marshal(){return this._key}get bytes(){return PublicKey.encode({Type:KeyType.Ed25519,Data:this.marshal()}).subarray()}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}}class Ed25519PrivateKey{constructor(t,r){Xe(this,"_key");Xe(this,"_publicKey");this._key=ensureKey(t,PRIVATE_KEY_BYTE_LENGTH),this._publicKey=ensureKey(r,PUBLIC_KEY_BYTE_LENGTH)}async sign(t){return hashAndSign$2(this._key,t)}get public(){return new Ed25519PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return PrivateKey.encode({Type:KeyType.Ed25519,Data:this.marshal()}).subarray()}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}async id(){const t=identity$4.digest(this.public.bytes);return base58btc$1.encode(t.bytes).substring(1)}async export(t,r="libp2p-key"){if(r==="libp2p-key")return exporter(this.bytes,t);throw new CodeError(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function unmarshalEd25519PrivateKey(e){if(e.length>PRIVATE_KEY_BYTE_LENGTH){e=ensureKey(e,PRIVATE_KEY_BYTE_LENGTH+PUBLIC_KEY_BYTE_LENGTH);const n=e.subarray(0,PRIVATE_KEY_BYTE_LENGTH),o=e.subarray(PRIVATE_KEY_BYTE_LENGTH,e.length);return new Ed25519PrivateKey(n,o)}e=ensureKey(e,PRIVATE_KEY_BYTE_LENGTH);const t=e.subarray(0,PRIVATE_KEY_BYTE_LENGTH),r=e.subarray(PUBLIC_KEY_BYTE_LENGTH);return new Ed25519PrivateKey(t,r)}function unmarshalEd25519PublicKey(e){return e=ensureKey(e,PUBLIC_KEY_BYTE_LENGTH),new Ed25519PublicKey(e)}async function generateKeyPair$3(){const{privateKey:e,publicKey:t}=await generateKey$2();return new Ed25519PrivateKey(e,t)}async function generateKeyPairFromSeed(e){const{privateKey:t,publicKey:r}=await generateKeyFromSeed(e);return new Ed25519PrivateKey(t,r)}function ensureKey(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new CodeError(`Key must be a Uint8Array of length ${t}, got ${e.length}`,"ERR_INVALID_KEY_TYPE");return e}const Ed25519=Object.freeze(Object.defineProperty({__proto__:null,Ed25519PublicKey,Ed25519PrivateKey,unmarshalEd25519PrivateKey,unmarshalEd25519PublicKey,generateKeyPair:generateKeyPair$3,generateKeyPairFromSeed},Symbol.toStringTag,{value:"Module"}));function toString$5(e,t="utf8"){const r=BASES[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}function bigIntegerToUintBase64url(e,t){let r=Uint8Array.from(e.abs().toByteArray());if(r=r[0]===0?r.subarray(1):r,t!=null){if(r.length>t)throw new Error("byte array longer than desired length");r=concat$1([new Uint8Array(t-r.length),r])}return toString$5(r,"base64url")}function base64urlToBigInteger(e){const t=base64urlToBuffer(e);return new forge$m.jsbn.BigInteger(toString$5(t,"base16"),16)}function base64urlToBuffer(e,t){let r=fromString$1(e,"base64urlpad");if(t!=null){if(r.length>t)throw new Error("byte array longer than desired length");r=concat$1([new Uint8Array(t-r.length),r])}return r}const bits={"P-256":256,"P-384":384,"P-521":521},curveTypes=Object.keys(bits);curveTypes.join(" / ");async function importer(e,t){const r=base64$4.decode(e);return create$3().decrypt(r,t)}var forge=forge$m,sha512$1=forge.sha512=forge.sha512||{};forge.md.sha512=forge.md.algorithms.sha512=sha512$1;var sha384=forge.sha384=forge.sha512.sha384=forge.sha512.sha384||{};sha384.create=function(){return sha512$1.create("SHA-384")};forge.md.sha384=forge.md.algorithms.sha384=sha384;forge.sha512.sha256=forge.sha512.sha256||{create:function(){return sha512$1.create("SHA-512/256")}};forge.md["sha512/256"]=forge.md.algorithms["sha512/256"]=forge.sha512.sha256;forge.sha512.sha224=forge.sha512.sha224||{create:function(){return sha512$1.create("SHA-512/224")}};forge.md["sha512/224"]=forge.md.algorithms["sha512/224"]=forge.sha512.sha224;sha512$1.create=function(e){if(_initialized||_init(),typeof e>"u"&&(e="SHA-512"),!(e in _states))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=_states[e],r=null,n=forge.util.createBuffer(),o=new Array(80),a=0;a<80;++a)o[a]=new Array(2);var l=64;switch(e){case"SHA-384":l=48;break;case"SHA-512/256":l=32;break;case"SHA-512/224":l=28;break}var c={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:l,messageLength:0,fullMessageLength:null,messageLengthSize:16};return c.start=function(){c.messageLength=0,c.fullMessageLength=c.messageLength128=[];for(var u=c.messageLengthSize/4,g=0;g>>0,b>>>0];for(var x=c.fullMessageLength.length-1;x>=0;--x)c.fullMessageLength[x]+=b[1],b[1]=b[0]+(c.fullMessageLength[x]/4294967296>>>0),c.fullMessageLength[x]=c.fullMessageLength[x]>>>0,b[0]=b[1]/4294967296>>>0;return n.putBytes(u),_update(r,o,n),(n.read>2048||n.length()===0)&&n.compact(),c},c.digest=function(){var u=forge.util.createBuffer();u.putBytes(n.bytes());var g=c.fullMessageLength[c.fullMessageLength.length-1]+c.messageLengthSize,b=g&c.blockLength-1;u.putBytes(_padding.substr(0,c.blockLength-b));for(var x,S,$=c.fullMessageLength[0]*8,k=0;k>>0,$+=S,u.putInt32($>>>0),$=x>>>0;u.putInt32($);for(var T=new Array(r.length),k=0;k=128;){for(ie=0;ie<16;++ie)t[ie][0]=r.getInt32()>>>0,t[ie][1]=r.getInt32()>>>0;for(;ie<80;++ie)ge=t[ie-2],pe=ge[0],ue=ge[1],n=((pe>>>19|ue<<13)^(ue>>>29|pe<<3)^pe>>>6)>>>0,o=((pe<<13|ue>>>19)^(ue<<3|pe>>>29)^(pe<<26|ue>>>6))>>>0,Ae=t[ie-15],pe=Ae[0],ue=Ae[1],a=((pe>>>1|ue<<31)^(pe>>>8|ue<<24)^pe>>>7)>>>0,l=((pe<<31|ue>>>1)^(pe<<24|ue>>>8)^(pe<<25|ue>>>7))>>>0,ye=t[ie-7],Re=t[ie-16],ue=o+ye[1]+l+Re[1],t[ie][0]=n+ye[0]+a+Re[0]+(ue/4294967296>>>0)>>>0,t[ie][1]=ue>>>0;for(T=e[0][0],D=e[0][1],I=e[1][0],O=e[1][1],N=e[2][0],ee=e[2][1],ne=e[3][0],B=e[3][1],le=e[4][0],fe=e[4][1],xe=e[5][0],we=e[5][1],he=e[6][0],_e=e[6][1],ve=e[7][0],ae=e[7][1],ie=0;ie<80;++ie)g=((le>>>14|fe<<18)^(le>>>18|fe<<14)^(fe>>>9|le<<23))>>>0,b=((le<<18|fe>>>14)^(le<<14|fe>>>18)^(fe<<23|le>>>9))>>>0,x=(he^le&(xe^he))>>>0,S=(_e^fe&(we^_e))>>>0,c=((T>>>28|D<<4)^(D>>>2|T<<30)^(D>>>7|T<<25))>>>0,u=((T<<4|D>>>28)^(D<<30|T>>>2)^(D<<25|T>>>7))>>>0,$=(T&I|N&(T^I))>>>0,k=(D&O|ee&(D^O))>>>0,ue=ae+b+S+_k[ie][1]+t[ie][1],n=ve+g+x+_k[ie][0]+t[ie][0]+(ue/4294967296>>>0)>>>0,o=ue>>>0,ue=u+k,a=c+$+(ue/4294967296>>>0)>>>0,l=ue>>>0,ve=he,ae=_e,he=xe,_e=we,xe=le,we=fe,ue=B+o,le=ne+n+(ue/4294967296>>>0)>>>0,fe=ue>>>0,ne=N,B=ee,N=I,ee=O,I=T,O=D,ue=o+l,T=n+a+(ue/4294967296>>>0)>>>0,D=ue>>>0;ue=e[0][1]+D,e[0][0]=e[0][0]+T+(ue/4294967296>>>0)>>>0,e[0][1]=ue>>>0,ue=e[1][1]+O,e[1][0]=e[1][0]+I+(ue/4294967296>>>0)>>>0,e[1][1]=ue>>>0,ue=e[2][1]+ee,e[2][0]=e[2][0]+N+(ue/4294967296>>>0)>>>0,e[2][1]=ue>>>0,ue=e[3][1]+B,e[3][0]=e[3][0]+ne+(ue/4294967296>>>0)>>>0,e[3][1]=ue>>>0,ue=e[4][1]+fe,e[4][0]=e[4][0]+le+(ue/4294967296>>>0)>>>0,e[4][1]=ue>>>0,ue=e[5][1]+we,e[5][0]=e[5][0]+xe+(ue/4294967296>>>0)>>>0,e[5][1]=ue>>>0,ue=e[6][1]+_e,e[6][0]=e[6][0]+he+(ue/4294967296>>>0)>>>0,e[6][1]=ue>>>0,ue=e[7][1]+ae,e[7][0]=e[7][0]+ve+(ue/4294967296>>>0)>>>0,e[7][1]=ue>>>0,We-=128}}function randomBytes(e){if(isNaN(e)||e<=0)throw new CodeError("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return randomBytes$1(e)}function convert$1(e,t){return t.map(r=>base64urlToBigInteger(e[r]))}function jwk2priv(e){return forge$m.pki.setRsaPrivateKey(...convert$1(e,["n","e","d","p","q","dp","dq","qi"]))}function jwk2pub(e){return forge$m.pki.setRsaPublicKey(...convert$1(e,["n","e"]))}function pkcs1ToJwk(e){const t=forge$m.asn1.fromDer(toString$5(e,"ascii")),r=forge$m.pki.privateKeyFromAsn1(t);return{kty:"RSA",n:bigIntegerToUintBase64url(r.n),e:bigIntegerToUintBase64url(r.e),d:bigIntegerToUintBase64url(r.d),p:bigIntegerToUintBase64url(r.p),q:bigIntegerToUintBase64url(r.q),dp:bigIntegerToUintBase64url(r.dP),dq:bigIntegerToUintBase64url(r.dQ),qi:bigIntegerToUintBase64url(r.qInv),alg:"RS256"}}function jwkToPkcs1(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new CodeError("JWK was missing components","ERR_INVALID_PARAMETERS");const t=forge$m.pki.privateKeyToAsn1({n:base64urlToBigInteger(e.n),e:base64urlToBigInteger(e.e),d:base64urlToBigInteger(e.d),p:base64urlToBigInteger(e.p),q:base64urlToBigInteger(e.q),dP:base64urlToBigInteger(e.dp),dQ:base64urlToBigInteger(e.dq),qInv:base64urlToBigInteger(e.qi)});return fromString$1(forge$m.asn1.toDer(t).getBytes(),"ascii")}function pkixToJwk(e){const t=forge$m.asn1.fromDer(toString$5(e,"ascii")),r=forge$m.pki.publicKeyFromAsn1(t);return{kty:"RSA",n:bigIntegerToUintBase64url(r.n),e:bigIntegerToUintBase64url(r.e)}}function jwkToPkix(e){if(e.n==null||e.e==null)throw new CodeError("JWK was missing components","ERR_INVALID_PARAMETERS");const t=forge$m.pki.publicKeyToAsn1({n:base64urlToBigInteger(e.n),e:base64urlToBigInteger(e.e)});return fromString$1(forge$m.asn1.toDer(t).getBytes(),"ascii")}async function generateKey$1(e){const t=await webcrypto.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await exportKey(t);return{privateKey:r[0],publicKey:r[1]}}async function unmarshalPrivateKey$1(e){const r=[await webcrypto.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await derivePublicFromPrivate(e)],n=await exportKey({privateKey:r[0],publicKey:r[1]});return{privateKey:n[0],publicKey:n[1]}}async function hashAndSign$1(e,t){const r=await webcrypto.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await webcrypto.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,Uint8Array.from(t));return new Uint8Array(n,0,n.byteLength)}async function hashAndVerify$1(e,t,r){const n=await webcrypto.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return webcrypto.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r)}async function exportKey(e){if(e.privateKey==null||e.publicKey==null)throw new CodeError("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([webcrypto.get().subtle.exportKey("jwk",e.privateKey),webcrypto.get().subtle.exportKey("jwk",e.publicKey)])}async function derivePublicFromPrivate(e){return webcrypto.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function convertKey(e,t,r,n){const o=t?jwk2pub(e):jwk2priv(e),a=toString$5(Uint8Array.from(r),"ascii"),l=n(a,o);return fromString$1(l,"ascii")}function encrypt(e,t){return convertKey(e,!0,t,(r,n)=>n.encrypt(r))}function decrypt(e,t){return convertKey(e,!1,t,(r,n)=>n.decrypt(r))}function keySize(e){if(e.kty!=="RSA")throw new CodeError("invalid key type","ERR_INVALID_KEY_TYPE");if(e.n==null)throw new CodeError("invalid key modulus","ERR_INVALID_KEY_MODULUS");return fromString$1(e.n,"base64url").length*8}const MAX_KEY_SIZE=8192;class RsaPublicKey{constructor(t){Xe(this,"_key");this._key=t}async verify(t,r){return hashAndVerify$1(this._key,r,t)}marshal(){return jwkToPkix(this._key)}get bytes(){return PublicKey.encode({Type:KeyType.RSA,Data:this.marshal()}).subarray()}encrypt(t){return encrypt(this._key,t)}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}}class RsaPrivateKey{constructor(t,r){Xe(this,"_key");Xe(this,"_publicKey");this._key=t,this._publicKey=r}genSecret(){return randomBytes(16)}async sign(t){return hashAndSign$1(this._key,t)}get public(){if(this._publicKey==null)throw new CodeError("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new RsaPublicKey(this._publicKey)}decrypt(t){return decrypt(this._key,t)}marshal(){return jwkToPkcs1(this._key)}get bytes(){return PrivateKey.encode({Type:KeyType.RSA,Data:this.marshal()}).subarray()}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}async id(){const t=await this.public.hash();return toString$5(t,"base58btc")}async export(t,r="pkcs-8"){if(r==="pkcs-8"){const n=new forge$m.util.ByteBuffer(this.marshal()),o=forge$m.asn1.fromDer(n),a=forge$m.pki.privateKeyFromAsn1(o),l={algorithm:"aes256",count:1e4,saltSize:128/8,prfAlgorithm:"sha512"};return forge$m.pki.encryptRsaPrivateKey(a,t,l)}else{if(r==="libp2p-key")return exporter(this.bytes,t);throw new CodeError(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}}async function unmarshalRsaPrivateKey(e){const t=pkcs1ToJwk(e);if(keySize(t)>MAX_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await unmarshalPrivateKey$1(t);return new RsaPrivateKey(r.privateKey,r.publicKey)}function unmarshalRsaPublicKey(e){const t=pkixToJwk(e);if(keySize(t)>MAX_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new RsaPublicKey(t)}async function fromJwk(e){if(keySize(e)>MAX_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await unmarshalPrivateKey$1(e);return new RsaPrivateKey(t.privateKey,t.publicKey)}async function generateKeyPair$2(e){if(e>MAX_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await generateKey$1(e);return new RsaPrivateKey(t.privateKey,t.publicKey)}const RSA=Object.freeze(Object.defineProperty({__proto__:null,MAX_KEY_SIZE,RsaPublicKey,RsaPrivateKey,unmarshalRsaPrivateKey,unmarshalRsaPublicKey,fromJwk,generateKeyPair:generateKeyPair$2},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts(e){const t=validateBasic(e);validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:b2n,hexToBytes:h2b}=ut,DER={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=DER;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const r=e[1],n=e.subarray(2,r+2);if(!r||n.length!==r)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:b2n(n),l:e.subarray(r+2)}},toSig(e){const{Err:t}=DER,r=typeof e=="string"?h2b(e):e;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new t("Invalid signature tag");if(r[1]!==n-2)throw new t("Invalid signature: incorrect length");const{d:o,l:a}=DER._parseInt(r.subarray(2)),{d:l,l:c}=DER._parseInt(a);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:l}},hexFromSig(e){const t=g=>Number.parseInt(g[0],16)&8?"00"+g:g,r=g=>{const b=g.toString(16);return b.length&1?`0${b}`:b},n=t(r(e.s)),o=t(r(e.r)),a=n.length/2,l=o.length/2,c=r(a),u=r(l);return`30${r(l+a+4)}02${u}${o}02${c}${n}`}},_0n=BigInt(0),_1n$1=BigInt(1);BigInt(2);const _3n=BigInt(3);BigInt(4);function weierstrassPoints(e){const t=validatePointOpts(e),{Fp:r}=t,n=t.toBytes||((k,T,D)=>{const I=T.toAffine();return concatBytes(Uint8Array.from([4]),r.toBytes(I.x),r.toBytes(I.y))}),o=t.fromBytes||(k=>{const T=k.subarray(1),D=r.fromBytes(T.subarray(0,r.BYTES)),I=r.fromBytes(T.subarray(r.BYTES,2*r.BYTES));return{x:D,y:I}});function a(k){const{a:T,b:D}=t,I=r.sqr(k),O=r.mul(I,k);return r.add(r.add(O,r.mul(k,T)),D)}if(!r.eql(r.sqr(t.Gy),a(t.Gx)))throw new Error("bad generator point: equation left != right");function l(k){return typeof k=="bigint"&&_0nr.eql(N,r.ZERO);return O(D)&&O(I)?x.ZERO:new x(D,I,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(T){const D=r.invertBatch(T.map(I=>I.pz));return T.map((I,O)=>I.toAffine(D[O])).map(x.fromAffine)}static fromHex(T){const D=x.fromAffine(o(ensureBytes("pointHex",T)));return D.assertValidity(),D}static fromPrivateKey(T){return x.BASE.multiply(u(T))}_setWindowSize(T){this._WINDOW_SIZE=T,g.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:T,y:D}=this.toAffine();if(!r.isValid(T)||!r.isValid(D))throw new Error("bad point: x or y not FE");const I=r.sqr(D),O=a(T);if(!r.eql(I,O))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:T}=this.toAffine();if(r.isOdd)return!r.isOdd(T);throw new Error("Field doesn't support isOdd")}equals(T){b(T);const{px:D,py:I,pz:O}=this,{px:N,py:ee,pz:ne}=T,B=r.eql(r.mul(D,ne),r.mul(N,O)),le=r.eql(r.mul(I,ne),r.mul(ee,O));return B&&le}negate(){return new x(this.px,r.neg(this.py),this.pz)}double(){const{a:T,b:D}=t,I=r.mul(D,_3n),{px:O,py:N,pz:ee}=this;let ne=r.ZERO,B=r.ZERO,le=r.ZERO,fe=r.mul(O,O),xe=r.mul(N,N),we=r.mul(ee,ee),he=r.mul(O,N);return he=r.add(he,he),le=r.mul(O,ee),le=r.add(le,le),ne=r.mul(T,le),B=r.mul(I,we),B=r.add(ne,B),ne=r.sub(xe,B),B=r.add(xe,B),B=r.mul(ne,B),ne=r.mul(he,ne),le=r.mul(I,le),we=r.mul(T,we),he=r.sub(fe,we),he=r.mul(T,he),he=r.add(he,le),le=r.add(fe,fe),fe=r.add(le,fe),fe=r.add(fe,we),fe=r.mul(fe,he),B=r.add(B,fe),we=r.mul(N,ee),we=r.add(we,we),fe=r.mul(we,he),ne=r.sub(ne,fe),le=r.mul(we,xe),le=r.add(le,le),le=r.add(le,le),new x(ne,B,le)}add(T){b(T);const{px:D,py:I,pz:O}=this,{px:N,py:ee,pz:ne}=T;let B=r.ZERO,le=r.ZERO,fe=r.ZERO;const xe=t.a,we=r.mul(t.b,_3n);let he=r.mul(D,N),_e=r.mul(I,ee),ve=r.mul(O,ne),ae=r.add(D,I),ie=r.add(N,ee);ae=r.mul(ae,ie),ie=r.add(he,_e),ae=r.sub(ae,ie),ie=r.add(D,O);let pe=r.add(N,ne);return ie=r.mul(ie,pe),pe=r.add(he,ve),ie=r.sub(ie,pe),pe=r.add(I,O),B=r.add(ee,ne),pe=r.mul(pe,B),B=r.add(_e,ve),pe=r.sub(pe,B),fe=r.mul(xe,ie),B=r.mul(we,ve),fe=r.add(B,fe),B=r.sub(_e,fe),fe=r.add(_e,fe),le=r.mul(B,fe),_e=r.add(he,he),_e=r.add(_e,he),ve=r.mul(xe,ve),ie=r.mul(we,ie),_e=r.add(_e,ve),ve=r.sub(he,ve),ve=r.mul(xe,ve),ie=r.add(ie,ve),he=r.mul(_e,ie),le=r.add(le,he),he=r.mul(pe,ie),B=r.mul(ae,B),B=r.sub(B,he),he=r.mul(ae,_e),fe=r.mul(pe,fe),fe=r.add(fe,he),new x(B,le,fe)}subtract(T){return this.add(T.negate())}is0(){return this.equals(x.ZERO)}wNAF(T){return $.wNAFCached(this,g,T,D=>{const I=r.invertBatch(D.map(O=>O.pz));return D.map((O,N)=>O.toAffine(I[N])).map(x.fromAffine)})}multiplyUnsafe(T){const D=x.ZERO;if(T===_0n)return D;if(c(T),T===_1n$1)return this;const{endo:I}=t;if(!I)return $.unsafeLadder(this,T);let{k1neg:O,k1:N,k2neg:ee,k2:ne}=I.splitScalar(T),B=D,le=D,fe=this;for(;N>_0n||ne>_0n;)N&_1n$1&&(B=B.add(fe)),ne&_1n$1&&(le=le.add(fe)),fe=fe.double(),N>>=_1n$1,ne>>=_1n$1;return O&&(B=B.negate()),ee&&(le=le.negate()),le=new x(r.mul(le.px,I.beta),le.py,le.pz),B.add(le)}multiply(T){c(T);let D=T,I,O;const{endo:N}=t;if(N){const{k1neg:ee,k1:ne,k2neg:B,k2:le}=N.splitScalar(D);let{p:fe,f:xe}=this.wNAF(ne),{p:we,f:he}=this.wNAF(le);fe=$.constTimeNegate(ee,fe),we=$.constTimeNegate(B,we),we=new x(r.mul(we.px,N.beta),we.py,we.pz),I=fe.add(we),O=xe.add(he)}else{const{p:ee,f:ne}=this.wNAF(D);I=ee,O=ne}return x.normalizeZ([I,O])[0]}multiplyAndAddUnsafe(T,D,I){const O=x.BASE,N=(ne,B)=>B===_0n||B===_1n$1||!ne.equals(O)?ne.multiplyUnsafe(B):ne.multiply(B),ee=N(this,D).add(N(T,I));return ee.is0()?void 0:ee}toAffine(T){const{px:D,py:I,pz:O}=this,N=this.is0();T==null&&(T=N?r.ONE:r.inv(O));const ee=r.mul(D,T),ne=r.mul(I,T),B=r.mul(O,T);if(N)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x:ee,y:ne}}isTorsionFree(){const{h:T,isTorsionFree:D}=t;if(T===_1n$1)return!0;if(D)return D(x,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:T,clearCofactor:D}=t;return T===_1n$1?this:D?D(x,this):this.multiplyUnsafe(t.h)}toRawBytes(T=!0){return this.assertValidity(),n(x,this,T)}toHex(T=!0){return bytesToHex(this.toRawBytes(T))}}x.BASE=new x(t.Gx,t.Gy,r.ONE),x.ZERO=new x(r.ZERO,r.ONE,r.ZERO);const S=t.nBitLength,$=wNAF(x,t.endo?Math.ceil(S/2):S);return{CURVE:t,ProjectivePoint:x,normPrivateKeyToScalar:u,weierstrassEquation:a,isWithinCurveOrder:l}}function validateOpts(e){const t=validateBasic(e);return validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function weierstrass(e){const t=validateOpts(e),{Fp:r,n}=t,o=r.BYTES+1,a=2*r.BYTES+1;function l(ie){return _0nbytesToHex(numberToBytesBE(ie,t.nByteLength));function k(ie){const pe=n>>_1n$1;return ie>pe}function T(ie){return k(ie)?c(-ie):ie}const D=(ie,pe,ue)=>bytesToNumberBE(ie.slice(pe,ue));class I{constructor(pe,ue,ge){this.r=pe,this.s=ue,this.recovery=ge,this.assertValidity()}static fromCompact(pe){const ue=t.nByteLength;return pe=ensureBytes("compactSignature",pe,ue*2),new I(D(pe,0,ue),D(pe,ue,2*ue))}static fromDER(pe){const{r:ue,s:ge}=DER.toSig(ensureBytes("DER",pe));return new I(ue,ge)}assertValidity(){if(!S(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!S(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(pe){return new I(this.r,this.s,pe)}recoverPublicKey(pe){const{r:ue,s:ge,recovery:ye}=this,Ae=le(ensureBytes("msgHash",pe));if(ye==null||![0,1,2,3].includes(ye))throw new Error("recovery id invalid");const Re=ye===2||ye===3?ue+t.n:ue;if(Re>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const We=(ye&1)===0?"02":"03",Pe=g.fromHex(We+$(Re)),Ue=u(Re),Oe=c(-Ae*Ue),Be=c(ge*Ue),Ye=g.BASE.multiplyAndAddUnsafe(Pe,Oe,Be);if(!Ye)throw new Error("point at infinify");return Ye.assertValidity(),Ye}hasHighS(){return k(this.s)}normalizeS(){return this.hasHighS()?new I(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes(this.toCompactHex())}toCompactHex(){return $(this.r)+$(this.s)}}const O={isValidPrivateKey(ie){try{return b(ie),!0}catch{return!1}},normPrivateKeyToScalar:b,randomPrivateKey:()=>{const ie=getMinHashLength(t.n);return mapHashToField(t.randomBytes(ie),t.n)},precompute(ie=8,pe=g.BASE){return pe._setWindowSize(ie),pe.multiply(BigInt(3)),pe}};function N(ie,pe=!0){return g.fromPrivateKey(ie).toRawBytes(pe)}function ee(ie){const pe=ie instanceof Uint8Array,ue=typeof ie=="string",ge=(pe||ue)&&ie.length;return pe?ge===o||ge===a:ue?ge===2*o||ge===2*a:ie instanceof g}function ne(ie,pe,ue=!0){if(ee(ie))throw new Error("first arg must be private key");if(!ee(pe))throw new Error("second arg must be public key");return g.fromHex(pe).multiply(b(ie)).toRawBytes(ue)}const B=t.bits2int||function(ie){const pe=bytesToNumberBE(ie),ue=ie.length*8-t.nBitLength;return ue>0?pe>>BigInt(ue):pe},le=t.bits2int_modN||function(ie){return c(B(ie))},fe=bitMask(t.nBitLength);function xe(ie){if(typeof ie!="bigint")throw new Error("bigint expected");if(!(_0n<=ie&&ieTe in ue))throw new Error("sign() legacy options not supported");const{hash:ge,randomBytes:ye}=t;let{lowS:Ae,prehash:Re,extraEntropy:We}=ue;Ae==null&&(Ae=!0),ie=ensureBytes("msgHash",ie),Re&&(ie=ensureBytes("prehashed msgHash",ge(ie)));const Pe=le(ie),Ue=b(pe),Oe=[xe(Ue),xe(Pe)];if(We!=null){const Te=We===!0?ye(r.BYTES):We;Oe.push(ensureBytes("extraEntropy",Te))}const Be=concatBytes(...Oe),Ye=Pe;function Se(Te){const $e=B(Te);if(!S($e))return;const Ve=u($e),oe=g.BASE.multiply($e).toAffine(),te=c(oe.x);if(te===_0n)return;const se=c(Ve*c(Ye+te*Ue));if(se===_0n)return;let me=(oe.x===te?0:2)|Number(oe.y&_1n$1),Ee=se;return Ae&&k(se)&&(Ee=T(se),me^=1),new I(te,Ee,me)}return{seed:Be,k2sig:Se}}const he={lowS:t.lowS,prehash:!1},_e={lowS:t.lowS,prehash:!1};function ve(ie,pe,ue=he){const{seed:ge,k2sig:ye}=we(ie,pe,ue),Ae=t;return createHmacDrbg(Ae.hash.outputLen,Ae.nByteLength,Ae.hmac)(ge,ye)}g.BASE._setWindowSize(8);function ae(ie,pe,ue,ge=_e){const ye=ie;if(pe=ensureBytes("msgHash",pe),ue=ensureBytes("publicKey",ue),"strict"in ge)throw new Error("options.strict was renamed to lowS");const{lowS:Ae,prehash:Re}=ge;let We,Pe;try{if(typeof ye=="string"||ye instanceof Uint8Array)try{We=I.fromDER(ye)}catch(oe){if(!(oe instanceof DER.Err))throw oe;We=I.fromCompact(ye)}else if(typeof ye=="object"&&typeof ye.r=="bigint"&&typeof ye.s=="bigint"){const{r:oe,s:te}=ye;We=new I(oe,te)}else throw new Error("PARSE");Pe=g.fromHex(ue)}catch(oe){if(oe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Ae&&We.hasHighS())return!1;Re&&(pe=t.hash(pe));const{r:Ue,s:Oe}=We,Be=le(pe),Ye=u(Oe),Se=c(Be*Ye),Te=c(Ue*Ye),$e=g.BASE.multiplyAndAddUnsafe(Pe,Se,Te)?.toAffine();return $e?c($e.x)===Ue:!1}return{CURVE:t,getPublicKey:N,getSharedSecret:ne,sign:ve,verify:ae,ProjectivePoint:g,Signature:I,utils:O}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash(e){return{hash:e,hmac:(t,...r)=>hmac$1(e,t,concatBytes$1(...r)),randomBytes:randomBytes$1}}function createCurve(e,t){const r=n=>weierstrass({...e,...getHash(n)});return Object.freeze({...r(t),create:r})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n=BigInt(1),_2n=BigInt(2),divNearest=(e,t)=>(e+t/_2n)/t;function sqrtMod(e){const t=secp256k1P,r=BigInt(3),n=BigInt(6),o=BigInt(11),a=BigInt(22),l=BigInt(23),c=BigInt(44),u=BigInt(88),g=e*e*e%t,b=g*g*e%t,x=pow2(b,r,t)*b%t,S=pow2(x,r,t)*b%t,$=pow2(S,_2n,t)*g%t,k=pow2($,o,t)*$%t,T=pow2(k,a,t)*k%t,D=pow2(T,c,t)*T%t,I=pow2(D,u,t)*D%t,O=pow2(I,c,t)*T%t,N=pow2(O,r,t)*b%t,ee=pow2(N,l,t)*k%t,ne=pow2(ee,n,t)*g%t,B=pow2(ne,_2n,t);if(!Fp.eql(Fp.sqr(B),e))throw new Error("Cannot find square root");return B}const Fp=Field(secp256k1P,void 0,void 0,{sqrt:sqrtMod}),secp256k1=createCurve({a:BigInt(0),b:BigInt(7),Fp,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=secp256k1N,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-_1n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),a=r,l=BigInt("0x100000000000000000000000000000000"),c=divNearest(a*e,t),u=divNearest(-n*e,t);let g=mod(e-c*r-u*o,t),b=mod(-c*n-u*a,t);const x=g>l,S=b>l;if(x&&(g=t-g),S&&(b=t-b),g>l||b>l)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:x,k1:g,k2neg:S,k2:b}}}},sha256$3);BigInt(0);secp256k1.ProjectivePoint;function generateKey(){return secp256k1.utils.randomPrivateKey()}async function hashAndSign(e,t){const{digest:r}=await sha256$1.digest(t);try{return secp256k1.sign(r,e).toDERRawBytes()}catch(n){throw new CodeError(String(n),"ERR_INVALID_INPUT")}}async function hashAndVerify(e,t,r){try{const{digest:n}=await sha256$1.digest(r);return secp256k1.verify(t,n,e)}catch(n){throw new CodeError(String(n),"ERR_INVALID_INPUT")}}function compressPublicKey(e){return secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!0)}function validatePrivateKey(e){try{secp256k1.getPublicKey(e,!0)}catch(t){throw new CodeError(String(t),"ERR_INVALID_PRIVATE_KEY")}}function validatePublicKey(e){try{secp256k1.ProjectivePoint.fromHex(e)}catch(t){throw new CodeError(String(t),"ERR_INVALID_PUBLIC_KEY")}}function computePublicKey(e){try{return secp256k1.getPublicKey(e,!0)}catch(t){throw new CodeError(String(t),"ERR_INVALID_PRIVATE_KEY")}}class Secp256k1PublicKey{constructor(t){Xe(this,"_key");validatePublicKey(t),this._key=t}async verify(t,r){return hashAndVerify(this._key,r,t)}marshal(){return compressPublicKey(this._key)}get bytes(){return PublicKey.encode({Type:KeyType.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}}class Secp256k1PrivateKey{constructor(t,r){Xe(this,"_key");Xe(this,"_publicKey");this._key=t,this._publicKey=r??computePublicKey(t),validatePrivateKey(this._key),validatePublicKey(this._publicKey)}async sign(t){return hashAndSign(this._key,t)}get public(){return new Secp256k1PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return PrivateKey.encode({Type:KeyType.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}async id(){const t=await this.public.hash();return toString$5(t,"base58btc")}async export(t,r="libp2p-key"){if(r==="libp2p-key")return exporter(this.bytes,t);throw new CodeError(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function unmarshalSecp256k1PrivateKey(e){return new Secp256k1PrivateKey(e)}function unmarshalSecp256k1PublicKey(e){return new Secp256k1PublicKey(e)}async function generateKeyPair$1(){const e=generateKey();return new Secp256k1PrivateKey(e)}const Secp256k1=Object.freeze(Object.defineProperty({__proto__:null,Secp256k1PublicKey,Secp256k1PrivateKey,unmarshalSecp256k1PrivateKey,unmarshalSecp256k1PublicKey,generateKeyPair:generateKeyPair$1},Symbol.toStringTag,{value:"Module"})),supportedKeys={rsa:RSA,ed25519:Ed25519,secp256k1:Secp256k1};function unsupportedKey(e){const t=Object.keys(supportedKeys).join(" / ");return new CodeError(`invalid or unsupported key type ${e}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function typeToKey(e){if(e=e.toLowerCase(),e==="rsa"||e==="ed25519"||e==="secp256k1")return supportedKeys[e];throw unsupportedKey(e)}async function generateKeyPair(e,t){return typeToKey(e).generateKeyPair(t??2048)}function unmarshalPublicKey(e){const t=PublicKey.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case KeyType.RSA:return supportedKeys.rsa.unmarshalRsaPublicKey(r);case KeyType.Ed25519:return supportedKeys.ed25519.unmarshalEd25519PublicKey(r);case KeyType.Secp256k1:return supportedKeys.secp256k1.unmarshalSecp256k1PublicKey(r);default:throw unsupportedKey(t.Type??"unknown")}}function marshalPublicKey(e,t){return t=(t??"rsa").toLowerCase(),typeToKey(t),e.bytes}async function unmarshalPrivateKey(e){const t=PrivateKey.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case KeyType.RSA:return supportedKeys.rsa.unmarshalRsaPrivateKey(r);case KeyType.Ed25519:return supportedKeys.ed25519.unmarshalEd25519PrivateKey(r);case KeyType.Secp256k1:return supportedKeys.secp256k1.unmarshalSecp256k1PrivateKey(r);default:throw unsupportedKey(t.Type??"RSA")}}function marshalPrivateKey(e,t){return t=(t??"rsa").toLowerCase(),typeToKey(t),e.bytes}async function importKey(e,t){try{const o=await importer(e,t);return await unmarshalPrivateKey(o)}catch{}const r=forge$m.pki.decryptRsaPrivateKey(e,t);if(r===null)throw new CodeError("Cannot read the key, most likely the password is wrong or not a RSA key","ERR_CANNOT_DECRYPT_PEM");let n=forge$m.asn1.toDer(forge$m.pki.privateKeyToAsn1(r));return n=fromString$1(n.getBytes(),"ascii"),supportedKeys.rsa.unmarshalRsaPrivateKey(n)}const symbol$3=Symbol.for("@libp2p/peer-id");function isPeerId(e){return e!=null&&Boolean(e[symbol$3])}const inspect$1=Symbol.for("nodejs.util.inspect.custom"),baseDecoder=Object.values(bases).map(e=>e.decoder).reduce((e,t)=>e.or(t),bases.identity.decoder),LIBP2P_KEY_CODE=114,MARSHALLED_ED225519_PUBLIC_KEY_LENGTH=36,MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH=37;var Xl;class PeerIdImpl{constructor(t){Xe(this,"type");Xe(this,"multihash");Xe(this,"privateKey");Xe(this,"publicKey");Xe(this,"string");Xe(this,Xl,!0);this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}toString(){return this.string==null&&(this.string=base58btc$1.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return CID.createV1(LIBP2P_KEY_CODE,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return equals$2(this.multihash.bytes,t);if(typeof t=="string")return peerIdFromString(t).equals(this);if(t?.multihash?.bytes!=null)return equals$2(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[(Xl=symbol$3,inspect$1)](){return`PeerId(${this.toString()})`}}class RSAPeerIdImpl extends PeerIdImpl{constructor(r){super({...r,type:"RSA"});Xe(this,"type","RSA");Xe(this,"publicKey");this.publicKey=r.publicKey}}class Ed25519PeerIdImpl extends PeerIdImpl{constructor(r){super({...r,type:"Ed25519"});Xe(this,"type","Ed25519");Xe(this,"publicKey");this.publicKey=r.multihash.digest}}class Secp256k1PeerIdImpl extends PeerIdImpl{constructor(r){super({...r,type:"secp256k1"});Xe(this,"type","secp256k1");Xe(this,"publicKey");this.publicKey=r.multihash.digest}}function peerIdFromPeerId(e){if(e.type==="RSA")return new RSAPeerIdImpl(e);if(e.type==="Ed25519")return new Ed25519PeerIdImpl(e);if(e.type==="secp256k1")return new Secp256k1PeerIdImpl(e);throw new CodeError("Not a PeerId","ERR_INVALID_PARAMETERS")}function peerIdFromString(e,t){if(e.charAt(0)==="1"||e.charAt(0)==="Q"){const r=decode$5(base58btc$1.decode(`z${e}`));return e.startsWith("12D")?new Ed25519PeerIdImpl({multihash:r}):e.startsWith("16U")?new Secp256k1PeerIdImpl({multihash:r}):new RSAPeerIdImpl({multihash:r})}return peerIdFromBytes(baseDecoder.decode(e))}function peerIdFromBytes(e){try{const t=decode$5(e);if(t.code===identity$4.code){if(t.digest.length===MARSHALLED_ED225519_PUBLIC_KEY_LENGTH)return new Ed25519PeerIdImpl({multihash:t});if(t.digest.length===MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH)return new Secp256k1PeerIdImpl({multihash:t})}if(t.code===sha256$1.code)return new RSAPeerIdImpl({multihash:t})}catch{return peerIdFromCID(CID.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function peerIdFromCID(e){if(e==null||e.multihash==null||e.version==null||e.version===1&&e.code!==LIBP2P_KEY_CODE)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===sha256$1.code)return new RSAPeerIdImpl({multihash:e.multihash});if(t.code===identity$4.code){if(t.digest.length===MARSHALLED_ED225519_PUBLIC_KEY_LENGTH)return new Ed25519PeerIdImpl({multihash:e.multihash});if(t.digest.length===MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH)return new Secp256k1PeerIdImpl({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function peerIdFromKeys(e,t){return e.length===MARSHALLED_ED225519_PUBLIC_KEY_LENGTH?new Ed25519PeerIdImpl({multihash:create$4(identity$4.code,e),privateKey:t}):e.length===MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH?new Secp256k1PeerIdImpl({multihash:create$4(identity$4.code,e),privateKey:t}):new RSAPeerIdImpl({multihash:await sha256$1.digest(e),publicKey:e,privateKey:t})}var NoiseExtensions;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.webtransportCerthashes!=null)for(const a of r.webtransportCerthashes)n.uint32(10),n.bytes(a);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={webtransportCerthashes:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.webtransportCerthashes.push(r.bytes());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(NoiseExtensions||(NoiseExtensions={}));var NoiseHandshakePayload;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),(o.writeDefaults===!0||r.identityKey!=null&&r.identityKey.byteLength>0)&&(n.uint32(10),n.bytes(r.identityKey??new Uint8Array(0))),(o.writeDefaults===!0||r.identitySig!=null&&r.identitySig.byteLength>0)&&(n.uint32(18),n.bytes(r.identitySig??new Uint8Array(0))),r.extensions!=null&&(n.uint32(34),NoiseExtensions.codec().encode(r.extensions,n,{writeDefaults:!1})),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={identityKey:new Uint8Array(0),identitySig:new Uint8Array(0)},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.identityKey=r.bytes();break;case 2:o.identitySig=r.bytes();break;case 4:o.extensions=NoiseExtensions.codec().decode(r,r.uint32());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(NoiseHandshakePayload||(NoiseHandshakePayload={}));async function getPayload(e,t,r){const n=await signPayload(e,getHandshakePayload(t));if(e.publicKey==null)throw new Error("PublicKey was missing from local PeerId");return createHandshakePayload(e.publicKey,n,r)}function createHandshakePayload(e,t,r){return NoiseHandshakePayload.encode({identityKey:e,identitySig:t,extensions:r??{webtransportCerthashes:[]}}).subarray()}async function signPayload(e,t){if(e.privateKey==null)throw new Error("PrivateKey was missing from PeerId");return(await unmarshalPrivateKey(e.privateKey)).sign(t)}async function getPeerIdFromPayload(e){return peerIdFromKeys(e.identityKey)}function decodePayload(e){return NoiseHandshakePayload.decode(e)}function getHandshakePayload(e){const t=fromString$1("noise-libp2p-static-key:");return concat$1([t,e],t.length+e.length)}async function verifySignedPayload(e,t,r){const n=await peerIdFromKeys(t.identityKey);if(!n.equals(r))throw new Error(`Payload identity key ${n.toString()} does not match expected remote peer ${r.toString()}`);const o=getHandshakePayload(e);if(n.publicKey==null)throw new Error("PublicKey was missing from PeerId");if(t.identitySig==null)throw new Error("Signature was missing from message");if(!await unmarshalPublicKey(n.publicKey).verify(o,t.identitySig))throw new Error("Static key doesn't match to peer that signed payload!");return n}function isValidPublicKey(e){return!(!(e instanceof Uint8Array)||e.length!==32)}var browser$7={exports:{}},ms$4,hasRequiredMs;function requireMs(){if(hasRequiredMs)return ms$4;hasRequiredMs=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,a=n*365.25;ms$4=function(b,x){x=x||{};var S=typeof b;if(S==="string"&&b.length>0)return l(b);if(S==="number"&&isFinite(b))return x.long?u(b):c(b);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(b))};function l(b){if(b=String(b),!(b.length>100)){var x=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(b);if(!!x){var S=parseFloat(x[1]),$=(x[2]||"ms").toLowerCase();switch($){case"years":case"year":case"yrs":case"yr":case"y":return S*a;case"weeks":case"week":case"w":return S*o;case"days":case"day":case"d":return S*n;case"hours":case"hour":case"hrs":case"hr":case"h":return S*r;case"minutes":case"minute":case"mins":case"min":case"m":return S*t;case"seconds":case"second":case"secs":case"sec":case"s":return S*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}function c(b){var x=Math.abs(b);return x>=n?Math.round(b/n)+"d":x>=r?Math.round(b/r)+"h":x>=t?Math.round(b/t)+"m":x>=e?Math.round(b/e)+"s":b+"ms"}function u(b){var x=Math.abs(b);return x>=n?g(b,x,n,"day"):x>=r?g(b,x,r,"hour"):x>=t?g(b,x,t,"minute"):x>=e?g(b,x,e,"second"):b+" ms"}function g(b,x,S,$){var k=x>=S*1.5;return Math.round(b/S)+" "+$+(k?"s":"")}return ms$4}function setup(e){r.debug=r,r.default=r,r.coerce=u,r.disable=a,r.enable=o,r.enabled=l,r.humanize=requireMs(),r.destroy=g,Object.keys(e).forEach(b=>{r[b]=e[b]}),r.names=[],r.skips=[],r.formatters={};function t(b){let x=0;for(let S=0;S{if(B==="%%")return"%";ee++;const fe=r.formatters[le];if(typeof fe=="function"){const xe=D[ee];B=fe.call(I,xe),D.splice(ee,1),ee--}return B}),r.formatArgs.call(I,D),(I.log||r.log).apply(I,D)}return T.namespace=b,T.useColors=r.useColors(),T.color=r.selectColor(b),T.extend=n,T.destroy=r.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>S!==null?S:($!==r.namespaces&&($=r.namespaces,k=r.enabled(b)),k),set:D=>{S=D}}),typeof r.init=="function"&&r.init(T),T}function n(b,x){const S=r(this.namespace+(typeof x>"u"?":":x)+b);return S.log=this.log,S}function o(b){r.save(b),r.namespaces=b,r.names=[],r.skips=[];let x;const S=(typeof b=="string"?b:"").split(/[\s,]+/),$=S.length;for(x=0;x<$;x++)!S[x]||(b=S[x].replace(/\*/g,".*?"),b[0]==="-"?r.skips.push(new RegExp("^"+b.slice(1)+"$")):r.names.push(new RegExp("^"+b+"$")))}function a(){const b=[...r.names.map(c),...r.skips.map(c).map(x=>"-"+x)].join(",");return r.enable(""),b}function l(b){if(b[b.length-1]==="*")return!0;let x,S;for(x=0,S=r.skips.length;x{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;u.splice(1,0,g,"color: inherit");let b=0,x=0;u[0].replace(/%[a-zA-Z%]/g,S=>{S!=="%%"&&(b++,S==="%c"&&(x=b))}),u.splice(x,0,g)}t.log=console.debug||console.log||(()=>{});function o(u){try{u?t.storage.setItem("debug",u):t.storage.removeItem("debug")}catch{}}function a(){let u;try{u=t.storage.getItem("debug")}catch{}return!u&&typeof process<"u"&&"env"in process&&(u={}.DEBUG),u}function l(){try{return localStorage}catch{}}e.exports=common(t);const{formatters:c}=e.exports;c.j=function(u){try{return JSON.stringify(u)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}})(browser$7,browser$7.exports);const debug$9=browser$7.exports;debug$9.formatters.b=e=>e==null?"undefined":base58btc$1.baseEncode(e);debug$9.formatters.t=e=>e==null?"undefined":base32$2.baseEncode(e);debug$9.formatters.m=e=>e==null?"undefined":base64$4.baseEncode(e);debug$9.formatters.p=e=>e==null?"undefined":e.toString();debug$9.formatters.c=e=>e==null?"undefined":e.toString();debug$9.formatters.k=e=>e==null?"undefined":e.toString();debug$9.formatters.a=e=>e==null?"undefined":e.toString();function createDisabledLogger(e){const t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function logger(e){let t=createDisabledLogger(`${e}:trace`);return debug$9.enabled(`${e}:trace`)&&debug$9.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=debug$9(`${e}:trace`)),Object.assign(debug$9(e),{error:debug$9(`${e}:error`),trace:t})}const log$B=logger("libp2p:noise");let keyLogger;DUMP_SESSION_KEYS?keyLogger=log$B:keyLogger=Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});function logLocalStaticKeys(e){keyLogger(`LOCAL_STATIC_PUBLIC_KEY ${toString$5(e.publicKey,"hex")}`),keyLogger(`LOCAL_STATIC_PRIVATE_KEY ${toString$5(e.privateKey,"hex")}`)}function logLocalEphemeralKeys(e){e?(keyLogger(`LOCAL_PUBLIC_EPHEMERAL_KEY ${toString$5(e.publicKey,"hex")}`),keyLogger(`LOCAL_PRIVATE_EPHEMERAL_KEY ${toString$5(e.privateKey,"hex")}`)):keyLogger("Missing local ephemeral keys.")}function logRemoteStaticKey(e){keyLogger(`REMOTE_STATIC_PUBLIC_KEY ${toString$5(e,"hex")}`)}function logRemoteEphemeralKey(e){keyLogger(`REMOTE_EPHEMERAL_PUBLIC_KEY ${toString$5(e,"hex")}`)}function logCipherState(e){e.cs1&&e.cs2?(keyLogger(`CIPHER_STATE_1 ${e.cs1.n.getUint64()} ${toString$5(e.cs1.k,"hex")}`),keyLogger(`CIPHER_STATE_2 ${e.cs2.n.getUint64()} ${toString$5(e.cs2.k,"hex")}`)):keyLogger("Missing cipher state.")}const MIN_NONCE=0,MAX_NONCE=4294967295,ERR_MAX_NONCE="Cipherstate has reached maximum n, a new handshake must be performed";class Nonce{constructor(t=MIN_NONCE){Xe(this,"n");Xe(this,"bytes");Xe(this,"view");this.n=t,this.bytes=new Uint8Array(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,t,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>MAX_NONCE)throw new Error(ERR_MAX_NONCE)}}class AbstractHandshake{constructor(t){Xe(this,"crypto");this.crypto=t}encryptWithAd(t,r,n){const o=this.encrypt(t.k,t.n,r,n);return t.n.increment(),o}decryptWithAd(t,r,n,o){const{plaintext:a,valid:l}=this.decrypt(t.k,t.n,r,n,o);return l&&t.n.increment(),{plaintext:a,valid:l}}hasKey(t){return!this.isEmptyKey(t.k)}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(t){const r=this.createEmptyKey();return equals$2(r,t)}encrypt(t,r,n,o){return r.assertValue(),this.crypto.chaCha20Poly1305Encrypt(o,r.getBytes(),n,t)}encryptAndHash(t,r){let n;return this.hasKey(t.cs)?n=this.encryptWithAd(t.cs,t.h,r):n=r,this.mixHash(t,n),n}decrypt(t,r,n,o,a){r.assertValue();const l=this.crypto.chaCha20Poly1305Decrypt(o,r.getBytes(),n,t,a);return l?{plaintext:l,valid:!0}:{plaintext:new Uint8Array(0),valid:!1}}decryptAndHash(t,r){let n,o=!0;return this.hasKey(t.cs)?{plaintext:n,valid:o}=this.decryptWithAd(t.cs,t.h,r):n=r,this.mixHash(t,r),{plaintext:n,valid:o}}dh(t,r){try{const n=this.crypto.generateX25519SharedKey(t,r);return n.length===32?n:n.subarray(0,32)}catch(n){const o=n;return log$B.error(o),new Uint8Array(32)}}mixHash(t,r){t.h=this.getHash(t.h,r)}getHash(t,r){return this.crypto.hashSHA256(concat$1([t,r],t.length+r.length))}mixKey(t,r){const[n,o]=this.crypto.getHKDF(t.ck,r);t.cs=this.initializeKey(o),t.ck=n}initializeKey(t){return{k:t,n:new Nonce}}initializeSymmetric(t){const r=fromString$1(t,"utf-8"),n=this.hashProtocolName(r),o=n,a=this.createEmptyKey();return{cs:this.initializeKey(a),ck:o,h:n}}hashProtocolName(t){if(t.length<=32){const r=new Uint8Array(32);return r.set(t),r}else return this.getHash(t,new Uint8Array(0))}split(t){const[r,n]=this.crypto.getHKDF(t.ck,new Uint8Array(0)),o=this.initializeKey(r),a=this.initializeKey(n);return{cs1:o,cs2:a}}writeMessageRegular(t,r){const n=this.encryptWithAd(t,new Uint8Array(0),r),o=this.createEmptyKey(),a=new Uint8Array(0);return{ne:o,ns:a,ciphertext:n}}readMessageRegular(t,r){return this.decryptWithAd(t,new Uint8Array(0),r.ciphertext)}}class XX extends AbstractHandshake{initializeInitiator(t,r,n,o){const a="Noise_XX_25519_ChaChaPoly_SHA256",l=this.initializeSymmetric(a);this.mixHash(l,t);const c=new Uint8Array(32);return{ss:l,s:r,rs:n,psk:o,re:c}}initializeResponder(t,r,n,o){const a="Noise_XX_25519_ChaChaPoly_SHA256",l=this.initializeSymmetric(a);this.mixHash(l,t);const c=new Uint8Array(32);return{ss:l,s:r,rs:n,psk:o,re:c}}writeMessageA(t,r,n){const o=new Uint8Array(0);n!==void 0?t.e=n:t.e=this.crypto.generateX25519KeyPair();const a=t.e.publicKey;this.mixHash(t.ss,a);const l=this.encryptAndHash(t.ss,r);return{ne:a,ns:o,ciphertext:l}}writeMessageB(t,r){t.e=this.crypto.generateX25519KeyPair();const n=t.e.publicKey;this.mixHash(t.ss,n),this.mixKey(t.ss,this.dh(t.e.privateKey,t.re));const o=t.s.publicKey,a=this.encryptAndHash(t.ss,o);this.mixKey(t.ss,this.dh(t.s.privateKey,t.re));const l=this.encryptAndHash(t.ss,r);return{ne:n,ns:a,ciphertext:l}}writeMessageC(t,r){const n=t.s.publicKey,o=this.encryptAndHash(t.ss,n);this.mixKey(t.ss,this.dh(t.s.privateKey,t.re));const a=this.encryptAndHash(t.ss,r),c={ne:this.createEmptyKey(),ns:o,ciphertext:a},{cs1:u,cs2:g}=this.split(t.ss);return{h:t.ss.h,messageBuffer:c,cs1:u,cs2:g}}readMessageA(t,r){return isValidPublicKey(r.ne)&&(t.re=r.ne),this.mixHash(t.ss,t.re),this.decryptAndHash(t.ss,r.ciphertext)}readMessageB(t,r){if(isValidPublicKey(r.ne)&&(t.re=r.ne),this.mixHash(t.ss,t.re),!t.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(t.ss,this.dh(t.e.privateKey,t.re));const{plaintext:n,valid:o}=this.decryptAndHash(t.ss,r.ns);o&&isValidPublicKey(n)&&(t.rs=n),this.mixKey(t.ss,this.dh(t.e.privateKey,t.rs));const{plaintext:a,valid:l}=this.decryptAndHash(t.ss,r.ciphertext);return{plaintext:a,valid:o&&l}}readMessageC(t,r){const{plaintext:n,valid:o}=this.decryptAndHash(t.ss,r.ns);if(o&&isValidPublicKey(n)&&(t.rs=n),!t.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(t.ss,this.dh(t.e.privateKey,t.rs));const{plaintext:a,valid:l}=this.decryptAndHash(t.ss,r.ciphertext),{cs1:c,cs2:u}=this.split(t.ss);return{h:t.ss.h,plaintext:a,valid:o&&l,cs1:c,cs2:u}}initSession(t,r,n){const o=this.createEmptyKey(),a=new Uint8Array(32);let l;return t?l=this.initializeInitiator(r,n,a,o):l=this.initializeResponder(r,n,a,o),{hs:l,i:t,mc:0}}sendMessage(t,r,n){let o;if(t.mc===0)o=this.writeMessageA(t.hs,r,n);else if(t.mc===1)o=this.writeMessageB(t.hs,r);else if(t.mc===2){const{h:a,messageBuffer:l,cs1:c,cs2:u}=this.writeMessageC(t.hs,r);o=l,t.h=a,t.cs1=c,t.cs2=u}else if(t.mc>2)if(t.i){if(!t.cs1)throw new Error("CS1 (cipher state) is not defined");o=this.writeMessageRegular(t.cs1,r)}else{if(!t.cs2)throw new Error("CS2 (cipher state) is not defined");o=this.writeMessageRegular(t.cs2,r)}else throw new Error("Session invalid.");return t.mc++,o}recvMessage(t,r){let n=new Uint8Array(0),o=!1;if(t.mc===0)({plaintext:n,valid:o}=this.readMessageA(t.hs,r));else if(t.mc===1)({plaintext:n,valid:o}=this.readMessageB(t.hs,r));else if(t.mc===2){const{h:a,plaintext:l,valid:c,cs1:u,cs2:g}=this.readMessageC(t.hs,r);n=l,o=c,t.h=a,t.cs1=u,t.cs2=g}return t.mc++,{plaintext:n,valid:o}}}class XXHandshake{constructor(t,r,n,o,a,l,c,u){Xe(this,"isInitiator");Xe(this,"session");Xe(this,"remotePeer");Xe(this,"remoteExtensions",{webtransportCerthashes:[]});Xe(this,"payload");Xe(this,"connection");Xe(this,"xx");Xe(this,"staticKeypair");Xe(this,"prologue");this.isInitiator=t,this.payload=r,this.prologue=n,this.staticKeypair=a,this.connection=l,c&&(this.remotePeer=c),this.xx=u??new XX(o),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair)}async propose(){if(logLocalStaticKeys(this.session.hs.s),this.isInitiator){log$B.trace("Stage 0 - Initiator starting to send first message.");const t=this.xx.sendMessage(this.session,new Uint8Array(0));await this.connection.write(encode0(t)),log$B.trace("Stage 0 - Initiator finished sending first message."),logLocalEphemeralKeys(this.session.hs.e)}else{log$B.trace("Stage 0 - Responder waiting to receive first message...");const t=decode0((await this.connection.read()).subarray()),{valid:r}=this.xx.recvMessage(this.session,t);if(!r)throw new InvalidCryptoExchangeError("xx handshake stage 0 validation fail");log$B.trace("Stage 0 - Responder received first message."),logRemoteEphemeralKey(this.session.hs.re)}}async exchange(){if(this.isInitiator){log$B.trace("Stage 1 - Initiator waiting to receive first message from responder...");const t=decode1((await this.connection.read()).subarray()),{plaintext:r,valid:n}=this.xx.recvMessage(this.session,t);if(!n)throw new InvalidCryptoExchangeError("xx handshake stage 1 validation fail");log$B.trace("Stage 1 - Initiator received the message."),logRemoteEphemeralKey(this.session.hs.re),logRemoteStaticKey(this.session.hs.rs),log$B.trace("Initiator going to check remote's signature...");try{const o=decodePayload(r);this.remotePeer=this.remotePeer||await getPeerIdFromPayload(o),await verifySignedPayload(this.session.hs.rs,o,this.remotePeer),this.setRemoteNoiseExtension(o.extensions)}catch(o){const a=o;throw new UnexpectedPeerError(`Error occurred while verifying signed payload: ${a.message}`)}log$B.trace("All good with the signature!")}else{log$B.trace("Stage 1 - Responder sending out first message with signed payload and static key.");const t=this.xx.sendMessage(this.session,this.payload);await this.connection.write(encode1(t)),log$B.trace("Stage 1 - Responder sent the second handshake message with signed payload."),logLocalEphemeralKeys(this.session.hs.e)}}async finish(){if(this.isInitiator){log$B.trace("Stage 2 - Initiator sending third handshake message.");const t=this.xx.sendMessage(this.session,this.payload);await this.connection.write(encode2(t)),log$B.trace("Stage 2 - Initiator sent message with signed payload.")}else{log$B.trace("Stage 2 - Responder waiting for third handshake message...");const t=decode2((await this.connection.read()).subarray()),{plaintext:r,valid:n}=this.xx.recvMessage(this.session,t);if(!n)throw new InvalidCryptoExchangeError("xx handshake stage 2 validation fail");log$B.trace("Stage 2 - Responder received the message, finished handshake.");try{const o=decodePayload(r);this.remotePeer=this.remotePeer||await getPeerIdFromPayload(o),await verifySignedPayload(this.session.hs.rs,o,this.remotePeer),this.setRemoteNoiseExtension(o.extensions)}catch(o){const a=o;throw new UnexpectedPeerError(`Error occurred while verifying signed payload: ${a.message}`)}}logCipherState(this.session)}encrypt(t,r){const n=this.getCS(r);return this.xx.encryptWithAd(n,new Uint8Array(0),t)}decrypt(t,r,n){const o=this.getCS(r,!1);return this.xx.decryptWithAd(o,new Uint8Array(0),t,n)}getRemoteStaticKey(){return this.session.hs.rs}getCS(t,r=!0){if(!t.cs1||!t.cs2)throw new InvalidCryptoExchangeError("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?r?t.cs1:t.cs2:r?t.cs2:t.cs1}setRemoteNoiseExtension(t){t&&(this.remoteExtensions=t)}}function registerMetrics(e){return{xxHandshakeSuccesses:e.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:e.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:e.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:e.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:e.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}class Noise{constructor(t={}){Xe(this,"protocol","/noise");Xe(this,"crypto");Xe(this,"prologue");Xe(this,"staticKeys");Xe(this,"extensions");Xe(this,"metrics");const{staticNoiseKey:r,extensions:n,crypto:o,prologueBytes:a,metrics:l}=t;this.crypto=o??pureJsCrypto,this.extensions=n,this.metrics=l?registerMetrics(l):void 0,r?this.staticKeys=this.crypto.generateX25519KeyPairFromSeed(r):this.staticKeys=this.crypto.generateX25519KeyPair(),this.prologue=a??new Uint8Array(0)}async secureOutbound(t,r,n){const o=lpStream(r,{lengthEncoder:uint16BEEncode,lengthDecoder:uint16BEDecode,maxDataLength:NOISE_MSG_MAX_LENGTH_BYTES}),a=await this.performHandshake({connection:o,isInitiator:!0,localPeer:t,remotePeer:n});return{conn:await this.createSecureConnection(o,a),remoteExtensions:a.remoteExtensions,remotePeer:a.remotePeer}}async secureInbound(t,r,n){const o=lpStream(r,{lengthEncoder:uint16BEEncode,lengthDecoder:uint16BEDecode,maxDataLength:NOISE_MSG_MAX_LENGTH_BYTES}),a=await this.performHandshake({connection:o,isInitiator:!1,localPeer:t,remotePeer:n});return{conn:await this.createSecureConnection(o,a),remotePeer:a.remotePeer,remoteExtensions:a.remoteExtensions}}async performHandshake(t){const r=await getPayload(t.localPeer,this.staticKeys.publicKey,this.extensions);return this.performXXHandshake(t,r)}async performXXHandshake(t,r){const{isInitiator:n,remotePeer:o,connection:a}=t,l=new XXHandshake(n,r,this.prologue,this.crypto,this.staticKeys,a,o);try{await l.propose(),await l.exchange(),await l.finish(),this.metrics?.xxHandshakeSuccesses.increment()}catch(c){if(this.metrics?.xxHandshakeErrors.increment(),c instanceof Error)throw c.message=`Error occurred during XX handshake: ${c.message}`,c}return l}async createSecureConnection(t,r){const[n,o]=duplexPair(),a=t.unwrap();return await pipe(n,encryptStream(r,this.metrics),a,l=>decode$a(l,{lengthDecoder:uint16BEDecode}),decryptStream(r,this.metrics),n),o}}function noise(e={}){return()=>new Noise(e)}var en;class EventEmitter$2 extends EventTarget{constructor(){super(...arguments);Er(this,en,new Map)}listenerCount(r){const n=ir(this,en).get(r);return n==null?0:n.length}addEventListener(r,n,o){super.addEventListener(r,n,o);let a=ir(this,en).get(r);a==null&&(a=[],ir(this,en).set(r,a)),a.push({callback:n,once:(o!==!0&&o!==!1&&o?.once)??!1})}removeEventListener(r,n,o){super.removeEventListener(r.toString(),n??null,o);let a=ir(this,en).get(r);a!=null&&(a=a.filter(({callback:l})=>l!==n),ir(this,en).set(r,a))}dispatchEvent(r){const n=super.dispatchEvent(r);let o=ir(this,en).get(r.type);return o==null||(o=o.filter(({once:a})=>!a),ir(this,en).set(r.type,o)),n}safeDispatchEvent(r,n){return this.dispatchEvent(new CustomEvent$1(r,n))}}en=new WeakMap;class CustomEventPolyfill extends Event{constructor(r,n){super(r,n);Xe(this,"detail");this.detail=n?.detail}}const CustomEvent$1=globalThis.CustomEvent??CustomEventPolyfill,peerDiscovery=Symbol.for("@libp2p/peer-discovery");class Parser{constructor(){Xe(this,"index",0);Xe(this,"input","")}new(t){return this.index=0,this.input=t,this}readAtomically(t){const r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){const r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{const r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let a=0,l=0;const c=this.peekChar();if(c===void 0)return;const u=c==="0",g=2**(8*o)-1;for(;;){const b=this.readAtomically(()=>{const x=this.readChar();if(x===void 0)return;const S=Number.parseInt(x,t);if(!Number.isNaN(S))return S});if(b===void 0)break;if(a*=t,a+=b,a>g||(l+=1,r!==void 0&&l>r))return}if(l!==0)return!n&&u&&l>1?void 0:a})}readIPv4Addr(){return this.readAtomically(()=>{const t=new Uint8Array(4);for(let r=0;rthis.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){const t=r=>{for(let n=0;nthis.readIPv4Addr());if(l!==void 0)return r[o]=l[0],r[o+1]=l[1],r[o+2]=l[2],r[o+3]=l[3],[o+4,!0]}const a=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(a===void 0)return[o,!1];r[o]=a>>8,r[o+1]=a&255}return[r.length,!1]};return this.readAtomically(()=>{const r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;const a=new Uint8Array(14),l=16-(n+2),[c]=t(a.subarray(0,l));return r.set(a.subarray(0,c),16-c),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}}const MAX_IPV6_LENGTH=45,MAX_IPV4_LENGTH=15,parser$4=new Parser;function parseIPv4(e){if(!(e.length>MAX_IPV4_LENGTH))return parser$4.new(e).parseWith(()=>parser$4.readIPv4Addr())}function parseIPv6(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>MAX_IPV6_LENGTH))return parser$4.new(e).parseWith(()=>parser$4.readIPv6Addr())}function parseIP(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>MAX_IPV6_LENGTH))return parser$4.new(e).parseWith(()=>parser$4.readIPAddr())}function isIPv4(e){return Boolean(parseIPv4(e))}function isIPv6(e){return Boolean(parseIPv6(e))}function isIP(e){return Boolean(parseIP(e))}const isV4=isIPv4,isV6=isIPv6,toBytes=function(e){let t=0;if(e=e.toString().trim(),isV4(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(isV6(e)){const r=e.split(":",8);let n;for(n=0;n0;n--)a.push("0");r.splice.apply(r,a)}const o=new Uint8Array(t+16);for(n=0;n>8&255,o[t++]=a&255}return o}throw new Error("invalid ip address")},toString$4=function(e,t=0,r){t=~~t,r=r??e.length-t;const n=new DataView(e.buffer);if(r===4){const o=[];for(let a=0;a{const t=createProtocol(...e);codes$8[t.code]=t,names$3[t.name]=t});function createProtocol(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(o)}}function getProtocol(e){if(typeof e=="number"){if(codes$8[e]!=null)return codes$8[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(names$3[e]!=null)return names$3[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}getProtocol("ip4");getProtocol("ip6");getProtocol("ipcidr");function convertToString(e,t){switch(getProtocol(e).code){case 4:case 41:return bytes2ip(t);case 42:return bytes2str(t);case 6:case 273:case 33:case 132:return bytes2port(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bytes2str(t);case 421:return bytes2mh(t);case 444:return bytes2onion(t);case 445:return bytes2onion(t);case 466:return bytes2mb(t);default:return toString$5(t,"base16")}}function convertToBytes(e,t){switch(getProtocol(e).code){case 4:return ip2bytes(t);case 41:return ip2bytes(t);case 42:return str2bytes(t);case 6:case 273:case 33:case 132:return port2bytes(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return str2bytes(t);case 421:return mh2bytes(t);case 444:return onion2bytes(t);case 445:return onion32bytes(t);case 466:return mb2bytes(t);default:return fromString$1(t,"base16")}}const decoders=Object.values(bases).map(e=>e.decoder),anybaseDecoder=function(){let e=decoders[0].or(decoders[1]);return decoders.slice(2).forEach(t=>e=e.or(t)),e}();function ip2bytes(e){if(!isIP(e))throw new Error("invalid ip address");return toBytes(e)}function bytes2ip(e){const t=toString$4(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!isIP(t))throw new Error("invalid ip address");return t}function port2bytes(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function bytes2port(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function str2bytes(e){const t=fromString$1(e),r=Uint8Array.from(encode$d(t.length));return concat$1([r,t],r.length+t.length)}function bytes2str(e){const t=decode$b(e);if(e=e.slice(encodingLength$2(t)),e.length!==t)throw new Error("inconsistent lengths");return toString$5(e)}function mh2bytes(e){let t;e[0]==="Q"||e[0]==="1"?t=decode$5(base58btc$1.decode(`z${e}`)).bytes:t=CID.parse(e).multihash.bytes;const r=Uint8Array.from(encode$d(t.length));return concat$1([r,t],r.length+t.length)}function mb2bytes(e){const t=anybaseDecoder.decode(e),r=Uint8Array.from(encode$d(t.length));return concat$1([r,t],r.length+t.length)}function bytes2mb(e){const t=decode$b(e),r=e.slice(encodingLength$2(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+toString$5(r,"base64url")}function bytes2mh(e){const t=decode$b(e),r=e.slice(encodingLength$2(t));if(r.length!==t)throw new Error("inconsistent lengths");return toString$5(r,"base58btc")}function onion2bytes(e){const t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);const r=base32$2.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const o=port2bytes(n);return concat$1([r,o],r.length+o.length)}function onion32bytes(e){const t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);const r=base32$2.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const o=port2bytes(n);return concat$1([r,o],r.length+o.length)}function bytes2onion(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=toString$5(t,"base32"),o=bytes2port(r);return`${n}:${o}`}function stringToMultiaddrParts(e){e=cleanPath(e);const t=[],r=[];let n=null;const o=e.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let a=0;a=o.length)throw ParseError("invalid address: "+e);if(c.path===!0){n=cleanPath(o.slice(a).join("/")),t.push([c.code,convertToBytes(c.code,n)]),r.push([c.code,n]);break}const u=convertToBytes(c.code,o[a]);t.push([c.code,u]),r.push([c.code,convertToString(c.code,u)])}return{string:stringTuplesToString(r),bytes:tuplesToBytes(t),tuples:t,stringTuples:r,path:n}}function bytesToMultiaddrParts(e){const t=[],r=[];let n=null,o=0;for(;oe.length)throw ParseError("Invalid address Uint8Array: "+toString$5(e,"base16"));t.push([a,g]);const b=convertToString(a,g);if(r.push([a,b]),c.path===!0){n=b;break}}return{bytes:Uint8Array.from(e),string:stringTuplesToString(r),tuples:t,stringTuples:r,path:n}}function stringTuplesToString(e){const t=[];return e.map(r=>{const n=getProtocol(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),cleanPath(t.join("/"))}function tuplesToBytes(e){return concat$1(e.map(t=>{const r=getProtocol(t[0]);let n=Uint8Array.from(encode$d(r.code));return t.length>1&&t[1]!=null&&(n=concat$1([n,t[1]])),n}))}function sizeForAddr(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{const r=decode$b(t instanceof Uint8Array?t:Uint8Array.from(t));return r+encodingLength$2(r)}}function cleanPath(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}function ParseError(e){return new Error("Error parsing address: "+e)}const inspect=Symbol.for("nodejs.util.inspect.custom"),DNS_CODES=[getProtocol("dns").code,getProtocol("dns4").code,getProtocol("dns6").code,getProtocol("dnsaddr").code],resolvers=new Map,symbol$2=Symbol.for("@multiformats/js-multiaddr/multiaddr");function isMultiaddr(e){return Boolean(e?.[symbol$2])}var Mi,Rn,fs,ps,Ql;const ai=class{constructor(t){Xe(this,"bytes");Er(this,Mi,void 0);Er(this,Rn,void 0);Er(this,fs,void 0);Er(this,ps,void 0);Xe(this,Ql,!0);t==null&&(t="");let r;if(t instanceof Uint8Array)r=bytesToMultiaddrParts(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=stringToMultiaddrParts(t)}else if(isMultiaddr(t))r=bytesToMultiaddrParts(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,Ln(this,Mi,r.string),Ln(this,Rn,r.tuples),Ln(this,fs,r.stringTuples),Ln(this,ps,r.path)}toString(){return ir(this,Mi)}toJSON(){return this.toString()}toOptions(){let t,r,n,o,a="";const l=getProtocol("tcp"),c=getProtocol("udp"),u=getProtocol("ip4"),g=getProtocol("ip6"),b=getProtocol("dns6"),x=getProtocol("ip6zone");for(const[$,k]of this.stringTuples())$===x.code&&(a=`%${k??""}`),DNS_CODES.includes($)&&(r=l.name,o=443,n=`${k??""}${a}`,t=$===b.code?6:4),($===l.code||$===c.code)&&(r=getProtocol($).name,o=parseInt(k??"")),($===u.code||$===g.code)&&(r=getProtocol($).name,n=`${k??""}${a}`,t=$===g.code?6:4);if(t==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:r,port:o}}protos(){return ir(this,Rn).map(([t])=>Object.assign({},getProtocol(t)))}protoCodes(){return ir(this,Rn).map(([t])=>t)}protoNames(){return ir(this,Rn).map(([t])=>getProtocol(t).name)}tuples(){return ir(this,Rn)}stringTuples(){return ir(this,fs)}encapsulate(t){return t=new ai(t),new ai(this.toString()+t.toString())}decapsulate(t){const r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new ai(n.slice(0,o))}decapsulateCode(t){const r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new ai(tuplesToBytes(r.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===names$3.p2p.code&&t.push([n,o]),n===names$3["p2p-circuit"].code&&(t=[])});const r=t.pop();if(r?.[1]!=null){const n=r[1];return n[0]==="Q"||n[0]==="1"?toString$5(base58btc$1.decode(`z${n}`),"base58btc"):toString$5(CID.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return ir(this,ps)}equals(t){return equals$2(this.bytes,t.bytes)}async resolve(t){const r=this.protos().find(a=>a.resolvable);if(r==null)return[this];const n=resolvers.get(r.name);if(n==null)throw new CodeError(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(a=>new ai(a))}nodeAddress(){const t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){const r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[(Ql=symbol$2,inspect)](){return`Multiaddr(${ir(this,Mi)})`}};let DefaultMultiaddr=ai;Mi=new WeakMap,Rn=new WeakMap,fs=new WeakMap,ps=new WeakMap;function multiaddr(e){return new DefaultMultiaddr(e)}const DNS4=base$3("dns4"),DNS6=base$3("dns6"),DNSADDR=base$3("dnsaddr"),DNS=or$2(base$3("dns"),DNSADDR,DNS4,DNS6),IP=or$2(base$3("ip4"),base$3("ip6")),TCP=or$2(and$1(IP,base$3("tcp")),and$1(DNS,base$3("tcp"))),UDP=and$1(IP,base$3("udp")),UTP=and$1(UDP,base$3("utp")),QUIC=and$1(UDP,base$3("quic")),QUICV1=and$1(UDP,base$3("quic-v1")),_WebSockets$1=or$2(and$1(TCP,base$3("ws")),and$1(DNS,base$3("ws"))),WebSockets$1=or$2(and$1(_WebSockets$1,base$3("p2p")),_WebSockets$1),_WebSocketsSecure$1=or$2(and$1(TCP,base$3("wss")),and$1(DNS,base$3("wss")),and$1(TCP,base$3("tls"),base$3("ws")),and$1(DNS,base$3("tls"),base$3("ws"))),WebSocketsSecure=or$2(and$1(_WebSocketsSecure$1,base$3("p2p")),_WebSocketsSecure$1),HTTP=or$2(and$1(TCP,base$3("http")),and$1(IP,base$3("http")),and$1(DNS,base$3("http"))),HTTPS=or$2(and$1(TCP,base$3("https")),and$1(IP,base$3("https")),and$1(DNS,base$3("https"))),_WebRTCDirect$1=and$1(UDP,base$3("webrtc-direct"),base$3("certhash")),WebRTCDirect=or$2(and$1(_WebRTCDirect$1,base$3("p2p")),_WebRTCDirect$1),_WebTransport$1=and$1(QUICV1,base$3("webtransport"),base$3("certhash"),base$3("certhash")),WebTransport=or$2(and$1(_WebTransport$1,base$3("p2p")),_WebTransport$1),P2PWebRTCStar=or$2(and$1(WebSockets$1,base$3("p2p-webrtc-star"),base$3("p2p")),and$1(WebSocketsSecure,base$3("p2p-webrtc-star"),base$3("p2p")),and$1(WebSockets$1,base$3("p2p-webrtc-star")),and$1(WebSocketsSecure,base$3("p2p-webrtc-star"))),P2PWebRTCDirect=or$2(and$1(HTTP,base$3("p2p-webrtc-direct"),base$3("p2p")),and$1(HTTPS,base$3("p2p-webrtc-direct"),base$3("p2p")),and$1(HTTP,base$3("p2p-webrtc-direct")),and$1(HTTPS,base$3("p2p-webrtc-direct"))),Reliable=or$2(_WebSockets$1,_WebSocketsSecure$1,HTTP,HTTPS,P2PWebRTCStar,P2PWebRTCDirect,TCP,UTP,QUIC,DNS,WebRTCDirect,WebTransport),_P2P$1=or$2(and$1(Reliable,base$3("p2p")),P2PWebRTCStar,P2PWebRTCDirect,WebRTCDirect,WebTransport,base$3("p2p")),_Circuit$1=or$2(and$1(_P2P$1,base$3("p2p-circuit"),_P2P$1),and$1(_P2P$1,base$3("p2p-circuit")),and$1(base$3("p2p-circuit"),_P2P$1),and$1(Reliable,base$3("p2p-circuit")),and$1(base$3("p2p-circuit"),Reliable),base$3("p2p-circuit")),CircuitRecursive=()=>or$2(and$1(_Circuit$1,CircuitRecursive),_Circuit$1),Circuit$1=CircuitRecursive(),P2P=or$2(and$1(Circuit$1,_P2P$1,Circuit$1),and$1(_P2P$1,Circuit$1),and$1(Circuit$1,_P2P$1),Circuit$1,_P2P$1);function makeMatchesFunction(e){function t(r){let n;try{n=multiaddr(r)}catch{return!1}const o=e(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function and$1(...e){function t(r){if(r.length(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:makeMatchesFunction(t),partialMatch:t}}function or$2(...e){function t(n){let o=null;return e.some(a=>{const l=typeof a=="function"?a().partialMatch(n):a.partialMatch(n);return l!=null?(o=l,!0):!1}),o}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:makeMatchesFunction(t),partialMatch:t}}function base$3(e){const t=e;function r(o){let a;try{a=multiaddr(o)}catch{return!1}const l=a.protoNames();return l.length===1&&l[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:r,partialMatch:n}}const log$A=logger("libp2p:bootstrap"),DEFAULT_BOOTSTRAP_TAG_NAME="bootstrap",DEFAULT_BOOTSTRAP_TAG_VALUE=50,DEFAULT_BOOTSTRAP_TAG_TTL=12e4,DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT=1e3;var Jl,ec;class Bootstrap extends EventEmitter$2{constructor(r,n={list:[]}){if(n.list==null||n.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super();Xe(this,"timer");Xe(this,"list");Xe(this,"timeout");Xe(this,"components");Xe(this,"_init");Xe(this,Jl,this);Xe(this,ec,"@libp2p/bootstrap");this.components=r,this.timeout=n.timeout??DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT,this.list=[];for(const o of n.list){if(!P2P.matches(o)){log$A.error("Invalid multiaddr");continue}const a=multiaddr(o),l=a.getPeerId();if(l==null){log$A.error("Invalid bootstrap multiaddr without peer id");continue}const c={id:peerIdFromString(l),multiaddrs:[a],protocols:[]};this.list.push(c)}this._init=n}isStarted(){return Boolean(this.timer)}start(){this.isStarted()||(log$A("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(r=>{log$A.error(r)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(const r of this.list){if(await this.components.peerStore.merge(r.id,{tags:{[this._init.tagName??DEFAULT_BOOTSTRAP_TAG_NAME]:{value:this._init.tagValue??DEFAULT_BOOTSTRAP_TAG_VALUE,ttl:this._init.tagTTL??DEFAULT_BOOTSTRAP_TAG_TTL}}}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:r})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}}Jl=peerDiscovery,ec=Symbol.toStringTag,Xe(Bootstrap,"tag","bootstrap");function bootstrap(e){return t=>new Bootstrap(t,e)}var TopicValidatorResult;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(TopicValidatorResult||(TopicValidatorResult={}));function mapIterable(e,t){const r={[Symbol.iterator]:()=>r,next:()=>{const n=e.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return r}class PeerMap{constructor(t){Xe(this,"map");if(this.map=new Map,t!=null)for(const[r,n]of t.entries())this.map.set(r.toString(),n)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){this.map.delete(t.toString())}entries(){return mapIterable(this.map.entries(),t=>[peerIdFromString(t[0]),t[1]])}forEach(t){this.map.forEach((r,n)=>{t(r,peerIdFromString(n),this)})}get(t){return this.map.get(t.toString())}has(t){return this.map.has(t.toString())}set(t,r){this.map.set(t.toString(),r)}keys(){return mapIterable(this.map.keys(),t=>peerIdFromString(t))}values(){return this.map.values()}get size(){return this.map.size}}class PeerSet{constructor(t){Xe(this,"set");if(this.set=new Set,t!=null)for(const r of t)this.set.add(r.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return mapIterable(this.set.entries(),t=>{const r=peerIdFromString(t[0]);return[r,r]})}forEach(t){this.set.forEach(r=>{const n=peerIdFromString(r);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return mapIterable(this.set.values(),t=>peerIdFromString(t))}intersection(t){const r=new PeerSet;for(const n of t)this.has(n)&&r.add(n);return r}difference(t){const r=new PeerSet;for(const n of this)t.has(n)||r.add(n);return r}union(t){const r=new PeerSet;for(const n of t)r.add(n);for(const n of this)r.add(n);return r}}var eventemitter3={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function o(u,g,b){this.fn=u,this.context=g,this.once=b||!1}function a(u,g,b,x,S){if(typeof b!="function")throw new TypeError("The listener must be a function");var $=new o(b,x||u,S),k=r?r+g:g;return u._events[k]?u._events[k].fn?u._events[k]=[u._events[k],$]:u._events[k].push($):(u._events[k]=$,u._eventsCount++),u}function l(u,g){--u._eventsCount===0?u._events=new n:delete u._events[g]}function c(){this._events=new n,this._eventsCount=0}c.prototype.eventNames=function(){var g=[],b,x;if(this._eventsCount===0)return g;for(x in b=this._events)t.call(b,x)&&g.push(r?x.slice(1):x);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(b)):g},c.prototype.listeners=function(g){var b=r?r+g:g,x=this._events[b];if(!x)return[];if(x.fn)return[x.fn];for(var S=0,$=x.length,k=new Array($);S<$;S++)k[S]=x[S].fn;return k},c.prototype.listenerCount=function(g){var b=r?r+g:g,x=this._events[b];return x?x.fn?1:x.length:0},c.prototype.emit=function(g,b,x,S,$,k){var T=r?r+g:g;if(!this._events[T])return!1;var D=this._events[T],I=arguments.length,O,N;if(D.fn){switch(D.once&&this.removeListener(g,D.fn,void 0,!0),I){case 1:return D.fn.call(D.context),!0;case 2:return D.fn.call(D.context,b),!0;case 3:return D.fn.call(D.context,b,x),!0;case 4:return D.fn.call(D.context,b,x,S),!0;case 5:return D.fn.call(D.context,b,x,S,$),!0;case 6:return D.fn.call(D.context,b,x,S,$,k),!0}for(N=1,O=new Array(I-1);NglobalThis.DOMException===void 0?new AbortError$3(e):new DOMException(e),getAbortedReason$1=e=>{const t=e.reason===void 0?getDOMException$1("This operation was aborted."):e.reason;return t instanceof Error?t:getDOMException$1(t)};function pTimeout$1(e,t,r,n){let o;const a=new Promise((l,c)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t===Number.POSITIVE_INFINITY){l(e);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){const{signal:u}=n;u.aborted&&c(getAbortedReason$1(u)),u.addEventListener("abort",()=>{c(getAbortedReason$1(u))})}o=n.customTimers.setTimeout.call(void 0,()=>{if(typeof r=="function"){try{l(r())}catch(b){c(b)}return}const u=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,g=r instanceof Error?r:new TimeoutError$1(u);typeof e.cancel=="function"&&e.cancel(),c(g)},t),(async()=>{try{l(await e)}catch(u){c(u)}finally{n.customTimers.clearTimeout.call(void 0,o)}})()});return a.clear=()=>{clearTimeout(o),o=void 0},a}function lowerBound$1(e,t,r){let n=0,o=e.length;for(;o>0;){const a=Math.trunc(o/2);let l=n+a;r(e[l],t)<=0?(n=++l,o-=a+1):o=a}return n}var __classPrivateFieldGet$1=globalThis&&globalThis.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},_PriorityQueue_queue;class PriorityQueue{constructor(){_PriorityQueue_queue.set(this,[])}enqueue(t,r){r={priority:0,...r};const n={priority:r.priority,run:t};if(this.size&&__classPrivateFieldGet$1(this,_PriorityQueue_queue,"f")[this.size-1].priority>=r.priority){__classPrivateFieldGet$1(this,_PriorityQueue_queue,"f").push(n);return}const o=lowerBound$1(__classPrivateFieldGet$1(this,_PriorityQueue_queue,"f"),n,(a,l)=>l.priority-a.priority);__classPrivateFieldGet$1(this,_PriorityQueue_queue,"f").splice(o,0,n)}dequeue(){const t=__classPrivateFieldGet$1(this,_PriorityQueue_queue,"f").shift();return t?.run}filter(t){return __classPrivateFieldGet$1(this,_PriorityQueue_queue,"f").filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return __classPrivateFieldGet$1(this,_PriorityQueue_queue,"f").length}}_PriorityQueue_queue=new WeakMap;var __classPrivateFieldSet=globalThis&&globalThis.__classPrivateFieldSet||function(e,t,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(e,r):o?o.value=r:t.set(e,r),r},__classPrivateFieldGet=globalThis&&globalThis.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},_PQueue_instances,_PQueue_carryoverConcurrencyCount,_PQueue_isIntervalIgnored,_PQueue_intervalCount,_PQueue_intervalCap,_PQueue_interval,_PQueue_intervalEnd,_PQueue_intervalId,_PQueue_timeoutId,_PQueue_queue,_PQueue_queueClass,_PQueue_pending,_PQueue_concurrency,_PQueue_isPaused,_PQueue_throwOnTimeout,_PQueue_doesIntervalAllowAnother_get,_PQueue_doesConcurrentAllowAnother_get,_PQueue_next,_PQueue_onResumeInterval,_PQueue_isIntervalPaused_get,_PQueue_tryToStartAnother,_PQueue_initializeIntervalIfNeeded,_PQueue_onInterval,_PQueue_processQueue,_PQueue_throwOnAbort,_PQueue_onEvent;class AbortError$2 extends Error{}class PQueue extends EventEmitter$1{constructor(t){var r,n,o,a;if(super(),_PQueue_instances.add(this),_PQueue_carryoverConcurrencyCount.set(this,void 0),_PQueue_isIntervalIgnored.set(this,void 0),_PQueue_intervalCount.set(this,0),_PQueue_intervalCap.set(this,void 0),_PQueue_interval.set(this,void 0),_PQueue_intervalEnd.set(this,0),_PQueue_intervalId.set(this,void 0),_PQueue_timeoutId.set(this,void 0),_PQueue_queue.set(this,void 0),_PQueue_queueClass.set(this,void 0),_PQueue_pending.set(this,0),_PQueue_concurrency.set(this,void 0),_PQueue_isPaused.set(this,void 0),_PQueue_throwOnTimeout.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:PriorityQueue,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(o=t.interval)===null||o===void 0?void 0:o.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);__classPrivateFieldSet(this,_PQueue_carryoverConcurrencyCount,t.carryoverConcurrencyCount,"f"),__classPrivateFieldSet(this,_PQueue_isIntervalIgnored,t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,"f"),__classPrivateFieldSet(this,_PQueue_intervalCap,t.intervalCap,"f"),__classPrivateFieldSet(this,_PQueue_interval,t.interval,"f"),__classPrivateFieldSet(this,_PQueue_queue,new t.queueClass,"f"),__classPrivateFieldSet(this,_PQueue_queueClass,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,__classPrivateFieldSet(this,_PQueue_throwOnTimeout,t.throwOnTimeout===!0,"f"),__classPrivateFieldSet(this,_PQueue_isPaused,t.autoStart===!1,"f")}get concurrency(){return __classPrivateFieldGet(this,_PQueue_concurrency,"f")}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);__classPrivateFieldSet(this,_PQueue_concurrency,t,"f"),__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_processQueue).call(this)}async add(t,r={}){return r={timeout:this.timeout,throwOnTimeout:__classPrivateFieldGet(this,_PQueue_throwOnTimeout,"f"),...r},new Promise((n,o)=>{__classPrivateFieldGet(this,_PQueue_queue,"f").enqueue(async()=>{var a,l,c;__classPrivateFieldSet(this,_PQueue_pending,(l=__classPrivateFieldGet(this,_PQueue_pending,"f"),l++,l),"f"),__classPrivateFieldSet(this,_PQueue_intervalCount,(c=__classPrivateFieldGet(this,_PQueue_intervalCount,"f"),c++,c),"f");try{if(!((a=r.signal)===null||a===void 0)&&a.aborted)throw new AbortError$2("The task was aborted.");let u=t({signal:r.signal});r.timeout&&(u=pTimeout$1(Promise.resolve(u),r.timeout)),r.signal&&(u=Promise.race([u,__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_throwOnAbort).call(this,r.signal)]));const g=await u;n(g),this.emit("completed",g)}catch(u){if(u instanceof TimeoutError$1&&!r.throwOnTimeout){n();return}o(u),this.emit("error",u)}finally{__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_next).call(this)}},r),this.emit("add"),__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_tryToStartAnother).call(this)})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return __classPrivateFieldGet(this,_PQueue_isPaused,"f")?(__classPrivateFieldSet(this,_PQueue_isPaused,!1,"f"),__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_processQueue).call(this),this):this}pause(){__classPrivateFieldSet(this,_PQueue_isPaused,!0,"f")}clear(){__classPrivateFieldSet(this,_PQueue_queue,new(__classPrivateFieldGet(this,_PQueue_queueClass,"f")),"f")}async onEmpty(){__classPrivateFieldGet(this,_PQueue_queue,"f").size!==0&&await __classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_onEvent).call(this,"empty")}async onSizeLessThan(t){__classPrivateFieldGet(this,_PQueue_queue,"f").size__classPrivateFieldGet(this,_PQueue_queue,"f").size{__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_onResumeInterval).call(this)},r),"f"),!0}return!1},_PQueue_tryToStartAnother=function e(){if(__classPrivateFieldGet(this,_PQueue_queue,"f").size===0)return __classPrivateFieldGet(this,_PQueue_intervalId,"f")&&clearInterval(__classPrivateFieldGet(this,_PQueue_intervalId,"f")),__classPrivateFieldSet(this,_PQueue_intervalId,void 0,"f"),this.emit("empty"),__classPrivateFieldGet(this,_PQueue_pending,"f")===0&&this.emit("idle"),!1;if(!__classPrivateFieldGet(this,_PQueue_isPaused,"f")){const t=!__classPrivateFieldGet(this,_PQueue_instances,"a",_PQueue_isIntervalPaused_get);if(__classPrivateFieldGet(this,_PQueue_instances,"a",_PQueue_doesIntervalAllowAnother_get)&&__classPrivateFieldGet(this,_PQueue_instances,"a",_PQueue_doesConcurrentAllowAnother_get)){const r=__classPrivateFieldGet(this,_PQueue_queue,"f").dequeue();return r?(this.emit("active"),r(),t&&__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_initializeIntervalIfNeeded).call(this),!0):!1}}return!1},_PQueue_initializeIntervalIfNeeded=function e(){__classPrivateFieldGet(this,_PQueue_isIntervalIgnored,"f")||__classPrivateFieldGet(this,_PQueue_intervalId,"f")!==void 0||(__classPrivateFieldSet(this,_PQueue_intervalId,setInterval(()=>{__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_onInterval).call(this)},__classPrivateFieldGet(this,_PQueue_interval,"f")),"f"),__classPrivateFieldSet(this,_PQueue_intervalEnd,Date.now()+__classPrivateFieldGet(this,_PQueue_interval,"f"),"f"))},_PQueue_onInterval=function e(){__classPrivateFieldGet(this,_PQueue_intervalCount,"f")===0&&__classPrivateFieldGet(this,_PQueue_pending,"f")===0&&__classPrivateFieldGet(this,_PQueue_intervalId,"f")&&(clearInterval(__classPrivateFieldGet(this,_PQueue_intervalId,"f")),__classPrivateFieldSet(this,_PQueue_intervalId,void 0,"f")),__classPrivateFieldSet(this,_PQueue_intervalCount,__classPrivateFieldGet(this,_PQueue_carryoverConcurrencyCount,"f")?__classPrivateFieldGet(this,_PQueue_pending,"f"):0,"f"),__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_processQueue).call(this)},_PQueue_processQueue=function e(){for(;__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_tryToStartAnother).call(this););},_PQueue_throwOnAbort=async function e(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(new AbortError$2("The task was aborted."))},{once:!0})})},_PQueue_onEvent=async function e(t,r){return new Promise(n=>{const o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})};const codes$7={ERR_INVALID_SIGNATURE_POLICY:"ERR_INVALID_SIGNATURE_POLICY",ERR_UNHANDLED_SIGNATURE_POLICY:"ERR_UNHANDLED_SIGNATURE_POLICY",ERR_MISSING_SIGNATURE:"ERR_MISSING_SIGNATURE",ERR_MISSING_SEQNO:"ERR_MISSING_SEQNO",ERR_MISSING_KEY:"ERR_MISSING_KEY",ERR_INVALID_SIGNATURE:"ERR_INVALID_SIGNATURE",ERR_MISSING_FROM:"ERR_MISSING_FROM",ERR_UNEXPECTED_FROM:"ERR_UNEXPECTED_FROM",ERR_UNEXPECTED_SIGNATURE:"ERR_UNEXPECTED_SIGNATURE",ERR_UNEXPECTED_KEY:"ERR_UNEXPECTED_KEY",ERR_UNEXPECTED_SEQNO:"ERR_UNEXPECTED_SEQNO",ERR_TOPIC_VALIDATOR_REJECT:"ERR_TOPIC_VALIDATOR_REJECT"};class AbortError$1 extends Error{constructor(t,r){super(t??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}}function getIterator(e){if(e!=null){if(typeof e[Symbol.iterator]=="function")return e[Symbol.iterator]();if(typeof e[Symbol.asyncIterator]=="function")return e[Symbol.asyncIterator]();if(typeof e.next=="function")return e}throw new Error("argument is not an iterator or iterable")}function abortableSource(e,t,r){const n=r??{},o=getIterator(e);async function*a(){let l;const c=()=>{l?.()};for(t.addEventListener("abort",c);;){let u;try{if(t.aborted){const{abortMessage:b,abortCode:x}=n;throw new AbortError$1(b,x)}const g=new Promise((b,x)=>{l=()=>{const{abortMessage:S,abortCode:$}=n;x(new AbortError$1(S,$))}});u=await Promise.race([g,o.next()]),l=null}catch(g){t.removeEventListener("abort",c);const b=g.type==="aborted"&&t.aborted;if(b&&n.onAbort!=null&&n.onAbort(e),typeof o.return=="function")try{const x=o.return();x instanceof Promise&&x.catch(S=>{n.onReturnError!=null&&n.onReturnError(S)})}catch(x){n.onReturnError!=null&&n.onReturnError(x)}if(b&&n.returnOnAbort===!0)return;throw g}if(u.done===!0)break;yield u.value}t.removeEventListener("abort",c)}return a()}function abortableSink(e,t,r){return n=>e(abortableSource(n,t,r))}function abortableDuplex(e,t,r){return{sink:abortableSink(e.sink,t,{...r,onAbort:void 0}),source:abortableSource(e.source,t,r)}}const log$z=logger("libp2p-pubsub:peer-streams");class PeerStreams extends EventEmitter$2{constructor(r){super();Xe(this,"id");Xe(this,"protocol");Xe(this,"outboundStream");Xe(this,"inboundStream");Xe(this,"_rawOutboundStream");Xe(this,"_rawInboundStream");Xe(this,"_inboundAbortController");Xe(this,"closed");this.id=r.id,this.protocol=r.protocol,this._inboundAbortController=new AbortController,this.closed=!1}get isReadable(){return Boolean(this.inboundStream)}get isWritable(){return Boolean(this.outboundStream)}write(r){if(this.outboundStream==null){const n=this.id.toString();throw new Error("No writable connection to "+n)}this.outboundStream.push(r instanceof Uint8Array?new Uint8ArrayList(r):r)}attachInboundStream(r){return this._rawInboundStream=r,this.inboundStream=abortableSource(pipe(this._rawInboundStream,n=>decode$a(n)),this._inboundAbortController.signal,{returnOnAbort:!0}),this.dispatchEvent(new CustomEvent$1("stream:inbound")),this.inboundStream}async attachOutboundStream(r){const n=this.outboundStream;return this.outboundStream!=null&&this.outboundStream.end(),this._rawOutboundStream=r,this.outboundStream=pushable({objectMode:!0,onEnd:o=>{this._rawOutboundStream!=null&&this._rawOutboundStream.closeWrite().catch(a=>{log$z("error closing outbound stream",a)}),this._rawOutboundStream=void 0,this.outboundStream=void 0,o!=null&&this.dispatchEvent(new CustomEvent$1("close"))}}),pipe(this.outboundStream,o=>encode$c(o),this._rawOutboundStream).catch(o=>{log$z.error(o)}),n==null&&this.dispatchEvent(new CustomEvent$1("stream:outbound")),this.outboundStream}close(){this.closed||(this.closed=!0,this.outboundStream!=null&&this.outboundStream.end(),this.inboundStream!=null&&this._inboundAbortController.abort(),this._rawOutboundStream=void 0,this.outboundStream=void 0,this._rawInboundStream=void 0,this.inboundStream=void 0,this.dispatchEvent(new CustomEvent$1("close")))}}const hashName={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function pbkdf2(e,t,r,n,o){if(o!=="sha1"&&o!=="sha2-256"&&o!=="sha2-512"){const c=Object.keys(hashName).join(" / ");throw new CodeError(`Hash '${o}' is unknown or not supported. Must be ${c}`,"ERR_UNSUPPORTED_HASH_TYPE")}const a=hashName[o],l=pbkdf2$1(e,t,r,n,a);return util$7.exports.encode64(l,null)}function randomSeqno(){return BigInt(`0x${toString$5(randomBytes(8),"base16")}`)}const msgId=(e,t)=>{const r=fromString$1(t.toString(16).padStart(16,"0"),"base16"),n=new Uint8Array(e.length+r.length);return n.set(e,0),n.set(r,e.length),n},noSignMsgId=e=>sha256$1.encode(e),ensureArray=function(e){return Array.isArray(e)?e:[e]},isSigned=async e=>{if(e.sequenceNumber==null||e.from==null||e.signature==null)return!1;const t=peerIdFromBytes(e.from);return t.publicKey!=null?!0:e.key!=null?(await peerIdFromKeys(e.key)).equals(t):!1},toMessage=async e=>{if(e.from==null)throw new CodeError("RPC message was missing from",codes$7.ERR_MISSING_FROM);if(!await isSigned(e))return{type:"unsigned",topic:e.topic??"",data:e.data??new Uint8Array(0)};const t=peerIdFromBytes(e.from),r={type:"signed",from:peerIdFromBytes(e.from),topic:e.topic??"",sequenceNumber:bigIntFromBytes(e.sequenceNumber??new Uint8Array(0)),data:e.data??new Uint8Array(0),signature:e.signature??new Uint8Array(0),key:e.key??t.publicKey??new Uint8Array(0)};if(r.key.length===0)throw new CodeError("Signed RPC message was missing key",codes$7.ERR_MISSING_KEY);return r},toRpcMessage=e=>e.type==="signed"?{from:e.from.multihash.bytes,data:e.data,sequenceNumber:bigIntToBytes(e.sequenceNumber),topic:e.topic,signature:e.signature,key:e.key}:{data:e.data,topic:e.topic},bigIntToBytes=e=>{let t=e.toString(16);return t.length%2!==0&&(t=`0${t}`),fromString$1(t,"base16")},bigIntFromBytes=e=>BigInt(`0x${toString$5(e,"base16")}`),SignPrefix=fromString$1("libp2p-pubsub:");async function signMessage(e,t,r){if(e.privateKey==null)throw new Error("Cannot sign message, no private key present");if(e.publicKey==null)throw new Error("Cannot sign message, no public key present");const n={type:"signed",topic:t.topic,data:t.data,sequenceNumber:t.sequenceNumber,from:e},o=concat$1([SignPrefix,r(toRpcMessage(n)).subarray()]),a=await unmarshalPrivateKey(e.privateKey);return n.signature=await a.sign(o),n.key=e.publicKey,n}async function verifySignature(e,t){if(e.type!=="signed")throw new Error('Message type must be "signed" to be verified');if(e.signature==null)throw new Error("Message must contain a signature to be verified");if(e.from==null)throw new Error("Message must contain a from property to be verified");const r=concat$1([SignPrefix,t({...toRpcMessage(e),signature:void 0,key:void 0}).subarray()]),n=await messagePublicKey(e);return unmarshalPublicKey(n).verify(r,e.signature)}async function messagePublicKey(e){if(e.type!=="signed")throw new Error('Message type must be "signed" to have a public key');if(e.from==null)throw new Error("Could not get the public key from the originator id");if(e.key!=null){const t=await peerIdFromKeys(e.key);if(t.publicKey!=null)return t.publicKey}if(e.from.publicKey!=null)return e.from.publicKey;throw new Error("Could not get the public key from the originator id")}const log$y=logger("libp2p:pubsub");class PubSubBaseProtocol extends EventEmitter$2{constructor(r,n){super();Xe(this,"started");Xe(this,"topics");Xe(this,"subscriptions");Xe(this,"peers");Xe(this,"globalSignaturePolicy");Xe(this,"canRelayMessage");Xe(this,"emitSelf");Xe(this,"topicValidators");Xe(this,"queue");Xe(this,"multicodecs");Xe(this,"components");Xe(this,"_registrarTopologyIds");Xe(this,"enabled");Xe(this,"maxInboundStreams");Xe(this,"maxOutboundStreams");const{multicodecs:o=[],globalSignaturePolicy:a="StrictSign",canRelayMessage:l=!1,emitSelf:c=!1,messageProcessingConcurrency:u=10,maxInboundStreams:g=1,maxOutboundStreams:b=1}=n;this.components=r,this.multicodecs=ensureArray(o),this.enabled=n.enabled!==!1,this.started=!1,this.topics=new Map,this.subscriptions=new Set,this.peers=new PeerMap,this.globalSignaturePolicy=a==="StrictNoSign"?"StrictNoSign":"StrictSign",this.canRelayMessage=l,this.emitSelf=c,this.topicValidators=new Map,this.queue=new PQueue({concurrency:u}),this.maxInboundStreams=g,this.maxOutboundStreams=b,this._onIncomingStream=this._onIncomingStream.bind(this),this._onPeerConnected=this._onPeerConnected.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this)}async start(){if(this.started||!this.enabled)return;log$y("starting");const r=this.components.registrar;await Promise.all(this.multicodecs.map(async o=>{await r.handle(o,this._onIncomingStream,{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams})}));const n={onConnect:this._onPeerConnected,onDisconnect:this._onPeerDisconnected};this._registrarTopologyIds=await Promise.all(this.multicodecs.map(async o=>r.register(o,n))),log$y("started"),this.started=!0}async stop(){if(!this.started||!this.enabled)return;const r=this.components.registrar;this._registrarTopologyIds!=null&&this._registrarTopologyIds?.forEach(n=>{r.unregister(n)}),await Promise.all(this.multicodecs.map(async n=>{await r.unhandle(n)})),log$y("stopping");for(const n of this.peers.values())n.close();this.peers.clear(),this.subscriptions=new Set,this.started=!1,log$y("stopped")}isStarted(){return this.started}_onIncomingStream(r){const{stream:n,connection:o}=r,a=o.remotePeer;if(n.protocol==null){n.abort(new Error("Stream was not multiplexed"));return}const l=this.addPeer(a,n.protocol),c=l.attachInboundStream(n);this.processMessages(a,c,l).catch(u=>{log$y(u)})}_onPeerConnected(r,n){log$y("connected %p",r),Promise.resolve().then(async()=>{try{const o=await n.newStream(this.multicodecs);if(o.protocol==null){o.abort(new Error("Stream was not multiplexed"));return}await this.addPeer(r,o.protocol).attachOutboundStream(o)}catch(o){log$y.error(o)}this.send(r,{subscriptions:Array.from(this.subscriptions).map(o=>o.toString()),subscribe:!0})}).catch(o=>{log$y.error(o)})}_onPeerDisconnected(r,n){const o=r.toString();log$y("connection ended",o),this._removePeer(r)}addPeer(r,n){const o=this.peers.get(r);if(o!=null)return o;log$y("new peer %p",r);const a=new PeerStreams({id:r,protocol:n});return this.peers.set(r,a),a.addEventListener("close",()=>this._removePeer(r),{once:!0}),a}_removePeer(r){const n=this.peers.get(r);if(n!=null){n.close(),log$y("delete peer %p",r),this.peers.delete(r);for(const o of this.topics.values())o.delete(r);return n}}async processMessages(r,n,o){try{await pipe(n,async a=>{for await(const l of a){const c=this.decodeRpc(l),u=[];for(const g of c.messages??[]){if(g.from==null||g.data==null||g.topic==null){log$y("message from %p was missing from, data or topic fields, dropping",r);continue}u.push({from:g.from,data:g.data,topic:g.topic,sequenceNumber:g.sequenceNumber??void 0,signature:g.signature??void 0,key:g.key??void 0})}this.processRpc(r,o,{subscriptions:(c.subscriptions??[]).map(g=>({subscribe:Boolean(g.subscribe),topic:g.topic??""})),messages:u}).catch(g=>{log$y(g)})}})}catch(a){this._onPeerDisconnected(o.id,a)}}async processRpc(r,n,o){if(!this.acceptFrom(r))return log$y("received message from unacceptable peer %p",r),!1;log$y("rpc from %p",r);const{subscriptions:a,messages:l}=o;return a!=null&&a.length>0&&(log$y("subscription update from %p",r),a.forEach(c=>{this.processRpcSubOpt(r,c)}),super.dispatchEvent(new CustomEvent$1("subscription-change",{detail:{peerId:n.id,subscriptions:a.map(({topic:c,subscribe:u})=>({topic:`${c??""}`,subscribe:Boolean(u)}))}}))),l!=null&&l.length>0&&(log$y("messages from %p",r),this.queue.addAll(l.map(c=>async()=>{if(c.topic==null||!this.subscriptions.has(c.topic)&&!this.canRelayMessage)return log$y("received message we didn't subscribe to. Dropping."),!1;try{const u=await toMessage(c);await this.processMessage(r,u)}catch(u){log$y.error(u)}})).catch(c=>{log$y(c)})),!0}processRpcSubOpt(r,n){const o=n.topic;if(o==null)return;let a=this.topics.get(o);a==null&&(a=new PeerSet,this.topics.set(o,a)),n.subscribe===!0?a.add(r):a.delete(r)}async processMessage(r,n){if(!(this.components.peerId.equals(r)&&!this.emitSelf)){try{await this.validate(r,n)}catch(o){log$y("Message is invalid, dropping it. %O",o);return}this.subscriptions.has(n.topic)&&(!this.components.peerId.equals(r)||this.emitSelf)&&super.dispatchEvent(new CustomEvent$1("message",{detail:n})),await this.publishMessage(r,n)}}getMsgId(r){switch(this.globalSignaturePolicy){case"StrictSign":if(r.type!=="signed")throw new CodeError('Message type should be "signed" when signature policy is StrictSign but it was not',codes$7.ERR_MISSING_SIGNATURE);if(r.sequenceNumber==null)throw new CodeError("Need seqno when signature policy is StrictSign but it was missing",codes$7.ERR_MISSING_SEQNO);if(r.key==null)throw new CodeError("Need key when signature policy is StrictSign but it was missing",codes$7.ERR_MISSING_KEY);return msgId(r.key,r.sequenceNumber);case"StrictNoSign":return noSignMsgId(r.data);default:throw new CodeError("Cannot get message id: unhandled signature policy",codes$7.ERR_UNHANDLED_SIGNATURE_POLICY)}}acceptFrom(r){return!0}send(r,n){const{messages:o,subscriptions:a,subscribe:l}=n;this.sendRpc(r,{subscriptions:(a??[]).map(c=>({topic:c,subscribe:Boolean(l)})),messages:(o??[]).map(toRpcMessage)})}sendRpc(r,n){const o=this.peers.get(r);if(o==null||!o.isWritable){log$y.error("Cannot send RPC to %p as there is no open stream to it available",r);return}o.write(this.encodeRpc(n))}async validate(r,n){switch(this.globalSignaturePolicy){case"StrictNoSign":if(n.type!=="unsigned")throw new CodeError('Message type should be "unsigned" when signature policy is StrictNoSign but it was not',codes$7.ERR_MISSING_SIGNATURE);if(n.signature!=null)throw new CodeError("StrictNoSigning: signature should not be present",codes$7.ERR_UNEXPECTED_SIGNATURE);if(n.key!=null)throw new CodeError("StrictNoSigning: key should not be present",codes$7.ERR_UNEXPECTED_KEY);if(n.sequenceNumber!=null)throw new CodeError("StrictNoSigning: seqno should not be present",codes$7.ERR_UNEXPECTED_SEQNO);break;case"StrictSign":if(n.type!=="signed")throw new CodeError('Message type should be "signed" when signature policy is StrictSign but it was not',codes$7.ERR_MISSING_SIGNATURE);if(n.signature==null)throw new CodeError("StrictSigning: Signing required and no signature was present",codes$7.ERR_MISSING_SIGNATURE);if(n.sequenceNumber==null)throw new CodeError("StrictSigning: Signing required and no sequenceNumber was present",codes$7.ERR_MISSING_SEQNO);if(!await verifySignature(n,this.encodeMessage.bind(this)))throw new CodeError("StrictSigning: Invalid message signature",codes$7.ERR_INVALID_SIGNATURE);break;default:throw new CodeError("Cannot validate message: unhandled signature policy",codes$7.ERR_UNHANDLED_SIGNATURE_POLICY)}const a=this.topicValidators.get(n.topic);if(a!=null){const l=await a(r,n);if(l===TopicValidatorResult.Reject||l===TopicValidatorResult.Ignore)throw new CodeError("Message validation failed",codes$7.ERR_TOPIC_VALIDATOR_REJECT)}}async buildMessage(r){switch(this.globalSignaturePolicy){case"StrictSign":return signMessage(this.components.peerId,r,this.encodeMessage.bind(this));case"StrictNoSign":return Promise.resolve({type:"unsigned",...r});default:throw new CodeError("Cannot build message: unhandled signature policy",codes$7.ERR_UNHANDLED_SIGNATURE_POLICY)}}getSubscribers(r){if(!this.started)throw new CodeError("not started yet","ERR_NOT_STARTED_YET");if(r==null)throw new CodeError("topic is required","ERR_NOT_VALID_TOPIC");const n=this.topics.get(r.toString());return n==null?[]:Array.from(n.values())}async publish(r,n){if(!this.started)throw new Error("Pubsub has not started");const o={from:this.components.peerId,topic:r,data:n??new Uint8Array(0),sequenceNumber:randomSeqno()};log$y("publish topic: %s from: %p data: %m",r,o.from,o.data);const a=await this.buildMessage(o);let l=!1;this.emitSelf&&this.subscriptions.has(r)&&(l=!0,super.dispatchEvent(new CustomEvent$1("message",{detail:a})));const c=await this.publishMessage(this.components.peerId,a);return l&&(c.recipients=[...c.recipients,this.components.peerId]),c}subscribe(r){if(!this.started)throw new Error("Pubsub has not started");if(log$y("subscribe to topic: %s",r),!this.subscriptions.has(r)){this.subscriptions.add(r);for(const n of this.peers.keys())this.send(n,{subscriptions:[r],subscribe:!0})}}unsubscribe(r){if(!this.started)throw new Error("Pubsub is not started");super.removeEventListener(r);const n=this.subscriptions.has(r);if(log$y("unsubscribe from %s - am subscribed %s",r,n),n){this.subscriptions.delete(r);for(const o of this.peers.keys())this.send(o,{subscriptions:[r],subscribe:!1})}}getTopics(){if(!this.started)throw new Error("Pubsub is not started");return Array.from(this.subscriptions)}getPeers(){if(!this.started)throw new Error("Pubsub is not started");return Array.from(this.peers.keys())}}class SimpleTimeCache{constructor(t){Xe(this,"entries");Xe(this,"validityMs");Xe(this,"lastPruneTime",0);this.entries=new Map,this.validityMs=t.validityMs}put(t,r){this.entries.set(t,{value:r,validUntilMs:Date.now()+this.validityMs}),this.prune()}prune(){const t=Date.now();if(!(t-this.lastPruneTime<200)){this.lastPruneTime=t;for(const[r,n]of this.entries.entries())if(n.validUntilMs=Date.now()?r.value:void 0}clear(){this.entries=new Map,this.lastPruneTime=0}}logger("libp2p:floodsub");const multicodec="/floodsub/1.0.0";var RPC;(function(e){(function(r){let n;r.codec=()=>(n==null&&(n=message((o,a,l={})=>{l.lengthDelimited!==!1&&a.fork(),o.subscribe!=null&&(a.uint32(8),a.bool(o.subscribe)),o.topic!=null&&(a.uint32(18),a.string(o.topic)),l.lengthDelimited!==!1&&a.ldelim()},(o,a)=>{const l={},c=a==null?o.len:o.pos+a;for(;o.pos>>3){case 1:l.subscribe=o.bool();break;case 2:l.topic=o.string();break;default:o.skipType(u&7);break}}return l})),n),r.encode=o=>encodeMessage(o,r.codec()),r.decode=o=>decodeMessage(o,r.codec())})(e.SubOpts||(e.SubOpts={})),function(r){let n;r.codec=()=>(n==null&&(n=message((o,a,l={})=>{l.lengthDelimited!==!1&&a.fork(),o.from!=null&&(a.uint32(10),a.bytes(o.from)),o.data!=null&&(a.uint32(18),a.bytes(o.data)),o.sequenceNumber!=null&&(a.uint32(26),a.bytes(o.sequenceNumber)),o.topic!=null&&(a.uint32(34),a.string(o.topic)),o.signature!=null&&(a.uint32(42),a.bytes(o.signature)),o.key!=null&&(a.uint32(50),a.bytes(o.key)),l.lengthDelimited!==!1&&a.ldelim()},(o,a)=>{const l={},c=a==null?o.len:o.pos+a;for(;o.pos>>3){case 1:l.from=o.bytes();break;case 2:l.data=o.bytes();break;case 3:l.sequenceNumber=o.bytes();break;case 4:l.topic=o.string();break;case 5:l.signature=o.bytes();break;case 6:l.key=o.bytes();break;default:o.skipType(u&7);break}}return l})),n),r.encode=o=>encodeMessage(o,r.codec()),r.decode=o=>decodeMessage(o,r.codec())}(e.Message||(e.Message={}));let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.subscriptions!=null)for(const a of r.subscriptions)n.uint32(10),e.SubOpts.codec().encode(a,n);if(r.messages!=null)for(const a of r.messages)n.uint32(18),e.Message.codec().encode(a,n);r.control!=null&&(n.uint32(26),ControlMessage.codec().encode(r.control,n)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={subscriptions:[],messages:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.subscriptions.push(e.SubOpts.codec().decode(r,r.uint32()));break;case 2:o.messages.push(e.Message.codec().decode(r,r.uint32()));break;case 3:o.control=ControlMessage.codec().decode(r,r.uint32());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(RPC||(RPC={}));var ControlMessage;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.ihave!=null)for(const a of r.ihave)n.uint32(10),ControlIHave.codec().encode(a,n);if(r.iwant!=null)for(const a of r.iwant)n.uint32(18),ControlIWant.codec().encode(a,n);if(r.graft!=null)for(const a of r.graft)n.uint32(26),ControlGraft.codec().encode(a,n);if(r.prune!=null)for(const a of r.prune)n.uint32(34),ControlPrune.codec().encode(a,n);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={ihave:[],iwant:[],graft:[],prune:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.ihave.push(ControlIHave.codec().decode(r,r.uint32()));break;case 2:o.iwant.push(ControlIWant.codec().decode(r,r.uint32()));break;case 3:o.graft.push(ControlGraft.codec().decode(r,r.uint32()));break;case 4:o.prune.push(ControlPrune.codec().decode(r,r.uint32()));break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ControlMessage||(ControlMessage={}));var ControlIHave;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.topic!=null&&(n.uint32(10),n.string(r.topic)),r.messageIDs!=null)for(const a of r.messageIDs)n.uint32(18),n.bytes(a);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={messageIDs:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.topic=r.string();break;case 2:o.messageIDs.push(r.bytes());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ControlIHave||(ControlIHave={}));var ControlIWant;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.messageIDs!=null)for(const a of r.messageIDs)n.uint32(10),n.bytes(a);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={messageIDs:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.messageIDs.push(r.bytes());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ControlIWant||(ControlIWant={}));var ControlGraft;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.topic!=null&&(n.uint32(10),n.string(r.topic)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.topic=r.string();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ControlGraft||(ControlGraft={}));var ControlPrune;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.topic!=null&&(n.uint32(10),n.string(r.topic)),r.peers!=null)for(const a of r.peers)n.uint32(18),PeerInfo.codec().encode(a,n);r.backoff!=null&&(n.uint32(24),n.uint64(r.backoff)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={peers:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.topic=r.string();break;case 2:o.peers.push(PeerInfo.codec().decode(r,r.uint32()));break;case 3:o.backoff=r.uint64();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ControlPrune||(ControlPrune={}));var PeerInfo;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.peerID!=null&&(n.uint32(10),n.bytes(r.peerID)),r.signedPeerRecord!=null&&(n.uint32(18),n.bytes(r.signedPeerRecord)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.peerID=r.bytes();break;case 2:o.signedPeerRecord=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(PeerInfo||(PeerInfo={}));const log$x=logger("libp2p:floodsub");class FloodSub extends PubSubBaseProtocol{constructor(r,n){super(r,{...n,canRelayMessage:!0,multicodecs:[multicodec]});Xe(this,"seenCache");this.seenCache=new SimpleTimeCache({validityMs:n?.seenTTL??3e4})}decodeRpc(r){return RPC.decode(r)}encodeRpc(r){return RPC.encode(r)}decodeMessage(r){return RPC.Message.decode(r)}encodeMessage(r){return RPC.Message.encode(r)}async processMessage(r,n){const o=await super.getMsgId(n),a=toString$5(o,"base64");this.seenCache.has(a)||(this.seenCache.put(a,!0),await super.processMessage(r,n))}async publishMessage(r,n){const o=this.getSubscribers(n.topic),a=[];return o==null||o.length===0?(log$x("no peers are subscribed to topic %s",n.topic),{recipients:a}):(o.forEach(l=>{if(this.components.peerId.equals(l)){log$x("not sending message on topic %s to myself",n.topic);return}if(l.equals(r)){log$x("not sending message on topic %s to sender %p",n.topic,l);return}log$x("publish msgs on topics %s %p",n.topic,l),a.push(l),this.send(l,{messages:[n]})}),{recipients:a})}}function floodsub(e={}){return t=>new FloodSub(t,e)}var RateLimiterAbstract_1=class{constructor(t={}){this.points=t.points,this.duration=t.duration,this.blockDuration=t.blockDuration,this.execEvenly=t.execEvenly,this.execEvenlyMinDelayMs=t.execEvenlyMinDelayMs,this.keyPrefix=t.keyPrefix}get points(){return this._points}set points(t){this._points=t>=0?t:4}get duration(){return this._duration}set duration(t){this._duration=typeof t>"u"?1:t}get msDuration(){return this.duration*1e3}get blockDuration(){return this._blockDuration}set blockDuration(t){this._blockDuration=typeof t>"u"?0:t}get msBlockDuration(){return this.blockDuration*1e3}get execEvenly(){return this._execEvenly}set execEvenly(t){this._execEvenly=typeof t>"u"?!1:Boolean(t)}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(t){this._execEvenlyMinDelayMs=typeof t>"u"?Math.ceil(this.msDuration/this.points):t}get keyPrefix(){return this._keyPrefix}set keyPrefix(t){if(typeof t>"u"&&(t="rlflx"),typeof t!="string")throw new Error("keyPrefix must be string");this._keyPrefix=t}_getKeySecDuration(t={}){return t&&t.customDuration>=0?t.customDuration:this.duration}getKey(t){return this.keyPrefix.length>0?`${this.keyPrefix}:${t}`:t}parseKey(t){return t.substring(this.keyPrefix.length)}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}},BlockedKeys_1$1=class{constructor(){this._keys={},this._addedKeysAmount=0}collectExpired(){const t=Date.now();Object.keys(this._keys).forEach(r=>{this._keys[r]<=t&&delete this._keys[r]}),this._addedKeysAmount=Object.keys(this._keys).length}add(t,r){this.addMs(t,r*1e3)}addMs(t,r){this._keys[t]=Date.now()+r,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(t){const r=this._keys[t];if(r&&r>=Date.now()){this.collectExpired();const n=Date.now();return r>=n?r-n:0}return 0}delete(t){t?delete this._keys[t]:Object.keys(this._keys).forEach(r=>{delete this._keys[r]})}};const BlockedKeys$1=BlockedKeys_1$1;var BlockedKeys_1=BlockedKeys$1,RateLimiterRes_1=class{constructor(t,r,n,o){this.remainingPoints=typeof t>"u"?0:t,this.msBeforeNext=typeof r>"u"?0:r,this.consumedPoints=typeof n>"u"?0:n,this.isFirstInDuration=typeof o>"u"?!1:o}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(t){return this._msBeforeNext=t,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(t){return this._remainingPoints=t,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(t){return this._consumedPoints=t,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(t){this._isFirstInDuration=Boolean(t)}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}};const RateLimiterAbstract$3=RateLimiterAbstract_1,BlockedKeys=BlockedKeys_1,RateLimiterRes$b=RateLimiterRes_1;var RateLimiterStoreAbstract_1=class extends RateLimiterAbstract$3{constructor(t={}){super(t),this.inMemoryBlockOnConsumed=t.inMemoryBlockOnConsumed,this.inMemoryBlockDuration=t.inMemoryBlockDuration,this.insuranceLimiter=t.insuranceLimiter,this._inMemoryBlockedKeys=new BlockedKeys}get client(){return this._client}set client(t){if(typeof t>"u")throw new Error("storeClient is not set");this._client=t}_afterConsume(t,r,n,o,a,l={}){const c=this._getRateLimiterRes(n,o,a);if(this.inMemoryBlockOnConsumed>0&&!(this.inMemoryBlockDuration>0)&&c.consumedPoints>=this.inMemoryBlockOnConsumed)return this._inMemoryBlockedKeys.addMs(n,c.msBeforeNext),c.consumedPoints>this.points?r(c):t(c);if(c.consumedPoints>this.points){let u=Promise.resolve();this.blockDuration>0&&c.consumedPoints<=this.points+o&&(c.msBeforeNext=this.msBlockDuration,u=this._block(n,c.consumedPoints,this.msBlockDuration,l)),this.inMemoryBlockOnConsumed>0&&c.consumedPoints>=this.inMemoryBlockOnConsumed&&(this._inMemoryBlockedKeys.add(n,this.inMemoryBlockDuration),c.msBeforeNext=this.msInMemoryBlockDuration),u.then(()=>{r(c)}).catch(g=>{r(g)})}else if(this.execEvenly&&c.msBeforeNext>0&&!c.isFirstInDuration){let u=Math.ceil(c.msBeforeNext/(c.remainingPoints+2));u{n(u)}).catch(u=>{o(u)}):o(t)}getInMemoryBlockMsBeforeExpire(t){return this.inMemoryBlockOnConsumed>0?this._inMemoryBlockedKeys.msBeforeExpire(t):0}get inMemoryBlockOnConsumed(){return this._inMemoryBlockOnConsumed}set inMemoryBlockOnConsumed(t){if(this._inMemoryBlockOnConsumed=t?parseInt(t):0,this.inMemoryBlockOnConsumed>0&&this.points>this.inMemoryBlockOnConsumed)throw new Error('inMemoryBlockOnConsumed option must be greater or equal "points" option')}get inMemoryBlockDuration(){return this._inMemoryBlockDuration}set inMemoryBlockDuration(t){if(this._inMemoryBlockDuration=t?parseInt(t):0,this.inMemoryBlockDuration>0&&this.inMemoryBlockOnConsumed===0)throw new Error("inMemoryBlockOnConsumed option must be set up")}get msInMemoryBlockDuration(){return this._inMemoryBlockDuration*1e3}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(t){if(typeof t<"u"&&!(t instanceof RateLimiterAbstract$3))throw new Error("insuranceLimiter must be instance of RateLimiterAbstract");this._insuranceLimiter=t,this._insuranceLimiter&&(this._insuranceLimiter.blockDuration=this.blockDuration,this._insuranceLimiter.execEvenly=this.execEvenly)}block(t,r,n={}){const o=r*1e3;return this._block(this.getKey(t),this.points+1,o,n)}set(t,r,n,o={}){const a=(n>=0?n:this.duration)*1e3;return this._block(this.getKey(t),r,a,o)}consume(t,r=1,n={}){return new Promise((o,a)=>{const l=this.getKey(t),c=this.getInMemoryBlockMsBeforeExpire(l);if(c>0)return a(new RateLimiterRes$b(0,c));this._upsert(l,r,this._getKeySecDuration(n)*1e3,!1,n).then(u=>{this._afterConsume(o,a,l,r,u)}).catch(u=>{this._handleError(u,"consume",o,a,t,r,n)})})}penalty(t,r=1,n={}){const o=this.getKey(t);return new Promise((a,l)=>{this._upsert(o,r,this._getKeySecDuration(n)*1e3,!1,n).then(c=>{a(this._getRateLimiterRes(o,r,c))}).catch(c=>{this._handleError(c,"penalty",a,l,t,r,n)})})}reward(t,r=1,n={}){const o=this.getKey(t);return new Promise((a,l)=>{this._upsert(o,-r,this._getKeySecDuration(n)*1e3,!1,n).then(c=>{a(this._getRateLimiterRes(o,-r,c))}).catch(c=>{this._handleError(c,"reward",a,l,t,r,n)})})}get(t,r={}){const n=this.getKey(t);return new Promise((o,a)=>{this._get(n,r).then(l=>{o(l===null||typeof l>"u"?null:this._getRateLimiterRes(n,0,l))}).catch(l=>{this._handleError(l,"get",o,a,t,r)})})}delete(t,r={}){const n=this.getKey(t);return new Promise((o,a)=>{this._delete(n,r).then(l=>{this._inMemoryBlockedKeys.delete(n),o(l)}).catch(l=>{this._handleError(l,"delete",o,a,t,r)})})}deleteInMemoryBlockedAll(){this._inMemoryBlockedKeys.delete()}_getRateLimiterRes(t,r,n){throw new Error("You have to implement the method '_getRateLimiterRes'!")}_block(t,r,n,o={}){return new Promise((a,l)=>{this._upsert(t,r,n,!0,o).then(()=>{a(new RateLimiterRes$b(0,n>0?n:-1,r))}).catch(c=>{this._handleError(c,"block",a,l,this.parseKey(t),n/1e3,o)})})}_get(t,r={}){throw new Error("You have to implement the method '_get'!")}_delete(t,r={}){throw new Error("You have to implement the method '_delete'!")}_upsert(t,r,n,o=!1,a={}){throw new Error("You have to implement the method '_upsert'!")}};const RateLimiterStoreAbstract$4=RateLimiterStoreAbstract_1,RateLimiterRes$a=RateLimiterRes_1,incrTtlLuaScript="redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') local consumed = redis.call('incrby', KEYS[1], ARGV[1]) local ttl = redis.call('pttl', KEYS[1]) if ttl == -1 then redis.call('expire', KEYS[1], ARGV[2]) ttl = 1000 * ARGV[2] end return {consumed, ttl} ";class RateLimiterRedis$1 extends RateLimiterStoreAbstract$4{constructor(t){super(t),this.client=t.storeClient,this._rejectIfRedisNotReady=!!t.rejectIfRedisNotReady,this.useRedisPackage=t.useRedisPackage,this.useRedis3AndLowerPackage=t.useRedis3AndLowerPackage,typeof this.client.defineCommand=="function"&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:incrTtlLuaScript})}_isRedisReady(){return this._rejectIfRedisNotReady?!(this.client.status&&this.client.status!=="ready"||typeof this.client.isReady=="function"&&!this.client.isReady()):!0}_getRateLimiterRes(t,r,n){let[o,a]=n;Array.isArray(o)&&([,o]=o,[,a]=a);const l=new RateLimiterRes$a;return l.consumedPoints=parseInt(o),l.isFirstInDuration=l.consumedPoints===r,l.remainingPoints=Math.max(this.points-l.consumedPoints,0),l.msBeforeNext=a,l}async _upsert(t,r,n,o=!1){if(!this._isRedisReady())throw new Error("Redis connection is not ready");const a=Math.floor(n/1e3),l=this.client.multi();return o?(a>0?!this.useRedisPackage&&!this.useRedis3AndLowerPackage?l.set(t,r,"EX",a):l.set(t,r,{EX:a}):l.set(t,r),!this.useRedisPackage&&!this.useRedis3AndLowerPackage?l.pttl(t).exec(!0):l.pTTL(t).exec(!0)):a>0?!this.useRedisPackage&&!this.useRedis3AndLowerPackage?this.client.rlflxIncr([t].concat([String(r),String(a)])):this.useRedis3AndLowerPackage?new Promise((c,u)=>{const g=function(b,x){return b?u(b):c(x)};typeof this.client.rlflxIncr=="function"?this.client.rlflxIncr(t,r,a,g):this.client.eval(incrTtlLuaScript,1,t,r,a,g)}):this.client.eval(incrTtlLuaScript,{keys:[t],arguments:[String(r),String(a)]}):!this.useRedisPackage&&!this.useRedis3AndLowerPackage?l.incrby(t,r).pttl(t).exec(!0):l.incrBy(t,r).pTTL(t).exec(!0)}async _get(t){if(!this._isRedisReady())throw new Error("Redis connection is not ready");return!this.useRedisPackage&&!this.useRedis3AndLowerPackage?this.client.multi().get(t).pttl(t).exec().then(r=>{const[[,n]]=r;return n===null?null:r}):this.client.multi().get(t).pTTL(t).exec(!0).then(r=>{const[n]=r;return n===null?null:r})}_delete(t){return this.client.del(t).then(r=>r>0)}}var RateLimiterRedis_1=RateLimiterRedis$1;const RateLimiterStoreAbstract$3=RateLimiterStoreAbstract_1,RateLimiterRes$9=RateLimiterRes_1;function getDriverVersion(e){try{const t=e.client?e.client:e,{version:r}=t.topology.s.options.metadata.driver,n=r.split(".").map(o=>parseInt(o));return{major:n[0],feature:n[1],patch:n[2]}}catch{return{major:0,feature:0,patch:0}}}class RateLimiterMongo$1 extends RateLimiterStoreAbstract$3{constructor(t){super(t),this.dbName=t.dbName,this.tableName=t.tableName,this.indexKeyPrefix=t.indexKeyPrefix,t.mongo?this.client=t.mongo:this.client=t.storeClient,typeof this.client.then=="function"?this.client.then(r=>{this.client=r,this._initCollection(),this._driverVersion=getDriverVersion(this.client)}):(this._initCollection(),this._driverVersion=getDriverVersion(this.client))}get dbName(){return this._dbName}set dbName(t){this._dbName=typeof t>"u"?RateLimiterMongo$1.getDbName():t}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(t){this._tableName=typeof t>"u"?this.keyPrefix:t}get client(){return this._client}set client(t){if(typeof t>"u")throw new Error("mongo is not set");this._client=t}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(t){this._indexKeyPrefix=t||{}}_initCollection(){const r=(typeof this.client.db=="function"?this.client.db(this.dbName):this.client).collection(this.tableName);r.createIndex({expire:-1},{expireAfterSeconds:0}),r.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=r}_getRateLimiterRes(t,r,n){const o=new RateLimiterRes$9;let a;return typeof n.value>"u"?a=n:a=n.value,o.isFirstInDuration=a.points===r,o.consumedPoints=a.points,o.remainingPoints=Math.max(this.points-o.consumedPoints,0),o.msBeforeNext=a.expire!==null?Math.max(new Date(a.expire).getTime()-Date.now(),0):-1,o}_upsert(t,r,n,o=!1,a={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const l=a.attrs||{};let c,u;o?(c={key:t},c=Object.assign(c,l),u={$set:{key:t,points:r,expire:n>0?new Date(Date.now()+n):null}},u.$set=Object.assign(u.$set,l)):(c={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:t},c=Object.assign(c,l),u={$setOnInsert:{key:t,expire:n>0?new Date(Date.now()+n):null},$inc:{points:r}},u.$setOnInsert=Object.assign(u.$setOnInsert,l));const g={upsert:!0};return this._driverVersion.major>=4||this._driverVersion.major===3&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?g.returnDocument="after":g.returnOriginal=!1,new Promise((b,x)=>{this._collection.findOneAndUpdate(c,u,g).then(S=>{b(S)}).catch(S=>{if(S&&S.code===11e3){const $=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:t},l),k={$set:Object.assign({key:t,points:r,expire:n>0?new Date(Date.now()+n):null},l)};this._collection.findOneAndUpdate($,k,g).then(T=>{b(T)}).catch(T=>{T&&T.code===11e3?this._upsert(t,r,n,o).then(D=>b(D)).catch(D=>x(D)):x(T)})}else x(S)})})}_get(t,r={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const n=r.attrs||{},o=Object.assign({key:t,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},n);return this._collection.findOne(o)}_delete(t,r={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const n=r.attrs||{},o=Object.assign({key:t},n);return this._collection.deleteOne(o).then(a=>a.deletedCount>0)}}var RateLimiterMongo_1=RateLimiterMongo$1;const RateLimiterStoreAbstract$2=RateLimiterStoreAbstract_1,RateLimiterRes$8=RateLimiterRes_1;class RateLimiterMySQL$1 extends RateLimiterStoreAbstract$2{constructor(t,r=null){super(t),this.client=t.storeClient,this.clientType=t.storeType,this.dbName=t.dbName,this.tableName=t.tableName,this.clearExpiredByTimeout=t.clearExpiredByTimeout,this.tableCreated=t.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),typeof r=="function"&&r()):this._createDbAndTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),typeof r=="function"&&r()}).catch(n=>{if(typeof r=="function")r(n);else throw n})}clearExpired(t){return new Promise(r=>{this._getConnection().then(n=>{n.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,t],()=>{this._releaseConnection(n),r()})}).catch(()=>{r()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":return new Promise((t,r)=>{this.client.getConnection((n,o)=>{if(n)return r(n);t(o)})});case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();default:return Promise.resolve(this.client)}}_releaseConnection(t){switch(this.clientType){case"pool":return t.release();case"sequelize":return this.client.connectionManager.releaseConnection(t);case"knex":return this.client.client.releaseConnection(t);default:return!0}}_createDbAndTable(){return new Promise((t,r)=>{this._getConnection().then(n=>{n.query(`CREATE DATABASE IF NOT EXISTS \`${this.dbName}\`;`,o=>{if(o)return this._releaseConnection(n),r(o);n.query(this._getCreateTableStmt(),a=>{if(a)return this._releaseConnection(n),r(a);this._releaseConnection(n),t()})})}).catch(n=>{r(n)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS \`${this.dbName}\`.\`${this.tableName}\` (\`key\` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\`points\` INT(9) NOT NULL default 0,\`expire\` BIGINT UNSIGNED,PRIMARY KEY (\`key\`)) ENGINE = INNODB;`}get clientType(){return this._clientType}set clientType(t){if(typeof t>"u")if(this.client.constructor.name==="Connection")t="connection";else if(this.client.constructor.name==="Pool")t="pool";else if(this.client.constructor.name==="Sequelize")t="sequelize";else throw new Error("storeType is not defined");this._clientType=t.toLowerCase()}get dbName(){return this._dbName}set dbName(t){this._dbName=typeof t>"u"?"rtlmtrflx":t}get tableName(){return this._tableName}set tableName(t){this._tableName=typeof t>"u"?this.keyPrefix:t}get tableCreated(){return this._tableCreated}set tableCreated(t){this._tableCreated=typeof t>"u"?!1:!!t}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(t){this._clearExpiredByTimeout=typeof t>"u"?!0:Boolean(t)}_getRateLimiterRes(t,r,n){const o=new RateLimiterRes$8,[a]=n;return o.isFirstInDuration=r===a.points,o.consumedPoints=o.isFirstInDuration?r:a.points,o.remainingPoints=Math.max(this.points-o.consumedPoints,0),o.msBeforeNext=a.expire?Math.max(a.expire-Date.now(),0):-1,o}_upsertTransaction(t,r,n,o,a){return new Promise((l,c)=>{t.query("BEGIN",u=>{if(u)return t.rollback(),c(u);const g=Date.now(),b=o>0?g+o:null;let x,S;a?(x=`INSERT INTO ??.?? VALUES (?, ?, ?) +`+c+t.substr(l+1),a=o-l-1,l=-1,++o}else(t[o]===" "||t[o]===" "||t[o]===",")&&(l=o);return t}function ltrim(e){return e.replace(/^\s+/,"")}var forge$a=forge$m,sha256$2=forge$a.sha256=forge$a.sha256||{};forge$a.md.sha256=forge$a.md.algorithms.sha256=sha256$2;sha256$2.create=function(){_initialized$2||_init$2();var e=null,t=forge$a.util.createBuffer(),r=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var o=n.messageLengthSize/4,a=0;a>>0,l>>>0];for(var c=n.fullMessageLength.length-1;c>=0;--c)n.fullMessageLength[c]+=l[1],l[1]=l[0]+(n.fullMessageLength[c]/4294967296>>>0),n.fullMessageLength[c]=n.fullMessageLength[c]>>>0,l[0]=l[1]/4294967296>>>0;return t.putBytes(o),_update$2(e,r,t),(t.read>2048||t.length()===0)&&t.compact(),n},n.digest=function(){var o=forge$a.util.createBuffer();o.putBytes(t.bytes());var a=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,l=a&n.blockLength-1;o.putBytes(_padding$2.substr(0,n.blockLength-l));for(var c,u,g=n.fullMessageLength[0]*8,b=0;b>>0,g+=u,o.putInt32(g>>>0),g=c>>>0;o.putInt32(g);var x={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};_update$2(x,r,o);var S=forge$a.util.createBuffer();return S.putInt32(x.h0),S.putInt32(x.h1),S.putInt32(x.h2),S.putInt32(x.h3),S.putInt32(x.h4),S.putInt32(x.h5),S.putInt32(x.h6),S.putInt32(x.h7),S},n};var _padding$2=null,_initialized$2=!1,_k$1=null;function _init$2(){_padding$2=String.fromCharCode(128),_padding$2+=forge$a.util.fillString(String.fromCharCode(0),64),_k$1=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],_initialized$2=!0}function _update$2(e,t,r){for(var n,o,a,l,c,u,g,b,x,S,$,k,T,D,I,O=r.length();O>=64;){for(g=0;g<16;++g)t[g]=r.getInt32();for(;g<64;++g)n=t[g-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,o=t[g-15],o=(o>>>7|o<<25)^(o>>>18|o<<14)^o>>>3,t[g]=n+t[g-7]+o+t[g-16]|0;for(b=e.h0,x=e.h1,S=e.h2,$=e.h3,k=e.h4,T=e.h5,D=e.h6,I=e.h7,g=0;g<64;++g)l=(k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7),c=D^k&(T^D),a=(b>>>2|b<<30)^(b>>>13|b<<19)^(b>>>22|b<<10),u=b&x|S&(b^x),n=I+l+c+_k$1[g]+t[g],o=a+u,I=D,D=T,T=k,k=$+n>>>0,$=S,S=x,x=b,b=n+o>>>0;e.h0=e.h0+b|0,e.h1=e.h1+x|0,e.h2=e.h2+S|0,e.h3=e.h3+$|0,e.h4=e.h4+k|0,e.h5=e.h5+T|0,e.h6=e.h6+D|0,e.h7=e.h7+I|0,O-=64}}var forge$9=forge$m,_crypto$1=null;forge$9.util.isNodejs&&!forge$9.options.usePureJavaScript&&!process.versions["node-webkit"]&&(_crypto$1=require$$6);var prng=forge$9.prng=forge$9.prng||{};prng.create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,n=new Array(32),o=0;o<32;++o)n[o]=r.create();t.pools=n,t.pool=0,t.generate=function(g,b){if(!b)return t.generateSync(g);var x=t.plugin.cipher,S=t.plugin.increment,$=t.plugin.formatKey,k=t.plugin.formatSeed,T=forge$9.util.createBuffer();t.key=null,D();function D(I){if(I)return b(I);if(T.length()>=g)return b(null,T.getBytes(g));if(t.generated>1048575&&(t.key=null),t.key===null)return forge$9.util.nextTick(function(){a(D)});var O=x(t.key,t.seed);t.generated+=O.length,T.putBytes(O),t.key=$(x(t.key,S(t.seed))),t.seed=k(x(t.key,t.seed)),forge$9.util.setImmediate(D)}},t.generateSync=function(g){var b=t.plugin.cipher,x=t.plugin.increment,S=t.plugin.formatKey,$=t.plugin.formatSeed;t.key=null;for(var k=forge$9.util.createBuffer();k.length()1048575&&(t.key=null),t.key===null&&l();var T=b(t.key,t.seed);t.generated+=T.length,k.putBytes(T),t.key=S(b(t.key,x(t.seed))),t.seed=$(b(t.key,t.seed))}return k.getBytes(g)};function a(g){if(t.pools[0].messageLength>=32)return c(),g();var b=32-t.pools[0].messageLength<<5;t.seedFile(b,function(x,S){if(x)return g(x);t.collect(S),c(),g()})}function l(){if(t.pools[0].messageLength>=32)return c();var g=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(g)),c()}function c(){t.reseeds=t.reseeds===4294967295?0:t.reseeds+1;var g=t.plugin.md.create();g.update(t.keyBytes);for(var b=1,x=0;x<32;++x)t.reseeds%b===0&&(g.update(t.pools[x].digest().getBytes()),t.pools[x].start()),b=b<<1;t.keyBytes=g.digest().getBytes(),g.start(),g.update(t.keyBytes);var S=g.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(S),t.generated=0}function u(g){var b=null,x=forge$9.util.globalScope,S=x.crypto||x.msCrypto;S&&S.getRandomValues&&(b=function(ne){return S.getRandomValues(ne)});var $=forge$9.util.createBuffer();if(b)for(;$.length()>16),O+=(I&32767)<<16,O+=I>>15,O=(O&2147483647)+(O>>31),ee=O&4294967295;for(var D=0;D<3;++D)N=ee>>>(D<<3),N^=Math.floor(Math.random()*256),$.putByte(N&255)}return $.getBytes(g)}return _crypto$1?(t.seedFile=function(g,b){_crypto$1.randomBytes(g,function(x,S){if(x)return b(x);b(null,S.toString())})},t.seedFileSync=function(g){return _crypto$1.randomBytes(g).toString()}):(t.seedFile=function(g,b){try{b(null,u(g))}catch(x){b(x)}},t.seedFileSync=u),t.collect=function(g){for(var b=g.length,x=0;x>S&255);t.collect(x)},t.registerWorker=function(g){if(g===self)t.seedFile=function(x,S){function $(k){var T=k.data;T.forge&&T.forge.prng&&(self.removeEventListener("message",$),S(T.forge.prng.err,T.forge.prng.bytes))}self.addEventListener("message",$),self.postMessage({forge:{prng:{needed:x}}})};else{var b=function(x){var S=x.data;S.forge&&S.forge.prng&&t.seedFile(S.forge.prng.needed,function($,k){g.postMessage({forge:{prng:{err:$,bytes:k}}})})};g.addEventListener("message",b)}},t};var forge$8=forge$m;(function(){forge$8.random&&forge$8.random.getBytes||function(e){var t={},r=new Array(4),n=forge$8.util.createBuffer();t.formatKey=function(x){var S=forge$8.util.createBuffer(x);return x=new Array(4),x[0]=S.getInt32(),x[1]=S.getInt32(),x[2]=S.getInt32(),x[3]=S.getInt32(),forge$8.aes._expandKey(x,!1)},t.formatSeed=function(x){var S=forge$8.util.createBuffer(x);return x=new Array(4),x[0]=S.getInt32(),x[1]=S.getInt32(),x[2]=S.getInt32(),x[3]=S.getInt32(),x},t.cipher=function(x,S){return forge$8.aes._updateBlock(x,S,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},t.increment=function(x){return++x[3],x},t.md=forge$8.md.sha256;function o(){var x=forge$8.prng.create(t);return x.getBytes=function(S,$){return x.generate(S,$)},x.getBytesSync=function(S){return x.generate(S)},x}var a=o(),l=null,c=forge$8.util.globalScope,u=c.crypto||c.msCrypto;if(u&&u.getRandomValues&&(l=function(x){return u.getRandomValues(x)}),!forge$8.util.isNodejs&&!l){if(a.collectInt(+new Date,32),typeof navigator<"u"){var g="";for(var b in navigator)try{typeof navigator[b]=="string"&&(g+=navigator[b])}catch{}a.collect(g),g=null}e&&(e().mousemove(function(x){a.collectInt(x.clientX,16),a.collectInt(x.clientY,16)}),e().keypress(function(x){a.collectInt(x.charCode,8)}))}if(!forge$8.random)forge$8.random=a;else for(var b in a)forge$8.random[b]=a[b];forge$8.random.createInstance=o}(typeof jQuery<"u"?jQuery:null)})();var forge$7=forge$m,piTable=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],s$4=[1,2,3,5],rol=function(e,t){return e<>16-t},ror=function(e,t){return(e&65535)>>t|e<<16-t&65535};forge$7.rc2=forge$7.rc2||{};forge$7.rc2.expandKey=function(e,t){typeof e=="string"&&(e=forge$7.util.createBuffer(e)),t=t||128;var r=e,n=e.length(),o=t,a=Math.ceil(o/8),l=255>>(o&7),c;for(c=n;c<128;c++)r.putByte(piTable[r.at(c-1)+r.at(c-n)&255]);for(r.setAt(128-a,piTable[r.at(128-a)&l]),c=127-a;c>=0;c--)r.setAt(c,piTable[r.at(c+1)^r.at(c+a)]);return r};var createCipher=function(e,t,r){var n=!1,o=null,a=null,l=null,c,u,g,b,x=[];for(e=forge$7.rc2.expandKey(e,t),g=0;g<64;g++)x.push(e.getInt16Le());r?(c=function(k){for(g=0;g<4;g++)k[g]+=x[b]+(k[(g+3)%4]&k[(g+2)%4])+(~k[(g+3)%4]&k[(g+1)%4]),k[g]=rol(k[g],s$4[g]),b++},u=function(k){for(g=0;g<4;g++)k[g]+=x[k[(g+3)%4]&63]}):(c=function(k){for(g=3;g>=0;g--)k[g]=ror(k[g],s$4[g]),k[g]-=x[b]+(k[(g+3)%4]&k[(g+2)%4])+(~k[(g+3)%4]&k[(g+1)%4]),b--},u=function(k){for(g=3;g>=0;g--)k[g]-=x[k[(g+3)%4]&63]});var S=function(k){var T=[];for(g=0;g<4;g++){var D=o.getInt16Le();l!==null&&(r?D^=l.getInt16Le():l.putInt16Le(D)),T.push(D&65535)}b=r?0:63;for(var I=0;I=8;)S([[5,c],[1,u],[6,c],[1,u],[5,c]])},finish:function(k){var T=!0;if(r)if(k)T=k(8,o,!r);else{var D=o.length()===8?8:8-o.length();o.fillWithByte(D,D)}if(T&&(n=!0,$.update()),!r&&(T=o.length()===0,T))if(k)T=k(8,a,!r);else{var I=a.length(),O=a.at(I-1);O>I?T=!1:a.truncate(O)}return T}},$};forge$7.rc2.startEncrypting=function(e,t,r){var n=forge$7.rc2.createEncryptionCipher(e,128);return n.start(t,r),n};forge$7.rc2.createEncryptionCipher=function(e,t){return createCipher(e,t,!0)};forge$7.rc2.startDecrypting=function(e,t,r){var n=forge$7.rc2.createDecryptionCipher(e,128);return n.start(t,r),n};forge$7.rc2.createDecryptionCipher=function(e,t){return createCipher(e,t,!1)};var forge$6=forge$m;forge$6.jsbn=forge$6.jsbn||{};var dbits;function BigInteger$2(e,t,r){this.data=[],e!=null&&(typeof e=="number"?this.fromNumber(e,t,r):t==null&&typeof e!="string"?this.fromString(e,256):this.fromString(e,t))}forge$6.jsbn.BigInteger=BigInteger$2;function nbi(){return new BigInteger$2(null)}function am1(e,t,r,n,o,a){for(;--a>=0;){var l=t*this.data[e++]+r.data[n]+o;o=Math.floor(l/67108864),r.data[n++]=l&67108863}return o}function am2(e,t,r,n,o,a){for(var l=t&32767,c=t>>15;--a>=0;){var u=this.data[e]&32767,g=this.data[e++]>>15,b=c*u+g*l;u=l*u+((b&32767)<<15)+r.data[n]+(o&1073741823),o=(u>>>30)+(b>>>15)+c*g+(o>>>30),r.data[n++]=u&1073741823}return o}function am3(e,t,r,n,o,a){for(var l=t&16383,c=t>>14;--a>=0;){var u=this.data[e]&16383,g=this.data[e++]>>14,b=c*u+g*l;u=l*u+((b&16383)<<14)+r.data[n]+o,o=(u>>28)+(b>>14)+c*g,r.data[n++]=u&268435455}return o}typeof navigator>"u"?(BigInteger$2.prototype.am=am3,dbits=28):navigator.appName=="Microsoft Internet Explorer"?(BigInteger$2.prototype.am=am2,dbits=30):navigator.appName!="Netscape"?(BigInteger$2.prototype.am=am1,dbits=26):(BigInteger$2.prototype.am=am3,dbits=28);BigInteger$2.prototype.DB=dbits;BigInteger$2.prototype.DM=(1<=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s}function bnpFromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0}function nbv(e){var t=nbi();return t.fromInt(e),t}function bnpFromString(e,t){var r;if(t==16)r=4;else if(t==8)r=3;else if(t==256)r=8;else if(t==2)r=1;else if(t==32)r=5;else if(t==4)r=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var n=e.length,o=!1,a=0;--n>=0;){var l=r==8?e[n]&255:intAt(e,n);if(l<0){e.charAt(n)=="-"&&(o=!0);continue}o=!1,a==0?this.data[this.t++]=l:a+r>this.DB?(this.data[this.t-1]|=(l&(1<>this.DB-a):this.data[this.t-1]|=l<=this.DB&&(a-=this.DB)}r==8&&(e[0]&128)!=0&&(this.s=-1,a>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t}function bnToString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var r=(1<0)for(c>c)>0&&(o=!0,a=int2char(n));l>=0;)c>(c+=this.DB-t)):(n=this.data[l]>>(c-=t)&r,c<=0&&(c+=this.DB,--l)),n>0&&(o=!0),o&&(a+=int2char(n));return o?a:"0"}function bnNegate(){var e=nbi();return BigInteger$2.ZERO.subTo(this,e),e}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(e){var t=this.s-e.s;if(t!=0)return t;var r=this.t;if(t=r-e.t,t!=0)return this.s<0?-t:t;for(;--r>=0;)if((t=this.data[r]-e.data[r])!=0)return t;return 0}function nbits(e){var t=1,r;return(r=e>>>16)!=0&&(e=r,t+=16),(r=e>>8)!=0&&(e=r,t+=8),(r=e>>4)!=0&&(e=r,t+=4),(r=e>>2)!=0&&(e=r,t+=2),(r=e>>1)!=0&&(e=r,t+=1),t}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this.data[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s}function bnpDRShiftTo(e,t){for(var r=e;r=0;--c)t.data[c+a+1]=this.data[c]>>n|l,l=(this.data[c]&o)<=0;--c)t.data[c]=0;t.data[a]=l,t.t=this.t+a+1,t.s=this.s,t.clamp()}function bnpRShiftTo(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t){t.t=0;return}var n=e%this.DB,o=this.DB-n,a=(1<>n;for(var l=r+1;l>n;n>0&&(t.data[this.t-r-1]|=(this.s&a)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()}function bnpMultiplyTo(e,t){var r=this.abs(),n=e.abs(),o=r.t;for(t.t=o+n.t;--o>=0;)t.data[o]=0;for(o=0;o=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()}function bnpDivRemTo(e,t,r){var n=e.abs();if(!(n.t<=0)){var o=this.abs();if(o.t0?(n.lShiftTo(u,a),o.lShiftTo(u,r)):(n.copyTo(a),o.copyTo(r));var g=a.t,b=a.data[g-1];if(b!=0){var x=b*(1<1?a.data[g-2]>>this.F2:0),S=this.FV/x,$=(1<=0&&(r.data[r.t++]=1,r.subTo(I,r)),BigInteger$2.ONE.dlShiftTo(g,I),I.subTo(a,a);a.t=0;){var O=r.data[--T]==b?this.DM:Math.floor(r.data[T]*S+(r.data[T-1]+k)*$);if((r.data[T]+=a.am(0,O,r,D,0,g))0&&r.rShiftTo(u,r),l<0&&BigInteger$2.ZERO.subTo(r,r)}}}function bnMod(e){var t=nbi();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(BigInteger$2.ZERO)>0&&e.subTo(t,t),t}function Classic(e){this.m=e}function cConvert(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function cRevert(e){return e}function cReduce(e){e.divRemTo(this.m,null,e)}function cMulTo(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function cSqrTo(e,t){e.squareTo(t),this.reduce(t)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1)return 0;var e=this.data[0];if((e&1)==0)return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Montgomery(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(t,t),t}function montRevert(e){var t=nbi();return e.copyTo(t),this.reduce(t),t}function montReduce(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function montSqrTo(e,t){e.squareTo(t),this.reduce(t)}function montMulTo(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return(this.t>0?this.data[0]&1:this.s)==0}function bnpExp(e,t){if(e>4294967295||e<1)return BigInteger$2.ONE;var r=nbi(),n=nbi(),o=t.convert(this),a=nbits(e)-1;for(o.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,o,r);else{var l=r;r=n,n=l}return t.revert(r)}function bnModPowInt(e,t){var r;return e<256||t.isEven()?r=new Classic(t):r=new Montgomery(t),this.exp(e,r)}BigInteger$2.prototype.copyTo=bnpCopyTo;BigInteger$2.prototype.fromInt=bnpFromInt;BigInteger$2.prototype.fromString=bnpFromString;BigInteger$2.prototype.clamp=bnpClamp;BigInteger$2.prototype.dlShiftTo=bnpDLShiftTo;BigInteger$2.prototype.drShiftTo=bnpDRShiftTo;BigInteger$2.prototype.lShiftTo=bnpLShiftTo;BigInteger$2.prototype.rShiftTo=bnpRShiftTo;BigInteger$2.prototype.subTo=bnpSubTo;BigInteger$2.prototype.multiplyTo=bnpMultiplyTo;BigInteger$2.prototype.squareTo=bnpSquareTo;BigInteger$2.prototype.divRemTo=bnpDivRemTo;BigInteger$2.prototype.invDigit=bnpInvDigit;BigInteger$2.prototype.isEven=bnpIsEven;BigInteger$2.prototype.exp=bnpExp;BigInteger$2.prototype.toString=bnToString;BigInteger$2.prototype.negate=bnNegate;BigInteger$2.prototype.abs=bnAbs;BigInteger$2.prototype.compareTo=bnCompareTo;BigInteger$2.prototype.bitLength=bnBitLength;BigInteger$2.prototype.mod=bnMod;BigInteger$2.prototype.modPowInt=bnModPowInt;BigInteger$2.ZERO=nbv(0);BigInteger$2.ONE=nbv(1);function bnClone(){var e=nbi();return this.copyTo(e),e}function bnIntValue(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return this.t==0?this.s:this.data[0]<<16>>16}function bnpChunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function bnSigNum(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function bnpToRadix(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=nbv(r),o=nbi(),a=nbi(),l="";for(this.divRemTo(n,o,a);o.signum()>0;)l=(r+a.intValue()).toString(e).substr(1)+l,o.divRemTo(n,o,a);return a.intValue().toString(e)+l}function bnpFromRadix(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),o=!1,a=0,l=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(l,0),a=0,l=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(l,0)),o&&BigInteger$2.ZERO.subTo(this,this)}function bnpFromNumber(e,t,r){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(BigInteger$2.ONE.shiftLeft(e-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(BigInteger$2.ONE.shiftLeft(e-1),this);else{var n=new Array,o=e&7;n.length=(e>>3)+1,t.nextBytes(n),o>0?n[0]&=(1<0)for(r>r)!=(this.s&this.DM)>>r&&(t[o++]=n|this.s<=0;)r<8?(n=(this.data[e]&(1<>(r+=this.DB-8)):(n=this.data[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),(n&128)!=0&&(n|=-256),o==0&&(this.s&128)!=(n&128)&&++o,(o>0||n!=this.s)&&(t[o++]=n);return t}function bnEquals(e){return this.compareTo(e)==0}function bnMin(e){return this.compareTo(e)<0?this:e}function bnMax(e){return this.compareTo(e)>0?this:e}function bnpBitwiseTo(e,t,r){var n,o,a=Math.min(e.t,this.t);for(n=0;n>=16,t+=16),(e&255)==0&&(e>>=8,t+=8),(e&15)==0&&(e>>=4,t+=4),(e&3)==0&&(e>>=2,t+=2),(e&1)==0&&++t,t}function bnGetLowestSetBit(){for(var e=0;e=this.t?this.s!=0:(this.data[t]&1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()}function bnAdd(e){var t=nbi();return this.addTo(e,t),t}function bnSubtract(e){var t=nbi();return this.subTo(e,t),t}function bnMultiply(e){var t=nbi();return this.multiplyTo(e,t),t}function bnDivide(e){var t=nbi();return this.divRemTo(e,t,null),t}function bnRemainder(e){var t=nbi();return this.divRemTo(e,null,t),t}function bnDivideAndRemainder(e){var t=nbi(),r=nbi();return this.divRemTo(e,t,r),new Array(t,r)}function bnpDMultiply(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(e,t){if(e!=0){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}}function NullExp(){}function nNop(e){return e}function nMulTo(e,t,r){e.multiplyTo(t,r)}function nSqrTo(e,t){e.squareTo(t)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(e){return this.exp(e,new NullExp)}function bnpMultiplyLowerTo(e,t,r){var n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;var o;for(o=r.t-this.t;n=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=nbi();return e.copyTo(t),this.reduce(t),t}function barrettRevert(e){return e}function barrettReduce(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function barrettSqrTo(e,t){e.squareTo(t),this.reduce(t)}function barrettMulTo(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(e,t){var r=e.bitLength(),n,o=nbv(1),a;if(r<=0)return o;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?a=new Classic(t):t.isEven()?a=new Barrett(t):a=new Montgomery(t);var l=new Array,c=3,u=n-1,g=(1<1){var b=nbi();for(a.sqrTo(l[1],b);c<=g;)l[c]=nbi(),a.mulTo(b,l[c-2],l[c]),c+=2}var x=e.t-1,S,$=!0,k=nbi(),T;for(r=nbits(e.data[x])-1;x>=0;){for(r>=u?S=e.data[x]>>r-u&g:(S=(e.data[x]&(1<0&&(S|=e.data[x-1]>>this.DB+r-u)),c=n;(S&1)==0;)S>>=1,--c;if((r-=c)<0&&(r+=this.DB,--x),$)l[S].copyTo(o),$=!1;else{for(;c>1;)a.sqrTo(o,k),a.sqrTo(k,o),c-=2;c>0?a.sqrTo(o,k):(T=o,o=k,k=T),a.mulTo(k,l[S],o)}for(;x>=0&&(e.data[x]&1<0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(o=t.getLowestSetBit())>0&&t.rShiftTo(o,t),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r}function bnpModInt(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(t==0)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r}function bnModInverse(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return BigInteger$2.ZERO;for(var r=e.clone(),n=this.clone(),o=nbv(1),a=nbv(0),l=nbv(0),c=nbv(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),t?((!o.isEven()||!a.isEven())&&(o.addTo(this,o),a.subTo(e,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?((!l.isEven()||!c.isEven())&&(l.addTo(this,l),c.subTo(e,c)),l.rShiftTo(1,l)):c.isEven()||c.subTo(e,c),c.rShiftTo(1,c);r.compareTo(n)>=0?(r.subTo(n,r),t&&o.subTo(l,o),a.subTo(c,a)):(n.subTo(r,n),t&&l.subTo(o,l),c.subTo(a,c))}if(n.compareTo(BigInteger$2.ONE)!=0)return BigInteger$2.ZERO;if(c.compareTo(e)>=0)return c.subtract(e);if(c.signum()<0)c.addTo(e,c);else return c;return c.signum()<0?c.add(e):c}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var t,r=this.abs();if(r.t==1&&r.data[0]<=lowprimes[lowprimes.length-1]){for(t=0;t=0);var c=a.modPow(n,this);if(c.compareTo(BigInteger$2.ONE)!=0&&c.compareTo(t)!=0){for(var u=1;u++>>0,l>>>0];for(var c=n.fullMessageLength.length-1;c>=0;--c)n.fullMessageLength[c]+=l[1],l[1]=l[0]+(n.fullMessageLength[c]/4294967296>>>0),n.fullMessageLength[c]=n.fullMessageLength[c]>>>0,l[0]=l[1]/4294967296>>>0;return t.putBytes(o),_update$1(e,r,t),(t.read>2048||t.length()===0)&&t.compact(),n},n.digest=function(){var o=forge$5.util.createBuffer();o.putBytes(t.bytes());var a=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,l=a&n.blockLength-1;o.putBytes(_padding$1.substr(0,n.blockLength-l));for(var c,u,g=n.fullMessageLength[0]*8,b=0;b>>0,g+=u,o.putInt32(g>>>0),g=c>>>0;o.putInt32(g);var x={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};_update$1(x,r,o);var S=forge$5.util.createBuffer();return S.putInt32(x.h0),S.putInt32(x.h1),S.putInt32(x.h2),S.putInt32(x.h3),S.putInt32(x.h4),S},n};var _padding$1=null,_initialized$1=!1;function _init$1(){_padding$1=String.fromCharCode(128),_padding$1+=forge$5.util.fillString(String.fromCharCode(0),64),_initialized$1=!0}function _update$1(e,t,r){for(var n,o,a,l,c,u,g,b,x=r.length();x>=64;){for(o=e.h0,a=e.h1,l=e.h2,c=e.h3,u=e.h4,b=0;b<16;++b)n=r.getInt32(),t[b]=n,g=c^a&(l^c),n=(o<<5|o>>>27)+g+u+1518500249+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;for(;b<20;++b)n=t[b-3]^t[b-8]^t[b-14]^t[b-16],n=n<<1|n>>>31,t[b]=n,g=c^a&(l^c),n=(o<<5|o>>>27)+g+u+1518500249+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;for(;b<32;++b)n=t[b-3]^t[b-8]^t[b-14]^t[b-16],n=n<<1|n>>>31,t[b]=n,g=a^l^c,n=(o<<5|o>>>27)+g+u+1859775393+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;for(;b<40;++b)n=t[b-6]^t[b-16]^t[b-28]^t[b-32],n=n<<2|n>>>30,t[b]=n,g=a^l^c,n=(o<<5|o>>>27)+g+u+1859775393+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;for(;b<60;++b)n=t[b-6]^t[b-16]^t[b-28]^t[b-32],n=n<<2|n>>>30,t[b]=n,g=a&l|c&(a^l),n=(o<<5|o>>>27)+g+u+2400959708+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;for(;b<80;++b)n=t[b-6]^t[b-16]^t[b-28]^t[b-32],n=n<<2|n>>>30,t[b]=n,g=a^l^c,n=(o<<5|o>>>27)+g+u+3395469782+n,u=c,c=l,l=(a<<30|a>>>2)>>>0,a=o,o=n;e.h0=e.h0+o|0,e.h1=e.h1+a|0,e.h2=e.h2+l|0,e.h3=e.h3+c|0,e.h4=e.h4+u|0,x-=64}}var forge$4=forge$m,pkcs1=forge$4.pkcs1=forge$4.pkcs1||{};pkcs1.encode_rsa_oaep=function(e,t,r){var n,o,a,l;typeof r=="string"?(n=r,o=arguments[3]||void 0,a=arguments[4]||void 0):r&&(n=r.label||void 0,o=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(l=r.mgf1.md)),a?a.start():a=forge$4.md.sha1.create(),l||(l=a);var c=Math.ceil(e.n.bitLength()/8),u=c-2*a.digestLength-2;if(t.length>u){var g=new Error("RSAES-OAEP input message length is too long.");throw g.length=t.length,g.maxLength=u,g}n||(n=""),a.update(n,"raw");for(var b=a.digest(),x="",S=u-t.length,$=0;$>24&255,a>>16&255,a>>8&255,a&255);r.start(),r.update(e+l),n+=r.digest().getBytes()}return n.substring(0,t)}var forge$3=forge$m;(function(){if(forge$3.prime)return;var e=forge$3.prime=forge$3.prime||{},t=forge$3.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new t(null);n.fromInt(30);var o=function(x,S){return x|S};e.generateProbablePrime=function(x,S,$){typeof S=="function"&&($=S,S={}),S=S||{};var k=S.algorithm||"PRIMEINC";typeof k=="string"&&(k={name:k}),k.options=k.options||{};var T=S.prng||forge$3.random,D={nextBytes:function(I){for(var O=T.getBytesSync(I.length),N=0;NS&&(x=g(S,$)),x.isProbablePrime(T))return I(null,x);x.dAddOffset(r[k++%8],0)}while(D<0||+new Date-O"u")return l(x,S,$,k);var T=g(x,S),D=$.workers,I=$.workLoad||100,O=I*30/8,N=$.workerScript||"forge/prime.worker.js";if(D===-1)return forge$3.util.estimateCores(function(ne,B){ne&&(B=2),D=B-1,ee()});ee();function ee(){D=Math.max(1,D);for(var ne=[],B=0;Bx&&(T=g(x,S));var _e=T.toString(16);xe.target.postMessage({hex:_e,workLoad:I}),T.dAddOffset(O,0)}}}}function g(x,S){var $=new t(x,S),k=x-1;return $.testBit(k)||$.bitwiseTo(t.ONE.shiftLeft(k),o,$),$.dAddOffset(31-$.mod(n).byteValue(),0),$}function b(x){return x<=100?27:x<=150?18:x<=200?15:x<=250?12:x<=300?9:x<=350?8:x<=400?7:x<=500?6:x<=600?5:x<=800?4:x<=1250?3:2}})();var forge$2=forge$m;if(typeof BigInteger$1>"u")var BigInteger$1=forge$2.jsbn.BigInteger;var _crypto=forge$2.util.isNodejs?require$$6:null,asn1$1=forge$2.asn1,util$5=forge$2.util;forge$2.pki=forge$2.pki||{};forge$2.pki.rsa=forge$2.rsa=forge$2.rsa||{};var pki$1=forge$2.pki,GCD_30_DELTA=[6,4,2,4,2,4,6,2],privateKeyValidator={name:"PrivateKeyInfo",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},rsaPrivateKeyValidator={name:"RSAPrivateKey",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},rsaPublicKeyValidator={name:"RSAPublicKey",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},publicKeyValidator=forge$2.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},digestInfoValidator={name:"DigestInfo",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:asn1$1.Class.UNIVERSAL,type:asn1$1.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},emsaPkcs1v15encode=function(e){var t;if(e.algorithm in pki$1.oids)t=pki$1.oids[e.algorithm];else{var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}var n=asn1$1.oidToDer(t).getBytes(),o=asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[]),a=asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[]);a.value.push(asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.OID,!1,n)),a.value.push(asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.NULL,!1,""));var l=asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.OCTETSTRING,!1,e.digest().getBytes());return o.value.push(a),o.value.push(l),asn1$1.toDer(o).getBytes()},_modPow=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);t.dP||(t.dP=t.d.mod(t.p.subtract(BigInteger$1.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(BigInteger$1.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));var n;do n=new BigInteger$1(forge$2.util.bytesToHex(forge$2.random.getBytes(t.n.bitLength()/8)),16);while(n.compareTo(t.n)>=0||!n.gcd(t.n).equals(BigInteger$1.ONE));e=e.multiply(n.modPow(t.e,t.n)).mod(t.n);for(var o=e.mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);o.compareTo(a)<0;)o=o.add(t.p);var l=o.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return l=l.multiply(n.modInverse(t.n)).mod(t.n),l};pki$1.rsa.encrypt=function(e,t,r){var n=r,o,a=Math.ceil(t.n.bitLength()/8);r!==!1&&r!==!0?(n=r===2,o=_encodePkcs1_v1_5(e,t,r)):(o=forge$2.util.createBuffer(),o.putBytes(e));for(var l=new BigInteger$1(o.toHex(),16),c=_modPow(l,t,n),u=c.toString(16),g=forge$2.util.createBuffer(),b=a-Math.ceil(u.length/2);b>0;)g.putByte(0),--b;return g.putBytes(forge$2.util.hexToBytes(u)),g.getBytes()};pki$1.rsa.decrypt=function(e,t,r,n){var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=o,a}var l=new BigInteger$1(forge$2.util.createBuffer(e).toHex(),16);if(l.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var c=_modPow(l,t,r),u=c.toString(16),g=forge$2.util.createBuffer(),b=o-Math.ceil(u.length/2);b>0;)g.putByte(0),--b;return g.putBytes(forge$2.util.hexToBytes(u)),n!==!1?_decodePkcs1_v1_5(g.getBytes(),t,r):g.getBytes()};pki$1.rsa.createKeyPairGenerationState=function(e,t,r){typeof e=="string"&&(e=parseInt(e,10)),e=e||2048,r=r||{};var n=r.prng||forge$2.random,o={nextBytes:function(c){for(var u=n.getBytesSync(c.length),g=0;g>1,pBits:e-(e>>1),pqState:0,num:null,keys:null},l.e.fromInt(l.eInt);else throw new Error("Invalid key generation algorithm: "+a);return l};pki$1.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new BigInteger$1(null);r.fromInt(30);for(var n=0,o=function(x,S){return x|S},a=+new Date,l,c=0;e.keys===null&&(t<=0||cu?e.pqState=0:e.num.isProbablePrime(_getMillerRabinTests(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(GCD_30_DELTA[n++%8],0):e.pqState===2?e.pqState=e.num.subtract(BigInteger$1.ONE).gcd(e.e).compareTo(BigInteger$1.ONE)===0?3:0:e.pqState===3&&(e.pqState=0,e.p===null?e.p=e.num:e.q=e.num,e.p!==null&&e.q!==null&&++e.state,e.num=null)}else if(e.state===1)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(e.state===2)e.p1=e.p.subtract(BigInteger$1.ONE),e.q1=e.q.subtract(BigInteger$1.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(e.state===3)e.phi.gcd(e.e).compareTo(BigInteger$1.ONE)===0?++e.state:(e.p=null,e.q=null,e.state=0);else if(e.state===4)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(e.state===5){var b=e.e.modInverse(e.phi);e.keys={privateKey:pki$1.rsa.setPrivateKey(e.n,e.e,b,e.p,e.q,b.mod(e.p1),b.mod(e.q1),e.q.modInverse(e.p)),publicKey:pki$1.rsa.setPublicKey(e.n,e.e)}}l=+new Date,c+=l-a,a=l}return e.keys!==null};pki$1.rsa.generateKeyPair=function(e,t,r,n){if(arguments.length===1?typeof e=="object"?(r=e,e=void 0):typeof e=="function"&&(n=e,e=void 0):arguments.length===2?typeof e=="number"?typeof t=="function"?(n=t,t=void 0):typeof t!="number"&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):arguments.length===3&&(typeof t=="number"?typeof r=="function"&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},e===void 0&&(e=r.bits||2048),t===void 0&&(t=r.e||65537),!r.prng&&e>=256&&e<=16384&&(t===65537||t===3)){if(n){if(_detectNodeCrypto("generateKeyPair"))return _crypto.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(c,u,g){if(c)return n(c);n(null,{privateKey:pki$1.privateKeyFromPem(g),publicKey:pki$1.publicKeyFromPem(u)})});if(_detectSubtleCrypto("generateKey")&&_detectSubtleCrypto("exportKey"))return util$5.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:_intToUint8Array(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(c){return util$5.globalScope.crypto.subtle.exportKey("pkcs8",c.privateKey)}).then(void 0,function(c){n(c)}).then(function(c){if(c){var u=pki$1.privateKeyFromAsn1(asn1$1.fromDer(forge$2.util.createBuffer(c)));n(null,{privateKey:u,publicKey:pki$1.setRsaPublicKey(u.n,u.e)})}});if(_detectSubtleMsCrypto("generateKey")&&_detectSubtleMsCrypto("exportKey")){var o=util$5.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:_intToUint8Array(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);o.oncomplete=function(c){var u=c.target.result,g=util$5.globalScope.msCrypto.subtle.exportKey("pkcs8",u.privateKey);g.oncomplete=function(b){var x=b.target.result,S=pki$1.privateKeyFromAsn1(asn1$1.fromDer(forge$2.util.createBuffer(x)));n(null,{privateKey:S,publicKey:pki$1.setRsaPublicKey(S.n,S.e)})},g.onerror=function(b){n(b)}},o.onerror=function(c){n(c)};return}}else if(_detectNodeCrypto("generateKeyPairSync")){var a=_crypto.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:pki$1.privateKeyFromPem(a.privateKey),publicKey:pki$1.publicKeyFromPem(a.publicKey)}}}var l=pki$1.rsa.createKeyPairGenerationState(e,t,r);if(!n)return pki$1.rsa.stepKeyPairGenerationState(l,0),l.keys;_generateKeyPair(l,r,n)};pki$1.setRsaPublicKey=pki$1.rsa.setPublicKey=function(e,t){var r={n:e,e:t};return r.encrypt=function(n,o,a){if(typeof o=="string"?o=o.toUpperCase():o===void 0&&(o="RSAES-PKCS1-V1_5"),o==="RSAES-PKCS1-V1_5")o={encode:function(c,u,g){return _encodePkcs1_v1_5(c,u,2).getBytes()}};else if(o==="RSA-OAEP"||o==="RSAES-OAEP")o={encode:function(c,u){return forge$2.pkcs1.encode_rsa_oaep(u,c,a)}};else if(["RAW","NONE","NULL",null].indexOf(o)!==-1)o={encode:function(c){return c}};else if(typeof o=="string")throw new Error('Unsupported encryption scheme: "'+o+'".');var l=o.encode(n,r,!0);return pki$1.rsa.encrypt(l,r,!0)},r.verify=function(n,o,a,l){typeof a=="string"?a=a.toUpperCase():a===void 0&&(a="RSASSA-PKCS1-V1_5"),l===void 0&&(l={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in l||(l._parseAllDigestBytes=!0),a==="RSASSA-PKCS1-V1_5"?a={verify:function(u,g){g=_decodePkcs1_v1_5(g,r,!0);var b=asn1$1.fromDer(g,{parseAllBytes:l._parseAllDigestBytes}),x={},S=[];if(!asn1$1.validate(b,digestInfoValidator,x,S)){var $=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw $.errors=S,$}var k=asn1$1.derToOid(x.algorithmIdentifier);if(!(k===forge$2.oids.md2||k===forge$2.oids.md5||k===forge$2.oids.sha1||k===forge$2.oids.sha224||k===forge$2.oids.sha256||k===forge$2.oids.sha384||k===forge$2.oids.sha512||k===forge$2.oids["sha512-224"]||k===forge$2.oids["sha512-256"])){var $=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw $.oid=k,$}if((k===forge$2.oids.md2||k===forge$2.oids.md5)&&!("parameters"in x))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return u===x.digest}}:(a==="NONE"||a==="NULL"||a===null)&&(a={verify:function(u,g){return g=_decodePkcs1_v1_5(g,r,!0),u===g}});var c=pki$1.rsa.decrypt(o,r,!0,!1);return a.verify(n,c,r.n.bitLength())},r};pki$1.setRsaPrivateKey=pki$1.rsa.setPrivateKey=function(e,t,r,n,o,a,l,c){var u={n:e,e:t,d:r,p:n,q:o,dP:a,dQ:l,qInv:c};return u.decrypt=function(g,b,x){typeof b=="string"?b=b.toUpperCase():b===void 0&&(b="RSAES-PKCS1-V1_5");var S=pki$1.rsa.decrypt(g,u,!1,!1);if(b==="RSAES-PKCS1-V1_5")b={decode:_decodePkcs1_v1_5};else if(b==="RSA-OAEP"||b==="RSAES-OAEP")b={decode:function($,k){return forge$2.pkcs1.decode_rsa_oaep(k,$,x)}};else if(["RAW","NONE","NULL",null].indexOf(b)!==-1)b={decode:function($){return $}};else throw new Error('Unsupported encryption scheme: "'+b+'".');return b.decode(S,u,!1)},u.sign=function(g,b){var x=!1;typeof b=="string"&&(b=b.toUpperCase()),b===void 0||b==="RSASSA-PKCS1-V1_5"?(b={encode:emsaPkcs1v15encode},x=1):(b==="NONE"||b==="NULL"||b===null)&&(b={encode:function(){return g}},x=1);var S=b.encode(g,u.n.bitLength());return pki$1.rsa.encrypt(S,u,x)},u};pki$1.wrapRsaPrivateKey=function(e){return asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,asn1$1.integerToDer(0).getBytes()),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.OID,!1,asn1$1.oidToDer(pki$1.oids.rsaEncryption).getBytes()),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.NULL,!1,"")]),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.OCTETSTRING,!1,asn1$1.toDer(e).getBytes())])};pki$1.privateKeyFromAsn1=function(e){var t={},r=[];if(asn1$1.validate(e,privateKeyValidator,t,r)&&(e=asn1$1.fromDer(forge$2.util.createBuffer(t.privateKey))),t={},r=[],!asn1$1.validate(e,rsaPrivateKeyValidator,t,r)){var n=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw n.errors=r,n}var o,a,l,c,u,g,b,x;return o=forge$2.util.createBuffer(t.privateKeyModulus).toHex(),a=forge$2.util.createBuffer(t.privateKeyPublicExponent).toHex(),l=forge$2.util.createBuffer(t.privateKeyPrivateExponent).toHex(),c=forge$2.util.createBuffer(t.privateKeyPrime1).toHex(),u=forge$2.util.createBuffer(t.privateKeyPrime2).toHex(),g=forge$2.util.createBuffer(t.privateKeyExponent1).toHex(),b=forge$2.util.createBuffer(t.privateKeyExponent2).toHex(),x=forge$2.util.createBuffer(t.privateKeyCoefficient).toHex(),pki$1.setRsaPrivateKey(new BigInteger$1(o,16),new BigInteger$1(a,16),new BigInteger$1(l,16),new BigInteger$1(c,16),new BigInteger$1(u,16),new BigInteger$1(g,16),new BigInteger$1(b,16),new BigInteger$1(x,16))};pki$1.privateKeyToAsn1=pki$1.privateKeyToRSAPrivateKey=function(e){return asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,asn1$1.integerToDer(0).getBytes()),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.n)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.e)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.d)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.p)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.q)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.dP)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.dQ)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.qInv))])};pki$1.publicKeyFromAsn1=function(e){var t={},r=[];if(asn1$1.validate(e,publicKeyValidator,t,r)){var n=asn1$1.derToOid(t.publicKeyOid);if(n!==pki$1.oids.rsaEncryption){var o=new Error("Cannot read public key. Unknown OID.");throw o.oid=n,o}e=t.rsaPublicKey}if(r=[],!asn1$1.validate(e,rsaPublicKeyValidator,t,r)){var o=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw o.errors=r,o}var a=forge$2.util.createBuffer(t.publicKeyModulus).toHex(),l=forge$2.util.createBuffer(t.publicKeyExponent).toHex();return pki$1.setRsaPublicKey(new BigInteger$1(a,16),new BigInteger$1(l,16))};pki$1.publicKeyToAsn1=pki$1.publicKeyToSubjectPublicKeyInfo=function(e){return asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.OID,!1,asn1$1.oidToDer(pki$1.oids.rsaEncryption).getBytes()),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.NULL,!1,"")]),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.BITSTRING,!1,[pki$1.publicKeyToRSAPublicKey(e)])])};pki$1.publicKeyToRSAPublicKey=function(e){return asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.SEQUENCE,!0,[asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.n)),asn1$1.create(asn1$1.Class.UNIVERSAL,asn1$1.Type.INTEGER,!1,_bnToBytes(e.e))])};function _encodePkcs1_v1_5(e,t,r){var n=forge$2.util.createBuffer(),o=Math.ceil(t.n.bitLength()/8);if(e.length>o-11){var a=new Error("Message is too long for PKCS#1 v1.5 padding.");throw a.length=e.length,a.max=o-11,a}n.putByte(0),n.putByte(r);var l=o-3-e.length,c;if(r===0||r===1){c=r===0?0:255;for(var u=0;u0;){for(var g=0,b=forge$2.random.getBytes(l),u=0;u"u")throw new Error("Encryption block is invalid.");var u=0;if(c===0){u=o-3-n;for(var g=0;g1;){if(a.getByte()!==255){--a.read;break}++u}else if(c===2)for(u=0;a.length()>1;){if(a.getByte()===0){--a.read;break}++u}var b=a.getByte();if(b!==0||u!==o-3-a.length())throw new Error("Encryption block is invalid.");return a.getBytes()}function _generateKeyPair(e,t,r){typeof t=="function"&&(r=t,t={}),t=t||{};var n={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(n.prng=t.prng),o();function o(){a(e.pBits,function(c,u){if(c)return r(c);if(e.p=u,e.q!==null)return l(c,e.q);a(e.qBits,l)})}function a(c,u){forge$2.prime.generateProbablePrime(c,n,u)}function l(c,u){if(c)return r(c);if(e.q=u,e.p.compareTo(e.q)<0){var g=e.p;e.p=e.q,e.q=g}if(e.p.subtract(BigInteger$1.ONE).gcd(e.e).compareTo(BigInteger$1.ONE)!==0){e.p=null,o();return}if(e.q.subtract(BigInteger$1.ONE).gcd(e.e).compareTo(BigInteger$1.ONE)!==0){e.q=null,a(e.qBits,l);return}if(e.p1=e.p.subtract(BigInteger$1.ONE),e.q1=e.q.subtract(BigInteger$1.ONE),e.phi=e.p1.multiply(e.q1),e.phi.gcd(e.e).compareTo(BigInteger$1.ONE)!==0){e.p=e.q=null,o();return}if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits){e.q=null,a(e.qBits,l);return}var b=e.e.modInverse(e.phi);e.keys={privateKey:pki$1.rsa.setPrivateKey(e.n,e.e,b,e.p,e.q,b.mod(e.p1),b.mod(e.q1),e.q.modInverse(e.p)),publicKey:pki$1.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}}function _bnToBytes(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=forge$2.util.hexToBytes(t);return r.length>1&&(r.charCodeAt(0)===0&&(r.charCodeAt(1)&128)===0||r.charCodeAt(0)===255&&(r.charCodeAt(1)&128)===128)?r.substr(1):r}function _getMillerRabinTests(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function _detectNodeCrypto(e){return forge$2.util.isNodejs&&typeof _crypto[e]=="function"}function _detectSubtleCrypto(e){return typeof util$5.globalScope<"u"&&typeof util$5.globalScope.crypto=="object"&&typeof util$5.globalScope.crypto.subtle=="object"&&typeof util$5.globalScope.crypto.subtle[e]=="function"}function _detectSubtleMsCrypto(e){return typeof util$5.globalScope<"u"&&typeof util$5.globalScope.msCrypto=="object"&&typeof util$5.globalScope.msCrypto.subtle=="object"&&typeof util$5.globalScope.msCrypto.subtle[e]=="function"}function _intToUint8Array(e){for(var t=forge$2.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n"u")var BigInteger=forge$1.jsbn.BigInteger;var asn1=forge$1.asn1,pki=forge$1.pki=forge$1.pki||{};pki.pbe=forge$1.pbe=forge$1.pbe||{};var oids=pki.oids,encryptedPrivateKeyValidator={name:"EncryptedPrivateKeyInfo",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},PBES2AlgorithmsValidator={name:"PBES2Algorithms",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},pkcs12PbeParamsValidator={name:"pkcs-12PbeParams",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:!1,capture:"iterations"}]};pki.encryptPrivateKeyInfo=function(e,t,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n=forge$1.random.getBytesSync(r.saltSize),o=r.count,a=asn1.integerToDer(o),l,c,u;if(r.algorithm.indexOf("aes")===0||r.algorithm==="des"){var g,b,x;switch(r.algorithm){case"aes128":l=16,g=16,b=oids["aes128-CBC"],x=forge$1.aes.createEncryptionCipher;break;case"aes192":l=24,g=16,b=oids["aes192-CBC"],x=forge$1.aes.createEncryptionCipher;break;case"aes256":l=32,g=16,b=oids["aes256-CBC"],x=forge$1.aes.createEncryptionCipher;break;case"des":l=8,g=8,b=oids.desCBC,x=forge$1.des.createEncryptionCipher;break;default:var S=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw S.algorithm=r.algorithm,S}var $="hmacWith"+r.prfAlgorithm.toUpperCase(),k=prfAlgorithmToMessageDigest($),T=forge$1.pkcs5.pbkdf2(t,n,o,l,k),D=forge$1.random.getBytesSync(g),I=x(T);I.start(D),I.update(asn1.toDer(e)),I.finish(),u=I.output.getBytes();var O=createPbkdf2Params(n,a,l,$);c=asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,!1,asn1.oidToDer(oids.pkcs5PBES2).getBytes()),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,!1,asn1.oidToDer(oids.pkcs5PBKDF2).getBytes()),O]),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,!1,asn1.oidToDer(b).getBytes()),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OCTETSTRING,!1,D)])])])}else if(r.algorithm==="3des"){l=24;var N=new forge$1.util.ByteBuffer(n),T=pki.pbe.generatePkcs12Key(t,N,1,o,l),D=pki.pbe.generatePkcs12Key(t,N,2,o,l),I=forge$1.des.createEncryptionCipher(T);I.start(D),I.update(asn1.toDer(e)),I.finish(),u=I.output.getBytes(),c=asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,!1,asn1.oidToDer(oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OCTETSTRING,!1,n),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.INTEGER,!1,a.getBytes())])])}else{var S=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw S.algorithm=r.algorithm,S}var ee=asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,!0,[c,asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OCTETSTRING,!1,u)]);return ee};pki.decryptPrivateKeyInfo=function(e,t){var r=null,n={},o=[];if(!asn1.validate(e,encryptedPrivateKeyValidator,n,o)){var a=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=o,a}var l=asn1.derToOid(n.encryptionOid),c=pki.pbe.getCipher(l,n.encryptionParams,t),u=forge$1.util.createBuffer(n.encryptedData);return c.update(u),c.finish()&&(r=asn1.fromDer(c.output)),r};pki.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:asn1.toDer(e).getBytes()};return forge$1.pem.encode(r,{maxline:t})};pki.encryptedPrivateKeyFromPem=function(e){var t=forge$1.pem.decode(e)[0];if(t.type!=="ENCRYPTED PRIVATE KEY"){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return asn1.fromDer(t.body)};pki.encryptRsaPrivateKey=function(e,t,r){if(r=r||{},!r.legacy){var n=pki.wrapRsaPrivateKey(pki.privateKeyToAsn1(e));return n=pki.encryptPrivateKeyInfo(n,t,r),pki.encryptedPrivateKeyToPem(n)}var o,a,l,c;switch(r.algorithm){case"aes128":o="AES-128-CBC",l=16,a=forge$1.random.getBytesSync(16),c=forge$1.aes.createEncryptionCipher;break;case"aes192":o="AES-192-CBC",l=24,a=forge$1.random.getBytesSync(16),c=forge$1.aes.createEncryptionCipher;break;case"aes256":o="AES-256-CBC",l=32,a=forge$1.random.getBytesSync(16),c=forge$1.aes.createEncryptionCipher;break;case"3des":o="DES-EDE3-CBC",l=24,a=forge$1.random.getBytesSync(8),c=forge$1.des.createEncryptionCipher;break;case"des":o="DES-CBC",l=8,a=forge$1.random.getBytesSync(8),c=forge$1.des.createEncryptionCipher;break;default:var u=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw u.algorithm=r.algorithm,u}var g=forge$1.pbe.opensslDeriveBytes(t,a.substr(0,8),l),b=c(g);b.start(a),b.update(asn1.toDer(pki.privateKeyToAsn1(e))),b.finish();var x={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:o,parameters:forge$1.util.bytesToHex(a).toUpperCase()},body:b.output.getBytes()};return forge$1.pem.encode(x)};pki.decryptRsaPrivateKey=function(e,t){var r=null,n=forge$1.pem.decode(e)[0];if(n.type!=="ENCRYPTED PRIVATE KEY"&&n.type!=="PRIVATE KEY"&&n.type!=="RSA PRIVATE KEY"){var o=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw o.headerType=o,o}if(n.procType&&n.procType.type==="ENCRYPTED"){var a,l;switch(n.dekInfo.algorithm){case"DES-CBC":a=8,l=forge$1.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,l=forge$1.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,l=forge$1.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,l=forge$1.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,l=forge$1.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,l=function(x){return forge$1.rc2.createDecryptionCipher(x,40)};break;case"RC2-64-CBC":a=8,l=function(x){return forge$1.rc2.createDecryptionCipher(x,64)};break;case"RC2-128-CBC":a=16,l=function(x){return forge$1.rc2.createDecryptionCipher(x,128)};break;default:var o=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".');throw o.algorithm=n.dekInfo.algorithm,o}var c=forge$1.util.hexToBytes(n.dekInfo.parameters),u=forge$1.pbe.opensslDeriveBytes(t,c.substr(0,8),a),g=l(u);if(g.start(c),g.update(forge$1.util.createBuffer(n.body)),g.finish())r=g.output.getBytes();else return r}else r=n.body;return n.type==="ENCRYPTED PRIVATE KEY"?r=pki.decryptPrivateKeyInfo(asn1.fromDer(r),t):r=asn1.fromDer(r),r!==null&&(r=pki.privateKeyFromAsn1(r)),r};pki.pbe.generatePkcs12Key=function(e,t,r,n,o,a){var l,c;if(typeof a>"u"||a===null){if(!("sha1"in forge$1.md))throw new Error('"sha1" hash algorithm unavailable.');a=forge$1.md.sha1.create()}var u=a.digestLength,g=a.blockLength,b=new forge$1.util.ByteBuffer,x=new forge$1.util.ByteBuffer;if(e!=null){for(c=0;c=0;c--)_e=_e>>8,_e+=fe.at(c)+he.at(c),he.setAt(c,_e&255);we.putBuffer(he)}N=we,b.putBuffer(B)}return b.truncate(b.length()-o),b};pki.pbe.getCipher=function(e,t,r){switch(e){case pki.oids.pkcs5PBES2:return pki.pbe.getCipherForPBES2(e,t,r);case pki.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case pki.oids["pbewithSHAAnd40BitRC2-CBC"]:return pki.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}};pki.pbe.getCipherForPBES2=function(e,t,r){var n={},o=[];if(!asn1.validate(t,PBES2AlgorithmsValidator,n,o)){var a=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=o,a}if(e=asn1.derToOid(n.kdfOid),e!==pki.oids.pkcs5PBKDF2){var a=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw a.oid=e,a.supportedOids=["pkcs5PBKDF2"],a}if(e=asn1.derToOid(n.encOid),e!==pki.oids["aes128-CBC"]&&e!==pki.oids["aes192-CBC"]&&e!==pki.oids["aes256-CBC"]&&e!==pki.oids["des-EDE3-CBC"]&&e!==pki.oids.desCBC){var a=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw a.oid=e,a.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],a}var l=n.kdfSalt,c=forge$1.util.createBuffer(n.kdfIterationCount);c=c.getInt(c.length()<<3);var u,g;switch(pki.oids[e]){case"aes128-CBC":u=16,g=forge$1.aes.createDecryptionCipher;break;case"aes192-CBC":u=24,g=forge$1.aes.createDecryptionCipher;break;case"aes256-CBC":u=32,g=forge$1.aes.createDecryptionCipher;break;case"des-EDE3-CBC":u=24,g=forge$1.des.createDecryptionCipher;break;case"desCBC":u=8,g=forge$1.des.createDecryptionCipher;break}var b=prfOidToMessageDigest(n.prfOid),x=forge$1.pkcs5.pbkdf2(r,l,c,u,b),S=n.encIv,$=g(x);return $.start(S),$};pki.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},o=[];if(!asn1.validate(t,pkcs12PbeParamsValidator,n,o)){var a=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=o,a}var l=forge$1.util.createBuffer(n.salt),c=forge$1.util.createBuffer(n.iterations);c=c.getInt(c.length()<<3);var u,g,b;switch(e){case pki.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:u=24,g=8,b=forge$1.des.startDecrypting;break;case pki.oids["pbewithSHAAnd40BitRC2-CBC"]:u=5,g=8,b=function(T,D){var I=forge$1.rc2.createDecryptionCipher(T,40);return I.start(D,null),I};break;default:var a=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw a.oid=e,a}var x=prfOidToMessageDigest(n.prfOid),S=pki.pbe.generatePkcs12Key(r,l,1,c,u,x);x.start();var $=pki.pbe.generatePkcs12Key(r,l,2,c,g,x);return b(S,$)};pki.pbe.opensslDeriveBytes=function(e,t,r,n){if(typeof n>"u"||n===null){if(!("md5"in forge$1.md))throw new Error('"md5" hash algorithm unavailable.');n=forge$1.md.md5.create()}t===null&&(t="");for(var o=[hash(n,e+t)],a=16,l=1;a=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,ee=new Uint8Array(N);I!==O;){for(var ne=k[I],B=0,le=N-1;(ne!==0||B>>0,ee[le]=ne%c>>>0,ne=ne/c>>>0;if(ne!==0)throw new Error("Non-zero carry");D=B,I++}for(var fe=N-D;fe!==N&&ee[fe]===0;)fe++;for(var xe=u.repeat(T);fe>>0,N=new Uint8Array(O);k[T];){var ee=r[k.charCodeAt(T)];if(ee===255)return;for(var ne=0,B=O-1;(ee!==0||ne>>0,N[B]=ee%256>>>0,ee=ee/256>>>0;if(ee!==0)throw new Error("Non-zero carry");I=ne,T++}if(k[T]!==" "){for(var le=O-I;le!==O&&N[le]===0;)le++;for(var fe=new Uint8Array(D+(O-le)),xe=D;le!==O;)fe[xe++]=N[le++];return fe}}}function $(k){var T=S(k);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:x,decodeUnsafe:S,decode:$}}var src$3=base$4,_brrp__multiformats_scope_baseX$1=src$3;const equals$1=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},fromString$2=e=>new TextEncoder().encode(e),toString$6=e=>new TextDecoder().decode(e);class Encoder$2{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class Decoder$2{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return or$3(this,t)}}class ComposedDecoder$1{constructor(t){this.decoders=t}or(t){return or$3(this,t)}decode(t){const r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const or$3=(e,t)=>new ComposedDecoder$1({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Codec$1{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Encoder$2(t,r,n),this.decoder=new Decoder$2(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const from$3=({name:e,prefix:t,encode:r,decode:n})=>new Codec$1(e,t,r,n),baseX$2=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=_brrp__multiformats_scope_baseX$1(r,t);return from$3({prefix:e,name:t,encode:n,decode:a=>coerce$2(o(a))})},decode$9=(e,t,r,n)=>{const o={};for(let b=0;b=8&&(c-=8,l[g++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return l},encode$b=(e,t,r)=>{const n=t[t.length-1]==="=",o=(1<r;)l-=r,a+=t[o&c>>l];if(l&&(a+=t[o&c<from$3({prefix:t,name:e,encode(o){return encode$b(o,n,r)},decode(o){return decode$9(o,n,r,e)}}),base10$2=baseX$2({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$3=Object.freeze(Object.defineProperty({__proto__:null,base10:base10$2},Symbol.toStringTag,{value:"Module"})),base16$2=rfc4648$3({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper$1=rfc4648$3({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$3=Object.freeze(Object.defineProperty({__proto__:null,base16:base16$2,base16upper:base16upper$1},Symbol.toStringTag,{value:"Module"})),base2$2=rfc4648$3({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$3=Object.freeze(Object.defineProperty({__proto__:null,base2:base2$2},Symbol.toStringTag,{value:"Module"})),alphabet$2=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),alphabetBytesToChars$1=alphabet$2.reduce((e,t,r)=>(e[r]=t,e),[]),alphabetCharsToBytes$1=alphabet$2.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function encode$a(e){return e.reduce((t,r)=>(t+=alphabetBytesToChars$1[r],t),"")}function decode$8(e){const t=[];for(const r of e){const n=alphabetCharsToBytes$1[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n)}return new Uint8Array(t)}const base256emoji$2=from$3({prefix:"\u{1F680}",name:"base256emoji",encode:encode$a,decode:decode$8}),base256emoji$3=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:base256emoji$2},Symbol.toStringTag,{value:"Module"})),base32$2=rfc4648$3({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper$1=rfc4648$3({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad$1=rfc4648$3({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper$1=rfc4648$3({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex$1=rfc4648$3({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper$1=rfc4648$3({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad$1=rfc4648$3({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper$1=rfc4648$3({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z$1=rfc4648$3({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$3=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$2,base32upper:base32upper$1,base32pad:base32pad$1,base32padupper:base32padupper$1,base32hex:base32hex$1,base32hexupper:base32hexupper$1,base32hexpad:base32hexpad$1,base32hexpadupper:base32hexpadupper$1,base32z:base32z$1},Symbol.toStringTag,{value:"Module"})),base36$2=baseX$2({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper$1=baseX$2({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$3=Object.freeze(Object.defineProperty({__proto__:null,base36:base36$2,base36upper:base36upper$1},Symbol.toStringTag,{value:"Module"})),base58btc$1=baseX$2({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr$1=baseX$2({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58$1=Object.freeze(Object.defineProperty({__proto__:null,base58btc:base58btc$1,base58flickr:base58flickr$1},Symbol.toStringTag,{value:"Module"})),base64$4=rfc4648$3({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad$1=rfc4648$3({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url$1=rfc4648$3({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad$1=rfc4648$3({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$5=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$4,base64pad:base64pad$1,base64url:base64url$1,base64urlpad:base64urlpad$1},Symbol.toStringTag,{value:"Module"})),base8$2=rfc4648$3({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$3=Object.freeze(Object.defineProperty({__proto__:null,base8:base8$2},Symbol.toStringTag,{value:"Module"})),identity$6=from$3({prefix:"\0",name:"identity",encode:e=>toString$6(e),decode:e=>fromString$2(e)}),identityBase$1=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$6},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;var encode_1$1=encode$9,MSB$3=128,REST$3=127,MSBALL$1=~REST$3,INT$1=Math.pow(2,31);function encode$9(e,t,r){t=t||[],r=r||0;for(var n=r;e>=INT$1;)t[r++]=e&255|MSB$3,e/=128;for(;e&MSBALL$1;)t[r++]=e&255|MSB$3,e>>>=7;return t[r]=e|0,encode$9.bytes=r-n+1,t}var decode$7=read$2,MSB$1$1=128,REST$1$1=127;function read$2(e,n){var r=0,n=n||0,o=0,a=n,l,c=e.length;do{if(a>=c)throw read$2.bytes=0,new RangeError("Could not decode varint");l=e[a++],r+=o<28?(l&REST$1$1)<=MSB$1$1);return read$2.bytes=a-n,r}var N1$1=Math.pow(2,7),N2$1=Math.pow(2,14),N3$1=Math.pow(2,21),N4$1=Math.pow(2,28),N5$1=Math.pow(2,35),N6$1=Math.pow(2,42),N7$1=Math.pow(2,49),N8$1=Math.pow(2,56),N9$1=Math.pow(2,63),length$2=function(e){return e[_brrp_varint$1.decode(e,t),_brrp_varint$1.decode.bytes],encodeTo$1=(e,t,r=0)=>(_brrp_varint$1.encode(e,t,r),t),encodingLength$1=e=>_brrp_varint$1.encodingLength(e),create$4=(e,t)=>{const r=t.byteLength,n=encodingLength$1(e),o=n+encodingLength$1(r),a=new Uint8Array(o+r);return encodeTo$1(e,a,0),encodeTo$1(r,a,n),a.set(t,o),new Digest$1(e,r,t,a)},decode$5=e=>{const t=coerce$2(e),[r,n]=decode$6(t),[o,a]=decode$6(t.subarray(n)),l=t.subarray(n+a);if(l.byteLength!==o)throw new Error("Incorrect length");return new Digest$1(r,o,l,t)},equals=(e,t)=>{if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&equals$1(e.bytes,r.bytes)}};class Digest$1{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}}const code$3=0,name$1="identity",encode$8=coerce$2,digest$1=e=>create$4(code$3,encode$8(e)),identity$4={code:code$3,name:name$1,encode:encode$8,digest:digest$1},identity$5=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$4},Symbol.toStringTag,{value:"Module"})),from$2=({name:e,code:t,encode:r})=>new Hasher$1(e,t,r);class Hasher$1{constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){const r=this.encode(t);return r instanceof Uint8Array?create$4(this.code,r):r.then(n=>create$4(this.code,n))}else throw Error("Unknown type, must be binary type")}}const sha$1=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),sha256$1=from$2({name:"sha2-256",code:18,encode:sha$1("SHA-256")}),sha512$2=from$2({name:"sha2-512",code:19,encode:sha$1("SHA-512")}),sha2$1=Object.freeze(Object.defineProperty({__proto__:null,sha256:sha256$1,sha512:sha512$2},Symbol.toStringTag,{value:"Module"})),format$3=(e,t)=>{const{bytes:r,version:n}=e;switch(n){case 0:return toStringV0(r,baseCache(e),t||base58btc$1.encoder);default:return toStringV1(r,baseCache(e),t||base32$2.encoder)}},cache$2=new WeakMap,baseCache=e=>{const t=cache$2.get(e);if(t==null){const r=new Map;return cache$2.set(e,r),r}return t};class CID{constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{const{code:t,multihash:r}=this;if(t!==DAG_PB_CODE)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==SHA_256_CODE)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return CID.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{const{code:t,digest:r}=this.multihash,n=create$4(t,r);return CID.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return CID.equals(this,t)}static equals(t,r){const n=r;return n&&t.code===n.code&&t.version===n.version&&equals(t.multihash,n.multihash)}toString(t){return format$3(this,t)}toJSON(){return{"/":format$3(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;const r=t;if(r instanceof CID)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){const{version:n,code:o,multihash:a,bytes:l}=r;return new CID(n,o,a,l||encodeCID(n,o,a.bytes))}else if(r[cidSymbol]===!0){const{version:n,multihash:o,code:a}=r,l=decode$5(o);return CID.create(n,a,l)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==DAG_PB_CODE)throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);return new CID(t,r,n,n.bytes)}case 1:{const o=encodeCID(t,r,n.bytes);return new CID(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return CID.create(0,DAG_PB_CODE,t)}static createV1(t,r){return CID.create(1,t,r)}static decode(t){const[r,n]=CID.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(t){const r=CID.inspectBytes(t),n=r.size-r.multihashSize,o=coerce$2(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");const a=o.subarray(r.multihashSize-r.digestSize),l=new Digest$1(r.multihashCode,r.digestSize,a,o);return[r.version===0?CID.createV0(l):CID.createV1(r.codec,l),t.subarray(r.size)]}static inspectBytes(t){let r=0;const n=()=>{const[x,S]=decode$6(t.subarray(r));return r+=S,x};let o=n(),a=DAG_PB_CODE;if(o===18?(o=0,r=0):a=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);const l=r,c=n(),u=n(),g=r+u,b=g-l;return{version:o,codec:a,multihashCode:c,digestSize:u,multihashSize:b,size:g}}static parse(t,r){const[n,o]=parseCIDtoBytes(t,r),a=CID.decode(o);if(a.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache(a).set(n,t),a}}const parseCIDtoBytes=(e,t)=>{switch(e[0]){case"Q":{const r=t||base58btc$1;return[base58btc$1.prefix,r.decode(`${base58btc$1.prefix}${e}`)]}case base58btc$1.prefix:{const r=t||base58btc$1;return[base58btc$1.prefix,r.decode(e)]}case base32$2.prefix:{const r=t||base32$2;return[base32$2.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},toStringV0=(e,t,r)=>{const{prefix:n}=r;if(n!==base58btc$1.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const o=t.get(n);if(o==null){const a=r.encode(e).slice(1);return t.set(n,a),a}else return o},toStringV1=(e,t,r)=>{const{prefix:n}=r,o=t.get(n);if(o==null){const a=r.encode(e);return t.set(n,a),a}else return o},DAG_PB_CODE=112,SHA_256_CODE=18,encodeCID=(e,t,r)=>{const n=encodingLength$1(e),o=n+encodingLength$1(t),a=new Uint8Array(o+r.byteLength);return encodeTo$1(e,a,0),encodeTo$1(t,a,n),a.set(r,o),a},cidSymbol=Symbol.for("@ipld/js-cid/CID"),bases={...identityBase$1,...base2$3,...base8$3,...base10$3,...base16$3,...base32$3,...base36$3,...base58$1,...base64$5,...base256emoji$3};({...sha2$1,...identity$5});function createCodec$1(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const string$1=createCodec$1("utf8","u",e=>{const t=new TextDecoder("utf8");return"u"+t.decode(e)},e=>new TextEncoder().encode(e.substring(1))),ascii=createCodec$1("ascii","a",e=>{let t="a";for(let r=0;r{e=e.substring(1);const t=allocUnsafe$2(e.length);for(let r=0;r1&&c.charAt(u)==="=";)++g;return Math.ceil(c.length*3)/4-g};for(var r=new Array(64),n=new Array(123),o=0;o<64;)n[r[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;t.encode=function(c,u,g){for(var b=null,x=[],S=0,$=0,k;u>2],k=(T&3)<<4,$=1;break;case 1:x[S++]=r[k|T>>4],k=(T&15)<<2,$=2;break;case 2:x[S++]=r[k|T>>6],x[S++]=r[T&63],$=0;break}S>8191&&((b||(b=[])).push(String.fromCharCode.apply(String,x)),S=0)}return $&&(x[S++]=r[k],x[S++]=61,$===1&&(x[S++]=61)),b?(S&&b.push(String.fromCharCode.apply(String,x.slice(0,S))),b.join("")):String.fromCharCode.apply(String,x.slice(0,S))};var a="invalid encoding";t.decode=function(c,u,g){for(var b=g,x=0,S,$=0;$1)break;if((k=n[k])===void 0)throw Error(a);switch(x){case 0:S=k,x=1;break;case 1:u[g++]=S<<2|(k&48)>>4,S=k,x=2;break;case 2:u[g++]=(S&15)<<4|(k&60)>>2,S=k,x=3;break;case 3:u[g++]=(S&3)<<6|k,x=0;break}}if(x===1)throw Error(a);return g-b},t.test=function(c){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(c)}})(base64$3);var eventemitter=EventEmitter$3;function EventEmitter$3(){this._listeners={}}EventEmitter$3.prototype.on=function(t,r,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:r,ctx:n||this}),this};EventEmitter$3.prototype.off=function(t,r){if(t===void 0)this._listeners={};else if(r===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],o=0;o0?0:2147483648,a,l);else if(isNaN(o))n(2143289344,a,l);else if(o>34028234663852886e22)n((c<<31|2139095040)>>>0,a,l);else if(o<11754943508222875e-54)n((c<<31|Math.round(o/1401298464324817e-60))>>>0,a,l);else{var u=Math.floor(Math.log(o)/Math.LN2),g=Math.round(o*Math.pow(2,-u)*8388608)&8388607;n((c<<31|u+127<<23|g)>>>0,a,l)}}e.writeFloatLE=t.bind(null,writeUintLE),e.writeFloatBE=t.bind(null,writeUintBE);function r(n,o,a){var l=n(o,a),c=(l>>31)*2+1,u=l>>>23&255,g=l&8388607;return u===255?g?NaN:c*(1/0):u===0?c*1401298464324817e-60*g:c*Math.pow(2,u-150)*(g+8388608)}e.readFloatLE=r.bind(null,readUintLE),e.readFloatBE=r.bind(null,readUintBE)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=r[7]===128;function o(u,g,b){t[0]=u,g[b]=r[0],g[b+1]=r[1],g[b+2]=r[2],g[b+3]=r[3],g[b+4]=r[4],g[b+5]=r[5],g[b+6]=r[6],g[b+7]=r[7]}function a(u,g,b){t[0]=u,g[b]=r[7],g[b+1]=r[6],g[b+2]=r[5],g[b+3]=r[4],g[b+4]=r[3],g[b+5]=r[2],g[b+6]=r[1],g[b+7]=r[0]}e.writeDoubleLE=n?o:a,e.writeDoubleBE=n?a:o;function l(u,g){return r[0]=u[g],r[1]=u[g+1],r[2]=u[g+2],r[3]=u[g+3],r[4]=u[g+4],r[5]=u[g+5],r[6]=u[g+6],r[7]=u[g+7],t[0]}function c(u,g){return r[7]=u[g],r[6]=u[g+1],r[5]=u[g+2],r[4]=u[g+3],r[3]=u[g+4],r[2]=u[g+5],r[1]=u[g+6],r[0]=u[g+7],t[0]}e.readDoubleLE=n?l:c,e.readDoubleBE=n?c:l}():function(){function t(n,o,a,l,c,u){var g=l<0?1:0;if(g&&(l=-l),l===0)n(0,c,u+o),n(1/l>0?0:2147483648,c,u+a);else if(isNaN(l))n(0,c,u+o),n(2146959360,c,u+a);else if(l>17976931348623157e292)n(0,c,u+o),n((g<<31|2146435072)>>>0,c,u+a);else{var b;if(l<22250738585072014e-324)b=l/5e-324,n(b>>>0,c,u+o),n((g<<31|b/4294967296)>>>0,c,u+a);else{var x=Math.floor(Math.log(l)/Math.LN2);x===1024&&(x=1023),b=l*Math.pow(2,-x),n(b*4503599627370496>>>0,c,u+o),n((g<<31|x+1023<<20|b*1048576&1048575)>>>0,c,u+a)}}}e.writeDoubleLE=t.bind(null,writeUintLE,0,4),e.writeDoubleBE=t.bind(null,writeUintBE,4,0);function r(n,o,a,l,c){var u=n(l,c+o),g=n(l,c+a),b=(g>>31)*2+1,x=g>>>20&2047,S=4294967296*(g&1048575)+u;return x===2047?S?NaN:b*(1/0):x===0?b*5e-324*S:b*Math.pow(2,x-1075)*(S+4503599627370496)}e.readDoubleLE=r.bind(null,readUintLE,0,4),e.readDoubleBE=r.bind(null,readUintBE,4,0)}(),e}function writeUintLE(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function writeUintBE(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=e&255}function readUintLE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function readUintBE(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}var utf8$3={};(function(e){var t=e;t.length=function(n){for(var o=0,a=0,l=0;l191&&b<224?u[g++]=(b&31)<<6|n[o++]&63:b>239&&b<365?(b=((b&7)<<18|(n[o++]&63)<<12|(n[o++]&63)<<6|n[o++]&63)-65536,u[g++]=55296+(b>>10),u[g++]=56320+(b&1023)):u[g++]=(b&15)<<12|(n[o++]&63)<<6|n[o++]&63,g>8191&&((c||(c=[])).push(String.fromCharCode.apply(String,u)),g=0);return c?(g&&c.push(String.fromCharCode.apply(String,u.slice(0,g))),c.join("")):String.fromCharCode.apply(String,u.slice(0,g))},t.write=function(n,o,a){for(var l=a,c,u,g=0;g>6|192,o[a++]=c&63|128):(c&64512)===55296&&((u=n.charCodeAt(g+1))&64512)===56320?(c=65536+((c&1023)<<10)+(u&1023),++g,o[a++]=c>>18|240,o[a++]=c>>12&63|128,o[a++]=c>>6&63|128,o[a++]=c&63|128):(o[a++]=c>>12|224,o[a++]=c>>6&63|128,o[a++]=c&63|128);return a-l}})(utf8$3);var pool_1=pool;function pool(e,t,r){var n=r||8192,o=n>>>1,a=null,l=n;return function(u){if(u<1||u>o)return e(u);l+u>n&&(a=e(n),l=0);var g=t.call(a,l,l+=u);return l&7&&(l=(l|7)+1),g}}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=t;var e=requireMinimal();function t(a,l){this.lo=a>>>0,this.hi=l>>>0}var r=t.zero=new t(0,0);r.toNumber=function(){return 0},r.zzEncode=r.zzDecode=function(){return this},r.length=function(){return 1};var n=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(l){if(l===0)return r;var c=l<0;c&&(l=-l);var u=l>>>0,g=(l-u)/4294967296>>>0;return c&&(g=~g>>>0,u=~u>>>0,++u>4294967295&&(u=0,++g>4294967295&&(g=0))),new t(u,g)},t.from=function(l){if(typeof l=="number")return t.fromNumber(l);if(e.isString(l))if(e.Long)l=e.Long.fromString(l);else return t.fromNumber(parseInt(l,10));return l.low||l.high?new t(l.low>>>0,l.high>>>0):r},t.prototype.toNumber=function(l){if(!l&&this.hi>>>31){var c=~this.lo+1>>>0,u=~this.hi>>>0;return c||(u=u+1>>>0),-(c+u*4294967296)}return this.lo+this.hi*4294967296},t.prototype.toLong=function(l){return e.Long?new e.Long(this.lo|0,this.hi|0,Boolean(l)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(l)}};var o=String.prototype.charCodeAt;return t.fromHash=function(l){return l===n?r:new t((o.call(l,0)|o.call(l,1)<<8|o.call(l,2)<<16|o.call(l,3)<<24)>>>0,(o.call(l,4)|o.call(l,5)<<8|o.call(l,6)<<16|o.call(l,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var l=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^l)>>>0,this.lo=(this.lo<<1^l)>>>0,this},t.prototype.zzDecode=function(){var l=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^l)>>>0,this.hi=(this.hi>>>1^l)>>>0,this},t.prototype.length=function(){var l=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,u=this.hi>>>24;return u===0?c===0?l<16384?l<128?1:2:l<2097152?3:4:c<16384?c<128?5:6:c<2097152?7:8:u<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(e){var t=e;t.asPromise=aspromise,t.base64=base64$3,t.EventEmitter=eventemitter,t.float=float,t.inquire=inquire_1,t.utf8=utf8$3,t.pool=pool_1,t.LongBits=requireLongbits(),t.isNode=Boolean(typeof commonjsGlobal$2<"u"&&commonjsGlobal$2&&commonjsGlobal$2.process&&commonjsGlobal$2.process.versions&&commonjsGlobal$2.process.versions.node),t.global=t.isNode&&commonjsGlobal$2||typeof window<"u"&&window||typeof self<"u"&&self||commonjsGlobal$2,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(a){return typeof a=="number"&&isFinite(a)&&Math.floor(a)===a},t.isString=function(a){return typeof a=="string"||a instanceof String},t.isObject=function(a){return a&&typeof a=="object"},t.isset=t.isSet=function(a,l){var c=a[l];return c!=null&&a.hasOwnProperty(l)?typeof c!="object"||(Array.isArray(c)?c.length:Object.keys(c).length)>0:!1},t.Buffer=function(){try{var o=t.inquire("buffer").Buffer;return o.prototype.utf8Write?o:null}catch{return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(a){return typeof a=="number"?t.Buffer?t._Buffer_allocUnsafe(a):new t.Array(a):t.Buffer?t._Buffer_from(a):typeof Uint8Array>"u"?a:new Uint8Array(a)},t.Array=typeof Uint8Array<"u"?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(a){return a?t.LongBits.from(a).toHash():t.LongBits.zeroHash},t.longFromHash=function(a,l){var c=t.LongBits.fromHash(a);return t.Long?t.Long.fromBits(c.lo,c.hi,l):c.toNumber(Boolean(l))};function r(o,a,l){for(var c=Object.keys(a),u=0;u-1;--g)if(l[u[g]]===1&&this[u[g]]!==void 0&&this[u[g]]!==null)return u[g]}},t.oneOfSetter=function(a){return function(l){for(var c=0;c "+e.len)}function Reader$1(e){this.buf=e,this.pos=0,this.len=e.length}var create_array=typeof Uint8Array<"u"?function e(t){if(t instanceof Uint8Array||Array.isArray(t))return new Reader$1(t);throw Error("illegal buffer")}:function e(t){if(Array.isArray(t))return new Reader$1(t);throw Error("illegal buffer")},create$2=function e(){return util$4.Buffer?function(r){return(Reader$1.create=function(o){return util$4.Buffer.isBuffer(o)?new BufferReader$1(o):create_array(o)})(r)}:create_array};Reader$1.create=create$2();Reader$1.prototype._slice=util$4.Array.prototype.subarray||util$4.Array.prototype.slice;Reader$1.prototype.uint32=function e(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return t}}();Reader$1.prototype.int32=function e(){return this.uint32()|0};Reader$1.prototype.sint32=function e(){var t=this.uint32();return t>>>1^-(t&1)|0};function readLongVarint(){var e=new LongBits$1(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}Reader$1.prototype.bool=function e(){return this.uint32()!==0};function readFixed32_end(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}Reader$1.prototype.fixed32=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)};Reader$1.prototype.sfixed32=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)|0};function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits$1(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader$1.prototype.float=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var t=util$4.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};Reader$1.prototype.double=function e(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var t=util$4.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};Reader$1.prototype.bytes=function e(){var t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw indexOutOfRange(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(r,n);if(r===n){var o=util$4.Buffer;return o?o.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,r,n)};Reader$1.prototype.string=function e(){var t=this.bytes();return utf8$2.read(t,0,t.length)};Reader$1.prototype.skip=function e(t){if(typeof t=="number"){if(this.pos+t>this.len)throw indexOutOfRange(this,t);this.pos+=t}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this};Reader$1.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this};Reader$1._configure=function(e){BufferReader$1=e,Reader$1.create=create$2(),BufferReader$1._configure();var t=util$4.Long?"toLong":"toNumber";util$4.merge(Reader$1.prototype,{int64:function(){return readLongVarint.call(this)[t](!1)},uint64:function(){return readLongVarint.call(this)[t](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[t](!1)},fixed64:function(){return readFixed64.call(this)[t](!0)},sfixed64:function(){return readFixed64.call(this)[t](!1)}})};var reader_buffer=BufferReader,Reader=reader$2;(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util$3=requireMinimal();function BufferReader(e){Reader.call(this,e)}BufferReader._configure=function(){util$3.Buffer&&(BufferReader.prototype._slice=util$3.Buffer.prototype.slice)};BufferReader.prototype.string=function e(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};BufferReader._configure();var minimalExports=requireMinimal(),writer$1=Writer$1,util$2=requireMinimal(),BufferWriter$1,LongBits=util$2.LongBits,base64$2=util$2.base64,utf8$1=util$2.utf8;function Op(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function noop$4(){}function State(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function Writer$1(){this.len=0,this.head=new Op(noop$4,0,0),this.tail=this.head,this.states=null}var create$1=function e(){return util$2.Buffer?function(){return(Writer$1.create=function(){return new BufferWriter$1})()}:function(){return new Writer$1}};Writer$1.create=create$1();Writer$1.alloc=function e(t){return new util$2.Array(t)};util$2.Array!==Array&&(Writer$1.alloc=util$2.pool(Writer$1.alloc,util$2.Array.prototype.subarray));Writer$1.prototype._push=function e(t,r,n){return this.tail=this.tail.next=new Op(t,r,n),this.len+=r,this};function writeByte(e,t,r){t[r]=e&255}function writeVarint32(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}function VarintOp(e,t){this.len=e,this.next=void 0,this.val=t}VarintOp.prototype=Object.create(Op.prototype);VarintOp.prototype.fn=writeVarint32;Writer$1.prototype.uint32=function e(t){return this.len+=(this.tail=this.tail.next=new VarintOp((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};Writer$1.prototype.int32=function e(t){return t<0?this._push(writeVarint64,10,LongBits.fromNumber(t)):this.uint32(t)};Writer$1.prototype.sint32=function e(t){return this.uint32((t<<1^t>>31)>>>0)};function writeVarint64(e,t,r){for(;e.hi;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}Writer$1.prototype.uint64=function e(t){var r=LongBits.from(t);return this._push(writeVarint64,r.length(),r)};Writer$1.prototype.int64=Writer$1.prototype.uint64;Writer$1.prototype.sint64=function e(t){var r=LongBits.from(t).zzEncode();return this._push(writeVarint64,r.length(),r)};Writer$1.prototype.bool=function e(t){return this._push(writeByte,1,t?1:0)};function writeFixed32(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}Writer$1.prototype.fixed32=function e(t){return this._push(writeFixed32,4,t>>>0)};Writer$1.prototype.sfixed32=Writer$1.prototype.fixed32;Writer$1.prototype.fixed64=function e(t){var r=LongBits.from(t);return this._push(writeFixed32,4,r.lo)._push(writeFixed32,4,r.hi)};Writer$1.prototype.sfixed64=Writer$1.prototype.fixed64;Writer$1.prototype.float=function e(t){return this._push(util$2.float.writeFloatLE,4,t)};Writer$1.prototype.double=function e(t){return this._push(util$2.float.writeDoubleLE,8,t)};var writeBytes=util$2.Array.prototype.set?function e(t,r,n){r.set(t,n)}:function e(t,r,n){for(var o=0;o>>0;if(!r)return this._push(writeByte,1,0);if(util$2.isString(t)){var n=Writer$1.alloc(r=base64$2.length(t));base64$2.decode(t,n,0),t=n}return this.uint32(r)._push(writeBytes,r,t)};Writer$1.prototype.string=function e(t){var r=utf8$1.length(t);return r?this.uint32(r)._push(utf8$1.write,r,t):this._push(writeByte,1,0)};Writer$1.prototype.fork=function e(){return this.states=new State(this),this.head=this.tail=new Op(noop$4,0,0),this.len=0,this};Writer$1.prototype.reset=function e(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop$4,0,0),this.len=0),this};Writer$1.prototype.ldelim=function e(){var t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=r,this.len+=n),this};Writer$1.prototype.finish=function e(){for(var t=this.head.next,r=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r};Writer$1._configure=function(e){BufferWriter$1=e,Writer$1.create=create$1(),BufferWriter$1._configure()};var writer_buffer=BufferWriter,Writer=writer$1;(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util$1=requireMinimal();function BufferWriter(){Writer.call(this)}BufferWriter._configure=function(){BufferWriter.alloc=util$1._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util$1.Buffer&&util$1.Buffer.prototype instanceof Uint8Array&&util$1.Buffer.prototype.set.name==="set"?function(t,r,n){r.set(t,n)}:function(t,r,n){if(t.copy)t.copy(r,n,0,t.length);else for(var o=0;o>>0;return this.uint32(r),r&&this._push(BufferWriter.writeBytesBuffer,r,t),this};function writeStringBuffer(e,t,r){e.length<40?util$1.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}BufferWriter.prototype.string=function e(t){var r=util$1.Buffer.byteLength(t);return this.uint32(r),r&&this._push(writeStringBuffer,r,t),this};BufferWriter._configure();function configure(){minimalExports._configure(),reader$2._configure(reader_buffer),writer$1._configure(writer_buffer)}configure();const methods=["uint64","int64","sint64","fixed64","sfixed64"];function patchReader(e){for(const t of methods){if(e[t]==null)continue;const r=e[t];e[t]=function(){return BigInt(r.call(this).toString())}}return e}function reader$1(e){return patchReader(new reader$2(e))}function patchWriter(e){for(const t of methods){if(e[t]==null)continue;const r=e[t];e[t]=function(n){return r.call(this,n.toString())}}return e}function writer(){return patchWriter(writer$1.create())}function decodeMessage(e,t){const r=reader$1(e instanceof Uint8Array?e:e.subarray());return t.decode(r)}function encodeMessage(e,t){const r=writer();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var CODEC_TYPES;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(CODEC_TYPES||(CODEC_TYPES={}));function createCodec(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function enumeration(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}const r=function(a,l){const c=t(a);l.int32(c)},n=function(a){const l=a.int32();return t(l)};return createCodec("enum",CODEC_TYPES.VARINT,r,n)}function message(e,t){return createCodec("message",CODEC_TYPES.LENGTH_DELIMITED,e,t)}var KeyType;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"})(KeyType||(KeyType={}));var __KeyTypeValues;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"})(__KeyTypeValues||(__KeyTypeValues={}));(function(e){e.codec=()=>enumeration(__KeyTypeValues)})(KeyType||(KeyType={}));var PublicKey;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),KeyType.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.Type=KeyType.codec().decode(r);break;case 2:o.Data=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(PublicKey||(PublicKey={}));var PrivateKey;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),KeyType.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.Type=KeyType.codec().decode(r);break;case 2:o.Data=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(PrivateKey||(PrivateKey={}));class Ed25519PublicKey{constructor(t){Xe(this,"_key");this._key=ensureKey(t,PUBLIC_KEY_BYTE_LENGTH)}async verify(t,r){return hashAndVerify$2(this._key,r,t)}marshal(){return this._key}get bytes(){return PublicKey.encode({Type:KeyType.Ed25519,Data:this.marshal()}).subarray()}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}}class Ed25519PrivateKey{constructor(t,r){Xe(this,"_key");Xe(this,"_publicKey");this._key=ensureKey(t,PRIVATE_KEY_BYTE_LENGTH),this._publicKey=ensureKey(r,PUBLIC_KEY_BYTE_LENGTH)}async sign(t){return hashAndSign$2(this._key,t)}get public(){return new Ed25519PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return PrivateKey.encode({Type:KeyType.Ed25519,Data:this.marshal()}).subarray()}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}async id(){const t=identity$4.digest(this.public.bytes);return base58btc$1.encode(t.bytes).substring(1)}async export(t,r="libp2p-key"){if(r==="libp2p-key")return exporter(this.bytes,t);throw new CodeError(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function unmarshalEd25519PrivateKey(e){if(e.length>PRIVATE_KEY_BYTE_LENGTH){e=ensureKey(e,PRIVATE_KEY_BYTE_LENGTH+PUBLIC_KEY_BYTE_LENGTH);const n=e.subarray(0,PRIVATE_KEY_BYTE_LENGTH),o=e.subarray(PRIVATE_KEY_BYTE_LENGTH,e.length);return new Ed25519PrivateKey(n,o)}e=ensureKey(e,PRIVATE_KEY_BYTE_LENGTH);const t=e.subarray(0,PRIVATE_KEY_BYTE_LENGTH),r=e.subarray(PUBLIC_KEY_BYTE_LENGTH);return new Ed25519PrivateKey(t,r)}function unmarshalEd25519PublicKey(e){return e=ensureKey(e,PUBLIC_KEY_BYTE_LENGTH),new Ed25519PublicKey(e)}async function generateKeyPair$3(){const{privateKey:e,publicKey:t}=await generateKey$2();return new Ed25519PrivateKey(e,t)}async function generateKeyPairFromSeed(e){const{privateKey:t,publicKey:r}=await generateKeyFromSeed(e);return new Ed25519PrivateKey(t,r)}function ensureKey(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new CodeError(`Key must be a Uint8Array of length ${t}, got ${e.length}`,"ERR_INVALID_KEY_TYPE");return e}const Ed25519=Object.freeze(Object.defineProperty({__proto__:null,Ed25519PublicKey,Ed25519PrivateKey,unmarshalEd25519PrivateKey,unmarshalEd25519PublicKey,generateKeyPair:generateKeyPair$3,generateKeyPairFromSeed},Symbol.toStringTag,{value:"Module"}));function toString$5(e,t="utf8"){const r=BASES[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}function bigIntegerToUintBase64url(e,t){let r=Uint8Array.from(e.abs().toByteArray());if(r=r[0]===0?r.subarray(1):r,t!=null){if(r.length>t)throw new Error("byte array longer than desired length");r=concat$1([new Uint8Array(t-r.length),r])}return toString$5(r,"base64url")}function base64urlToBigInteger(e){const t=base64urlToBuffer(e);return new forge$m.jsbn.BigInteger(toString$5(t,"base16"),16)}function base64urlToBuffer(e,t){let r=fromString$1(e,"base64urlpad");if(t!=null){if(r.length>t)throw new Error("byte array longer than desired length");r=concat$1([new Uint8Array(t-r.length),r])}return r}const bits={"P-256":256,"P-384":384,"P-521":521},curveTypes=Object.keys(bits);curveTypes.join(" / ");async function importer(e,t){const r=base64$4.decode(e);return create$3().decrypt(r,t)}var forge=forge$m,sha512$1=forge.sha512=forge.sha512||{};forge.md.sha512=forge.md.algorithms.sha512=sha512$1;var sha384=forge.sha384=forge.sha512.sha384=forge.sha512.sha384||{};sha384.create=function(){return sha512$1.create("SHA-384")};forge.md.sha384=forge.md.algorithms.sha384=sha384;forge.sha512.sha256=forge.sha512.sha256||{create:function(){return sha512$1.create("SHA-512/256")}};forge.md["sha512/256"]=forge.md.algorithms["sha512/256"]=forge.sha512.sha256;forge.sha512.sha224=forge.sha512.sha224||{create:function(){return sha512$1.create("SHA-512/224")}};forge.md["sha512/224"]=forge.md.algorithms["sha512/224"]=forge.sha512.sha224;sha512$1.create=function(e){if(_initialized||_init(),typeof e>"u"&&(e="SHA-512"),!(e in _states))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=_states[e],r=null,n=forge.util.createBuffer(),o=new Array(80),a=0;a<80;++a)o[a]=new Array(2);var l=64;switch(e){case"SHA-384":l=48;break;case"SHA-512/256":l=32;break;case"SHA-512/224":l=28;break}var c={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:l,messageLength:0,fullMessageLength:null,messageLengthSize:16};return c.start=function(){c.messageLength=0,c.fullMessageLength=c.messageLength128=[];for(var u=c.messageLengthSize/4,g=0;g>>0,b>>>0];for(var x=c.fullMessageLength.length-1;x>=0;--x)c.fullMessageLength[x]+=b[1],b[1]=b[0]+(c.fullMessageLength[x]/4294967296>>>0),c.fullMessageLength[x]=c.fullMessageLength[x]>>>0,b[0]=b[1]/4294967296>>>0;return n.putBytes(u),_update(r,o,n),(n.read>2048||n.length()===0)&&n.compact(),c},c.digest=function(){var u=forge.util.createBuffer();u.putBytes(n.bytes());var g=c.fullMessageLength[c.fullMessageLength.length-1]+c.messageLengthSize,b=g&c.blockLength-1;u.putBytes(_padding.substr(0,c.blockLength-b));for(var x,S,$=c.fullMessageLength[0]*8,k=0;k>>0,$+=S,u.putInt32($>>>0),$=x>>>0;u.putInt32($);for(var T=new Array(r.length),k=0;k=128;){for(ie=0;ie<16;++ie)t[ie][0]=r.getInt32()>>>0,t[ie][1]=r.getInt32()>>>0;for(;ie<80;++ie)ge=t[ie-2],pe=ge[0],ue=ge[1],n=((pe>>>19|ue<<13)^(ue>>>29|pe<<3)^pe>>>6)>>>0,o=((pe<<13|ue>>>19)^(ue<<3|pe>>>29)^(pe<<26|ue>>>6))>>>0,Ae=t[ie-15],pe=Ae[0],ue=Ae[1],a=((pe>>>1|ue<<31)^(pe>>>8|ue<<24)^pe>>>7)>>>0,l=((pe<<31|ue>>>1)^(pe<<24|ue>>>8)^(pe<<25|ue>>>7))>>>0,ye=t[ie-7],Re=t[ie-16],ue=o+ye[1]+l+Re[1],t[ie][0]=n+ye[0]+a+Re[0]+(ue/4294967296>>>0)>>>0,t[ie][1]=ue>>>0;for(T=e[0][0],D=e[0][1],I=e[1][0],O=e[1][1],N=e[2][0],ee=e[2][1],ne=e[3][0],B=e[3][1],le=e[4][0],fe=e[4][1],xe=e[5][0],we=e[5][1],he=e[6][0],_e=e[6][1],ve=e[7][0],ae=e[7][1],ie=0;ie<80;++ie)g=((le>>>14|fe<<18)^(le>>>18|fe<<14)^(fe>>>9|le<<23))>>>0,b=((le<<18|fe>>>14)^(le<<14|fe>>>18)^(fe<<23|le>>>9))>>>0,x=(he^le&(xe^he))>>>0,S=(_e^fe&(we^_e))>>>0,c=((T>>>28|D<<4)^(D>>>2|T<<30)^(D>>>7|T<<25))>>>0,u=((T<<4|D>>>28)^(D<<30|T>>>2)^(D<<25|T>>>7))>>>0,$=(T&I|N&(T^I))>>>0,k=(D&O|ee&(D^O))>>>0,ue=ae+b+S+_k[ie][1]+t[ie][1],n=ve+g+x+_k[ie][0]+t[ie][0]+(ue/4294967296>>>0)>>>0,o=ue>>>0,ue=u+k,a=c+$+(ue/4294967296>>>0)>>>0,l=ue>>>0,ve=he,ae=_e,he=xe,_e=we,xe=le,we=fe,ue=B+o,le=ne+n+(ue/4294967296>>>0)>>>0,fe=ue>>>0,ne=N,B=ee,N=I,ee=O,I=T,O=D,ue=o+l,T=n+a+(ue/4294967296>>>0)>>>0,D=ue>>>0;ue=e[0][1]+D,e[0][0]=e[0][0]+T+(ue/4294967296>>>0)>>>0,e[0][1]=ue>>>0,ue=e[1][1]+O,e[1][0]=e[1][0]+I+(ue/4294967296>>>0)>>>0,e[1][1]=ue>>>0,ue=e[2][1]+ee,e[2][0]=e[2][0]+N+(ue/4294967296>>>0)>>>0,e[2][1]=ue>>>0,ue=e[3][1]+B,e[3][0]=e[3][0]+ne+(ue/4294967296>>>0)>>>0,e[3][1]=ue>>>0,ue=e[4][1]+fe,e[4][0]=e[4][0]+le+(ue/4294967296>>>0)>>>0,e[4][1]=ue>>>0,ue=e[5][1]+we,e[5][0]=e[5][0]+xe+(ue/4294967296>>>0)>>>0,e[5][1]=ue>>>0,ue=e[6][1]+_e,e[6][0]=e[6][0]+he+(ue/4294967296>>>0)>>>0,e[6][1]=ue>>>0,ue=e[7][1]+ae,e[7][0]=e[7][0]+ve+(ue/4294967296>>>0)>>>0,e[7][1]=ue>>>0,We-=128}}function randomBytes(e){if(isNaN(e)||e<=0)throw new CodeError("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return randomBytes$1(e)}function convert$1(e,t){return t.map(r=>base64urlToBigInteger(e[r]))}function jwk2priv(e){return forge$m.pki.setRsaPrivateKey(...convert$1(e,["n","e","d","p","q","dp","dq","qi"]))}function jwk2pub(e){return forge$m.pki.setRsaPublicKey(...convert$1(e,["n","e"]))}function pkcs1ToJwk(e){const t=forge$m.asn1.fromDer(toString$5(e,"ascii")),r=forge$m.pki.privateKeyFromAsn1(t);return{kty:"RSA",n:bigIntegerToUintBase64url(r.n),e:bigIntegerToUintBase64url(r.e),d:bigIntegerToUintBase64url(r.d),p:bigIntegerToUintBase64url(r.p),q:bigIntegerToUintBase64url(r.q),dp:bigIntegerToUintBase64url(r.dP),dq:bigIntegerToUintBase64url(r.dQ),qi:bigIntegerToUintBase64url(r.qInv),alg:"RS256"}}function jwkToPkcs1(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new CodeError("JWK was missing components","ERR_INVALID_PARAMETERS");const t=forge$m.pki.privateKeyToAsn1({n:base64urlToBigInteger(e.n),e:base64urlToBigInteger(e.e),d:base64urlToBigInteger(e.d),p:base64urlToBigInteger(e.p),q:base64urlToBigInteger(e.q),dP:base64urlToBigInteger(e.dp),dQ:base64urlToBigInteger(e.dq),qInv:base64urlToBigInteger(e.qi)});return fromString$1(forge$m.asn1.toDer(t).getBytes(),"ascii")}function pkixToJwk(e){const t=forge$m.asn1.fromDer(toString$5(e,"ascii")),r=forge$m.pki.publicKeyFromAsn1(t);return{kty:"RSA",n:bigIntegerToUintBase64url(r.n),e:bigIntegerToUintBase64url(r.e)}}function jwkToPkix(e){if(e.n==null||e.e==null)throw new CodeError("JWK was missing components","ERR_INVALID_PARAMETERS");const t=forge$m.pki.publicKeyToAsn1({n:base64urlToBigInteger(e.n),e:base64urlToBigInteger(e.e)});return fromString$1(forge$m.asn1.toDer(t).getBytes(),"ascii")}async function generateKey$1(e){const t=await webcrypto.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await exportKey(t);return{privateKey:r[0],publicKey:r[1]}}async function unmarshalPrivateKey$1(e){const r=[await webcrypto.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await derivePublicFromPrivate(e)],n=await exportKey({privateKey:r[0],publicKey:r[1]});return{privateKey:n[0],publicKey:n[1]}}async function hashAndSign$1(e,t){const r=await webcrypto.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await webcrypto.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,Uint8Array.from(t));return new Uint8Array(n,0,n.byteLength)}async function hashAndVerify$1(e,t,r){const n=await webcrypto.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return webcrypto.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r)}async function exportKey(e){if(e.privateKey==null||e.publicKey==null)throw new CodeError("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([webcrypto.get().subtle.exportKey("jwk",e.privateKey),webcrypto.get().subtle.exportKey("jwk",e.publicKey)])}async function derivePublicFromPrivate(e){return webcrypto.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function convertKey(e,t,r,n){const o=t?jwk2pub(e):jwk2priv(e),a=toString$5(Uint8Array.from(r),"ascii"),l=n(a,o);return fromString$1(l,"ascii")}function encrypt(e,t){return convertKey(e,!0,t,(r,n)=>n.encrypt(r))}function decrypt(e,t){return convertKey(e,!1,t,(r,n)=>n.decrypt(r))}function keySize(e){if(e.kty!=="RSA")throw new CodeError("invalid key type","ERR_INVALID_KEY_TYPE");if(e.n==null)throw new CodeError("invalid key modulus","ERR_INVALID_KEY_MODULUS");return fromString$1(e.n,"base64url").length*8}const MAX_KEY_SIZE=8192;class RsaPublicKey{constructor(t){Xe(this,"_key");this._key=t}async verify(t,r){return hashAndVerify$1(this._key,r,t)}marshal(){return jwkToPkix(this._key)}get bytes(){return PublicKey.encode({Type:KeyType.RSA,Data:this.marshal()}).subarray()}encrypt(t){return encrypt(this._key,t)}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}}class RsaPrivateKey{constructor(t,r){Xe(this,"_key");Xe(this,"_publicKey");this._key=t,this._publicKey=r}genSecret(){return randomBytes(16)}async sign(t){return hashAndSign$1(this._key,t)}get public(){if(this._publicKey==null)throw new CodeError("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new RsaPublicKey(this._publicKey)}decrypt(t){return decrypt(this._key,t)}marshal(){return jwkToPkcs1(this._key)}get bytes(){return PrivateKey.encode({Type:KeyType.RSA,Data:this.marshal()}).subarray()}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}async id(){const t=await this.public.hash();return toString$5(t,"base58btc")}async export(t,r="pkcs-8"){if(r==="pkcs-8"){const n=new forge$m.util.ByteBuffer(this.marshal()),o=forge$m.asn1.fromDer(n),a=forge$m.pki.privateKeyFromAsn1(o),l={algorithm:"aes256",count:1e4,saltSize:128/8,prfAlgorithm:"sha512"};return forge$m.pki.encryptRsaPrivateKey(a,t,l)}else{if(r==="libp2p-key")return exporter(this.bytes,t);throw new CodeError(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}}async function unmarshalRsaPrivateKey(e){const t=pkcs1ToJwk(e);if(keySize(t)>MAX_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await unmarshalPrivateKey$1(t);return new RsaPrivateKey(r.privateKey,r.publicKey)}function unmarshalRsaPublicKey(e){const t=pkixToJwk(e);if(keySize(t)>MAX_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new RsaPublicKey(t)}async function fromJwk(e){if(keySize(e)>MAX_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await unmarshalPrivateKey$1(e);return new RsaPrivateKey(t.privateKey,t.publicKey)}async function generateKeyPair$2(e){if(e>MAX_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await generateKey$1(e);return new RsaPrivateKey(t.privateKey,t.publicKey)}const RSA=Object.freeze(Object.defineProperty({__proto__:null,MAX_KEY_SIZE,RsaPublicKey,RsaPrivateKey,unmarshalRsaPrivateKey,unmarshalRsaPublicKey,fromJwk,generateKeyPair:generateKeyPair$2},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts(e){const t=validateBasic(e);validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:b2n,hexToBytes:h2b}=ut,DER={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=DER;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const r=e[1],n=e.subarray(2,r+2);if(!r||n.length!==r)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:b2n(n),l:e.subarray(r+2)}},toSig(e){const{Err:t}=DER,r=typeof e=="string"?h2b(e):e;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new t("Invalid signature tag");if(r[1]!==n-2)throw new t("Invalid signature: incorrect length");const{d:o,l:a}=DER._parseInt(r.subarray(2)),{d:l,l:c}=DER._parseInt(a);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:l}},hexFromSig(e){const t=g=>Number.parseInt(g[0],16)&8?"00"+g:g,r=g=>{const b=g.toString(16);return b.length&1?`0${b}`:b},n=t(r(e.s)),o=t(r(e.r)),a=n.length/2,l=o.length/2,c=r(a),u=r(l);return`30${r(l+a+4)}02${u}${o}02${c}${n}`}},_0n=BigInt(0),_1n$1=BigInt(1);BigInt(2);const _3n=BigInt(3);BigInt(4);function weierstrassPoints(e){const t=validatePointOpts(e),{Fp:r}=t,n=t.toBytes||((k,T,D)=>{const I=T.toAffine();return concatBytes(Uint8Array.from([4]),r.toBytes(I.x),r.toBytes(I.y))}),o=t.fromBytes||(k=>{const T=k.subarray(1),D=r.fromBytes(T.subarray(0,r.BYTES)),I=r.fromBytes(T.subarray(r.BYTES,2*r.BYTES));return{x:D,y:I}});function a(k){const{a:T,b:D}=t,I=r.sqr(k),O=r.mul(I,k);return r.add(r.add(O,r.mul(k,T)),D)}if(!r.eql(r.sqr(t.Gy),a(t.Gx)))throw new Error("bad generator point: equation left != right");function l(k){return typeof k=="bigint"&&_0nr.eql(N,r.ZERO);return O(D)&&O(I)?x.ZERO:new x(D,I,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(T){const D=r.invertBatch(T.map(I=>I.pz));return T.map((I,O)=>I.toAffine(D[O])).map(x.fromAffine)}static fromHex(T){const D=x.fromAffine(o(ensureBytes("pointHex",T)));return D.assertValidity(),D}static fromPrivateKey(T){return x.BASE.multiply(u(T))}_setWindowSize(T){this._WINDOW_SIZE=T,g.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:T,y:D}=this.toAffine();if(!r.isValid(T)||!r.isValid(D))throw new Error("bad point: x or y not FE");const I=r.sqr(D),O=a(T);if(!r.eql(I,O))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:T}=this.toAffine();if(r.isOdd)return!r.isOdd(T);throw new Error("Field doesn't support isOdd")}equals(T){b(T);const{px:D,py:I,pz:O}=this,{px:N,py:ee,pz:ne}=T,B=r.eql(r.mul(D,ne),r.mul(N,O)),le=r.eql(r.mul(I,ne),r.mul(ee,O));return B&&le}negate(){return new x(this.px,r.neg(this.py),this.pz)}double(){const{a:T,b:D}=t,I=r.mul(D,_3n),{px:O,py:N,pz:ee}=this;let ne=r.ZERO,B=r.ZERO,le=r.ZERO,fe=r.mul(O,O),xe=r.mul(N,N),we=r.mul(ee,ee),he=r.mul(O,N);return he=r.add(he,he),le=r.mul(O,ee),le=r.add(le,le),ne=r.mul(T,le),B=r.mul(I,we),B=r.add(ne,B),ne=r.sub(xe,B),B=r.add(xe,B),B=r.mul(ne,B),ne=r.mul(he,ne),le=r.mul(I,le),we=r.mul(T,we),he=r.sub(fe,we),he=r.mul(T,he),he=r.add(he,le),le=r.add(fe,fe),fe=r.add(le,fe),fe=r.add(fe,we),fe=r.mul(fe,he),B=r.add(B,fe),we=r.mul(N,ee),we=r.add(we,we),fe=r.mul(we,he),ne=r.sub(ne,fe),le=r.mul(we,xe),le=r.add(le,le),le=r.add(le,le),new x(ne,B,le)}add(T){b(T);const{px:D,py:I,pz:O}=this,{px:N,py:ee,pz:ne}=T;let B=r.ZERO,le=r.ZERO,fe=r.ZERO;const xe=t.a,we=r.mul(t.b,_3n);let he=r.mul(D,N),_e=r.mul(I,ee),ve=r.mul(O,ne),ae=r.add(D,I),ie=r.add(N,ee);ae=r.mul(ae,ie),ie=r.add(he,_e),ae=r.sub(ae,ie),ie=r.add(D,O);let pe=r.add(N,ne);return ie=r.mul(ie,pe),pe=r.add(he,ve),ie=r.sub(ie,pe),pe=r.add(I,O),B=r.add(ee,ne),pe=r.mul(pe,B),B=r.add(_e,ve),pe=r.sub(pe,B),fe=r.mul(xe,ie),B=r.mul(we,ve),fe=r.add(B,fe),B=r.sub(_e,fe),fe=r.add(_e,fe),le=r.mul(B,fe),_e=r.add(he,he),_e=r.add(_e,he),ve=r.mul(xe,ve),ie=r.mul(we,ie),_e=r.add(_e,ve),ve=r.sub(he,ve),ve=r.mul(xe,ve),ie=r.add(ie,ve),he=r.mul(_e,ie),le=r.add(le,he),he=r.mul(pe,ie),B=r.mul(ae,B),B=r.sub(B,he),he=r.mul(ae,_e),fe=r.mul(pe,fe),fe=r.add(fe,he),new x(B,le,fe)}subtract(T){return this.add(T.negate())}is0(){return this.equals(x.ZERO)}wNAF(T){return $.wNAFCached(this,g,T,D=>{const I=r.invertBatch(D.map(O=>O.pz));return D.map((O,N)=>O.toAffine(I[N])).map(x.fromAffine)})}multiplyUnsafe(T){const D=x.ZERO;if(T===_0n)return D;if(c(T),T===_1n$1)return this;const{endo:I}=t;if(!I)return $.unsafeLadder(this,T);let{k1neg:O,k1:N,k2neg:ee,k2:ne}=I.splitScalar(T),B=D,le=D,fe=this;for(;N>_0n||ne>_0n;)N&_1n$1&&(B=B.add(fe)),ne&_1n$1&&(le=le.add(fe)),fe=fe.double(),N>>=_1n$1,ne>>=_1n$1;return O&&(B=B.negate()),ee&&(le=le.negate()),le=new x(r.mul(le.px,I.beta),le.py,le.pz),B.add(le)}multiply(T){c(T);let D=T,I,O;const{endo:N}=t;if(N){const{k1neg:ee,k1:ne,k2neg:B,k2:le}=N.splitScalar(D);let{p:fe,f:xe}=this.wNAF(ne),{p:we,f:he}=this.wNAF(le);fe=$.constTimeNegate(ee,fe),we=$.constTimeNegate(B,we),we=new x(r.mul(we.px,N.beta),we.py,we.pz),I=fe.add(we),O=xe.add(he)}else{const{p:ee,f:ne}=this.wNAF(D);I=ee,O=ne}return x.normalizeZ([I,O])[0]}multiplyAndAddUnsafe(T,D,I){const O=x.BASE,N=(ne,B)=>B===_0n||B===_1n$1||!ne.equals(O)?ne.multiplyUnsafe(B):ne.multiply(B),ee=N(this,D).add(N(T,I));return ee.is0()?void 0:ee}toAffine(T){const{px:D,py:I,pz:O}=this,N=this.is0();T==null&&(T=N?r.ONE:r.inv(O));const ee=r.mul(D,T),ne=r.mul(I,T),B=r.mul(O,T);if(N)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x:ee,y:ne}}isTorsionFree(){const{h:T,isTorsionFree:D}=t;if(T===_1n$1)return!0;if(D)return D(x,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:T,clearCofactor:D}=t;return T===_1n$1?this:D?D(x,this):this.multiplyUnsafe(t.h)}toRawBytes(T=!0){return this.assertValidity(),n(x,this,T)}toHex(T=!0){return bytesToHex(this.toRawBytes(T))}}x.BASE=new x(t.Gx,t.Gy,r.ONE),x.ZERO=new x(r.ZERO,r.ONE,r.ZERO);const S=t.nBitLength,$=wNAF(x,t.endo?Math.ceil(S/2):S);return{CURVE:t,ProjectivePoint:x,normPrivateKeyToScalar:u,weierstrassEquation:a,isWithinCurveOrder:l}}function validateOpts(e){const t=validateBasic(e);return validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function weierstrass(e){const t=validateOpts(e),{Fp:r,n}=t,o=r.BYTES+1,a=2*r.BYTES+1;function l(ie){return _0nbytesToHex(numberToBytesBE(ie,t.nByteLength));function k(ie){const pe=n>>_1n$1;return ie>pe}function T(ie){return k(ie)?c(-ie):ie}const D=(ie,pe,ue)=>bytesToNumberBE(ie.slice(pe,ue));class I{constructor(pe,ue,ge){this.r=pe,this.s=ue,this.recovery=ge,this.assertValidity()}static fromCompact(pe){const ue=t.nByteLength;return pe=ensureBytes("compactSignature",pe,ue*2),new I(D(pe,0,ue),D(pe,ue,2*ue))}static fromDER(pe){const{r:ue,s:ge}=DER.toSig(ensureBytes("DER",pe));return new I(ue,ge)}assertValidity(){if(!S(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!S(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(pe){return new I(this.r,this.s,pe)}recoverPublicKey(pe){const{r:ue,s:ge,recovery:ye}=this,Ae=le(ensureBytes("msgHash",pe));if(ye==null||![0,1,2,3].includes(ye))throw new Error("recovery id invalid");const Re=ye===2||ye===3?ue+t.n:ue;if(Re>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const We=(ye&1)===0?"02":"03",Pe=g.fromHex(We+$(Re)),Ue=u(Re),Oe=c(-Ae*Ue),Be=c(ge*Ue),Ye=g.BASE.multiplyAndAddUnsafe(Pe,Oe,Be);if(!Ye)throw new Error("point at infinify");return Ye.assertValidity(),Ye}hasHighS(){return k(this.s)}normalizeS(){return this.hasHighS()?new I(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes(this.toCompactHex())}toCompactHex(){return $(this.r)+$(this.s)}}const O={isValidPrivateKey(ie){try{return b(ie),!0}catch{return!1}},normPrivateKeyToScalar:b,randomPrivateKey:()=>{const ie=getMinHashLength(t.n);return mapHashToField(t.randomBytes(ie),t.n)},precompute(ie=8,pe=g.BASE){return pe._setWindowSize(ie),pe.multiply(BigInt(3)),pe}};function N(ie,pe=!0){return g.fromPrivateKey(ie).toRawBytes(pe)}function ee(ie){const pe=ie instanceof Uint8Array,ue=typeof ie=="string",ge=(pe||ue)&&ie.length;return pe?ge===o||ge===a:ue?ge===2*o||ge===2*a:ie instanceof g}function ne(ie,pe,ue=!0){if(ee(ie))throw new Error("first arg must be private key");if(!ee(pe))throw new Error("second arg must be public key");return g.fromHex(pe).multiply(b(ie)).toRawBytes(ue)}const B=t.bits2int||function(ie){const pe=bytesToNumberBE(ie),ue=ie.length*8-t.nBitLength;return ue>0?pe>>BigInt(ue):pe},le=t.bits2int_modN||function(ie){return c(B(ie))},fe=bitMask(t.nBitLength);function xe(ie){if(typeof ie!="bigint")throw new Error("bigint expected");if(!(_0n<=ie&&ieTe in ue))throw new Error("sign() legacy options not supported");const{hash:ge,randomBytes:ye}=t;let{lowS:Ae,prehash:Re,extraEntropy:We}=ue;Ae==null&&(Ae=!0),ie=ensureBytes("msgHash",ie),Re&&(ie=ensureBytes("prehashed msgHash",ge(ie)));const Pe=le(ie),Ue=b(pe),Oe=[xe(Ue),xe(Pe)];if(We!=null){const Te=We===!0?ye(r.BYTES):We;Oe.push(ensureBytes("extraEntropy",Te))}const Be=concatBytes(...Oe),Ye=Pe;function Se(Te){const $e=B(Te);if(!S($e))return;const Ve=u($e),oe=g.BASE.multiply($e).toAffine(),te=c(oe.x);if(te===_0n)return;const se=c(Ve*c(Ye+te*Ue));if(se===_0n)return;let me=(oe.x===te?0:2)|Number(oe.y&_1n$1),Ee=se;return Ae&&k(se)&&(Ee=T(se),me^=1),new I(te,Ee,me)}return{seed:Be,k2sig:Se}}const he={lowS:t.lowS,prehash:!1},_e={lowS:t.lowS,prehash:!1};function ve(ie,pe,ue=he){const{seed:ge,k2sig:ye}=we(ie,pe,ue),Ae=t;return createHmacDrbg(Ae.hash.outputLen,Ae.nByteLength,Ae.hmac)(ge,ye)}g.BASE._setWindowSize(8);function ae(ie,pe,ue,ge=_e){const ye=ie;if(pe=ensureBytes("msgHash",pe),ue=ensureBytes("publicKey",ue),"strict"in ge)throw new Error("options.strict was renamed to lowS");const{lowS:Ae,prehash:Re}=ge;let We,Pe;try{if(typeof ye=="string"||ye instanceof Uint8Array)try{We=I.fromDER(ye)}catch(oe){if(!(oe instanceof DER.Err))throw oe;We=I.fromCompact(ye)}else if(typeof ye=="object"&&typeof ye.r=="bigint"&&typeof ye.s=="bigint"){const{r:oe,s:te}=ye;We=new I(oe,te)}else throw new Error("PARSE");Pe=g.fromHex(ue)}catch(oe){if(oe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Ae&&We.hasHighS())return!1;Re&&(pe=t.hash(pe));const{r:Ue,s:Oe}=We,Be=le(pe),Ye=u(Oe),Se=c(Be*Ye),Te=c(Ue*Ye),$e=g.BASE.multiplyAndAddUnsafe(Pe,Se,Te)?.toAffine();return $e?c($e.x)===Ue:!1}return{CURVE:t,getPublicKey:N,getSharedSecret:ne,sign:ve,verify:ae,ProjectivePoint:g,Signature:I,utils:O}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash(e){return{hash:e,hmac:(t,...r)=>hmac$1(e,t,concatBytes$1(...r)),randomBytes:randomBytes$1}}function createCurve(e,t){const r=n=>weierstrass({...e,...getHash(n)});return Object.freeze({...r(t),create:r})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n=BigInt(1),_2n=BigInt(2),divNearest=(e,t)=>(e+t/_2n)/t;function sqrtMod(e){const t=secp256k1P,r=BigInt(3),n=BigInt(6),o=BigInt(11),a=BigInt(22),l=BigInt(23),c=BigInt(44),u=BigInt(88),g=e*e*e%t,b=g*g*e%t,x=pow2(b,r,t)*b%t,S=pow2(x,r,t)*b%t,$=pow2(S,_2n,t)*g%t,k=pow2($,o,t)*$%t,T=pow2(k,a,t)*k%t,D=pow2(T,c,t)*T%t,I=pow2(D,u,t)*D%t,O=pow2(I,c,t)*T%t,N=pow2(O,r,t)*b%t,ee=pow2(N,l,t)*k%t,ne=pow2(ee,n,t)*g%t,B=pow2(ne,_2n,t);if(!Fp.eql(Fp.sqr(B),e))throw new Error("Cannot find square root");return B}const Fp=Field(secp256k1P,void 0,void 0,{sqrt:sqrtMod}),secp256k1=createCurve({a:BigInt(0),b:BigInt(7),Fp,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=secp256k1N,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-_1n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),a=r,l=BigInt("0x100000000000000000000000000000000"),c=divNearest(a*e,t),u=divNearest(-n*e,t);let g=mod(e-c*r-u*o,t),b=mod(-c*n-u*a,t);const x=g>l,S=b>l;if(x&&(g=t-g),S&&(b=t-b),g>l||b>l)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:x,k1:g,k2neg:S,k2:b}}}},sha256$3);BigInt(0);secp256k1.ProjectivePoint;function generateKey(){return secp256k1.utils.randomPrivateKey()}async function hashAndSign(e,t){const{digest:r}=await sha256$1.digest(t);try{return secp256k1.sign(r,e).toDERRawBytes()}catch(n){throw new CodeError(String(n),"ERR_INVALID_INPUT")}}async function hashAndVerify(e,t,r){try{const{digest:n}=await sha256$1.digest(r);return secp256k1.verify(t,n,e)}catch(n){throw new CodeError(String(n),"ERR_INVALID_INPUT")}}function compressPublicKey(e){return secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!0)}function validatePrivateKey(e){try{secp256k1.getPublicKey(e,!0)}catch(t){throw new CodeError(String(t),"ERR_INVALID_PRIVATE_KEY")}}function validatePublicKey(e){try{secp256k1.ProjectivePoint.fromHex(e)}catch(t){throw new CodeError(String(t),"ERR_INVALID_PUBLIC_KEY")}}function computePublicKey(e){try{return secp256k1.getPublicKey(e,!0)}catch(t){throw new CodeError(String(t),"ERR_INVALID_PRIVATE_KEY")}}class Secp256k1PublicKey{constructor(t){Xe(this,"_key");validatePublicKey(t),this._key=t}async verify(t,r){return hashAndVerify(this._key,r,t)}marshal(){return compressPublicKey(this._key)}get bytes(){return PublicKey.encode({Type:KeyType.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}}class Secp256k1PrivateKey{constructor(t,r){Xe(this,"_key");Xe(this,"_publicKey");this._key=t,this._publicKey=r??computePublicKey(t),validatePrivateKey(this._key),validatePublicKey(this._publicKey)}async sign(t){return hashAndSign(this._key,t)}get public(){return new Secp256k1PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return PrivateKey.encode({Type:KeyType.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return equals$2(this.bytes,t.bytes)}async hash(){const{bytes:t}=await sha256$1.digest(this.bytes);return t}async id(){const t=await this.public.hash();return toString$5(t,"base58btc")}async export(t,r="libp2p-key"){if(r==="libp2p-key")return exporter(this.bytes,t);throw new CodeError(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function unmarshalSecp256k1PrivateKey(e){return new Secp256k1PrivateKey(e)}function unmarshalSecp256k1PublicKey(e){return new Secp256k1PublicKey(e)}async function generateKeyPair$1(){const e=generateKey();return new Secp256k1PrivateKey(e)}const Secp256k1=Object.freeze(Object.defineProperty({__proto__:null,Secp256k1PublicKey,Secp256k1PrivateKey,unmarshalSecp256k1PrivateKey,unmarshalSecp256k1PublicKey,generateKeyPair:generateKeyPair$1},Symbol.toStringTag,{value:"Module"})),supportedKeys={rsa:RSA,ed25519:Ed25519,secp256k1:Secp256k1};function unsupportedKey(e){const t=Object.keys(supportedKeys).join(" / ");return new CodeError(`invalid or unsupported key type ${e}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function typeToKey(e){if(e=e.toLowerCase(),e==="rsa"||e==="ed25519"||e==="secp256k1")return supportedKeys[e];throw unsupportedKey(e)}async function generateKeyPair(e,t){return typeToKey(e).generateKeyPair(t??2048)}function unmarshalPublicKey(e){const t=PublicKey.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case KeyType.RSA:return supportedKeys.rsa.unmarshalRsaPublicKey(r);case KeyType.Ed25519:return supportedKeys.ed25519.unmarshalEd25519PublicKey(r);case KeyType.Secp256k1:return supportedKeys.secp256k1.unmarshalSecp256k1PublicKey(r);default:throw unsupportedKey(t.Type??"unknown")}}function marshalPublicKey(e,t){return t=(t??"rsa").toLowerCase(),typeToKey(t),e.bytes}async function unmarshalPrivateKey(e){const t=PrivateKey.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case KeyType.RSA:return supportedKeys.rsa.unmarshalRsaPrivateKey(r);case KeyType.Ed25519:return supportedKeys.ed25519.unmarshalEd25519PrivateKey(r);case KeyType.Secp256k1:return supportedKeys.secp256k1.unmarshalSecp256k1PrivateKey(r);default:throw unsupportedKey(t.Type??"RSA")}}function marshalPrivateKey(e,t){return t=(t??"rsa").toLowerCase(),typeToKey(t),e.bytes}async function importKey(e,t){try{const o=await importer(e,t);return await unmarshalPrivateKey(o)}catch{}const r=forge$m.pki.decryptRsaPrivateKey(e,t);if(r===null)throw new CodeError("Cannot read the key, most likely the password is wrong or not a RSA key","ERR_CANNOT_DECRYPT_PEM");let n=forge$m.asn1.toDer(forge$m.pki.privateKeyToAsn1(r));return n=fromString$1(n.getBytes(),"ascii"),supportedKeys.rsa.unmarshalRsaPrivateKey(n)}const symbol$3=Symbol.for("@libp2p/peer-id");function isPeerId(e){return e!=null&&Boolean(e[symbol$3])}const inspect$1=Symbol.for("nodejs.util.inspect.custom"),baseDecoder=Object.values(bases).map(e=>e.decoder).reduce((e,t)=>e.or(t),bases.identity.decoder),LIBP2P_KEY_CODE=114,MARSHALLED_ED225519_PUBLIC_KEY_LENGTH=36,MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH=37;var Zl;class PeerIdImpl{constructor(t){Xe(this,"type");Xe(this,"multihash");Xe(this,"privateKey");Xe(this,"publicKey");Xe(this,"string");Xe(this,Zl,!0);this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}toString(){return this.string==null&&(this.string=base58btc$1.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return CID.createV1(LIBP2P_KEY_CODE,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return equals$2(this.multihash.bytes,t);if(typeof t=="string")return peerIdFromString(t).equals(this);if(t?.multihash?.bytes!=null)return equals$2(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[(Zl=symbol$3,inspect$1)](){return`PeerId(${this.toString()})`}}class RSAPeerIdImpl extends PeerIdImpl{constructor(r){super({...r,type:"RSA"});Xe(this,"type","RSA");Xe(this,"publicKey");this.publicKey=r.publicKey}}class Ed25519PeerIdImpl extends PeerIdImpl{constructor(r){super({...r,type:"Ed25519"});Xe(this,"type","Ed25519");Xe(this,"publicKey");this.publicKey=r.multihash.digest}}class Secp256k1PeerIdImpl extends PeerIdImpl{constructor(r){super({...r,type:"secp256k1"});Xe(this,"type","secp256k1");Xe(this,"publicKey");this.publicKey=r.multihash.digest}}function peerIdFromPeerId(e){if(e.type==="RSA")return new RSAPeerIdImpl(e);if(e.type==="Ed25519")return new Ed25519PeerIdImpl(e);if(e.type==="secp256k1")return new Secp256k1PeerIdImpl(e);throw new CodeError("Not a PeerId","ERR_INVALID_PARAMETERS")}function peerIdFromString(e,t){if(e.charAt(0)==="1"||e.charAt(0)==="Q"){const r=decode$5(base58btc$1.decode(`z${e}`));return e.startsWith("12D")?new Ed25519PeerIdImpl({multihash:r}):e.startsWith("16U")?new Secp256k1PeerIdImpl({multihash:r}):new RSAPeerIdImpl({multihash:r})}return peerIdFromBytes(baseDecoder.decode(e))}function peerIdFromBytes(e){try{const t=decode$5(e);if(t.code===identity$4.code){if(t.digest.length===MARSHALLED_ED225519_PUBLIC_KEY_LENGTH)return new Ed25519PeerIdImpl({multihash:t});if(t.digest.length===MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH)return new Secp256k1PeerIdImpl({multihash:t})}if(t.code===sha256$1.code)return new RSAPeerIdImpl({multihash:t})}catch{return peerIdFromCID(CID.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function peerIdFromCID(e){if(e==null||e.multihash==null||e.version==null||e.version===1&&e.code!==LIBP2P_KEY_CODE)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===sha256$1.code)return new RSAPeerIdImpl({multihash:e.multihash});if(t.code===identity$4.code){if(t.digest.length===MARSHALLED_ED225519_PUBLIC_KEY_LENGTH)return new Ed25519PeerIdImpl({multihash:e.multihash});if(t.digest.length===MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH)return new Secp256k1PeerIdImpl({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function peerIdFromKeys(e,t){return e.length===MARSHALLED_ED225519_PUBLIC_KEY_LENGTH?new Ed25519PeerIdImpl({multihash:create$4(identity$4.code,e),privateKey:t}):e.length===MARSHALLED_SECP256K1_PUBLIC_KEY_LENGTH?new Secp256k1PeerIdImpl({multihash:create$4(identity$4.code,e),privateKey:t}):new RSAPeerIdImpl({multihash:await sha256$1.digest(e),publicKey:e,privateKey:t})}var NoiseExtensions;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.webtransportCerthashes!=null)for(const a of r.webtransportCerthashes)n.uint32(10),n.bytes(a);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={webtransportCerthashes:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.webtransportCerthashes.push(r.bytes());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(NoiseExtensions||(NoiseExtensions={}));var NoiseHandshakePayload;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),(o.writeDefaults===!0||r.identityKey!=null&&r.identityKey.byteLength>0)&&(n.uint32(10),n.bytes(r.identityKey??new Uint8Array(0))),(o.writeDefaults===!0||r.identitySig!=null&&r.identitySig.byteLength>0)&&(n.uint32(18),n.bytes(r.identitySig??new Uint8Array(0))),r.extensions!=null&&(n.uint32(34),NoiseExtensions.codec().encode(r.extensions,n,{writeDefaults:!1})),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={identityKey:new Uint8Array(0),identitySig:new Uint8Array(0)},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.identityKey=r.bytes();break;case 2:o.identitySig=r.bytes();break;case 4:o.extensions=NoiseExtensions.codec().decode(r,r.uint32());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(NoiseHandshakePayload||(NoiseHandshakePayload={}));async function getPayload(e,t,r){const n=await signPayload(e,getHandshakePayload(t));if(e.publicKey==null)throw new Error("PublicKey was missing from local PeerId");return createHandshakePayload(e.publicKey,n,r)}function createHandshakePayload(e,t,r){return NoiseHandshakePayload.encode({identityKey:e,identitySig:t,extensions:r??{webtransportCerthashes:[]}}).subarray()}async function signPayload(e,t){if(e.privateKey==null)throw new Error("PrivateKey was missing from PeerId");return(await unmarshalPrivateKey(e.privateKey)).sign(t)}async function getPeerIdFromPayload(e){return peerIdFromKeys(e.identityKey)}function decodePayload(e){return NoiseHandshakePayload.decode(e)}function getHandshakePayload(e){const t=fromString$1("noise-libp2p-static-key:");return concat$1([t,e],t.length+e.length)}async function verifySignedPayload(e,t,r){const n=await peerIdFromKeys(t.identityKey);if(!n.equals(r))throw new Error(`Payload identity key ${n.toString()} does not match expected remote peer ${r.toString()}`);const o=getHandshakePayload(e);if(n.publicKey==null)throw new Error("PublicKey was missing from PeerId");if(t.identitySig==null)throw new Error("Signature was missing from message");if(!await unmarshalPublicKey(n.publicKey).verify(o,t.identitySig))throw new Error("Static key doesn't match to peer that signed payload!");return n}function isValidPublicKey(e){return!(!(e instanceof Uint8Array)||e.length!==32)}var browser$7={exports:{}},ms$4,hasRequiredMs;function requireMs(){if(hasRequiredMs)return ms$4;hasRequiredMs=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,a=n*365.25;ms$4=function(b,x){x=x||{};var S=typeof b;if(S==="string"&&b.length>0)return l(b);if(S==="number"&&isFinite(b))return x.long?u(b):c(b);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(b))};function l(b){if(b=String(b),!(b.length>100)){var x=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(b);if(!!x){var S=parseFloat(x[1]),$=(x[2]||"ms").toLowerCase();switch($){case"years":case"year":case"yrs":case"yr":case"y":return S*a;case"weeks":case"week":case"w":return S*o;case"days":case"day":case"d":return S*n;case"hours":case"hour":case"hrs":case"hr":case"h":return S*r;case"minutes":case"minute":case"mins":case"min":case"m":return S*t;case"seconds":case"second":case"secs":case"sec":case"s":return S*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}function c(b){var x=Math.abs(b);return x>=n?Math.round(b/n)+"d":x>=r?Math.round(b/r)+"h":x>=t?Math.round(b/t)+"m":x>=e?Math.round(b/e)+"s":b+"ms"}function u(b){var x=Math.abs(b);return x>=n?g(b,x,n,"day"):x>=r?g(b,x,r,"hour"):x>=t?g(b,x,t,"minute"):x>=e?g(b,x,e,"second"):b+" ms"}function g(b,x,S,$){var k=x>=S*1.5;return Math.round(b/S)+" "+$+(k?"s":"")}return ms$4}function setup(e){r.debug=r,r.default=r,r.coerce=u,r.disable=a,r.enable=o,r.enabled=l,r.humanize=requireMs(),r.destroy=g,Object.keys(e).forEach(b=>{r[b]=e[b]}),r.names=[],r.skips=[],r.formatters={};function t(b){let x=0;for(let S=0;S{if(B==="%%")return"%";ee++;const fe=r.formatters[le];if(typeof fe=="function"){const xe=D[ee];B=fe.call(I,xe),D.splice(ee,1),ee--}return B}),r.formatArgs.call(I,D),(I.log||r.log).apply(I,D)}return T.namespace=b,T.useColors=r.useColors(),T.color=r.selectColor(b),T.extend=n,T.destroy=r.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>S!==null?S:($!==r.namespaces&&($=r.namespaces,k=r.enabled(b)),k),set:D=>{S=D}}),typeof r.init=="function"&&r.init(T),T}function n(b,x){const S=r(this.namespace+(typeof x>"u"?":":x)+b);return S.log=this.log,S}function o(b){r.save(b),r.namespaces=b,r.names=[],r.skips=[];let x;const S=(typeof b=="string"?b:"").split(/[\s,]+/),$=S.length;for(x=0;x<$;x++)!S[x]||(b=S[x].replace(/\*/g,".*?"),b[0]==="-"?r.skips.push(new RegExp("^"+b.slice(1)+"$")):r.names.push(new RegExp("^"+b+"$")))}function a(){const b=[...r.names.map(c),...r.skips.map(c).map(x=>"-"+x)].join(",");return r.enable(""),b}function l(b){if(b[b.length-1]==="*")return!0;let x,S;for(x=0,S=r.skips.length;x{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;u.splice(1,0,g,"color: inherit");let b=0,x=0;u[0].replace(/%[a-zA-Z%]/g,S=>{S!=="%%"&&(b++,S==="%c"&&(x=b))}),u.splice(x,0,g)}t.log=console.debug||console.log||(()=>{});function o(u){try{u?t.storage.setItem("debug",u):t.storage.removeItem("debug")}catch{}}function a(){let u;try{u=t.storage.getItem("debug")}catch{}return!u&&typeof process<"u"&&"env"in process&&(u={}.DEBUG),u}function l(){try{return localStorage}catch{}}e.exports=common(t);const{formatters:c}=e.exports;c.j=function(u){try{return JSON.stringify(u)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}})(browser$7,browser$7.exports);const debug$9=browser$7.exports;debug$9.formatters.b=e=>e==null?"undefined":base58btc$1.baseEncode(e);debug$9.formatters.t=e=>e==null?"undefined":base32$2.baseEncode(e);debug$9.formatters.m=e=>e==null?"undefined":base64$4.baseEncode(e);debug$9.formatters.p=e=>e==null?"undefined":e.toString();debug$9.formatters.c=e=>e==null?"undefined":e.toString();debug$9.formatters.k=e=>e==null?"undefined":e.toString();debug$9.formatters.a=e=>e==null?"undefined":e.toString();function createDisabledLogger(e){const t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function logger(e){let t=createDisabledLogger(`${e}:trace`);return debug$9.enabled(`${e}:trace`)&&debug$9.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=debug$9(`${e}:trace`)),Object.assign(debug$9(e),{error:debug$9(`${e}:error`),trace:t})}const log$B=logger("libp2p:noise");let keyLogger;DUMP_SESSION_KEYS?keyLogger=log$B:keyLogger=Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});function logLocalStaticKeys(e){keyLogger(`LOCAL_STATIC_PUBLIC_KEY ${toString$5(e.publicKey,"hex")}`),keyLogger(`LOCAL_STATIC_PRIVATE_KEY ${toString$5(e.privateKey,"hex")}`)}function logLocalEphemeralKeys(e){e?(keyLogger(`LOCAL_PUBLIC_EPHEMERAL_KEY ${toString$5(e.publicKey,"hex")}`),keyLogger(`LOCAL_PRIVATE_EPHEMERAL_KEY ${toString$5(e.privateKey,"hex")}`)):keyLogger("Missing local ephemeral keys.")}function logRemoteStaticKey(e){keyLogger(`REMOTE_STATIC_PUBLIC_KEY ${toString$5(e,"hex")}`)}function logRemoteEphemeralKey(e){keyLogger(`REMOTE_EPHEMERAL_PUBLIC_KEY ${toString$5(e,"hex")}`)}function logCipherState(e){e.cs1&&e.cs2?(keyLogger(`CIPHER_STATE_1 ${e.cs1.n.getUint64()} ${toString$5(e.cs1.k,"hex")}`),keyLogger(`CIPHER_STATE_2 ${e.cs2.n.getUint64()} ${toString$5(e.cs2.k,"hex")}`)):keyLogger("Missing cipher state.")}const MIN_NONCE=0,MAX_NONCE=4294967295,ERR_MAX_NONCE="Cipherstate has reached maximum n, a new handshake must be performed";class Nonce{constructor(t=MIN_NONCE){Xe(this,"n");Xe(this,"bytes");Xe(this,"view");this.n=t,this.bytes=new Uint8Array(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,t,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>MAX_NONCE)throw new Error(ERR_MAX_NONCE)}}class AbstractHandshake{constructor(t){Xe(this,"crypto");this.crypto=t}encryptWithAd(t,r,n){const o=this.encrypt(t.k,t.n,r,n);return t.n.increment(),o}decryptWithAd(t,r,n,o){const{plaintext:a,valid:l}=this.decrypt(t.k,t.n,r,n,o);return l&&t.n.increment(),{plaintext:a,valid:l}}hasKey(t){return!this.isEmptyKey(t.k)}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(t){const r=this.createEmptyKey();return equals$2(r,t)}encrypt(t,r,n,o){return r.assertValue(),this.crypto.chaCha20Poly1305Encrypt(o,r.getBytes(),n,t)}encryptAndHash(t,r){let n;return this.hasKey(t.cs)?n=this.encryptWithAd(t.cs,t.h,r):n=r,this.mixHash(t,n),n}decrypt(t,r,n,o,a){r.assertValue();const l=this.crypto.chaCha20Poly1305Decrypt(o,r.getBytes(),n,t,a);return l?{plaintext:l,valid:!0}:{plaintext:new Uint8Array(0),valid:!1}}decryptAndHash(t,r){let n,o=!0;return this.hasKey(t.cs)?{plaintext:n,valid:o}=this.decryptWithAd(t.cs,t.h,r):n=r,this.mixHash(t,r),{plaintext:n,valid:o}}dh(t,r){try{const n=this.crypto.generateX25519SharedKey(t,r);return n.length===32?n:n.subarray(0,32)}catch(n){const o=n;return log$B.error(o),new Uint8Array(32)}}mixHash(t,r){t.h=this.getHash(t.h,r)}getHash(t,r){return this.crypto.hashSHA256(concat$1([t,r],t.length+r.length))}mixKey(t,r){const[n,o]=this.crypto.getHKDF(t.ck,r);t.cs=this.initializeKey(o),t.ck=n}initializeKey(t){return{k:t,n:new Nonce}}initializeSymmetric(t){const r=fromString$1(t,"utf-8"),n=this.hashProtocolName(r),o=n,a=this.createEmptyKey();return{cs:this.initializeKey(a),ck:o,h:n}}hashProtocolName(t){if(t.length<=32){const r=new Uint8Array(32);return r.set(t),r}else return this.getHash(t,new Uint8Array(0))}split(t){const[r,n]=this.crypto.getHKDF(t.ck,new Uint8Array(0)),o=this.initializeKey(r),a=this.initializeKey(n);return{cs1:o,cs2:a}}writeMessageRegular(t,r){const n=this.encryptWithAd(t,new Uint8Array(0),r),o=this.createEmptyKey(),a=new Uint8Array(0);return{ne:o,ns:a,ciphertext:n}}readMessageRegular(t,r){return this.decryptWithAd(t,new Uint8Array(0),r.ciphertext)}}class XX extends AbstractHandshake{initializeInitiator(t,r,n,o){const a="Noise_XX_25519_ChaChaPoly_SHA256",l=this.initializeSymmetric(a);this.mixHash(l,t);const c=new Uint8Array(32);return{ss:l,s:r,rs:n,psk:o,re:c}}initializeResponder(t,r,n,o){const a="Noise_XX_25519_ChaChaPoly_SHA256",l=this.initializeSymmetric(a);this.mixHash(l,t);const c=new Uint8Array(32);return{ss:l,s:r,rs:n,psk:o,re:c}}writeMessageA(t,r,n){const o=new Uint8Array(0);n!==void 0?t.e=n:t.e=this.crypto.generateX25519KeyPair();const a=t.e.publicKey;this.mixHash(t.ss,a);const l=this.encryptAndHash(t.ss,r);return{ne:a,ns:o,ciphertext:l}}writeMessageB(t,r){t.e=this.crypto.generateX25519KeyPair();const n=t.e.publicKey;this.mixHash(t.ss,n),this.mixKey(t.ss,this.dh(t.e.privateKey,t.re));const o=t.s.publicKey,a=this.encryptAndHash(t.ss,o);this.mixKey(t.ss,this.dh(t.s.privateKey,t.re));const l=this.encryptAndHash(t.ss,r);return{ne:n,ns:a,ciphertext:l}}writeMessageC(t,r){const n=t.s.publicKey,o=this.encryptAndHash(t.ss,n);this.mixKey(t.ss,this.dh(t.s.privateKey,t.re));const a=this.encryptAndHash(t.ss,r),c={ne:this.createEmptyKey(),ns:o,ciphertext:a},{cs1:u,cs2:g}=this.split(t.ss);return{h:t.ss.h,messageBuffer:c,cs1:u,cs2:g}}readMessageA(t,r){return isValidPublicKey(r.ne)&&(t.re=r.ne),this.mixHash(t.ss,t.re),this.decryptAndHash(t.ss,r.ciphertext)}readMessageB(t,r){if(isValidPublicKey(r.ne)&&(t.re=r.ne),this.mixHash(t.ss,t.re),!t.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(t.ss,this.dh(t.e.privateKey,t.re));const{plaintext:n,valid:o}=this.decryptAndHash(t.ss,r.ns);o&&isValidPublicKey(n)&&(t.rs=n),this.mixKey(t.ss,this.dh(t.e.privateKey,t.rs));const{plaintext:a,valid:l}=this.decryptAndHash(t.ss,r.ciphertext);return{plaintext:a,valid:o&&l}}readMessageC(t,r){const{plaintext:n,valid:o}=this.decryptAndHash(t.ss,r.ns);if(o&&isValidPublicKey(n)&&(t.rs=n),!t.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(t.ss,this.dh(t.e.privateKey,t.rs));const{plaintext:a,valid:l}=this.decryptAndHash(t.ss,r.ciphertext),{cs1:c,cs2:u}=this.split(t.ss);return{h:t.ss.h,plaintext:a,valid:o&&l,cs1:c,cs2:u}}initSession(t,r,n){const o=this.createEmptyKey(),a=new Uint8Array(32);let l;return t?l=this.initializeInitiator(r,n,a,o):l=this.initializeResponder(r,n,a,o),{hs:l,i:t,mc:0}}sendMessage(t,r,n){let o;if(t.mc===0)o=this.writeMessageA(t.hs,r,n);else if(t.mc===1)o=this.writeMessageB(t.hs,r);else if(t.mc===2){const{h:a,messageBuffer:l,cs1:c,cs2:u}=this.writeMessageC(t.hs,r);o=l,t.h=a,t.cs1=c,t.cs2=u}else if(t.mc>2)if(t.i){if(!t.cs1)throw new Error("CS1 (cipher state) is not defined");o=this.writeMessageRegular(t.cs1,r)}else{if(!t.cs2)throw new Error("CS2 (cipher state) is not defined");o=this.writeMessageRegular(t.cs2,r)}else throw new Error("Session invalid.");return t.mc++,o}recvMessage(t,r){let n=new Uint8Array(0),o=!1;if(t.mc===0)({plaintext:n,valid:o}=this.readMessageA(t.hs,r));else if(t.mc===1)({plaintext:n,valid:o}=this.readMessageB(t.hs,r));else if(t.mc===2){const{h:a,plaintext:l,valid:c,cs1:u,cs2:g}=this.readMessageC(t.hs,r);n=l,o=c,t.h=a,t.cs1=u,t.cs2=g}return t.mc++,{plaintext:n,valid:o}}}class XXHandshake{constructor(t,r,n,o,a,l,c,u){Xe(this,"isInitiator");Xe(this,"session");Xe(this,"remotePeer");Xe(this,"remoteExtensions",{webtransportCerthashes:[]});Xe(this,"payload");Xe(this,"connection");Xe(this,"xx");Xe(this,"staticKeypair");Xe(this,"prologue");this.isInitiator=t,this.payload=r,this.prologue=n,this.staticKeypair=a,this.connection=l,c&&(this.remotePeer=c),this.xx=u??new XX(o),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair)}async propose(){if(logLocalStaticKeys(this.session.hs.s),this.isInitiator){log$B.trace("Stage 0 - Initiator starting to send first message.");const t=this.xx.sendMessage(this.session,new Uint8Array(0));await this.connection.write(encode0(t)),log$B.trace("Stage 0 - Initiator finished sending first message."),logLocalEphemeralKeys(this.session.hs.e)}else{log$B.trace("Stage 0 - Responder waiting to receive first message...");const t=decode0((await this.connection.read()).subarray()),{valid:r}=this.xx.recvMessage(this.session,t);if(!r)throw new InvalidCryptoExchangeError("xx handshake stage 0 validation fail");log$B.trace("Stage 0 - Responder received first message."),logRemoteEphemeralKey(this.session.hs.re)}}async exchange(){if(this.isInitiator){log$B.trace("Stage 1 - Initiator waiting to receive first message from responder...");const t=decode1((await this.connection.read()).subarray()),{plaintext:r,valid:n}=this.xx.recvMessage(this.session,t);if(!n)throw new InvalidCryptoExchangeError("xx handshake stage 1 validation fail");log$B.trace("Stage 1 - Initiator received the message."),logRemoteEphemeralKey(this.session.hs.re),logRemoteStaticKey(this.session.hs.rs),log$B.trace("Initiator going to check remote's signature...");try{const o=decodePayload(r);this.remotePeer=this.remotePeer||await getPeerIdFromPayload(o),await verifySignedPayload(this.session.hs.rs,o,this.remotePeer),this.setRemoteNoiseExtension(o.extensions)}catch(o){const a=o;throw new UnexpectedPeerError(`Error occurred while verifying signed payload: ${a.message}`)}log$B.trace("All good with the signature!")}else{log$B.trace("Stage 1 - Responder sending out first message with signed payload and static key.");const t=this.xx.sendMessage(this.session,this.payload);await this.connection.write(encode1(t)),log$B.trace("Stage 1 - Responder sent the second handshake message with signed payload."),logLocalEphemeralKeys(this.session.hs.e)}}async finish(){if(this.isInitiator){log$B.trace("Stage 2 - Initiator sending third handshake message.");const t=this.xx.sendMessage(this.session,this.payload);await this.connection.write(encode2(t)),log$B.trace("Stage 2 - Initiator sent message with signed payload.")}else{log$B.trace("Stage 2 - Responder waiting for third handshake message...");const t=decode2((await this.connection.read()).subarray()),{plaintext:r,valid:n}=this.xx.recvMessage(this.session,t);if(!n)throw new InvalidCryptoExchangeError("xx handshake stage 2 validation fail");log$B.trace("Stage 2 - Responder received the message, finished handshake.");try{const o=decodePayload(r);this.remotePeer=this.remotePeer||await getPeerIdFromPayload(o),await verifySignedPayload(this.session.hs.rs,o,this.remotePeer),this.setRemoteNoiseExtension(o.extensions)}catch(o){const a=o;throw new UnexpectedPeerError(`Error occurred while verifying signed payload: ${a.message}`)}}logCipherState(this.session)}encrypt(t,r){const n=this.getCS(r);return this.xx.encryptWithAd(n,new Uint8Array(0),t)}decrypt(t,r,n){const o=this.getCS(r,!1);return this.xx.decryptWithAd(o,new Uint8Array(0),t,n)}getRemoteStaticKey(){return this.session.hs.rs}getCS(t,r=!0){if(!t.cs1||!t.cs2)throw new InvalidCryptoExchangeError("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?r?t.cs1:t.cs2:r?t.cs2:t.cs1}setRemoteNoiseExtension(t){t&&(this.remoteExtensions=t)}}function registerMetrics(e){return{xxHandshakeSuccesses:e.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:e.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:e.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:e.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:e.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}class Noise{constructor(t={}){Xe(this,"protocol","/noise");Xe(this,"crypto");Xe(this,"prologue");Xe(this,"staticKeys");Xe(this,"extensions");Xe(this,"metrics");const{staticNoiseKey:r,extensions:n,crypto:o,prologueBytes:a,metrics:l}=t;this.crypto=o??pureJsCrypto,this.extensions=n,this.metrics=l?registerMetrics(l):void 0,r?this.staticKeys=this.crypto.generateX25519KeyPairFromSeed(r):this.staticKeys=this.crypto.generateX25519KeyPair(),this.prologue=a??new Uint8Array(0)}async secureOutbound(t,r,n){const o=lpStream(r,{lengthEncoder:uint16BEEncode,lengthDecoder:uint16BEDecode,maxDataLength:NOISE_MSG_MAX_LENGTH_BYTES}),a=await this.performHandshake({connection:o,isInitiator:!0,localPeer:t,remotePeer:n});return{conn:await this.createSecureConnection(o,a),remoteExtensions:a.remoteExtensions,remotePeer:a.remotePeer}}async secureInbound(t,r,n){const o=lpStream(r,{lengthEncoder:uint16BEEncode,lengthDecoder:uint16BEDecode,maxDataLength:NOISE_MSG_MAX_LENGTH_BYTES}),a=await this.performHandshake({connection:o,isInitiator:!1,localPeer:t,remotePeer:n});return{conn:await this.createSecureConnection(o,a),remotePeer:a.remotePeer,remoteExtensions:a.remoteExtensions}}async performHandshake(t){const r=await getPayload(t.localPeer,this.staticKeys.publicKey,this.extensions);return this.performXXHandshake(t,r)}async performXXHandshake(t,r){const{isInitiator:n,remotePeer:o,connection:a}=t,l=new XXHandshake(n,r,this.prologue,this.crypto,this.staticKeys,a,o);try{await l.propose(),await l.exchange(),await l.finish(),this.metrics?.xxHandshakeSuccesses.increment()}catch(c){if(this.metrics?.xxHandshakeErrors.increment(),c instanceof Error)throw c.message=`Error occurred during XX handshake: ${c.message}`,c}return l}async createSecureConnection(t,r){const[n,o]=duplexPair(),a=t.unwrap();return await pipe(n,encryptStream(r,this.metrics),a,l=>decode$a(l,{lengthDecoder:uint16BEDecode}),decryptStream(r,this.metrics),n),o}}function noise(e={}){return()=>new Noise(e)}var en;class EventEmitter$2 extends EventTarget{constructor(){super(...arguments);Er(this,en,new Map)}listenerCount(r){const n=ir(this,en).get(r);return n==null?0:n.length}addEventListener(r,n,o){super.addEventListener(r,n,o);let a=ir(this,en).get(r);a==null&&(a=[],ir(this,en).set(r,a)),a.push({callback:n,once:(o!==!0&&o!==!1&&o?.once)??!1})}removeEventListener(r,n,o){super.removeEventListener(r.toString(),n??null,o);let a=ir(this,en).get(r);a!=null&&(a=a.filter(({callback:l})=>l!==n),ir(this,en).set(r,a))}dispatchEvent(r){const n=super.dispatchEvent(r);let o=ir(this,en).get(r.type);return o==null||(o=o.filter(({once:a})=>!a),ir(this,en).set(r.type,o)),n}safeDispatchEvent(r,n){return this.dispatchEvent(new CustomEvent$1(r,n))}}en=new WeakMap;class CustomEventPolyfill extends Event{constructor(r,n){super(r,n);Xe(this,"detail");this.detail=n?.detail}}const CustomEvent$1=globalThis.CustomEvent??CustomEventPolyfill,peerDiscovery=Symbol.for("@libp2p/peer-discovery");class Parser{constructor(){Xe(this,"index",0);Xe(this,"input","")}new(t){return this.index=0,this.input=t,this}readAtomically(t){const r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){const r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{const r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let a=0,l=0;const c=this.peekChar();if(c===void 0)return;const u=c==="0",g=2**(8*o)-1;for(;;){const b=this.readAtomically(()=>{const x=this.readChar();if(x===void 0)return;const S=Number.parseInt(x,t);if(!Number.isNaN(S))return S});if(b===void 0)break;if(a*=t,a+=b,a>g||(l+=1,r!==void 0&&l>r))return}if(l!==0)return!n&&u&&l>1?void 0:a})}readIPv4Addr(){return this.readAtomically(()=>{const t=new Uint8Array(4);for(let r=0;rthis.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){const t=r=>{for(let n=0;nthis.readIPv4Addr());if(l!==void 0)return r[o]=l[0],r[o+1]=l[1],r[o+2]=l[2],r[o+3]=l[3],[o+4,!0]}const a=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(a===void 0)return[o,!1];r[o]=a>>8,r[o+1]=a&255}return[r.length,!1]};return this.readAtomically(()=>{const r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;const a=new Uint8Array(14),l=16-(n+2),[c]=t(a.subarray(0,l));return r.set(a.subarray(0,c),16-c),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}}const MAX_IPV6_LENGTH=45,MAX_IPV4_LENGTH=15,parser$4=new Parser;function parseIPv4(e){if(!(e.length>MAX_IPV4_LENGTH))return parser$4.new(e).parseWith(()=>parser$4.readIPv4Addr())}function parseIPv6(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>MAX_IPV6_LENGTH))return parser$4.new(e).parseWith(()=>parser$4.readIPv6Addr())}function parseIP(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>MAX_IPV6_LENGTH))return parser$4.new(e).parseWith(()=>parser$4.readIPAddr())}function isIPv4(e){return Boolean(parseIPv4(e))}function isIPv6(e){return Boolean(parseIPv6(e))}function isIP(e){return Boolean(parseIP(e))}const isV4=isIPv4,isV6=isIPv6,toBytes=function(e){let t=0;if(e=e.toString().trim(),isV4(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(isV6(e)){const r=e.split(":",8);let n;for(n=0;n0;n--)a.push("0");r.splice.apply(r,a)}const o=new Uint8Array(t+16);for(n=0;n>8&255,o[t++]=a&255}return o}throw new Error("invalid ip address")},toString$4=function(e,t=0,r){t=~~t,r=r??e.length-t;const n=new DataView(e.buffer);if(r===4){const o=[];for(let a=0;a{const t=createProtocol(...e);codes$8[t.code]=t,names$3[t.name]=t});function createProtocol(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(o)}}function getProtocol(e){if(typeof e=="number"){if(codes$8[e]!=null)return codes$8[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(names$3[e]!=null)return names$3[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}getProtocol("ip4");getProtocol("ip6");getProtocol("ipcidr");function convertToString(e,t){switch(getProtocol(e).code){case 4:case 41:return bytes2ip(t);case 42:return bytes2str(t);case 6:case 273:case 33:case 132:return bytes2port(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bytes2str(t);case 421:return bytes2mh(t);case 444:return bytes2onion(t);case 445:return bytes2onion(t);case 466:return bytes2mb(t);default:return toString$5(t,"base16")}}function convertToBytes(e,t){switch(getProtocol(e).code){case 4:return ip2bytes(t);case 41:return ip2bytes(t);case 42:return str2bytes(t);case 6:case 273:case 33:case 132:return port2bytes(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return str2bytes(t);case 421:return mh2bytes(t);case 444:return onion2bytes(t);case 445:return onion32bytes(t);case 466:return mb2bytes(t);default:return fromString$1(t,"base16")}}const decoders=Object.values(bases).map(e=>e.decoder),anybaseDecoder=function(){let e=decoders[0].or(decoders[1]);return decoders.slice(2).forEach(t=>e=e.or(t)),e}();function ip2bytes(e){if(!isIP(e))throw new Error("invalid ip address");return toBytes(e)}function bytes2ip(e){const t=toString$4(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!isIP(t))throw new Error("invalid ip address");return t}function port2bytes(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function bytes2port(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function str2bytes(e){const t=fromString$1(e),r=Uint8Array.from(encode$d(t.length));return concat$1([r,t],r.length+t.length)}function bytes2str(e){const t=decode$b(e);if(e=e.slice(encodingLength$2(t)),e.length!==t)throw new Error("inconsistent lengths");return toString$5(e)}function mh2bytes(e){let t;e[0]==="Q"||e[0]==="1"?t=decode$5(base58btc$1.decode(`z${e}`)).bytes:t=CID.parse(e).multihash.bytes;const r=Uint8Array.from(encode$d(t.length));return concat$1([r,t],r.length+t.length)}function mb2bytes(e){const t=anybaseDecoder.decode(e),r=Uint8Array.from(encode$d(t.length));return concat$1([r,t],r.length+t.length)}function bytes2mb(e){const t=decode$b(e),r=e.slice(encodingLength$2(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+toString$5(r,"base64url")}function bytes2mh(e){const t=decode$b(e),r=e.slice(encodingLength$2(t));if(r.length!==t)throw new Error("inconsistent lengths");return toString$5(r,"base58btc")}function onion2bytes(e){const t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);const r=base32$2.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const o=port2bytes(n);return concat$1([r,o],r.length+o.length)}function onion32bytes(e){const t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);const r=base32$2.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const o=port2bytes(n);return concat$1([r,o],r.length+o.length)}function bytes2onion(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=toString$5(t,"base32"),o=bytes2port(r);return`${n}:${o}`}function stringToMultiaddrParts(e){e=cleanPath(e);const t=[],r=[];let n=null;const o=e.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let a=0;a=o.length)throw ParseError("invalid address: "+e);if(c.path===!0){n=cleanPath(o.slice(a).join("/")),t.push([c.code,convertToBytes(c.code,n)]),r.push([c.code,n]);break}const u=convertToBytes(c.code,o[a]);t.push([c.code,u]),r.push([c.code,convertToString(c.code,u)])}return{string:stringTuplesToString(r),bytes:tuplesToBytes(t),tuples:t,stringTuples:r,path:n}}function bytesToMultiaddrParts(e){const t=[],r=[];let n=null,o=0;for(;oe.length)throw ParseError("Invalid address Uint8Array: "+toString$5(e,"base16"));t.push([a,g]);const b=convertToString(a,g);if(r.push([a,b]),c.path===!0){n=b;break}}return{bytes:Uint8Array.from(e),string:stringTuplesToString(r),tuples:t,stringTuples:r,path:n}}function stringTuplesToString(e){const t=[];return e.map(r=>{const n=getProtocol(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),cleanPath(t.join("/"))}function tuplesToBytes(e){return concat$1(e.map(t=>{const r=getProtocol(t[0]);let n=Uint8Array.from(encode$d(r.code));return t.length>1&&t[1]!=null&&(n=concat$1([n,t[1]])),n}))}function sizeForAddr(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{const r=decode$b(t instanceof Uint8Array?t:Uint8Array.from(t));return r+encodingLength$2(r)}}function cleanPath(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}function ParseError(e){return new Error("Error parsing address: "+e)}const inspect=Symbol.for("nodejs.util.inspect.custom"),DNS_CODES=[getProtocol("dns").code,getProtocol("dns4").code,getProtocol("dns6").code,getProtocol("dnsaddr").code],resolvers=new Map,symbol$2=Symbol.for("@multiformats/js-multiaddr/multiaddr");function isMultiaddr(e){return Boolean(e?.[symbol$2])}var Mi,Rn,fs,ps,Xl;const ai=class{constructor(t){Xe(this,"bytes");Er(this,Mi,void 0);Er(this,Rn,void 0);Er(this,fs,void 0);Er(this,ps,void 0);Xe(this,Xl,!0);t==null&&(t="");let r;if(t instanceof Uint8Array)r=bytesToMultiaddrParts(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=stringToMultiaddrParts(t)}else if(isMultiaddr(t))r=bytesToMultiaddrParts(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,Ln(this,Mi,r.string),Ln(this,Rn,r.tuples),Ln(this,fs,r.stringTuples),Ln(this,ps,r.path)}toString(){return ir(this,Mi)}toJSON(){return this.toString()}toOptions(){let t,r,n,o,a="";const l=getProtocol("tcp"),c=getProtocol("udp"),u=getProtocol("ip4"),g=getProtocol("ip6"),b=getProtocol("dns6"),x=getProtocol("ip6zone");for(const[$,k]of this.stringTuples())$===x.code&&(a=`%${k??""}`),DNS_CODES.includes($)&&(r=l.name,o=443,n=`${k??""}${a}`,t=$===b.code?6:4),($===l.code||$===c.code)&&(r=getProtocol($).name,o=parseInt(k??"")),($===u.code||$===g.code)&&(r=getProtocol($).name,n=`${k??""}${a}`,t=$===g.code?6:4);if(t==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:r,port:o}}protos(){return ir(this,Rn).map(([t])=>Object.assign({},getProtocol(t)))}protoCodes(){return ir(this,Rn).map(([t])=>t)}protoNames(){return ir(this,Rn).map(([t])=>getProtocol(t).name)}tuples(){return ir(this,Rn)}stringTuples(){return ir(this,fs)}encapsulate(t){return t=new ai(t),new ai(this.toString()+t.toString())}decapsulate(t){const r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new ai(n.slice(0,o))}decapsulateCode(t){const r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new ai(tuplesToBytes(r.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===names$3.p2p.code&&t.push([n,o]),n===names$3["p2p-circuit"].code&&(t=[])});const r=t.pop();if(r?.[1]!=null){const n=r[1];return n[0]==="Q"||n[0]==="1"?toString$5(base58btc$1.decode(`z${n}`),"base58btc"):toString$5(CID.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return ir(this,ps)}equals(t){return equals$2(this.bytes,t.bytes)}async resolve(t){const r=this.protos().find(a=>a.resolvable);if(r==null)return[this];const n=resolvers.get(r.name);if(n==null)throw new CodeError(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(a=>new ai(a))}nodeAddress(){const t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){const r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[(Xl=symbol$2,inspect)](){return`Multiaddr(${ir(this,Mi)})`}};let DefaultMultiaddr=ai;Mi=new WeakMap,Rn=new WeakMap,fs=new WeakMap,ps=new WeakMap;function multiaddr(e){return new DefaultMultiaddr(e)}const DNS4=base$3("dns4"),DNS6=base$3("dns6"),DNSADDR=base$3("dnsaddr"),DNS=or$2(base$3("dns"),DNSADDR,DNS4,DNS6),IP=or$2(base$3("ip4"),base$3("ip6")),TCP=or$2(and$1(IP,base$3("tcp")),and$1(DNS,base$3("tcp"))),UDP=and$1(IP,base$3("udp")),UTP=and$1(UDP,base$3("utp")),QUIC=and$1(UDP,base$3("quic")),QUICV1=and$1(UDP,base$3("quic-v1")),_WebSockets$1=or$2(and$1(TCP,base$3("ws")),and$1(DNS,base$3("ws"))),WebSockets$1=or$2(and$1(_WebSockets$1,base$3("p2p")),_WebSockets$1),_WebSocketsSecure$1=or$2(and$1(TCP,base$3("wss")),and$1(DNS,base$3("wss")),and$1(TCP,base$3("tls"),base$3("ws")),and$1(DNS,base$3("tls"),base$3("ws"))),WebSocketsSecure=or$2(and$1(_WebSocketsSecure$1,base$3("p2p")),_WebSocketsSecure$1),HTTP=or$2(and$1(TCP,base$3("http")),and$1(IP,base$3("http")),and$1(DNS,base$3("http"))),HTTPS=or$2(and$1(TCP,base$3("https")),and$1(IP,base$3("https")),and$1(DNS,base$3("https"))),_WebRTCDirect$1=and$1(UDP,base$3("webrtc-direct"),base$3("certhash")),WebRTCDirect=or$2(and$1(_WebRTCDirect$1,base$3("p2p")),_WebRTCDirect$1),_WebTransport$1=and$1(QUICV1,base$3("webtransport"),base$3("certhash"),base$3("certhash")),WebTransport=or$2(and$1(_WebTransport$1,base$3("p2p")),_WebTransport$1),P2PWebRTCStar=or$2(and$1(WebSockets$1,base$3("p2p-webrtc-star"),base$3("p2p")),and$1(WebSocketsSecure,base$3("p2p-webrtc-star"),base$3("p2p")),and$1(WebSockets$1,base$3("p2p-webrtc-star")),and$1(WebSocketsSecure,base$3("p2p-webrtc-star"))),P2PWebRTCDirect=or$2(and$1(HTTP,base$3("p2p-webrtc-direct"),base$3("p2p")),and$1(HTTPS,base$3("p2p-webrtc-direct"),base$3("p2p")),and$1(HTTP,base$3("p2p-webrtc-direct")),and$1(HTTPS,base$3("p2p-webrtc-direct"))),Reliable=or$2(_WebSockets$1,_WebSocketsSecure$1,HTTP,HTTPS,P2PWebRTCStar,P2PWebRTCDirect,TCP,UTP,QUIC,DNS,WebRTCDirect,WebTransport),_P2P$1=or$2(and$1(Reliable,base$3("p2p")),P2PWebRTCStar,P2PWebRTCDirect,WebRTCDirect,WebTransport,base$3("p2p")),_Circuit$1=or$2(and$1(_P2P$1,base$3("p2p-circuit"),_P2P$1),and$1(_P2P$1,base$3("p2p-circuit")),and$1(base$3("p2p-circuit"),_P2P$1),and$1(Reliable,base$3("p2p-circuit")),and$1(base$3("p2p-circuit"),Reliable),base$3("p2p-circuit")),CircuitRecursive=()=>or$2(and$1(_Circuit$1,CircuitRecursive),_Circuit$1),Circuit$1=CircuitRecursive(),P2P=or$2(and$1(Circuit$1,_P2P$1,Circuit$1),and$1(_P2P$1,Circuit$1),and$1(Circuit$1,_P2P$1),Circuit$1,_P2P$1);function makeMatchesFunction(e){function t(r){let n;try{n=multiaddr(r)}catch{return!1}const o=e(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function and$1(...e){function t(r){if(r.length(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:makeMatchesFunction(t),partialMatch:t}}function or$2(...e){function t(n){let o=null;return e.some(a=>{const l=typeof a=="function"?a().partialMatch(n):a.partialMatch(n);return l!=null?(o=l,!0):!1}),o}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:makeMatchesFunction(t),partialMatch:t}}function base$3(e){const t=e;function r(o){let a;try{a=multiaddr(o)}catch{return!1}const l=a.protoNames();return l.length===1&&l[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:r,partialMatch:n}}const log$A=logger("libp2p:bootstrap"),DEFAULT_BOOTSTRAP_TAG_NAME="bootstrap",DEFAULT_BOOTSTRAP_TAG_VALUE=50,DEFAULT_BOOTSTRAP_TAG_TTL=12e4,DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT=1e3;var Ql,Jl;class Bootstrap extends EventEmitter$2{constructor(r,n={list:[]}){if(n.list==null||n.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super();Xe(this,"timer");Xe(this,"list");Xe(this,"timeout");Xe(this,"components");Xe(this,"_init");Xe(this,Ql,this);Xe(this,Jl,"@libp2p/bootstrap");this.components=r,this.timeout=n.timeout??DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT,this.list=[];for(const o of n.list){if(!P2P.matches(o)){log$A.error("Invalid multiaddr");continue}const a=multiaddr(o),l=a.getPeerId();if(l==null){log$A.error("Invalid bootstrap multiaddr without peer id");continue}const c={id:peerIdFromString(l),multiaddrs:[a],protocols:[]};this.list.push(c)}this._init=n}isStarted(){return Boolean(this.timer)}start(){this.isStarted()||(log$A("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(r=>{log$A.error(r)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(const r of this.list){if(await this.components.peerStore.merge(r.id,{tags:{[this._init.tagName??DEFAULT_BOOTSTRAP_TAG_NAME]:{value:this._init.tagValue??DEFAULT_BOOTSTRAP_TAG_VALUE,ttl:this._init.tagTTL??DEFAULT_BOOTSTRAP_TAG_TTL}}}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:r})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}}Ql=peerDiscovery,Jl=Symbol.toStringTag,Xe(Bootstrap,"tag","bootstrap");function bootstrap(e){return t=>new Bootstrap(t,e)}var TopicValidatorResult;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(TopicValidatorResult||(TopicValidatorResult={}));function mapIterable(e,t){const r={[Symbol.iterator]:()=>r,next:()=>{const n=e.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return r}class PeerMap{constructor(t){Xe(this,"map");if(this.map=new Map,t!=null)for(const[r,n]of t.entries())this.map.set(r.toString(),n)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){this.map.delete(t.toString())}entries(){return mapIterable(this.map.entries(),t=>[peerIdFromString(t[0]),t[1]])}forEach(t){this.map.forEach((r,n)=>{t(r,peerIdFromString(n),this)})}get(t){return this.map.get(t.toString())}has(t){return this.map.has(t.toString())}set(t,r){this.map.set(t.toString(),r)}keys(){return mapIterable(this.map.keys(),t=>peerIdFromString(t))}values(){return this.map.values()}get size(){return this.map.size}}class PeerSet{constructor(t){Xe(this,"set");if(this.set=new Set,t!=null)for(const r of t)this.set.add(r.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return mapIterable(this.set.entries(),t=>{const r=peerIdFromString(t[0]);return[r,r]})}forEach(t){this.set.forEach(r=>{const n=peerIdFromString(r);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return mapIterable(this.set.values(),t=>peerIdFromString(t))}intersection(t){const r=new PeerSet;for(const n of t)this.has(n)&&r.add(n);return r}difference(t){const r=new PeerSet;for(const n of this)t.has(n)||r.add(n);return r}union(t){const r=new PeerSet;for(const n of t)r.add(n);for(const n of this)r.add(n);return r}}var eventemitter3={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function o(u,g,b){this.fn=u,this.context=g,this.once=b||!1}function a(u,g,b,x,S){if(typeof b!="function")throw new TypeError("The listener must be a function");var $=new o(b,x||u,S),k=r?r+g:g;return u._events[k]?u._events[k].fn?u._events[k]=[u._events[k],$]:u._events[k].push($):(u._events[k]=$,u._eventsCount++),u}function l(u,g){--u._eventsCount===0?u._events=new n:delete u._events[g]}function c(){this._events=new n,this._eventsCount=0}c.prototype.eventNames=function(){var g=[],b,x;if(this._eventsCount===0)return g;for(x in b=this._events)t.call(b,x)&&g.push(r?x.slice(1):x);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(b)):g},c.prototype.listeners=function(g){var b=r?r+g:g,x=this._events[b];if(!x)return[];if(x.fn)return[x.fn];for(var S=0,$=x.length,k=new Array($);S<$;S++)k[S]=x[S].fn;return k},c.prototype.listenerCount=function(g){var b=r?r+g:g,x=this._events[b];return x?x.fn?1:x.length:0},c.prototype.emit=function(g,b,x,S,$,k){var T=r?r+g:g;if(!this._events[T])return!1;var D=this._events[T],I=arguments.length,O,N;if(D.fn){switch(D.once&&this.removeListener(g,D.fn,void 0,!0),I){case 1:return D.fn.call(D.context),!0;case 2:return D.fn.call(D.context,b),!0;case 3:return D.fn.call(D.context,b,x),!0;case 4:return D.fn.call(D.context,b,x,S),!0;case 5:return D.fn.call(D.context,b,x,S,$),!0;case 6:return D.fn.call(D.context,b,x,S,$,k),!0}for(N=1,O=new Array(I-1);NglobalThis.DOMException===void 0?new AbortError$3(e):new DOMException(e),getAbortedReason$1=e=>{const t=e.reason===void 0?getDOMException$1("This operation was aborted."):e.reason;return t instanceof Error?t:getDOMException$1(t)};function pTimeout$1(e,t,r,n){let o;const a=new Promise((l,c)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t===Number.POSITIVE_INFINITY){l(e);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){const{signal:u}=n;u.aborted&&c(getAbortedReason$1(u)),u.addEventListener("abort",()=>{c(getAbortedReason$1(u))})}o=n.customTimers.setTimeout.call(void 0,()=>{if(typeof r=="function"){try{l(r())}catch(b){c(b)}return}const u=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,g=r instanceof Error?r:new TimeoutError$1(u);typeof e.cancel=="function"&&e.cancel(),c(g)},t),(async()=>{try{l(await e)}catch(u){c(u)}finally{n.customTimers.clearTimeout.call(void 0,o)}})()});return a.clear=()=>{clearTimeout(o),o=void 0},a}function lowerBound$1(e,t,r){let n=0,o=e.length;for(;o>0;){const a=Math.trunc(o/2);let l=n+a;r(e[l],t)<=0?(n=++l,o-=a+1):o=a}return n}var __classPrivateFieldGet$1=globalThis&&globalThis.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},_PriorityQueue_queue;class PriorityQueue{constructor(){_PriorityQueue_queue.set(this,[])}enqueue(t,r){r={priority:0,...r};const n={priority:r.priority,run:t};if(this.size&&__classPrivateFieldGet$1(this,_PriorityQueue_queue,"f")[this.size-1].priority>=r.priority){__classPrivateFieldGet$1(this,_PriorityQueue_queue,"f").push(n);return}const o=lowerBound$1(__classPrivateFieldGet$1(this,_PriorityQueue_queue,"f"),n,(a,l)=>l.priority-a.priority);__classPrivateFieldGet$1(this,_PriorityQueue_queue,"f").splice(o,0,n)}dequeue(){const t=__classPrivateFieldGet$1(this,_PriorityQueue_queue,"f").shift();return t?.run}filter(t){return __classPrivateFieldGet$1(this,_PriorityQueue_queue,"f").filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return __classPrivateFieldGet$1(this,_PriorityQueue_queue,"f").length}}_PriorityQueue_queue=new WeakMap;var __classPrivateFieldSet=globalThis&&globalThis.__classPrivateFieldSet||function(e,t,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(e,r):o?o.value=r:t.set(e,r),r},__classPrivateFieldGet=globalThis&&globalThis.__classPrivateFieldGet||function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},_PQueue_instances,_PQueue_carryoverConcurrencyCount,_PQueue_isIntervalIgnored,_PQueue_intervalCount,_PQueue_intervalCap,_PQueue_interval,_PQueue_intervalEnd,_PQueue_intervalId,_PQueue_timeoutId,_PQueue_queue,_PQueue_queueClass,_PQueue_pending,_PQueue_concurrency,_PQueue_isPaused,_PQueue_throwOnTimeout,_PQueue_doesIntervalAllowAnother_get,_PQueue_doesConcurrentAllowAnother_get,_PQueue_next,_PQueue_onResumeInterval,_PQueue_isIntervalPaused_get,_PQueue_tryToStartAnother,_PQueue_initializeIntervalIfNeeded,_PQueue_onInterval,_PQueue_processQueue,_PQueue_throwOnAbort,_PQueue_onEvent;class AbortError$2 extends Error{}class PQueue extends EventEmitter$1{constructor(t){var r,n,o,a;if(super(),_PQueue_instances.add(this),_PQueue_carryoverConcurrencyCount.set(this,void 0),_PQueue_isIntervalIgnored.set(this,void 0),_PQueue_intervalCount.set(this,0),_PQueue_intervalCap.set(this,void 0),_PQueue_interval.set(this,void 0),_PQueue_intervalEnd.set(this,0),_PQueue_intervalId.set(this,void 0),_PQueue_timeoutId.set(this,void 0),_PQueue_queue.set(this,void 0),_PQueue_queueClass.set(this,void 0),_PQueue_pending.set(this,0),_PQueue_concurrency.set(this,void 0),_PQueue_isPaused.set(this,void 0),_PQueue_throwOnTimeout.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:PriorityQueue,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(o=t.interval)===null||o===void 0?void 0:o.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);__classPrivateFieldSet(this,_PQueue_carryoverConcurrencyCount,t.carryoverConcurrencyCount,"f"),__classPrivateFieldSet(this,_PQueue_isIntervalIgnored,t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,"f"),__classPrivateFieldSet(this,_PQueue_intervalCap,t.intervalCap,"f"),__classPrivateFieldSet(this,_PQueue_interval,t.interval,"f"),__classPrivateFieldSet(this,_PQueue_queue,new t.queueClass,"f"),__classPrivateFieldSet(this,_PQueue_queueClass,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,__classPrivateFieldSet(this,_PQueue_throwOnTimeout,t.throwOnTimeout===!0,"f"),__classPrivateFieldSet(this,_PQueue_isPaused,t.autoStart===!1,"f")}get concurrency(){return __classPrivateFieldGet(this,_PQueue_concurrency,"f")}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);__classPrivateFieldSet(this,_PQueue_concurrency,t,"f"),__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_processQueue).call(this)}async add(t,r={}){return r={timeout:this.timeout,throwOnTimeout:__classPrivateFieldGet(this,_PQueue_throwOnTimeout,"f"),...r},new Promise((n,o)=>{__classPrivateFieldGet(this,_PQueue_queue,"f").enqueue(async()=>{var a,l,c;__classPrivateFieldSet(this,_PQueue_pending,(l=__classPrivateFieldGet(this,_PQueue_pending,"f"),l++,l),"f"),__classPrivateFieldSet(this,_PQueue_intervalCount,(c=__classPrivateFieldGet(this,_PQueue_intervalCount,"f"),c++,c),"f");try{if(!((a=r.signal)===null||a===void 0)&&a.aborted)throw new AbortError$2("The task was aborted.");let u=t({signal:r.signal});r.timeout&&(u=pTimeout$1(Promise.resolve(u),r.timeout)),r.signal&&(u=Promise.race([u,__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_throwOnAbort).call(this,r.signal)]));const g=await u;n(g),this.emit("completed",g)}catch(u){if(u instanceof TimeoutError$1&&!r.throwOnTimeout){n();return}o(u),this.emit("error",u)}finally{__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_next).call(this)}},r),this.emit("add"),__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_tryToStartAnother).call(this)})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return __classPrivateFieldGet(this,_PQueue_isPaused,"f")?(__classPrivateFieldSet(this,_PQueue_isPaused,!1,"f"),__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_processQueue).call(this),this):this}pause(){__classPrivateFieldSet(this,_PQueue_isPaused,!0,"f")}clear(){__classPrivateFieldSet(this,_PQueue_queue,new(__classPrivateFieldGet(this,_PQueue_queueClass,"f")),"f")}async onEmpty(){__classPrivateFieldGet(this,_PQueue_queue,"f").size!==0&&await __classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_onEvent).call(this,"empty")}async onSizeLessThan(t){__classPrivateFieldGet(this,_PQueue_queue,"f").size__classPrivateFieldGet(this,_PQueue_queue,"f").size{__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_onResumeInterval).call(this)},r),"f"),!0}return!1},_PQueue_tryToStartAnother=function e(){if(__classPrivateFieldGet(this,_PQueue_queue,"f").size===0)return __classPrivateFieldGet(this,_PQueue_intervalId,"f")&&clearInterval(__classPrivateFieldGet(this,_PQueue_intervalId,"f")),__classPrivateFieldSet(this,_PQueue_intervalId,void 0,"f"),this.emit("empty"),__classPrivateFieldGet(this,_PQueue_pending,"f")===0&&this.emit("idle"),!1;if(!__classPrivateFieldGet(this,_PQueue_isPaused,"f")){const t=!__classPrivateFieldGet(this,_PQueue_instances,"a",_PQueue_isIntervalPaused_get);if(__classPrivateFieldGet(this,_PQueue_instances,"a",_PQueue_doesIntervalAllowAnother_get)&&__classPrivateFieldGet(this,_PQueue_instances,"a",_PQueue_doesConcurrentAllowAnother_get)){const r=__classPrivateFieldGet(this,_PQueue_queue,"f").dequeue();return r?(this.emit("active"),r(),t&&__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_initializeIntervalIfNeeded).call(this),!0):!1}}return!1},_PQueue_initializeIntervalIfNeeded=function e(){__classPrivateFieldGet(this,_PQueue_isIntervalIgnored,"f")||__classPrivateFieldGet(this,_PQueue_intervalId,"f")!==void 0||(__classPrivateFieldSet(this,_PQueue_intervalId,setInterval(()=>{__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_onInterval).call(this)},__classPrivateFieldGet(this,_PQueue_interval,"f")),"f"),__classPrivateFieldSet(this,_PQueue_intervalEnd,Date.now()+__classPrivateFieldGet(this,_PQueue_interval,"f"),"f"))},_PQueue_onInterval=function e(){__classPrivateFieldGet(this,_PQueue_intervalCount,"f")===0&&__classPrivateFieldGet(this,_PQueue_pending,"f")===0&&__classPrivateFieldGet(this,_PQueue_intervalId,"f")&&(clearInterval(__classPrivateFieldGet(this,_PQueue_intervalId,"f")),__classPrivateFieldSet(this,_PQueue_intervalId,void 0,"f")),__classPrivateFieldSet(this,_PQueue_intervalCount,__classPrivateFieldGet(this,_PQueue_carryoverConcurrencyCount,"f")?__classPrivateFieldGet(this,_PQueue_pending,"f"):0,"f"),__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_processQueue).call(this)},_PQueue_processQueue=function e(){for(;__classPrivateFieldGet(this,_PQueue_instances,"m",_PQueue_tryToStartAnother).call(this););},_PQueue_throwOnAbort=async function e(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(new AbortError$2("The task was aborted."))},{once:!0})})},_PQueue_onEvent=async function e(t,r){return new Promise(n=>{const o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})};const codes$7={ERR_INVALID_SIGNATURE_POLICY:"ERR_INVALID_SIGNATURE_POLICY",ERR_UNHANDLED_SIGNATURE_POLICY:"ERR_UNHANDLED_SIGNATURE_POLICY",ERR_MISSING_SIGNATURE:"ERR_MISSING_SIGNATURE",ERR_MISSING_SEQNO:"ERR_MISSING_SEQNO",ERR_MISSING_KEY:"ERR_MISSING_KEY",ERR_INVALID_SIGNATURE:"ERR_INVALID_SIGNATURE",ERR_MISSING_FROM:"ERR_MISSING_FROM",ERR_UNEXPECTED_FROM:"ERR_UNEXPECTED_FROM",ERR_UNEXPECTED_SIGNATURE:"ERR_UNEXPECTED_SIGNATURE",ERR_UNEXPECTED_KEY:"ERR_UNEXPECTED_KEY",ERR_UNEXPECTED_SEQNO:"ERR_UNEXPECTED_SEQNO",ERR_TOPIC_VALIDATOR_REJECT:"ERR_TOPIC_VALIDATOR_REJECT"};class AbortError$1 extends Error{constructor(t,r){super(t??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}}function getIterator(e){if(e!=null){if(typeof e[Symbol.iterator]=="function")return e[Symbol.iterator]();if(typeof e[Symbol.asyncIterator]=="function")return e[Symbol.asyncIterator]();if(typeof e.next=="function")return e}throw new Error("argument is not an iterator or iterable")}function abortableSource(e,t,r){const n=r??{},o=getIterator(e);async function*a(){let l;const c=()=>{l?.()};for(t.addEventListener("abort",c);;){let u;try{if(t.aborted){const{abortMessage:b,abortCode:x}=n;throw new AbortError$1(b,x)}const g=new Promise((b,x)=>{l=()=>{const{abortMessage:S,abortCode:$}=n;x(new AbortError$1(S,$))}});u=await Promise.race([g,o.next()]),l=null}catch(g){t.removeEventListener("abort",c);const b=g.type==="aborted"&&t.aborted;if(b&&n.onAbort!=null&&n.onAbort(e),typeof o.return=="function")try{const x=o.return();x instanceof Promise&&x.catch(S=>{n.onReturnError!=null&&n.onReturnError(S)})}catch(x){n.onReturnError!=null&&n.onReturnError(x)}if(b&&n.returnOnAbort===!0)return;throw g}if(u.done===!0)break;yield u.value}t.removeEventListener("abort",c)}return a()}function abortableSink(e,t,r){return n=>e(abortableSource(n,t,r))}function abortableDuplex(e,t,r){return{sink:abortableSink(e.sink,t,{...r,onAbort:void 0}),source:abortableSource(e.source,t,r)}}const log$z=logger("libp2p-pubsub:peer-streams");class PeerStreams extends EventEmitter$2{constructor(r){super();Xe(this,"id");Xe(this,"protocol");Xe(this,"outboundStream");Xe(this,"inboundStream");Xe(this,"_rawOutboundStream");Xe(this,"_rawInboundStream");Xe(this,"_inboundAbortController");Xe(this,"closed");this.id=r.id,this.protocol=r.protocol,this._inboundAbortController=new AbortController,this.closed=!1}get isReadable(){return Boolean(this.inboundStream)}get isWritable(){return Boolean(this.outboundStream)}write(r){if(this.outboundStream==null){const n=this.id.toString();throw new Error("No writable connection to "+n)}this.outboundStream.push(r instanceof Uint8Array?new Uint8ArrayList(r):r)}attachInboundStream(r){return this._rawInboundStream=r,this.inboundStream=abortableSource(pipe(this._rawInboundStream,n=>decode$a(n)),this._inboundAbortController.signal,{returnOnAbort:!0}),this.dispatchEvent(new CustomEvent$1("stream:inbound")),this.inboundStream}async attachOutboundStream(r){const n=this.outboundStream;return this.outboundStream!=null&&this.outboundStream.end(),this._rawOutboundStream=r,this.outboundStream=pushable({objectMode:!0,onEnd:o=>{this._rawOutboundStream!=null&&this._rawOutboundStream.closeWrite().catch(a=>{log$z("error closing outbound stream",a)}),this._rawOutboundStream=void 0,this.outboundStream=void 0,o!=null&&this.dispatchEvent(new CustomEvent$1("close"))}}),pipe(this.outboundStream,o=>encode$c(o),this._rawOutboundStream).catch(o=>{log$z.error(o)}),n==null&&this.dispatchEvent(new CustomEvent$1("stream:outbound")),this.outboundStream}close(){this.closed||(this.closed=!0,this.outboundStream!=null&&this.outboundStream.end(),this.inboundStream!=null&&this._inboundAbortController.abort(),this._rawOutboundStream=void 0,this.outboundStream=void 0,this._rawInboundStream=void 0,this.inboundStream=void 0,this.dispatchEvent(new CustomEvent$1("close")))}}const hashName={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function pbkdf2(e,t,r,n,o){if(o!=="sha1"&&o!=="sha2-256"&&o!=="sha2-512"){const c=Object.keys(hashName).join(" / ");throw new CodeError(`Hash '${o}' is unknown or not supported. Must be ${c}`,"ERR_UNSUPPORTED_HASH_TYPE")}const a=hashName[o],l=pbkdf2$1(e,t,r,n,a);return util$7.exports.encode64(l,null)}function randomSeqno(){return BigInt(`0x${toString$5(randomBytes(8),"base16")}`)}const msgId=(e,t)=>{const r=fromString$1(t.toString(16).padStart(16,"0"),"base16"),n=new Uint8Array(e.length+r.length);return n.set(e,0),n.set(r,e.length),n},noSignMsgId=e=>sha256$1.encode(e),ensureArray=function(e){return Array.isArray(e)?e:[e]},isSigned=async e=>{if(e.sequenceNumber==null||e.from==null||e.signature==null)return!1;const t=peerIdFromBytes(e.from);return t.publicKey!=null?!0:e.key!=null?(await peerIdFromKeys(e.key)).equals(t):!1},toMessage=async e=>{if(e.from==null)throw new CodeError("RPC message was missing from",codes$7.ERR_MISSING_FROM);if(!await isSigned(e))return{type:"unsigned",topic:e.topic??"",data:e.data??new Uint8Array(0)};const t=peerIdFromBytes(e.from),r={type:"signed",from:peerIdFromBytes(e.from),topic:e.topic??"",sequenceNumber:bigIntFromBytes(e.sequenceNumber??new Uint8Array(0)),data:e.data??new Uint8Array(0),signature:e.signature??new Uint8Array(0),key:e.key??t.publicKey??new Uint8Array(0)};if(r.key.length===0)throw new CodeError("Signed RPC message was missing key",codes$7.ERR_MISSING_KEY);return r},toRpcMessage=e=>e.type==="signed"?{from:e.from.multihash.bytes,data:e.data,sequenceNumber:bigIntToBytes(e.sequenceNumber),topic:e.topic,signature:e.signature,key:e.key}:{data:e.data,topic:e.topic},bigIntToBytes=e=>{let t=e.toString(16);return t.length%2!==0&&(t=`0${t}`),fromString$1(t,"base16")},bigIntFromBytes=e=>BigInt(`0x${toString$5(e,"base16")}`),SignPrefix=fromString$1("libp2p-pubsub:");async function signMessage(e,t,r){if(e.privateKey==null)throw new Error("Cannot sign message, no private key present");if(e.publicKey==null)throw new Error("Cannot sign message, no public key present");const n={type:"signed",topic:t.topic,data:t.data,sequenceNumber:t.sequenceNumber,from:e},o=concat$1([SignPrefix,r(toRpcMessage(n)).subarray()]),a=await unmarshalPrivateKey(e.privateKey);return n.signature=await a.sign(o),n.key=e.publicKey,n}async function verifySignature(e,t){if(e.type!=="signed")throw new Error('Message type must be "signed" to be verified');if(e.signature==null)throw new Error("Message must contain a signature to be verified");if(e.from==null)throw new Error("Message must contain a from property to be verified");const r=concat$1([SignPrefix,t({...toRpcMessage(e),signature:void 0,key:void 0}).subarray()]),n=await messagePublicKey(e);return unmarshalPublicKey(n).verify(r,e.signature)}async function messagePublicKey(e){if(e.type!=="signed")throw new Error('Message type must be "signed" to have a public key');if(e.from==null)throw new Error("Could not get the public key from the originator id");if(e.key!=null){const t=await peerIdFromKeys(e.key);if(t.publicKey!=null)return t.publicKey}if(e.from.publicKey!=null)return e.from.publicKey;throw new Error("Could not get the public key from the originator id")}const log$y=logger("libp2p:pubsub");class PubSubBaseProtocol extends EventEmitter$2{constructor(r,n){super();Xe(this,"started");Xe(this,"topics");Xe(this,"subscriptions");Xe(this,"peers");Xe(this,"globalSignaturePolicy");Xe(this,"canRelayMessage");Xe(this,"emitSelf");Xe(this,"topicValidators");Xe(this,"queue");Xe(this,"multicodecs");Xe(this,"components");Xe(this,"_registrarTopologyIds");Xe(this,"enabled");Xe(this,"maxInboundStreams");Xe(this,"maxOutboundStreams");const{multicodecs:o=[],globalSignaturePolicy:a="StrictSign",canRelayMessage:l=!1,emitSelf:c=!1,messageProcessingConcurrency:u=10,maxInboundStreams:g=1,maxOutboundStreams:b=1}=n;this.components=r,this.multicodecs=ensureArray(o),this.enabled=n.enabled!==!1,this.started=!1,this.topics=new Map,this.subscriptions=new Set,this.peers=new PeerMap,this.globalSignaturePolicy=a==="StrictNoSign"?"StrictNoSign":"StrictSign",this.canRelayMessage=l,this.emitSelf=c,this.topicValidators=new Map,this.queue=new PQueue({concurrency:u}),this.maxInboundStreams=g,this.maxOutboundStreams=b,this._onIncomingStream=this._onIncomingStream.bind(this),this._onPeerConnected=this._onPeerConnected.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this)}async start(){if(this.started||!this.enabled)return;log$y("starting");const r=this.components.registrar;await Promise.all(this.multicodecs.map(async o=>{await r.handle(o,this._onIncomingStream,{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams})}));const n={onConnect:this._onPeerConnected,onDisconnect:this._onPeerDisconnected};this._registrarTopologyIds=await Promise.all(this.multicodecs.map(async o=>r.register(o,n))),log$y("started"),this.started=!0}async stop(){if(!this.started||!this.enabled)return;const r=this.components.registrar;this._registrarTopologyIds!=null&&this._registrarTopologyIds?.forEach(n=>{r.unregister(n)}),await Promise.all(this.multicodecs.map(async n=>{await r.unhandle(n)})),log$y("stopping");for(const n of this.peers.values())n.close();this.peers.clear(),this.subscriptions=new Set,this.started=!1,log$y("stopped")}isStarted(){return this.started}_onIncomingStream(r){const{stream:n,connection:o}=r,a=o.remotePeer;if(n.protocol==null){n.abort(new Error("Stream was not multiplexed"));return}const l=this.addPeer(a,n.protocol),c=l.attachInboundStream(n);this.processMessages(a,c,l).catch(u=>{log$y(u)})}_onPeerConnected(r,n){log$y("connected %p",r),Promise.resolve().then(async()=>{try{const o=await n.newStream(this.multicodecs);if(o.protocol==null){o.abort(new Error("Stream was not multiplexed"));return}await this.addPeer(r,o.protocol).attachOutboundStream(o)}catch(o){log$y.error(o)}this.send(r,{subscriptions:Array.from(this.subscriptions).map(o=>o.toString()),subscribe:!0})}).catch(o=>{log$y.error(o)})}_onPeerDisconnected(r,n){const o=r.toString();log$y("connection ended",o),this._removePeer(r)}addPeer(r,n){const o=this.peers.get(r);if(o!=null)return o;log$y("new peer %p",r);const a=new PeerStreams({id:r,protocol:n});return this.peers.set(r,a),a.addEventListener("close",()=>this._removePeer(r),{once:!0}),a}_removePeer(r){const n=this.peers.get(r);if(n!=null){n.close(),log$y("delete peer %p",r),this.peers.delete(r);for(const o of this.topics.values())o.delete(r);return n}}async processMessages(r,n,o){try{await pipe(n,async a=>{for await(const l of a){const c=this.decodeRpc(l),u=[];for(const g of c.messages??[]){if(g.from==null||g.data==null||g.topic==null){log$y("message from %p was missing from, data or topic fields, dropping",r);continue}u.push({from:g.from,data:g.data,topic:g.topic,sequenceNumber:g.sequenceNumber??void 0,signature:g.signature??void 0,key:g.key??void 0})}this.processRpc(r,o,{subscriptions:(c.subscriptions??[]).map(g=>({subscribe:Boolean(g.subscribe),topic:g.topic??""})),messages:u}).catch(g=>{log$y(g)})}})}catch(a){this._onPeerDisconnected(o.id,a)}}async processRpc(r,n,o){if(!this.acceptFrom(r))return log$y("received message from unacceptable peer %p",r),!1;log$y("rpc from %p",r);const{subscriptions:a,messages:l}=o;return a!=null&&a.length>0&&(log$y("subscription update from %p",r),a.forEach(c=>{this.processRpcSubOpt(r,c)}),super.dispatchEvent(new CustomEvent$1("subscription-change",{detail:{peerId:n.id,subscriptions:a.map(({topic:c,subscribe:u})=>({topic:`${c??""}`,subscribe:Boolean(u)}))}}))),l!=null&&l.length>0&&(log$y("messages from %p",r),this.queue.addAll(l.map(c=>async()=>{if(c.topic==null||!this.subscriptions.has(c.topic)&&!this.canRelayMessage)return log$y("received message we didn't subscribe to. Dropping."),!1;try{const u=await toMessage(c);await this.processMessage(r,u)}catch(u){log$y.error(u)}})).catch(c=>{log$y(c)})),!0}processRpcSubOpt(r,n){const o=n.topic;if(o==null)return;let a=this.topics.get(o);a==null&&(a=new PeerSet,this.topics.set(o,a)),n.subscribe===!0?a.add(r):a.delete(r)}async processMessage(r,n){if(!(this.components.peerId.equals(r)&&!this.emitSelf)){try{await this.validate(r,n)}catch(o){log$y("Message is invalid, dropping it. %O",o);return}this.subscriptions.has(n.topic)&&(!this.components.peerId.equals(r)||this.emitSelf)&&super.dispatchEvent(new CustomEvent$1("message",{detail:n})),await this.publishMessage(r,n)}}getMsgId(r){switch(this.globalSignaturePolicy){case"StrictSign":if(r.type!=="signed")throw new CodeError('Message type should be "signed" when signature policy is StrictSign but it was not',codes$7.ERR_MISSING_SIGNATURE);if(r.sequenceNumber==null)throw new CodeError("Need seqno when signature policy is StrictSign but it was missing",codes$7.ERR_MISSING_SEQNO);if(r.key==null)throw new CodeError("Need key when signature policy is StrictSign but it was missing",codes$7.ERR_MISSING_KEY);return msgId(r.key,r.sequenceNumber);case"StrictNoSign":return noSignMsgId(r.data);default:throw new CodeError("Cannot get message id: unhandled signature policy",codes$7.ERR_UNHANDLED_SIGNATURE_POLICY)}}acceptFrom(r){return!0}send(r,n){const{messages:o,subscriptions:a,subscribe:l}=n;this.sendRpc(r,{subscriptions:(a??[]).map(c=>({topic:c,subscribe:Boolean(l)})),messages:(o??[]).map(toRpcMessage)})}sendRpc(r,n){const o=this.peers.get(r);if(o==null||!o.isWritable){log$y.error("Cannot send RPC to %p as there is no open stream to it available",r);return}o.write(this.encodeRpc(n))}async validate(r,n){switch(this.globalSignaturePolicy){case"StrictNoSign":if(n.type!=="unsigned")throw new CodeError('Message type should be "unsigned" when signature policy is StrictNoSign but it was not',codes$7.ERR_MISSING_SIGNATURE);if(n.signature!=null)throw new CodeError("StrictNoSigning: signature should not be present",codes$7.ERR_UNEXPECTED_SIGNATURE);if(n.key!=null)throw new CodeError("StrictNoSigning: key should not be present",codes$7.ERR_UNEXPECTED_KEY);if(n.sequenceNumber!=null)throw new CodeError("StrictNoSigning: seqno should not be present",codes$7.ERR_UNEXPECTED_SEQNO);break;case"StrictSign":if(n.type!=="signed")throw new CodeError('Message type should be "signed" when signature policy is StrictSign but it was not',codes$7.ERR_MISSING_SIGNATURE);if(n.signature==null)throw new CodeError("StrictSigning: Signing required and no signature was present",codes$7.ERR_MISSING_SIGNATURE);if(n.sequenceNumber==null)throw new CodeError("StrictSigning: Signing required and no sequenceNumber was present",codes$7.ERR_MISSING_SEQNO);if(!await verifySignature(n,this.encodeMessage.bind(this)))throw new CodeError("StrictSigning: Invalid message signature",codes$7.ERR_INVALID_SIGNATURE);break;default:throw new CodeError("Cannot validate message: unhandled signature policy",codes$7.ERR_UNHANDLED_SIGNATURE_POLICY)}const a=this.topicValidators.get(n.topic);if(a!=null){const l=await a(r,n);if(l===TopicValidatorResult.Reject||l===TopicValidatorResult.Ignore)throw new CodeError("Message validation failed",codes$7.ERR_TOPIC_VALIDATOR_REJECT)}}async buildMessage(r){switch(this.globalSignaturePolicy){case"StrictSign":return signMessage(this.components.peerId,r,this.encodeMessage.bind(this));case"StrictNoSign":return Promise.resolve({type:"unsigned",...r});default:throw new CodeError("Cannot build message: unhandled signature policy",codes$7.ERR_UNHANDLED_SIGNATURE_POLICY)}}getSubscribers(r){if(!this.started)throw new CodeError("not started yet","ERR_NOT_STARTED_YET");if(r==null)throw new CodeError("topic is required","ERR_NOT_VALID_TOPIC");const n=this.topics.get(r.toString());return n==null?[]:Array.from(n.values())}async publish(r,n){if(!this.started)throw new Error("Pubsub has not started");const o={from:this.components.peerId,topic:r,data:n??new Uint8Array(0),sequenceNumber:randomSeqno()};log$y("publish topic: %s from: %p data: %m",r,o.from,o.data);const a=await this.buildMessage(o);let l=!1;this.emitSelf&&this.subscriptions.has(r)&&(l=!0,super.dispatchEvent(new CustomEvent$1("message",{detail:a})));const c=await this.publishMessage(this.components.peerId,a);return l&&(c.recipients=[...c.recipients,this.components.peerId]),c}subscribe(r){if(!this.started)throw new Error("Pubsub has not started");if(log$y("subscribe to topic: %s",r),!this.subscriptions.has(r)){this.subscriptions.add(r);for(const n of this.peers.keys())this.send(n,{subscriptions:[r],subscribe:!0})}}unsubscribe(r){if(!this.started)throw new Error("Pubsub is not started");super.removeEventListener(r);const n=this.subscriptions.has(r);if(log$y("unsubscribe from %s - am subscribed %s",r,n),n){this.subscriptions.delete(r);for(const o of this.peers.keys())this.send(o,{subscriptions:[r],subscribe:!1})}}getTopics(){if(!this.started)throw new Error("Pubsub is not started");return Array.from(this.subscriptions)}getPeers(){if(!this.started)throw new Error("Pubsub is not started");return Array.from(this.peers.keys())}}class SimpleTimeCache{constructor(t){Xe(this,"entries");Xe(this,"validityMs");Xe(this,"lastPruneTime",0);this.entries=new Map,this.validityMs=t.validityMs}put(t,r){this.entries.set(t,{value:r,validUntilMs:Date.now()+this.validityMs}),this.prune()}prune(){const t=Date.now();if(!(t-this.lastPruneTime<200)){this.lastPruneTime=t;for(const[r,n]of this.entries.entries())if(n.validUntilMs=Date.now()?r.value:void 0}clear(){this.entries=new Map,this.lastPruneTime=0}}logger("libp2p:floodsub");const multicodec="/floodsub/1.0.0";var RPC;(function(e){(function(r){let n;r.codec=()=>(n==null&&(n=message((o,a,l={})=>{l.lengthDelimited!==!1&&a.fork(),o.subscribe!=null&&(a.uint32(8),a.bool(o.subscribe)),o.topic!=null&&(a.uint32(18),a.string(o.topic)),l.lengthDelimited!==!1&&a.ldelim()},(o,a)=>{const l={},c=a==null?o.len:o.pos+a;for(;o.pos>>3){case 1:l.subscribe=o.bool();break;case 2:l.topic=o.string();break;default:o.skipType(u&7);break}}return l})),n),r.encode=o=>encodeMessage(o,r.codec()),r.decode=o=>decodeMessage(o,r.codec())})(e.SubOpts||(e.SubOpts={})),function(r){let n;r.codec=()=>(n==null&&(n=message((o,a,l={})=>{l.lengthDelimited!==!1&&a.fork(),o.from!=null&&(a.uint32(10),a.bytes(o.from)),o.data!=null&&(a.uint32(18),a.bytes(o.data)),o.sequenceNumber!=null&&(a.uint32(26),a.bytes(o.sequenceNumber)),o.topic!=null&&(a.uint32(34),a.string(o.topic)),o.signature!=null&&(a.uint32(42),a.bytes(o.signature)),o.key!=null&&(a.uint32(50),a.bytes(o.key)),l.lengthDelimited!==!1&&a.ldelim()},(o,a)=>{const l={},c=a==null?o.len:o.pos+a;for(;o.pos>>3){case 1:l.from=o.bytes();break;case 2:l.data=o.bytes();break;case 3:l.sequenceNumber=o.bytes();break;case 4:l.topic=o.string();break;case 5:l.signature=o.bytes();break;case 6:l.key=o.bytes();break;default:o.skipType(u&7);break}}return l})),n),r.encode=o=>encodeMessage(o,r.codec()),r.decode=o=>decodeMessage(o,r.codec())}(e.Message||(e.Message={}));let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.subscriptions!=null)for(const a of r.subscriptions)n.uint32(10),e.SubOpts.codec().encode(a,n);if(r.messages!=null)for(const a of r.messages)n.uint32(18),e.Message.codec().encode(a,n);r.control!=null&&(n.uint32(26),ControlMessage.codec().encode(r.control,n)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={subscriptions:[],messages:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.subscriptions.push(e.SubOpts.codec().decode(r,r.uint32()));break;case 2:o.messages.push(e.Message.codec().decode(r,r.uint32()));break;case 3:o.control=ControlMessage.codec().decode(r,r.uint32());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(RPC||(RPC={}));var ControlMessage;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.ihave!=null)for(const a of r.ihave)n.uint32(10),ControlIHave.codec().encode(a,n);if(r.iwant!=null)for(const a of r.iwant)n.uint32(18),ControlIWant.codec().encode(a,n);if(r.graft!=null)for(const a of r.graft)n.uint32(26),ControlGraft.codec().encode(a,n);if(r.prune!=null)for(const a of r.prune)n.uint32(34),ControlPrune.codec().encode(a,n);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={ihave:[],iwant:[],graft:[],prune:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.ihave.push(ControlIHave.codec().decode(r,r.uint32()));break;case 2:o.iwant.push(ControlIWant.codec().decode(r,r.uint32()));break;case 3:o.graft.push(ControlGraft.codec().decode(r,r.uint32()));break;case 4:o.prune.push(ControlPrune.codec().decode(r,r.uint32()));break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ControlMessage||(ControlMessage={}));var ControlIHave;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.topic!=null&&(n.uint32(10),n.string(r.topic)),r.messageIDs!=null)for(const a of r.messageIDs)n.uint32(18),n.bytes(a);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={messageIDs:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.topic=r.string();break;case 2:o.messageIDs.push(r.bytes());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ControlIHave||(ControlIHave={}));var ControlIWant;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.messageIDs!=null)for(const a of r.messageIDs)n.uint32(10),n.bytes(a);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={messageIDs:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.messageIDs.push(r.bytes());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ControlIWant||(ControlIWant={}));var ControlGraft;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.topic!=null&&(n.uint32(10),n.string(r.topic)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.topic=r.string();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ControlGraft||(ControlGraft={}));var ControlPrune;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.topic!=null&&(n.uint32(10),n.string(r.topic)),r.peers!=null)for(const a of r.peers)n.uint32(18),PeerInfo.codec().encode(a,n);r.backoff!=null&&(n.uint32(24),n.uint64(r.backoff)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={peers:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.topic=r.string();break;case 2:o.peers.push(PeerInfo.codec().decode(r,r.uint32()));break;case 3:o.backoff=r.uint64();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ControlPrune||(ControlPrune={}));var PeerInfo;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.peerID!=null&&(n.uint32(10),n.bytes(r.peerID)),r.signedPeerRecord!=null&&(n.uint32(18),n.bytes(r.signedPeerRecord)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.peerID=r.bytes();break;case 2:o.signedPeerRecord=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(PeerInfo||(PeerInfo={}));const log$x=logger("libp2p:floodsub");class FloodSub extends PubSubBaseProtocol{constructor(r,n){super(r,{...n,canRelayMessage:!0,multicodecs:[multicodec]});Xe(this,"seenCache");this.seenCache=new SimpleTimeCache({validityMs:n?.seenTTL??3e4})}decodeRpc(r){return RPC.decode(r)}encodeRpc(r){return RPC.encode(r)}decodeMessage(r){return RPC.Message.decode(r)}encodeMessage(r){return RPC.Message.encode(r)}async processMessage(r,n){const o=await super.getMsgId(n),a=toString$5(o,"base64");this.seenCache.has(a)||(this.seenCache.put(a,!0),await super.processMessage(r,n))}async publishMessage(r,n){const o=this.getSubscribers(n.topic),a=[];return o==null||o.length===0?(log$x("no peers are subscribed to topic %s",n.topic),{recipients:a}):(o.forEach(l=>{if(this.components.peerId.equals(l)){log$x("not sending message on topic %s to myself",n.topic);return}if(l.equals(r)){log$x("not sending message on topic %s to sender %p",n.topic,l);return}log$x("publish msgs on topics %s %p",n.topic,l),a.push(l),this.send(l,{messages:[n]})}),{recipients:a})}}function floodsub(e={}){return t=>new FloodSub(t,e)}var RateLimiterAbstract_1=class{constructor(t={}){this.points=t.points,this.duration=t.duration,this.blockDuration=t.blockDuration,this.execEvenly=t.execEvenly,this.execEvenlyMinDelayMs=t.execEvenlyMinDelayMs,this.keyPrefix=t.keyPrefix}get points(){return this._points}set points(t){this._points=t>=0?t:4}get duration(){return this._duration}set duration(t){this._duration=typeof t>"u"?1:t}get msDuration(){return this.duration*1e3}get blockDuration(){return this._blockDuration}set blockDuration(t){this._blockDuration=typeof t>"u"?0:t}get msBlockDuration(){return this.blockDuration*1e3}get execEvenly(){return this._execEvenly}set execEvenly(t){this._execEvenly=typeof t>"u"?!1:Boolean(t)}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(t){this._execEvenlyMinDelayMs=typeof t>"u"?Math.ceil(this.msDuration/this.points):t}get keyPrefix(){return this._keyPrefix}set keyPrefix(t){if(typeof t>"u"&&(t="rlflx"),typeof t!="string")throw new Error("keyPrefix must be string");this._keyPrefix=t}_getKeySecDuration(t={}){return t&&t.customDuration>=0?t.customDuration:this.duration}getKey(t){return this.keyPrefix.length>0?`${this.keyPrefix}:${t}`:t}parseKey(t){return t.substring(this.keyPrefix.length)}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}},BlockedKeys_1$1=class{constructor(){this._keys={},this._addedKeysAmount=0}collectExpired(){const t=Date.now();Object.keys(this._keys).forEach(r=>{this._keys[r]<=t&&delete this._keys[r]}),this._addedKeysAmount=Object.keys(this._keys).length}add(t,r){this.addMs(t,r*1e3)}addMs(t,r){this._keys[t]=Date.now()+r,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(t){const r=this._keys[t];if(r&&r>=Date.now()){this.collectExpired();const n=Date.now();return r>=n?r-n:0}return 0}delete(t){t?delete this._keys[t]:Object.keys(this._keys).forEach(r=>{delete this._keys[r]})}};const BlockedKeys$1=BlockedKeys_1$1;var BlockedKeys_1=BlockedKeys$1,RateLimiterRes_1=class{constructor(t,r,n,o){this.remainingPoints=typeof t>"u"?0:t,this.msBeforeNext=typeof r>"u"?0:r,this.consumedPoints=typeof n>"u"?0:n,this.isFirstInDuration=typeof o>"u"?!1:o}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(t){return this._msBeforeNext=t,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(t){return this._remainingPoints=t,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(t){return this._consumedPoints=t,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(t){this._isFirstInDuration=Boolean(t)}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}};const RateLimiterAbstract$3=RateLimiterAbstract_1,BlockedKeys=BlockedKeys_1,RateLimiterRes$b=RateLimiterRes_1;var RateLimiterStoreAbstract_1=class extends RateLimiterAbstract$3{constructor(t={}){super(t),this.inMemoryBlockOnConsumed=t.inMemoryBlockOnConsumed,this.inMemoryBlockDuration=t.inMemoryBlockDuration,this.insuranceLimiter=t.insuranceLimiter,this._inMemoryBlockedKeys=new BlockedKeys}get client(){return this._client}set client(t){if(typeof t>"u")throw new Error("storeClient is not set");this._client=t}_afterConsume(t,r,n,o,a,l={}){const c=this._getRateLimiterRes(n,o,a);if(this.inMemoryBlockOnConsumed>0&&!(this.inMemoryBlockDuration>0)&&c.consumedPoints>=this.inMemoryBlockOnConsumed)return this._inMemoryBlockedKeys.addMs(n,c.msBeforeNext),c.consumedPoints>this.points?r(c):t(c);if(c.consumedPoints>this.points){let u=Promise.resolve();this.blockDuration>0&&c.consumedPoints<=this.points+o&&(c.msBeforeNext=this.msBlockDuration,u=this._block(n,c.consumedPoints,this.msBlockDuration,l)),this.inMemoryBlockOnConsumed>0&&c.consumedPoints>=this.inMemoryBlockOnConsumed&&(this._inMemoryBlockedKeys.add(n,this.inMemoryBlockDuration),c.msBeforeNext=this.msInMemoryBlockDuration),u.then(()=>{r(c)}).catch(g=>{r(g)})}else if(this.execEvenly&&c.msBeforeNext>0&&!c.isFirstInDuration){let u=Math.ceil(c.msBeforeNext/(c.remainingPoints+2));u{n(u)}).catch(u=>{o(u)}):o(t)}getInMemoryBlockMsBeforeExpire(t){return this.inMemoryBlockOnConsumed>0?this._inMemoryBlockedKeys.msBeforeExpire(t):0}get inMemoryBlockOnConsumed(){return this._inMemoryBlockOnConsumed}set inMemoryBlockOnConsumed(t){if(this._inMemoryBlockOnConsumed=t?parseInt(t):0,this.inMemoryBlockOnConsumed>0&&this.points>this.inMemoryBlockOnConsumed)throw new Error('inMemoryBlockOnConsumed option must be greater or equal "points" option')}get inMemoryBlockDuration(){return this._inMemoryBlockDuration}set inMemoryBlockDuration(t){if(this._inMemoryBlockDuration=t?parseInt(t):0,this.inMemoryBlockDuration>0&&this.inMemoryBlockOnConsumed===0)throw new Error("inMemoryBlockOnConsumed option must be set up")}get msInMemoryBlockDuration(){return this._inMemoryBlockDuration*1e3}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(t){if(typeof t<"u"&&!(t instanceof RateLimiterAbstract$3))throw new Error("insuranceLimiter must be instance of RateLimiterAbstract");this._insuranceLimiter=t,this._insuranceLimiter&&(this._insuranceLimiter.blockDuration=this.blockDuration,this._insuranceLimiter.execEvenly=this.execEvenly)}block(t,r,n={}){const o=r*1e3;return this._block(this.getKey(t),this.points+1,o,n)}set(t,r,n,o={}){const a=(n>=0?n:this.duration)*1e3;return this._block(this.getKey(t),r,a,o)}consume(t,r=1,n={}){return new Promise((o,a)=>{const l=this.getKey(t),c=this.getInMemoryBlockMsBeforeExpire(l);if(c>0)return a(new RateLimiterRes$b(0,c));this._upsert(l,r,this._getKeySecDuration(n)*1e3,!1,n).then(u=>{this._afterConsume(o,a,l,r,u)}).catch(u=>{this._handleError(u,"consume",o,a,t,r,n)})})}penalty(t,r=1,n={}){const o=this.getKey(t);return new Promise((a,l)=>{this._upsert(o,r,this._getKeySecDuration(n)*1e3,!1,n).then(c=>{a(this._getRateLimiterRes(o,r,c))}).catch(c=>{this._handleError(c,"penalty",a,l,t,r,n)})})}reward(t,r=1,n={}){const o=this.getKey(t);return new Promise((a,l)=>{this._upsert(o,-r,this._getKeySecDuration(n)*1e3,!1,n).then(c=>{a(this._getRateLimiterRes(o,-r,c))}).catch(c=>{this._handleError(c,"reward",a,l,t,r,n)})})}get(t,r={}){const n=this.getKey(t);return new Promise((o,a)=>{this._get(n,r).then(l=>{o(l===null||typeof l>"u"?null:this._getRateLimiterRes(n,0,l))}).catch(l=>{this._handleError(l,"get",o,a,t,r)})})}delete(t,r={}){const n=this.getKey(t);return new Promise((o,a)=>{this._delete(n,r).then(l=>{this._inMemoryBlockedKeys.delete(n),o(l)}).catch(l=>{this._handleError(l,"delete",o,a,t,r)})})}deleteInMemoryBlockedAll(){this._inMemoryBlockedKeys.delete()}_getRateLimiterRes(t,r,n){throw new Error("You have to implement the method '_getRateLimiterRes'!")}_block(t,r,n,o={}){return new Promise((a,l)=>{this._upsert(t,r,n,!0,o).then(()=>{a(new RateLimiterRes$b(0,n>0?n:-1,r))}).catch(c=>{this._handleError(c,"block",a,l,this.parseKey(t),n/1e3,o)})})}_get(t,r={}){throw new Error("You have to implement the method '_get'!")}_delete(t,r={}){throw new Error("You have to implement the method '_delete'!")}_upsert(t,r,n,o=!1,a={}){throw new Error("You have to implement the method '_upsert'!")}};const RateLimiterStoreAbstract$4=RateLimiterStoreAbstract_1,RateLimiterRes$a=RateLimiterRes_1,incrTtlLuaScript="redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') local consumed = redis.call('incrby', KEYS[1], ARGV[1]) local ttl = redis.call('pttl', KEYS[1]) if ttl == -1 then redis.call('expire', KEYS[1], ARGV[2]) ttl = 1000 * ARGV[2] end return {consumed, ttl} ";class RateLimiterRedis$1 extends RateLimiterStoreAbstract$4{constructor(t){super(t),this.client=t.storeClient,this._rejectIfRedisNotReady=!!t.rejectIfRedisNotReady,this.useRedisPackage=t.useRedisPackage,this.useRedis3AndLowerPackage=t.useRedis3AndLowerPackage,typeof this.client.defineCommand=="function"&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:incrTtlLuaScript})}_isRedisReady(){return this._rejectIfRedisNotReady?!(this.client.status&&this.client.status!=="ready"||typeof this.client.isReady=="function"&&!this.client.isReady()):!0}_getRateLimiterRes(t,r,n){let[o,a]=n;Array.isArray(o)&&([,o]=o,[,a]=a);const l=new RateLimiterRes$a;return l.consumedPoints=parseInt(o),l.isFirstInDuration=l.consumedPoints===r,l.remainingPoints=Math.max(this.points-l.consumedPoints,0),l.msBeforeNext=a,l}async _upsert(t,r,n,o=!1){if(!this._isRedisReady())throw new Error("Redis connection is not ready");const a=Math.floor(n/1e3),l=this.client.multi();return o?(a>0?!this.useRedisPackage&&!this.useRedis3AndLowerPackage?l.set(t,r,"EX",a):l.set(t,r,{EX:a}):l.set(t,r),!this.useRedisPackage&&!this.useRedis3AndLowerPackage?l.pttl(t).exec(!0):l.pTTL(t).exec(!0)):a>0?!this.useRedisPackage&&!this.useRedis3AndLowerPackage?this.client.rlflxIncr([t].concat([String(r),String(a)])):this.useRedis3AndLowerPackage?new Promise((c,u)=>{const g=function(b,x){return b?u(b):c(x)};typeof this.client.rlflxIncr=="function"?this.client.rlflxIncr(t,r,a,g):this.client.eval(incrTtlLuaScript,1,t,r,a,g)}):this.client.eval(incrTtlLuaScript,{keys:[t],arguments:[String(r),String(a)]}):!this.useRedisPackage&&!this.useRedis3AndLowerPackage?l.incrby(t,r).pttl(t).exec(!0):l.incrBy(t,r).pTTL(t).exec(!0)}async _get(t){if(!this._isRedisReady())throw new Error("Redis connection is not ready");return!this.useRedisPackage&&!this.useRedis3AndLowerPackage?this.client.multi().get(t).pttl(t).exec().then(r=>{const[[,n]]=r;return n===null?null:r}):this.client.multi().get(t).pTTL(t).exec(!0).then(r=>{const[n]=r;return n===null?null:r})}_delete(t){return this.client.del(t).then(r=>r>0)}}var RateLimiterRedis_1=RateLimiterRedis$1;const RateLimiterStoreAbstract$3=RateLimiterStoreAbstract_1,RateLimiterRes$9=RateLimiterRes_1;function getDriverVersion(e){try{const t=e.client?e.client:e,{version:r}=t.topology.s.options.metadata.driver,n=r.split(".").map(o=>parseInt(o));return{major:n[0],feature:n[1],patch:n[2]}}catch{return{major:0,feature:0,patch:0}}}class RateLimiterMongo$1 extends RateLimiterStoreAbstract$3{constructor(t){super(t),this.dbName=t.dbName,this.tableName=t.tableName,this.indexKeyPrefix=t.indexKeyPrefix,t.mongo?this.client=t.mongo:this.client=t.storeClient,typeof this.client.then=="function"?this.client.then(r=>{this.client=r,this._initCollection(),this._driverVersion=getDriverVersion(this.client)}):(this._initCollection(),this._driverVersion=getDriverVersion(this.client))}get dbName(){return this._dbName}set dbName(t){this._dbName=typeof t>"u"?RateLimiterMongo$1.getDbName():t}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(t){this._tableName=typeof t>"u"?this.keyPrefix:t}get client(){return this._client}set client(t){if(typeof t>"u")throw new Error("mongo is not set");this._client=t}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(t){this._indexKeyPrefix=t||{}}_initCollection(){const r=(typeof this.client.db=="function"?this.client.db(this.dbName):this.client).collection(this.tableName);r.createIndex({expire:-1},{expireAfterSeconds:0}),r.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=r}_getRateLimiterRes(t,r,n){const o=new RateLimiterRes$9;let a;return typeof n.value>"u"?a=n:a=n.value,o.isFirstInDuration=a.points===r,o.consumedPoints=a.points,o.remainingPoints=Math.max(this.points-o.consumedPoints,0),o.msBeforeNext=a.expire!==null?Math.max(new Date(a.expire).getTime()-Date.now(),0):-1,o}_upsert(t,r,n,o=!1,a={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const l=a.attrs||{};let c,u;o?(c={key:t},c=Object.assign(c,l),u={$set:{key:t,points:r,expire:n>0?new Date(Date.now()+n):null}},u.$set=Object.assign(u.$set,l)):(c={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:t},c=Object.assign(c,l),u={$setOnInsert:{key:t,expire:n>0?new Date(Date.now()+n):null},$inc:{points:r}},u.$setOnInsert=Object.assign(u.$setOnInsert,l));const g={upsert:!0};return this._driverVersion.major>=4||this._driverVersion.major===3&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?g.returnDocument="after":g.returnOriginal=!1,new Promise((b,x)=>{this._collection.findOneAndUpdate(c,u,g).then(S=>{b(S)}).catch(S=>{if(S&&S.code===11e3){const $=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:t},l),k={$set:Object.assign({key:t,points:r,expire:n>0?new Date(Date.now()+n):null},l)};this._collection.findOneAndUpdate($,k,g).then(T=>{b(T)}).catch(T=>{T&&T.code===11e3?this._upsert(t,r,n,o).then(D=>b(D)).catch(D=>x(D)):x(T)})}else x(S)})})}_get(t,r={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const n=r.attrs||{},o=Object.assign({key:t,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},n);return this._collection.findOne(o)}_delete(t,r={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const n=r.attrs||{},o=Object.assign({key:t},n);return this._collection.deleteOne(o).then(a=>a.deletedCount>0)}}var RateLimiterMongo_1=RateLimiterMongo$1;const RateLimiterStoreAbstract$2=RateLimiterStoreAbstract_1,RateLimiterRes$8=RateLimiterRes_1;class RateLimiterMySQL$1 extends RateLimiterStoreAbstract$2{constructor(t,r=null){super(t),this.client=t.storeClient,this.clientType=t.storeType,this.dbName=t.dbName,this.tableName=t.tableName,this.clearExpiredByTimeout=t.clearExpiredByTimeout,this.tableCreated=t.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),typeof r=="function"&&r()):this._createDbAndTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),typeof r=="function"&&r()}).catch(n=>{if(typeof r=="function")r(n);else throw n})}clearExpired(t){return new Promise(r=>{this._getConnection().then(n=>{n.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,t],()=>{this._releaseConnection(n),r()})}).catch(()=>{r()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":return new Promise((t,r)=>{this.client.getConnection((n,o)=>{if(n)return r(n);t(o)})});case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();default:return Promise.resolve(this.client)}}_releaseConnection(t){switch(this.clientType){case"pool":return t.release();case"sequelize":return this.client.connectionManager.releaseConnection(t);case"knex":return this.client.client.releaseConnection(t);default:return!0}}_createDbAndTable(){return new Promise((t,r)=>{this._getConnection().then(n=>{n.query(`CREATE DATABASE IF NOT EXISTS \`${this.dbName}\`;`,o=>{if(o)return this._releaseConnection(n),r(o);n.query(this._getCreateTableStmt(),a=>{if(a)return this._releaseConnection(n),r(a);this._releaseConnection(n),t()})})}).catch(n=>{r(n)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS \`${this.dbName}\`.\`${this.tableName}\` (\`key\` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\`points\` INT(9) NOT NULL default 0,\`expire\` BIGINT UNSIGNED,PRIMARY KEY (\`key\`)) ENGINE = INNODB;`}get clientType(){return this._clientType}set clientType(t){if(typeof t>"u")if(this.client.constructor.name==="Connection")t="connection";else if(this.client.constructor.name==="Pool")t="pool";else if(this.client.constructor.name==="Sequelize")t="sequelize";else throw new Error("storeType is not defined");this._clientType=t.toLowerCase()}get dbName(){return this._dbName}set dbName(t){this._dbName=typeof t>"u"?"rtlmtrflx":t}get tableName(){return this._tableName}set tableName(t){this._tableName=typeof t>"u"?this.keyPrefix:t}get tableCreated(){return this._tableCreated}set tableCreated(t){this._tableCreated=typeof t>"u"?!1:!!t}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(t){this._clearExpiredByTimeout=typeof t>"u"?!0:Boolean(t)}_getRateLimiterRes(t,r,n){const o=new RateLimiterRes$8,[a]=n;return o.isFirstInDuration=r===a.points,o.consumedPoints=o.isFirstInDuration?r:a.points,o.remainingPoints=Math.max(this.points-o.consumedPoints,0),o.msBeforeNext=a.expire?Math.max(a.expire-Date.now(),0):-1,o}_upsertTransaction(t,r,n,o,a){return new Promise((l,c)=>{t.query("BEGIN",u=>{if(u)return t.rollback(),c(u);const g=Date.now(),b=o>0?g+o:null;let x,S;a?(x=`INSERT INTO ??.?? VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE points = ?, expire = ?;`,S=[this.dbName,this.tableName,r,n,b,n,b]):(x=`INSERT INTO ??.?? VALUES (?, ?, ?) @@ -162,7 +162,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho expire = ${l} RETURNING points, expire;`,values:[t,r,a,Date.now()]})}_get(t){return this.tableCreated?new Promise((r,n)=>{this._query({name:"rlflx-get",text:` SELECT points, expire FROM ${this.tableName} WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,values:[t,Date.now()]}).then(o=>{o.rowCount===0&&(o=null),r(o)}).catch(o=>{n(o)})}):Promise.reject(Error("Table is not created yet"))}_delete(t){return this.tableCreated?this._query({name:"rlflx-delete",text:`DELETE FROM ${this.tableName} WHERE key = $1`,values:[t]}).then(r=>r.rowCount>0):Promise.reject(Error("Table is not created yet"))}}var RateLimiterPostgres_1=RateLimiterPostgres$1,Record_1=class{constructor(t,r,n=null){this.value=t,this.expiresAt=r,this.timeoutId=n}get value(){return this._value}set value(t){this._value=parseInt(t)}get expiresAt(){return this._expiresAt}set expiresAt(t){!(t instanceof Date)&&Number.isInteger(t)&&(t=new Date(t)),this._expiresAt=t}get timeoutId(){return this._timeoutId}set timeoutId(t){this._timeoutId=t}};const Record=Record_1,RateLimiterRes$6=RateLimiterRes_1;var MemoryStorage_1=class{constructor(){this._storage={}}incrby(t,r,n){if(this._storage[t]){const o=this._storage[t].expiresAt?this._storage[t].expiresAt.getTime()-new Date().getTime():-1;return o!==0?(this._storage[t].value=this._storage[t].value+r,new RateLimiterRes$6(0,o,this._storage[t].value,!1)):this.set(t,r,n)}return this.set(t,r,n)}set(t,r,n){const o=n*1e3;return this._storage[t]&&this._storage[t].timeoutId&&clearTimeout(this._storage[t].timeoutId),this._storage[t]=new Record(r,o>0?new Date(Date.now()+o):null),o>0&&(this._storage[t].timeoutId=setTimeout(()=>{delete this._storage[t]},o),this._storage[t].timeoutId.unref&&this._storage[t].timeoutId.unref()),new RateLimiterRes$6(0,o===0?-1:o,this._storage[t].value,!0)}get(t){if(this._storage[t]){const r=this._storage[t].expiresAt?this._storage[t].expiresAt.getTime()-new Date().getTime():-1;return new RateLimiterRes$6(0,r,this._storage[t].value,!1)}return null}delete(t){return this._storage[t]?(this._storage[t].timeoutId&&clearTimeout(this._storage[t].timeoutId),delete this._storage[t],!0):!1}};const RateLimiterAbstract$2=RateLimiterAbstract_1,MemoryStorage=MemoryStorage_1,RateLimiterRes$5=RateLimiterRes_1;class RateLimiterMemory$2 extends RateLimiterAbstract$2{constructor(t={}){super(t),this._memoryStorage=new MemoryStorage}consume(t,r=1,n={}){return new Promise((o,a)=>{const l=this.getKey(t),c=this._getKeySecDuration(n);let u=this._memoryStorage.incrby(l,r,c);if(u.remainingPoints=Math.max(this.points-u.consumedPoints,0),u.consumedPoints>this.points)this.blockDuration>0&&u.consumedPoints<=this.points+r&&(u=this._memoryStorage.set(l,u.consumedPoints,this.blockDuration)),a(u);else if(this.execEvenly&&u.msBeforeNext>0&&!u.isFirstInDuration){let g=Math.ceil(u.msBeforeNext/(u.remainingPoints+2));g{const l=this._getKeySecDuration(n),c=this._memoryStorage.incrby(o,r,l);c.remainingPoints=Math.max(this.points-c.consumedPoints,0),a(c)})}reward(t,r=1,n={}){const o=this.getKey(t);return new Promise(a=>{const l=this._getKeySecDuration(n),c=this._memoryStorage.incrby(o,-r,l);c.remainingPoints=Math.max(this.points-c.consumedPoints,0),a(c)})}block(t,r){const n=r*1e3,o=this.points+1;return this._memoryStorage.set(this.getKey(t),o,r),Promise.resolve(new RateLimiterRes$5(0,n===0?-1:n,o))}set(t,r,n){const o=(n>=0?n:this.duration)*1e3;return this._memoryStorage.set(this.getKey(t),r,n),Promise.resolve(new RateLimiterRes$5(0,o===0?-1:o,r))}get(t){const r=this._memoryStorage.get(this.getKey(t));return r!==null&&(r.remainingPoints=Math.max(this.points-r.consumedPoints,0)),Promise.resolve(r)}delete(t){return Promise.resolve(this._memoryStorage.delete(this.getKey(t)))}}var RateLimiterMemory_1=RateLimiterMemory$2;const cluster=require$$6,crypto$1=require$$6,RateLimiterAbstract$1=RateLimiterAbstract_1,RateLimiterMemory$1=RateLimiterMemory_1,RateLimiterRes$4=RateLimiterRes_1,channel="rate_limiter_flexible";let masterInstance=null;const masterSendToWorker=function(e,t,r,n){let o;n===null||n===!0||n===!1?o=n:o={remainingPoints:n.remainingPoints,msBeforeNext:n.msBeforeNext,consumedPoints:n.consumedPoints,isFirstInDuration:n.isFirstInDuration},e.send({channel,keyPrefix:t.keyPrefix,promiseId:t.promiseId,type:r,data:o})},workerWaitInit=function(e){setTimeout(()=>{this._initiated?process.send(e):typeof this._promises[e.promiseId]<"u"&&workerWaitInit.call(this,e)},30)},workerSendToMaster=function(e,t,r,n,o){const a={channel,keyPrefix:this.keyPrefix,func:e,promiseId:t,data:{key:r,arg:n,opts:o}};this._initiated?process.send(a):workerWaitInit.call(this,a)},masterProcessMsg=function(e,t){if(!t||t.channel!==channel||typeof this._rateLimiters[t.keyPrefix]>"u")return!1;let r;switch(t.func){case"consume":r=this._rateLimiters[t.keyPrefix].consume(t.data.key,t.data.arg,t.data.opts);break;case"penalty":r=this._rateLimiters[t.keyPrefix].penalty(t.data.key,t.data.arg,t.data.opts);break;case"reward":r=this._rateLimiters[t.keyPrefix].reward(t.data.key,t.data.arg,t.data.opts);break;case"block":r=this._rateLimiters[t.keyPrefix].block(t.data.key,t.data.arg,t.data.opts);break;case"get":r=this._rateLimiters[t.keyPrefix].get(t.data.key,t.data.opts);break;case"delete":r=this._rateLimiters[t.keyPrefix].delete(t.data.key,t.data.opts);break;default:return!1}r&&r.then(n=>{masterSendToWorker(e,t,"resolve",n)}).catch(n=>{masterSendToWorker(e,t,"reject",n)})},workerProcessMsg=function(e){if(!e||e.channel!==channel||e.keyPrefix!==this.keyPrefix)return!1;if(this._promises[e.promiseId]){clearTimeout(this._promises[e.promiseId].timeoutId);let t;switch(e.data===null||e.data===!0||e.data===!1?t=e.data:t=new RateLimiterRes$4(e.data.remainingPoints,e.data.msBeforeNext,e.data.consumedPoints,e.data.isFirstInDuration),e.type){case"resolve":this._promises[e.promiseId].resolve(t);break;case"reject":this._promises[e.promiseId].reject(t);break;default:throw new Error(`RateLimiterCluster: no such message type '${e.type}'`)}delete this._promises[e.promiseId]}},getOpts=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},savePromise=function(e,t){const r=process.hrtime();let n=r[0].toString()+r[1].toString();return typeof this._promises[n]<"u"&&(n+=crypto$1.randomBytes(12).toString("base64")),this._promises[n]={resolve:e,reject:t,timeoutId:setTimeout(()=>{delete this._promises[n],t(new Error("RateLimiterCluster timeout: no answer from master in time"))},this.timeoutMs)},n};class RateLimiterClusterMaster$1{constructor(){if(masterInstance)return masterInstance;this._rateLimiters={},cluster.setMaxListeners(0),cluster.on("message",(t,r)=>{r&&r.channel===channel&&r.type==="init"?(typeof this._rateLimiters[r.opts.keyPrefix]>"u"&&(this._rateLimiters[r.opts.keyPrefix]=new RateLimiterMemory$1(r.opts)),t.send({channel,type:"init",keyPrefix:r.opts.keyPrefix})):masterProcessMsg.call(this,t,r)}),masterInstance=this}}class RateLimiterClusterMasterPM2$1{constructor(t){if(masterInstance)return masterInstance;this._rateLimiters={},t.launchBus((r,n)=>{n.on("process:msg",o=>{const a=o.raw;if(a&&a.channel===channel&&a.type==="init")typeof this._rateLimiters[a.opts.keyPrefix]>"u"&&(this._rateLimiters[a.opts.keyPrefix]=new RateLimiterMemory$1(a.opts)),t.sendDataToProcessId(o.process.pm_id,{data:{},topic:channel,channel,type:"init",keyPrefix:a.opts.keyPrefix},(l,c)=>{l&&console.log(l,c)});else{const l={send:c=>{const u=c;u.topic=channel,typeof u.data>"u"&&(u.data={}),t.sendDataToProcessId(o.process.pm_id,u,(g,b)=>{g&&console.log(g,b)})}};masterProcessMsg.call(this,l,a)}})}),masterInstance=this}}class RateLimiterClusterWorker extends RateLimiterAbstract$1{get timeoutMs(){return this._timeoutMs}set timeoutMs(t){this._timeoutMs=typeof t>"u"?5e3:Math.abs(parseInt(t))}constructor(t={}){super(t),process.setMaxListeners(0),this.timeoutMs=t.timeoutMs,this._initiated=!1,process.on("message",r=>{r&&r.channel===channel&&r.type==="init"&&r.keyPrefix===this.keyPrefix?this._initiated=!0:workerProcessMsg.call(this,r)}),process.send({channel,type:"init",opts:getOpts.call(this)}),this._promises={}}consume(t,r=1,n={}){return new Promise((o,a)=>{const l=savePromise.call(this,o,a);workerSendToMaster.call(this,"consume",l,t,r,n)})}penalty(t,r=1,n={}){return new Promise((o,a)=>{const l=savePromise.call(this,o,a);workerSendToMaster.call(this,"penalty",l,t,r,n)})}reward(t,r=1,n={}){return new Promise((o,a)=>{const l=savePromise.call(this,o,a);workerSendToMaster.call(this,"reward",l,t,r,n)})}block(t,r,n={}){return new Promise((o,a)=>{const l=savePromise.call(this,o,a);workerSendToMaster.call(this,"block",l,t,r,n)})}get(t,r={}){return new Promise((n,o)=>{const a=savePromise.call(this,n,o);workerSendToMaster.call(this,"get",a,t,r)})}delete(t,r={}){return new Promise((n,o)=>{const a=savePromise.call(this,n,o);workerSendToMaster.call(this,"delete",a,t,r)})}}var RateLimiterCluster$1={RateLimiterClusterMaster:RateLimiterClusterMaster$1,RateLimiterClusterMasterPM2:RateLimiterClusterMasterPM2$1,RateLimiterCluster:RateLimiterClusterWorker};const RateLimiterStoreAbstract=RateLimiterStoreAbstract_1,RateLimiterRes$3=RateLimiterRes_1;class RateLimiterMemcache$1 extends RateLimiterStoreAbstract{constructor(t){super(t),this.client=t.storeClient}_getRateLimiterRes(t,r,n){const o=new RateLimiterRes$3;return o.consumedPoints=parseInt(n.consumedPoints),o.isFirstInDuration=n.consumedPoints===r,o.remainingPoints=Math.max(this.points-o.consumedPoints,0),o.msBeforeNext=n.msBeforeNext,o}_upsert(t,r,n,o=!1,a={}){return new Promise((l,c)=>{const u=Date.now(),g=Math.floor(n/1e3);o?this.client.set(t,r,g,b=>{b?c(b):this.client.set(`${t}_expire`,g>0?u+g*1e3:-1,g,()=>{const x={consumedPoints:r,msBeforeNext:g>0?g*1e3:-1};l(x)})}):this.client.incr(t,r,(b,x)=>{b||x===!1?this.client.add(t,r,g,(S,$)=>{if(S||!$)if(typeof a.attemptNumber>"u"||a.attemptNumber<3){const k=Object.assign({},a);k.attemptNumber=k.attemptNumber?k.attemptNumber+1:1,this._upsert(t,r,n,o,k).then(T=>l(T)).catch(T=>c(T))}else c(new Error("Can not add key"));else this.client.add(`${t}_expire`,g>0?u+g*1e3:-1,g,()=>{const k={consumedPoints:r,msBeforeNext:g>0?g*1e3:-1};l(k)})}):this.client.get(`${t}_expire`,(S,$)=>{if(S)c(S);else{const k=$===!1?0:$,T={consumedPoints:x,msBeforeNext:k>=0?Math.max(k-u,0):-1};l(T)}})})})}_get(t){return new Promise((r,n)=>{const o=Date.now();this.client.get(t,(a,l)=>{l?this.client.get(`${t}_expire`,(c,u)=>{if(c)n(c);else{const g=u===!1?0:u,b={consumedPoints:l,msBeforeNext:g>=0?Math.max(g-o,0):-1};r(b)}}):r(null)})})}_delete(t){return new Promise((r,n)=>{this.client.del(t,(o,a)=>{o?n(o):a===!1?r(a):this.client.del(`${t}_expire`,l=>{l?n(l):r(a)})})})}}var RateLimiterMemcache_1=RateLimiterMemcache$1;const RateLimiterRes$2=RateLimiterRes_1;var RLWrapperBlackAndWhite_1=class{constructor(t={}){this.limiter=t.limiter,this.blackList=t.blackList,this.whiteList=t.whiteList,this.isBlackListed=t.isBlackListed,this.isWhiteListed=t.isWhiteListed,this.runActionAnyway=t.runActionAnyway}get limiter(){return this._limiter}set limiter(t){if(typeof t>"u")throw new Error("limiter is not set");this._limiter=t}get runActionAnyway(){return this._runActionAnyway}set runActionAnyway(t){this._runActionAnyway=typeof t>"u"?!1:t}get blackList(){return this._blackList}set blackList(t){this._blackList=Array.isArray(t)?t:[]}get isBlackListed(){return this._isBlackListed}set isBlackListed(t){if(typeof t>"u"&&(t=()=>!1),typeof t!="function")throw new Error("isBlackListed must be function");this._isBlackListed=t}get whiteList(){return this._whiteList}set whiteList(t){this._whiteList=Array.isArray(t)?t:[]}get isWhiteListed(){return this._isWhiteListed}set isWhiteListed(t){if(typeof t>"u"&&(t=()=>!1),typeof t!="function")throw new Error("isWhiteListed must be function");this._isWhiteListed=t}isBlackListedSomewhere(t){return this.blackList.indexOf(t)>=0||this.isBlackListed(t)}isWhiteListedSomewhere(t){return this.whiteList.indexOf(t)>=0||this.isWhiteListed(t)}getBlackRes(){return new RateLimiterRes$2(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new RateLimiterRes$2(Number.MAX_SAFE_INTEGER,0,0,!1)}rejectBlack(){return Promise.reject(this.getBlackRes())}resolveBlack(){return Promise.resolve(this.getBlackRes())}resolveWhite(){return Promise.resolve(this.getWhiteRes())}consume(t,r=1){let n;return this.isWhiteListedSomewhere(t)?n=this.resolveWhite():this.isBlackListedSomewhere(t)&&(n=this.rejectBlack()),typeof n>"u"?this.limiter.consume(t,r):(this.runActionAnyway&&this.limiter.consume(t,r).catch(()=>{}),n)}block(t,r){let n;return this.isWhiteListedSomewhere(t)?n=this.resolveWhite():this.isBlackListedSomewhere(t)&&(n=this.resolveBlack()),typeof n>"u"?this.limiter.block(t,r):(this.runActionAnyway&&this.limiter.block(t,r).catch(()=>{}),n)}penalty(t,r){let n;return this.isWhiteListedSomewhere(t)?n=this.resolveWhite():this.isBlackListedSomewhere(t)&&(n=this.resolveBlack()),typeof n>"u"?this.limiter.penalty(t,r):(this.runActionAnyway&&this.limiter.penalty(t,r).catch(()=>{}),n)}reward(t,r){let n;return this.isWhiteListedSomewhere(t)?n=this.resolveWhite():this.isBlackListedSomewhere(t)&&(n=this.resolveBlack()),typeof n>"u"?this.limiter.reward(t,r):(this.runActionAnyway&&this.limiter.reward(t,r).catch(()=>{}),n)}get(t){let r;return this.isWhiteListedSomewhere(t)?r=this.resolveWhite():this.isBlackListedSomewhere(t)&&(r=this.resolveBlack()),typeof r>"u"||this.runActionAnyway?this.limiter.get(t):r}delete(t){return this.limiter.delete(t)}};const RateLimiterAbstract=RateLimiterAbstract_1;var RateLimiterUnion_1=class{constructor(...t){if(t.length<1)throw new Error("RateLimiterUnion: at least one limiter have to be passed");t.forEach(r=>{if(!(r instanceof RateLimiterAbstract))throw new Error("RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract")}),this._limiters=t}consume(t,r=1){return new Promise((n,o)=>{const a=[];this._limiters.forEach(l=>{a.push(l.consume(t,r).catch(c=>({rejected:!0,rej:c})))}),Promise.all(a).then(l=>{const c={};let u=!1;l.forEach(g=>{g.rejected===!0&&(u=!0)});for(let g=0;gt!==null?t.remainingPoints:this._limiterFlexible.points)}removeTokens(t){const r=this;return new Promise((n,o)=>{if(t>r._limiterFlexible.points){o(new RateLimiterQueueError(`Requested tokens ${t} exceeds maximum ${r._limiterFlexible.points} tokens per interval`));return}r._queue.length>0?r._queueRequest.call(r,n,o,t):r._limiterFlexible.consume(r._key,t).then(a=>{n(a.remainingPoints)}).catch(a=>{a instanceof Error?o(a):(r._queueRequest.call(r,n,o,t),r._waitTimeout===null&&(r._waitTimeout=setTimeout(r._processFIFO.bind(r),a.msBeforeNext)))})})}_queueRequest(t,r,n){const o=this;o._queue.length{r.resolve(n.remainingPoints),t._processFIFO.call(t)}).catch(n=>{n instanceof Error?(r.reject(n),t._processFIFO.call(t)):(t._queue.unshift(r),t._waitTimeout===null&&(t._waitTimeout=setTimeout(t._processFIFO.bind(t),n.msBeforeNext)))})}}const RateLimiterRes$1=RateLimiterRes_1;var BurstyRateLimiter_1=class{constructor(t,r){this._rateLimiter=t,this._burstLimiter=r}_combineRes(t,r){return t?new RateLimiterRes$1(t.remainingPoints,Math.min(t.msBeforeNext,r?r.msBeforeNext:0),t.consumedPoints,t.isFirstInDuration):null}consume(t,r=1,n={}){return this._rateLimiter.consume(t,r,n).catch(o=>o instanceof RateLimiterRes$1?this._burstLimiter.consume(t,r,n).then(a=>Promise.resolve(this._combineRes(o,a))).catch(a=>a instanceof RateLimiterRes$1?Promise.reject(this._combineRes(o,a)):Promise.reject(a)):Promise.reject(o))}get(t){return Promise.all([this._rateLimiter.get(t),this._burstLimiter.get(t)]).then(([r,n])=>this._combineRes(r,n))}get points(){return this._rateLimiter.points}};const RateLimiterRedis=RateLimiterRedis_1,RateLimiterMongo=RateLimiterMongo_1,RateLimiterMySQL=RateLimiterMySQL_1,RateLimiterPostgres=RateLimiterPostgres_1,{RateLimiterClusterMaster,RateLimiterClusterMasterPM2,RateLimiterCluster}=RateLimiterCluster$1,RateLimiterMemory=RateLimiterMemory_1,RateLimiterMemcache=RateLimiterMemcache_1,RLWrapperBlackAndWhite=RLWrapperBlackAndWhite_1,RateLimiterUnion=RateLimiterUnion_1,RateLimiterQueue=RateLimiterQueue_1,BurstyRateLimiter=BurstyRateLimiter_1,RateLimiterRes=RateLimiterRes_1;var rateLimiterFlexible={RateLimiterRedis,RateLimiterMongo,RateLimiterMySQL,RateLimiterPostgres,RateLimiterMemory,RateLimiterMemcache,RateLimiterClusterMaster,RateLimiterClusterMasterPM2,RateLimiterCluster,RLWrapperBlackAndWhite,RateLimiterUnion,RateLimiterQueue,BurstyRateLimiter,RateLimiterRes},MessageTypes;(function(e){e[e.NEW_STREAM=0]="NEW_STREAM",e[e.MESSAGE_RECEIVER=1]="MESSAGE_RECEIVER",e[e.MESSAGE_INITIATOR=2]="MESSAGE_INITIATOR",e[e.CLOSE_RECEIVER=3]="CLOSE_RECEIVER",e[e.CLOSE_INITIATOR=4]="CLOSE_INITIATOR",e[e.RESET_RECEIVER=5]="RESET_RECEIVER",e[e.RESET_INITIATOR=6]="RESET_INITIATOR"})(MessageTypes||(MessageTypes={}));const MessageTypeNames=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),InitiatorMessageTypes=Object.freeze({NEW_STREAM:MessageTypes.NEW_STREAM,MESSAGE:MessageTypes.MESSAGE_INITIATOR,CLOSE:MessageTypes.CLOSE_INITIATOR,RESET:MessageTypes.RESET_INITIATOR}),ReceiverMessageTypes=Object.freeze({MESSAGE:MessageTypes.MESSAGE_RECEIVER,CLOSE:MessageTypes.CLOSE_RECEIVER,RESET:MessageTypes.RESET_RECEIVER}),MAX_MSG_SIZE=1<<20,MAX_MSG_QUEUE_SIZE=4<<20;class Decoder$1{constructor(t=MAX_MSG_SIZE,r=MAX_MSG_QUEUE_SIZE){Xe(this,"_buffer");Xe(this,"_headerInfo");Xe(this,"_maxMessageSize");Xe(this,"_maxUnprocessedMessageQueueSize");this._buffer=new Uint8ArrayList,this._headerInfo=null,this._maxMessageSize=t,this._maxUnprocessedMessageQueueSize=r}write(t){if(t==null||t.length===0)return[];if(this._buffer.append(t),this._buffer.byteLength>this._maxUnprocessedMessageQueueSize)throw Object.assign(new Error("unprocessed message queue size too large!"),{code:"ERR_MSG_QUEUE_TOO_BIG"});const r=[];for(;this._buffer.length!==0;){if(this._headerInfo==null)try{this._headerInfo=this._decodeHeader(this._buffer)}catch(g){if(g.code==="ERR_MSG_TOO_BIG")throw g;break}const{id:n,type:o,length:a,offset:l}=this._headerInfo;if(this._buffer.length-lthis._maxMessageSize)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"});return{id:r>>3,type:l,offset:n+a,length:o}}}const MSB$2=128,REST$2=127;function readVarInt(e,t=0){let r=0,n=0,o=t,a;const l=e.length;do{if(o>=l||n>49)throw t=0,new RangeError("Could not decode varint");a=e.get(o++),r+=n<28?(a&REST$2)<=MSB$2);return t=o-t,{value:r,offset:t}}function isAsyncIterable$7(e){return e[Symbol.asyncIterator]!=null}const DEFAULT_BATCH_SIZE=1024*1024,DEFAULT_SERIALIZE=(e,t)=>{t.append(e)};function batchedBytes(e,t){return isAsyncIterable$7(e)?async function*(){let r=new Uint8ArrayList,n=!1,o=pDefer(),a=Number(t?.size??DEFAULT_BATCH_SIZE);if((isNaN(a)||a===0||a<0)&&(a=DEFAULT_BATCH_SIZE),a!==Math.round(a))throw new Error("Batch size must be an integer");const l=t?.yieldAfter??0,c=t?.serialize??DEFAULT_SERIALIZE;for(Promise.resolve().then(async()=>{try{let u;for await(const g of e){if(c(g,r),r.byteLength>=a){clearTimeout(u),o.resolve();continue}u=setTimeout(()=>{o.resolve()},l)}clearTimeout(u),o.resolve()}catch(u){o.reject(u)}finally{n=!0}});!n;)if(await o.promise,o=pDefer(),r.byteLength>0){const u=r;r=new Uint8ArrayList,yield u.subarray()}}():function*(){const r=new Uint8ArrayList;let n=Number(t?.size??DEFAULT_BATCH_SIZE);if((isNaN(n)||n===0||n<0)&&(n=DEFAULT_BATCH_SIZE),n!==Math.round(n))throw new Error("Batch size must be an integer");const o=t?.serialize??DEFAULT_SERIALIZE;for(const a of e)o(a,r),r.byteLength>=n&&(yield r.subarray(0,n),r.consume(n));r.byteLength>0&&(yield r.subarray())}()}function allocUnsafe(e){return new Uint8Array(e)}const POOL_SIZE=10*1024;class Encoder$1{constructor(){Xe(this,"_pool");Xe(this,"_poolOffset");this._pool=allocUnsafe(POOL_SIZE),this._poolOffset=0}write(t,r){const n=this._pool;let o=this._poolOffset;encode$d(t.id<<3|t.type,n,o),o+=encodingLength$2(t.id<<3|t.type),(t.type===MessageTypes.NEW_STREAM||t.type===MessageTypes.MESSAGE_INITIATOR||t.type===MessageTypes.MESSAGE_RECEIVER)&&t.data!=null?(encode$d(t.data.length,n,o),o+=encodingLength$2(t.data.length)):(encode$d(0,n,o),o+=encodingLength$2(0));const a=n.subarray(this._poolOffset,o);POOL_SIZE-o<100?(this._pool=allocUnsafe(POOL_SIZE),this._poolOffset=0):this._poolOffset=o,r.append(a),(t.type===MessageTypes.NEW_STREAM||t.type===MessageTypes.MESSAGE_INITIATOR||t.type===MessageTypes.MESSAGE_RECEIVER)&&t.data!=null&&r.append(t.data)}}const encoder=new Encoder$1;async function*encode$7(e,t=0){if(t==null||t===0){for await(const r of e){const n=new Uint8ArrayList;for(const o of r)encoder.write(o,n);yield n.subarray()}return}yield*batchedBytes(e,{size:t,serialize:(r,n)=>{for(const o of r)encoder.write(o,n)}})}const ERR_STREAM_RESET="ERR_STREAM_RESET",ERR_SINK_INVALID_STATE="ERR_SINK_INVALID_STATE";function isPromise(e){return e!=null&&typeof e.then=="function"}class AbstractStream{constructor(t){Xe(this,"id");Xe(this,"direction");Xe(this,"timeline");Xe(this,"protocol");Xe(this,"metadata");Xe(this,"source");Xe(this,"status");Xe(this,"readStatus");Xe(this,"writeStatus");Xe(this,"sinkController");Xe(this,"sinkEnd");Xe(this,"endErr");Xe(this,"streamSource");Xe(this,"onEnd");Xe(this,"onCloseRead");Xe(this,"onCloseWrite");Xe(this,"onReset");Xe(this,"onAbort");Xe(this,"log");this.sinkController=new AbortController,this.sinkEnd=pDefer(),this.log=t.log,this.status="open",this.readStatus="ready",this.writeStatus="ready",this.id=t.id,this.metadata=t.metadata??{},this.direction=t.direction,this.timeline={open:Date.now()},this.onEnd=t.onEnd,this.onCloseRead=t?.onCloseRead,this.onCloseWrite=t?.onCloseWrite,this.onReset=t?.onReset,this.onAbort=t?.onAbort,this.source=this.streamSource=pushable({onEnd:r=>{r!=null?this.log.trace("source ended with error",r):this.log.trace("source ended"),this.readStatus="closed",this.onSourceEnd(r)}}),this.sink=this.sink.bind(this)}async sink(t){if(this.writeStatus!=="ready")throw new CodeError(`writable end state is "${this.writeStatus}" not "ready"`,ERR_SINK_INVALID_STATE);try{this.writeStatus="writing";const r={signal:this.sinkController.signal};if(this.direction==="outbound"){const n=this.sendNewStream(r);isPromise(n)&&await n}t=abortableSource(t,this.sinkController.signal,{returnOnAbort:!0}),this.log.trace("sink reading from source");for await(let n of t){n=n instanceof Uint8Array?new Uint8ArrayList(n):n;const o=this.sendData(n,r);isPromise(o)&&await o}this.log.trace("sink finished reading from source"),this.writeStatus="done",this.log.trace("sink calling closeWrite"),await this.closeWrite(r),this.onSinkEnd()}catch(r){throw this.log.trace("sink ended with error, calling abort with error",r),this.abort(r),r}finally{this.log.trace("resolve sink end"),this.sinkEnd.resolve()}}onSourceEnd(t){this.timeline.closeRead==null&&(this.timeline.closeRead=Date.now(),t!=null&&this.endErr==null&&(this.endErr=t),this.onCloseRead?.(),this.timeline.closeWrite!=null?(this.log.trace("source and sink ended"),this.timeline.close=Date.now(),this.onEnd!=null&&this.onEnd(this.endErr)):this.log.trace("source ended, waiting for sink to end"))}onSinkEnd(t){this.timeline.closeWrite==null&&(this.timeline.closeWrite=Date.now(),t!=null&&this.endErr==null&&(this.endErr=t),this.onCloseWrite?.(),this.timeline.closeRead!=null?(this.log.trace("sink and source ended"),this.timeline.close=Date.now(),this.onEnd!=null&&this.onEnd(this.endErr)):this.log.trace("sink ended, waiting for source to end"))}async close(t){this.log.trace("closing gracefully"),this.status="closing",await Promise.all([this.closeRead(t),this.closeWrite(t)]),this.status="closed",this.log.trace("closed gracefully")}async closeRead(t={}){if(this.readStatus==="closing"||this.readStatus==="closed")return;this.log.trace('closing readable end of stream with starting read status "%s"',this.readStatus);const r=this.readStatus;this.readStatus="closing",r==="ready"&&(this.log.trace("ending internal source queue"),this.streamSource.end()),this.status!=="reset"&&this.status!=="aborted"&&this.timeline.closeRead==null&&(this.log.trace("send close read to remote"),await this.sendCloseRead(t)),this.log.trace("closed readable end of stream")}async closeWrite(t={}){if(this.writeStatus==="closing"||this.writeStatus==="closed")return;this.log.trace('closing writable end of stream with starting write status "%s"',this.writeStatus);const r=this.writeStatus;this.writeStatus==="ready"&&(this.log.trace("sink was never sunk, sink an empty array"),await this.sink([])),this.writeStatus="closing",r==="writing"&&await new Promise((n,o)=>{queueMicrotask(()=>{this.log.trace("aborting source passed to .sink"),this.sinkController.abort(),this.sinkEnd.promise.then(n,o)})}),this.status!=="reset"&&this.status!=="aborted"&&this.timeline.closeWrite==null&&(this.log.trace("send close write to remote"),await this.sendCloseWrite(t)),this.writeStatus="closed",this.log.trace("closed writable end of stream")}abort(t){if(this.status==="closed"||this.status==="aborted"||this.status==="reset")return;this.log("abort with error",t),this.log("try to send reset to remote");const r=this.sendReset();isPromise(r)&&r.catch(n=>{this.log.error("error sending reset message",n)}),this.status="aborted",this.timeline.abort=Date.now(),this._closeSinkAndSource(t),this.onAbort?.(t)}reset(){if(this.status==="closed"||this.status==="aborted"||this.status==="reset")return;const t=new CodeError("stream reset",ERR_STREAM_RESET);this.status="reset",this._closeSinkAndSource(t),this.onReset?.()}_closeSinkAndSource(t){this._closeSink(t),this._closeSource(t)}_closeSink(t){this.writeStatus==="writing"&&(this.log.trace("end sink source"),this.sinkController.abort()),this.onSinkEnd(t)}_closeSource(t){this.readStatus!=="closing"&&this.readStatus!=="closed"&&(this.log.trace("ending source with %d bytes to be read by consumer",this.streamSource.readableLength),this.readStatus="closing",this.streamSource.end(t))}remoteCloseWrite(){if(this.readStatus==="closing"||this.readStatus==="closed"){this.log("received remote close write but local source is already closed");return}this.log.trace("remote close write"),this._closeSource()}remoteCloseRead(){if(this.writeStatus==="closing"||this.writeStatus==="closed"){this.log("received remote close read but local sink is already closed");return}this.log.trace("remote close read"),this._closeSink()}destroy(){if(this.status==="closed"||this.status==="aborted"||this.status==="reset"){this.log("received destroy but we are already closed");return}this.log.trace("muxer destroyed"),this._closeSinkAndSource()}sourcePush(t){this.streamSource.push(t)}sourceReadableLength(){return this.streamSource.readableLength}}class MplexStream extends AbstractStream{constructor(r){super(r);Xe(this,"name");Xe(this,"streamId");Xe(this,"send");Xe(this,"types");Xe(this,"maxDataSize");this.types=r.direction==="outbound"?InitiatorMessageTypes:ReceiverMessageTypes,this.send=r.send,this.name=r.name,this.streamId=r.streamId,this.maxDataSize=r.maxDataSize}async sendNewStream(){await this.send({id:this.streamId,type:InitiatorMessageTypes.NEW_STREAM,data:new Uint8ArrayList(fromString$1(this.name))})}async sendData(r){for(r=r.sublist();r.byteLength>0;){const n=Math.min(r.byteLength,this.maxDataSize);await this.send({id:this.streamId,type:this.types.MESSAGE,data:r.sublist(0,n)}),r.consume(n)}}async sendReset(){await this.send({id:this.streamId,type:this.types.RESET})}async sendCloseWrite(){await this.send({id:this.streamId,type:this.types.CLOSE})}async sendCloseRead(){}}function createStream$1(e){const{id:t,name:r,send:n,onEnd:o,type:a="initiator",maxMsgSize:l=MAX_MSG_SIZE}=e;return new MplexStream({id:a==="initiator"?`i${t}`:`r${t}`,streamId:t,name:`${r??t}`,direction:a==="initiator"?"outbound":"inbound",maxDataSize:l,onEnd:o,send:n,log:logger(`libp2p:mplex:stream:${a}:${t}`)})}const log$w=logger("libp2p:mplex"),MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION=1024,MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION=1024,MAX_STREAM_BUFFER_SIZE=1024*1024*4,DISCONNECT_THRESHOLD=5,CLOSE_TIMEOUT$2=500;function printMessage(e){const t={...e,type:`${MessageTypeNames[e.type]} (${e.type})`};return e.type===MessageTypes.NEW_STREAM&&(t.data=toString$5(e.data instanceof Uint8Array?e.data:e.data.subarray())),(e.type===MessageTypes.MESSAGE_INITIATOR||e.type===MessageTypes.MESSAGE_RECEIVER)&&(t.data=toString$5(e.data instanceof Uint8Array?e.data:e.data.subarray(),"base16")),t}class MplexStreamMuxer{constructor(t){Xe(this,"protocol","/mplex/6.7.0");Xe(this,"sink");Xe(this,"source");Xe(this,"_streamId");Xe(this,"_streams");Xe(this,"_init");Xe(this,"_source");Xe(this,"closeController");Xe(this,"rateLimiter");Xe(this,"closeTimeout");t=t??{},this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._init=t,this.closeTimeout=t.closeTimeout??CLOSE_TIMEOUT$2,this.sink=this._createSink(),this._source=pushableV({objectMode:!0,onEnd:()=>{for(const r of this._streams.initiators.values())r.destroy();for(const r of this._streams.receivers.values())r.destroy()}}),this.source=pipe(this._source,r=>encode$7(r,this._init.minSendBytes)),this.closeController=new AbortController,this.rateLimiter=new rateLimiterFlexible.RateLimiterMemory({points:t.disconnectThreshold??DISCONNECT_THRESHOLD,duration:1})}get streams(){const t=[];for(const r of this._streams.initiators.values())t.push(r);for(const r of this._streams.receivers.values())t.push(r);return t}newStream(t){if(this.closeController.signal.aborted)throw new Error("Muxer already closed");const r=this._streamId++;t=t==null?r.toString():t.toString();const n=this._streams.initiators;return this._newStream({id:r,name:t,type:"initiator",registry:n})}async close(t){if(this.closeController.signal.aborted)return;const r=t?.signal??AbortSignal.timeout(this.closeTimeout);try{await Promise.all(this.streams.map(async n=>n.close({signal:r}))),this._source.end(),await this._source.onEmpty({signal:r}),this.closeController.abort()}catch(n){this.abort(n)}}abort(t){this.closeController.signal.aborted||(this.streams.forEach(r=>{r.abort(t)}),this.closeController.abort(t))}_newReceiverStream(t){const{id:r,name:n}=t,o=this._streams.receivers;return this._newStream({id:r,name:n,type:"receiver",registry:o})}_newStream(t){const{id:r,name:n,type:o,registry:a}=t;if(log$w("new %s stream %s",o,r),o==="initiator"&&this._streams.initiators.size===(this._init.maxOutboundStreams??MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION))throw new CodeError("Too many outbound streams open","ERR_TOO_MANY_OUTBOUND_STREAMS");if(a.has(r))throw new Error(`${o} stream ${r} already exists!`);const u=createStream$1({id:r,name:n,send:async g=>{log$w.enabled&&log$w.trace("%s stream %s send",o,r,printMessage(g)),this._source.push(g)},type:o,onEnd:()=>{log$w("%s stream with id %s and protocol %s ended",o,r,u.protocol),a.delete(r),this._init.onStreamEnd!=null&&this._init.onStreamEnd(u)},maxMsgSize:this._init.maxMsgSize});return a.set(r,u),u}_createSink(){return async r=>{try{r=abortableSource(r,this.closeController.signal,{returnOnAbort:!0});const n=new Decoder$1(this._init.maxMsgSize,this._init.maxUnprocessedMessageQueueSize);for await(const o of r)for(const a of n.write(o))await this._handleIncoming(a);this._source.end()}catch(n){log$w("error in sink",n),this._source.end(n)}}}async _handleIncoming(t){const{id:r,type:n}=t;if(log$w.enabled&&log$w.trace("incoming message",printMessage(t)),t.type===MessageTypes.NEW_STREAM){if(this._streams.receivers.size===(this._init.maxInboundStreams??MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION)){log$w("too many inbound streams open"),this._source.push({id:r,type:MessageTypes.RESET_RECEIVER});try{await this.rateLimiter.consume("new-stream",1)}catch{log$w("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),this.abort(new Error("Too many open streams"));return}return}const c=this._newReceiverStream({id:r,name:toString$5(t.data instanceof Uint8Array?t.data:t.data.subarray())});this._init.onIncomingStream!=null&&this._init.onIncomingStream(c);return}const a=((n&1)===1?this._streams.initiators:this._streams.receivers).get(r);if(a==null){log$w("missing stream %s for message type %s",r,MessageTypeNames[n]);try{await this.rateLimiter.consume("missing-stream",1)}catch{log$w("rate limit hit when receiving messages for streams that do not exist - closing remote connection"),this.abort(new Error("Too many messages for missing streams"));return}return}const l=this._init.maxStreamBufferSize??MAX_STREAM_BUFFER_SIZE;try{switch(n){case MessageTypes.MESSAGE_INITIATOR:case MessageTypes.MESSAGE_RECEIVER:if(a.sourceReadableLength()>l)throw this._source.push({id:t.id,type:n===MessageTypes.MESSAGE_INITIATOR?MessageTypes.RESET_RECEIVER:MessageTypes.RESET_INITIATOR}),new CodeError("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers","ERR_STREAM_INPUT_BUFFER_FULL");a.sourcePush(t.data);break;case MessageTypes.CLOSE_INITIATOR:case MessageTypes.CLOSE_RECEIVER:a.remoteCloseWrite();break;case MessageTypes.RESET_INITIATOR:case MessageTypes.RESET_RECEIVER:a.reset();break;default:log$w("unknown message type %s",n)}}catch(c){log$w.error("error while processing message",c),a.abort(c)}}}class Mplex{constructor(t={}){Xe(this,"protocol","/mplex/6.7.0");Xe(this,"_init");this._init=t}createStreamMuxer(t={}){return new MplexStreamMuxer({...t,...this._init})}}function mplex(e={}){return()=>new Mplex(e)}const symbol$1=Symbol.for("@libp2p/transport");var FaultTolerance;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(FaultTolerance||(FaultTolerance={}));var codes$6;(function(e){e.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",e.ERR_DATA_CHANNEL="ERR_DATA_CHANNEL",e.ERR_CONNECTION_CLOSED="ERR_CONNECTION_CLOSED",e.ERR_HASH_NOT_SUPPORTED="ERR_HASH_NOT_SUPPORTED",e.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",e.ERR_INVALID_FINGERPRINT="ERR_INVALID_FINGERPRINT",e.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",e.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",e.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",e.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS"})(codes$6||(codes$6={}));var __spreadArray=globalThis&&globalThis.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,a;n"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ReactNativeInfo:typeof navigator<"u"?parseUserAgent(navigator.userAgent):getNodeVersion()}function matchUserAgent(e){return e!==""&&userAgentRules.reduce(function(t,r){var n=r[0],o=r[1];if(t)return t;var a=o.exec(e);return!!a&&[n,a]},!1)}function parseUserAgent(e){var t=matchUserAgent(e);if(!t)return null;var r=t[0],n=t[1];if(r==="searchbot")return new BotInfo;var o=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);o?o.length{},log$v=logger("libp2p:webrtc:connection");class WebRTCMultiaddrConnection{constructor(t){Xe(this,"peerConnection");Xe(this,"remoteAddr");Xe(this,"timeline");Xe(this,"metrics");Xe(this,"source",nopSource());Xe(this,"sink",nopSink);this.remoteAddr=t.remoteAddr,this.timeline=t.timeline,this.peerConnection=t.peerConnection,this.peerConnection.onconnectionstatechange=()=>{(this.peerConnection.connectionState==="closed"||this.peerConnection.connectionState==="disconnected"||this.peerConnection.connectionState==="failed")&&(this.timeline.close=Date.now())}}async close(t){log$v.trace("closing connection"),this.peerConnection.close(),this.timeline.close=Date.now(),this.metrics?.increment({close:!0})}abort(t){log$v.error("closing connection due to error",t),this.peerConnection.close(),this.timeline.close=Date.now(),this.metrics?.increment({abort:!0})}}const RTCPeerConnection=globalThis.RTCPeerConnection,RTCSessionDescription=globalThis.RTCSessionDescription,RTCIceCandidate=globalThis.RTCIceCandidate;function pbStream(e,t){const r=lpStream(e,t),n={read:async(o,a)=>{const l=await r.read(a);return o.decode(l)},write:async(o,a,l)=>{await r.write(a.encode(o),l)},pb:o=>({read:async a=>n.read(o,a),write:async(a,l)=>n.write(a,o,l),unwrap:()=>n}),unwrap:()=>r.unwrap()};return n}class TimeoutError extends Error{constructor(t){super(t),this.name="TimeoutError"}}class AbortError extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const getDOMException=e=>globalThis.DOMException===void 0?new AbortError(e):new DOMException(e),getAbortedReason=e=>{const t=e.reason===void 0?getDOMException("This operation was aborted."):e.reason;return t instanceof Error?t:getDOMException(t)};function pTimeout(e,t){const{milliseconds:r,fallback:n,message:o,customTimers:a={setTimeout,clearTimeout}}=t;let l;const u=new Promise((g,b)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){const{signal:S}=t;S.aborted&&b(getAbortedReason(S)),S.addEventListener("abort",()=>{b(getAbortedReason(S))})}if(r===Number.POSITIVE_INFINITY){e.then(g,b);return}const x=new TimeoutError;l=a.setTimeout.call(void 0,()=>{if(n){try{g(n())}catch(S){b(S)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?g():o instanceof Error?b(o):(x.message=o??`Promise timed out after ${r} milliseconds`,b(x))},r),(async()=>{try{g(await e)}catch(S){b(S)}})()}).finally(()=>{u.clear()});return u.clear=()=>{a.clearTimeout.call(void 0,l),l=void 0},u}const normalizeEmitter=e=>{const t=e.on||e.addListener||e.addEventListener,r=e.off||e.removeListener||e.removeEventListener;if(!t||!r)throw new TypeError("Emitter is not compatible");return{addListener:t.bind(e),removeListener:r.bind(e)}};function pEventMultiple(e,t,r){let n;const o=new Promise((a,l)=>{if(r={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();const c=[t].flat(),u=[],{addListener:g,removeListener:b}=normalizeEmitter(e),x=(...$)=>{const k=r.multiArgs?$:$[0];r.filter&&!r.filter(k)||(u.push(k),r.count===u.length&&(n(),a(u)))},S=$=>{n(),l($)};n=()=>{for(const $ of c)b($,x);for(const $ of r.rejectionEvents)b($,S)};for(const $ of c)g($,x);for(const $ of r.rejectionEvents)g($,S);r.signal&&r.signal.addEventListener("abort",()=>{S(r.signal.reason)},{once:!0}),r.resolveImmediately&&a(u)});if(o.cancel=n,typeof r.timeout=="number"){const a=pTimeout(o,{milliseconds:r.timeout});return a.cancel=n,a}return o}function pEvent(e,t,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};const n=pEventMultiple(e,t,r),o=n.then(a=>a[0]);return o.cancel=n.cancel,o}var Message$1;(function(e){(function(n){n.FIN="FIN",n.STOP_SENDING="STOP_SENDING",n.RESET="RESET"})(e.Flag||(e.Flag={}));let t;(function(n){n[n.FIN=0]="FIN",n[n.STOP_SENDING=1]="STOP_SENDING",n[n.RESET=2]="RESET"})(t||(t={})),function(n){n.codec=()=>enumeration(t)}(e.Flag||(e.Flag={}));let r;e.codec=()=>(r==null&&(r=message((n,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),n.flag!=null&&(o.uint32(8),e.Flag.codec().encode(n.flag,o)),n.message!=null&&(o.uint32(18),o.bytes(n.message)),a.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{const a={},l=o==null?n.len:n.pos+o;for(;n.pos>>3){case 1:a.flag=e.Flag.codec().decode(n);break;case 2:a.message=n.bytes();break;default:n.skipType(c&7);break}}return a})),r),e.encode=n=>encodeMessage(n,e.codec()),e.decode=n=>decodeMessage(n,e.codec())})(Message$1||(Message$1={}));const MAX_MESSAGE_SIZE=16*1024,MAX_BUFFERED_AMOUNT=16*1024*1024,BUFFERED_AMOUNT_LOW_TIMEOUT=30*1e3,PROTOBUF_OVERHEAD=5,VARINT_LENGTH=2;class WebRTCStream extends AbstractStream{constructor(r){super(r);Xe(this,"channel");Xe(this,"dataChannelOptions");Xe(this,"incomingData");Xe(this,"messageQueue");Xe(this,"maxDataSize");switch(this.channel=r.channel,this.channel.binaryType="arraybuffer",this.incomingData=pushable(),this.messageQueue=new Uint8ArrayList,this.dataChannelOptions={bufferedAmountLowEventTimeout:r.dataChannelOptions?.bufferedAmountLowEventTimeout??BUFFERED_AMOUNT_LOW_TIMEOUT,maxBufferedAmount:r.dataChannelOptions?.maxBufferedAmount??MAX_BUFFERED_AMOUNT,maxMessageSize:r.dataChannelOptions?.maxMessageSize??r.maxDataSize},this.maxDataSize=r.maxDataSize,this.channel.readyState){case"open":break;case"closed":case"closing":(this.timeline.close===void 0||this.timeline.close===0)&&(this.timeline.close=Date.now());break;case"connecting":break;default:throw this.log.error("unknown datachannel state %s",this.channel.readyState),new CodeError("Unknown datachannel state","ERR_INVALID_STATE")}this.channel.onopen=o=>{this.timeline.open=new Date().getTime(),this.messageQueue!=null&&(this._sendMessage(this.messageQueue).catch(a=>{this.abort(a)}),this.messageQueue=void 0)},this.channel.onclose=o=>{this.close().catch(a=>{this.log.error("error closing stream after channel closed",a)})},this.channel.onerror=o=>{const a=o.error;this.abort(a)};const n=this;this.channel.onmessage=async o=>{const{data:a}=o;a===null||a.byteLength===0||this.incomingData.push(new Uint8Array(a,0,a.byteLength))},Promise.resolve().then(async()=>{for await(const o of decode$a(this.incomingData)){const a=n.processIncomingProtobuf(o.subarray());a!=null&&n.sourcePush(new Uint8ArrayList(a))}}).catch(o=>{this.log.error("error processing incoming data channel messages",o)})}sendNewStream(){}async _sendMessage(r,n=!0){if(n&&this.channel.bufferedAmount>this.dataChannelOptions.maxBufferedAmount)try{await pEvent(this.channel,"bufferedamountlow",{timeout:this.dataChannelOptions.bufferedAmountLowEventTimeout})}catch(o){throw o instanceof TimeoutError?new Error("Timed out waiting for DataChannel buffer to clear"):o}if(this.channel.readyState==="closed"||this.channel.readyState==="closing")throw new CodeError("Invalid datachannel state - closed or closing","ERR_INVALID_STATE");if(this.channel.readyState==="open")for(const o of r)this.channel.send(o);else if(this.channel.readyState==="connecting")this.messageQueue==null&&(this.messageQueue=new Uint8ArrayList),this.messageQueue.append(r);else throw this.log.error("unknown datachannel state %s",this.channel.readyState),new CodeError("Unknown datachannel state","ERR_INVALID_STATE")}async sendData(r){for(r=r.sublist();r.byteLength>0;){const n=Math.min(r.byteLength,this.maxDataSize),o=r.subarray(0,n),a=Message$1.encode({message:o}),l=encode$c.single(a);await this._sendMessage(l),r.consume(n)}}async sendReset(){await this._sendFlag(Message$1.Flag.RESET)}async sendCloseWrite(){await this._sendFlag(Message$1.Flag.FIN)}async sendCloseRead(){await this._sendFlag(Message$1.Flag.STOP_SENDING)}processIncomingProtobuf(r){const n=Message$1.decode(r);return n.flag!==void 0&&(n.flag===Message$1.Flag.FIN&&(this.incomingData.end(),this.remoteCloseWrite()),n.flag===Message$1.Flag.RESET&&this.reset(),n.flag===Message$1.Flag.STOP_SENDING&&this.remoteCloseRead()),n.message}async _sendFlag(r){this.log.trace("Sending flag: %s",r.toString());const n=Message$1.encode({flag:r}),o=encode$c.single(n);await this._sendMessage(o,!1)}}function createStream(e){const{channel:t,direction:r,onEnd:n,dataChannelOptions:o}=e;return new WebRTCStream({id:r==="inbound"?`i${t.id}`:`r${t.id}`,direction:r,maxDataSize:(o?.maxMessageSize??MAX_MESSAGE_SIZE)-PROTOBUF_OVERHEAD-VARINT_LENGTH,dataChannelOptions:o,onEnd:n,channel:t,log:logger(`libp2p:webrtc:stream:${r}:${t.id}`)})}const PROTOCOL="/webrtc";class DataChannelMuxerFactory{constructor(t){Xe(this,"protocol");Xe(this,"peerConnection");Xe(this,"streamBuffer",[]);Xe(this,"metrics");Xe(this,"dataChannelOptions");this.peerConnection=t.peerConnection,this.metrics=t.metrics,this.protocol=t.protocol??PROTOCOL,this.dataChannelOptions=t.dataChannelOptions,this.peerConnection.ondatachannel=({channel:r})=>{const n=createStream({channel:r,direction:"inbound",dataChannelOptions:t.dataChannelOptions,onEnd:()=>{this.streamBuffer=this.streamBuffer.filter(o=>o.id!==n.id)}});this.streamBuffer.push(n)}}createStreamMuxer(t){return new DataChannelMuxer({...t,peerConnection:this.peerConnection,dataChannelOptions:this.dataChannelOptions,metrics:this.metrics,streams:this.streamBuffer,protocol:this.protocol})}}class DataChannelMuxer{constructor(t){Xe(this,"init");Xe(this,"streams");Xe(this,"protocol");Xe(this,"peerConnection");Xe(this,"dataChannelOptions");Xe(this,"metrics");Xe(this,"close",async()=>{});Xe(this,"abort",()=>{});Xe(this,"source",nopSource());Xe(this,"sink",nopSink);this.init=t,this.streams=t.streams,this.peerConnection=t.peerConnection,this.protocol=t.protocol??PROTOCOL,this.metrics=t.metrics,this.peerConnection.ondatachannel=({channel:n})=>{const o=createStream({channel:n,direction:"inbound",dataChannelOptions:this.dataChannelOptions,onEnd:()=>{this.streams=this.streams.filter(a=>a.id!==o.id),this.metrics?.increment({stream_end:!0}),t?.onStreamEnd?.(o)}});this.streams.push(o),t?.onIncomingStream!=null&&(this.metrics?.increment({incoming_stream:!0}),t.onIncomingStream(o))};const r=t?.onIncomingStream;r!=null&&this.streams.forEach(n=>{r(n)})}newStream(){const t=this.peerConnection.createDataChannel(""),r=createStream({channel:t,direction:"outbound",dataChannelOptions:this.dataChannelOptions,onEnd:()=>{t.close(),this.streams=this.streams.filter(n=>n.id!==r.id),this.metrics?.increment({stream_end:!0}),this.init?.onStreamEnd?.(r)}});return this.streams.push(r),this.metrics?.increment({outgoing_stream:!0}),r}}var Message;(function(e){(function(n){n.SDP_OFFER="SDP_OFFER",n.SDP_ANSWER="SDP_ANSWER",n.ICE_CANDIDATE="ICE_CANDIDATE"})(e.Type||(e.Type={}));let t;(function(n){n[n.SDP_OFFER=0]="SDP_OFFER",n[n.SDP_ANSWER=1]="SDP_ANSWER",n[n.ICE_CANDIDATE=2]="ICE_CANDIDATE"})(t||(t={})),function(n){n.codec=()=>enumeration(t)}(e.Type||(e.Type={}));let r;e.codec=()=>(r==null&&(r=message((n,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),e.Type.codec().encode(n.type,o)),n.data!=null&&(o.uint32(18),o.string(n.data)),a.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{const a={},l=o==null?n.len:n.pos+o;for(;n.pos>>3){case 1:a.type=e.Type.codec().decode(n);break;case 2:a.data=n.string();break;default:n.skipType(c&7);break}}return a})),r),e.encode=n=>encodeMessage(n,e.codec()),e.decode=n=>decodeMessage(n,e.codec())})(Message||(Message={}));const log$u=logger("libp2p:webrtc:peer:util"),readCandidatesUntilConnected=async(e,t,r)=>{for(;;){const n=await Promise.race([e.promise,r.read()]);if(n instanceof Object){const o=n;if(o.type!==Message.Type.ICE_CANDIDATE)throw new Error("expected only ice candidates");if(o.data==null||o.data===""){log$u.trace("end-of-candidates received");break}log$u.trace("received new ICE candidate: %s",o.data);try{await t.addIceCandidate(new RTCIceCandidate(JSON.parse(o.data)))}catch(a){throw log$u.error("bad candidate received: ",a),new Error("bad candidate received")}}else break}await e.promise};function resolveOnConnected(e,t){e[isFirefox?"oniceconnectionstatechange":"onconnectionstatechange"]=r=>{switch(log$u.trace("receiver peerConnectionState state: ",e.connectionState),isFirefox?e.iceConnectionState:e.connectionState){case"connected":t.resolve();break;case"failed":case"disconnected":case"closed":t.reject(new Error("RTCPeerConnection was closed"));break}}}const DEFAULT_TIMEOUT=30*1e3,log$t=logger("libp2p:webrtc:peer");async function handleIncomingStream({rtcConfiguration:e,dataChannelOptions:t,stream:r}){const n=AbortSignal.timeout(DEFAULT_TIMEOUT),o=pbStream(abortableDuplex(r,n)).pb(Message),a=new RTCPeerConnection(e);try{const l=new DataChannelMuxerFactory({peerConnection:a,dataChannelOptions:t}),c=pDefer(),u=pDefer();n.onabort=()=>{c.reject(new CodeError("Timed out while trying to connect","ERR_TIMEOUT"))},a.onicecandidate=({candidate:$})=>{u.promise.then(async()=>{await o.write({type:Message.Type.ICE_CANDIDATE,data:$!=null?JSON.stringify($.toJSON()):""})},k=>{log$t.error("cannot set candidate since sending answer failed",k),c.reject(k)})},resolveOnConnected(a,c);const g=await o.read();if(g.type!==Message.Type.SDP_OFFER)throw new Error(`expected message type SDP_OFFER, received: ${g.type??"undefined"} `);const b=new RTCSessionDescription({type:"offer",sdp:g.data});await a.setRemoteDescription(b).catch($=>{throw log$t.error("could not execute setRemoteDescription",$),new Error("Failed to set remoteDescription")});const x=await a.createAnswer().catch($=>{throw log$t.error("could not execute createAnswer",$),u.reject($),new Error("Failed to create answer")});await o.write({type:Message.Type.SDP_ANSWER,data:x.sdp}),await a.setLocalDescription(x).catch($=>{throw log$t.error("could not execute setLocalDescription",$),u.reject($),new Error("Failed to set localDescription")}),u.resolve(),await readCandidatesUntilConnected(c,a,o);const S=parseRemoteAddress(a.currentRemoteDescription?.sdp??"");return{pc:a,muxerFactory:l,remoteAddress:S}}catch(l){throw a.close(),l}}async function initiateConnection({rtcConfiguration:e,dataChannelOptions:t,signal:r,stream:n}){const o=pbStream(abortableDuplex(n,r)).pb(Message),a=new RTCPeerConnection(e);try{const l=new DataChannelMuxerFactory({peerConnection:a,dataChannelOptions:t}),c=pDefer();resolveOnConnected(a,c),r.onabort=c.reject;const u=a.createDataChannel("init");a.onicecandidate=({candidate:$})=>{o.write({type:Message.Type.ICE_CANDIDATE,data:$!=null?JSON.stringify($.toJSON()):""}).catch(k=>{log$t.error("error sending ICE candidate",k)})};const g=await a.createOffer();await o.write({type:Message.Type.SDP_OFFER,data:g.sdp}),await a.setLocalDescription(g).catch($=>{throw log$t.error("could not execute setLocalDescription",$),new Error("Failed to set localDescription")});const b=await o.read();if(b.type!==Message.Type.SDP_ANSWER)throw new Error("remote should send an SDP answer");const x=new RTCSessionDescription({type:"answer",sdp:b.data});await a.setRemoteDescription(x).catch($=>{throw log$t.error("could not execute setRemoteDescription",$),new Error("Failed to set remoteDescription")}),await readCandidatesUntilConnected(c,a,o),u.close();const S=parseRemoteAddress(a.currentRemoteDescription?.sdp??"");return{pc:a,muxerFactory:l,remoteAddress:S}}catch(l){throw a.close(),l}}function parseRemoteAddress(e){const t=e.split(`\r -`).filter(n=>n.startsWith("a=candidate")).pop(),r=t?.split(" ");return t==null||r==null||r.length<5?(log$t("could not parse remote address from",t),"/webrtc"):`/dnsaddr/${r[4]}/${r[2].toLowerCase()}/${r[5]}/webrtc`}class WebRTCPeerListener extends EventEmitter$2{constructor(r){super();Xe(this,"peerId");Xe(this,"transportManager");this.peerId=r.peerId,this.transportManager=r.transportManager}async listen(){this.safeDispatchEvent("listening",{})}getAddrs(){return this.transportManager.getListeners().filter(r=>r!==this).map(r=>r.getAddrs().filter(n=>Circuit$1.matches(n)).map(n=>n.encapsulate(`/webrtc/p2p/${this.peerId}`))).flat()}async close(){this.safeDispatchEvent("close",{})}}const log$s=logger("libp2p:webrtc:peer"),WEBRTC_TRANSPORT="/webrtc",CIRCUIT_RELAY_TRANSPORT="/p2p-circuit",SIGNALING_PROTO_ID="/webrtc-signaling/0.0.1",WEBRTC_CODE=getProtocol("webrtc").code;var tc,rc;class WebRTCTransport{constructor(t,r={}){Xe(this,"components");Xe(this,"init");Xe(this,"_started",!1);Xe(this,"metrics");Xe(this,tc,"@libp2p/webrtc");Xe(this,rc,!0);this.components=t,this.init=r,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_webrtc_dialer_events_total",{label:"event",help:"Total count of WebRTC dialer events by type"}),listenerEvents:t.metrics.registerCounterGroup("libp2p_webrtc_listener_events_total",{label:"event",help:"Total count of WebRTC listener events by type"})})}isStarted(){return this._started}async start(){await this.components.registrar.handle(SIGNALING_PROTO_ID,t=>{this._onProtocol(t).catch(r=>{log$s.error("failed to handle incoming connect from %p",t.connection.remotePeer,r)})},{runOnTransientConnection:!0}),this._started=!0}async stop(){await this.components.registrar.unhandle(SIGNALING_PROTO_ID),this._started=!1}createListener(t){return new WebRTCPeerListener(this.components)}filter(t){return t.filter(r=>r.protoCodes().includes(WEBRTC_CODE))}async dial(t,r){log$s.trace("dialing address: ",t);const{baseAddr:n,peerId:o}=splitAddr(t);if(r.signal==null){const c=new AbortController;r.signal=c.signal}this.metrics?.dialerEvents.increment({open:!0});const a=await this.components.transportManager.dial(n,r),l=await a.newStream(SIGNALING_PROTO_ID,{...r,runOnTransientConnection:!0});try{const{pc:c,muxerFactory:u,remoteAddress:g}=await initiateConnection({stream:l,rtcConfiguration:this.init.rtcConfiguration,dataChannelOptions:this.init.dataChannel,signal:r.signal}),b=await r.upgrader.upgradeOutbound(new WebRTCMultiaddrConnection({peerConnection:c,timeline:{open:Date.now()},remoteAddr:multiaddr(g).encapsulate(`/p2p/${o.toString()}`),metrics:this.metrics?.dialerEvents}),{skipProtection:!0,skipEncryption:!0,muxerFactory:u});return await l.close(),b}catch(c){throw this.metrics?.dialerEvents.increment({error:!0}),l.abort(c),c}finally{await a.close()}}async _onProtocol({connection:t,stream:r}){try{const{pc:n,muxerFactory:o,remoteAddress:a}=await handleIncomingStream({rtcConfiguration:this.init.rtcConfiguration,connection:t,stream:r,dataChannelOptions:this.init.dataChannel});await this.components.upgrader.upgradeInbound(new WebRTCMultiaddrConnection({peerConnection:n,timeline:{open:new Date().getTime()},remoteAddr:multiaddr(a).encapsulate(`/p2p/${t.remotePeer.toString()}`),metrics:this.metrics?.listenerEvents}),{skipEncryption:!0,skipProtection:!0,muxerFactory:o})}catch(n){throw r.abort(n),n}finally{await t.close()}}}tc=Symbol.toStringTag,rc=symbol$1;function splitAddr(e){const t=e.toString().split(WEBRTC_TRANSPORT+"/");if(t.length!==2)throw new CodeError("webrtc protocol was not present in multiaddr",codes$6.ERR_INVALID_MULTIADDR);if(!t[0].includes(CIRCUIT_RELAY_TRANSPORT))throw new CodeError("p2p-circuit protocol was not present in multiaddr",codes$6.ERR_INVALID_MULTIADDR);let r=multiaddr(t[0]);const o=multiaddr("/"+t[1]).getPeerId();if(o==null)throw new CodeError("destination peer id was missing",codes$6.ERR_INVALID_MULTIADDR);const a=r.protos().pop();if(a===void 0)throw new CodeError("invalid multiaddr",codes$6.ERR_INVALID_MULTIADDR);return a.name!=="p2p"&&(r=r.encapsulate(`/p2p/${o}`)),{baseAddr:r,peerId:peerIdFromString(o)}}var src$2={exports:{}};function base$2(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,N=new Uint8Array(O);D!==I;){for(var ee=$[D],ne=0,B=O-1;(ee!==0||ne>>0,N[B]=ee%l>>>0,ee=ee/l>>>0;if(ee!==0)throw new Error("Non-zero carry");T=ne,D++}for(var le=O-T;le!==O&&N[le]===0;)le++;for(var fe=c.repeat(k);le>>0,O=new Uint8Array(I);$[k];){var N=t[$.charCodeAt(k)];if(N===255)return;for(var ee=0,ne=I-1;(N!==0||ee>>0,O[ne]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");D=ee,k++}if($[k]!==" "){for(var B=I-D;B!==I&&O[B]===0;)B++;for(var le=new Uint8Array(T+(I-B)),fe=T;B!==I;)le[fe++]=O[B++];return le}}}function S($){var k=x($);if(k)return k;throw new Error("Non-base"+l+" character")}return{encode:b,decodeUnsafe:x,decode:S}}var src$1=base$2;const textDecoder=new TextDecoder,decodeText$1=e=>textDecoder.decode(e),textEncoder=new TextEncoder,encodeText$2=e=>textEncoder.encode(e);function concat(e,t){const r=new Uint8Array(t);let n=0;for(const o of e)r.set(o,n),n+=o.length;return r}var util={decodeText:decodeText$1,encodeText:encodeText$2,concat};const{encodeText:encodeText$1}=util;class Base$1{constructor(t,r,n,o){this.name=t,this.code=r,this.codeBuf=encodeText$1(this.code),this.alphabet=o,this.codec=n(o)}encode(t){return this.codec.encode(t)}decode(t){for(const r of t)if(this.alphabet&&this.alphabet.indexOf(r)<0)throw new Error(`invalid character '${r}' in '${t}'`);return this.codec.decode(t)}}var base$1=Base$1;const decode$4=(e,t,r)=>{const n={};for(let g=0;g=8&&(l-=8,a[u++]=255&c>>l)}if(l>=r||255&c<<8-l)throw new SyntaxError("Unexpected end of data");return a},encode$6=(e,t,r)=>{const n=t[t.length-1]==="=",o=(1<r;)l-=r,a+=t[o&c>>l];if(l&&(a+=t[o&c<t=>({encode(r){return encode$6(r,t,e)},decode(r){return decode$4(r,t,e)}});var rfc4648_1={rfc4648:rfc4648$2};const baseX$1=src$1,Base=base$1,{rfc4648:rfc4648$1}=rfc4648_1,{decodeText,encodeText}=util,identity$3=()=>({encode:decodeText,decode:encodeText}),constants$1=[["identity","\0",identity$3,""],["base2","0",rfc4648$1(1),"01"],["base8","7",rfc4648$1(3),"01234567"],["base10","9",baseX$1,"0123456789"],["base16","f",rfc4648$1(4),"0123456789abcdef"],["base16upper","F",rfc4648$1(4),"0123456789ABCDEF"],["base32hex","v",rfc4648$1(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",rfc4648$1(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",rfc4648$1(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",rfc4648$1(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",rfc4648$1(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",rfc4648$1(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",rfc4648$1(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",rfc4648$1(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",rfc4648$1(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",baseX$1,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",baseX$1,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",baseX$1,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",baseX$1,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",rfc4648$1(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",rfc4648$1(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",rfc4648$1(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",rfc4648$1(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],names$2=constants$1.reduce((e,t)=>(e[t[0]]=new Base(t[0],t[1],t[2],t[3]),e),{}),codes$5=constants$1.reduce((e,t)=>(e[t[1]]=names$2[t[0]],e),{});var constants_1={names:names$2,codes:codes$5};(function(e,t){const r=constants_1,{encodeText:n,decodeText:o,concat:a}=util;function l(T,D){if(!D)throw new Error("requires an encoded Uint8Array");const{name:I,codeBuf:O}=x(T);return b(I,D),a([O,D],O.length+D.length)}function c(T,D){const I=x(T),O=n(I.encode(D));return a([I.codeBuf,O],I.codeBuf.length+O.length)}function u(T){T instanceof Uint8Array&&(T=o(T));const D=T[0];return["f","F","v","V","t","T","b","B","c","C","h","k","K"].includes(D)&&(T=T.toLowerCase()),x(T[0]).decode(T.substring(1))}function g(T){if(T instanceof Uint8Array&&(T=o(T)),Object.prototype.toString.call(T)!=="[object String]")return!1;try{return x(T[0]).name}catch{return!1}}function b(T,D){x(T).decode(o(D))}function x(T){if(Object.prototype.hasOwnProperty.call(r.names,T))return r.names[T];if(Object.prototype.hasOwnProperty.call(r.codes,T))return r.codes[T];throw new Error(`Unsupported encoding: ${T}`)}function S(T){return T instanceof Uint8Array&&(T=o(T)),x(T[0])}t=e.exports=l,t.encode=c,t.decode=u,t.isEncoded=g,t.encoding=x,t.encodingFromData=S;const $=Object.freeze(r.names),k=Object.freeze(r.codes);t.names=$,t.codes=k})(src$2,src$2.exports);const names$1=Object.freeze({identity:0,sha1:17,"sha2-256":18,"sha2-512":19,"sha3-512":20,"sha3-384":21,"sha3-256":22,"sha3-224":23,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,blake3:30,"murmur3-128":34,"murmur3-32":35,"dbl-sha2-256":86,md4:212,md5:213,bmt:214,"sha2-256-trunc254-padded":4114,"ripemd-128":4178,"ripemd-160":4179,"ripemd-256":4180,"ripemd-320":4181,x11:4352,kangarootwelve:7425,"sm3-256":21325,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"skein256-8":45825,"skein256-16":45826,"skein256-24":45827,"skein256-32":45828,"skein256-40":45829,"skein256-48":45830,"skein256-56":45831,"skein256-64":45832,"skein256-72":45833,"skein256-80":45834,"skein256-88":45835,"skein256-96":45836,"skein256-104":45837,"skein256-112":45838,"skein256-120":45839,"skein256-128":45840,"skein256-136":45841,"skein256-144":45842,"skein256-152":45843,"skein256-160":45844,"skein256-168":45845,"skein256-176":45846,"skein256-184":45847,"skein256-192":45848,"skein256-200":45849,"skein256-208":45850,"skein256-216":45851,"skein256-224":45852,"skein256-232":45853,"skein256-240":45854,"skein256-248":45855,"skein256-256":45856,"skein512-8":45857,"skein512-16":45858,"skein512-24":45859,"skein512-32":45860,"skein512-40":45861,"skein512-48":45862,"skein512-56":45863,"skein512-64":45864,"skein512-72":45865,"skein512-80":45866,"skein512-88":45867,"skein512-96":45868,"skein512-104":45869,"skein512-112":45870,"skein512-120":45871,"skein512-128":45872,"skein512-136":45873,"skein512-144":45874,"skein512-152":45875,"skein512-160":45876,"skein512-168":45877,"skein512-176":45878,"skein512-184":45879,"skein512-192":45880,"skein512-200":45881,"skein512-208":45882,"skein512-216":45883,"skein512-224":45884,"skein512-232":45885,"skein512-240":45886,"skein512-248":45887,"skein512-256":45888,"skein512-264":45889,"skein512-272":45890,"skein512-280":45891,"skein512-288":45892,"skein512-296":45893,"skein512-304":45894,"skein512-312":45895,"skein512-320":45896,"skein512-328":45897,"skein512-336":45898,"skein512-344":45899,"skein512-352":45900,"skein512-360":45901,"skein512-368":45902,"skein512-376":45903,"skein512-384":45904,"skein512-392":45905,"skein512-400":45906,"skein512-408":45907,"skein512-416":45908,"skein512-424":45909,"skein512-432":45910,"skein512-440":45911,"skein512-448":45912,"skein512-456":45913,"skein512-464":45914,"skein512-472":45915,"skein512-480":45916,"skein512-488":45917,"skein512-496":45918,"skein512-504":45919,"skein512-512":45920,"skein1024-8":45921,"skein1024-16":45922,"skein1024-24":45923,"skein1024-32":45924,"skein1024-40":45925,"skein1024-48":45926,"skein1024-56":45927,"skein1024-64":45928,"skein1024-72":45929,"skein1024-80":45930,"skein1024-88":45931,"skein1024-96":45932,"skein1024-104":45933,"skein1024-112":45934,"skein1024-120":45935,"skein1024-128":45936,"skein1024-136":45937,"skein1024-144":45938,"skein1024-152":45939,"skein1024-160":45940,"skein1024-168":45941,"skein1024-176":45942,"skein1024-184":45943,"skein1024-192":45944,"skein1024-200":45945,"skein1024-208":45946,"skein1024-216":45947,"skein1024-224":45948,"skein1024-232":45949,"skein1024-240":45950,"skein1024-248":45951,"skein1024-256":45952,"skein1024-264":45953,"skein1024-272":45954,"skein1024-280":45955,"skein1024-288":45956,"skein1024-296":45957,"skein1024-304":45958,"skein1024-312":45959,"skein1024-320":45960,"skein1024-328":45961,"skein1024-336":45962,"skein1024-344":45963,"skein1024-352":45964,"skein1024-360":45965,"skein1024-368":45966,"skein1024-376":45967,"skein1024-384":45968,"skein1024-392":45969,"skein1024-400":45970,"skein1024-408":45971,"skein1024-416":45972,"skein1024-424":45973,"skein1024-432":45974,"skein1024-440":45975,"skein1024-448":45976,"skein1024-456":45977,"skein1024-464":45978,"skein1024-472":45979,"skein1024-480":45980,"skein1024-488":45981,"skein1024-496":45982,"skein1024-504":45983,"skein1024-512":45984,"skein1024-520":45985,"skein1024-528":45986,"skein1024-536":45987,"skein1024-544":45988,"skein1024-552":45989,"skein1024-560":45990,"skein1024-568":45991,"skein1024-576":45992,"skein1024-584":45993,"skein1024-592":45994,"skein1024-600":45995,"skein1024-608":45996,"skein1024-616":45997,"skein1024-624":45998,"skein1024-632":45999,"skein1024-640":46e3,"skein1024-648":46001,"skein1024-656":46002,"skein1024-664":46003,"skein1024-672":46004,"skein1024-680":46005,"skein1024-688":46006,"skein1024-696":46007,"skein1024-704":46008,"skein1024-712":46009,"skein1024-720":46010,"skein1024-728":46011,"skein1024-736":46012,"skein1024-744":46013,"skein1024-752":46014,"skein1024-760":46015,"skein1024-768":46016,"skein1024-776":46017,"skein1024-784":46018,"skein1024-792":46019,"skein1024-800":46020,"skein1024-808":46021,"skein1024-816":46022,"skein1024-824":46023,"skein1024-832":46024,"skein1024-840":46025,"skein1024-848":46026,"skein1024-856":46027,"skein1024-864":46028,"skein1024-872":46029,"skein1024-880":46030,"skein1024-888":46031,"skein1024-896":46032,"skein1024-904":46033,"skein1024-912":46034,"skein1024-920":46035,"skein1024-928":46036,"skein1024-936":46037,"skein1024-944":46038,"skein1024-952":46039,"skein1024-960":46040,"skein1024-968":46041,"skein1024-976":46042,"skein1024-984":46043,"skein1024-992":46044,"skein1024-1000":46045,"skein1024-1008":46046,"skein1024-1016":46047,"skein1024-1024":46048,"poseidon-bls12_381-a2-fc1":46081,"poseidon-bls12_381-a2-fc1-sc":46082});var constants={names:names$1};function base(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,ee=new Uint8Array(N);I!==O;){for(var ne=k[I],B=0,le=N-1;(ne!==0||B>>0,ee[le]=ne%c>>>0,ne=ne/c>>>0;if(ne!==0)throw new Error("Non-zero carry");D=B,I++}for(var fe=N-D;fe!==N&&ee[fe]===0;)fe++;for(var xe=u.repeat(T);fe>>0,N=new Uint8Array(O);k[T];){var ee=r[k.charCodeAt(T)];if(ee===255)return;for(var ne=0,B=O-1;(ee!==0||ne>>0,N[B]=ee%256>>>0,ee=ee/256>>>0;if(ee!==0)throw new Error("Non-zero carry");I=ne,T++}if(k[T]!==" "){for(var le=O-I;le!==O&&N[le]===0;)le++;for(var fe=new Uint8Array(D+(O-le)),xe=D;le!==O;)fe[xe++]=N[le++];return fe}}}function $(k){var T=S(k);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:x,decodeUnsafe:S,decode:$}}var src=base,_brrp__multiformats_scope_baseX=src;const coerce$1=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},fromString=e=>new TextEncoder().encode(e),toString$3=e=>new TextDecoder().decode(e);class Encoder{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class Decoder{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return or$1(this,t)}}class ComposedDecoder{constructor(t){this.decoders=t}or(t){return or$1(this,t)}decode(t){const r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const or$1=(e,t)=>new ComposedDecoder({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Codec{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Encoder(t,r,n),this.decoder=new Decoder(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const from$1=({name:e,prefix:t,encode:r,decode:n})=>new Codec(e,t,r,n),baseX=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=_brrp__multiformats_scope_baseX(r,t);return from$1({prefix:e,name:t,encode:n,decode:a=>coerce$1(o(a))})},decode$3=(e,t,r,n)=>{const o={};for(let b=0;b=8&&(c-=8,l[g++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return l},encode$5=(e,t,r)=>{const n=t[t.length-1]==="=",o=(1<r;)l-=r,a+=t[o&c>>l];if(l&&(a+=t[o&c<from$1({prefix:t,name:e,encode(o){return encode$5(o,n,r)},decode(o){return decode$3(o,n,r,e)}}),identity$2=from$1({prefix:"\0",name:"identity",encode:e=>toString$3(e),decode:e=>fromString(e)}),identityBase=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$2},Symbol.toStringTag,{value:"Module"})),base2=rfc4648({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$1=Object.freeze(Object.defineProperty({__proto__:null,base2},Symbol.toStringTag,{value:"Module"})),base8=rfc4648({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$1=Object.freeze(Object.defineProperty({__proto__:null,base8},Symbol.toStringTag,{value:"Module"})),base10=baseX({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$1=Object.freeze(Object.defineProperty({__proto__:null,base10},Symbol.toStringTag,{value:"Module"})),base16=rfc4648({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper=rfc4648({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$1=Object.freeze(Object.defineProperty({__proto__:null,base16,base16upper},Symbol.toStringTag,{value:"Module"})),base32=rfc4648({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper=rfc4648({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad=rfc4648({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper=rfc4648({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex=rfc4648({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper=rfc4648({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad=rfc4648({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper=rfc4648({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z=rfc4648({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$1=Object.freeze(Object.defineProperty({__proto__:null,base32,base32upper,base32pad,base32padupper,base32hex,base32hexupper,base32hexpad,base32hexpadupper,base32z},Symbol.toStringTag,{value:"Module"})),base36=baseX({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper=baseX({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$1=Object.freeze(Object.defineProperty({__proto__:null,base36,base36upper},Symbol.toStringTag,{value:"Module"})),base58btc=baseX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr=baseX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58=Object.freeze(Object.defineProperty({__proto__:null,base58btc,base58flickr},Symbol.toStringTag,{value:"Module"})),base64=rfc4648({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad=rfc4648({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url=rfc4648({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad=rfc4648({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$1=Object.freeze(Object.defineProperty({__proto__:null,base64,base64pad,base64url,base64urlpad},Symbol.toStringTag,{value:"Module"})),alphabet$1=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),alphabetBytesToChars=alphabet$1.reduce((e,t,r)=>(e[r]=t,e),[]),alphabetCharsToBytes=alphabet$1.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function encode$4(e){return e.reduce((t,r)=>(t+=alphabetBytesToChars[r],t),"")}function decode$2(e){const t=[];for(const r of e){const n=alphabetCharsToBytes[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n)}return new Uint8Array(t)}const base256emoji=from$1({prefix:"\u{1F680}",name:"base256emoji",encode:encode$4,decode:decode$2}),base256emoji$1=Object.freeze(Object.defineProperty({__proto__:null,base256emoji},Symbol.toStringTag,{value:"Module"}));var encode_1=encode$3,MSB=128,REST=127,MSBALL=~REST,INT=Math.pow(2,31);function encode$3(e,t,r){t=t||[],r=r||0;for(var n=r;e>=INT;)t[r++]=e&255|MSB,e/=128;for(;e&MSBALL;)t[r++]=e&255|MSB,e>>>=7;return t[r]=e|0,encode$3.bytes=r-n+1,t}var decode$1=read$1,MSB$1=128,REST$1=127;function read$1(e,n){var r=0,n=n||0,o=0,a=n,l,c=e.length;do{if(a>=c)throw read$1.bytes=0,new RangeError("Could not decode varint");l=e[a++],r+=o<28?(l&REST$1)<=MSB$1);return read$1.bytes=a-n,r}var N1=Math.pow(2,7),N2=Math.pow(2,14),N3=Math.pow(2,21),N4=Math.pow(2,28),N5=Math.pow(2,35),N6=Math.pow(2,42),N7=Math.pow(2,49),N8=Math.pow(2,56),N9=Math.pow(2,63),length$1=function(e){return e(_brrp_varint.encode(e,t,r),t),encodingLength=e=>_brrp_varint.encodingLength(e),create=(e,t)=>{const r=t.byteLength,n=encodingLength(e),o=n+encodingLength(r),a=new Uint8Array(o+r);return encodeTo(e,a,0),encodeTo(r,a,n),a.set(t,o),new Digest(e,r,t,a)};class Digest{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}}const from=({name:e,code:t,encode:r})=>new Hasher(e,t,r);class Hasher{constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){const r=this.encode(t);return r instanceof Uint8Array?create(this.code,r):r.then(n=>create(this.code,n))}else throw Error("Unknown type, must be binary type")}}const sha=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),sha256=from({name:"sha2-256",code:18,encode:sha("SHA-256")}),sha512=from({name:"sha2-512",code:19,encode:sha("SHA-512")}),sha2=Object.freeze(Object.defineProperty({__proto__:null,sha256,sha512},Symbol.toStringTag,{value:"Module"})),code$2=0,name="identity",encode$2=coerce$1,digest=e=>create(code$2,encode$2(e)),identity={code:code$2,name,encode:encode$2,digest},identity$1=Object.freeze(Object.defineProperty({__proto__:null,identity},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;({...identityBase,...base2$1,...base8$1,...base10$1,...base16$1,...base32$1,...base36$1,...base58,...base64$1,...base256emoji$1});({...sha2,...identity$1});const{names}=constants,codes$4={};for(const e in names){const t=e;codes$4[names[t]]=t}Object.freeze(codes$4);logger("libp2p:webrtc:sdp");Object.values(bases).map(e=>e.decoder).reduce((e,t)=>e.or(t));Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");logger("libp2p:webrtc:transport");getProtocol("webrtc-direct").code;getProtocol("certhash").code;function webRTC(e){return t=>new WebRTCTransport(t,e)}function extractSNI(e){let t;try{t=getProtocol("sni").code}catch{return null}for(const[r,n]of e)if(r===t&&n!==void 0)return n;return null}function hasTLS(e){return e.some(([t,r])=>t===getProtocol("tls").code)}function interpretNext(e,t,r){const n=interpreters[getProtocol(e).name];if(n===void 0)throw new Error(`Can't interpret protocol ${getProtocol(e).name}`);const o=n(t,r);return e===getProtocol("ip6").code?`[${o}]`:o}const interpreters={ip4:(e,t)=>e,ip6:(e,t)=>t.length===0?e:`[${e}]`,tcp:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`tcp://${interpretNext(r[0],r[1]??"",t)}:${e}`},udp:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`udp://${interpretNext(r[0],r[1]??"",t)}:${e}`},dnsaddr:(e,t)=>e,dns4:(e,t)=>e,dns6:(e,t)=>e,dns:(e,t)=>e,ipfs:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(r[0],r[1]??"",t)}/ipfs/${e}`},p2p:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(r[0],r[1]??"",t)}/p2p/${e}`},http:(e,t)=>{const r=hasTLS(t),n=extractSNI(t);if(r&&n!==null)return`https://${n}`;const o=r?"https://":"http://",a=t.pop();if(a===void 0)throw new Error("Unexpected end of multiaddr");let l=interpretNext(a[0],a[1]??"",t);return l=l.replace("tcp://",""),`${o}${l}`},tls:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return interpretNext(r[0],r[1]??"",t)},sni:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return interpretNext(r[0],r[1]??"",t)},https:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=interpretNext(r[0],r[1]??"",t);return n=n.replace("tcp://",""),`https://${n}`},ws:(e,t)=>{const r=hasTLS(t),n=extractSNI(t);if(r&&n!==null)return`wss://${n}`;const o=r?"wss://":"ws://",a=t.pop();if(a===void 0)throw new Error("Unexpected end of multiaddr");let l=interpretNext(a[0],a[1]??"",t);return l=l.replace("tcp://",""),`${o}${l}`},wss:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=interpretNext(r[0],r[1]??"",t);return n=n.replace("tcp://",""),`wss://${n}`},"p2p-websocket-star":(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(r[0],r[1]??"",t)}/p2p-websocket-star`},"p2p-webrtc-star":(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(r[0],r[1]??"",t)}/p2p-webrtc-star`},"p2p-webrtc-direct":(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(r[0],r[1]??"",t)}/p2p-webrtc-direct`}};function multiaddrToUri(e,t){const n=multiaddr(e).stringTuples(),o=n.pop();if(o===void 0)throw new Error("Unexpected end of multiaddr");const a=getProtocol(o[0]),l=interpreters[a.name];if(l==null)throw new Error(`No interpreter found for ${a.name}`);let c=l(o[1]??"",n);return t?.assumeHttp!==!1&&o[0]===getProtocol("tcp").code&&(c=c.replace("tcp://","http://"),(o[1]==="443"||o[1]==="80")&&(o[1]==="443"&&(c=c.replace("http://","https://")),c=c.substring(0,c.lastIndexOf(":")))),c}const ready=async e=>{if(e.readyState>=2)throw new Error("socket closed");e.readyState!==1&&await new Promise((t,r)=>{function n(){e.removeEventListener("open",o),e.removeEventListener("error",a)}function o(){n(),t()}function a(l){n(),r(l.error??new Error(`connect ECONNREFUSED ${e.url}`))}e.addEventListener("open",o),e.addEventListener("error",a)})},sink=(e,t)=>(t=t??{},t.closeOnEnd=t.closeOnEnd!==!1,async n=>{for await(const o of n){try{await ready(e)}catch(a){if(a.message==="socket closed")break;throw a}if(e.readyState===e.CLOSING||e.readyState===e.CLOSED)break;e.send(o)}t.closeOnEnd!=null&&e.readyState<=1&&await new Promise((o,a)=>{e.addEventListener("close",l=>{if(l.wasClean||l.code===1006)o();else{const c=Object.assign(new Error("ws error"),{event:l});a(c)}}),setTimeout(()=>{e.close()})})});var dom$1={},eventIterator={};Object.defineProperty(eventIterator,"__esModule",{value:!0});class EventQueue{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(t){if(this.isStopped)return;const r={value:t,done:!1};if(this.pullQueue.length){const n=this.pullQueue.shift();n&&n.resolve(r)}else this.pushQueue.push(Promise.resolve(r)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const t of this.pullQueue)t.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(t){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const r of this.pullQueue)r.reject(t);this.pullQueue.length=0}else{const r=Promise.reject(t);r.catch(()=>{}),this.pushQueue.push(r)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:t=>{const r=this.pushQueue.shift();return r?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),r):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((n,o)=>{this.pullQueue.push({resolve:n,reject:o})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class EventIterator$1{constructor(t,{highWaterMark:r=100,lowWaterMark:n=1}={}){const o=new EventQueue;o.highWaterMark=r,o.lowWaterMark=n,o.removeCallback=t({push:a=>o.push(a),stop:()=>o.stop(),fail:a=>o.fail(a),on:(a,l)=>{o.eventHandlers[a]=l}})||(()=>{}),this[Symbol.asyncIterator]=()=>o[Symbol.asyncIterator](),Object.freeze(this)}}eventIterator.EventIterator=EventIterator$1;eventIterator.default=EventIterator$1;Object.defineProperty(dom$1,"__esModule",{value:!0});const event_iterator_1=eventIterator;var EventIterator=dom$1.EventIterator=event_iterator_1.EventIterator;function subscribe(e,t,r){return new event_iterator_1.EventIterator(({push:n})=>(this.addEventListener(e,n,t),()=>this.removeEventListener(e,n,t)),r)}dom$1.subscribe=subscribe;dom$1.default=event_iterator_1.EventIterator;function isArrayBuffer(e){return e instanceof ArrayBuffer||e?.constructor?.name==="ArrayBuffer"&&typeof e?.byteLength=="number"}const source=e=>{e.binaryType="arraybuffer";const t=async()=>{await new Promise((a,l)=>{if(n){a();return}if(o!=null){l(o);return}const c=b=>{e.removeEventListener("open",u),e.removeEventListener("error",g),b()},u=()=>{c(a)},g=b=>{c(()=>{l(b.error??new Error(`connect ECONNREFUSED ${e.url}`))})};e.addEventListener("open",u),e.addEventListener("error",g)})},r=async function*(){const a=new EventIterator(({push:l,stop:c,fail:u})=>{const g=x=>{let S=null;typeof x.data=="string"&&(S=fromString$1(x.data)),isArrayBuffer(x.data)&&(S=new Uint8Array(x.data)),x.data instanceof Uint8Array&&(S=x.data),S!=null&&l(S)},b=x=>{u(x.error??new Error("Socket error"))};return e.addEventListener("message",g),e.addEventListener("error",b),e.addEventListener("close",c),()=>{e.removeEventListener("message",g),e.removeEventListener("error",b),e.removeEventListener("close",c)}},{highWaterMark:1/0});await t();for await(const l of a)yield isArrayBuffer(l)?new Uint8Array(l):l}();let n=e.readyState===1,o;return e.addEventListener("open",()=>{n=!0,o=null}),e.addEventListener("close",()=>{n=!1,o=null}),e.addEventListener("error",a=>{n||(o=a.error??new Error(`connect ECONNREFUSED ${e.url}`))}),Object.assign(r,{connected:t})},duplex=(e,t)=>{t=t??{};const r=source(e);let n=t.remoteAddress,o=t.remotePort;if(e.url!=null)try{const l=new URL(e.url);n=l.hostname,o=parseInt(l.port,10)}catch{}if(n==null||o==null)throw new Error("Remote connection did not have address and/or port");return{sink:sink(e,t),source:r,connected:async()=>{await r.connected()},close:async()=>{(e.readyState===e.CONNECTING||e.readyState===e.OPEN)&&await new Promise(l=>{e.addEventListener("close",()=>{l()}),e.close()})},destroy:()=>{e.terminate!=null?e.terminate():e.close()},remoteAddress:n,remotePort:o,socket:e}},WebSocket$1=WebSocket,isReactNative$1=typeof navigator<"u"&&navigator.product==="ReactNative";function getDefaultBase(){return isReactNative$1?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}const URL$1=self.URL,defaultBase$1=getDefaultBase();class URLWithLegacySupport$2{constructor(t="",r=defaultBase$1){this.super=new URL$1(t,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set username(t){this.super.username=t}static createObjectURL(t){return URL$1.createObjectURL(t)}static revokeObjectURL(t){URL$1.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}}function format$2(e){if(typeof e=="string")return new URL$1(e).toString();if(!(e instanceof URL$1)){const t=e.username&&e.password?`${e.username}:${e.password}@`:"",r=e.auth?e.auth+"@":"",n=e.port?":"+e.port:"",o=e.protocol?e.protocol+"//":"",a=e.host||"",l=e.hostname||"",c=e.search||(e.query?"?"+e.query:""),u=e.hash||"",g=e.pathname||"",b=e.path||g+c;return`${o}${t||r}${a||l+n}${b}${u}`}}var urlBrowser={URLWithLegacySupport:URLWithLegacySupport$2,URLSearchParams:self.URLSearchParams,defaultBase:defaultBase$1,format:format$2};const{URLWithLegacySupport:URLWithLegacySupport$1,format:format$1}=urlBrowser;var relative$1=(e,t={},r={},n)=>{let o=t.protocol?t.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let a;try{a=new URLWithLegacySupport$1(e)}catch{a={}}const l=Object.assign({},t,{protocol:o||a.protocol,host:t.host||a.host});return new URLWithLegacySupport$1(e,format$1(l)).toString()};const{URLWithLegacySupport,format,URLSearchParams:URLSearchParams$1,defaultBase}=urlBrowser,relative=relative$1;var isoUrl={URL:URLWithLegacySupport,URLSearchParams:URLSearchParams$1,format,relative,defaultBase};const map$2={http:"ws",https:"wss"},def="ws",wsurl=(e,t)=>isoUrl.relative(e,t,map$2,def);function connect(e,t){const r=typeof window>"u"?"":window.location;t=t??{};const n=wsurl(e,r.toString()),o=new WebSocket$1(n,t.websocket);return duplex(o,t)}function isElectron$1(){return typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&!!process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0}var isElectron_1=isElectron$1;const isEnvWithDom=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,isElectron=isElectron_1(),isBrowser=isEnvWithDom&&!isElectron,isElectronMain=isElectron&&!isEnvWithDom,isElectronRenderer=isElectron&&isEnvWithDom,isNode=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!isElectron,isWebWorker=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope;typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+(()=>"_")()+"ENV"];const isReactNative=typeof navigator<"u"&&navigator.product==="ReactNative",CODE_P2P=421,CODE_CIRCUIT=290,CLOSE_TIMEOUT$1=500;function all$1(e){return e.filter(t=>{if(t.protoCodes().includes(CODE_CIRCUIT))return!1;const r=t.decapsulateCode(CODE_P2P);return WebSockets$1.matches(r)||WebSocketsSecure.matches(r)})}function wss(e){return e.filter(t=>{if(t.protoCodes().includes(CODE_CIRCUIT))return!1;const r=t.decapsulateCode(CODE_P2P);return WebSocketsSecure.matches(r)})}function createListener$1(){throw new Error("WebSocket Servers can not be created in the browser!")}const log$r=logger("libp2p:websockets:socket");function socketToMaConn(e,t,r){r=r??{};const n={async sink(o){r?.signal!=null&&(o=abortableSource(o,r.signal));try{await e.sink(o)}catch(a){a.type!=="aborted"&&log$r.error(a)}},source:r.signal!=null?abortableSource(e.source,r.signal):e.source,remoteAddr:t,timeline:{open:Date.now()},async close(o={}){const a=Date.now();o.signal=o.signal??AbortSignal.timeout(CLOSE_TIMEOUT$1);const l=()=>{const{host:c,port:u}=n.remoteAddr.toOptions();log$r("timeout closing stream to %s:%s after %dms, destroying it manually",c,u,Date.now()-a),this.abort(new CodeError("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT"))};o.signal.addEventListener("abort",l);try{await e.close()}catch(c){this.abort(c)}finally{o.signal.removeEventListener("abort",l),n.timeline.close=Date.now()}},abort(o){const{host:a,port:l}=n.remoteAddr.toOptions();log$r("timeout closing stream to %s:%s due to error",a,l,o),e.destroy(),n.timeline.close=Date.now()}};return e.socket.addEventListener("close",()=>{n.timeline.close==null&&(n.timeline.close=Date.now())},{once:!0}),n}const log$q=logger("libp2p:websockets");var nc,ic;class WebSockets{constructor(t){Xe(this,"init");Xe(this,nc,"@libp2p/websockets");Xe(this,ic,!0);this.init=t}async dial(t,r){log$q("dialing %s",t),r=r??{};const n=await this._connect(t,r),o=socketToMaConn(n,t);log$q("new outbound connection %s",o.remoteAddr);const a=await r.upgrader.upgradeOutbound(o);return log$q("outbound connection %s upgraded",o.remoteAddr),a}async _connect(t,r){if(r?.signal?.aborted===!0)throw new AbortError$4;const n=t.toOptions();log$q("dialing %s:%s",n.host,n.port);const o=pDefer(),a=connect(multiaddrToUri(t),this.init);if(a.socket.addEventListener("error",()=>{const u=new CodeError(`Could not connect to ${t.toString()}`,"ERR_CONNECTION_FAILED");log$q.error("connection error:",u),o.reject(u)}),r.signal==null)return await Promise.race([a.connected(),o.promise]),log$q("connected %s",t),a;let l;const c=new Promise((u,g)=>{if(l=()=>{g(new AbortError$4),a.close().catch(b=>{log$q.error("error closing raw socket",b)})},r?.signal?.aborted===!0){l();return}r?.signal?.addEventListener("abort",l)});try{await Promise.race([c,o.promise,a.connected()])}finally{l!=null&&r?.signal?.removeEventListener("abort",l)}return log$q("connected %s",t),a}createListener(t){return createListener$1({...this.init,...t})}filter(t){return t=Array.isArray(t)?t:[t],this.init?.filter!=null?this.init?.filter(t):isBrowser||isWebWorker?wss(t):all$1(t)}}nc=Symbol.toStringTag,ic=symbol$1;function webSockets(e={}){return()=>new WebSockets(e)}var events$1={exports:{}},R$1=typeof Reflect=="object"?Reflect:null,ReflectApply=R$1&&typeof R$1.apply=="function"?R$1.apply:function e(t,r,n){return Function.prototype.apply.call(t,r,n)},ReflectOwnKeys;R$1&&typeof R$1.ownKeys=="function"?ReflectOwnKeys=R$1.ownKeys:Object.getOwnPropertySymbols?ReflectOwnKeys=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ReflectOwnKeys=function(t){return Object.getOwnPropertyNames(t)};function ProcessEmitWarning(e){console&&console.warn&&console.warn(e)}var NumberIsNaN=Number.isNaN||function e(t){return t!==t};function EventEmitter(){EventEmitter.init.call(this)}events$1.exports=EventEmitter;events$1.exports.once=once;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=void 0;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=void 0;var defaultMaxListeners=10;function checkListener(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(e){if(typeof e!="number"||e<0||NumberIsNaN(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");defaultMaxListeners=e}});EventEmitter.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};EventEmitter.prototype.setMaxListeners=function e(t){if(typeof t!="number"||t<0||NumberIsNaN(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function _getMaxListeners(e){return e._maxListeners===void 0?EventEmitter.defaultMaxListeners:e._maxListeners}EventEmitter.prototype.getMaxListeners=function e(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function e(t){for(var r=[],n=1;n0&&(l=r[0]),l instanceof Error)throw l;var c=new Error("Unhandled error."+(l?" ("+l.message+")":""));throw c.context=l,c}var u=a[t];if(u===void 0)return!1;if(typeof u=="function")ReflectApply(u,this,r);else for(var g=u.length,b=arrayClone(u,g),n=0;n0&&l.length>o&&!l.warned){l.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=l.length,ProcessEmitWarning(c)}return e}EventEmitter.prototype.addListener=function e(t,r){return _addListener(this,t,r,!1)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function e(t,r){return _addListener(this,t,r,!0)};function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=onceWrapper.bind(n);return o.listener=r,n.wrapFn=o,o}EventEmitter.prototype.once=function e(t,r){return checkListener(r),this.on(t,_onceWrap(this,t,r)),this};EventEmitter.prototype.prependOnceListener=function e(t,r){return checkListener(r),this.prependListener(t,_onceWrap(this,t,r)),this};EventEmitter.prototype.removeListener=function e(t,r){var n,o,a,l,c;if(checkListener(r),o=this._events,o===void 0)return this;if(n=o[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[t],o.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(a=-1,l=n.length-1;l>=0;l--)if(n[l]===r||n[l].listener===r){c=n[l].listener,a=l;break}if(a<0)return this;a===0?n.shift():spliceOne(n,a),n.length===1&&(o[t]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",t,c||r)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function e(t){var r,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var a=Object.keys(n),l;for(o=0;o=0;o--)this.removeListener(t,r[o]);return this};function _listeners(e,t,r){var n=e._events;if(n===void 0)return[];var o=n[t];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?unwrapListeners(o):arrayClone(o,o.length)}EventEmitter.prototype.listeners=function e(t){return _listeners(this,t,!0)};EventEmitter.prototype.rawListeners=function e(t){return _listeners(this,t,!1)};EventEmitter.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):listenerCount.call(e,t)};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}EventEmitter.prototype.eventNames=function e(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(e,t){for(var r=new Array(t),n=0;ncrypto.getRandomValues(new Uint8Array(e)).reduce((t,r)=>(r&=63,r<36?t+=r.toString(36):r<62?t+=(r-26).toString(36).toUpperCase():r>62?t+="-":t+="_",t),"");const pathSepS="/",pathSepB=new TextEncoder().encode(pathSepS),pathSep=pathSepB[0];class Key{constructor(t,r){Xe(this,"_buf");if(typeof t=="string")this._buf=fromString$1(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==pathSep)throw new Error("Invalid key")}toString(t="utf8"){return toString$5(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new Key(t.join(pathSepS))}static random(){return new Key(nanoid().replace(/-/g,""))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new Key(t):typeof t.uint8Array=="function"?new Key(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=pathSepB),this._buf[0]!==pathSep){const t=new Uint8Array(this._buf.byteLength+1);t.fill(pathSep,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===pathSep;)this._buf=this._buf.subarray(0,-1)}less(t){const r=this.list(),n=t.list();for(let o=0;ol)return!1}return r.lengthr.namespaces()))])}}function namespaceType(e){const t=e.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function namespaceValue(e){const t=e.split(":");return t[t.length-1]}function flatten(e){return[].concat(...e)}var isPlainObj=e=>{if(Object.prototype.toString.call(e)!=="[object Object]")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype};const isOptionObject=isPlainObj,{hasOwnProperty:hasOwnProperty$1}=Object.prototype,{propertyIsEnumerable}=Object,defineProperty=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),globalThis$4=commonjsGlobal$2,defaultMergeOptions={concatArrays:!1,ignoreUndefined:!1},getEnumerableOwnPropertyKeys=e=>{const t=[];for(const r in e)hasOwnProperty$1.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)propertyIsEnumerable.call(e,n)&&t.push(n)}return t};function clone$1(e){return Array.isArray(e)?cloneArray(e):isOptionObject(e)?cloneOptionObject(e):e}function cloneArray(e){const t=e.slice(0,0);return getEnumerableOwnPropertyKeys(e).forEach(r=>{defineProperty(t,r,clone$1(e[r]))}),t}function cloneOptionObject(e){const t=Object.getPrototypeOf(e)===null?Object.create(null):{};return getEnumerableOwnPropertyKeys(e).forEach(r=>{defineProperty(t,r,clone$1(e[r]))}),t}const mergeKeys=(e,t,r,n)=>(r.forEach(o=>{typeof t[o]>"u"&&n.ignoreUndefined||(o in e&&e[o]!==Object.getPrototypeOf(e)?defineProperty(e,o,merge(e[o],t[o],n)):defineProperty(e,o,clone$1(t[o])))}),e),concatArrays=(e,t,r)=>{let n=e.slice(0,0),o=0;return[e,t].forEach(a=>{const l=[];for(let c=0;c!l.includes(c)),r)}),n};function merge(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?concatArrays(e,t,r):!isOptionObject(t)||!isOptionObject(e)?clone$1(t):mergeKeys(e,t,getEnumerableOwnPropertyKeys(t),r)}var mergeOptions=function(...e){const t=merge(clone$1(defaultMergeOptions),this!==globalThis$4&&this||{},defaultMergeOptions);let r={_:{}};for(const n of e)if(n!==void 0){if(!isOptionObject(n))throw new TypeError("`"+n+"` is not an Option Object");r=merge(r,{_:n},t)}return r._};function isHighSurrogate$1(e){return e>=55296&&e<=56319}function isLowSurrogate$1(e){return e>=56320&&e<=57343}var truncate$2=function e(t,r,n){if(typeof r!="string")throw new Error("Input must be string");for(var o=r.length,a=0,l,c,u=0;un)return r.slice(0,u-c.length+1)}return r};function isHighSurrogate(e){return e>=55296&&e<=56319}function isLowSurrogate(e){return e>=56320&&e<=57343}var browser$5=function e(t){if(typeof t!="string")throw new Error("Input must be string");for(var r=t.length,n=0,o=null,a=null,l=0;l=128&&o<=2047?n+=2:o>=2048&&o<=65535&&(n+=3),a=o;return n},truncate$1=truncate$2,getLength=browser$5,browser$4=truncate$1.bind(null,getLength),truncate=browser$4,illegalRe=/[\/\?<>\\:\*\|"]/g,controlRe=/[\x00-\x1f\x80-\x9f]/g,reservedRe=/^\.+$/,windowsReservedRe=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,windowsTrailingRe=/[\. ]+$/;function sanitize(e,t){if(typeof e!="string")throw new Error("Input must be string");var r=e.replace(illegalRe,t).replace(controlRe,t).replace(reservedRe,t).replace(windowsReservedRe,t).replace(windowsTrailingRe,t);return truncate(r,255)}var sanitizeFilename=function(e,t){var r=t&&t.replacement||"",n=sanitize(e,r);return r===""?n:sanitize(n,"")},codes$3;(function(e){e.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",e.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",e.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",e.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",e.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",e.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",e.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",e.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",e.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",e.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",e.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",e.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",e.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",e.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",e.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH"})(codes$3||(codes$3={}));const log$p=logger("libp2p:keychain"),keyPrefix="/pkcs8/",infoPrefix="/info/",privates=new WeakMap,NIST={minKeyLength:112/8,minSaltLength:128/8,minIterationCount:1e3},defaultOptions$6={dek:{keyLength:512/8,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function validateKeyName(e){return e==null||typeof e!="string"?!1:e===sanitizeFilename(e.trim())&&e.length>0}async function randomDelay(){const r=Math.random()*800+200;await new Promise(n=>setTimeout(n,r))}function DsName(e){return new Key(keyPrefix+e)}function DsInfoName(e){return new Key(infoPrefix+e)}class DefaultKeyChain{constructor(t,r){Xe(this,"components");Xe(this,"init");if(this.components=t,this.init=mergeOptions(defaultOptions$6,r),this.init.pass!=null&&this.init.pass?.length<20)throw new Error("pass must be least 20 characters");if(this.init.dek?.keyLength!=null&&this.init.dek.keyLengtho.id===t);if(n==null)throw new CodeError(`Key with id '${t}' does not exist.`,codes$3.ERR_KEY_NOT_FOUND);return n}catch(r){throw await randomDelay(),r}}async findKeyByName(t){if(!validateKeyName(t))throw await randomDelay(),new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);const r=DsInfoName(t);try{const n=await this.components.datastore.get(r);return JSON.parse(toString$5(n))}catch(n){throw await randomDelay(),log$p.error(n),new CodeError(`Key '${t}' does not exist.`,codes$3.ERR_KEY_NOT_FOUND)}}async removeKey(t){if(!validateKeyName(t)||t==="self")throw await randomDelay(),new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);const r=DsName(t),n=await this.findKeyByName(t),o=this.components.datastore.batch();return o.delete(r),o.delete(DsInfoName(t)),await o.commit(),n}async renameKey(t,r){if(!validateKeyName(t)||t==="self")throw await randomDelay(),new CodeError(`Invalid old key name '${t}'`,codes$3.ERR_OLD_KEY_NAME_INVALID);if(!validateKeyName(r)||r==="self")throw await randomDelay(),new CodeError(`Invalid new key name '${r}'`,codes$3.ERR_NEW_KEY_NAME_INVALID);const n=DsName(t),o=DsName(r),a=DsInfoName(t),l=DsInfoName(r);if(await this.components.datastore.has(o))throw await randomDelay(),new CodeError(`Key '${r}' already exists`,codes$3.ERR_KEY_ALREADY_EXISTS);try{const u=await this.components.datastore.get(n),g=await this.components.datastore.get(a),b=JSON.parse(toString$5(g));b.name=r;const x=this.components.datastore.batch();return x.put(o,u),x.put(l,fromString$1(JSON.stringify(b))),x.delete(n),x.delete(a),await x.commit(),b}catch(u){throw await randomDelay(),u}}async exportKey(t,r){if(!validateKeyName(t))throw await randomDelay(),new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);if(r==null)throw await randomDelay(),new CodeError("Password is required",codes$3.ERR_PASSWORD_REQUIRED);const n=DsName(t);try{const o=await this.components.datastore.get(n),a=toString$5(o),l=privates.get(this);if(l==null)throw new CodeError("dek missing",codes$3.ERR_INVALID_PARAMETERS);const c=l.dek;return await(await importKey(a,c)).export(r)}catch(o){throw await randomDelay(),o}}async exportPeerId(t){const r="temporary-password",n=await this.exportKey(t,r),o=await importKey(n,r);return peerIdFromKeys(o.public.bytes,o.bytes)}async importKey(t,r,n){if(!validateKeyName(t)||t==="self")throw await randomDelay(),new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);if(r==null)throw await randomDelay(),new CodeError("PEM encoded key is required",codes$3.ERR_PEM_REQUIRED);const o=DsName(t);if(await this.components.datastore.has(o))throw await randomDelay(),new CodeError(`Key '${t}' already exists`,codes$3.ERR_KEY_ALREADY_EXISTS);let l;try{l=await importKey(r,n)}catch{throw await randomDelay(),new CodeError("Cannot read the key, most likely the password is wrong",codes$3.ERR_CANNOT_READ_KEY)}let c;try{c=await l.id();const b=privates.get(this);if(b==null)throw new CodeError("dek missing",codes$3.ERR_INVALID_PARAMETERS);const x=b.dek;r=await l.export(x)}catch(b){throw await randomDelay(),b}const u={name:t,id:c},g=this.components.datastore.batch();return g.put(o,fromString$1(r)),g.put(DsInfoName(t),fromString$1(JSON.stringify(u))),await g.commit(),u}async importPeer(t,r){try{if(!validateKeyName(t))throw new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);if(r==null)throw new CodeError("PeerId is required",codes$3.ERR_MISSING_PRIVATE_KEY);if(r.privateKey==null)throw new CodeError("PeerId.privKey is required",codes$3.ERR_MISSING_PRIVATE_KEY);const n=await unmarshalPrivateKey(r.privateKey),o=DsName(t);if(await this.components.datastore.has(o))throw await randomDelay(),new CodeError(`Key '${t}' already exists`,codes$3.ERR_KEY_ALREADY_EXISTS);const l=privates.get(this);if(l==null)throw new CodeError("dek missing",codes$3.ERR_INVALID_PARAMETERS);const c=l.dek,u=await n.export(c),g={name:t,id:r.toString()},b=this.components.datastore.batch();return b.put(o,fromString$1(u)),b.put(DsInfoName(t),fromString$1(JSON.stringify(g))),await b.commit(),g}catch(n){throw await randomDelay(),n}}async getPrivateKey(t){if(!validateKeyName(t))throw await randomDelay(),new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);try{const r=DsName(t),n=await this.components.datastore.get(r);return toString$5(n)}catch(r){throw await randomDelay(),log$p.error(r),new CodeError(`Key '${t}' does not exist.`,codes$3.ERR_KEY_NOT_FOUND)}}async rotateKeychainPass(t,r){if(typeof t!="string")throw await randomDelay(),new CodeError(`Invalid old pass type '${typeof t}'`,codes$3.ERR_INVALID_OLD_PASS_TYPE);if(typeof r!="string")throw await randomDelay(),new CodeError(`Invalid new pass type '${typeof r}'`,codes$3.ERR_INVALID_NEW_PASS_TYPE);if(r.length<20)throw await randomDelay(),new CodeError(`Invalid pass length ${r.length}`,codes$3.ERR_INVALID_PASS_LENGTH);log$p("recreating keychain");const n=privates.get(this);if(n==null)throw new CodeError("dek missing",codes$3.ERR_INVALID_PARAMETERS);const o=n.dek;this.init.pass=r;const a=r!=null&&this.init.dek?.salt!=null?pbkdf2(r,this.init.dek.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";privates.set(this,{dek:a});const l=await this.listKeys();for(const c of l){const u=await this.components.datastore.get(DsName(c.name)),g=toString$5(u),b=await importKey(g,o),x=a.toString(),S=await b.export(x),$=this.components.datastore.batch(),k={name:c.name,id:c.id};$.put(DsName(c.name),fromString$1(S)),$.put(DsInfoName(c.name),fromString$1(JSON.stringify(k))),await $.commit()}log$p("keychain reconstructed")}}var PeerIdProto;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.id!=null&&(n.uint32(10),n.bytes(r.id)),r.pubKey!=null&&(n.uint32(18),n.bytes(r.pubKey)),r.privKey!=null&&(n.uint32(26),n.bytes(r.privKey)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.id=r.bytes();break;case 2:o.pubKey=r.bytes();break;case 3:o.privKey=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(PeerIdProto||(PeerIdProto={}));const createEd25519PeerId=async()=>{const e=await generateKeyPair("Ed25519"),t=await createFromPrivKey(e);if(t.type==="Ed25519")return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function createFromPrivKey(e){return peerIdFromKeys(marshalPublicKey(e.public),marshalPrivateKey(e))}const codes$2={ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"};var Envelope;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.publicKey!=null&&r.publicKey.byteLength>0&&(n.uint32(10),n.bytes(r.publicKey)),r.payloadType!=null&&r.payloadType.byteLength>0&&(n.uint32(18),n.bytes(r.payloadType)),r.payload!=null&&r.payload.byteLength>0&&(n.uint32(26),n.bytes(r.payload)),r.signature!=null&&r.signature.byteLength>0&&(n.uint32(42),n.bytes(r.signature)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.publicKey=r.bytes();break;case 2:o.payloadType=r.bytes();break;case 3:o.payload=r.bytes();break;case 5:o.signature=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Envelope||(Envelope={}));const ds=class{constructor(t){Xe(this,"peerId");Xe(this,"payloadType");Xe(this,"payload");Xe(this,"signature");Xe(this,"marshaled");const{peerId:r,payloadType:n,payload:o,signature:a}=t;this.peerId=r,this.payloadType=n,this.payload=o,this.signature=a}marshal(){if(this.peerId.publicKey==null)throw new Error("Missing public key");return this.marshaled==null&&(this.marshaled=Envelope.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(t){return equals$2(this.marshal(),t.marshal())}async validate(t){const r=formatSignaturePayload(t,this.payloadType,this.payload);if(this.peerId.publicKey==null)throw new Error("Missing public key");return unmarshalPublicKey(this.peerId.publicKey).verify(r.subarray(),this.signature)}};let RecordEnvelope=ds;Xe(RecordEnvelope,"createFromProtobuf",async t=>{const r=Envelope.decode(t),n=await peerIdFromKeys(r.publicKey);return new ds({peerId:n,payloadType:r.payloadType,payload:r.payload,signature:r.signature})}),Xe(RecordEnvelope,"seal",async(t,r)=>{if(r.privateKey==null)throw new Error("Missing private key");const n=t.domain,o=t.codec,a=t.marshal(),l=formatSignaturePayload(n,o,a),u=await(await unmarshalPrivateKey(r.privateKey)).sign(l.subarray());return new ds({peerId:r,payloadType:o,payload:a,signature:u})}),Xe(RecordEnvelope,"openAndCertify",async(t,r)=>{const n=await ds.createFromProtobuf(t);if(!await n.validate(r))throw new CodeError("envelope signature is not valid for the given domain",codes$2.ERR_SIGNATURE_NOT_VALID);return n});const formatSignaturePayload=(e,t,r)=>{const n=fromString$1(e),o=encode$d(n.byteLength),a=encode$d(t.length),l=encode$d(r.length);return new Uint8ArrayList(o,n,a,t,l,r)};function arrayEquals(e,t){const r=(n,o)=>n.toString().localeCompare(o.toString());return e.length!==t.length?!1:(t.sort(r),e.sort(r).every((n,o)=>t[o].equals(n)))}const ENVELOPE_DOMAIN_PEER_RECORD="libp2p-peer-record",ENVELOPE_PAYLOAD_TYPE_PEER_RECORD=Uint8Array.from([3,1]);var PeerRecord$1;(function(e){(function(r){let n;r.codec=()=>(n==null&&(n=message((o,a,l={})=>{l.lengthDelimited!==!1&&a.fork(),o.multiaddr!=null&&o.multiaddr.byteLength>0&&(a.uint32(10),a.bytes(o.multiaddr)),l.lengthDelimited!==!1&&a.ldelim()},(o,a)=>{const l={multiaddr:new Uint8Array(0)},c=a==null?o.len:o.pos+a;for(;o.pos>>3){case 1:l.multiaddr=o.bytes();break;default:o.skipType(u&7);break}}return l})),n),r.encode=o=>encodeMessage(o,r.codec()),r.decode=o=>decodeMessage(o,r.codec())})(e.AddressInfo||(e.AddressInfo={}));let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.peerId!=null&&r.peerId.byteLength>0&&(n.uint32(10),n.bytes(r.peerId)),r.seq!=null&&r.seq!==0n&&(n.uint32(16),n.uint64(r.seq)),r.addresses!=null)for(const a of r.addresses)n.uint32(26),e.AddressInfo.codec().encode(a,n);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={peerId:new Uint8Array(0),seq:0n,addresses:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.peerId=r.bytes();break;case 2:o.seq=r.uint64();break;case 3:o.addresses.push(e.AddressInfo.codec().decode(r,r.uint32()));break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(PeerRecord$1||(PeerRecord$1={}));const Ri=class{constructor(t){Xe(this,"peerId");Xe(this,"multiaddrs");Xe(this,"seqNumber");Xe(this,"domain",Ri.DOMAIN);Xe(this,"codec",Ri.CODEC);Xe(this,"marshaled");const{peerId:r,multiaddrs:n,seqNumber:o}=t;this.peerId=r,this.multiaddrs=n??[],this.seqNumber=o??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=PeerRecord$1.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!(!(t instanceof Ri)||!this.peerId.equals(t.peerId)||this.seqNumber!==t.seqNumber||!arrayEquals(this.multiaddrs,t.multiaddrs))}};let PeerRecord=Ri;Xe(PeerRecord,"createFromProtobuf",t=>{const r=PeerRecord$1.decode(t),n=peerIdFromBytes(r.peerId),o=(r.addresses??[]).map(l=>multiaddr(l.multiaddr)),a=r.seq;return new Ri({peerId:n,multiaddrs:o,seqNumber:a})}),Xe(PeerRecord,"DOMAIN",ENVELOPE_DOMAIN_PEER_RECORD),Xe(PeerRecord,"CODEC",ENVELOPE_PAYLOAD_TYPE_PEER_RECORD);function isAsyncIterable$6(e){return e[Symbol.asyncIterator]!=null}function all(e){if(isAsyncIterable$6(e))return(async()=>{const r=[];for await(const n of e)r.push(n);return r})();const t=[];for(const r of e)t.push(r);return t}const WORKER_REQUEST_READ_LOCK="lock:worker:request-read",WORKER_RELEASE_READ_LOCK="lock:worker:release-read",MASTER_GRANT_READ_LOCK="lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK="lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK="lock:worker:release-write",MASTER_GRANT_WRITE_LOCK="lock:master:grant-write",events={},observable=e=>{e.addEventListener("message",t=>{observable.dispatchEvent("message",e,t)}),e.port!=null&&e.port.addEventListener("message",t=>{observable.dispatchEvent("message",e,t)})};observable.addEventListener=(e,t)=>{events[e]==null&&(events[e]=[]),events[e].push(t)};observable.removeEventListener=(e,t)=>{events[e]!=null&&(events[e]=events[e].filter(r=>r===t))};observable.dispatchEvent=function(e,t,r){events[e]!=null&&events[e].forEach(n=>n(t,r))};const handleWorkerLockRequest=(e,t,r,n,o)=>(a,l)=>{if(l.data.type!==r)return;const c={type:l.data.type,name:l.data.name,identifier:l.data.identifier};e.dispatchEvent(new MessageEvent(t,{data:{name:c.name,handler:async()=>(a.postMessage({type:o,name:c.name,identifier:c.identifier}),await new Promise(u=>{const g=b=>{if(b==null||b.data==null)return;const x={type:b.data.type,name:b.data.name,identifier:b.data.identifier};x.type===n&&x.identifier===c.identifier&&(a.removeEventListener("message",g),u())};a.addEventListener("message",g)}))}}))},makeWorkerLockRequest=(e,t,r,n)=>async()=>{const o=nanoid();return globalThis.postMessage({type:t,identifier:o,name:e}),await new Promise(a=>{const l=c=>{if(c==null||c.data==null)return;const u={type:c.data.type,identifier:c.data.identifier};u.type===r&&u.identifier===o&&(globalThis.removeEventListener("message",l),a(()=>{globalThis.postMessage({type:n,identifier:o,name:e})}))};globalThis.addEventListener("message",l)})},defaultOptions$5={singleProcess:!1},impl=e=>{if(e=Object.assign({},defaultOptions$5,e),Boolean(globalThis.document)||e.singleProcess){const r=new EventTarget;return observable.addEventListener("message",handleWorkerLockRequest(r,"requestReadLock",WORKER_REQUEST_READ_LOCK,WORKER_RELEASE_READ_LOCK,MASTER_GRANT_READ_LOCK)),observable.addEventListener("message",handleWorkerLockRequest(r,"requestWriteLock",WORKER_REQUEST_WRITE_LOCK,WORKER_RELEASE_WRITE_LOCK,MASTER_GRANT_WRITE_LOCK)),r}return{isWorker:!0,readLock:r=>makeWorkerLockRequest(r,WORKER_REQUEST_READ_LOCK,MASTER_GRANT_READ_LOCK,WORKER_RELEASE_READ_LOCK),writeLock:r=>makeWorkerLockRequest(r,WORKER_REQUEST_WRITE_LOCK,MASTER_GRANT_WRITE_LOCK,WORKER_RELEASE_WRITE_LOCK)}},mutexes={};let implementation;async function createReleaseable(e,t){let r;const n=new Promise(o=>{r=o});return e.add(async()=>await pTimeout((async()=>await new Promise(o=>{r(()=>{o()})}))(),{milliseconds:t.timeout})),await n}const createMutex=(e,t)=>{if(implementation.isWorker===!0)return{readLock:implementation.readLock(e,t),writeLock:implementation.writeLock(e,t)};const r=new PQueue({concurrency:1});let n;return{async readLock(){if(n!=null)return await createReleaseable(n,t);n=new PQueue({concurrency:t.concurrency,autoStart:!1});const o=n,a=createReleaseable(n,t);return r.add(async()=>(o.start(),await o.onIdle().then(()=>{n===o&&(n=null)}))),await a},async writeLock(){return n=null,await createReleaseable(r,t)}}},defaultOptions$4={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function createMortice(e){const t=Object.assign({},defaultOptions$4,e);return implementation==null&&(implementation=impl(t),implementation.isWorker!==!0&&(implementation.addEventListener("requestReadLock",r=>{mutexes[r.data.name]!=null&&mutexes[r.data.name].readLock().then(async n=>await r.data.handler().finally(()=>n()))}),implementation.addEventListener("requestWriteLock",async r=>{mutexes[r.data.name]!=null&&mutexes[r.data.name].writeLock().then(async n=>await r.data.handler().finally(()=>n()))}))),mutexes[t.name]==null&&(mutexes[t.name]=createMutex(t.name,t)),mutexes[t.name]}const codes$1={ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS"};var Peer$1;(function(e){(function(r){let n;r.codec=()=>(n==null&&(n=message((o,a,l={})=>{l.lengthDelimited!==!1&&a.fork(),o.key!=null&&o.key!==""&&(a.uint32(10),a.string(o.key)),o.value!=null&&o.value.byteLength>0&&(a.uint32(18),a.bytes(o.value)),l.lengthDelimited!==!1&&a.ldelim()},(o,a)=>{const l={key:"",value:new Uint8Array(0)},c=a==null?o.len:o.pos+a;for(;o.pos>>3){case 1:l.key=o.string();break;case 2:l.value=o.bytes();break;default:o.skipType(u&7);break}}return l})),n),r.encode=o=>encodeMessage(o,r.codec()),r.decode=o=>decodeMessage(o,r.codec())})(e.Peer$metadataEntry||(e.Peer$metadataEntry={})),function(r){let n;r.codec=()=>(n==null&&(n=message((o,a,l={})=>{l.lengthDelimited!==!1&&a.fork(),o.key!=null&&o.key!==""&&(a.uint32(10),a.string(o.key)),o.value!=null&&(a.uint32(18),Tag.codec().encode(o.value,a)),l.lengthDelimited!==!1&&a.ldelim()},(o,a)=>{const l={key:""},c=a==null?o.len:o.pos+a;for(;o.pos>>3){case 1:l.key=o.string();break;case 2:l.value=Tag.codec().decode(o,o.uint32());break;default:o.skipType(u&7);break}}return l})),n),r.encode=o=>encodeMessage(o,r.codec()),r.decode=o=>decodeMessage(o,r.codec())}(e.Peer$tagsEntry||(e.Peer$tagsEntry={}));let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.addresses!=null)for(const a of r.addresses)n.uint32(10),Address.codec().encode(a,n);if(r.protocols!=null)for(const a of r.protocols)n.uint32(18),n.string(a);if(r.publicKey!=null&&(n.uint32(34),n.bytes(r.publicKey)),r.peerRecordEnvelope!=null&&(n.uint32(42),n.bytes(r.peerRecordEnvelope)),r.metadata!=null&&r.metadata.size!==0)for(const[a,l]of r.metadata.entries())n.uint32(50),e.Peer$metadataEntry.codec().encode({key:a,value:l},n);if(r.tags!=null&&r.tags.size!==0)for(const[a,l]of r.tags.entries())n.uint32(58),e.Peer$tagsEntry.codec().encode({key:a,value:l},n);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={addresses:[],protocols:[],metadata:new Map,tags:new Map},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.addresses.push(Address.codec().decode(r,r.uint32()));break;case 2:o.protocols.push(r.string());break;case 4:o.publicKey=r.bytes();break;case 5:o.peerRecordEnvelope=r.bytes();break;case 6:{const c=e.Peer$metadataEntry.codec().decode(r,r.uint32());o.metadata.set(c.key,c.value);break}case 7:{const c=e.Peer$tagsEntry.codec().decode(r,r.uint32());o.tags.set(c.key,c.value);break}default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Peer$1||(Peer$1={}));var Address;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.multiaddr!=null&&r.multiaddr.byteLength>0&&(n.uint32(10),n.bytes(r.multiaddr)),r.isCertified!=null&&(n.uint32(16),n.bool(r.isCertified)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={multiaddr:new Uint8Array(0)},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.multiaddr=r.bytes();break;case 2:o.isCertified=r.bool();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Address||(Address={}));var Tag;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.value!=null&&r.value!==0&&(n.uint32(8),n.uint32(r.value)),r.expiry!=null&&(n.uint32(16),n.uint64(r.expiry)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={value:0},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.value=r.uint32();break;case 2:o.expiry=r.uint64();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Tag||(Tag={}));function bytesToPeer(e,t){const r=Peer$1.decode(t);r.publicKey!=null&&e.publicKey==null&&(e=peerIdFromPeerId({...e,publicKey:e.publicKey}));const n=new Map,o=BigInt(Date.now());for(const[a,l]of r.tags.entries())l.expiry!=null&&l.expiry({multiaddr:multiaddr(a),isCertified:l??!1})),metadata:r.metadata,peerRecordEnvelope:r.peerRecordEnvelope??void 0,tags:n}}const NAMESPACE_COMMON="/peers/";function peerIdToDatastoreKey(e){if(!isPeerId(e)||e.type==null)throw new CodeError("Invalid PeerId",codes$1.ERR_INVALID_PARAMETERS);const t=e.toCID().toString();return new Key(`${NAMESPACE_COMMON}${t}`)}async function dedupeFilterAndSortAddresses(e,t,r){const n=new Map;for(const o of r){if(o==null)continue;if(o.multiaddr instanceof Uint8Array&&(o.multiaddr=multiaddr(o.multiaddr)),!isMultiaddr(o.multiaddr))throw new CodeError("Multiaddr was invalid",codes$1.ERR_INVALID_PARAMETERS);if(!await t(e,o.multiaddr))continue;const a=o.isCertified??!1,l=o.multiaddr.toString(),c=n.get(l);c!=null?o.isCertified=c.isCertified||a:n.set(l,{multiaddr:o.multiaddr,isCertified:a})}return[...n.values()].sort((o,a)=>o.multiaddr.toString().localeCompare(a.multiaddr.toString())).map(({isCertified:o,multiaddr:a})=>({isCertified:o,multiaddr:a.bytes}))}async function toPeerPB(e,t,r,n){if(t==null)throw new CodeError("Invalid PeerData",codes$1.ERR_INVALID_PARAMETERS);if(t.publicKey!=null&&e.publicKey!=null&&!equals$2(t.publicKey,e.publicKey))throw new CodeError("publicKey bytes do not match peer id publicKey bytes",codes$1.ERR_INVALID_PARAMETERS);const o=n.existingPeer;if(o!=null&&!e.equals(o.id))throw new CodeError("peer id did not match existing peer id",codes$1.ERR_INVALID_PARAMETERS);let a=o?.addresses??[],l=new Set(o?.protocols??[]),c=o?.metadata??new Map,u=o?.tags??new Map,g=o?.peerRecordEnvelope;if(r==="patch"){if((t.multiaddrs!=null||t.addresses!=null)&&(a=[],t.multiaddrs!=null&&a.push(...t.multiaddrs.map(x=>({isCertified:!1,multiaddr:x}))),t.addresses!=null&&a.push(...t.addresses)),t.protocols!=null&&(l=new Set(t.protocols)),t.metadata!=null){const x=t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata);c=createSortedMap(x,{validate:validateMetadata})}if(t.tags!=null){const x=t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags);u=createSortedMap(x,{validate:validateTag,map:mapTag})}t.peerRecordEnvelope!=null&&(g=t.peerRecordEnvelope)}if(r==="merge"){if(t.multiaddrs!=null&&a.push(...t.multiaddrs.map(x=>({isCertified:!1,multiaddr:x}))),t.addresses!=null&&a.push(...t.addresses),t.protocols!=null&&(l=new Set([...l,...t.protocols])),t.metadata!=null){const x=t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata);for(const[S,$]of x)$==null?c.delete(S):c.set(S,$);c=createSortedMap([...c.entries()],{validate:validateMetadata})}if(t.tags!=null){const x=t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags),S=new Map(u);for(const[$,k]of x)k==null?S.delete($):S.set($,k);u=createSortedMap([...S.entries()],{validate:validateTag,map:mapTag})}t.peerRecordEnvelope!=null&&(g=t.peerRecordEnvelope)}const b={addresses:await dedupeFilterAndSortAddresses(e,n.addressFilter??(async()=>!0),a),protocols:[...l.values()].sort((x,S)=>x.localeCompare(S)),metadata:c,tags:u,publicKey:o?.id.publicKey??t.publicKey??e.publicKey,peerRecordEnvelope:g};return e.type!=="RSA"&&delete b.publicKey,b}function createSortedMap(e,t){const r=new Map;for(const[n,o]of e)o!=null&&t.validate(n,o);for(const[n,o]of e.sort(([a],[l])=>a.localeCompare(l)))o!=null&&r.set(n,t.map?.(n,o)??o);return r}function validateMetadata(e,t){if(typeof e!="string")throw new CodeError("Metadata key must be a string",codes$1.ERR_INVALID_PARAMETERS);if(!(t instanceof Uint8Array))throw new CodeError("Metadata value must be a Uint8Array",codes$1.ERR_INVALID_PARAMETERS)}function validateTag(e,t){if(typeof e!="string")throw new CodeError("Tag name must be a string",codes$1.ERR_INVALID_PARAMETERS);if(t.value!=null){if(parseInt(`${t.value}`,10)!==t.value)throw new CodeError("Tag value must be an integer",codes$1.ERR_INVALID_PARAMETERS);if(t.value<0||t.value>100)throw new CodeError("Tag value must be between 0-100",codes$1.ERR_INVALID_PARAMETERS)}if(t.ttl!=null){if(parseInt(`${t.ttl}`,10)!==t.ttl)throw new CodeError("Tag ttl must be an integer",codes$1.ERR_INVALID_PARAMETERS);if(t.ttl<0)throw new CodeError("Tag ttl must be between greater than 0",codes$1.ERR_INVALID_PARAMETERS)}}function mapTag(e,t){let r;return t.expiry!=null&&(r=t.expiry),t.ttl!=null&&(r=BigInt(Date.now()+Number(t.ttl))),{value:t.value??0,expiry:r}}function decodePeer(e,t,r){const n=e.toString().split("/")[2],o=base32$2.decode(n),a=peerIdFromBytes(o),l=r.get(a);if(l!=null)return l;const c=bytesToPeer(a,t);return r.set(a,c),c}function mapQuery(e,t){return e==null?{}:{prefix:NAMESPACE_COMMON,filters:(e.filters??[]).map(r=>({key:n,value:o})=>r(decodePeer(n,o,t))),orders:(e.orders??[]).map(r=>(n,o)=>r(decodePeer(n.key,n.value,t),decodePeer(o.key,o.value,t)))}}var Oi,po,Di,go;class PersistentStore{constructor(t,r={}){Er(this,Oi);Er(this,Di);Xe(this,"peerId");Xe(this,"datastore");Xe(this,"lock");Xe(this,"addressFilter");this.peerId=t.peerId,this.datastore=t.datastore,this.addressFilter=r.addressFilter,this.lock=createMortice({name:"peer-store",singleProcess:!0})}async has(t){return this.datastore.has(peerIdToDatastoreKey(t))}async delete(t){if(this.peerId.equals(t))throw new CodeError("Cannot delete self peer",codes$1.ERR_INVALID_PARAMETERS);await this.datastore.delete(peerIdToDatastoreKey(t))}async load(t){const r=await this.datastore.get(peerIdToDatastoreKey(t));return bytesToPeer(t,r)}async save(t,r){const{existingBuf:n,existingPeer:o}=await xr(this,Oi,po).call(this,t),a=await toPeerPB(t,r,"patch",{addressFilter:this.addressFilter});return xr(this,Di,go).call(this,t,a,n,o)}async patch(t,r){const{existingBuf:n,existingPeer:o}=await xr(this,Oi,po).call(this,t),a=await toPeerPB(t,r,"patch",{addressFilter:this.addressFilter,existingPeer:o});return xr(this,Di,go).call(this,t,a,n,o)}async merge(t,r){const{existingBuf:n,existingPeer:o}=await xr(this,Oi,po).call(this,t),a=await toPeerPB(t,r,"merge",{addressFilter:this.addressFilter,existingPeer:o});return xr(this,Di,go).call(this,t,a,n,o)}async*all(t){const r=new PeerMap;for await(const{key:n,value:o}of this.datastore.query(mapQuery(t??{},r))){const a=decodePeer(n,o,r);a.id.equals(this.peerId)||(yield a)}}}Oi=new WeakSet,po=async function(t){try{const r=await this.datastore.get(peerIdToDatastoreKey(t)),n=bytesToPeer(t,r);return{existingBuf:r,existingPeer:n}}catch(r){if(r.code!=="ERR_NOT_FOUND")throw r}return{}},Di=new WeakSet,go=async function(t,r,n,o){const a=Peer$1.encode(r);return n!=null&&equals$2(a,n)?{peer:bytesToPeer(t,a),previous:o,updated:!1}:(await this.datastore.put(peerIdToDatastoreKey(t),a),{peer:bytesToPeer(t,a),previous:o,updated:!0})};const log$o=logger("libp2p:peer-store");var Ni,yo;class PersistentPeerStore{constructor(t,r={}){Er(this,Ni);Xe(this,"store");Xe(this,"events");Xe(this,"peerId");this.events=t.events,this.peerId=t.peerId,this.store=new PersistentStore(t,r)}async forEach(t,r){log$o.trace("forEach await read lock");const n=await this.store.lock.readLock();log$o.trace("forEach got read lock");try{for await(const o of this.store.all(r))t(o)}finally{log$o.trace("forEach release read lock"),n()}}async all(t){log$o.trace("all await read lock");const r=await this.store.lock.readLock();log$o.trace("all got read lock");try{return await all(this.store.all(t))}finally{log$o.trace("all release read lock"),r()}}async delete(t){log$o.trace("delete await write lock");const r=await this.store.lock.writeLock();log$o.trace("delete got write lock");try{await this.store.delete(t)}finally{log$o.trace("delete release write lock"),r()}}async has(t){log$o.trace("has await read lock");const r=await this.store.lock.readLock();log$o.trace("has got read lock");try{return await this.store.has(t)}finally{log$o.trace("has release read lock"),r()}}async get(t){log$o.trace("get await read lock");const r=await this.store.lock.readLock();log$o.trace("get got read lock");try{return await this.store.load(t)}finally{log$o.trace("get release read lock"),r()}}async save(t,r){log$o.trace("save await write lock");const n=await this.store.lock.writeLock();log$o.trace("save got write lock");try{const o=await this.store.save(t,r);return xr(this,Ni,yo).call(this,t,o),o.peer}finally{log$o.trace("save release write lock"),n()}}async patch(t,r){log$o.trace("patch await write lock");const n=await this.store.lock.writeLock();log$o.trace("patch got write lock");try{const o=await this.store.patch(t,r);return xr(this,Ni,yo).call(this,t,o),o.peer}finally{log$o.trace("patch release write lock"),n()}}async merge(t,r){log$o.trace("merge await write lock");const n=await this.store.lock.writeLock();log$o.trace("merge got write lock");try{const o=await this.store.merge(t,r);return xr(this,Ni,yo).call(this,t,o),o.peer}finally{log$o.trace("merge release write lock"),n()}}async consumePeerRecord(t,r){const n=await RecordEnvelope.openAndCertify(t,PeerRecord.DOMAIN);if(r?.equals(n.peerId)===!1)return log$o("envelope peer id was not the expected peer id - expected: %p received: %p",r,n.peerId),!1;const o=PeerRecord.createFromProtobuf(n.payload);let a;try{a=await this.get(n.peerId)}catch(l){if(l.code!=="ERR_NOT_FOUND")throw l}if(a?.peerRecordEnvelope!=null){const l=await RecordEnvelope.createFromProtobuf(a.peerRecordEnvelope),c=PeerRecord.createFromProtobuf(l.payload);if(c.seqNumber>=o.seqNumber)return log$o("sequence number was lower or equal to existing sequence number - stored: %d received: %d",c.seqNumber,o.seqNumber),!1}return await this.patch(o.peerId,{peerRecordEnvelope:t,addresses:o.multiaddrs.map(l=>({isCertified:!0,multiaddr:l}))}),!0}}Ni=new WeakSet,yo=function(t,r){!r.updated||(this.peerId.equals(t)?this.events.safeDispatchEvent("self:peer:update",{detail:r}):this.events.safeDispatchEvent("peer:update",{detail:r}))};function isAsyncIterable$5(e){return e[Symbol.asyncIterator]!=null}function drain(e){if(isAsyncIterable$5(e))return(async()=>{for await(const t of e);})();for(const t of e);}function peekable(e){const[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}function isAsyncIterable$4(e){return e[Symbol.asyncIterator]!=null}function filter(e,t){if(isAsyncIterable$4(e))return async function*(){for await(const c of e)await t(c)&&(yield c)}();const r=peekable(e),{value:n,done:o}=r.next();if(o===!0)return function*(){}();const a=t(n);if(typeof a.then=="function")return async function*(){await a&&(yield n);for await(const c of r)await t(c)&&(yield c)}();const l=t;return function*(){a===!0&&(yield n);for(const c of r)l(c)&&(yield c)}()}function isAsyncIterable$3(e){return e[Symbol.asyncIterator]!=null}function sort(e,t){return isAsyncIterable$3(e)?async function*(){yield*(await all(e)).sort(t)}():function*(){yield*all(e).sort(t)}()}function isAsyncIterable$2(e){return e[Symbol.asyncIterator]!=null}function take(e,t){return isAsyncIterable$2(e)?async function*(){let r=0;if(!(t<1)){for await(const n of e)if(yield n,r++,r===t)return}}():function*(){let r=0;if(!(t<1)){for(const n of e)if(yield n,r++,r===t)return}}()}class BaseDatastore{put(t,r,n){return Promise.reject(new Error(".put is not implemented"))}get(t,r){return Promise.reject(new Error(".get is not implemented"))}has(t,r){return Promise.reject(new Error(".has is not implemented"))}delete(t,r){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(t,r={}){for await(const{key:n,value:o}of t)await this.put(n,o,r),yield n}async*getMany(t,r={}){for await(const n of t)yield{key:n,value:await this.get(n,r)}}async*deleteMany(t,r={}){for await(const n of t)await this.delete(n,r),yield n}batch(){let t=[],r=[];return{put(n,o){t.push({key:n,value:o})},delete(n){r.push(n)},commit:async n=>{await drain(this.putMany(t,n)),t=[],await drain(this.deleteMany(r,n)),r=[]}}}async*_all(t,r){throw new Error("._all is not implemented")}async*_allKeys(t,r){throw new Error("._allKeys is not implemented")}query(t,r){let n=this._all(t,r);if(t.prefix!=null){const o=t.prefix;n=filter(n,a=>a.key.toString().startsWith(o))}if(Array.isArray(t.filters)&&(n=t.filters.reduce((o,a)=>filter(o,a),n)),Array.isArray(t.orders)&&(n=t.orders.reduce((o,a)=>sort(o,a),n)),t.offset!=null){let o=0;const a=t.offset;n=filter(n,()=>o++>=a)}return t.limit!=null&&(n=take(n,t.limit)),n}queryKeys(t,r){let n=this._allKeys(t,r);if(t.prefix!=null){const o=t.prefix;n=filter(n,a=>a.toString().startsWith(o))}if(Array.isArray(t.filters)&&(n=t.filters.reduce((o,a)=>filter(o,a),n)),Array.isArray(t.orders)&&(n=t.orders.reduce((o,a)=>sort(o,a),n)),t.offset!=null){const o=t.offset;let a=0;n=filter(n,()=>a++>=o)}return t.limit!=null&&(n=take(n,t.limit)),n}}function notFoundError(e){return e=e??new Error("Not Found"),errCode(e,"ERR_NOT_FOUND")}class MemoryDatastore extends BaseDatastore{constructor(){super();Xe(this,"data");this.data=new Map}put(r,n){return this.data.set(r.toString(),n),r}get(r){const n=this.data.get(r.toString());if(n==null)throw notFoundError();return n}has(r){return this.data.has(r.toString())}delete(r){this.data.delete(r.toString())}*_all(){for(const[r,n]of this.data.entries())yield{key:new Key(r),value:n}}*_allKeys(){for(const r of this.data.keys())yield new Key(r)}}function debounce(e,t){let r;return function(){const n=function(){r=void 0,e()};clearTimeout(r),r=setTimeout(n,t)}}const log$n=logger("libp2p:address-manager"),defaultAddressFilter=e=>e;function stripPeerId(e,t){const r=e.getPeerId();return r!=null&&peerIdFromString(r).equals(t)&&(e=e.decapsulate(multiaddr(`/p2p/${t.toString()}`))),e}class DefaultAddressManager{constructor(t,r={}){Xe(this,"components");Xe(this,"listen");Xe(this,"announce");Xe(this,"observed");Xe(this,"announceFilter");const{listen:n=[],announce:o=[]}=r;this.components=t,this.listen=n.map(a=>a.toString()),this.announce=new Set(o.map(a=>a.toString())),this.observed=new Map,this.announceFilter=r.announceFilter??defaultAddressFilter,this._updatePeerStoreAddresses=debounce(this._updatePeerStoreAddresses.bind(this),1e3),t.events.addEventListener("transport:listening",()=>{this._updatePeerStoreAddresses()}),t.events.addEventListener("transport:close",()=>{this._updatePeerStoreAddresses()})}_updatePeerStoreAddresses(){const t=this.getAnnounceAddrs().concat(this.components.transportManager.getAddrs()).concat([...this.observed.entries()].filter(([r,n])=>n.confident).map(([r])=>multiaddr(r))).map(r=>r.getPeerId()===this.components.peerId.toString()?r.decapsulate(`/p2p/${this.components.peerId.toString()}`):r);this.components.peerStore.patch(this.components.peerId,{multiaddrs:t}).catch(r=>{log$n.error("error updating addresses",r)})}getListenAddrs(){return Array.from(this.listen).map(t=>multiaddr(t))}getAnnounceAddrs(){return Array.from(this.announce).map(t=>multiaddr(t))}getObservedAddrs(){return Array.from(this.observed).map(([t])=>multiaddr(t))}addObservedAddr(t){t=stripPeerId(t,this.components.peerId);const r=t.toString();this.observed.has(r)||this.observed.set(r,{confident:!1})}confirmObservedAddr(t){t=stripPeerId(t,this.components.peerId);const r=t.toString(),o=(this.observed.get(r)??{confident:!1}).confident;this.observed.set(r,{confident:!0}),o||this._updatePeerStoreAddresses()}removeObservedAddr(t){t=stripPeerId(t,this.components.peerId);const r=t.toString();this.observed.delete(r)}getAddresses(){let t=this.getAnnounceAddrs().map(n=>n.toString());t.length===0&&(t=this.components.transportManager.getAddrs().map(n=>n.toString())),t=t.concat(Array.from(this.observed).filter(([n,o])=>o.confident).map(([n])=>n));const r=new Set(t);return this.announceFilter(Array.from(r).map(n=>multiaddr(n))).map(n=>n.protos().pop()?.path===!0||n.getPeerId()===this.components.peerId.toString()?n:n.encapsulate(`/p2p/${this.components.peerId.toString()}`))}}function isStartable(e){return e!=null&&typeof e.start=="function"&&typeof e.stop=="function"}class DefaultComponents{constructor(t={}){Xe(this,"components",{});Xe(this,"_started",!1);this.components={};for(const[r,n]of Object.entries(t))this.components[r]=n}isStarted(){return this._started}async _invokeStartableMethod(t){await Promise.all(Object.values(this.components).filter(r=>isStartable(r)).map(async r=>{await r[t]?.()}))}async beforeStart(){await this._invokeStartableMethod("beforeStart")}async start(){await this._invokeStartableMethod("start"),this._started=!0}async afterStart(){await this._invokeStartableMethod("afterStart")}async beforeStop(){await this._invokeStartableMethod("beforeStop")}async stop(){await this._invokeStartableMethod("stop"),this._started=!1}async afterStop(){await this._invokeStartableMethod("afterStop")}}const OPTIONAL_SERVICES=["metrics","connectionProtector"],NON_SERVICE_PROPERTIES=["components","isStarted","beforeStart","start","afterStart","beforeStop","stop","afterStop","then","_invokeStartableMethod"];function defaultComponents(e={}){const t=new DefaultComponents(e);return new Proxy(t,{get(n,o,a){if(typeof o=="string"&&!NON_SERVICE_PROPERTIES.includes(o)){const l=t.components[o];if(l==null&&!OPTIONAL_SERVICES.includes(o))throw new CodeError(`${o} not set`,"ERR_SERVICE_MISSING");return l}return Reflect.get(n,o,a)},set(n,o,a){return typeof o=="string"?t.components[o]=a:Reflect.set(n,o,a),!0}})}var Netmask_1;(function(){var e,t,r,n,o,a,l,c;c=function(u){var g,b,x,S;return g=(u&255<<24)>>>24,b=(u&255<<16)>>>16,x=(u&255<<8)>>>8,S=u&255,[g,b,x,S].join(".")},l=function(u){var g,b,x,S,$,k;for(g=[],x=S=0;S<=3&&u.length!==0;x=++S){if(x>0){if(u[0]!==".")throw new Error("Invalid IP");u=u.substring(1)}k=t(u),$=k[0],b=k[1],u=u.substring(b),g.push($)}if(u.length!==0)throw new Error("Invalid IP");switch(g.length){case 1:if(g[0]>4294967295)throw new Error("Invalid IP");return g[0]>>>0;case 2:if(g[0]>255||g[1]>16777215)throw new Error("Invalid IP");return(g[0]<<24|g[1])>>>0;case 3:if(g[0]>255||g[1]>255||g[2]>65535)throw new Error("Invalid IP");return(g[0]<<24|g[1]<<16|g[2])>>>0;case 4:if(g[0]>255||g[1]>255||g[2]>255||g[3]>255)throw new Error("Invalid IP");return(g[0]<<24|g[1]<<16|g[2]<<8|g[3])>>>0;default:throw new Error("Invalid IP")}},r=function(u){return u.charCodeAt(0)},n=r("0"),a=r("a"),o=r("A"),t=function(u){var g,b,x,S,$;for(S=0,g=10,b="9",x=0,u.length>1&&u[x]==="0"&&(u[x+1]==="x"||u[x+1]==="X"?(x+=2,g=16):"0"<=u[x+1]&&u[x+1]<="9"&&(x++,g=8,b="7")),$=x;x>>0;else if(g===16)if("a"<=u[x]&&u[x]<="f")S=S*g+(10+r(u[x])-a)>>>0;else if("A"<=u[x]&&u[x]<="F")S=S*g+(10+r(u[x])-o)>>>0;else break;else break;if(S>4294967295)throw new Error("too large");x++}if(x===$)throw new Error("empty octet");return[S,x]},e=function(){function u(g,b){var x,S,$;if(typeof g!="string")throw new Error("Missing `net' parameter");if(b||($=g.split("/",2),g=$[0],b=$[1]),b||(b=32),typeof b=="string"&&b.indexOf(".")>-1){try{this.maskLong=l(b)}catch{throw new Error("Invalid mask: "+b)}for(x=S=32;S>=0;x=--S)if(this.maskLong===4294967295<<32-x>>>0){this.bitmask=x;break}}else if(b||b===0)this.bitmask=parseInt(b,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(l(g)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+g)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+b);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return u.prototype.contains=function(g){return typeof g=="string"&&(g.indexOf("/")>0||g.split(".").length!==4)&&(g=new u(g)),g instanceof u?this.contains(g.base)&&this.contains(g.broadcast||g.last):(l(g)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},u.prototype.next=function(g){return g==null&&(g=1),new u(c(this.netLong+this.size*g),this.mask)},u.prototype.forEach=function(g){var b,x,S;for(S=l(this.first),x=l(this.last),b=0;S<=x;)g(c(S),S,b),b++,S++},u.prototype.toString=function(){return this.base+"/"+this.bitmask},u}(),Netmask_1=e}).call(commonjsGlobal$2);const word="[a-fA-F\\d:]",boundry=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))`:"",v4="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",v6segment="[a-fA-F\\d]{1,4}",v6=` +`).filter(n=>n.startsWith("a=candidate")).pop(),r=t?.split(" ");return t==null||r==null||r.length<5?(log$t("could not parse remote address from",t),"/webrtc"):`/dnsaddr/${r[4]}/${r[2].toLowerCase()}/${r[5]}/webrtc`}class WebRTCPeerListener extends EventEmitter$2{constructor(r){super();Xe(this,"peerId");Xe(this,"transportManager");this.peerId=r.peerId,this.transportManager=r.transportManager}async listen(){this.safeDispatchEvent("listening",{})}getAddrs(){return this.transportManager.getListeners().filter(r=>r!==this).map(r=>r.getAddrs().filter(n=>Circuit$1.matches(n)).map(n=>n.encapsulate(`/webrtc/p2p/${this.peerId}`))).flat()}async close(){this.safeDispatchEvent("close",{})}}const log$s=logger("libp2p:webrtc:peer"),WEBRTC_TRANSPORT="/webrtc",CIRCUIT_RELAY_TRANSPORT="/p2p-circuit",SIGNALING_PROTO_ID="/webrtc-signaling/0.0.1",WEBRTC_CODE=getProtocol("webrtc").code;var ec,tc;class WebRTCTransport{constructor(t,r={}){Xe(this,"components");Xe(this,"init");Xe(this,"_started",!1);Xe(this,"metrics");Xe(this,ec,"@libp2p/webrtc");Xe(this,tc,!0);this.components=t,this.init=r,t.metrics!=null&&(this.metrics={dialerEvents:t.metrics.registerCounterGroup("libp2p_webrtc_dialer_events_total",{label:"event",help:"Total count of WebRTC dialer events by type"}),listenerEvents:t.metrics.registerCounterGroup("libp2p_webrtc_listener_events_total",{label:"event",help:"Total count of WebRTC listener events by type"})})}isStarted(){return this._started}async start(){await this.components.registrar.handle(SIGNALING_PROTO_ID,t=>{this._onProtocol(t).catch(r=>{log$s.error("failed to handle incoming connect from %p",t.connection.remotePeer,r)})},{runOnTransientConnection:!0}),this._started=!0}async stop(){await this.components.registrar.unhandle(SIGNALING_PROTO_ID),this._started=!1}createListener(t){return new WebRTCPeerListener(this.components)}filter(t){return t.filter(r=>r.protoCodes().includes(WEBRTC_CODE))}async dial(t,r){log$s.trace("dialing address: ",t);const{baseAddr:n,peerId:o}=splitAddr(t);if(r.signal==null){const c=new AbortController;r.signal=c.signal}this.metrics?.dialerEvents.increment({open:!0});const a=await this.components.transportManager.dial(n,r),l=await a.newStream(SIGNALING_PROTO_ID,{...r,runOnTransientConnection:!0});try{const{pc:c,muxerFactory:u,remoteAddress:g}=await initiateConnection({stream:l,rtcConfiguration:this.init.rtcConfiguration,dataChannelOptions:this.init.dataChannel,signal:r.signal}),b=await r.upgrader.upgradeOutbound(new WebRTCMultiaddrConnection({peerConnection:c,timeline:{open:Date.now()},remoteAddr:multiaddr(g).encapsulate(`/p2p/${o.toString()}`),metrics:this.metrics?.dialerEvents}),{skipProtection:!0,skipEncryption:!0,muxerFactory:u});return await l.close(),b}catch(c){throw this.metrics?.dialerEvents.increment({error:!0}),l.abort(c),c}finally{await a.close()}}async _onProtocol({connection:t,stream:r}){try{const{pc:n,muxerFactory:o,remoteAddress:a}=await handleIncomingStream({rtcConfiguration:this.init.rtcConfiguration,connection:t,stream:r,dataChannelOptions:this.init.dataChannel});await this.components.upgrader.upgradeInbound(new WebRTCMultiaddrConnection({peerConnection:n,timeline:{open:new Date().getTime()},remoteAddr:multiaddr(a).encapsulate(`/p2p/${t.remotePeer.toString()}`),metrics:this.metrics?.listenerEvents}),{skipEncryption:!0,skipProtection:!0,muxerFactory:o})}catch(n){throw r.abort(n),n}finally{await t.close()}}}ec=Symbol.toStringTag,tc=symbol$1;function splitAddr(e){const t=e.toString().split(WEBRTC_TRANSPORT+"/");if(t.length!==2)throw new CodeError("webrtc protocol was not present in multiaddr",codes$6.ERR_INVALID_MULTIADDR);if(!t[0].includes(CIRCUIT_RELAY_TRANSPORT))throw new CodeError("p2p-circuit protocol was not present in multiaddr",codes$6.ERR_INVALID_MULTIADDR);let r=multiaddr(t[0]);const o=multiaddr("/"+t[1]).getPeerId();if(o==null)throw new CodeError("destination peer id was missing",codes$6.ERR_INVALID_MULTIADDR);const a=r.protos().pop();if(a===void 0)throw new CodeError("invalid multiaddr",codes$6.ERR_INVALID_MULTIADDR);return a.name!=="p2p"&&(r=r.encapsulate(`/p2p/${o}`)),{baseAddr:r,peerId:peerIdFromString(o)}}var src$2={exports:{}};function base$2(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,N=new Uint8Array(O);D!==I;){for(var ee=$[D],ne=0,B=O-1;(ee!==0||ne>>0,N[B]=ee%l>>>0,ee=ee/l>>>0;if(ee!==0)throw new Error("Non-zero carry");T=ne,D++}for(var le=O-T;le!==O&&N[le]===0;)le++;for(var fe=c.repeat(k);le>>0,O=new Uint8Array(I);$[k];){var N=t[$.charCodeAt(k)];if(N===255)return;for(var ee=0,ne=I-1;(N!==0||ee>>0,O[ne]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");D=ee,k++}if($[k]!==" "){for(var B=I-D;B!==I&&O[B]===0;)B++;for(var le=new Uint8Array(T+(I-B)),fe=T;B!==I;)le[fe++]=O[B++];return le}}}function S($){var k=x($);if(k)return k;throw new Error("Non-base"+l+" character")}return{encode:b,decodeUnsafe:x,decode:S}}var src$1=base$2;const textDecoder=new TextDecoder,decodeText$1=e=>textDecoder.decode(e),textEncoder=new TextEncoder,encodeText$2=e=>textEncoder.encode(e);function concat(e,t){const r=new Uint8Array(t);let n=0;for(const o of e)r.set(o,n),n+=o.length;return r}var util={decodeText:decodeText$1,encodeText:encodeText$2,concat};const{encodeText:encodeText$1}=util;class Base$1{constructor(t,r,n,o){this.name=t,this.code=r,this.codeBuf=encodeText$1(this.code),this.alphabet=o,this.codec=n(o)}encode(t){return this.codec.encode(t)}decode(t){for(const r of t)if(this.alphabet&&this.alphabet.indexOf(r)<0)throw new Error(`invalid character '${r}' in '${t}'`);return this.codec.decode(t)}}var base$1=Base$1;const decode$4=(e,t,r)=>{const n={};for(let g=0;g=8&&(l-=8,a[u++]=255&c>>l)}if(l>=r||255&c<<8-l)throw new SyntaxError("Unexpected end of data");return a},encode$6=(e,t,r)=>{const n=t[t.length-1]==="=",o=(1<r;)l-=r,a+=t[o&c>>l];if(l&&(a+=t[o&c<t=>({encode(r){return encode$6(r,t,e)},decode(r){return decode$4(r,t,e)}});var rfc4648_1={rfc4648:rfc4648$2};const baseX$1=src$1,Base=base$1,{rfc4648:rfc4648$1}=rfc4648_1,{decodeText,encodeText}=util,identity$3=()=>({encode:decodeText,decode:encodeText}),constants$1=[["identity","\0",identity$3,""],["base2","0",rfc4648$1(1),"01"],["base8","7",rfc4648$1(3),"01234567"],["base10","9",baseX$1,"0123456789"],["base16","f",rfc4648$1(4),"0123456789abcdef"],["base16upper","F",rfc4648$1(4),"0123456789ABCDEF"],["base32hex","v",rfc4648$1(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",rfc4648$1(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",rfc4648$1(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",rfc4648$1(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",rfc4648$1(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",rfc4648$1(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",rfc4648$1(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",rfc4648$1(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",rfc4648$1(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",baseX$1,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",baseX$1,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",baseX$1,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",baseX$1,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",rfc4648$1(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",rfc4648$1(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",rfc4648$1(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",rfc4648$1(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],names$2=constants$1.reduce((e,t)=>(e[t[0]]=new Base(t[0],t[1],t[2],t[3]),e),{}),codes$5=constants$1.reduce((e,t)=>(e[t[1]]=names$2[t[0]],e),{});var constants_1={names:names$2,codes:codes$5};(function(e,t){const r=constants_1,{encodeText:n,decodeText:o,concat:a}=util;function l(T,D){if(!D)throw new Error("requires an encoded Uint8Array");const{name:I,codeBuf:O}=x(T);return b(I,D),a([O,D],O.length+D.length)}function c(T,D){const I=x(T),O=n(I.encode(D));return a([I.codeBuf,O],I.codeBuf.length+O.length)}function u(T){T instanceof Uint8Array&&(T=o(T));const D=T[0];return["f","F","v","V","t","T","b","B","c","C","h","k","K"].includes(D)&&(T=T.toLowerCase()),x(T[0]).decode(T.substring(1))}function g(T){if(T instanceof Uint8Array&&(T=o(T)),Object.prototype.toString.call(T)!=="[object String]")return!1;try{return x(T[0]).name}catch{return!1}}function b(T,D){x(T).decode(o(D))}function x(T){if(Object.prototype.hasOwnProperty.call(r.names,T))return r.names[T];if(Object.prototype.hasOwnProperty.call(r.codes,T))return r.codes[T];throw new Error(`Unsupported encoding: ${T}`)}function S(T){return T instanceof Uint8Array&&(T=o(T)),x(T[0])}t=e.exports=l,t.encode=c,t.decode=u,t.isEncoded=g,t.encoding=x,t.encodingFromData=S;const $=Object.freeze(r.names),k=Object.freeze(r.codes);t.names=$,t.codes=k})(src$2,src$2.exports);const names$1=Object.freeze({identity:0,sha1:17,"sha2-256":18,"sha2-512":19,"sha3-512":20,"sha3-384":21,"sha3-256":22,"sha3-224":23,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,blake3:30,"murmur3-128":34,"murmur3-32":35,"dbl-sha2-256":86,md4:212,md5:213,bmt:214,"sha2-256-trunc254-padded":4114,"ripemd-128":4178,"ripemd-160":4179,"ripemd-256":4180,"ripemd-320":4181,x11:4352,kangarootwelve:7425,"sm3-256":21325,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"skein256-8":45825,"skein256-16":45826,"skein256-24":45827,"skein256-32":45828,"skein256-40":45829,"skein256-48":45830,"skein256-56":45831,"skein256-64":45832,"skein256-72":45833,"skein256-80":45834,"skein256-88":45835,"skein256-96":45836,"skein256-104":45837,"skein256-112":45838,"skein256-120":45839,"skein256-128":45840,"skein256-136":45841,"skein256-144":45842,"skein256-152":45843,"skein256-160":45844,"skein256-168":45845,"skein256-176":45846,"skein256-184":45847,"skein256-192":45848,"skein256-200":45849,"skein256-208":45850,"skein256-216":45851,"skein256-224":45852,"skein256-232":45853,"skein256-240":45854,"skein256-248":45855,"skein256-256":45856,"skein512-8":45857,"skein512-16":45858,"skein512-24":45859,"skein512-32":45860,"skein512-40":45861,"skein512-48":45862,"skein512-56":45863,"skein512-64":45864,"skein512-72":45865,"skein512-80":45866,"skein512-88":45867,"skein512-96":45868,"skein512-104":45869,"skein512-112":45870,"skein512-120":45871,"skein512-128":45872,"skein512-136":45873,"skein512-144":45874,"skein512-152":45875,"skein512-160":45876,"skein512-168":45877,"skein512-176":45878,"skein512-184":45879,"skein512-192":45880,"skein512-200":45881,"skein512-208":45882,"skein512-216":45883,"skein512-224":45884,"skein512-232":45885,"skein512-240":45886,"skein512-248":45887,"skein512-256":45888,"skein512-264":45889,"skein512-272":45890,"skein512-280":45891,"skein512-288":45892,"skein512-296":45893,"skein512-304":45894,"skein512-312":45895,"skein512-320":45896,"skein512-328":45897,"skein512-336":45898,"skein512-344":45899,"skein512-352":45900,"skein512-360":45901,"skein512-368":45902,"skein512-376":45903,"skein512-384":45904,"skein512-392":45905,"skein512-400":45906,"skein512-408":45907,"skein512-416":45908,"skein512-424":45909,"skein512-432":45910,"skein512-440":45911,"skein512-448":45912,"skein512-456":45913,"skein512-464":45914,"skein512-472":45915,"skein512-480":45916,"skein512-488":45917,"skein512-496":45918,"skein512-504":45919,"skein512-512":45920,"skein1024-8":45921,"skein1024-16":45922,"skein1024-24":45923,"skein1024-32":45924,"skein1024-40":45925,"skein1024-48":45926,"skein1024-56":45927,"skein1024-64":45928,"skein1024-72":45929,"skein1024-80":45930,"skein1024-88":45931,"skein1024-96":45932,"skein1024-104":45933,"skein1024-112":45934,"skein1024-120":45935,"skein1024-128":45936,"skein1024-136":45937,"skein1024-144":45938,"skein1024-152":45939,"skein1024-160":45940,"skein1024-168":45941,"skein1024-176":45942,"skein1024-184":45943,"skein1024-192":45944,"skein1024-200":45945,"skein1024-208":45946,"skein1024-216":45947,"skein1024-224":45948,"skein1024-232":45949,"skein1024-240":45950,"skein1024-248":45951,"skein1024-256":45952,"skein1024-264":45953,"skein1024-272":45954,"skein1024-280":45955,"skein1024-288":45956,"skein1024-296":45957,"skein1024-304":45958,"skein1024-312":45959,"skein1024-320":45960,"skein1024-328":45961,"skein1024-336":45962,"skein1024-344":45963,"skein1024-352":45964,"skein1024-360":45965,"skein1024-368":45966,"skein1024-376":45967,"skein1024-384":45968,"skein1024-392":45969,"skein1024-400":45970,"skein1024-408":45971,"skein1024-416":45972,"skein1024-424":45973,"skein1024-432":45974,"skein1024-440":45975,"skein1024-448":45976,"skein1024-456":45977,"skein1024-464":45978,"skein1024-472":45979,"skein1024-480":45980,"skein1024-488":45981,"skein1024-496":45982,"skein1024-504":45983,"skein1024-512":45984,"skein1024-520":45985,"skein1024-528":45986,"skein1024-536":45987,"skein1024-544":45988,"skein1024-552":45989,"skein1024-560":45990,"skein1024-568":45991,"skein1024-576":45992,"skein1024-584":45993,"skein1024-592":45994,"skein1024-600":45995,"skein1024-608":45996,"skein1024-616":45997,"skein1024-624":45998,"skein1024-632":45999,"skein1024-640":46e3,"skein1024-648":46001,"skein1024-656":46002,"skein1024-664":46003,"skein1024-672":46004,"skein1024-680":46005,"skein1024-688":46006,"skein1024-696":46007,"skein1024-704":46008,"skein1024-712":46009,"skein1024-720":46010,"skein1024-728":46011,"skein1024-736":46012,"skein1024-744":46013,"skein1024-752":46014,"skein1024-760":46015,"skein1024-768":46016,"skein1024-776":46017,"skein1024-784":46018,"skein1024-792":46019,"skein1024-800":46020,"skein1024-808":46021,"skein1024-816":46022,"skein1024-824":46023,"skein1024-832":46024,"skein1024-840":46025,"skein1024-848":46026,"skein1024-856":46027,"skein1024-864":46028,"skein1024-872":46029,"skein1024-880":46030,"skein1024-888":46031,"skein1024-896":46032,"skein1024-904":46033,"skein1024-912":46034,"skein1024-920":46035,"skein1024-928":46036,"skein1024-936":46037,"skein1024-944":46038,"skein1024-952":46039,"skein1024-960":46040,"skein1024-968":46041,"skein1024-976":46042,"skein1024-984":46043,"skein1024-992":46044,"skein1024-1000":46045,"skein1024-1008":46046,"skein1024-1016":46047,"skein1024-1024":46048,"poseidon-bls12_381-a2-fc1":46081,"poseidon-bls12_381-a2-fc1-sc":46082});var constants={names:names$1};function base(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,ee=new Uint8Array(N);I!==O;){for(var ne=k[I],B=0,le=N-1;(ne!==0||B>>0,ee[le]=ne%c>>>0,ne=ne/c>>>0;if(ne!==0)throw new Error("Non-zero carry");D=B,I++}for(var fe=N-D;fe!==N&&ee[fe]===0;)fe++;for(var xe=u.repeat(T);fe>>0,N=new Uint8Array(O);k[T];){var ee=r[k.charCodeAt(T)];if(ee===255)return;for(var ne=0,B=O-1;(ee!==0||ne>>0,N[B]=ee%256>>>0,ee=ee/256>>>0;if(ee!==0)throw new Error("Non-zero carry");I=ne,T++}if(k[T]!==" "){for(var le=O-I;le!==O&&N[le]===0;)le++;for(var fe=new Uint8Array(D+(O-le)),xe=D;le!==O;)fe[xe++]=N[le++];return fe}}}function $(k){var T=S(k);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:x,decodeUnsafe:S,decode:$}}var src=base,_brrp__multiformats_scope_baseX=src;const coerce$1=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},fromString=e=>new TextEncoder().encode(e),toString$3=e=>new TextDecoder().decode(e);class Encoder{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class Decoder{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return or$1(this,t)}}class ComposedDecoder{constructor(t){this.decoders=t}or(t){return or$1(this,t)}decode(t){const r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const or$1=(e,t)=>new ComposedDecoder({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Codec{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Encoder(t,r,n),this.decoder=new Decoder(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const from$1=({name:e,prefix:t,encode:r,decode:n})=>new Codec(e,t,r,n),baseX=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=_brrp__multiformats_scope_baseX(r,t);return from$1({prefix:e,name:t,encode:n,decode:a=>coerce$1(o(a))})},decode$3=(e,t,r,n)=>{const o={};for(let b=0;b=8&&(c-=8,l[g++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return l},encode$5=(e,t,r)=>{const n=t[t.length-1]==="=",o=(1<r;)l-=r,a+=t[o&c>>l];if(l&&(a+=t[o&c<from$1({prefix:t,name:e,encode(o){return encode$5(o,n,r)},decode(o){return decode$3(o,n,r,e)}}),identity$2=from$1({prefix:"\0",name:"identity",encode:e=>toString$3(e),decode:e=>fromString(e)}),identityBase=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$2},Symbol.toStringTag,{value:"Module"})),base2=rfc4648({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$1=Object.freeze(Object.defineProperty({__proto__:null,base2},Symbol.toStringTag,{value:"Module"})),base8=rfc4648({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$1=Object.freeze(Object.defineProperty({__proto__:null,base8},Symbol.toStringTag,{value:"Module"})),base10=baseX({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$1=Object.freeze(Object.defineProperty({__proto__:null,base10},Symbol.toStringTag,{value:"Module"})),base16=rfc4648({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper=rfc4648({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$1=Object.freeze(Object.defineProperty({__proto__:null,base16,base16upper},Symbol.toStringTag,{value:"Module"})),base32=rfc4648({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper=rfc4648({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad=rfc4648({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper=rfc4648({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex=rfc4648({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper=rfc4648({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad=rfc4648({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper=rfc4648({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z=rfc4648({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$1=Object.freeze(Object.defineProperty({__proto__:null,base32,base32upper,base32pad,base32padupper,base32hex,base32hexupper,base32hexpad,base32hexpadupper,base32z},Symbol.toStringTag,{value:"Module"})),base36=baseX({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper=baseX({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$1=Object.freeze(Object.defineProperty({__proto__:null,base36,base36upper},Symbol.toStringTag,{value:"Module"})),base58btc=baseX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr=baseX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58=Object.freeze(Object.defineProperty({__proto__:null,base58btc,base58flickr},Symbol.toStringTag,{value:"Module"})),base64=rfc4648({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad=rfc4648({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url=rfc4648({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad=rfc4648({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$1=Object.freeze(Object.defineProperty({__proto__:null,base64,base64pad,base64url,base64urlpad},Symbol.toStringTag,{value:"Module"})),alphabet$1=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),alphabetBytesToChars=alphabet$1.reduce((e,t,r)=>(e[r]=t,e),[]),alphabetCharsToBytes=alphabet$1.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function encode$4(e){return e.reduce((t,r)=>(t+=alphabetBytesToChars[r],t),"")}function decode$2(e){const t=[];for(const r of e){const n=alphabetCharsToBytes[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n)}return new Uint8Array(t)}const base256emoji=from$1({prefix:"\u{1F680}",name:"base256emoji",encode:encode$4,decode:decode$2}),base256emoji$1=Object.freeze(Object.defineProperty({__proto__:null,base256emoji},Symbol.toStringTag,{value:"Module"}));var encode_1=encode$3,MSB=128,REST=127,MSBALL=~REST,INT=Math.pow(2,31);function encode$3(e,t,r){t=t||[],r=r||0;for(var n=r;e>=INT;)t[r++]=e&255|MSB,e/=128;for(;e&MSBALL;)t[r++]=e&255|MSB,e>>>=7;return t[r]=e|0,encode$3.bytes=r-n+1,t}var decode$1=read$1,MSB$1=128,REST$1=127;function read$1(e,n){var r=0,n=n||0,o=0,a=n,l,c=e.length;do{if(a>=c)throw read$1.bytes=0,new RangeError("Could not decode varint");l=e[a++],r+=o<28?(l&REST$1)<=MSB$1);return read$1.bytes=a-n,r}var N1=Math.pow(2,7),N2=Math.pow(2,14),N3=Math.pow(2,21),N4=Math.pow(2,28),N5=Math.pow(2,35),N6=Math.pow(2,42),N7=Math.pow(2,49),N8=Math.pow(2,56),N9=Math.pow(2,63),length$1=function(e){return e(_brrp_varint.encode(e,t,r),t),encodingLength=e=>_brrp_varint.encodingLength(e),create=(e,t)=>{const r=t.byteLength,n=encodingLength(e),o=n+encodingLength(r),a=new Uint8Array(o+r);return encodeTo(e,a,0),encodeTo(r,a,n),a.set(t,o),new Digest(e,r,t,a)};class Digest{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}}const from=({name:e,code:t,encode:r})=>new Hasher(e,t,r);class Hasher{constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){const r=this.encode(t);return r instanceof Uint8Array?create(this.code,r):r.then(n=>create(this.code,n))}else throw Error("Unknown type, must be binary type")}}const sha=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),sha256=from({name:"sha2-256",code:18,encode:sha("SHA-256")}),sha512=from({name:"sha2-512",code:19,encode:sha("SHA-512")}),sha2=Object.freeze(Object.defineProperty({__proto__:null,sha256,sha512},Symbol.toStringTag,{value:"Module"})),code$2=0,name="identity",encode$2=coerce$1,digest=e=>create(code$2,encode$2(e)),identity={code:code$2,name,encode:encode$2,digest},identity$1=Object.freeze(Object.defineProperty({__proto__:null,identity},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;({...identityBase,...base2$1,...base8$1,...base10$1,...base16$1,...base32$1,...base36$1,...base58,...base64$1,...base256emoji$1});({...sha2,...identity$1});const{names}=constants,codes$4={};for(const e in names){const t=e;codes$4[names[t]]=t}Object.freeze(codes$4);logger("libp2p:webrtc:sdp");Object.values(bases).map(e=>e.decoder).reduce((e,t)=>e.or(t));Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");logger("libp2p:webrtc:transport");getProtocol("webrtc-direct").code;getProtocol("certhash").code;function webRTC(e){return t=>new WebRTCTransport(t,e)}function extractSNI(e){let t;try{t=getProtocol("sni").code}catch{return null}for(const[r,n]of e)if(r===t&&n!==void 0)return n;return null}function hasTLS(e){return e.some(([t,r])=>t===getProtocol("tls").code)}function interpretNext(e,t,r){const n=interpreters[getProtocol(e).name];if(n===void 0)throw new Error(`Can't interpret protocol ${getProtocol(e).name}`);const o=n(t,r);return e===getProtocol("ip6").code?`[${o}]`:o}const interpreters={ip4:(e,t)=>e,ip6:(e,t)=>t.length===0?e:`[${e}]`,tcp:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`tcp://${interpretNext(r[0],r[1]??"",t)}:${e}`},udp:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`udp://${interpretNext(r[0],r[1]??"",t)}:${e}`},dnsaddr:(e,t)=>e,dns4:(e,t)=>e,dns6:(e,t)=>e,dns:(e,t)=>e,ipfs:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(r[0],r[1]??"",t)}/ipfs/${e}`},p2p:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(r[0],r[1]??"",t)}/p2p/${e}`},http:(e,t)=>{const r=hasTLS(t),n=extractSNI(t);if(r&&n!==null)return`https://${n}`;const o=r?"https://":"http://",a=t.pop();if(a===void 0)throw new Error("Unexpected end of multiaddr");let l=interpretNext(a[0],a[1]??"",t);return l=l.replace("tcp://",""),`${o}${l}`},tls:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return interpretNext(r[0],r[1]??"",t)},sni:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return interpretNext(r[0],r[1]??"",t)},https:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=interpretNext(r[0],r[1]??"",t);return n=n.replace("tcp://",""),`https://${n}`},ws:(e,t)=>{const r=hasTLS(t),n=extractSNI(t);if(r&&n!==null)return`wss://${n}`;const o=r?"wss://":"ws://",a=t.pop();if(a===void 0)throw new Error("Unexpected end of multiaddr");let l=interpretNext(a[0],a[1]??"",t);return l=l.replace("tcp://",""),`${o}${l}`},wss:(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=interpretNext(r[0],r[1]??"",t);return n=n.replace("tcp://",""),`wss://${n}`},"p2p-websocket-star":(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(r[0],r[1]??"",t)}/p2p-websocket-star`},"p2p-webrtc-star":(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(r[0],r[1]??"",t)}/p2p-webrtc-star`},"p2p-webrtc-direct":(e,t)=>{const r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${interpretNext(r[0],r[1]??"",t)}/p2p-webrtc-direct`}};function multiaddrToUri(e,t){const n=multiaddr(e).stringTuples(),o=n.pop();if(o===void 0)throw new Error("Unexpected end of multiaddr");const a=getProtocol(o[0]),l=interpreters[a.name];if(l==null)throw new Error(`No interpreter found for ${a.name}`);let c=l(o[1]??"",n);return t?.assumeHttp!==!1&&o[0]===getProtocol("tcp").code&&(c=c.replace("tcp://","http://"),(o[1]==="443"||o[1]==="80")&&(o[1]==="443"&&(c=c.replace("http://","https://")),c=c.substring(0,c.lastIndexOf(":")))),c}const ready=async e=>{if(e.readyState>=2)throw new Error("socket closed");e.readyState!==1&&await new Promise((t,r)=>{function n(){e.removeEventListener("open",o),e.removeEventListener("error",a)}function o(){n(),t()}function a(l){n(),r(l.error??new Error(`connect ECONNREFUSED ${e.url}`))}e.addEventListener("open",o),e.addEventListener("error",a)})},sink=(e,t)=>(t=t??{},t.closeOnEnd=t.closeOnEnd!==!1,async n=>{for await(const o of n){try{await ready(e)}catch(a){if(a.message==="socket closed")break;throw a}if(e.readyState===e.CLOSING||e.readyState===e.CLOSED)break;e.send(o)}t.closeOnEnd!=null&&e.readyState<=1&&await new Promise((o,a)=>{e.addEventListener("close",l=>{if(l.wasClean||l.code===1006)o();else{const c=Object.assign(new Error("ws error"),{event:l});a(c)}}),setTimeout(()=>{e.close()})})});var dom$1={},eventIterator={};Object.defineProperty(eventIterator,"__esModule",{value:!0});class EventQueue{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(t){if(this.isStopped)return;const r={value:t,done:!1};if(this.pullQueue.length){const n=this.pullQueue.shift();n&&n.resolve(r)}else this.pushQueue.push(Promise.resolve(r)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const t of this.pullQueue)t.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(t){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const r of this.pullQueue)r.reject(t);this.pullQueue.length=0}else{const r=Promise.reject(t);r.catch(()=>{}),this.pushQueue.push(r)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:t=>{const r=this.pushQueue.shift();return r?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),r):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((n,o)=>{this.pullQueue.push({resolve:n,reject:o})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class EventIterator$1{constructor(t,{highWaterMark:r=100,lowWaterMark:n=1}={}){const o=new EventQueue;o.highWaterMark=r,o.lowWaterMark=n,o.removeCallback=t({push:a=>o.push(a),stop:()=>o.stop(),fail:a=>o.fail(a),on:(a,l)=>{o.eventHandlers[a]=l}})||(()=>{}),this[Symbol.asyncIterator]=()=>o[Symbol.asyncIterator](),Object.freeze(this)}}eventIterator.EventIterator=EventIterator$1;eventIterator.default=EventIterator$1;Object.defineProperty(dom$1,"__esModule",{value:!0});const event_iterator_1=eventIterator;var EventIterator=dom$1.EventIterator=event_iterator_1.EventIterator;function subscribe(e,t,r){return new event_iterator_1.EventIterator(({push:n})=>(this.addEventListener(e,n,t),()=>this.removeEventListener(e,n,t)),r)}dom$1.subscribe=subscribe;dom$1.default=event_iterator_1.EventIterator;function isArrayBuffer(e){return e instanceof ArrayBuffer||e?.constructor?.name==="ArrayBuffer"&&typeof e?.byteLength=="number"}const source=e=>{e.binaryType="arraybuffer";const t=async()=>{await new Promise((a,l)=>{if(n){a();return}if(o!=null){l(o);return}const c=b=>{e.removeEventListener("open",u),e.removeEventListener("error",g),b()},u=()=>{c(a)},g=b=>{c(()=>{l(b.error??new Error(`connect ECONNREFUSED ${e.url}`))})};e.addEventListener("open",u),e.addEventListener("error",g)})},r=async function*(){const a=new EventIterator(({push:l,stop:c,fail:u})=>{const g=x=>{let S=null;typeof x.data=="string"&&(S=fromString$1(x.data)),isArrayBuffer(x.data)&&(S=new Uint8Array(x.data)),x.data instanceof Uint8Array&&(S=x.data),S!=null&&l(S)},b=x=>{u(x.error??new Error("Socket error"))};return e.addEventListener("message",g),e.addEventListener("error",b),e.addEventListener("close",c),()=>{e.removeEventListener("message",g),e.removeEventListener("error",b),e.removeEventListener("close",c)}},{highWaterMark:1/0});await t();for await(const l of a)yield isArrayBuffer(l)?new Uint8Array(l):l}();let n=e.readyState===1,o;return e.addEventListener("open",()=>{n=!0,o=null}),e.addEventListener("close",()=>{n=!1,o=null}),e.addEventListener("error",a=>{n||(o=a.error??new Error(`connect ECONNREFUSED ${e.url}`))}),Object.assign(r,{connected:t})},duplex=(e,t)=>{t=t??{};const r=source(e);let n=t.remoteAddress,o=t.remotePort;if(e.url!=null)try{const l=new URL(e.url);n=l.hostname,o=parseInt(l.port,10)}catch{}if(n==null||o==null)throw new Error("Remote connection did not have address and/or port");return{sink:sink(e,t),source:r,connected:async()=>{await r.connected()},close:async()=>{(e.readyState===e.CONNECTING||e.readyState===e.OPEN)&&await new Promise(l=>{e.addEventListener("close",()=>{l()}),e.close()})},destroy:()=>{e.terminate!=null?e.terminate():e.close()},remoteAddress:n,remotePort:o,socket:e}},WebSocket$1=WebSocket,isReactNative$1=typeof navigator<"u"&&navigator.product==="ReactNative";function getDefaultBase(){return isReactNative$1?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}const URL$1=self.URL,defaultBase$1=getDefaultBase();class URLWithLegacySupport$2{constructor(t="",r=defaultBase$1){this.super=new URL$1(t,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set username(t){this.super.username=t}static createObjectURL(t){return URL$1.createObjectURL(t)}static revokeObjectURL(t){URL$1.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}}function format$2(e){if(typeof e=="string")return new URL$1(e).toString();if(!(e instanceof URL$1)){const t=e.username&&e.password?`${e.username}:${e.password}@`:"",r=e.auth?e.auth+"@":"",n=e.port?":"+e.port:"",o=e.protocol?e.protocol+"//":"",a=e.host||"",l=e.hostname||"",c=e.search||(e.query?"?"+e.query:""),u=e.hash||"",g=e.pathname||"",b=e.path||g+c;return`${o}${t||r}${a||l+n}${b}${u}`}}var urlBrowser={URLWithLegacySupport:URLWithLegacySupport$2,URLSearchParams:self.URLSearchParams,defaultBase:defaultBase$1,format:format$2};const{URLWithLegacySupport:URLWithLegacySupport$1,format:format$1}=urlBrowser;var relative$1=(e,t={},r={},n)=>{let o=t.protocol?t.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let a;try{a=new URLWithLegacySupport$1(e)}catch{a={}}const l=Object.assign({},t,{protocol:o||a.protocol,host:t.host||a.host});return new URLWithLegacySupport$1(e,format$1(l)).toString()};const{URLWithLegacySupport,format,URLSearchParams:URLSearchParams$1,defaultBase}=urlBrowser,relative=relative$1;var isoUrl={URL:URLWithLegacySupport,URLSearchParams:URLSearchParams$1,format,relative,defaultBase};const map$2={http:"ws",https:"wss"},def="ws",wsurl=(e,t)=>isoUrl.relative(e,t,map$2,def);function connect(e,t){const r=typeof window>"u"?"":window.location;t=t??{};const n=wsurl(e,r.toString()),o=new WebSocket$1(n,t.websocket);return duplex(o,t)}function isElectron$1(){return typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&!!process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0}var isElectron_1=isElectron$1;const isEnvWithDom=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,isElectron=isElectron_1(),isBrowser=isEnvWithDom&&!isElectron,isElectronMain=isElectron&&!isEnvWithDom,isElectronRenderer=isElectron&&isEnvWithDom,isNode=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!isElectron,isWebWorker=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope;typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+(()=>"_")()+"ENV"];const isReactNative=typeof navigator<"u"&&navigator.product==="ReactNative",CODE_P2P=421,CODE_CIRCUIT=290,CLOSE_TIMEOUT$1=500;function all$1(e){return e.filter(t=>{if(t.protoCodes().includes(CODE_CIRCUIT))return!1;const r=t.decapsulateCode(CODE_P2P);return WebSockets$1.matches(r)||WebSocketsSecure.matches(r)})}function wss(e){return e.filter(t=>{if(t.protoCodes().includes(CODE_CIRCUIT))return!1;const r=t.decapsulateCode(CODE_P2P);return WebSocketsSecure.matches(r)})}function createListener$1(){throw new Error("WebSocket Servers can not be created in the browser!")}const log$r=logger("libp2p:websockets:socket");function socketToMaConn(e,t,r){r=r??{};const n={async sink(o){r?.signal!=null&&(o=abortableSource(o,r.signal));try{await e.sink(o)}catch(a){a.type!=="aborted"&&log$r.error(a)}},source:r.signal!=null?abortableSource(e.source,r.signal):e.source,remoteAddr:t,timeline:{open:Date.now()},async close(o={}){const a=Date.now();o.signal=o.signal??AbortSignal.timeout(CLOSE_TIMEOUT$1);const l=()=>{const{host:c,port:u}=n.remoteAddr.toOptions();log$r("timeout closing stream to %s:%s after %dms, destroying it manually",c,u,Date.now()-a),this.abort(new CodeError("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT"))};o.signal.addEventListener("abort",l);try{await e.close()}catch(c){this.abort(c)}finally{o.signal.removeEventListener("abort",l),n.timeline.close=Date.now()}},abort(o){const{host:a,port:l}=n.remoteAddr.toOptions();log$r("timeout closing stream to %s:%s due to error",a,l,o),e.destroy(),n.timeline.close=Date.now()}};return e.socket.addEventListener("close",()=>{n.timeline.close==null&&(n.timeline.close=Date.now())},{once:!0}),n}const log$q=logger("libp2p:websockets");var rc,nc;class WebSockets{constructor(t){Xe(this,"init");Xe(this,rc,"@libp2p/websockets");Xe(this,nc,!0);this.init=t}async dial(t,r){log$q("dialing %s",t),r=r??{};const n=await this._connect(t,r),o=socketToMaConn(n,t);log$q("new outbound connection %s",o.remoteAddr);const a=await r.upgrader.upgradeOutbound(o);return log$q("outbound connection %s upgraded",o.remoteAddr),a}async _connect(t,r){if(r?.signal?.aborted===!0)throw new AbortError$4;const n=t.toOptions();log$q("dialing %s:%s",n.host,n.port);const o=pDefer(),a=connect(multiaddrToUri(t),this.init);if(a.socket.addEventListener("error",()=>{const u=new CodeError(`Could not connect to ${t.toString()}`,"ERR_CONNECTION_FAILED");log$q.error("connection error:",u),o.reject(u)}),r.signal==null)return await Promise.race([a.connected(),o.promise]),log$q("connected %s",t),a;let l;const c=new Promise((u,g)=>{if(l=()=>{g(new AbortError$4),a.close().catch(b=>{log$q.error("error closing raw socket",b)})},r?.signal?.aborted===!0){l();return}r?.signal?.addEventListener("abort",l)});try{await Promise.race([c,o.promise,a.connected()])}finally{l!=null&&r?.signal?.removeEventListener("abort",l)}return log$q("connected %s",t),a}createListener(t){return createListener$1({...this.init,...t})}filter(t){return t=Array.isArray(t)?t:[t],this.init?.filter!=null?this.init?.filter(t):isBrowser||isWebWorker?wss(t):all$1(t)}}rc=Symbol.toStringTag,nc=symbol$1;function webSockets(e={}){return()=>new WebSockets(e)}var events$1={exports:{}},R$1=typeof Reflect=="object"?Reflect:null,ReflectApply=R$1&&typeof R$1.apply=="function"?R$1.apply:function e(t,r,n){return Function.prototype.apply.call(t,r,n)},ReflectOwnKeys;R$1&&typeof R$1.ownKeys=="function"?ReflectOwnKeys=R$1.ownKeys:Object.getOwnPropertySymbols?ReflectOwnKeys=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ReflectOwnKeys=function(t){return Object.getOwnPropertyNames(t)};function ProcessEmitWarning(e){console&&console.warn&&console.warn(e)}var NumberIsNaN=Number.isNaN||function e(t){return t!==t};function EventEmitter(){EventEmitter.init.call(this)}events$1.exports=EventEmitter;events$1.exports.once=once;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=void 0;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=void 0;var defaultMaxListeners=10;function checkListener(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(e){if(typeof e!="number"||e<0||NumberIsNaN(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");defaultMaxListeners=e}});EventEmitter.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};EventEmitter.prototype.setMaxListeners=function e(t){if(typeof t!="number"||t<0||NumberIsNaN(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function _getMaxListeners(e){return e._maxListeners===void 0?EventEmitter.defaultMaxListeners:e._maxListeners}EventEmitter.prototype.getMaxListeners=function e(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function e(t){for(var r=[],n=1;n0&&(l=r[0]),l instanceof Error)throw l;var c=new Error("Unhandled error."+(l?" ("+l.message+")":""));throw c.context=l,c}var u=a[t];if(u===void 0)return!1;if(typeof u=="function")ReflectApply(u,this,r);else for(var g=u.length,b=arrayClone(u,g),n=0;n0&&l.length>o&&!l.warned){l.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=l.length,ProcessEmitWarning(c)}return e}EventEmitter.prototype.addListener=function e(t,r){return _addListener(this,t,r,!1)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function e(t,r){return _addListener(this,t,r,!0)};function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=onceWrapper.bind(n);return o.listener=r,n.wrapFn=o,o}EventEmitter.prototype.once=function e(t,r){return checkListener(r),this.on(t,_onceWrap(this,t,r)),this};EventEmitter.prototype.prependOnceListener=function e(t,r){return checkListener(r),this.prependListener(t,_onceWrap(this,t,r)),this};EventEmitter.prototype.removeListener=function e(t,r){var n,o,a,l,c;if(checkListener(r),o=this._events,o===void 0)return this;if(n=o[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[t],o.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(a=-1,l=n.length-1;l>=0;l--)if(n[l]===r||n[l].listener===r){c=n[l].listener,a=l;break}if(a<0)return this;a===0?n.shift():spliceOne(n,a),n.length===1&&(o[t]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",t,c||r)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function e(t){var r,n,o;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var a=Object.keys(n),l;for(o=0;o=0;o--)this.removeListener(t,r[o]);return this};function _listeners(e,t,r){var n=e._events;if(n===void 0)return[];var o=n[t];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?unwrapListeners(o):arrayClone(o,o.length)}EventEmitter.prototype.listeners=function e(t){return _listeners(this,t,!0)};EventEmitter.prototype.rawListeners=function e(t){return _listeners(this,t,!1)};EventEmitter.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):listenerCount.call(e,t)};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}EventEmitter.prototype.eventNames=function e(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(e,t){for(var r=new Array(t),n=0;ncrypto.getRandomValues(new Uint8Array(e)).reduce((t,r)=>(r&=63,r<36?t+=r.toString(36):r<62?t+=(r-26).toString(36).toUpperCase():r>62?t+="-":t+="_",t),"");const pathSepS="/",pathSepB=new TextEncoder().encode(pathSepS),pathSep=pathSepB[0];class Key{constructor(t,r){Xe(this,"_buf");if(typeof t=="string")this._buf=fromString$1(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==pathSep)throw new Error("Invalid key")}toString(t="utf8"){return toString$5(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new Key(t.join(pathSepS))}static random(){return new Key(nanoid().replace(/-/g,""))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new Key(t):typeof t.uint8Array=="function"?new Key(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=pathSepB),this._buf[0]!==pathSep){const t=new Uint8Array(this._buf.byteLength+1);t.fill(pathSep,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===pathSep;)this._buf=this._buf.subarray(0,-1)}less(t){const r=this.list(),n=t.list();for(let o=0;ol)return!1}return r.lengthr.namespaces()))])}}function namespaceType(e){const t=e.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function namespaceValue(e){const t=e.split(":");return t[t.length-1]}function flatten(e){return[].concat(...e)}var isPlainObj=e=>{if(Object.prototype.toString.call(e)!=="[object Object]")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype};const isOptionObject=isPlainObj,{hasOwnProperty:hasOwnProperty$1}=Object.prototype,{propertyIsEnumerable}=Object,defineProperty=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),globalThis$4=commonjsGlobal$2,defaultMergeOptions={concatArrays:!1,ignoreUndefined:!1},getEnumerableOwnPropertyKeys=e=>{const t=[];for(const r in e)hasOwnProperty$1.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)propertyIsEnumerable.call(e,n)&&t.push(n)}return t};function clone$1(e){return Array.isArray(e)?cloneArray(e):isOptionObject(e)?cloneOptionObject(e):e}function cloneArray(e){const t=e.slice(0,0);return getEnumerableOwnPropertyKeys(e).forEach(r=>{defineProperty(t,r,clone$1(e[r]))}),t}function cloneOptionObject(e){const t=Object.getPrototypeOf(e)===null?Object.create(null):{};return getEnumerableOwnPropertyKeys(e).forEach(r=>{defineProperty(t,r,clone$1(e[r]))}),t}const mergeKeys=(e,t,r,n)=>(r.forEach(o=>{typeof t[o]>"u"&&n.ignoreUndefined||(o in e&&e[o]!==Object.getPrototypeOf(e)?defineProperty(e,o,merge(e[o],t[o],n)):defineProperty(e,o,clone$1(t[o])))}),e),concatArrays=(e,t,r)=>{let n=e.slice(0,0),o=0;return[e,t].forEach(a=>{const l=[];for(let c=0;c!l.includes(c)),r)}),n};function merge(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?concatArrays(e,t,r):!isOptionObject(t)||!isOptionObject(e)?clone$1(t):mergeKeys(e,t,getEnumerableOwnPropertyKeys(t),r)}var mergeOptions=function(...e){const t=merge(clone$1(defaultMergeOptions),this!==globalThis$4&&this||{},defaultMergeOptions);let r={_:{}};for(const n of e)if(n!==void 0){if(!isOptionObject(n))throw new TypeError("`"+n+"` is not an Option Object");r=merge(r,{_:n},t)}return r._};function isHighSurrogate$1(e){return e>=55296&&e<=56319}function isLowSurrogate$1(e){return e>=56320&&e<=57343}var truncate$2=function e(t,r,n){if(typeof r!="string")throw new Error("Input must be string");for(var o=r.length,a=0,l,c,u=0;un)return r.slice(0,u-c.length+1)}return r};function isHighSurrogate(e){return e>=55296&&e<=56319}function isLowSurrogate(e){return e>=56320&&e<=57343}var browser$5=function e(t){if(typeof t!="string")throw new Error("Input must be string");for(var r=t.length,n=0,o=null,a=null,l=0;l=128&&o<=2047?n+=2:o>=2048&&o<=65535&&(n+=3),a=o;return n},truncate$1=truncate$2,getLength=browser$5,browser$4=truncate$1.bind(null,getLength),truncate=browser$4,illegalRe=/[\/\?<>\\:\*\|"]/g,controlRe=/[\x00-\x1f\x80-\x9f]/g,reservedRe=/^\.+$/,windowsReservedRe=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,windowsTrailingRe=/[\. ]+$/;function sanitize(e,t){if(typeof e!="string")throw new Error("Input must be string");var r=e.replace(illegalRe,t).replace(controlRe,t).replace(reservedRe,t).replace(windowsReservedRe,t).replace(windowsTrailingRe,t);return truncate(r,255)}var sanitizeFilename=function(e,t){var r=t&&t.replacement||"",n=sanitize(e,r);return r===""?n:sanitize(n,"")},codes$3;(function(e){e.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",e.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",e.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",e.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",e.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",e.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",e.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",e.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",e.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",e.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",e.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",e.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",e.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",e.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",e.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH"})(codes$3||(codes$3={}));const log$p=logger("libp2p:keychain"),keyPrefix="/pkcs8/",infoPrefix="/info/",privates=new WeakMap,NIST={minKeyLength:112/8,minSaltLength:128/8,minIterationCount:1e3},defaultOptions$6={dek:{keyLength:512/8,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function validateKeyName(e){return e==null||typeof e!="string"?!1:e===sanitizeFilename(e.trim())&&e.length>0}async function randomDelay(){const r=Math.random()*800+200;await new Promise(n=>setTimeout(n,r))}function DsName(e){return new Key(keyPrefix+e)}function DsInfoName(e){return new Key(infoPrefix+e)}class DefaultKeyChain{constructor(t,r){Xe(this,"components");Xe(this,"init");if(this.components=t,this.init=mergeOptions(defaultOptions$6,r),this.init.pass!=null&&this.init.pass?.length<20)throw new Error("pass must be least 20 characters");if(this.init.dek?.keyLength!=null&&this.init.dek.keyLengtho.id===t);if(n==null)throw new CodeError(`Key with id '${t}' does not exist.`,codes$3.ERR_KEY_NOT_FOUND);return n}catch(r){throw await randomDelay(),r}}async findKeyByName(t){if(!validateKeyName(t))throw await randomDelay(),new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);const r=DsInfoName(t);try{const n=await this.components.datastore.get(r);return JSON.parse(toString$5(n))}catch(n){throw await randomDelay(),log$p.error(n),new CodeError(`Key '${t}' does not exist.`,codes$3.ERR_KEY_NOT_FOUND)}}async removeKey(t){if(!validateKeyName(t)||t==="self")throw await randomDelay(),new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);const r=DsName(t),n=await this.findKeyByName(t),o=this.components.datastore.batch();return o.delete(r),o.delete(DsInfoName(t)),await o.commit(),n}async renameKey(t,r){if(!validateKeyName(t)||t==="self")throw await randomDelay(),new CodeError(`Invalid old key name '${t}'`,codes$3.ERR_OLD_KEY_NAME_INVALID);if(!validateKeyName(r)||r==="self")throw await randomDelay(),new CodeError(`Invalid new key name '${r}'`,codes$3.ERR_NEW_KEY_NAME_INVALID);const n=DsName(t),o=DsName(r),a=DsInfoName(t),l=DsInfoName(r);if(await this.components.datastore.has(o))throw await randomDelay(),new CodeError(`Key '${r}' already exists`,codes$3.ERR_KEY_ALREADY_EXISTS);try{const u=await this.components.datastore.get(n),g=await this.components.datastore.get(a),b=JSON.parse(toString$5(g));b.name=r;const x=this.components.datastore.batch();return x.put(o,u),x.put(l,fromString$1(JSON.stringify(b))),x.delete(n),x.delete(a),await x.commit(),b}catch(u){throw await randomDelay(),u}}async exportKey(t,r){if(!validateKeyName(t))throw await randomDelay(),new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);if(r==null)throw await randomDelay(),new CodeError("Password is required",codes$3.ERR_PASSWORD_REQUIRED);const n=DsName(t);try{const o=await this.components.datastore.get(n),a=toString$5(o),l=privates.get(this);if(l==null)throw new CodeError("dek missing",codes$3.ERR_INVALID_PARAMETERS);const c=l.dek;return await(await importKey(a,c)).export(r)}catch(o){throw await randomDelay(),o}}async exportPeerId(t){const r="temporary-password",n=await this.exportKey(t,r),o=await importKey(n,r);return peerIdFromKeys(o.public.bytes,o.bytes)}async importKey(t,r,n){if(!validateKeyName(t)||t==="self")throw await randomDelay(),new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);if(r==null)throw await randomDelay(),new CodeError("PEM encoded key is required",codes$3.ERR_PEM_REQUIRED);const o=DsName(t);if(await this.components.datastore.has(o))throw await randomDelay(),new CodeError(`Key '${t}' already exists`,codes$3.ERR_KEY_ALREADY_EXISTS);let l;try{l=await importKey(r,n)}catch{throw await randomDelay(),new CodeError("Cannot read the key, most likely the password is wrong",codes$3.ERR_CANNOT_READ_KEY)}let c;try{c=await l.id();const b=privates.get(this);if(b==null)throw new CodeError("dek missing",codes$3.ERR_INVALID_PARAMETERS);const x=b.dek;r=await l.export(x)}catch(b){throw await randomDelay(),b}const u={name:t,id:c},g=this.components.datastore.batch();return g.put(o,fromString$1(r)),g.put(DsInfoName(t),fromString$1(JSON.stringify(u))),await g.commit(),u}async importPeer(t,r){try{if(!validateKeyName(t))throw new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);if(r==null)throw new CodeError("PeerId is required",codes$3.ERR_MISSING_PRIVATE_KEY);if(r.privateKey==null)throw new CodeError("PeerId.privKey is required",codes$3.ERR_MISSING_PRIVATE_KEY);const n=await unmarshalPrivateKey(r.privateKey),o=DsName(t);if(await this.components.datastore.has(o))throw await randomDelay(),new CodeError(`Key '${t}' already exists`,codes$3.ERR_KEY_ALREADY_EXISTS);const l=privates.get(this);if(l==null)throw new CodeError("dek missing",codes$3.ERR_INVALID_PARAMETERS);const c=l.dek,u=await n.export(c),g={name:t,id:r.toString()},b=this.components.datastore.batch();return b.put(o,fromString$1(u)),b.put(DsInfoName(t),fromString$1(JSON.stringify(g))),await b.commit(),g}catch(n){throw await randomDelay(),n}}async getPrivateKey(t){if(!validateKeyName(t))throw await randomDelay(),new CodeError(`Invalid key name '${t}'`,codes$3.ERR_INVALID_KEY_NAME);try{const r=DsName(t),n=await this.components.datastore.get(r);return toString$5(n)}catch(r){throw await randomDelay(),log$p.error(r),new CodeError(`Key '${t}' does not exist.`,codes$3.ERR_KEY_NOT_FOUND)}}async rotateKeychainPass(t,r){if(typeof t!="string")throw await randomDelay(),new CodeError(`Invalid old pass type '${typeof t}'`,codes$3.ERR_INVALID_OLD_PASS_TYPE);if(typeof r!="string")throw await randomDelay(),new CodeError(`Invalid new pass type '${typeof r}'`,codes$3.ERR_INVALID_NEW_PASS_TYPE);if(r.length<20)throw await randomDelay(),new CodeError(`Invalid pass length ${r.length}`,codes$3.ERR_INVALID_PASS_LENGTH);log$p("recreating keychain");const n=privates.get(this);if(n==null)throw new CodeError("dek missing",codes$3.ERR_INVALID_PARAMETERS);const o=n.dek;this.init.pass=r;const a=r!=null&&this.init.dek?.salt!=null?pbkdf2(r,this.init.dek.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";privates.set(this,{dek:a});const l=await this.listKeys();for(const c of l){const u=await this.components.datastore.get(DsName(c.name)),g=toString$5(u),b=await importKey(g,o),x=a.toString(),S=await b.export(x),$=this.components.datastore.batch(),k={name:c.name,id:c.id};$.put(DsName(c.name),fromString$1(S)),$.put(DsInfoName(c.name),fromString$1(JSON.stringify(k))),await $.commit()}log$p("keychain reconstructed")}}var PeerIdProto;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.id!=null&&(n.uint32(10),n.bytes(r.id)),r.pubKey!=null&&(n.uint32(18),n.bytes(r.pubKey)),r.privKey!=null&&(n.uint32(26),n.bytes(r.privKey)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.id=r.bytes();break;case 2:o.pubKey=r.bytes();break;case 3:o.privKey=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(PeerIdProto||(PeerIdProto={}));const createEd25519PeerId=async()=>{const e=await generateKeyPair("Ed25519"),t=await createFromPrivKey(e);if(t.type==="Ed25519")return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function createFromPrivKey(e){return peerIdFromKeys(marshalPublicKey(e.public),marshalPrivateKey(e))}const codes$2={ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"};var Envelope;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.publicKey!=null&&r.publicKey.byteLength>0&&(n.uint32(10),n.bytes(r.publicKey)),r.payloadType!=null&&r.payloadType.byteLength>0&&(n.uint32(18),n.bytes(r.payloadType)),r.payload!=null&&r.payload.byteLength>0&&(n.uint32(26),n.bytes(r.payload)),r.signature!=null&&r.signature.byteLength>0&&(n.uint32(42),n.bytes(r.signature)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.publicKey=r.bytes();break;case 2:o.payloadType=r.bytes();break;case 3:o.payload=r.bytes();break;case 5:o.signature=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Envelope||(Envelope={}));const ds=class{constructor(t){Xe(this,"peerId");Xe(this,"payloadType");Xe(this,"payload");Xe(this,"signature");Xe(this,"marshaled");const{peerId:r,payloadType:n,payload:o,signature:a}=t;this.peerId=r,this.payloadType=n,this.payload=o,this.signature=a}marshal(){if(this.peerId.publicKey==null)throw new Error("Missing public key");return this.marshaled==null&&(this.marshaled=Envelope.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(t){return equals$2(this.marshal(),t.marshal())}async validate(t){const r=formatSignaturePayload(t,this.payloadType,this.payload);if(this.peerId.publicKey==null)throw new Error("Missing public key");return unmarshalPublicKey(this.peerId.publicKey).verify(r.subarray(),this.signature)}};let RecordEnvelope=ds;Xe(RecordEnvelope,"createFromProtobuf",async t=>{const r=Envelope.decode(t),n=await peerIdFromKeys(r.publicKey);return new ds({peerId:n,payloadType:r.payloadType,payload:r.payload,signature:r.signature})}),Xe(RecordEnvelope,"seal",async(t,r)=>{if(r.privateKey==null)throw new Error("Missing private key");const n=t.domain,o=t.codec,a=t.marshal(),l=formatSignaturePayload(n,o,a),u=await(await unmarshalPrivateKey(r.privateKey)).sign(l.subarray());return new ds({peerId:r,payloadType:o,payload:a,signature:u})}),Xe(RecordEnvelope,"openAndCertify",async(t,r)=>{const n=await ds.createFromProtobuf(t);if(!await n.validate(r))throw new CodeError("envelope signature is not valid for the given domain",codes$2.ERR_SIGNATURE_NOT_VALID);return n});const formatSignaturePayload=(e,t,r)=>{const n=fromString$1(e),o=encode$d(n.byteLength),a=encode$d(t.length),l=encode$d(r.length);return new Uint8ArrayList(o,n,a,t,l,r)};function arrayEquals(e,t){const r=(n,o)=>n.toString().localeCompare(o.toString());return e.length!==t.length?!1:(t.sort(r),e.sort(r).every((n,o)=>t[o].equals(n)))}const ENVELOPE_DOMAIN_PEER_RECORD="libp2p-peer-record",ENVELOPE_PAYLOAD_TYPE_PEER_RECORD=Uint8Array.from([3,1]);var PeerRecord$1;(function(e){(function(r){let n;r.codec=()=>(n==null&&(n=message((o,a,l={})=>{l.lengthDelimited!==!1&&a.fork(),o.multiaddr!=null&&o.multiaddr.byteLength>0&&(a.uint32(10),a.bytes(o.multiaddr)),l.lengthDelimited!==!1&&a.ldelim()},(o,a)=>{const l={multiaddr:new Uint8Array(0)},c=a==null?o.len:o.pos+a;for(;o.pos>>3){case 1:l.multiaddr=o.bytes();break;default:o.skipType(u&7);break}}return l})),n),r.encode=o=>encodeMessage(o,r.codec()),r.decode=o=>decodeMessage(o,r.codec())})(e.AddressInfo||(e.AddressInfo={}));let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.peerId!=null&&r.peerId.byteLength>0&&(n.uint32(10),n.bytes(r.peerId)),r.seq!=null&&r.seq!==0n&&(n.uint32(16),n.uint64(r.seq)),r.addresses!=null)for(const a of r.addresses)n.uint32(26),e.AddressInfo.codec().encode(a,n);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={peerId:new Uint8Array(0),seq:0n,addresses:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.peerId=r.bytes();break;case 2:o.seq=r.uint64();break;case 3:o.addresses.push(e.AddressInfo.codec().decode(r,r.uint32()));break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(PeerRecord$1||(PeerRecord$1={}));const Ri=class{constructor(t){Xe(this,"peerId");Xe(this,"multiaddrs");Xe(this,"seqNumber");Xe(this,"domain",Ri.DOMAIN);Xe(this,"codec",Ri.CODEC);Xe(this,"marshaled");const{peerId:r,multiaddrs:n,seqNumber:o}=t;this.peerId=r,this.multiaddrs=n??[],this.seqNumber=o??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=PeerRecord$1.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!(!(t instanceof Ri)||!this.peerId.equals(t.peerId)||this.seqNumber!==t.seqNumber||!arrayEquals(this.multiaddrs,t.multiaddrs))}};let PeerRecord=Ri;Xe(PeerRecord,"createFromProtobuf",t=>{const r=PeerRecord$1.decode(t),n=peerIdFromBytes(r.peerId),o=(r.addresses??[]).map(l=>multiaddr(l.multiaddr)),a=r.seq;return new Ri({peerId:n,multiaddrs:o,seqNumber:a})}),Xe(PeerRecord,"DOMAIN",ENVELOPE_DOMAIN_PEER_RECORD),Xe(PeerRecord,"CODEC",ENVELOPE_PAYLOAD_TYPE_PEER_RECORD);function isAsyncIterable$6(e){return e[Symbol.asyncIterator]!=null}function all(e){if(isAsyncIterable$6(e))return(async()=>{const r=[];for await(const n of e)r.push(n);return r})();const t=[];for(const r of e)t.push(r);return t}const WORKER_REQUEST_READ_LOCK="lock:worker:request-read",WORKER_RELEASE_READ_LOCK="lock:worker:release-read",MASTER_GRANT_READ_LOCK="lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK="lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK="lock:worker:release-write",MASTER_GRANT_WRITE_LOCK="lock:master:grant-write",events={},observable=e=>{e.addEventListener("message",t=>{observable.dispatchEvent("message",e,t)}),e.port!=null&&e.port.addEventListener("message",t=>{observable.dispatchEvent("message",e,t)})};observable.addEventListener=(e,t)=>{events[e]==null&&(events[e]=[]),events[e].push(t)};observable.removeEventListener=(e,t)=>{events[e]!=null&&(events[e]=events[e].filter(r=>r===t))};observable.dispatchEvent=function(e,t,r){events[e]!=null&&events[e].forEach(n=>n(t,r))};const handleWorkerLockRequest=(e,t,r,n,o)=>(a,l)=>{if(l.data.type!==r)return;const c={type:l.data.type,name:l.data.name,identifier:l.data.identifier};e.dispatchEvent(new MessageEvent(t,{data:{name:c.name,handler:async()=>(a.postMessage({type:o,name:c.name,identifier:c.identifier}),await new Promise(u=>{const g=b=>{if(b==null||b.data==null)return;const x={type:b.data.type,name:b.data.name,identifier:b.data.identifier};x.type===n&&x.identifier===c.identifier&&(a.removeEventListener("message",g),u())};a.addEventListener("message",g)}))}}))},makeWorkerLockRequest=(e,t,r,n)=>async()=>{const o=nanoid();return globalThis.postMessage({type:t,identifier:o,name:e}),await new Promise(a=>{const l=c=>{if(c==null||c.data==null)return;const u={type:c.data.type,identifier:c.data.identifier};u.type===r&&u.identifier===o&&(globalThis.removeEventListener("message",l),a(()=>{globalThis.postMessage({type:n,identifier:o,name:e})}))};globalThis.addEventListener("message",l)})},defaultOptions$5={singleProcess:!1},impl=e=>{if(e=Object.assign({},defaultOptions$5,e),Boolean(globalThis.document)||e.singleProcess){const r=new EventTarget;return observable.addEventListener("message",handleWorkerLockRequest(r,"requestReadLock",WORKER_REQUEST_READ_LOCK,WORKER_RELEASE_READ_LOCK,MASTER_GRANT_READ_LOCK)),observable.addEventListener("message",handleWorkerLockRequest(r,"requestWriteLock",WORKER_REQUEST_WRITE_LOCK,WORKER_RELEASE_WRITE_LOCK,MASTER_GRANT_WRITE_LOCK)),r}return{isWorker:!0,readLock:r=>makeWorkerLockRequest(r,WORKER_REQUEST_READ_LOCK,MASTER_GRANT_READ_LOCK,WORKER_RELEASE_READ_LOCK),writeLock:r=>makeWorkerLockRequest(r,WORKER_REQUEST_WRITE_LOCK,MASTER_GRANT_WRITE_LOCK,WORKER_RELEASE_WRITE_LOCK)}},mutexes={};let implementation;async function createReleaseable(e,t){let r;const n=new Promise(o=>{r=o});return e.add(async()=>await pTimeout((async()=>await new Promise(o=>{r(()=>{o()})}))(),{milliseconds:t.timeout})),await n}const createMutex=(e,t)=>{if(implementation.isWorker===!0)return{readLock:implementation.readLock(e,t),writeLock:implementation.writeLock(e,t)};const r=new PQueue({concurrency:1});let n;return{async readLock(){if(n!=null)return await createReleaseable(n,t);n=new PQueue({concurrency:t.concurrency,autoStart:!1});const o=n,a=createReleaseable(n,t);return r.add(async()=>(o.start(),await o.onIdle().then(()=>{n===o&&(n=null)}))),await a},async writeLock(){return n=null,await createReleaseable(r,t)}}},defaultOptions$4={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function createMortice(e){const t=Object.assign({},defaultOptions$4,e);return implementation==null&&(implementation=impl(t),implementation.isWorker!==!0&&(implementation.addEventListener("requestReadLock",r=>{mutexes[r.data.name]!=null&&mutexes[r.data.name].readLock().then(async n=>await r.data.handler().finally(()=>n()))}),implementation.addEventListener("requestWriteLock",async r=>{mutexes[r.data.name]!=null&&mutexes[r.data.name].writeLock().then(async n=>await r.data.handler().finally(()=>n()))}))),mutexes[t.name]==null&&(mutexes[t.name]=createMutex(t.name,t)),mutexes[t.name]}const codes$1={ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS"};var Peer$1;(function(e){(function(r){let n;r.codec=()=>(n==null&&(n=message((o,a,l={})=>{l.lengthDelimited!==!1&&a.fork(),o.key!=null&&o.key!==""&&(a.uint32(10),a.string(o.key)),o.value!=null&&o.value.byteLength>0&&(a.uint32(18),a.bytes(o.value)),l.lengthDelimited!==!1&&a.ldelim()},(o,a)=>{const l={key:"",value:new Uint8Array(0)},c=a==null?o.len:o.pos+a;for(;o.pos>>3){case 1:l.key=o.string();break;case 2:l.value=o.bytes();break;default:o.skipType(u&7);break}}return l})),n),r.encode=o=>encodeMessage(o,r.codec()),r.decode=o=>decodeMessage(o,r.codec())})(e.Peer$metadataEntry||(e.Peer$metadataEntry={})),function(r){let n;r.codec=()=>(n==null&&(n=message((o,a,l={})=>{l.lengthDelimited!==!1&&a.fork(),o.key!=null&&o.key!==""&&(a.uint32(10),a.string(o.key)),o.value!=null&&(a.uint32(18),Tag.codec().encode(o.value,a)),l.lengthDelimited!==!1&&a.ldelim()},(o,a)=>{const l={key:""},c=a==null?o.len:o.pos+a;for(;o.pos>>3){case 1:l.key=o.string();break;case 2:l.value=Tag.codec().decode(o,o.uint32());break;default:o.skipType(u&7);break}}return l})),n),r.encode=o=>encodeMessage(o,r.codec()),r.decode=o=>decodeMessage(o,r.codec())}(e.Peer$tagsEntry||(e.Peer$tagsEntry={}));let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.addresses!=null)for(const a of r.addresses)n.uint32(10),Address.codec().encode(a,n);if(r.protocols!=null)for(const a of r.protocols)n.uint32(18),n.string(a);if(r.publicKey!=null&&(n.uint32(34),n.bytes(r.publicKey)),r.peerRecordEnvelope!=null&&(n.uint32(42),n.bytes(r.peerRecordEnvelope)),r.metadata!=null&&r.metadata.size!==0)for(const[a,l]of r.metadata.entries())n.uint32(50),e.Peer$metadataEntry.codec().encode({key:a,value:l},n);if(r.tags!=null&&r.tags.size!==0)for(const[a,l]of r.tags.entries())n.uint32(58),e.Peer$tagsEntry.codec().encode({key:a,value:l},n);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={addresses:[],protocols:[],metadata:new Map,tags:new Map},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.addresses.push(Address.codec().decode(r,r.uint32()));break;case 2:o.protocols.push(r.string());break;case 4:o.publicKey=r.bytes();break;case 5:o.peerRecordEnvelope=r.bytes();break;case 6:{const c=e.Peer$metadataEntry.codec().decode(r,r.uint32());o.metadata.set(c.key,c.value);break}case 7:{const c=e.Peer$tagsEntry.codec().decode(r,r.uint32());o.tags.set(c.key,c.value);break}default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Peer$1||(Peer$1={}));var Address;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.multiaddr!=null&&r.multiaddr.byteLength>0&&(n.uint32(10),n.bytes(r.multiaddr)),r.isCertified!=null&&(n.uint32(16),n.bool(r.isCertified)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={multiaddr:new Uint8Array(0)},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.multiaddr=r.bytes();break;case 2:o.isCertified=r.bool();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Address||(Address={}));var Tag;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.value!=null&&r.value!==0&&(n.uint32(8),n.uint32(r.value)),r.expiry!=null&&(n.uint32(16),n.uint64(r.expiry)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={value:0},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.value=r.uint32();break;case 2:o.expiry=r.uint64();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Tag||(Tag={}));function bytesToPeer(e,t){const r=Peer$1.decode(t);r.publicKey!=null&&e.publicKey==null&&(e=peerIdFromPeerId({...e,publicKey:e.publicKey}));const n=new Map,o=BigInt(Date.now());for(const[a,l]of r.tags.entries())l.expiry!=null&&l.expiry({multiaddr:multiaddr(a),isCertified:l??!1})),metadata:r.metadata,peerRecordEnvelope:r.peerRecordEnvelope??void 0,tags:n}}const NAMESPACE_COMMON="/peers/";function peerIdToDatastoreKey(e){if(!isPeerId(e)||e.type==null)throw new CodeError("Invalid PeerId",codes$1.ERR_INVALID_PARAMETERS);const t=e.toCID().toString();return new Key(`${NAMESPACE_COMMON}${t}`)}async function dedupeFilterAndSortAddresses(e,t,r){const n=new Map;for(const o of r){if(o==null)continue;if(o.multiaddr instanceof Uint8Array&&(o.multiaddr=multiaddr(o.multiaddr)),!isMultiaddr(o.multiaddr))throw new CodeError("Multiaddr was invalid",codes$1.ERR_INVALID_PARAMETERS);if(!await t(e,o.multiaddr))continue;const a=o.isCertified??!1,l=o.multiaddr.toString(),c=n.get(l);c!=null?o.isCertified=c.isCertified||a:n.set(l,{multiaddr:o.multiaddr,isCertified:a})}return[...n.values()].sort((o,a)=>o.multiaddr.toString().localeCompare(a.multiaddr.toString())).map(({isCertified:o,multiaddr:a})=>({isCertified:o,multiaddr:a.bytes}))}async function toPeerPB(e,t,r,n){if(t==null)throw new CodeError("Invalid PeerData",codes$1.ERR_INVALID_PARAMETERS);if(t.publicKey!=null&&e.publicKey!=null&&!equals$2(t.publicKey,e.publicKey))throw new CodeError("publicKey bytes do not match peer id publicKey bytes",codes$1.ERR_INVALID_PARAMETERS);const o=n.existingPeer;if(o!=null&&!e.equals(o.id))throw new CodeError("peer id did not match existing peer id",codes$1.ERR_INVALID_PARAMETERS);let a=o?.addresses??[],l=new Set(o?.protocols??[]),c=o?.metadata??new Map,u=o?.tags??new Map,g=o?.peerRecordEnvelope;if(r==="patch"){if((t.multiaddrs!=null||t.addresses!=null)&&(a=[],t.multiaddrs!=null&&a.push(...t.multiaddrs.map(x=>({isCertified:!1,multiaddr:x}))),t.addresses!=null&&a.push(...t.addresses)),t.protocols!=null&&(l=new Set(t.protocols)),t.metadata!=null){const x=t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata);c=createSortedMap(x,{validate:validateMetadata})}if(t.tags!=null){const x=t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags);u=createSortedMap(x,{validate:validateTag,map:mapTag})}t.peerRecordEnvelope!=null&&(g=t.peerRecordEnvelope)}if(r==="merge"){if(t.multiaddrs!=null&&a.push(...t.multiaddrs.map(x=>({isCertified:!1,multiaddr:x}))),t.addresses!=null&&a.push(...t.addresses),t.protocols!=null&&(l=new Set([...l,...t.protocols])),t.metadata!=null){const x=t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata);for(const[S,$]of x)$==null?c.delete(S):c.set(S,$);c=createSortedMap([...c.entries()],{validate:validateMetadata})}if(t.tags!=null){const x=t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags),S=new Map(u);for(const[$,k]of x)k==null?S.delete($):S.set($,k);u=createSortedMap([...S.entries()],{validate:validateTag,map:mapTag})}t.peerRecordEnvelope!=null&&(g=t.peerRecordEnvelope)}const b={addresses:await dedupeFilterAndSortAddresses(e,n.addressFilter??(async()=>!0),a),protocols:[...l.values()].sort((x,S)=>x.localeCompare(S)),metadata:c,tags:u,publicKey:o?.id.publicKey??t.publicKey??e.publicKey,peerRecordEnvelope:g};return e.type!=="RSA"&&delete b.publicKey,b}function createSortedMap(e,t){const r=new Map;for(const[n,o]of e)o!=null&&t.validate(n,o);for(const[n,o]of e.sort(([a],[l])=>a.localeCompare(l)))o!=null&&r.set(n,t.map?.(n,o)??o);return r}function validateMetadata(e,t){if(typeof e!="string")throw new CodeError("Metadata key must be a string",codes$1.ERR_INVALID_PARAMETERS);if(!(t instanceof Uint8Array))throw new CodeError("Metadata value must be a Uint8Array",codes$1.ERR_INVALID_PARAMETERS)}function validateTag(e,t){if(typeof e!="string")throw new CodeError("Tag name must be a string",codes$1.ERR_INVALID_PARAMETERS);if(t.value!=null){if(parseInt(`${t.value}`,10)!==t.value)throw new CodeError("Tag value must be an integer",codes$1.ERR_INVALID_PARAMETERS);if(t.value<0||t.value>100)throw new CodeError("Tag value must be between 0-100",codes$1.ERR_INVALID_PARAMETERS)}if(t.ttl!=null){if(parseInt(`${t.ttl}`,10)!==t.ttl)throw new CodeError("Tag ttl must be an integer",codes$1.ERR_INVALID_PARAMETERS);if(t.ttl<0)throw new CodeError("Tag ttl must be between greater than 0",codes$1.ERR_INVALID_PARAMETERS)}}function mapTag(e,t){let r;return t.expiry!=null&&(r=t.expiry),t.ttl!=null&&(r=BigInt(Date.now()+Number(t.ttl))),{value:t.value??0,expiry:r}}function decodePeer(e,t,r){const n=e.toString().split("/")[2],o=base32$2.decode(n),a=peerIdFromBytes(o),l=r.get(a);if(l!=null)return l;const c=bytesToPeer(a,t);return r.set(a,c),c}function mapQuery(e,t){return e==null?{}:{prefix:NAMESPACE_COMMON,filters:(e.filters??[]).map(r=>({key:n,value:o})=>r(decodePeer(n,o,t))),orders:(e.orders??[]).map(r=>(n,o)=>r(decodePeer(n.key,n.value,t),decodePeer(o.key,o.value,t)))}}var Oi,po,Di,go;class PersistentStore{constructor(t,r={}){Er(this,Oi);Er(this,Di);Xe(this,"peerId");Xe(this,"datastore");Xe(this,"lock");Xe(this,"addressFilter");this.peerId=t.peerId,this.datastore=t.datastore,this.addressFilter=r.addressFilter,this.lock=createMortice({name:"peer-store",singleProcess:!0})}async has(t){return this.datastore.has(peerIdToDatastoreKey(t))}async delete(t){if(this.peerId.equals(t))throw new CodeError("Cannot delete self peer",codes$1.ERR_INVALID_PARAMETERS);await this.datastore.delete(peerIdToDatastoreKey(t))}async load(t){const r=await this.datastore.get(peerIdToDatastoreKey(t));return bytesToPeer(t,r)}async save(t,r){const{existingBuf:n,existingPeer:o}=await xr(this,Oi,po).call(this,t),a=await toPeerPB(t,r,"patch",{addressFilter:this.addressFilter});return xr(this,Di,go).call(this,t,a,n,o)}async patch(t,r){const{existingBuf:n,existingPeer:o}=await xr(this,Oi,po).call(this,t),a=await toPeerPB(t,r,"patch",{addressFilter:this.addressFilter,existingPeer:o});return xr(this,Di,go).call(this,t,a,n,o)}async merge(t,r){const{existingBuf:n,existingPeer:o}=await xr(this,Oi,po).call(this,t),a=await toPeerPB(t,r,"merge",{addressFilter:this.addressFilter,existingPeer:o});return xr(this,Di,go).call(this,t,a,n,o)}async*all(t){const r=new PeerMap;for await(const{key:n,value:o}of this.datastore.query(mapQuery(t??{},r))){const a=decodePeer(n,o,r);a.id.equals(this.peerId)||(yield a)}}}Oi=new WeakSet,po=async function(t){try{const r=await this.datastore.get(peerIdToDatastoreKey(t)),n=bytesToPeer(t,r);return{existingBuf:r,existingPeer:n}}catch(r){if(r.code!=="ERR_NOT_FOUND")throw r}return{}},Di=new WeakSet,go=async function(t,r,n,o){const a=Peer$1.encode(r);return n!=null&&equals$2(a,n)?{peer:bytesToPeer(t,a),previous:o,updated:!1}:(await this.datastore.put(peerIdToDatastoreKey(t),a),{peer:bytesToPeer(t,a),previous:o,updated:!0})};const log$o=logger("libp2p:peer-store");var Ni,yo;class PersistentPeerStore{constructor(t,r={}){Er(this,Ni);Xe(this,"store");Xe(this,"events");Xe(this,"peerId");this.events=t.events,this.peerId=t.peerId,this.store=new PersistentStore(t,r)}async forEach(t,r){log$o.trace("forEach await read lock");const n=await this.store.lock.readLock();log$o.trace("forEach got read lock");try{for await(const o of this.store.all(r))t(o)}finally{log$o.trace("forEach release read lock"),n()}}async all(t){log$o.trace("all await read lock");const r=await this.store.lock.readLock();log$o.trace("all got read lock");try{return await all(this.store.all(t))}finally{log$o.trace("all release read lock"),r()}}async delete(t){log$o.trace("delete await write lock");const r=await this.store.lock.writeLock();log$o.trace("delete got write lock");try{await this.store.delete(t)}finally{log$o.trace("delete release write lock"),r()}}async has(t){log$o.trace("has await read lock");const r=await this.store.lock.readLock();log$o.trace("has got read lock");try{return await this.store.has(t)}finally{log$o.trace("has release read lock"),r()}}async get(t){log$o.trace("get await read lock");const r=await this.store.lock.readLock();log$o.trace("get got read lock");try{return await this.store.load(t)}finally{log$o.trace("get release read lock"),r()}}async save(t,r){log$o.trace("save await write lock");const n=await this.store.lock.writeLock();log$o.trace("save got write lock");try{const o=await this.store.save(t,r);return xr(this,Ni,yo).call(this,t,o),o.peer}finally{log$o.trace("save release write lock"),n()}}async patch(t,r){log$o.trace("patch await write lock");const n=await this.store.lock.writeLock();log$o.trace("patch got write lock");try{const o=await this.store.patch(t,r);return xr(this,Ni,yo).call(this,t,o),o.peer}finally{log$o.trace("patch release write lock"),n()}}async merge(t,r){log$o.trace("merge await write lock");const n=await this.store.lock.writeLock();log$o.trace("merge got write lock");try{const o=await this.store.merge(t,r);return xr(this,Ni,yo).call(this,t,o),o.peer}finally{log$o.trace("merge release write lock"),n()}}async consumePeerRecord(t,r){const n=await RecordEnvelope.openAndCertify(t,PeerRecord.DOMAIN);if(r?.equals(n.peerId)===!1)return log$o("envelope peer id was not the expected peer id - expected: %p received: %p",r,n.peerId),!1;const o=PeerRecord.createFromProtobuf(n.payload);let a;try{a=await this.get(n.peerId)}catch(l){if(l.code!=="ERR_NOT_FOUND")throw l}if(a?.peerRecordEnvelope!=null){const l=await RecordEnvelope.createFromProtobuf(a.peerRecordEnvelope),c=PeerRecord.createFromProtobuf(l.payload);if(c.seqNumber>=o.seqNumber)return log$o("sequence number was lower or equal to existing sequence number - stored: %d received: %d",c.seqNumber,o.seqNumber),!1}return await this.patch(o.peerId,{peerRecordEnvelope:t,addresses:o.multiaddrs.map(l=>({isCertified:!0,multiaddr:l}))}),!0}}Ni=new WeakSet,yo=function(t,r){!r.updated||(this.peerId.equals(t)?this.events.safeDispatchEvent("self:peer:update",{detail:r}):this.events.safeDispatchEvent("peer:update",{detail:r}))};function isAsyncIterable$5(e){return e[Symbol.asyncIterator]!=null}function drain(e){if(isAsyncIterable$5(e))return(async()=>{for await(const t of e);})();for(const t of e);}function peekable(e){const[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}function isAsyncIterable$4(e){return e[Symbol.asyncIterator]!=null}function filter(e,t){if(isAsyncIterable$4(e))return async function*(){for await(const c of e)await t(c)&&(yield c)}();const r=peekable(e),{value:n,done:o}=r.next();if(o===!0)return function*(){}();const a=t(n);if(typeof a.then=="function")return async function*(){await a&&(yield n);for await(const c of r)await t(c)&&(yield c)}();const l=t;return function*(){a===!0&&(yield n);for(const c of r)l(c)&&(yield c)}()}function isAsyncIterable$3(e){return e[Symbol.asyncIterator]!=null}function sort(e,t){return isAsyncIterable$3(e)?async function*(){yield*(await all(e)).sort(t)}():function*(){yield*all(e).sort(t)}()}function isAsyncIterable$2(e){return e[Symbol.asyncIterator]!=null}function take(e,t){return isAsyncIterable$2(e)?async function*(){let r=0;if(!(t<1)){for await(const n of e)if(yield n,r++,r===t)return}}():function*(){let r=0;if(!(t<1)){for(const n of e)if(yield n,r++,r===t)return}}()}class BaseDatastore{put(t,r,n){return Promise.reject(new Error(".put is not implemented"))}get(t,r){return Promise.reject(new Error(".get is not implemented"))}has(t,r){return Promise.reject(new Error(".has is not implemented"))}delete(t,r){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(t,r={}){for await(const{key:n,value:o}of t)await this.put(n,o,r),yield n}async*getMany(t,r={}){for await(const n of t)yield{key:n,value:await this.get(n,r)}}async*deleteMany(t,r={}){for await(const n of t)await this.delete(n,r),yield n}batch(){let t=[],r=[];return{put(n,o){t.push({key:n,value:o})},delete(n){r.push(n)},commit:async n=>{await drain(this.putMany(t,n)),t=[],await drain(this.deleteMany(r,n)),r=[]}}}async*_all(t,r){throw new Error("._all is not implemented")}async*_allKeys(t,r){throw new Error("._allKeys is not implemented")}query(t,r){let n=this._all(t,r);if(t.prefix!=null){const o=t.prefix;n=filter(n,a=>a.key.toString().startsWith(o))}if(Array.isArray(t.filters)&&(n=t.filters.reduce((o,a)=>filter(o,a),n)),Array.isArray(t.orders)&&(n=t.orders.reduce((o,a)=>sort(o,a),n)),t.offset!=null){let o=0;const a=t.offset;n=filter(n,()=>o++>=a)}return t.limit!=null&&(n=take(n,t.limit)),n}queryKeys(t,r){let n=this._allKeys(t,r);if(t.prefix!=null){const o=t.prefix;n=filter(n,a=>a.toString().startsWith(o))}if(Array.isArray(t.filters)&&(n=t.filters.reduce((o,a)=>filter(o,a),n)),Array.isArray(t.orders)&&(n=t.orders.reduce((o,a)=>sort(o,a),n)),t.offset!=null){const o=t.offset;let a=0;n=filter(n,()=>a++>=o)}return t.limit!=null&&(n=take(n,t.limit)),n}}function notFoundError(e){return e=e??new Error("Not Found"),errCode(e,"ERR_NOT_FOUND")}class MemoryDatastore extends BaseDatastore{constructor(){super();Xe(this,"data");this.data=new Map}put(r,n){return this.data.set(r.toString(),n),r}get(r){const n=this.data.get(r.toString());if(n==null)throw notFoundError();return n}has(r){return this.data.has(r.toString())}delete(r){this.data.delete(r.toString())}*_all(){for(const[r,n]of this.data.entries())yield{key:new Key(r),value:n}}*_allKeys(){for(const r of this.data.keys())yield new Key(r)}}function debounce(e,t){let r;return function(){const n=function(){r=void 0,e()};clearTimeout(r),r=setTimeout(n,t)}}const log$n=logger("libp2p:address-manager"),defaultAddressFilter=e=>e;function stripPeerId(e,t){const r=e.getPeerId();return r!=null&&peerIdFromString(r).equals(t)&&(e=e.decapsulate(multiaddr(`/p2p/${t.toString()}`))),e}class DefaultAddressManager{constructor(t,r={}){Xe(this,"components");Xe(this,"listen");Xe(this,"announce");Xe(this,"observed");Xe(this,"announceFilter");const{listen:n=[],announce:o=[]}=r;this.components=t,this.listen=n.map(a=>a.toString()),this.announce=new Set(o.map(a=>a.toString())),this.observed=new Map,this.announceFilter=r.announceFilter??defaultAddressFilter,this._updatePeerStoreAddresses=debounce(this._updatePeerStoreAddresses.bind(this),1e3),t.events.addEventListener("transport:listening",()=>{this._updatePeerStoreAddresses()}),t.events.addEventListener("transport:close",()=>{this._updatePeerStoreAddresses()})}_updatePeerStoreAddresses(){const t=this.getAnnounceAddrs().concat(this.components.transportManager.getAddrs()).concat([...this.observed.entries()].filter(([r,n])=>n.confident).map(([r])=>multiaddr(r))).map(r=>r.getPeerId()===this.components.peerId.toString()?r.decapsulate(`/p2p/${this.components.peerId.toString()}`):r);this.components.peerStore.patch(this.components.peerId,{multiaddrs:t}).catch(r=>{log$n.error("error updating addresses",r)})}getListenAddrs(){return Array.from(this.listen).map(t=>multiaddr(t))}getAnnounceAddrs(){return Array.from(this.announce).map(t=>multiaddr(t))}getObservedAddrs(){return Array.from(this.observed).map(([t])=>multiaddr(t))}addObservedAddr(t){t=stripPeerId(t,this.components.peerId);const r=t.toString();this.observed.has(r)||this.observed.set(r,{confident:!1})}confirmObservedAddr(t){t=stripPeerId(t,this.components.peerId);const r=t.toString(),o=(this.observed.get(r)??{confident:!1}).confident;this.observed.set(r,{confident:!0}),o||this._updatePeerStoreAddresses()}removeObservedAddr(t){t=stripPeerId(t,this.components.peerId);const r=t.toString();this.observed.delete(r)}getAddresses(){let t=this.getAnnounceAddrs().map(n=>n.toString());t.length===0&&(t=this.components.transportManager.getAddrs().map(n=>n.toString())),t=t.concat(Array.from(this.observed).filter(([n,o])=>o.confident).map(([n])=>n));const r=new Set(t);return this.announceFilter(Array.from(r).map(n=>multiaddr(n))).map(n=>n.protos().pop()?.path===!0||n.getPeerId()===this.components.peerId.toString()?n:n.encapsulate(`/p2p/${this.components.peerId.toString()}`))}}function isStartable(e){return e!=null&&typeof e.start=="function"&&typeof e.stop=="function"}class DefaultComponents{constructor(t={}){Xe(this,"components",{});Xe(this,"_started",!1);this.components={};for(const[r,n]of Object.entries(t))this.components[r]=n}isStarted(){return this._started}async _invokeStartableMethod(t){await Promise.all(Object.values(this.components).filter(r=>isStartable(r)).map(async r=>{await r[t]?.()}))}async beforeStart(){await this._invokeStartableMethod("beforeStart")}async start(){await this._invokeStartableMethod("start"),this._started=!0}async afterStart(){await this._invokeStartableMethod("afterStart")}async beforeStop(){await this._invokeStartableMethod("beforeStop")}async stop(){await this._invokeStartableMethod("stop"),this._started=!1}async afterStop(){await this._invokeStartableMethod("afterStop")}}const OPTIONAL_SERVICES=["metrics","connectionProtector"],NON_SERVICE_PROPERTIES=["components","isStarted","beforeStart","start","afterStart","beforeStop","stop","afterStop","then","_invokeStartableMethod"];function defaultComponents(e={}){const t=new DefaultComponents(e);return new Proxy(t,{get(n,o,a){if(typeof o=="string"&&!NON_SERVICE_PROPERTIES.includes(o)){const l=t.components[o];if(l==null&&!OPTIONAL_SERVICES.includes(o))throw new CodeError(`${o} not set`,"ERR_SERVICE_MISSING");return l}return Reflect.get(n,o,a)},set(n,o,a){return typeof o=="string"?t.components[o]=a:Reflect.set(n,o,a),!0}})}var Netmask_1;(function(){var e,t,r,n,o,a,l,c;c=function(u){var g,b,x,S;return g=(u&255<<24)>>>24,b=(u&255<<16)>>>16,x=(u&255<<8)>>>8,S=u&255,[g,b,x,S].join(".")},l=function(u){var g,b,x,S,$,k;for(g=[],x=S=0;S<=3&&u.length!==0;x=++S){if(x>0){if(u[0]!==".")throw new Error("Invalid IP");u=u.substring(1)}k=t(u),$=k[0],b=k[1],u=u.substring(b),g.push($)}if(u.length!==0)throw new Error("Invalid IP");switch(g.length){case 1:if(g[0]>4294967295)throw new Error("Invalid IP");return g[0]>>>0;case 2:if(g[0]>255||g[1]>16777215)throw new Error("Invalid IP");return(g[0]<<24|g[1])>>>0;case 3:if(g[0]>255||g[1]>255||g[2]>65535)throw new Error("Invalid IP");return(g[0]<<24|g[1]<<16|g[2])>>>0;case 4:if(g[0]>255||g[1]>255||g[2]>255||g[3]>255)throw new Error("Invalid IP");return(g[0]<<24|g[1]<<16|g[2]<<8|g[3])>>>0;default:throw new Error("Invalid IP")}},r=function(u){return u.charCodeAt(0)},n=r("0"),a=r("a"),o=r("A"),t=function(u){var g,b,x,S,$;for(S=0,g=10,b="9",x=0,u.length>1&&u[x]==="0"&&(u[x+1]==="x"||u[x+1]==="X"?(x+=2,g=16):"0"<=u[x+1]&&u[x+1]<="9"&&(x++,g=8,b="7")),$=x;x>>0;else if(g===16)if("a"<=u[x]&&u[x]<="f")S=S*g+(10+r(u[x])-a)>>>0;else if("A"<=u[x]&&u[x]<="F")S=S*g+(10+r(u[x])-o)>>>0;else break;else break;if(S>4294967295)throw new Error("too large");x++}if(x===$)throw new Error("empty octet");return[S,x]},e=function(){function u(g,b){var x,S,$;if(typeof g!="string")throw new Error("Missing `net' parameter");if(b||($=g.split("/",2),g=$[0],b=$[1]),b||(b=32),typeof b=="string"&&b.indexOf(".")>-1){try{this.maskLong=l(b)}catch{throw new Error("Invalid mask: "+b)}for(x=S=32;S>=0;x=--S)if(this.maskLong===4294967295<<32-x>>>0){this.bitmask=x;break}}else if(b||b===0)this.bitmask=parseInt(b,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(l(g)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+g)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+b);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return u.prototype.contains=function(g){return typeof g=="string"&&(g.indexOf("/")>0||g.split(".").length!==4)&&(g=new u(g)),g instanceof u?this.contains(g.base)&&this.contains(g.broadcast||g.last):(l(g)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},u.prototype.next=function(g){return g==null&&(g=1),new u(c(this.netLong+this.size*g),this.mask)},u.prototype.forEach=function(g){var b,x,S;for(S=l(this.first),x=l(this.last),b=0;S<=x;)g(c(S),S,b),b++,S++},u.prototype.toString=function(){return this.base+"/"+this.bitmask},u}(),Netmask_1=e}).call(commonjsGlobal$2);const word="[a-fA-F\\d:]",boundry=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))`:"",v4="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",v6segment="[a-fA-F\\d]{1,4}",v6=` (?: (?:${v6segment}:){7}(?:${v6segment}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8 (?:${v6segment}:){6}(?:${v4}|:${v6segment}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4 @@ -174,7 +174,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho (?::(?:(?::${v6segment}){0,5}:${v4}|(?::${v6segment}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4 )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1 `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),v46Exact=new RegExp(`(?:^${v4}$)|(?:^${v6}$)`),v4exact=new RegExp(`^${v4}$`),v6exact=new RegExp(`^${v6}$`),ipRegex=e=>e&&e.exact?v46Exact:new RegExp(`(?:${boundry(e)}${v4}${boundry(e)})|(?:${boundry(e)}${v6}${boundry(e)})`,"g");ipRegex.v4=e=>e&&e.exact?v4exact:new RegExp(`${boundry(e)}${v4}${boundry(e)}`,"g");ipRegex.v6=e=>e&&e.exact?v6exact:new RegExp(`${boundry(e)}${v6}${boundry(e)}`,"g");var ipaddr$1={exports:{}};(function(e){(function(t){const r="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${r}\\.${r}\\.${r}\\.${r}$`,"i"),threeOctet:new RegExp(`^${r}\\.${r}\\.${r}$`,"i"),twoOctet:new RegExp(`^${r}\\.${r}$`,"i"),longValue:new RegExp(`^${r}$`,"i")},o=new RegExp("^0[0-7]+$","i"),a=new RegExp("^0x[a-f0-9]+$","i"),l="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",u={zoneIndex:new RegExp(l,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${l})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${r}\\.${r}\\.${r}\\.${r}(${l})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${r}\\.${r}\\.${r}\\.${r}(${l})?$`,"i")};function g(k,T){if(k.indexOf("::")!==k.lastIndexOf("::"))return null;let D=0,I=-1,O=(k.match(u.zoneIndex)||[])[0],N,ee;for(O&&(O=O.substring(1),k=k.replace(/%.+$/,""));(I=k.indexOf(":",I+1))>=0;)D++;if(k.substr(0,2)==="::"&&D--,k.substr(-2,2)==="::"&&D--,D>T)return null;for(ee=T-D,N=":";ee--;)N+="0:";return k=k.replace("::",N),k[0]===":"&&(k=k.slice(1)),k[k.length-1]===":"&&(k=k.slice(0,-1)),T=function(){const ne=k.split(":"),B=[];for(let le=0;le0;){if(N=D-I,N<0&&(N=0),k[O]>>N!==T[O]>>N)return!1;I-=D,O+=1}return!0}function x(k){if(a.test(k))return parseInt(k,16);if(k[0]==="0"&&!isNaN(parseInt(k[1],10))){if(o.test(k))return parseInt(k,8);throw new Error(`ipaddr: cannot parse ${k} as octal`)}return parseInt(k,10)}function S(k,T){for(;k.length=0;O-=1)if(N=this.octets[O],N in I){if(ee=I[N],D&&ee!==0)return null;ee!==8&&(D=!0),T+=ee}else return null;return 32-T},k.prototype.range=function(){return $.subnetMatch(this,this.SpecialRanges)},k.prototype.toByteArray=function(){return this.octets.slice(0)},k.prototype.toIPv4MappedAddress=function(){return $.IPv6.parse(`::ffff:${this.toString()}`)},k.prototype.toNormalizedString=function(){return this.toString()},k.prototype.toString=function(){return this.octets.join(".")},k}(),$.IPv4.broadcastAddressFromCIDR=function(k){try{const T=this.parseCIDR(k),D=T[0].toByteArray(),I=this.subnetMaskFromPrefixLength(T[1]).toByteArray(),O=[];let N=0;for(;N<4;)O.push(parseInt(D[N],10)|parseInt(I[N],10)^255),N++;return new this(O)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},$.IPv4.isIPv4=function(k){return this.parser(k)!==null},$.IPv4.isValid=function(k){try{return new this(this.parser(k)),!0}catch{return!1}},$.IPv4.isValidFourPartDecimal=function(k){return!!($.IPv4.isValid(k)&&k.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},$.IPv4.networkAddressFromCIDR=function(k){let T,D,I,O,N;try{for(T=this.parseCIDR(k),I=T[0].toByteArray(),N=this.subnetMaskFromPrefixLength(T[1]).toByteArray(),O=[],D=0;D<4;)O.push(parseInt(I[D],10)&parseInt(N[D],10)),D++;return new this(O)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},$.IPv4.parse=function(k){const T=this.parser(k);if(T===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(T)},$.IPv4.parseCIDR=function(k){let T;if(T=k.match(/^(.+)\/(\d+)$/)){const D=parseInt(T[2]);if(D>=0&&D<=32){const I=[this.parse(T[1]),D];return Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},$.IPv4.parser=function(k){let T,D,I;if(T=k.match(n.fourOctet))return function(){const O=T.slice(1,6),N=[];for(let ee=0;ee4294967295||I<0)throw new Error("ipaddr: address outside defined range");return function(){const O=[];let N;for(N=0;N<=24;N+=8)O.push(I>>N&255);return O}().reverse()}else return(T=k.match(n.twoOctet))?function(){const O=T.slice(1,4),N=[];if(I=x(O[1]),I>16777215||I<0)throw new Error("ipaddr: address outside defined range");return N.push(x(O[0])),N.push(I>>16&255),N.push(I>>8&255),N.push(I&255),N}():(T=k.match(n.threeOctet))?function(){const O=T.slice(1,5),N=[];if(I=x(O[2]),I>65535||I<0)throw new Error("ipaddr: address outside defined range");return N.push(x(O[0])),N.push(x(O[1])),N.push(I>>8&255),N.push(I&255),N}():null},$.IPv4.subnetMaskFromPrefixLength=function(k){if(k=parseInt(k),k<0||k>32)throw new Error("ipaddr: invalid IPv4 prefix length");const T=[0,0,0,0];let D=0;const I=Math.floor(k/8);for(;D=0;ee-=1)if(O=this.parts[ee],O in I){if(N=I[O],D&&N!==0)return null;N!==16&&(D=!0),T+=N}else return null;return 128-T},k.prototype.range=function(){return $.subnetMatch(this,this.SpecialRanges)},k.prototype.toByteArray=function(){let T;const D=[],I=this.parts;for(let O=0;O>8),D.push(T&255);return D},k.prototype.toFixedLengthString=function(){const T=function(){const I=[];for(let O=0;O>8,D&255,I>>8,I&255])},k.prototype.toNormalizedString=function(){const T=function(){const I=[];for(let O=0;OO&&(I=N.index,O=N[0].length);return O<0?D:`${D.substring(0,I)}::${D.substring(I+O)}`},k.prototype.toString=function(){return this.toRFC5952String()},k}(),$.IPv6.broadcastAddressFromCIDR=function(k){try{const T=this.parseCIDR(k),D=T[0].toByteArray(),I=this.subnetMaskFromPrefixLength(T[1]).toByteArray(),O=[];let N=0;for(;N<16;)O.push(parseInt(D[N],10)|parseInt(I[N],10)^255),N++;return new this(O)}catch(T){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${T})`)}},$.IPv6.isIPv6=function(k){return this.parser(k)!==null},$.IPv6.isValid=function(k){if(typeof k=="string"&&k.indexOf(":")===-1)return!1;try{const T=this.parser(k);return new this(T.parts,T.zoneId),!0}catch{return!1}},$.IPv6.networkAddressFromCIDR=function(k){let T,D,I,O,N;try{for(T=this.parseCIDR(k),I=T[0].toByteArray(),N=this.subnetMaskFromPrefixLength(T[1]).toByteArray(),O=[],D=0;D<16;)O.push(parseInt(I[D],10)&parseInt(N[D],10)),D++;return new this(O)}catch(ee){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${ee})`)}},$.IPv6.parse=function(k){const T=this.parser(k);if(T.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(T.parts,T.zoneId)},$.IPv6.parseCIDR=function(k){let T,D,I;if((D=k.match(/^(.+)\/(\d+)$/))&&(T=parseInt(D[2]),T>=0&&T<=128))return I=[this.parse(D[1]),T],Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},$.IPv6.parser=function(k){let T,D,I,O,N,ee;if(I=k.match(u.deprecatedTransitional))return this.parser(`::ffff:${I[1]}`);if(u.native.test(k))return g(k,8);if((I=k.match(u.transitional))&&(ee=I[6]||"",T=g(I[1].slice(0,-1)+ee,6),T.parts)){for(N=[parseInt(I[2]),parseInt(I[3]),parseInt(I[4]),parseInt(I[5])],D=0;D128)throw new Error("ipaddr: invalid IPv6 prefix length");const T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let D=0;const I=Math.floor(k/8);for(;Dnew Netmask_1(e));function ipv4_check(e){for(let t of NETMASK_RANGES)if(t.contains(e))return!0;return!1}function ipv6_check(e){return/^::$/.test(e)||/^::1$/.test(e)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(e)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(e)||/^ff([0-9a-fA-F]{2,2}):/i.test(e)}const is_ip_private=e=>{if(is_valid(e)){const t=parse$6(e);if(t.kind()==="ipv4")return ipv4_check(t.toNormalizedString());if(t.kind()==="ipv6")return ipv6_check(e)}else if(isIP(e)&&ipRegex.v6().test(e))return ipv6_check(e)};function connectionGater(e={}){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async t=>{const r=t.stringTuples();return r[0][0]===4||r[0][0]===41?Boolean(is_ip_private(`${r[0][1]}`)):!1},denyInboundConnection:async()=>!1,denyOutboundConnection:async()=>!1,denyInboundEncryptedConnection:async()=>!1,denyOutboundEncryptedConnection:async()=>!1,denyInboundUpgradedConnection:async()=>!1,denyOutboundUpgradedConnection:async()=>!1,filterMultiaddrForPeer:async()=>!0,...e}}const toParts=e=>e.toString().split("/").slice(1),func=e=>({match:t=>t.length<1?!1:e(t[0])?t.slice(1):!1,pattern:"fn"}),literal=e=>({match:t=>func(r=>r===e).match(t),pattern:e}),string=()=>({match:e=>func(t=>typeof t=="string").match(e),pattern:"{string}"}),number$1=()=>({match:e=>func(t=>!isNaN(parseInt(t))).match(e),pattern:"{number}"}),peerId=()=>({match:e=>{if(e.length<2||e[0]!=="p2p"&&e[0]!=="ipfs")return!1;if(e[1].startsWith("Q")||e[1].startsWith("1"))try{base58btc$1.decode(`z${e[1]}`)}catch{return!1}else return!1;return e.slice(2)},pattern:"/p2p/{peerid}"}),certhash=()=>({match:e=>{if(e.length<2||e[0]!=="certhash")return!1;try{base64url$1.decode(e[1])}catch{return!1}return e.slice(2)},pattern:"/certhash/{certhash}"}),optional=e=>({match:t=>{const r=e.match(t);return r===!1?t:r},pattern:`optional(${e.pattern})`}),or=(...e)=>({match:t=>{let r;for(const n of e){const o=n.match(t);o!==!1&&(r==null||o.lengtht.pattern).join(", ")})`}),and=(...e)=>({match:t=>{for(const r of e){const n=r.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${e.map(t=>t.pattern).join(", ")})`});function fmt(...e){function t(o){let a=toParts(o);for(const l of e){const c=l.match(a);if(c===!1)return!1;a=c}return a}function r(o){return t(o)!==!1}function n(o){const a=t(o);return a===!1?!1:a.length===0}return{matches:r,exactMatch:n}}const _DNS4=and(literal("dns4"),string()),_DNS6=and(literal("dns6"),string()),_DNSADDR=and(literal("dnsaddr"),string()),_DNS=and(literal("dns"),string());fmt(or(_DNS,_DNSADDR,_DNS4,_DNS6));const _IP4=and(literal("ip4"),func(isIPv4)),_IP6=and(literal("ip6"),func(isIPv6)),_IP=or(_IP4,_IP6),IP_OR_DOMAIN=or(_IP,_DNS,_DNS4,_DNS6,_DNSADDR),_TCP=and(IP_OR_DOMAIN,literal("tcp"),number$1()),_UDP=and(IP_OR_DOMAIN,literal("udp"),number$1()),TCP_OR_UDP=or(_TCP,_UDP),_QUIC=and(_UDP,literal("quic")),_QUICV1=and(_UDP,literal("quic-v1")),QUIC_V0_OR_V1=or(_QUIC,_QUICV1),_WEB=or(IP_OR_DOMAIN,_TCP,_UDP,_QUIC,_QUICV1),_WebSockets=or(and(_WEB,literal("ws"),optional(peerId()))),_WebSocketsSecure=or(and(_WEB,literal("wss"),optional(peerId())),and(_WEB,literal("tls"),literal("ws"),optional(peerId()))),_WebRTCDirect=and(TCP_OR_UDP,literal("webrtc-direct"),certhash(),optional(certhash()),optional(peerId())),_WebTransport=and(_QUICV1,literal("webtransport"),certhash(),certhash(),optional(peerId())),_P2P=or(_WebSockets,_WebSocketsSecure,and(_TCP,optional(peerId())),and(QUIC_V0_OR_V1,optional(peerId())),and(IP_OR_DOMAIN,optional(peerId())),_WebRTCDirect,_WebTransport,peerId()),_Circuit=and(_P2P,literal("p2p-circuit"),peerId()),Circuit=fmt(_Circuit);or(and(_P2P,literal("p2p-circuit"),literal("webrtc"),peerId()),and(_P2P,literal("webrtc"),optional(peerId())),literal("webrtc"));function isPrivate(e){try{const{address:t}=e.nodeAddress();return Boolean(is_ip_private(t))}catch{return!0}}function publicAddressesFirst(e,t){const r=isPrivate(e.multiaddr),n=isPrivate(t.multiaddr);return r&&!n?1:!r&&n?-1:0}function certifiedAddressesFirst(e,t){return e.isCertified&&!t.isCertified?-1:!e.isCertified&&t.isCertified?1:0}function circuitRelayAddressesLast(e,t){const r=Circuit.exactMatch(e.multiaddr),n=Circuit.exactMatch(t.multiaddr);return r&&!n?1:!r&&n?-1:0}function defaultAddressSort(e,t){const r=publicAddressesFirst(e,t);if(r!==0)return r;const n=circuitRelayAddressesLast(e,t);return n!==0?n:certifiedAddressesFirst(e,t)}var s$3=1e3,m$4=s$3*60,h$4=m$4*60,d$5=h$4*24,w$2=d$5*7,y$3=d$5*365.25,ms$3=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return parse$5(e);if(r==="number"&&isFinite(e))return t.long?fmtLong$3(e):fmtShort$3(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse$5(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!!t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*y$3;case"weeks":case"week":case"w":return r*w$2;case"days":case"day":case"d":return r*d$5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*h$4;case"minutes":case"minute":case"mins":case"min":case"m":return r*m$4;case"seconds":case"second":case"secs":case"sec":case"s":return r*s$3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function fmtShort$3(e){var t=Math.abs(e);return t>=d$5?Math.round(e/d$5)+"d":t>=h$4?Math.round(e/h$4)+"h":t>=m$4?Math.round(e/m$4)+"m":t>=s$3?Math.round(e/s$3)+"s":e+"ms"}function fmtLong$3(e){var t=Math.abs(e);return t>=d$5?plural$3(e,t,d$5,"day"):t>=h$4?plural$3(e,t,h$4,"hour"):t>=m$4?plural$3(e,t,m$4,"minute"):t>=s$3?plural$3(e,t,s$3,"second"):e+" ms"}function plural$3(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}var receptacle=Receptacle,toMS=ms$3,cache$1=Receptacle.prototype,counter=new Date%1e9;function getUID(){return(Math.random()*1e9>>>0)+counter++}function Receptacle(e){e=e||{},this.id=e.id||getUID(),this.max=e.max||1/0,this.items=e.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(e.lastModified||new Date);for(var t,r,n=this.items.length;n--;)t=this.items[n],r=new Date(t.expires)-new Date,this._lookup[t.key]=t,r>0?this.expire(t.key,r):r<=0&&this.delete(t.key)}cache$1.has=function(e){return e in this._lookup};cache$1.get=function(e){if(!this.has(e))return null;var t=this._lookup[e];return t.refresh&&this.expire(e,t.refresh),this.items.splice(this.items.indexOf(t),1),this.items.push(t),t.value};cache$1.meta=function(e){if(!this.has(e))return null;var t=this._lookup[e];return"meta"in t?t.meta:null};cache$1.set=function(e,t,r){var n=this._lookup[e],o=this._lookup[e]={key:e,value:t};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,o)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(o),this.size++),r&&("ttl"in r&&this.expire(e,r.ttl),"meta"in r&&(o.meta=r.meta),r.refresh&&(o.refresh=r.ttl)),this};cache$1.delete=function(e){var t=this._lookup[e];return t?(this.lastModified=new Date,this.items.splice(this.items.indexOf(t),1),clearTimeout(t.timeout),delete this._lookup[e],this.size--,this):!1};cache$1.expire=function(e,t){var r=t||0,n=this._lookup[e];if(!n)return this;if(typeof r=="string"&&(r=toMS(t)),typeof r!="number")throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),r),n.expires=Number(new Date)+r,this};cache$1.clear=function(){for(var e=this.items.length;e--;)this.delete(this.items[e].key);return this};cache$1.toJSON=function(){for(var e=new Array(this.items.length),t,r=e.length;r--;)t=this.items[r],e[r]={key:t.key,meta:t.meta,value:t.value,expires:t.expires,refresh:t.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:e}};const globalFetch=globalThis.fetch,globalHeaders=globalThis.Headers;function buildResource(e,t,r){return`${e}?name=${t}&type=${r}`}async function request(e,t){return await(await globalFetch(e,{headers:new globalHeaders({accept:"application/dns-json"}),signal:t})).json()}function getCacheKey(e,t){return`${t}_${e}`}const log$m=Object.assign(debug$9("dns-over-http-resolver"),{error:debug$9("dns-over-http-resolver:error")});class Resolver{constructor(t={}){this._cache=new receptacle({max:t?.maxCache??100}),this._TXTcache=new receptacle({max:t?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=t.request??request,this._abortControllers=[]}cancel(){this._abortControllers.forEach(t=>t.abort())}getServers(){return this._servers}_getShuffledServers(){const t=[...this._servers];for(let r=t.length-1;r>0;r--){const n=Math.floor(Math.random()*r),o=t[r];t[r]=t[n],t[n]=o}return t}setServers(t){this._servers=t}async resolve(t,r="A"){switch(r){case"A":return await this.resolve4(t);case"AAAA":return await this.resolve6(t);case"TXT":return await this.resolveTxt(t);default:throw new Error(`${r} is not supported`)}}async resolve4(t){const r="A",n=this._cache.get(getCacheKey(t,r));if(n!=null)return n;let o=!1;for(const a of this._getShuffledServers()){const l=new AbortController;this._abortControllers.push(l);try{const c=await this._request(buildResource(a,t,r),l.signal),u=c.Answer.map(b=>b.data),g=Math.min(...c.Answer.map(b=>b.TTL));return this._cache.set(getCacheKey(t,r),u,{ttl:g}),u}catch{l.signal.aborted&&(o=!0),log$m.error(`${a} could not resolve ${t} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(c=>c!==l)}}throw o?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${t} record ${r}`)}async resolve6(t){const r="AAAA",n=this._cache.get(getCacheKey(t,r));if(n!=null)return n;let o=!1;for(const a of this._getShuffledServers()){const l=new AbortController;this._abortControllers.push(l);try{const c=await this._request(buildResource(a,t,r),l.signal),u=c.Answer.map(b=>b.data),g=Math.min(...c.Answer.map(b=>b.TTL));return this._cache.set(getCacheKey(t,r),u,{ttl:g}),u}catch{l.signal.aborted&&(o=!0),log$m.error(`${a} could not resolve ${t} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(c=>c!==l)}}throw o?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${t} record ${r}`)}async resolveTxt(t){const r="TXT",n=this._TXTcache.get(getCacheKey(t,r));if(n!=null)return n;let o=!1;for(const a of this._getShuffledServers()){const l=new AbortController;this._abortControllers.push(l);try{const c=await this._request(buildResource(a,t,r),l.signal),u=c.Answer.map(b=>[b.data.replace(/['"]+/g,"")]),g=Math.min(...c.Answer.map(b=>b.TTL));return this._TXTcache.set(getCacheKey(t,r),u,{ttl:g}),u}catch{l.signal.aborted&&(o=!0),log$m.error(`${a} could not resolve ${t} record ${r}`)}finally{this._abortControllers=this._abortControllers.filter(c=>c!==l)}}throw o?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${t} record ${r}`)}clearCache(){this._cache.clear(),this._TXTcache.clear()}}const{code:dnsaddrCode}=getProtocol("dnsaddr");async function dnsaddrResolver(e,t={}){const r=new Resolver;t.signal!=null&&t.signal.addEventListener("abort",()=>{r.cancel()});const n=e.getPeerId(),[,o]=e.stringTuples().find(([c])=>c===dnsaddrCode)??[];if(o==null)throw new Error("No hostname found in multiaddr");let l=(await r.resolveTxt(`_dnsaddr.${o}`)).flat().map(c=>c.split("=")[1]).filter(Boolean);return n!=null&&(l=l.filter(c=>c.includes(n))),l}var messages$1;(function(e){e.NOT_STARTED_YET="The libp2p node is not started yet",e.DHT_DISABLED="DHT is not available",e.PUBSUB_DISABLED="PubSub is not available",e.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",e.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",e.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",e.NOT_FOUND="Not found"})(messages$1||(messages$1={}));var codes;(function(e){e.DHT_DISABLED="ERR_DHT_DISABLED",e.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",e.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",e.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",e.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",e.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",e.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",e.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",e.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",e.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",e.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",e.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",e.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",e.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",e.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",e.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",e.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",e.ERR_DIALED_SELF="ERR_DIALED_SELF",e.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",e.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",e.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",e.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",e.ERR_INVALID_KEY="ERR_INVALID_KEY",e.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",e.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",e.ERR_INVALID_PEER="ERR_INVALID_PEER",e.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",e.ERR_NOT_FOUND="ERR_NOT_FOUND",e.ERR_TIMEOUT="ERR_TIMEOUT",e.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",e.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",e.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",e.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",e.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",e.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",e.ERR_FIND_SELF="ERR_FIND_SELF",e.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",e.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",e.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",e.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",e.ERR_INVALID_CMS="ERR_INVALID_CMS",e.ERR_MISSING_KEYS="ERR_MISSING_KEYS",e.ERR_NO_KEY="ERR_NO_KEY",e.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",e.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",e.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",e.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",e.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",e.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",e.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",e.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",e.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",e.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",e.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",e.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",e.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",e.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",e.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",e.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",e.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",e.ERR_INVALID_RECORD="ERR_INVALID_RECORD",e.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",e.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",e.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",e.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",e.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED",e.ERR_TRANSFER_LIMIT_EXCEEDED="ERR_TRANSFER_LIMIT_EXCEEDED"})(codes||(codes={}));const DefaultConfig={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:e=>e},connectionManager:{resolvers:{dnsaddr:dnsaddrResolver},addressSorter:defaultAddressSort},transportManager:{faultTolerance:FaultTolerance.FATAL_ALL}};function validateConfig(e){const t=mergeOptions(DefaultConfig,e);if(t.transports==null||t.transports.length<1)throw new CodeError(messages$1.ERR_TRANSPORTS_REQUIRED,codes.ERR_TRANSPORTS_REQUIRED);if(t.connectionProtector===null&&globalThis.process?.env?.LIBP2P_FORCE_PNET!=null)throw new CodeError(messages$1.ERR_PROTECTOR_REQUIRED,codes.ERR_PROTECTOR_REQUIRED);return t}const KEEP_ALIVE="keep-alive",log$l=logger("libp2p:get-peer");function getPeerAddress(e){if(isPeerId(e))return{peerId:e,multiaddrs:[]};Array.isArray(e)||(e=[e]);let t;if(e.length>0){const r=e[0].getPeerId();t=r==null?void 0:peerIdFromString(r),e.forEach(n=>{if(!isMultiaddr(n))throw log$l.error("multiaddr %s was invalid",n),new CodeError("Invalid Multiaddr",codes.ERR_INVALID_MULTIADDR);const o=n.getPeerId();if(o==null){if(t!=null)throw new CodeError("Multiaddrs must all have the same peer id or have no peer id",codes.ERR_INVALID_PARAMETERS)}else{const a=peerIdFromString(o);if(t==null||!t.equals(a))throw new CodeError("Multiaddrs must all have the same peer id or have no peer id",codes.ERR_INVALID_PARAMETERS)}})}return{peerId:t,multiaddrs:e}}function lowerBound(e,t,r){let n=0,o=e.length;for(;o>0;){const a=Math.trunc(o/2);let l=n+a;r(e[l],t)<=0?(n=++l,o-=a+1):o=a}return n}var Gr;class PeerPriorityQueue{constructor(){Er(this,Gr,[])}enqueue(t,r){const n=r?.peerId,o=r?.priority??0;if(n==null)throw new CodeError("missing peer id",codes.ERR_INVALID_PARAMETERS);const a={priority:o,peerId:n,run:t};if(this.size>0&&ir(this,Gr)[this.size-1].priority>=o){ir(this,Gr).push(a);return}const l=lowerBound(ir(this,Gr),a,(c,u)=>u.priority-c.priority);ir(this,Gr).splice(l,0,a)}dequeue(){return ir(this,Gr).shift()?.run}filter(t){if(t.peerId!=null){const r=t.peerId;return ir(this,Gr).filter(n=>r.equals(n.peerId)).map(n=>n.run)}return ir(this,Gr).filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return ir(this,Gr).length}}Gr=new WeakMap;class PeerJobQueue extends PQueue{constructor(t={}){super({...t,queueClass:PeerPriorityQueue})}hasJob(t){return this.sizeBy({peerId:t})>0}}const DIAL_TIMEOUT=3e4,INBOUND_UPGRADE_TIMEOUT=3e4,MAX_PEER_ADDRS_TO_DIAL=25,MAX_PARALLEL_DIALS_PER_PEER=1,AUTO_DIAL_INTERVAL=5e3,AUTO_DIAL_CONCURRENCY=25,AUTO_DIAL_PRIORITY=0,AUTO_DIAL_MAX_QUEUE_LENGTH=100,AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE=10,INBOUND_CONNECTION_THRESHOLD=5,MAX_INCOMING_PENDING_CONNECTIONS=10,LAST_DIAL_FAILURE_KEY="last-dial-failure",MIN_CONNECTIONS=5,MAX_CONNECTIONS=100,MAX_PARALLEL_DIALS=50,AUTO_DIAL_PEER_RETRY_THRESHOLD=1e3*60*7,log$k=logger("libp2p:connection-manager:auto-dial"),defaultOptions$3={minConnections:MIN_CONNECTIONS,maxQueueLength:AUTO_DIAL_MAX_QUEUE_LENGTH,autoDialConcurrency:AUTO_DIAL_CONCURRENCY,autoDialPriority:AUTO_DIAL_PRIORITY,autoDialInterval:AUTO_DIAL_INTERVAL,autoDialPeerRetryThreshold:AUTO_DIAL_PEER_RETRY_THRESHOLD,autoDialDiscoveredPeersDebounce:AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE};class AutoDial{constructor(t,r){Xe(this,"connectionManager");Xe(this,"peerStore");Xe(this,"queue");Xe(this,"minConnections");Xe(this,"autoDialPriority");Xe(this,"autoDialIntervalMs");Xe(this,"autoDialMaxQueueLength");Xe(this,"autoDialPeerRetryThresholdMs");Xe(this,"autoDialDiscoveredPeersDebounce");Xe(this,"autoDialInterval");Xe(this,"started");Xe(this,"running");this.connectionManager=t.connectionManager,this.peerStore=t.peerStore,this.minConnections=r.minConnections??defaultOptions$3.minConnections,this.autoDialPriority=r.autoDialPriority??defaultOptions$3.autoDialPriority,this.autoDialIntervalMs=r.autoDialInterval??defaultOptions$3.autoDialInterval,this.autoDialMaxQueueLength=r.maxQueueLength??defaultOptions$3.maxQueueLength,this.autoDialPeerRetryThresholdMs=r.autoDialPeerRetryThreshold??defaultOptions$3.autoDialPeerRetryThreshold,this.autoDialDiscoveredPeersDebounce=r.autoDialDiscoveredPeersDebounce??defaultOptions$3.autoDialDiscoveredPeersDebounce,this.started=!1,this.running=!1,this.queue=new PeerJobQueue({concurrency:r.autoDialConcurrency??defaultOptions$3.autoDialConcurrency}),this.queue.addListener("error",o=>{log$k.error("error during auto-dial",o)}),t.events.addEventListener("connection:close",()=>{this.autoDial().catch(o=>{log$k.error(o)})});let n;t.events.addEventListener("peer:discovery",()=>{clearTimeout(n),n=setTimeout(()=>{this.autoDial().catch(o=>{log$k.error(o)})},this.autoDialDiscoveredPeersDebounce)})}isStarted(){return this.started}start(){this.autoDialInterval=setTimeout(()=>{this.autoDial().catch(t=>{log$k.error("error while autodialing",t)})},this.autoDialIntervalMs),this.started=!0}afterStart(){this.autoDial().catch(t=>{log$k.error("error while autodialing",t)})}stop(){this.queue.clear(),clearTimeout(this.autoDialInterval),this.started=!1,this.running=!1}async autoDial(){if(!this.started)return;const t=this.connectionManager.getConnectionsMap(),r=t.size;if(r>=this.minConnections){this.minConnections>0&&log$k.trace("have enough connections %d/%d",r,this.minConnections);return}if(this.queue.size>this.autoDialMaxQueueLength){log$k("not enough connections %d/%d but auto dial queue is full",r,this.minConnections);return}if(this.running){log$k("not enough connections %d/%d - but skipping autodial as it is already running",r,this.minConnections);return}this.running=!0,log$k("not enough connections %d/%d - will dial peers to increase the number of connections",r,this.minConnections);const n=new PeerSet(this.connectionManager.getDialQueue().map(g=>g.peerId).filter(Boolean)),o=await this.peerStore.all({filters:[g=>g.addresses.length===0?(log$k.trace("not autodialing %p because they have no addresses"),!1):t.has(g.id)?(log$k.trace("not autodialing %p because they are already connected"),!1):n.has(g.id)?(log$k.trace("not autodialing %p because they are already being dialed"),!1):this.queue.hasJob(g.id)?(log$k.trace("not autodialing %p because they are already being autodialed"),!1):!0]}),a=o.sort(()=>Math.random()>.5?1:-1),l=new PeerMap;for(const g of a)l.has(g.id)||l.set(g.id,[...g.tags.values()].reduce((b,x)=>b+x.value,0));const u=a.sort((g,b)=>{const x=l.get(g.id)??0,S=l.get(b.id)??0;return x>S?-1:x{const b=g.metadata.get(LAST_DIAL_FAILURE_KEY);if(b==null)return!0;const x=parseInt(toString$5(b));return isNaN(x)?!0:Date.now()-x>this.autoDialPeerRetryThresholdMs});log$k("selected %d/%d peers to dial",u.length,o.length);for(const g of u)this.queue.add(async()=>{const b=this.connectionManager.getConnectionsMap().size;if(b>=this.minConnections){log$k("got enough connections now %d/%d",b,this.minConnections),this.queue.clear();return}log$k("connecting to a peerStore stored peer %p",g.id),await this.connectionManager.openConnection(g.id,{priority:this.autoDialPriority})},{peerId:g.id}).catch(b=>{log$k.error("could not connect to peerStore stored peer",b)});this.running=!1,this.started&&(this.autoDialInterval=setTimeout(()=>{this.autoDial().catch(g=>{log$k.error("error while autodialing",g)})},this.autoDialIntervalMs))}}const log$j=logger("libp2p:connection-manager:connection-pruner"),defaultOptions$2={maxConnections:MAX_CONNECTIONS,allow:[]};class ConnectionPruner{constructor(t,r={}){Xe(this,"maxConnections");Xe(this,"connectionManager");Xe(this,"peerStore");Xe(this,"allow");Xe(this,"events");this.maxConnections=r.maxConnections??defaultOptions$2.maxConnections,this.allow=r.allow??defaultOptions$2.allow,this.connectionManager=t.connectionManager,this.peerStore=t.peerStore,this.events=t.events,t.events.addEventListener("connection:open",()=>{this.maybePruneConnections().catch(n=>{log$j.error(n)})})}async maybePruneConnections(){const t=this.connectionManager.getConnections(),r=t.length,n=Math.max(r-this.maxConnections,0);if(log$j("checking max connections limit %d/%d",r,this.maxConnections),r<=this.maxConnections)return;log$j("max connections limit exceeded %d/%d, pruning %d connection(s)",r,this.maxConnections,n);const o=new PeerMap;for(const c of t){const u=c.remotePeer;if(!o.has(u)){o.set(u,0);try{const g=await this.peerStore.get(u);o.set(u,[...g.tags.values()].reduce((b,x)=>b+x.value,0))}catch(g){g.code!=="ERR_NOT_FOUND"&&log$j.error("error loading peer tags",g)}}}const a=t.sort((c,u)=>{const g=o.get(c.remotePeer)??0,b=o.get(u.remotePeer)??0;if(g>b)return 1;if(gS?-1:0}),l=[];for(const c of a)if(log$j("too many connections open - closing a connection to %p",c.remotePeer),this.allow.some(g=>c.remoteAddr.toString().startsWith(g.toString()))||l.push(c),l.length===n)break;await Promise.all(l.map(async c=>{try{await c.close()}catch(u){log$j.error(u)}})),this.events.safeDispatchEvent("connection:prune",{detail:l})}}function anySignal(e){const t=new globalThis.AbortController;function r(){t.abort();for(const a of e)a?.removeEventListener!=null&&a.removeEventListener("abort",r)}for(const a of e){if(a?.aborted===!0){r();break}a?.addEventListener!=null&&a.addEventListener("abort",r)}function n(){for(const a of e)a?.removeEventListener!=null&&a.removeEventListener("abort",r)}const o=t.signal;return o.clear=n,o}const log$i=logger("libp2p:connection-manager:utils");async function resolveMultiaddrs(e,t){if(!e.protoNames().includes("dnsaddr"))return[e];const n=await resolveRecord(e,t),l=(await Promise.all(n.map(async c=>resolveMultiaddrs(c,t)))).flat().reduce((c,u)=>(c.find(g=>g.equals(u))==null&&c.push(u),c),[]);return log$i("resolved %s to",e,l.map(c=>c.toString())),l}async function resolveRecord(e,t){try{return e=multiaddr(e.toString()),await e.resolve(t)}catch(r){return log$i.error(`multiaddr ${e.toString()} could not be resolved`,r),[]}}function combineSignals(...e){const t=[];for(const n of e)if(n!=null){try{events$1.exports.setMaxListeners?.(1/0,n)}catch{}t.push(n)}const r=anySignal(t);try{events$1.exports.setMaxListeners?.(1/0,r)}catch{}return r}const log$h=logger("libp2p:connection-manager:dial-queue"),defaultOptions$1={addressSorter:defaultAddressSort,maxParallelDials:MAX_PARALLEL_DIALS,maxPeerAddrsToDial:MAX_PEER_ADDRS_TO_DIAL,maxParallelDialsPerPeer:MAX_PARALLEL_DIALS_PER_PEER,dialTimeout:DIAL_TIMEOUT,resolvers:{dnsaddr:dnsaddrResolver}};class DialQueue{constructor(t,r={}){Xe(this,"pendingDials");Xe(this,"queue");Xe(this,"peerId");Xe(this,"peerStore");Xe(this,"connectionGater");Xe(this,"transportManager");Xe(this,"addressSorter");Xe(this,"maxPeerAddrsToDial");Xe(this,"maxParallelDialsPerPeer");Xe(this,"dialTimeout");Xe(this,"inProgressDialCount");Xe(this,"pendingDialCount");Xe(this,"shutDownController");this.addressSorter=r.addressSorter??defaultOptions$1.addressSorter,this.maxPeerAddrsToDial=r.maxPeerAddrsToDial??defaultOptions$1.maxPeerAddrsToDial,this.maxParallelDialsPerPeer=r.maxParallelDialsPerPeer??defaultOptions$1.maxParallelDialsPerPeer,this.dialTimeout=r.dialTimeout??defaultOptions$1.dialTimeout,this.peerId=t.peerId,this.peerStore=t.peerStore,this.connectionGater=t.connectionGater,this.transportManager=t.transportManager,this.shutDownController=new AbortController;try{events$1.exports.setMaxListeners?.(1/0,this.shutDownController.signal)}catch{}this.pendingDialCount=t.metrics?.registerMetric("libp2p_dialler_pending_dials"),this.inProgressDialCount=t.metrics?.registerMetric("libp2p_dialler_in_progress_dials"),this.pendingDials=[];for(const[n,o]of Object.entries(r.resolvers??{}))resolvers.set(n,o);this.queue=new PQueue({concurrency:r.maxParallelDials??defaultOptions$1.maxParallelDials}),this.queue.on("add",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("active",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("completed",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("error",n=>{log$h.error("error in dial queue",n),this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("empty",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("idle",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)})}stop(){this.shutDownController.abort()}async dial(t,r={}){const{peerId:n,multiaddrs:o}=getPeerAddress(t),a=o.map(b=>({multiaddr:b,isCertified:!1})),l=this.createDialAbortControllers(r.signal);let c;try{c=await this.calculateMultiaddrs(n,a,{...r,signal:l})}catch(b){throw l.clear(),b}const u=this.pendingDials.find(b=>!!(b.peerId!=null&&n!=null&&b.peerId.equals(n)||c.map(({multiaddr:x})=>x.toString()).join()===b.multiaddrs.map(x=>x.toString()).join()));if(u!=null)return log$h("joining existing dial target for %p",n),l.clear(),u.promise;log$h("creating dial target for",c.map(({multiaddr:b})=>b.toString()));const g={id:randomId(),status:"queued",peerId:n,multiaddrs:c.map(({multiaddr:b})=>b)};return g.promise=this.performDial(g,{...r,signal:l}).finally(()=>{this.pendingDials=this.pendingDials.filter(b=>b.id!==g.id),l.clear()}).catch(async b=>{if(log$h.error("dial failed to %s",g.multiaddrs.map(x=>x.toString()).join(", "),b),n!=null)try{await this.peerStore.patch(n,{metadata:{[LAST_DIAL_FAILURE_KEY]:fromString$1(Date.now().toString())}})}catch(x){log$h.error("could not update last dial failure key for %p",n,x)}throw l.aborted?new CodeError(b.message,codes.ERR_TIMEOUT):b}),this.pendingDials.push(g),g.promise}createDialAbortControllers(t){const r=anySignal([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,t]);try{events$1.exports.setMaxListeners?.(1/0,r)}catch{}return r}async calculateMultiaddrs(t,r=[],n={}){if(t!=null){if(this.peerId.equals(t))throw new CodeError("Tried to dial self",codes.ERR_DIALED_SELF);if(await this.connectionGater.denyDialPeer?.(t)===!0)throw new CodeError("The dial request is blocked by gater.allowDialPeer",codes.ERR_PEER_DIAL_INTERCEPTED);if(r.length===0){log$h("loading multiaddrs for %p",t);try{const b=await this.peerStore.get(t);r.push(...b.addresses),log$h("loaded multiaddrs for %p",t,r.map(({multiaddr:x})=>x.toString()))}catch(b){if(b.code!==codes.ERR_NOT_FOUND)throw b}}}const o=(await Promise.all(r.map(async b=>{const x=await resolveMultiaddrs(b.multiaddr,n);return x.length===1&&x[0].equals(b.multiaddr)?b:x.map(S=>({multiaddr:S,isCertified:!1}))}))).flat(),a=o.filter(b=>{if(this.transportManager.transportForMultiaddr(b.multiaddr)==null)return!1;const x=b.multiaddr.getPeerId();return t!=null&&x!=null?t.equals(x):!0}),l=new Map;for(const b of a){const x=b.multiaddr.toString(),S=l.get(x);if(S!=null){S.isCertified=S.isCertified||b.isCertified||!1;continue}l.set(x,b)}let c=[...l.values()];if((c.length===0||c.length>this.maxPeerAddrsToDial)&&(log$h("addresses for %p before filtering",t??"unknown peer",o.map(({multiaddr:b})=>b.toString())),log$h("addresses for %p after filtering",t??"unknown peer",c.map(({multiaddr:b})=>b.toString()))),c.length===0)throw new CodeError("The dial request has no valid addresses",codes.ERR_NO_VALID_ADDRESSES);if(c.length>this.maxPeerAddrsToDial)throw new CodeError("dial with more addresses than allowed",codes.ERR_TOO_MANY_ADDRESSES);if(t!=null){const b=`/p2p/${t.toString()}`;c=c.map(x=>{const S=x.multiaddr.getPeerId();return x.multiaddr.protos().pop()?.path===!0?x:S!==t.toString()?{multiaddr:x.multiaddr.encapsulate(b),isCertified:x.isCertified}:x})}const u=[];for(const b of c)this.connectionGater.denyDialMultiaddr!=null&&await this.connectionGater.denyDialMultiaddr(b.multiaddr)||u.push(b);const g=u.sort(this.addressSorter);if(g.length===0)throw new CodeError("The connection gater denied all addresses in the dial request",codes.ERR_NO_VALID_ADDRESSES);return g}async performDial(t,r={}){const n=t.multiaddrs.map(()=>new AbortController);try{const o=new PQueue({concurrency:this.maxParallelDialsPerPeer});o.on("error",l=>{log$h.error("error dialling",l)});const a=await Promise.any(t.multiaddrs.map(async(l,c)=>{const u=n[c];if(u==null)throw new CodeError("dialAction did not come with an AbortController",codes.ERR_INVALID_PARAMETERS);const g=combineSignals(u.signal,r.signal);g.addEventListener("abort",()=>{log$h("dial to %a aborted",l)});const b=pDefer();return await o.add(async()=>{if(g.aborted){log$h("dial to %a was aborted before reaching the head of the peer dial queue",l),b.reject(new AbortError$4);return}await this.queue.add(async()=>{try{if(g.aborted){log$h("dial to %a was aborted before reaching the head of the dial queue",l),b.reject(new AbortError$4);return}t.status="active";const x=await this.transportManager.dial(l,{...r,signal:g});if(u.signal.aborted){log$h("multiple dials succeeded, closing superfluous connection"),x.close().catch(S=>{log$h.error("error closing superfluous connection",S)}),b.reject(new AbortError$4);return}n[c]=void 0,n.forEach(S=>{S!==void 0&&S.abort()}),log$h("dial to %a succeeded",l),b.resolve(x)}catch(x){log$h.error("error during dial of %a",l,x),b.reject(x)}},{...r,signal:g}).catch(x=>{b.reject(x)})},{signal:g}).catch(x=>{b.reject(x)}).finally(()=>{g.clear()}),b.promise}));if(a==null)throw new CodeError("successful dial led to empty object returned from peer dial queue",codes.ERR_TRANSPORT_DIAL_FAILED);return t.status="success",a}catch(o){throw t.status="error",t.multiaddrs.length===1&&o.name==="AggregateError"?o.errors[0]:o}}}function randomId(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}const log$g=logger("libp2p:connection-manager"),DEFAULT_DIAL_PRIORITY=50,defaultOptions={minConnections:MIN_CONNECTIONS,maxConnections:MAX_CONNECTIONS,inboundConnectionThreshold:INBOUND_CONNECTION_THRESHOLD,maxIncomingPendingConnections:MAX_INCOMING_PENDING_CONNECTIONS,autoDialConcurrency:AUTO_DIAL_CONCURRENCY,autoDialPriority:AUTO_DIAL_PRIORITY,autoDialMaxQueueLength:AUTO_DIAL_MAX_QUEUE_LENGTH};class DefaultConnectionManager{constructor(t,r={}){Xe(this,"started");Xe(this,"connections");Xe(this,"allow");Xe(this,"deny");Xe(this,"maxIncomingPendingConnections");Xe(this,"incomingPendingConnections");Xe(this,"maxConnections");Xe(this,"dialQueue");Xe(this,"autoDial");Xe(this,"connectionPruner");Xe(this,"inboundConnectionRateLimiter");Xe(this,"peerStore");Xe(this,"metrics");Xe(this,"events");this.maxConnections=r.maxConnections??defaultOptions.maxConnections;const n=r.minConnections??defaultOptions.minConnections;if(this.maxConnectionsmultiaddr(o)),this.deny=(r.deny??[]).map(o=>multiaddr(o)),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=r.maxIncomingPendingConnections??defaultOptions.maxIncomingPendingConnections,this.inboundConnectionRateLimiter=new rateLimiterFlexible.RateLimiterMemory({points:r.inboundConnectionThreshold??defaultOptions.inboundConnectionThreshold,duration:1}),this.autoDial=new AutoDial({connectionManager:this,peerStore:t.peerStore,events:t.events},{minConnections:n,autoDialConcurrency:r.autoDialConcurrency??defaultOptions.autoDialConcurrency,autoDialPriority:r.autoDialPriority??defaultOptions.autoDialPriority,maxQueueLength:r.autoDialMaxQueueLength??defaultOptions.autoDialMaxQueueLength}),this.connectionPruner=new ConnectionPruner({connectionManager:this,peerStore:t.peerStore,events:t.events},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new DialQueue({peerId:t.peerId,metrics:t.metrics,peerStore:t.peerStore,transportManager:t.transportManager,connectionGater:t.connectionGater},{addressSorter:r.addressSorter??defaultAddressSort,maxParallelDials:r.maxParallelDials??MAX_PARALLEL_DIALS,maxPeerAddrsToDial:r.maxPeerAddrsToDial??MAX_PEER_ADDRS_TO_DIAL,maxParallelDialsPerPeer:r.maxParallelDialsPerPeer??MAX_PARALLEL_DIALS_PER_PEER,dialTimeout:r.dialTimeout??DIAL_TIMEOUT,resolvers:r.resolvers??{dnsaddr:dnsaddrResolver}})}isStarted(){return this.started}async start(){this.metrics?.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{const t={inbound:0,outbound:0};for(const r of this.connections.values())for(const n of r)n.direction==="inbound"?t.inbound++:t.outbound++;return t}}),this.metrics?.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{const t={};for(const r of this.connections.values())for(const n of r)for(const o of n.streams){const a=`${o.direction} ${o.protocol??"unnegotiated"}`;t[a]=(t[a]??0)+1}return t}}),this.metrics?.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{const t={};for(const n of this.connections.values())for(const o of n){const a={};for(const l of o.streams){const c=`${l.direction} ${l.protocol??"unnegotiated"}`;a[c]=(a[c]??0)+1}for(const[l,c]of Object.entries(a))t[l]=t[l]??[],t[l].push(c)}const r={};for(let[n,o]of Object.entries(t)){o=o.sort((l,c)=>l-c);const a=Math.floor(o.length*.9);r[n]=o[a]}return r}}),this.autoDial.start(),this.started=!0,log$g("started")}async afterStart(){Promise.resolve().then(async()=>{const t=await this.peerStore.all({filters:[r=>r.tags.has(KEEP_ALIVE)]});await Promise.all(t.map(async r=>{await this.openConnection(r.id).catch(n=>{log$g.error(n)})}))}).catch(t=>{log$g.error(t)}),this.autoDial.afterStart()}async stop(){this.dialQueue.stop(),this.autoDial.stop();const t=[];for(const r of this.connections.values())for(const n of r)t.push((async()=>{try{await n.close()}catch(o){log$g.error(o)}})());log$g("closing %d connections",t.length),await Promise.all(t),this.connections.clear(),log$g("stopped")}onConnect(t){this._onConnect(t).catch(r=>{log$g.error(r)})}async _onConnect(t){const{detail:r}=t;if(!this.started){await r.close();return}const n=r.remotePeer,o=this.connections.get(n);let a=!1;o!=null?o.push(r):(a=!0,this.connections.set(n,[r])),n.publicKey!=null&&n.type==="RSA"&&await this.peerStore.patch(n,{publicKey:n.publicKey}),a&&this.events.safeDispatchEvent("peer:connect",{detail:r.remotePeer})}onDisconnect(t){const{detail:r}=t;if(!this.started)return;const n=r.remotePeer;let o=this.connections.get(n);o!=null&&o.length>1?(o=o.filter(a=>a.id!==r.id),this.connections.set(n,o)):o!=null&&(this.connections.delete(n),this.events.safeDispatchEvent("peer:disconnect",{detail:r.remotePeer}))}getConnections(t){if(t!=null)return this.connections.get(t)??[];let r=[];for(const n of this.connections.values())r=r.concat(n);return r}getConnectionsMap(){return this.connections}async openConnection(t,r={}){if(!this.isStarted())throw new CodeError("Not started",codes.ERR_NODE_NOT_STARTED);r.signal?.throwIfAborted();const{peerId:n}=getPeerAddress(t);if(n!=null&&r.force!==!0){log$g("dial %p",n);const c=this.getConnections(n);if(c.length>0)return log$g("had an existing connection to %p",n),c[0]}const o=await this.dialQueue.dial(t,{...r,priority:r.priority??DEFAULT_DIAL_PRIORITY});let a=this.connections.get(o.remotePeer);a==null&&(a=[],this.connections.set(o.remotePeer,a));let l=!1;for(const c of a)c.id===o.id&&(l=!0);return l||a.push(o),o}async closeConnections(t,r={}){const n=this.connections.get(t)??[];await Promise.all(n.map(async o=>{try{await o.close(r)}catch(a){o.abort(a)}}))}async acceptIncomingConnection(t){if(this.deny.some(o=>t.remoteAddr.toString().startsWith(o.toString())))return log$g("connection from %a refused - connection remote address was in deny list",t.remoteAddr),!1;if(this.allow.some(o=>t.remoteAddr.toString().startsWith(o.toString())))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.maxIncomingPendingConnections)return log$g("connection from %a refused - incomingPendingConnections exceeded by host",t.remoteAddr),!1;if(t.remoteAddr.isThinWaistAddress()){const o=t.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(o,1)}catch{return log$g("connection from %a refused - inboundConnectionThreshold exceeded by host %s",t.remoteAddr,o),!1}}return this.getConnections().length(await t.merge(r.id,{multiaddrs:r.multiaddrs}),r))}function uniquePeers(e){const t=new Set;return filter(e,r=>t.has(r.id.toString())?!1:(t.add(r.id.toString()),!0))}async function*requirePeers(e,t=1){let r=0;for await(const n of e)r++,yield n;if(rn.findProviders(t,r))),n=>storeAddresses(n,this.components.peerStore),n=>uniquePeers(n),n=>requirePeers(n))}async provide(t,r={}){if(this.routers.length===0)throw new CodeError("No content routers available",codes.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map(async n=>{await n.provide(t,r)}))}async put(t,r,n){if(!this.isStarted())throw new CodeError(messages$1.NOT_STARTED_YET,codes.DHT_NOT_STARTED);await Promise.all(this.routers.map(async o=>{await o.put(t,r,n)}))}async get(t,r){if(!this.isStarted())throw new CodeError(messages$1.NOT_STARTED_YET,codes.DHT_NOT_STARTED);return Promise.any(this.routers.map(async n=>n.get(t,r)))}}function isAsyncIterable(e){return e[Symbol.asyncIterator]!=null}function first(e){if(isAsyncIterable(e))return(async()=>{for await(const t of e)return t})();for(const t of e)return t}const log$f=logger("libp2p:peer-routing");class DefaultPeerRouting{constructor(t,r){Xe(this,"components");Xe(this,"routers");this.components=t,this.routers=r.routers??[]}async findPeer(t,r){if(this.routers.length===0)throw new CodeError("No peer routers available",codes.ERR_NO_ROUTERS_AVAILABLE);if(t.toString()===this.components.peerId.toString())throw new CodeError("Should not try to find self",codes.ERR_FIND_SELF);const n=await pipe(merge$1(...this.routers.map(o=>async function*(){try{yield await o.findPeer(t,r)}catch(a){log$f.error(a)}}())),o=>filter(o,Boolean),o=>storeAddresses(o,this.components.peerStore),async o=>first(o));if(n!=null)return n;throw new CodeError(messages$1.NOT_FOUND,codes.ERR_NOT_FOUND)}async*getClosestPeers(t,r){if(this.routers.length===0)throw new CodeError("No peer routers available",codes.ERR_NO_ROUTERS_AVAILABLE);yield*pipe(merge$1(...this.routers.map(n=>n.getClosestPeers(t,r))),n=>storeAddresses(n,this.components.peerStore),n=>uniquePeers(n),n=>requirePeers(n))}}const log$e=logger("libp2p:registrar"),DEFAULT_MAX_INBOUND_STREAMS=32,DEFAULT_MAX_OUTBOUND_STREAMS=64;class DefaultRegistrar{constructor(t){Xe(this,"topologies");Xe(this,"handlers");Xe(this,"components");this.topologies=new Map,this.handlers=new Map,this.components=t,this._onDisconnect=this._onDisconnect.bind(this),this._onPeerUpdate=this._onPeerUpdate.bind(this),this._onConnect=this._onConnect.bind(this),this.components.events.addEventListener("peer:disconnect",this._onDisconnect),this.components.events.addEventListener("peer:connect",this._onConnect),this.components.events.addEventListener("peer:update",this._onPeerUpdate)}getProtocols(){return Array.from(new Set([...this.handlers.keys()])).sort()}getHandler(t){const r=this.handlers.get(t);if(r==null)throw new CodeError(`No handler registered for protocol ${t}`,codes.ERR_NO_HANDLER_FOR_PROTOCOL);return r}getTopologies(t){const r=this.topologies.get(t);return r==null?[]:[...r.values()]}async handle(t,r,n){if(this.handlers.has(t))throw new CodeError(`Handler already registered for protocol ${t}`,codes.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const o=mergeOptions.bind({ignoreUndefined:!0})({maxInboundStreams:DEFAULT_MAX_INBOUND_STREAMS,maxOutboundStreams:DEFAULT_MAX_OUTBOUND_STREAMS},n);this.handlers.set(t,{handler:r,options:o}),await this.components.peerStore.merge(this.components.peerId,{protocols:[t]})}async unhandle(t){(Array.isArray(t)?t:[t]).forEach(n=>{this.handlers.delete(n)}),await this.components.peerStore.patch(this.components.peerId,{protocols:this.getProtocols()})}async register(t,r){if(r==null)throw new CodeError("invalid topology",codes.ERR_INVALID_PARAMETERS);const n=`${(Math.random()*1e9).toString(36)}${Date.now()}`;let o=this.topologies.get(t);return o==null&&(o=new Map,this.topologies.set(t,o)),o.set(n,r),n}unregister(t){for(const[r,n]of this.topologies.entries())n.has(t)&&(n.delete(t),n.size===0&&this.topologies.delete(r))}_onDisconnect(t){const r=t.detail;this.components.peerStore.get(r).then(n=>{for(const o of n.protocols){const a=this.topologies.get(o);if(a!=null)for(const l of a.values())l.onDisconnect?.(r)}}).catch(n=>{n.code!==codes.ERR_NOT_FOUND&&log$e.error("could not inform topologies of disconnecting peer %p",r,n)})}_onConnect(t){const r=t.detail;this.components.peerStore.get(r).then(n=>{const o=this.components.connectionManager.getConnections(n.id)[0];if(o==null){log$e("peer %p connected but the connection manager did not have a connection",n);return}for(const a of n.protocols){const l=this.topologies.get(a);if(l!=null)for(const c of l.values())c.onConnect?.(r,o)}}).catch(n=>{n.code!==codes.ERR_NOT_FOUND&&log$e.error("could not inform topologies of connecting peer %p",r,n)})}_onPeerUpdate(t){const{peer:r,previous:n}=t.detail,o=(n?.protocols??[]).filter(l=>!r.protocols.includes(l)),a=r.protocols.filter(l=>!(n?.protocols??[]).includes(l));for(const l of o){const c=this.topologies.get(l);if(c!=null)for(const u of c.values())u.onDisconnect?.(r.id)}for(const l of a){const c=this.topologies.get(l);if(c!=null)for(const u of c.values()){const g=this.components.connectionManager.getConnections(r.id)[0];g!=null&&u.onConnect?.(r.id,g)}}}}class TrackedMap extends Map{constructor(r){super();Xe(this,"metric");const{name:n,metrics:o}=r;this.metric=o.registerMetric(n),this.updateComponentMetric()}set(r,n){return super.set(r,n),this.updateComponentMetric(),this}delete(r){const n=super.delete(r);return this.updateComponentMetric(),n}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}}function trackedMap(e){const{name:t,metrics:r}=e;let n;return r!=null?n=new TrackedMap({name:t,metrics:r}):n=new Map,n}const log$d=logger("libp2p:transports");class DefaultTransportManager{constructor(t,r={}){Xe(this,"components");Xe(this,"transports");Xe(this,"listeners");Xe(this,"faultTolerance");Xe(this,"started");this.components=t,this.started=!1,this.transports=new Map,this.listeners=trackedMap({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=r.faultTolerance??FaultTolerance.FATAL_ALL}add(t){const r=t[Symbol.toStringTag];if(r==null)throw new CodeError("Transport must have a valid tag",codes.ERR_INVALID_KEY);if(this.transports.has(r))throw new CodeError(`There is already a transport with the tag ${r}`,codes.ERR_DUPLICATE_TRANSPORT);log$d("adding transport %s",r),this.transports.set(r,t),this.listeners.has(r)||this.listeners.set(r,[])}isStarted(){return this.started}start(){this.started=!0}async afterStart(){const t=this.components.addressManager.getListenAddrs();await this.listen(t)}async stop(){const t=[];for(const[r,n]of this.listeners)for(log$d("closing listeners for %s",r);n.length>0;){const o=n.pop();o!=null&&t.push(o.close())}await Promise.all(t),log$d("all listeners closed");for(const r of this.listeners.keys())this.listeners.set(r,[]);this.started=!1}async dial(t,r){const n=this.transportForMultiaddr(t);if(n==null)throw new CodeError(`No transport available for address ${String(t)}`,codes.ERR_TRANSPORT_UNAVAILABLE);try{return await n.dial(t,{...r,upgrader:this.components.upgrader})}catch(o){throw o.code==null&&(o.code=codes.ERR_TRANSPORT_DIAL_FAILED),o}}getAddrs(){let t=[];for(const r of this.listeners.values())for(const n of r)t=[...t,...n.getAddrs()];return t}getTransports(){return Array.of(...this.transports.values())}getListeners(){return Array.of(...this.listeners.values()).flat()}transportForMultiaddr(t){for(const r of this.transports.values())if(r.filter([t]).length>0)return r}async listen(t){if(!this.isStarted())throw new CodeError("Not started",codes.ERR_NODE_NOT_STARTED);if(t==null||t.length===0){log$d("no addresses were provided for listening, this node is dial only");return}const r=[];for(const[n,o]of this.transports.entries()){const a=o.filter(t),l=[];for(const g of a){log$d("creating listener for %s on %a",n,g);const b=o.createListener({upgrader:this.components.upgrader});let x=this.listeners.get(n)??[];x==null&&(x=[],this.listeners.set(n,x)),x.push(b),b.addEventListener("listening",()=>{this.components.events.safeDispatchEvent("transport:listening",{detail:b})}),b.addEventListener("close",()=>{const S=x.findIndex($=>$===b);x.splice(S,1),this.components.events.safeDispatchEvent("transport:close",{detail:b})}),l.push(b.listen(g))}if(l.length===0){r.push(n);continue}if((await Promise.allSettled(l)).find(g=>g.status==="fulfilled")==null&&this.faultTolerance!==FaultTolerance.NO_FATAL)throw new CodeError(`Transport (${n}) could not listen on any available address`,codes.ERR_NO_VALID_ADDRESSES)}if(r.length===this.transports.size){const n=`no valid addresses were provided for transports [${r.join(", ")}]`;if(this.faultTolerance===FaultTolerance.FATAL_ALL)throw new CodeError(n,codes.ERR_NO_VALID_ADDRESSES);log$d(`libp2p in dial mode only: ${n}`)}}async remove(t){log$d("removing %s",t);for(const r of this.listeners.get(t)??[])await r.close();this.transports.delete(t),this.listeners.delete(t)}async removeAll(){const t=[];for(const r of this.transports.keys())t.push(this.remove(r));await Promise.all(t)}}const PROTOCOL_ID="/multistream/1.0.0",MAX_PROTOCOL_LENGTH=1024;function reader(e){const t=async function*(){let r=yield,n=new Uint8ArrayList;for await(const o of e){if(r==null){n.append(o),r=yield n,n=new Uint8ArrayList;continue}for(n.append(o);n.length>=r;){const a=n.sublist(0,r);if(n.consume(r),r=yield a,r==null){n.length>0&&(r=yield n,n=new Uint8ArrayList);break}}}if(r!=null)throw Object.assign(new Error(`stream ended before ${r} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return t.next(),t}function handshake(e){const t=pushable(),r=reader(e.source),n=pDefer();let o;const a=e.sink(async function*(){yield*t,yield*await n.promise}());return a.catch(c=>{o=c}),{reader:r,writer:t,stream:{sink:async c=>{if(o!=null){await Promise.reject(o);return}n.resolve(c),await a},source:r},rest:()=>t.end(),write:t.push,read:async()=>{const c=await r.next();if(c.value!=null)return c.value}}}const log$c=logger("libp2p:mss"),NewLine=fromString$1(` -`);function encode$1(e){const t=new Uint8ArrayList(e,NewLine);return encode$c.single(t)}function write(e,t,r={}){const n=encode$1(t);r.writeBytes===!0?e.push(n.subarray()):e.push(n)}function writeAll(e,t,r={}){const n=new Uint8ArrayList;for(const o of t)n.append(encode$1(o));r.writeBytes===!0?e.push(n.subarray()):e.push(n)}async function read(e,t){let r=1;const n={[Symbol.asyncIterator]:()=>n,next:async()=>e.next(r)};let o=n;t?.signal!=null&&(o=abortableSource(n,t.signal));const a=c=>{r=c},l=await pipe(o,c=>decode$a(c,{onLength:a,maxDataLength:MAX_PROTOCOL_LENGTH}),async c=>first(c));if(l==null||l.length===0)throw new CodeError("no buffer returned","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(l.get(l.byteLength-1)!==NewLine[0])throw log$c.error("Invalid mss message - missing newline - %s",l.subarray()),new CodeError("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return l.sublist(0,-1)}async function readString(e,t){const r=await read(e,t);return toString$5(r.subarray())}const log$b=logger("libp2p:mss:select");async function select(e,t,r={}){t=Array.isArray(t)?[...t]:[t];const{reader:n,writer:o,rest:a,stream:l}=handshake(e),c=t.shift();if(c==null)throw new Error("At least one protocol must be specified");log$b.trace('select: write ["%s", "%s"]',PROTOCOL_ID,c);const u=fromString$1(PROTOCOL_ID),g=fromString$1(c);writeAll(o,[u,g],r);let b=await readString(n,r);if(log$b.trace('select: read "%s"',b),b===PROTOCOL_ID&&(b=await readString(n,r),log$b.trace('select: read "%s"',b)),b===c)return a(),{stream:l,protocol:c};for(const x of t){log$b.trace('select: write "%s"',x),write(o,fromString$1(x),r);const S=await readString(n,r);if(log$b.trace('select: read "%s" for "%s"',S,x),S===x)return a(),{stream:l,protocol:x}}throw a(),new CodeError("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}const log$a=logger("libp2p:mss:handle");async function handle(e,t,r){t=Array.isArray(t)?t:[t];const{writer:n,reader:o,rest:a,stream:l}=handshake(e);for(;;){const c=await readString(o,r);if(log$a.trace('read "%s"',c),c===PROTOCOL_ID){log$a.trace('respond with "%s" for "%s"',PROTOCOL_ID,c),write(n,fromString$1(PROTOCOL_ID),r);continue}if(t.includes(c))return write(n,fromString$1(c),r),log$a.trace('respond with "%s" for "%s"',c,c),a(),{stream:l,protocol:c};if(c==="ls"){write(n,new Uint8ArrayList(...t.map(u=>encode$1(fromString$1(u)))),r),log$a.trace('respond with "%s" for %s',t,c);continue}write(n,fromString$1("na"),r),log$a('respond with "na" for "%s"',c)}}const symbol=Symbol.for("@libp2p/connection"),log$9=logger("libp2p:connection"),CLOSE_TIMEOUT=500;var sc,oc;class ConnectionImpl{constructor(t){Xe(this,"id");Xe(this,"remoteAddr");Xe(this,"remotePeer");Xe(this,"direction");Xe(this,"timeline");Xe(this,"multiplexer");Xe(this,"encryption");Xe(this,"status");Xe(this,"transient");Xe(this,"tags");Xe(this,"_newStream");Xe(this,"_close");Xe(this,"_abort");Xe(this,"_getStreams");Xe(this,sc,"Connection");Xe(this,oc,!0);const{remoteAddr:r,remotePeer:n,newStream:o,close:a,abort:l,getStreams:c}=t;this.id=`${parseInt(String(Math.random()*1e9)).toString(36)}${Date.now()}`,this.remoteAddr=r,this.remotePeer=n,this.direction=t.direction,this.status="open",this.timeline=t.timeline,this.multiplexer=t.multiplexer,this.encryption=t.encryption,this.transient=t.transient??!1,this._newStream=o,this._close=a,this._abort=l,this._getStreams=c,this.tags=[]}get streams(){return this._getStreams()}async newStream(t,r){if(this.status==="closing")throw new CodeError("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if(this.status==="closed")throw new CodeError("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(t)||(t=[t]),this.transient&&r?.runOnTransientConnection!==!0)throw new CodeError("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");const n=await this._newStream(t,r);return n.direction="outbound",n}async close(t={}){if(!(this.status==="closed"||this.status==="closing")){log$9("closing connection to %a",this.remoteAddr),this.status="closing",t.signal=t?.signal??AbortSignal.timeout(CLOSE_TIMEOUT);try{events$1.exports.setMaxListeners?.(1/0,t.signal)}catch{}try{await Promise.all(this.streams.map(async r=>r.close(t))),await this._close(t),this.timeline.close=Date.now(),this.status="closed"}catch(r){log$9.error("error encountered during graceful close of connection to %a",this.remoteAddr,r),this.abort(r)}}}abort(t){log$9.error("aborting connection to %a due to error",this.remoteAddr,t),this.status="closing",this.streams.forEach(r=>{r.abort(t)}),log$9.error("all streams aborted",this.streams.length),this._abort(t),this.timeline.close=Date.now(),this.status="closed"}}sc=Symbol.toStringTag,oc=symbol;function createConnection(e){return new ConnectionImpl(e)}const log$8=logger("libp2p:upgrader");function findIncomingStreamLimit(e,t){try{const{options:r}=t.getHandler(e);return r.maxInboundStreams}catch(r){if(r.code!==codes.ERR_NO_HANDLER_FOR_PROTOCOL)throw r}return DEFAULT_MAX_INBOUND_STREAMS}function findOutgoingStreamLimit(e,t,r={}){try{const{options:n}=t.getHandler(e);if(n.maxOutboundStreams!=null)return n.maxOutboundStreams}catch(n){if(n.code!==codes.ERR_NO_HANDLER_FOR_PROTOCOL)throw n}return r.maxOutboundStreams??DEFAULT_MAX_OUTBOUND_STREAMS}function countStreams(e,t,r){let n=0;return r.streams.forEach(o=>{o.direction===t&&o.protocol===e&&n++}),n}class DefaultUpgrader{constructor(t,r){Xe(this,"components");Xe(this,"connectionEncryption");Xe(this,"muxers");Xe(this,"inboundUpgradeTimeout");Xe(this,"events");this.components=t,this.connectionEncryption=new Map,r.connectionEncryption.forEach(n=>{this.connectionEncryption.set(n.protocol,n)}),this.muxers=new Map,r.muxers.forEach(n=>{this.muxers.set(n.protocol,n)}),this.inboundUpgradeTimeout=r.inboundUpgradeTimeout??INBOUND_UPGRADE_TIMEOUT,this.events=t.events}async shouldBlockConnection(t,r,n){const o=this.components.connectionGater[n];if(o!==void 0&&await o(t,r))throw new CodeError(`The multiaddr connection is blocked by gater.${n}`,codes.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(t,r){if(!await this.components.connectionManager.acceptIncomingConnection(t))throw new CodeError("connection denied",codes.ERR_CONNECTION_DENIED);let o,a,l,c,u;const g=AbortSignal.timeout(this.inboundUpgradeTimeout),b=()=>{t.abort(new CodeError("inbound upgrade timeout",codes.ERR_TIMEOUT))};g.addEventListener("abort",b,{once:!0});try{events$1.exports.setMaxListeners?.(1/0,g)}catch{}try{if(await this.components.connectionGater.denyInboundConnection?.(t)===!0)throw new CodeError("The multiaddr connection is blocked by gater.acceptConnection",codes.ERR_CONNECTION_INTERCEPTED);this.components.metrics?.trackMultiaddrConnection(t),log$8("starting the inbound connection upgrade");let x=t;if(r?.skipProtection!==!0){const S=this.components.connectionProtector;S!=null&&(log$8("protecting the inbound connection"),x=await S.protect(t))}try{if(o=x,r?.skipEncryption!==!0){({conn:o,remotePeer:a,protocol:u}=await this._encryptInbound(x));const S={...x,...o};await this.shouldBlockConnection(a,S,"denyInboundEncryptedConnection")}else{const S=t.remoteAddr.getPeerId();if(S==null)throw new CodeError("inbound connection that skipped encryption must have a peer id",codes.ERR_INVALID_MULTIADDR);const $=peerIdFromString(S);u="native",a=$}if(l=o,r?.muxerFactory!=null)c=r.muxerFactory;else if(this.muxers.size>0){const S=await this._multiplexInbound({...x,...o},this.muxers);c=S.muxerFactory,l=S.stream}}catch(S){throw log$8.error("Failed to upgrade inbound connection",S),S}return await this.shouldBlockConnection(a,t,"denyInboundUpgradedConnection"),log$8("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:u,direction:"inbound",maConn:t,upgradedConn:l,muxerFactory:c,remotePeer:a,transient:r?.transient})}finally{g.removeEventListener("abort",b),this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(t,r){const n=t.remoteAddr.getPeerId();let o;n!=null&&(o=peerIdFromString(n),await this.shouldBlockConnection(o,t,"denyOutboundConnection"));let a,l,c,u,g;this.components.metrics?.trackMultiaddrConnection(t),log$8("Starting the outbound connection upgrade");let b=t;if(r?.skipProtection!==!0){const x=this.components.connectionProtector;x!=null&&(b=await x.protect(t))}try{if(a=b,r?.skipEncryption!==!0){({conn:a,remotePeer:l,protocol:u}=await this._encryptOutbound(b,o));const x={...b,...a};await this.shouldBlockConnection(l,x,"denyOutboundEncryptedConnection")}else{if(o==null)throw new CodeError("Encryption was skipped but no peer id was passed",codes.ERR_INVALID_PEER);u="native",l=o}if(c=a,r?.muxerFactory!=null)g=r.muxerFactory;else if(this.muxers.size>0){const x=await this._multiplexOutbound({...b,...a},this.muxers);g=x.muxerFactory,c=x.stream}}catch(x){throw log$8.error("Failed to upgrade outbound connection",x),await t.close(x),x}return await this.shouldBlockConnection(l,t,"denyOutboundUpgradedConnection"),log$8("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:u,direction:"outbound",maConn:t,upgradedConn:c,muxerFactory:g,remotePeer:l,transient:r?.transient})}_createConnection(t){const{cryptoProtocol:r,direction:n,maConn:o,upgradedConn:a,remotePeer:l,muxerFactory:c,transient:u}=t;let g,b,x;c!=null&&(g=c.createStreamMuxer({direction:n,onIncomingStream:k=>{x!=null&&Promise.resolve().then(async()=>{const T=this.components.registrar.getProtocols(),{stream:D,protocol:I}=await handle(k,T);if(log$8("%s: incoming stream opened on %s",n,I),x==null)return;const O=findIncomingStreamLimit(I,this.components.registrar);if(countStreams(I,"inbound",x)===O){const ee=new CodeError(`Too many inbound protocol streams for protocol "${I}" - limit ${O}`,codes.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw k.abort(ee),ee}k.source=D.source,k.sink=D.sink,k.protocol=I,await this.components.peerStore.merge(l,{protocols:[I]}),this.components.metrics?.trackProtocolStream(k,x),this._onStream({connection:x,stream:k,protocol:I})}).catch(async T=>{log$8.error(T),k.timeline.close==null&&await k.close()})}}),b=async(k,T={})=>{if(g==null)throw new CodeError("Stream is not multiplexed",codes.ERR_MUXER_UNAVAILABLE);log$8("%s: starting new stream on %s",n,k);const D=await g.newStream();try{if(T.signal==null){log$8("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",k),T.signal=AbortSignal.timeout(3e4);try{events$1.exports.setMaxListeners?.(1/0,T.signal)}catch{}}const{stream:I,protocol:O}=await select(D,k,T),N=findOutgoingStreamLimit(O,this.components.registrar,T);if(countStreams(O,"outbound",x)>=N){const ne=new CodeError(`Too many outbound protocol streams for protocol "${O}" - limit ${N}`,codes.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw D.abort(ne),ne}return await this.components.peerStore.merge(l,{protocols:[O]}),D.source=I.source,D.sink=I.sink,D.protocol=O,this.components.metrics?.trackProtocolStream(D,x),D}catch(I){throw log$8.error("could not create new stream",I),D.timeline.close==null&&D.abort(I),I.code!=null?I:new CodeError(String(I),codes.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([g.sink(a.source),a.sink(g.source)]).catch(k=>{log$8.error(k)}));const S=o.timeline;o.timeline=new Proxy(S,{set:(...k)=>(x!=null&&k[1]==="close"&&k[2]!=null&&S.close==null&&(async()=>{try{x.status==="open"&&await x.close()}catch(T){log$8.error(T)}finally{this.events.safeDispatchEvent("connection:close",{detail:x})}})().catch(T=>{log$8.error(T)}),Reflect.set(...k))}),o.timeline.upgraded=Date.now();const $=()=>{throw new CodeError("connection is not multiplexed",codes.ERR_CONNECTION_NOT_MULTIPLEXED)};return x=createConnection({remoteAddr:o.remoteAddr,remotePeer:l,status:"open",direction:n,timeline:o.timeline,multiplexer:g?.protocol,encryption:r,transient:u,newStream:b??$,getStreams:()=>g!=null?g.streams:[],close:async k=>{await o.close(k),g!=null&&await g.close(k)},abort:k=>{o.abort(k),g?.abort(k)}}),this.events.safeDispatchEvent("connection:open",{detail:x}),x}_onStream(t){const{connection:r,stream:n,protocol:o}=t,{handler:a,options:l}=this.components.registrar.getHandler(o);if(r.transient&&l.runOnTransientConnection!==!0)throw new CodeError("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");a({connection:r,stream:n})}async _encryptInbound(t){const r=Array.from(this.connectionEncryption.keys());log$8("handling inbound crypto protocol selection",r);try{const{stream:n,protocol:o}=await handle(t,r,{writeBytes:!0}),a=this.connectionEncryption.get(o);if(a==null)throw new Error(`no crypto module found for ${o}`);return log$8("encrypting inbound connection..."),{...await a.secureInbound(this.components.peerId,n),protocol:o}}catch(n){throw new CodeError(String(n),codes.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(t,r){const n=Array.from(this.connectionEncryption.keys());log$8("selecting outbound crypto protocol",n);try{const{stream:o,protocol:a}=await select(t,n,{writeBytes:!0}),l=this.connectionEncryption.get(a);if(l==null)throw new Error(`no crypto module found for ${a}`);return log$8("encrypting outbound connection to %p",r),{...await l.secureOutbound(this.components.peerId,o,r),protocol:a}}catch(o){throw new CodeError(String(o),codes.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(t,r){const n=Array.from(r.keys());log$8("outbound selecting muxer %s",n);try{const{stream:o,protocol:a}=await select(t,n,{writeBytes:!0});log$8("%s selected as muxer protocol",a);const l=r.get(a);return{stream:o,muxerFactory:l}}catch(o){throw log$8.error("error multiplexing outbound stream",o),new CodeError(String(o),codes.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(t,r){const n=Array.from(r.keys());log$8("inbound handling muxers %s",n);try{const{stream:o,protocol:a}=await handle(t,n,{writeBytes:!0}),l=r.get(a);return{stream:o,muxerFactory:l}}catch(o){throw log$8.error("error multiplexing inbound stream",o),new CodeError(String(o),codes.ERR_MUXER_UNAVAILABLE)}}}const log$7=logger("libp2p");var xn,gs,ya;class Libp2pNode extends EventEmitter$2{constructor(r){super();Er(this,gs);Xe(this,"peerId");Xe(this,"peerStore");Xe(this,"contentRouting");Xe(this,"peerRouting");Xe(this,"keychain");Xe(this,"metrics");Xe(this,"services");Xe(this,"components");Er(this,xn,void 0);const n=new EventEmitter$2,o=n.dispatchEvent.bind(n);n.dispatchEvent=g=>{const b=o(g),x=this.dispatchEvent(new CustomEvent$1(g.type,{detail:g.detail}));return b||x};try{events$1.exports.setMaxListeners?.(1/0,n)}catch{}Ln(this,xn,!1),this.peerId=r.peerId,this.services={};const a=this.components=defaultComponents({peerId:r.peerId,events:n,datastore:r.datastore??new MemoryDatastore,connectionGater:connectionGater(r.connectionGater)});this.peerStore=this.configureComponent("peerStore",new PersistentPeerStore(a,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...r.peerStore})),r.metrics!=null&&(this.metrics=this.configureComponent("metrics",r.metrics(this.components))),a.events.addEventListener("peer:update",g=>{if(g.detail.previous==null){const b={id:g.detail.peer.id,multiaddrs:g.detail.peer.addresses.map(x=>x.multiaddr),protocols:g.detail.peer.protocols};a.events.safeDispatchEvent("peer:discovery",{detail:b})}}),r.connectionProtector!=null&&this.configureComponent("connectionProtector",r.connectionProtector(a)),this.components.upgrader=new DefaultUpgrader(this.components,{connectionEncryption:(r.connectionEncryption??[]).map((g,b)=>this.configureComponent(`connection-encryption-${b}`,g(this.components))),muxers:(r.streamMuxers??[]).map((g,b)=>this.configureComponent(`stream-muxers-${b}`,g(this.components))),inboundUpgradeTimeout:r.connectionManager.inboundUpgradeTimeout}),this.configureComponent("transportManager",new DefaultTransportManager(this.components,r.transportManager)),this.configureComponent("connectionManager",new DefaultConnectionManager(this.components,r.connectionManager)),this.configureComponent("registrar",new DefaultRegistrar(this.components)),this.configureComponent("addressManager",new DefaultAddressManager(this.components,r.addresses));const l=DefaultKeyChain.generateOptions();this.keychain=this.configureComponent("keyChain",new DefaultKeyChain(this.components,{...l,...r.keychain}));const c=(r.peerRouters??[]).map((g,b)=>this.configureComponent(`peer-router-${b}`,g(this.components)));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new DefaultPeerRouting(this.components,{routers:c}));const u=(r.contentRouters??[]).map((g,b)=>this.configureComponent(`content-router-${b}`,g(this.components)));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new CompoundContentRouting(this.components,{routers:u})),(r.peerDiscovery??[]).forEach((g,b)=>{this.configureComponent(`peer-discovery-${b}`,g(this.components)).addEventListener("peer",S=>{xr(this,gs,ya).call(this,S)})}),r.transports.forEach((g,b)=>{this.components.transportManager.add(this.configureComponent(`transport-${b}`,g(this.components)))}),r.services!=null)for(const g of Object.keys(r.services)){const b=r.services[g],x=b(this.components);if(x==null){log$7.error("service factory %s returned null or undefined instance",g);continue}this.services[g]=x,this.configureComponent(g,x),x[contentRouting]!=null&&(log$7("registering service %s for content routing",g),u.push(x[contentRouting])),x[peerRouting]!=null&&(log$7("registering service %s for peer routing",g),c.push(x[peerRouting])),x[peerDiscovery]!=null&&(log$7("registering service %s for peer discovery",g),x[peerDiscovery].addEventListener("peer",S=>{xr(this,gs,ya).call(this,S)}))}}configureComponent(r,n){return n==null&&log$7.error("component %s was null or undefined",r),this.components[r]=n,n}async start(){if(ir(this,xn))return;Ln(this,xn,!0),log$7("libp2p is starting"),(await this.keychain.listKeys()).find(n=>n.name==="self")==null&&(log$7("importing self key into keychain"),await this.keychain.importPeer("self",this.components.peerId));try{await this.components.beforeStart?.(),await this.components.start(),await this.components.afterStart?.(),this.safeDispatchEvent("start",{detail:this}),log$7("libp2p has started")}catch(n){throw log$7.error("An error occurred starting libp2p",n),await this.stop(),n}}async stop(){!ir(this,xn)||(log$7("libp2p is stopping"),Ln(this,xn,!1),await this.components.beforeStop?.(),await this.components.stop(),await this.components.afterStop?.(),this.safeDispatchEvent("stop",{detail:this}),log$7("libp2p has stopped"))}isStarted(){return ir(this,xn)}getConnections(r){return this.components.connectionManager.getConnections(r)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){const r=new PeerSet;for(const n of this.components.connectionManager.getConnections())r.add(n.remotePeer);return Array.from(r)}async dial(r,n={}){return this.components.connectionManager.openConnection(r,n)}async dialProtocol(r,n,o={}){if(n==null)throw new CodeError("no protocols were provided to open a stream",codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(n=Array.isArray(n)?n:[n],n.length===0)throw new CodeError("no protocols were provided to open a stream",codes.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this.dial(r,o)).newStream(n,o)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(r,n={}){isMultiaddr(r)&&(r=peerIdFromString(r.getPeerId()??"")),await this.components.connectionManager.closeConnections(r,n)}async getPublicKey(r,n={}){if(log$7("getPublicKey %p",r),r.publicKey!=null)return r.publicKey;const o=await this.peerStore.get(r);if(o.id.publicKey!=null)return o.id.publicKey;const a=concat$1([fromString$1("/pk/"),r.multihash.digest]),l=await this.contentRouting.get(a,n);return unmarshalPublicKey(l),await this.peerStore.patch(r,{publicKey:l}),l}async handle(r,n,o){Array.isArray(r)||(r=[r]),await Promise.all(r.map(async a=>{await this.components.registrar.handle(a,n,o)}))}async unhandle(r){Array.isArray(r)||(r=[r]),await Promise.all(r.map(async n=>{await this.components.registrar.unhandle(n)}))}async register(r,n){return this.components.registrar.register(r,n)}unregister(r){this.components.registrar.unregister(r)}}xn=new WeakMap,gs=new WeakSet,ya=function(r){const{detail:n}=r;if(n.id.toString()===this.peerId.toString()){log$7.error(new Error(codes.ERR_DISCOVERED_SELF));return}this.components.peerStore.merge(n.id,{multiaddrs:n.multiaddrs,protocols:n.protocols}).catch(o=>{log$7.error(o)})};async function createLibp2pNode(e){if(e.peerId==null){const t=e.datastore;if(t!=null)try{const r=new DefaultKeyChain({datastore:t},mergeOptions(DefaultKeyChain.generateOptions(),e.keychain));e.peerId=await r.exportPeerId("self")}catch(r){if(r.code!=="ERR_NOT_FOUND")throw r}}return e.peerId==null&&(e.peerId=await createEd25519PeerId()),new Libp2pNode(validateConfig(e))}async function createLibp2p(e){const t=await createLibp2pNode(e);return e.start!==!1&&await t.start(),t}const CIRCUIT_PROTO_CODE=290,RELAY_RENDEZVOUS_NS="/libp2p/relay",DEFAULT_RESERVATION_CONCURRENCY=1,RELAY_TAG="circuit-relay-relay";BigInt(1<<17);const RELAY_V2_HOP_CODEC="/libp2p/circuit/relay/0.2.0/hop",RELAY_V2_STOP_CODEC="/libp2p/circuit/relay/0.2.0/stop";var HopMessage;(function(e){(function(n){n.RESERVE="RESERVE",n.CONNECT="CONNECT",n.STATUS="STATUS"})(e.Type||(e.Type={}));let t;(function(n){n[n.RESERVE=0]="RESERVE",n[n.CONNECT=1]="CONNECT",n[n.STATUS=2]="STATUS"})(t||(t={})),function(n){n.codec=()=>enumeration(t)}(e.Type||(e.Type={}));let r;e.codec=()=>(r==null&&(r=message((n,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),e.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),Peer.codec().encode(n.peer,o)),n.reservation!=null&&(o.uint32(26),Reservation.codec().encode(n.reservation,o)),n.limit!=null&&(o.uint32(34),Limit.codec().encode(n.limit,o)),n.status!=null&&(o.uint32(40),Status.codec().encode(n.status,o)),a.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{const a={},l=o==null?n.len:n.pos+o;for(;n.pos>>3){case 1:a.type=e.Type.codec().decode(n);break;case 2:a.peer=Peer.codec().decode(n,n.uint32());break;case 3:a.reservation=Reservation.codec().decode(n,n.uint32());break;case 4:a.limit=Limit.codec().decode(n,n.uint32());break;case 5:a.status=Status.codec().decode(n);break;default:n.skipType(c&7);break}}return a})),r),e.encode=n=>encodeMessage(n,e.codec()),e.decode=n=>decodeMessage(n,e.codec())})(HopMessage||(HopMessage={}));var StopMessage;(function(e){(function(n){n.CONNECT="CONNECT",n.STATUS="STATUS"})(e.Type||(e.Type={}));let t;(function(n){n[n.CONNECT=0]="CONNECT",n[n.STATUS=1]="STATUS"})(t||(t={})),function(n){n.codec=()=>enumeration(t)}(e.Type||(e.Type={}));let r;e.codec=()=>(r==null&&(r=message((n,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),e.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),Peer.codec().encode(n.peer,o)),n.limit!=null&&(o.uint32(26),Limit.codec().encode(n.limit,o)),n.status!=null&&(o.uint32(32),Status.codec().encode(n.status,o)),a.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{const a={},l=o==null?n.len:n.pos+o;for(;n.pos>>3){case 1:a.type=e.Type.codec().decode(n);break;case 2:a.peer=Peer.codec().decode(n,n.uint32());break;case 3:a.limit=Limit.codec().decode(n,n.uint32());break;case 4:a.status=Status.codec().decode(n);break;default:n.skipType(c&7);break}}return a})),r),e.encode=n=>encodeMessage(n,e.codec()),e.decode=n=>decodeMessage(n,e.codec())})(StopMessage||(StopMessage={}));var Peer;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.id!=null&&r.id.byteLength>0&&(n.uint32(10),n.bytes(r.id)),r.addrs!=null)for(const a of r.addrs)n.uint32(18),n.bytes(a);o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={id:new Uint8Array(0),addrs:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.id=r.bytes();break;case 2:o.addrs.push(r.bytes());break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Peer||(Peer={}));var Reservation;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.expire!=null&&r.expire!==0n&&(n.uint32(8),n.uint64(r.expire)),r.addrs!=null)for(const a of r.addrs)n.uint32(18),n.bytes(a);r.voucher!=null&&(n.uint32(26),n.bytes(r.voucher)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={expire:0n,addrs:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.expire=r.uint64();break;case 2:o.addrs.push(r.bytes());break;case 3:o.voucher=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Reservation||(Reservation={}));var Limit;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.duration!=null&&(n.uint32(8),n.uint32(r.duration)),r.data!=null&&(n.uint32(16),n.uint64(r.data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.duration=r.uint32();break;case 2:o.data=r.uint64();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Limit||(Limit={}));var Status;(function(e){e.UNUSED="UNUSED",e.OK="OK",e.RESERVATION_REFUSED="RESERVATION_REFUSED",e.RESOURCE_LIMIT_EXCEEDED="RESOURCE_LIMIT_EXCEEDED",e.PERMISSION_DENIED="PERMISSION_DENIED",e.CONNECTION_FAILED="CONNECTION_FAILED",e.NO_RESERVATION="NO_RESERVATION",e.MALFORMED_MESSAGE="MALFORMED_MESSAGE",e.UNEXPECTED_MESSAGE="UNEXPECTED_MESSAGE"})(Status||(Status={}));var __StatusValues;(function(e){e[e.UNUSED=0]="UNUSED",e[e.OK=100]="OK",e[e.RESERVATION_REFUSED=200]="RESERVATION_REFUSED",e[e.RESOURCE_LIMIT_EXCEEDED=201]="RESOURCE_LIMIT_EXCEEDED",e[e.PERMISSION_DENIED=202]="PERMISSION_DENIED",e[e.CONNECTION_FAILED=203]="CONNECTION_FAILED",e[e.NO_RESERVATION=204]="NO_RESERVATION",e[e.MALFORMED_MESSAGE=400]="MALFORMED_MESSAGE",e[e.UNEXPECTED_MESSAGE=401]="UNEXPECTED_MESSAGE"})(__StatusValues||(__StatusValues={}));(function(e){e.codec=()=>enumeration(__StatusValues)})(Status||(Status={}));var ReservationVoucher;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.relay!=null&&r.relay.byteLength>0&&(n.uint32(10),n.bytes(r.relay)),r.peer!=null&&r.peer.byteLength>0&&(n.uint32(18),n.bytes(r.peer)),r.expiration!=null&&r.expiration!==0n&&(n.uint32(24),n.uint64(r.expiration)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={relay:new Uint8Array(0),peer:new Uint8Array(0),expiration:0n},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 1:o.relay=r.bytes();break;case 2:o.peer=r.bytes();break;case 3:o.expiration=r.uint64();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(ReservationVoucher||(ReservationVoucher={}));logger("libp2p:circuit-relay:utils");async function namespaceToCid(e){const t=new TextEncoder().encode(e),r=await sha256$1.digest(t);return CID.createV0(r)}function getExpirationMilliseconds(e){const t=e*BigInt(1e3),r=new Date().getTime();return Number(t-BigInt(r))}var retry$1={exports:{}},retry={};function RetryOperation(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var retry_operation=RetryOperation;RetryOperation.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};RetryOperation.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};RetryOperation.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;return this._timer=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r),this._options.unref&&this._timer.unref(),!0};RetryOperation.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};RetryOperation.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};RetryOperation.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};RetryOperation.prototype.start=RetryOperation.prototype.try;RetryOperation.prototype.errors=function(){return this._errors};RetryOperation.prototype.attempts=function(){return this._attempts};RetryOperation.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,n=0;n=r&&(t=o,r=l)}return t};(function(e){var t=retry_operation;e.operation=function(r){var n=e.timeouts(r);return new t(n,{forever:r&&(r.forever||r.retries===1/0),unref:r&&r.unref,maxRetryTime:r&&r.maxRetryTime})},e.timeouts=function(r){if(r instanceof Array)return[].concat(r);var n={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var o in r)n[o]=r[o];if(n.minTimeout>n.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var a=[],l=0;l{this.safeDispatchEvent("relay:discover",{detail:r})}}),this.discover().catch(r=>{log$5.error("error listening on relays",r)}),this.started=!0}stop(){this.topologyId!=null&&this.registrar.unregister(this.topologyId),this.started=!1}async discover(){log$5("searching peer store for relays");const r=await this.peerStore.all({filters:[n=>n.protocols.includes(RELAY_V2_HOP_CODEC)],orders:[()=>Math.random()<.5?1:-1]});for(const n of r)log$5("found relay peer %p in content peer store",n.id),this.safeDispatchEvent("relay:discover",{detail:n.id});log$5("found %d relay peers in peer store",r.length);try{log$5("searching content routing for relays");const n=await namespaceToCid(RELAY_RENDEZVOUS_NS);let o=0;for await(const a of this.contentRouting.findProviders(n))if(a.multiaddrs.length>0&&!a.id.equals(this.peerId)){const l=a.id;o++,await this.peerStore.merge(l,{multiaddrs:a.multiaddrs}),log$5("found relay peer %p in content routing",l),this.safeDispatchEvent("relay:discover",{detail:l})}log$5("found %d relay peers in content routing",o)}catch(n){log$5.error("failed when finding relays on the network",n)}}}const log$4=logger("libp2p:circuit-relay:transport:listener");var vo,Va;class CircuitRelayTransportListener extends EventEmitter$2{constructor(r){super();Er(this,vo);Xe(this,"connectionManager");Xe(this,"relayStore");Xe(this,"listeningAddrs");this.connectionManager=r.connectionManager,this.relayStore=r.relayStore,this.listeningAddrs=new PeerMap,this.relayStore.addEventListener("relay:removed",n=>{xr(this,vo,Va).call(this,n.detail)})}async listen(r){log$4("listen on %a",r);const n=r.getPeerId();let o;if(n!=null){const l=peerIdFromString(n),c=this.connectionManager.getConnectionsMap().get(l)??[];c.length>0&&(o=c[0])}if(o==null){const l=r.toString().split("/p2p-circuit").find(u=>u!==""),c=multiaddr(l);o=await this.connectionManager.openConnection(c)}if(!this.relayStore.hasReservation(o.remotePeer)){await this.relayStore.addRelay(o.remotePeer,"configured");return}const a=this.relayStore.getReservation(o.remotePeer);if(a==null)throw new CodeError("Did not have reservation after making reservation","ERR_NO_RESERVATION");if(this.listeningAddrs.has(o.remotePeer)){log$4("already listening on relay %p",o.remotePeer);return}this.listeningAddrs.set(o.remotePeer,a.addrs.map(l=>multiaddr(l).encapsulate("/p2p-circuit"))),this.safeDispatchEvent("listening",{})}getAddrs(){return[...this.listeningAddrs.values()].flat()}async close(){}}vo=new WeakSet,Va=function(r){const n=this.listeningAddrs.has(r);log$4("relay peer removed %p - had reservation",r,n),this.listeningAddrs.delete(r),n&&this.safeDispatchEvent("close",{})};function createListener(e){return new CircuitRelayTransportListener(e)}const log$3=logger("libp2p:circuit-relay:transport:reservation-store"),REFRESH_WINDOW=60*1e3*10,REFRESH_TIMEOUT=60*1e3*5,REFRESH_TIMEOUT_MIN=30*1e3;var bo,Ha,wo,za;class ReservationStore extends EventEmitter$2{constructor(r,n){super();Er(this,bo);Er(this,wo);Xe(this,"peerId");Xe(this,"connectionManager");Xe(this,"transportManager");Xe(this,"peerStore");Xe(this,"events");Xe(this,"reserveQueue");Xe(this,"reservations");Xe(this,"maxDiscoveredRelays");Xe(this,"maxReservationQueueLength");Xe(this,"reservationCompletionTimeout");Xe(this,"started");this.peerId=r.peerId,this.connectionManager=r.connectionManager,this.transportManager=r.transportManager,this.peerStore=r.peerStore,this.events=r.events,this.reservations=new PeerMap,this.maxDiscoveredRelays=n?.discoverRelays??0,this.maxReservationQueueLength=n?.maxReservationQueueLength??100,this.reservationCompletionTimeout=n?.reservationCompletionTimeout??1e4,this.started=!1,this.reserveQueue=new PeerJobQueue({concurrency:n?.reservationConcurrency??DEFAULT_RESERVATION_CONCURRENCY}),this.events.addEventListener("peer:disconnect",o=>{xr(this,wo,za).call(this,o.detail)})}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.reserveQueue.clear(),this.reservations.forEach(({timeout:r})=>{clearTimeout(r)}),this.reservations.clear(),this.started=!1}async addRelay(r,n){if(this.peerId.equals(r)){log$3("not trying to use self as relay");return}if(this.reserveQueue.size>this.maxReservationQueueLength){log$3("not adding relay as the queue is full");return}if(this.reserveQueue.hasJob(r)){log$3("relay peer is already in the reservation queue");return}log$3("add relay %p",r),await this.reserveQueue.add(async()=>{try{const o=this.reservations.get(r);if(o!=null){if(getExpirationMilliseconds(o.reservation.expire)>REFRESH_WINDOW){log$3("already have reservation on relay peer %p and it expires in more than 10 minutes",r);return}clearTimeout(o.timeout),this.reservations.delete(r)}if(n==="discovered"&&[...this.reservations.values()].reduce((x,S)=>(S.type==="discovered"&&x++,x),0)>=this.maxDiscoveredRelays){log$3("already have enough discovered relays");return}const a=AbortSignal.timeout(this.reservationCompletionTimeout),l=await this.connectionManager.openConnection(r,{signal:a});if(l.remoteAddr.protoNames().includes("p2p-circuit")){log$3("not creating reservation over relayed connection");return}const c=await xr(this,bo,Ha).call(this,l,{signal:a});log$3("created reservation on relay peer %p",r);const u=getExpirationMilliseconds(c.expire),g=Math.min(Math.max(u-REFRESH_TIMEOUT,REFRESH_TIMEOUT_MIN),Math.pow(2,31)-1),b=setTimeout(()=>{this.addRelay(r,n).catch(x=>{log$3.error("could not refresh reservation to relay %p",r,x)})},g);this.reservations.set(r,{timeout:b,reservation:c,type:n}),await this.peerStore.merge(r,{tags:{[RELAY_TAG]:{value:1,ttl:u}}}),await this.transportManager.listen([multiaddr(`/p2p/${r.toString()}/p2p-circuit`)])}catch(o){log$3.error("could not reserve slot on %p",r,o);const a=this.reservations.get(r);a!=null&&clearTimeout(a.timeout),this.reservations.delete(r)}},{peerId:r})}hasReservation(r){return this.reservations.has(r)}getReservation(r){return this.reservations.get(r)?.reservation}}bo=new WeakSet,Ha=async function(r,n){n.signal?.throwIfAborted(),log$3("requesting reservation from %p",r.remotePeer);const o=await r.newStream(RELAY_V2_HOP_CODEC,n),l=pbStream(o).pb(HopMessage);await l.write({type:HopMessage.Type.RESERVE},n);let c;try{c=await l.read(n)}catch(g){throw log$3.error("error parsing reserve message response from %p because",r.remotePeer,g),g}finally{await o.close()}if(c.status===Status.OK&&c.reservation!=null)return c.reservation;const u=`reservation failed with status ${c.status??"undefined"}`;throw log$3.error(u),new Error(u)},wo=new WeakSet,za=function(r){const n=this.reservations.get(r);n!=null&&(log$3("connection to relay %p closed, removing reservation from local store",r),clearTimeout(n.timeout),this.reservations.delete(r),this.safeDispatchEvent("relay:removed",{detail:r}),this.reservations.size{if(e.peer==null)return!1;try{e.peer.addrs.forEach(multiaddr)}catch{return!1}return!0},defaults={maxInboundStopStreams:MAX_CONNECTIONS,maxOutboundStopStreams:MAX_CONNECTIONS,stopTimeout:3e4};var ac,lc;class CircuitRelayTransport{constructor(t,r){Xe(this,"discovery");Xe(this,"registrar");Xe(this,"peerStore");Xe(this,"connectionManager");Xe(this,"peerId");Xe(this,"upgrader");Xe(this,"addressManager");Xe(this,"connectionGater");Xe(this,"reservationStore");Xe(this,"maxInboundStopStreams");Xe(this,"maxOutboundStopStreams");Xe(this,"stopTimeout");Xe(this,"started");Xe(this,ac,!0);Xe(this,lc,"libp2p/circuit-relay-v2");this.registrar=t.registrar,this.peerStore=t.peerStore,this.connectionManager=t.connectionManager,this.peerId=t.peerId,this.upgrader=t.upgrader,this.addressManager=t.addressManager,this.connectionGater=t.connectionGater,this.maxInboundStopStreams=r.maxInboundStopStreams??defaults.maxInboundStopStreams,this.maxOutboundStopStreams=r.maxOutboundStopStreams??defaults.maxOutboundStopStreams,this.stopTimeout=r.stopTimeout??defaults.stopTimeout,r.discoverRelays!=null&&r.discoverRelays>0&&(this.discovery=new RelayDiscovery(t),this.discovery.addEventListener("relay:discover",n=>{this.reservationStore.addRelay(n.detail,"discovered").catch(o=>{log$2.error("could not add discovered relay %p",n.detail,o)})})),this.reservationStore=new ReservationStore(t,r),this.reservationStore.addEventListener("relay:not-enough-relays",()=>{this.discovery?.discover().catch(n=>{log$2.error("could not discover relays",n)})}),this.started=!1}isStarted(){return this.started}async start(){await this.reservationStore.start(),await this.discovery?.start(),await this.registrar.handle(RELAY_V2_STOP_CODEC,t=>{this.onStop(t).catch(r=>{log$2.error("error while handling STOP protocol",r),t.stream.abort(r)})},{maxInboundStreams:this.maxInboundStopStreams,maxOutboundStreams:this.maxOutboundStopStreams,runOnTransientConnection:!0}),this.started=!0}async stop(){this.discovery?.stop(),await this.reservationStore.stop(),await this.registrar.unhandle(RELAY_V2_STOP_CODEC),this.started=!1}async dial(t,r={}){if(t.protoCodes().filter(k=>k===CIRCUIT_PROTO_CODE).length!==1){const k="Invalid circuit relay address";throw log$2.error(k,t),new CodeError(k,codes.ERR_RELAYED_DIAL)}const n=t.toString().split("/p2p-circuit"),o=multiaddr(n[0]),a=multiaddr(n[n.length-1]),l=o.getPeerId(),c=a.getPeerId();if(l==null||c==null){const k=`Circuit relay dial to ${t.toString()} failed as address did not have peer ids`;throw log$2.error(k),new CodeError(k,codes.ERR_RELAYED_DIAL)}const u=peerIdFromString(l),g=peerIdFromString(c);let b=!1,S=this.connectionManager.getConnections(u)[0];S==null&&(await this.peerStore.merge(u,{multiaddrs:[o]}),S=await this.connectionManager.openConnection(u,r),b=!0);let $;try{return $=await S.newStream([RELAY_V2_HOP_CODEC]),await this.connectV2({stream:$,connection:S,destinationPeer:g,destinationAddr:a,relayAddr:o,ma:t,disconnectOnFailure:b})}catch(k){throw log$2.error(`Circuit relay dial to destination ${g.toString()} via relay ${u.toString()} failed`,k),$?.abort(k),b&&await S.close(),k}}async connectV2({stream:t,connection:r,destinationPeer:n,destinationAddr:o,relayAddr:a,ma:l,disconnectOnFailure:c}){try{const u=pbStream(t),g=u.pb(HopMessage);await g.write({type:HopMessage.Type.CONNECT,peer:{id:n.toBytes(),addrs:[multiaddr(o).bytes]}});const b=await g.read();if(b.status!==Status.OK)throw new CodeError(`failed to connect via relay with status ${b?.status?.toString()??"undefined"}`,codes.ERR_HOP_REQUEST_FAILED);const x=streamToMaConnection({stream:u.unwrap(),remoteAddr:l,localAddr:a.encapsulate(`/p2p-circuit/p2p/${this.peerId.toString()}`)});return log$2("new outbound transient connection %a",x.remoteAddr),await this.upgrader.upgradeOutbound(x,{transient:!0})}catch(u){throw log$2.error(`Circuit relay dial to destination ${n.toString()} via relay ${r.remotePeer.toString()} failed`,u),c&&await r.close(),u}}createListener(t){return createListener({connectionManager:this.connectionManager,relayStore:this.reservationStore})}filter(t){return t=Array.isArray(t)?t:[t],t.filter(r=>Circuit$1.matches(r))}async onStop({connection:t,stream:r}){const n=AbortSignal.timeout(this.stopTimeout),o=pbStream(r).pb(StopMessage),a=await o.read({signal:n});if(log$2("new circuit relay v2 stop stream from %p with type %s",t.remotePeer,a.type),a?.type===void 0){log$2.error("type was missing from circuit v2 stop protocol request from %s",t.remotePeer),await o.write({type:StopMessage.Type.STATUS,status:Status.MALFORMED_MESSAGE},{signal:n}),await r.close();return}if(a.type!==StopMessage.Type.CONNECT){log$2.error("invalid stop connect request via peer %p",t.remotePeer),await o.write({type:StopMessage.Type.STATUS,status:Status.UNEXPECTED_MESSAGE},{signal:n}),await r.close();return}if(!isValidStop(a)){log$2.error("invalid stop connect request via peer %p",t.remotePeer),await o.write({type:StopMessage.Type.STATUS,status:Status.MALFORMED_MESSAGE},{signal:n}),await r.close();return}const l=peerIdFromBytes(a.peer.id);if(await this.connectionGater.denyInboundRelayedConnection?.(t.remotePeer,l)===!0){log$2.error("connection gater denied inbound relayed connection from %p",t.remotePeer),await o.write({type:StopMessage.Type.STATUS,status:Status.PERMISSION_DENIED},{signal:n}),await r.close();return}log$2.trace("sending success response to %p",t.remotePeer),await o.write({type:StopMessage.Type.STATUS,status:Status.OK},{signal:n});const c=t.remoteAddr.encapsulate(`/p2p-circuit/p2p/${l.toString()}`),u=this.addressManager.getAddresses()[0],g=streamToMaConnection({stream:o.unwrap().unwrap(),remoteAddr:c,localAddr:u});log$2("new inbound transient connection %a",g.remoteAddr),await this.upgrader.upgradeInbound(g,{transient:!0}),log$2("%s connection %a upgraded","inbound",g.remoteAddr)}}ac=symbol$1,lc=Symbol.toStringTag;function circuitRelayTransport(e={}){return t=>new CircuitRelayTransport(t,e)}const version="0.46.11",AGENT_VERSION=`js-libp2p/${version}`,IDENTIFY_PROTOCOL_VERSION="0.1.0",MULTICODEC_IDENTIFY_PROTOCOL_NAME="id",MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME="id/push",MULTICODEC_IDENTIFY_PROTOCOL_VERSION="1.0.0",MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION="1.0.0";var Identify;(function(e){let t;e.codec=()=>(t==null&&(t=message((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.protocolVersion!=null&&(n.uint32(42),n.string(r.protocolVersion)),r.agentVersion!=null&&(n.uint32(50),n.string(r.agentVersion)),r.publicKey!=null&&(n.uint32(10),n.bytes(r.publicKey)),r.listenAddrs!=null)for(const a of r.listenAddrs)n.uint32(18),n.bytes(a);if(r.observedAddr!=null&&(n.uint32(34),n.bytes(r.observedAddr)),r.protocols!=null)for(const a of r.protocols)n.uint32(26),n.string(a);r.signedPeerRecord!=null&&(n.uint32(66),n.bytes(r.signedPeerRecord)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{const o={listenAddrs:[],protocols:[]},a=n==null?r.len:r.pos+n;for(;r.pos>>3){case 5:o.protocolVersion=r.string();break;case 6:o.agentVersion=r.string();break;case 1:o.publicKey=r.bytes();break;case 2:o.listenAddrs.push(r.bytes());break;case 4:o.observedAddr=r.bytes();break;case 3:o.protocols.push(r.string());break;case 8:o.signedPeerRecord=r.bytes();break;default:r.skipType(l&7);break}}return o})),t),e.encode=r=>encodeMessage(r,e.codec()),e.decode=r=>decodeMessage(r,e.codec())})(Identify||(Identify={}));const log$1=logger("libp2p:identify"),MAX_IDENTIFY_MESSAGE_SIZE=1024*8,defaultValues={protocolPrefix:"ipfs",agentVersion:AGENT_VERSION,timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1,maxObservedAddresses:10,maxIdentifyMessageSize:8192,runOnConnectionOpen:!0,runOnTransientConnection:!0};var ys,va;class DefaultIdentifyService{constructor(t,r){Er(this,ys);Xe(this,"identifyProtocolStr");Xe(this,"identifyPushProtocolStr");Xe(this,"host");Xe(this,"started");Xe(this,"timeout");Xe(this,"peerId");Xe(this,"peerStore");Xe(this,"registrar");Xe(this,"connectionManager");Xe(this,"addressManager");Xe(this,"maxInboundStreams");Xe(this,"maxOutboundStreams");Xe(this,"maxPushIncomingStreams");Xe(this,"maxPushOutgoingStreams");Xe(this,"maxIdentifyMessageSize");Xe(this,"maxObservedAddresses");Xe(this,"events");Xe(this,"runOnTransientConnection");this.started=!1,this.peerId=t.peerId,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.connectionManager=t.connectionManager,this.events=t.events,this.identifyProtocolStr=`/${r.protocolPrefix??defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`,this.identifyPushProtocolStr=`/${r.protocolPrefix??defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`,this.timeout=r.timeout??defaultValues.timeout,this.maxInboundStreams=r.maxInboundStreams??defaultValues.maxInboundStreams,this.maxOutboundStreams=r.maxOutboundStreams??defaultValues.maxOutboundStreams,this.maxPushIncomingStreams=r.maxPushIncomingStreams??defaultValues.maxPushIncomingStreams,this.maxPushOutgoingStreams=r.maxPushOutgoingStreams??defaultValues.maxPushOutgoingStreams,this.maxIdentifyMessageSize=r.maxIdentifyMessageSize??defaultValues.maxIdentifyMessageSize,this.maxObservedAddresses=r.maxObservedAddresses??defaultValues.maxObservedAddresses,this.runOnTransientConnection=r.runOnTransientConnection??defaultValues.runOnTransientConnection,this.host={protocolVersion:`${r.protocolPrefix??defaultValues.protocolPrefix}/${IDENTIFY_PROTOCOL_VERSION}`,agentVersion:r.agentVersion??defaultValues.agentVersion},(r.runOnConnectionOpen??defaultValues.runOnConnectionOpen)&&t.events.addEventListener("connection:open",n=>{const o=n.detail;this.identify(o).catch(a=>{log$1.error("error during identify trigged by connection:open",a)})}),t.events.addEventListener("self:peer:update",n=>{this.push().catch(o=>{log$1.error(o)})}),this.host.agentVersion===AGENT_VERSION&&(isNode||isElectronMain?this.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(isBrowser||isWebWorker||isElectronRenderer||isReactNative)&&(this.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`))}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:fromString$1(this.host.agentVersion),ProtocolVersion:fromString$1(this.host.protocolVersion)}}),await this.registrar.handle(this.identifyProtocolStr,t=>{this._handleIdentify(t).catch(r=>{log$1.error(r)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),await this.registrar.handle(this.identifyPushProtocolStr,t=>{this._handlePush(t).catch(r=>{log$1.error(r)})},{maxInboundStreams:this.maxPushIncomingStreams,maxOutboundStreams:this.maxPushOutgoingStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.identifyProtocolStr),await this.registrar.unhandle(this.identifyPushProtocolStr),this.started=!1}async pushToConnections(t){const r=this.addressManager.getAddresses().map(b=>b.decapsulateCode(getProtocol("p2p").code)),n=new PeerRecord({peerId:this.peerId,multiaddrs:r}),o=await RecordEnvelope.seal(n,this.peerId),a=this.registrar.getProtocols(),l=await this.peerStore.get(this.peerId),c=toString$5(l.metadata.get("AgentVersion")??fromString$1(this.host.agentVersion)),u=toString$5(l.metadata.get("ProtocolVersion")??fromString$1(this.host.protocolVersion)),g=t.map(async b=>{let x;const S=AbortSignal.timeout(this.timeout);try{events$1.exports.setMaxListeners?.(1/0,S)}catch{}try{x=await b.newStream([this.identifyPushProtocolStr],{signal:S,runOnTransientConnection:this.runOnTransientConnection}),await pbStream(x,{maxDataLength:this.maxIdentifyMessageSize??MAX_IDENTIFY_MESSAGE_SIZE}).pb(Identify).write({listenAddrs:r.map(k=>k.bytes),signedPeerRecord:o.marshal(),protocols:a,agentVersion:c,protocolVersion:u},{signal:S}),await x.close({signal:S})}catch($){log$1.error("could not push identify update to peer",$),x?.abort($)}});await Promise.all(g)}async push(){if(!this.isStarted())return;const t=[];await Promise.all(this.connectionManager.getConnections().map(async r=>{try{if(!(await this.peerStore.get(r.remotePeer)).protocols.includes(this.identifyPushProtocolStr))return;t.push(r)}catch(n){if(n.code!==codes.ERR_NOT_FOUND)throw n}})),await this.pushToConnections(t)}async _identify(t,r={}){let n;r.signal=r.signal??AbortSignal.timeout(this.timeout);try{n=await t.newStream([this.identifyProtocolStr],{...r,runOnTransientConnection:this.runOnTransientConnection});const a=await pbStream(n,{maxDataLength:this.maxIdentifyMessageSize??MAX_IDENTIFY_MESSAGE_SIZE}).pb(Identify).read(r);return await n.close(r),a}catch(o){throw log$1.error("error while reading identify message",o),n?.abort(o),o}}async identify(t,r={}){const n=await this._identify(t,r),{publicKey:o,protocols:a,observedAddr:l}=n;if(o==null)throw new CodeError("public key was missing from identify message",codes.ERR_MISSING_PUBLIC_KEY);const c=await peerIdFromKeys(o);if(!t.remotePeer.equals(c))throw new CodeError("identified peer does not match the expected peer",codes.ERR_INVALID_PEER);if(this.peerId.equals(c))throw new CodeError("identified peer is our own peer id?",codes.ERR_INVALID_PEER);const u=getCleanMultiaddr(l);log$1("identify completed for peer %p and protocols %o",c,a),log$1("our observed address is %a",u),u!=null&&this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(log$1("storing our observed address %a",u),this.addressManager.addObservedAddr(u));const g=await xr(this,ys,va).call(this,t.remotePeer,n),b={peerId:c,protocolVersion:n.protocolVersion,agentVersion:n.agentVersion,publicKey:n.publicKey,listenAddrs:n.listenAddrs.map(x=>multiaddr(x)),observedAddr:n.observedAddr==null?void 0:multiaddr(n.observedAddr),protocols:n.protocols,signedPeerRecord:g};return this.events.safeDispatchEvent("peer:identify",{detail:b}),b}async _handleIdentify(t){const{connection:r,stream:n}=t,o=AbortSignal.timeout(this.timeout);try{events$1.exports.setMaxListeners?.(1/0,o)}catch{}try{const a=this.peerId.publicKey??new Uint8Array(0),l=await this.peerStore.get(this.peerId),c=this.addressManager.getAddresses().map(b=>b.decapsulateCode(getProtocol("p2p").code));let u=l.peerRecordEnvelope;if(c.length>0&&u==null){const b=new PeerRecord({peerId:this.peerId,multiaddrs:c});u=(await RecordEnvelope.seal(b,this.peerId)).marshal().subarray()}await pbStream(n).pb(Identify).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:a,listenAddrs:c.map(b=>b.bytes),signedPeerRecord:u,observedAddr:r.remoteAddr.bytes,protocols:l.protocols},{signal:o}),await n.close({signal:o})}catch(a){log$1.error("could not respond to identify request",a),n.abort(a)}}async _handlePush(t){const{connection:r,stream:n}=t;try{if(this.peerId.equals(r.remotePeer))throw new Error("received push from ourselves?");const o={signal:AbortSignal.timeout(this.timeout)},l=await pbStream(n,{maxDataLength:this.maxIdentifyMessageSize??MAX_IDENTIFY_MESSAGE_SIZE}).pb(Identify).read(o);await n.close(o),await xr(this,ys,va).call(this,r.remotePeer,l)}catch(o){log$1.error("received invalid message",o),n.abort(o);return}log$1("handled push from %p",r.remotePeer)}}ys=new WeakSet,va=async function(t,r){if(log$1("received identify from %p",t),r==null)throw new Error("Message was null or undefined");const n={addresses:r.listenAddrs.map(a=>({isCertified:!1,multiaddr:multiaddr(a)})),protocols:r.protocols,metadata:new Map,peerRecordEnvelope:r.signedPeerRecord};let o;if(r.signedPeerRecord!=null){log$1("received signedPeerRecord in push from %p",t);let a=r.signedPeerRecord;const l=await RecordEnvelope.openAndCertify(a,PeerRecord.DOMAIN);let c=PeerRecord.createFromProtobuf(l.payload);if(!c.peerId.equals(l.peerId))throw new Error("signing key does not match PeerId in the PeerRecord");if(!t.equals(c.peerId))throw new Error("signing key does not match remote PeerId");let u;try{u=await this.peerStore.get(c.peerId)}catch(g){if(g.code!=="ERR_NOT_FOUND")throw g}if(u!=null&&(n.metadata=u.metadata,u.peerRecordEnvelope!=null)){const g=await RecordEnvelope.createFromProtobuf(u.peerRecordEnvelope),b=PeerRecord.createFromProtobuf(g.payload);b.seqNumber>=c.seqNumber&&(log$1("sequence number was lower or equal to existing sequence number - stored: %d received: %d",b.seqNumber,c.seqNumber),c=b,a=u.peerRecordEnvelope)}n.peerRecordEnvelope=a,n.addresses=c.multiaddrs.map(g=>({isCertified:!0,multiaddr:g})),o={seq:c.seqNumber,addresses:c.multiaddrs}}else log$1("%p did not send a signed peer record",t);return r.agentVersion!=null&&n.metadata.set("AgentVersion",fromString$1(r.agentVersion)),r.protocolVersion!=null&&n.metadata.set("ProtocolVersion",fromString$1(r.protocolVersion)),await this.peerStore.patch(t,n),o};function getCleanMultiaddr(e){if(e!=null&&e.length>0)try{return multiaddr(e)}catch{}}function identifyService(e={}){return t=>new DefaultIdentifyService(t,e)}const createNode=async e=>await createLibp2p({addresses:{listen:["/webrtc"]},transports:[webSockets({filter:all$1}),webRTC(),circuitRelayTransport({discoverRelays:1})],streamMuxers:[mplex()],connectionEncryption:[noise()],services:{pubsub:floodsub(),identify:identifyService()},peerDiscovery:[bootstrap({list:e.bootstrappers})],connectionGater:{denyDialMultiaddr:()=>!1}}),topic="airalab.lighthouse.5.robonomics.eth";class Provider$1{constructor(t){this.node=null,this.isReady=!1,this.whiteListAccounts=[],this.history={},this.init(t).then(()=>{this.isReady=!0,window.pubsubPeers=()=>{console.log("peers",this.node.services.pubsub.getPeers().map(r=>r.toString())),console.log("pubsub",this.node.services.pubsub.getSubscribers(topic).map(r=>r.toString()))}})}async init(t){this.node=await createNode(t),this.whiteListAccounts=getAgents()}ready(){return new Promise(t=>{const r=setInterval(()=>{this.isReady&&(t(),clearInterval(r))},100)})}getHistoryBySensor(t){return Promise.resolve(this.history[t]?this.history[t]:[])}watch(t){this.node.services.pubsub.subscribe(topic),this.node.services.pubsub.addEventListener("message",r=>{const n=r.detail.from.toString();if(!this.whiteListAccounts.includes(n))return;let o;try{o=JSON.parse(Buffer.from(r.detail.data).toString("utf8"))}catch(l){console.error(l.message);return}for(const l in o){const c=o[l];if(Object.prototype.hasOwnProperty.call(c,"model")&&(!Object.prototype.hasOwnProperty.call(this.history,l)||this.history[l].find(u=>u.timestamp===c.measurement.timestamp)===void 0)){const{timestamp:u,...g}=c.measurement,b={};for(var a in g){const T=a.toLowerCase();b[T]=measurements[T]?.calculate?measurements[T].calculate(g[a]):g[a]}const[x,S]=c.geo.split(","),$=c.donated_by||void 0,k={sensor_id:l,sender:n,model:c.model,geo:{lat:x,lng:S},data:b,donated_by:$,timestamp:u};Object.prototype.hasOwnProperty.call(this.history,l)||(this.history[l]=[]),this.history[l].push(k),t(k)}}})}}var lib$1={exports:{}},re=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,parts=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],parseuri$2=function e(t){var r=t,n=t.indexOf("["),o=t.indexOf("]");n!=-1&&o!=-1&&(t=t.substring(0,n)+t.substring(n,o).replace(/:/g,";")+t.substring(o,t.length));for(var a=re.exec(t||""),l={},c=14;c--;)l[parts[c]]=a[c]||"";return n!=-1&&o!=-1&&(l.source=r,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=pathNames(l,l.path),l.queryKey=queryKey(l,l.query),l};function pathNames(e,t){var r=/\/{2,9}/g,n=t.replace(r,"/").split("/");return(t.substr(0,1)=="/"||t.length===0)&&n.splice(0,1),t.substr(t.length-1,1)=="/"&&n.splice(n.length-1,1),n}function queryKey(e,t){var r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,o,a){o&&(r[o]=a)}),r}var browser$3={exports:{}},debug$8={exports:{}},s$2=1e3,m$3=s$2*60,h$3=m$3*60,d$4=h$3*24,y$2=d$4*365.25,ms$2=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return parse$4(e);if(r==="number"&&isNaN(e)===!1)return t.long?fmtLong$2(e):fmtShort$2(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse$4(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!!t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*y$2;case"days":case"day":case"d":return r*d$4;case"hours":case"hour":case"hrs":case"hr":case"h":return r*h$3;case"minutes":case"minute":case"mins":case"min":case"m":return r*m$3;case"seconds":case"second":case"secs":case"sec":case"s":return r*s$2;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function fmtShort$2(e){return e>=d$4?Math.round(e/d$4)+"d":e>=h$3?Math.round(e/h$3)+"h":e>=m$3?Math.round(e/m$3)+"m":e>=s$2?Math.round(e/s$2)+"s":e+"ms"}function fmtLong$2(e){return plural$2(e,d$4,"day")||plural$2(e,h$3,"hour")||plural$2(e,m$3,"minute")||plural$2(e,s$2,"second")||e+" ms"}function plural$2(e,t,r){if(!(e=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}t.formatters.j=function(u){try{return JSON.stringify(u)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}};function n(u){var g=this.useColors;if(u[0]=(g?"%c":"")+this.namespace+(g?" %c":" ")+u[0]+(g?"%c ":" ")+"+"+t.humanize(this.diff),!!g){var b="color: "+this.color;u.splice(1,0,b,"color: inherit");var x=0,S=0;u[0].replace(/%[a-zA-Z%]/g,function($){$!=="%%"&&(x++,$==="%c"&&(S=x))}),u.splice(S,0,b)}}function o(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(u){try{u==null?t.storage.removeItem("debug"):t.storage.debug=u}catch{}}function l(){var u;try{u=t.storage.debug}catch{}return!u&&typeof process<"u"&&"env"in process&&(u={}.DEBUG),u}t.enable(l());function c(){try{return window.localStorage}catch{}}})(browser$3,browser$3.exports);var parseuri$1=parseuri$2,debug$7=browser$3.exports("socket.io-client:url"),url_1=url;function url(e,t){var r=e;t=t||typeof location<"u"&&location,e==null&&(e=t.protocol+"//"+t.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=t.protocol+e:e=t.host+e),/^(https?|wss?):\/\//.test(e)||(debug$7("protocol-less url %s",e),typeof t<"u"?e=t.protocol+"//"+e:e="https://"+e),debug$7("parse %s",e),r=parseuri$1(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var n=r.host.indexOf(":")!==-1,o=n?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port,r.href=r.protocol+"://"+o+(t&&t.port===r.port?"":":"+r.port),r}var socket_ioParser={},browser$2={exports:{}},debug$6={exports:{}},s$1=1e3,m$2=s$1*60,h$2=m$2*60,d$3=h$2*24,y$1=d$3*365.25,ms$1=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return parse$3(e);if(r==="number"&&isNaN(e)===!1)return t.long?fmtLong$1(e):fmtShort$1(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse$3(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!!t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*y$1;case"days":case"day":case"d":return r*d$3;case"hours":case"hour":case"hrs":case"hr":case"h":return r*h$2;case"minutes":case"minute":case"mins":case"min":case"m":return r*m$2;case"seconds":case"second":case"secs":case"sec":case"s":return r*s$1;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function fmtShort$1(e){return e>=d$3?Math.round(e/d$3)+"d":e>=h$2?Math.round(e/h$2)+"h":e>=m$2?Math.round(e/m$2)+"m":e>=s$1?Math.round(e/s$1)+"s":e+"ms"}function fmtLong$1(e){return plural$1(e,d$3,"day")||plural$1(e,h$2,"hour")||plural$1(e,m$2,"minute")||plural$1(e,s$1,"second")||e+" ms"}function plural$1(e,t,r){if(!(e=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}t.formatters.j=function(u){try{return JSON.stringify(u)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}};function n(u){var g=this.useColors;if(u[0]=(g?"%c":"")+this.namespace+(g?" %c":" ")+u[0]+(g?"%c ":" ")+"+"+t.humanize(this.diff),!!g){var b="color: "+this.color;u.splice(1,0,b,"color: inherit");var x=0,S=0;u[0].replace(/%[a-zA-Z%]/g,function($){$!=="%%"&&(x++,$==="%c"&&(S=x))}),u.splice(S,0,b)}}function o(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(u){try{u==null?t.storage.removeItem("debug"):t.storage.debug=u}catch{}}function l(){var u;try{u=t.storage.debug}catch{}return!u&&typeof process<"u"&&"env"in process&&(u={}.DEBUG),u}t.enable(l());function c(){try{return window.localStorage}catch{}}})(browser$2,browser$2.exports);var componentEmitter={exports:{}};(function(e){e.exports=t;function t(n){if(n)return r(n)}function r(n){for(var o in t.prototype)n[o]=t.prototype[o];return n}t.prototype.on=t.prototype.addEventListener=function(n,o){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(o),this},t.prototype.once=function(n,o){function a(){this.off(n,a),o.apply(this,arguments)}return a.fn=o,this.on(n,a),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(n,o){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var a=this._callbacks["$"+n];if(!a)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var l,c=0;c=0&&e.numn&&(r=n),t>=n||t>=r||n===0)return new ArrayBuffer(0);for(var o=new Uint8Array(e),a=new Uint8Array(r-t),l=t,c=0;l=55296&&o<=56319&&r65535&&(n-=65536,o+=stringFromCharCode(n>>>10&1023|55296),n=56320|n&1023),o+=stringFromCharCode(n);return o}function checkScalarValue(e,t){if(e>=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function createByte(e,t){return stringFromCharCode(e>>t&63|128)}function encodeCodePoint(e,t){if((e&4294967168)==0)return stringFromCharCode(e);var r="";return(e&4294965248)==0?r=stringFromCharCode(e>>6&31|192):(e&4294901760)==0?(checkScalarValue(e,t)||(e=65533),r=stringFromCharCode(e>>12&15|224),r+=createByte(e,6)):(e&4292870144)==0&&(r=stringFromCharCode(e>>18&7|240),r+=createByte(e,12),r+=createByte(e,6)),r+=stringFromCharCode(e&63|128),r}function utf8encode(e,t){t=t||{};for(var r=t.strict!==!1,n=ucs2decode$1(e),o=n.length,a=-1,l,c="";++a=byteCount)throw Error("Invalid byte index");var e=byteArray[byteIndex]&255;if(byteIndex++,(e&192)==128)return e&63;throw Error("Invalid continuation byte")}function decodeSymbol(e){var t,r,n,o,a;if(byteIndex>byteCount)throw Error("Invalid byte index");if(byteIndex==byteCount)return!1;if(t=byteArray[byteIndex]&255,byteIndex++,(t&128)==0)return t;if((t&224)==192){if(r=readContinuationByte(),a=(t&31)<<6|r,a>=128)return a;throw Error("Invalid continuation byte")}if((t&240)==224){if(r=readContinuationByte(),n=readContinuationByte(),a=(t&15)<<12|r<<6|n,a>=2048)return checkScalarValue(a,e)?a:65533;throw Error("Invalid continuation byte")}if((t&248)==240&&(r=readContinuationByte(),n=readContinuationByte(),o=readContinuationByte(),a=(t&7)<<18|r<<12|n<<6|o,a>=65536&&a<=1114111))return a;throw Error("Invalid UTF-8 detected")}var byteArray,byteCount,byteIndex;function utf8decode(e,t){t=t||{};var r=t.strict!==!1;byteArray=ucs2decode$1(e),byteCount=byteArray.length,byteIndex=0;for(var n=[],o;(o=decodeSymbol(r))!==!1;)n.push(o);return ucs2encode(n)}var utf8={version:"2.1.2",encode:utf8encode,decode:utf8decode},base64Arraybuffer={},hasRequiredBase64Arraybuffer;function requireBase64Arraybuffer(){return hasRequiredBase64Arraybuffer||(hasRequiredBase64Arraybuffer=1,function(e){base64Arraybuffer.encode=function(t){var r=new Uint8Array(t),n,o=r.length,a="";for(n=0;n>2],a+=e[(r[n]&3)<<4|r[n+1]>>4],a+=e[(r[n+1]&15)<<2|r[n+2]>>6],a+=e[r[n+2]&63];return o%3===2?a=a.substring(0,a.length-1)+"=":o%3===1&&(a=a.substring(0,a.length-2)+"=="),a},base64Arraybuffer.decode=function(t){var r=t.length*.75,n=t.length,o,a=0,l,c,u,g;t[t.length-1]==="="&&(r--,t[t.length-2]==="="&&r--);var b=new ArrayBuffer(r),x=new Uint8Array(b);for(o=0;o>4,x[a++]=(c&15)<<4|u>>2,x[a++]=(u&3)<<6|g&63;return b}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")),base64Arraybuffer}var blob,hasRequiredBlob;function requireBlob(){if(hasRequiredBlob)return blob;hasRequiredBlob=1;var e=typeof e<"u"?e:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:!1,t=function(){try{var c=new Blob(["hi"]);return c.size===2}catch{return!1}}(),r=t&&function(){try{var c=new Blob([new Uint8Array([1,2])]);return c.size===2}catch{return!1}}(),n=e&&e.prototype.append&&e.prototype.getBlob;function o(c){return c.map(function(u){if(u.buffer instanceof ArrayBuffer){var g=u.buffer;if(u.byteLength!==g.byteLength){var b=new Uint8Array(u.byteLength);b.set(new Uint8Array(g,u.byteOffset,u.byteLength)),g=b.buffer}return g}return u})}function a(c,u){u=u||{};var g=new e;return o(c).forEach(function(b){g.append(b)}),u.type?g.getBlob(u.type):g.getBlob()}function l(c,u){return new Blob(o(c),u||{})}return typeof Blob<"u"&&(a.prototype=Blob.prototype,l.prototype=Blob.prototype),blob=function(){return t?r?Blob:l:n?a:void 0}(),blob}(function(e){var t=keys,r=hasBinary2,n=arraybuffer_slice,o=after_1,a=utf8,l;typeof ArrayBuffer<"u"&&(l=requireBase64Arraybuffer());var c=typeof navigator<"u"&&/Android/i.test(navigator.userAgent),u=typeof navigator<"u"&&/PhantomJS/i.test(navigator.userAgent),g=c||u;e.protocol=3;var b=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},x=t(b),S={type:"error",data:"parser error"},$=requireBlob();e.encodePacket=function(ee,ne,B,le){typeof ne=="function"&&(le=ne,ne=!1),typeof B=="function"&&(le=B,B=null);var fe=ee.data===void 0?void 0:ee.data.buffer||ee.data;if(typeof ArrayBuffer<"u"&&fe instanceof ArrayBuffer)return T(ee,ne,le);if(typeof $<"u"&&fe instanceof $)return I(ee,ne,le);if(fe&&fe.base64)return k(ee,le);var xe=b[ee.type];return ee.data!==void 0&&(xe+=B?a.encode(String(ee.data),{strict:!1}):String(ee.data)),le(""+xe)};function k(ee,ne){var B="b"+e.packets[ee.type]+ee.data.data;return ne(B)}function T(ee,ne,B){if(!ne)return e.encodeBase64Packet(ee,B);var le=ee.data,fe=new Uint8Array(le),xe=new Uint8Array(1+le.byteLength);xe[0]=b[ee.type];for(var we=0;we1?{type:x[fe],data:ee.substring(1)}:{type:x[fe]}}var le=new Uint8Array(ee),fe=le[0],xe=n(ee,1);return $&&ne==="blob"&&(xe=new $([xe])),{type:x[fe],data:xe}};function O(ee){try{ee=a.decode(ee,{strict:!1})}catch{return!1}return ee}e.decodeBase64Packet=function(ee,ne){var B=x[ee.charAt(0)];if(!l)return{type:B,data:{base64:!0,data:ee.substr(1)}};var le=l.decode(ee.substr(1));return ne==="blob"&&$&&(le=new $([le])),{type:B,data:le}},e.encodePayload=function(ee,ne,B){typeof ne=="function"&&(B=ne,ne=null);var le=r(ee);if(ne&&le)return $&&!g?e.encodePayloadAsBlob(ee,B):e.encodePayloadAsArrayBuffer(ee,B);if(!ee.length)return B("0:");function fe(we){return we.length+":"+we}function xe(we,he){e.encodePacket(we,le?ne:!1,!1,function(_e){he(null,fe(_e))})}N(ee,xe,function(we,he){return B(he.join(""))})};function N(ee,ne,B){for(var le=new Array(ee.length),fe=o(ee.length,B),xe=function(he,_e,ve){ne(_e,function(ae,ie){le[he]=ie,ve(ae,le)})},we=0;we0;){for(var xe=new Uint8Array(le),we=xe[0]===0,he="",_e=1;xe[_e]!==255;_e++){if(he.length>310)return B(S,0,1);he+=xe[_e]}le=n(le,2+he.length),he=parseInt(he);var ve=n(le,0,he);if(we)try{ve=String.fromCharCode.apply(null,new Uint8Array(ve))}catch{var ae=new Uint8Array(ve);ve="";for(var _e=0;_e0);return t}function decode(e){var t=0;for(i=0;i0)return parse$2(e);if(r==="number"&&isNaN(e)===!1)return t.long?fmtLong(e):fmtShort(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function parse$2(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!!t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*y;case"days":case"day":case"d":return r*d$2;case"hours":case"hour":case"hrs":case"hr":case"h":return r*h$1;case"minutes":case"minute":case"mins":case"min":case"m":return r*m$1;case"seconds":case"second":case"secs":case"sec":case"s":return r*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function fmtShort(e){return e>=d$2?Math.round(e/d$2)+"d":e>=h$1?Math.round(e/h$1)+"h":e>=m$1?Math.round(e/m$1)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function fmtLong(e){return plural(e,d$2,"day")||plural(e,h$1,"hour")||plural(e,m$1,"minute")||plural(e,s,"second")||e+" ms"}function plural(e,t,r){if(!(e=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}t.formatters.j=function(u){try{return JSON.stringify(u)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}};function n(u){var g=this.useColors;if(u[0]=(g?"%c":"")+this.namespace+(g?" %c":" ")+u[0]+(g?"%c ":" ")+"+"+t.humanize(this.diff),!!g){var b="color: "+this.color;u.splice(1,0,b,"color: inherit");var x=0,S=0;u[0].replace(/%[a-zA-Z%]/g,function($){$!=="%%"&&(x++,$==="%c"&&(S=x))}),u.splice(S,0,b)}}function o(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(u){try{u==null?t.storage.removeItem("debug"):t.storage.debug=u}catch{}}function l(){var u;try{u=t.storage.debug}catch{}return!u&&typeof process<"u"&&"env"in process&&(u={}.DEBUG),u}t.enable(l());function c(){try{return window.localStorage}catch{}}})(browser,browser.exports);var Transport$1=requireTransport(),parseqs$2=parseqs$3,parser$3=browser$1,inherit$3=componentInherit,yeast$1=yeast_1,debug$4=browser.exports("engine.io-client:polling"),polling$1=Polling$2,hasXHR2=function(){var e=xmlhttprequest_browser,t=new e({xdomain:!1});return t.responseType!=null}();function Polling$2(e){var t=e&&e.forceBase64;(!hasXHR2||t)&&(this.supportsBinary=!1),Transport$1.call(this,e)}inherit$3(Polling$2,Transport$1);Polling$2.prototype.name="polling";Polling$2.prototype.doOpen=function(){this.poll()};Polling$2.prototype.pause=function(e){var t=this;this.readyState="pausing";function r(){debug$4("paused"),t.readyState="paused",e()}if(this.polling||!this.writable){var n=0;this.polling&&(debug$4("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){debug$4("pre-pause polling complete"),--n||r()})),this.writable||(debug$4("we are currently writing - waiting to pause"),n++,this.once("drain",function(){debug$4("pre-pause writing complete"),--n||r()}))}else r()};Polling$2.prototype.poll=function(){debug$4("polling"),this.polling=!0,this.doPoll(),this.emit("poll")};Polling$2.prototype.onData=function(e){var t=this;debug$4("polling got data %s",e);var r=function(n,o,a){if(t.readyState==="opening"&&n.type==="open"&&t.onOpen(),n.type==="close")return t.onClose(),!1;t.onPacket(n)};parser$3.decodePayload(e,this.socket.binaryType,r),this.readyState!=="closed"&&(this.polling=!1,this.emit("pollComplete"),this.readyState==="open"?this.poll():debug$4('ignoring poll - transport state "%s"',this.readyState))};Polling$2.prototype.doClose=function(){var e=this;function t(){debug$4("writing close packet"),e.write([{type:"close"}])}this.readyState==="open"?(debug$4("transport open - closing"),t()):(debug$4("transport not open - deferring close"),this.once("open",t))};Polling$2.prototype.write=function(e){var t=this;this.writable=!1;var r=function(){t.writable=!0,t.emit("drain")};parser$3.encodePayload(e,this.supportsBinary,function(n){t.doWrite(n,r)})};Polling$2.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",r="";this.timestampRequests!==!1&&(e[this.timestampParam]=yeast$1()),!this.supportsBinary&&!e.sid&&(e.b64=1),e=parseqs$2.encode(e),this.port&&(t==="https"&&Number(this.port)!==443||t==="http"&&Number(this.port)!==80)&&(r=":"+this.port),e.length&&(e="?"+e);var n=this.hostname.indexOf(":")!==-1;return t+"://"+(n?"["+this.hostname+"]":this.hostname)+r+this.path+e};var XMLHttpRequest$2=xmlhttprequest_browser,Polling$1=polling$1,Emitter$2=componentEmitter.exports,inherit$2=componentInherit,debug$3=browser.exports("engine.io-client:polling-xhr"),globalThis$2=globalThis_browser;pollingXhr.exports=XHR$1;pollingXhr.exports.Request=Request;function empty$1(){}function XHR$1(e){if(Polling$1.call(this,e),this.requestTimeout=e.requestTimeout,this.extraHeaders=e.extraHeaders,typeof location<"u"){var t=location.protocol==="https:",r=location.port;r||(r=t?443:80),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port,this.xs=e.secure!==t}}inherit$2(XHR$1,Polling$1);XHR$1.prototype.supportsBinary=!0;XHR$1.prototype.request=function(e){return e=e||{},e.uri=this.uri(),e.xd=this.xd,e.xs=this.xs,e.agent=this.agent||!1,e.supportsBinary=this.supportsBinary,e.enablesXDR=this.enablesXDR,e.withCredentials=this.withCredentials,e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized,e.requestTimeout=this.requestTimeout,e.extraHeaders=this.extraHeaders,new Request(e)};XHR$1.prototype.doWrite=function(e,t){var r=typeof e!="string"&&e!==void 0,n=this.request({method:"POST",data:e,isBinary:r}),o=this;n.on("success",t),n.on("error",function(a){o.onError("xhr post error",a)}),this.sendXhr=n};XHR$1.prototype.doPoll=function(){debug$3("xhr poll");var e=this.request(),t=this;e.on("data",function(r){t.onData(r)}),e.on("error",function(r){t.onError("xhr poll error",r)}),this.pollXhr=e};function Request(e){this.method=e.method||"GET",this.uri=e.uri,this.xd=!!e.xd,this.xs=!!e.xs,this.async=e.async!==!1,this.data=e.data!==void 0?e.data:null,this.agent=e.agent,this.isBinary=e.isBinary,this.supportsBinary=e.supportsBinary,this.enablesXDR=e.enablesXDR,this.withCredentials=e.withCredentials,this.requestTimeout=e.requestTimeout,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.extraHeaders=e.extraHeaders,this.create()}Emitter$2(Request.prototype);Request.prototype.create=function(){var e={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized;var t=this.xhr=new XMLHttpRequest$2(e),r=this;try{debug$3("xhr open %s: %s",this.method,this.uri),t.open(this.method,this.uri,this.async);try{if(this.extraHeaders){t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0);for(var n in this.extraHeaders)this.extraHeaders.hasOwnProperty(n)&&t.setRequestHeader(n,this.extraHeaders[n])}}catch{}if(this.method==="POST")try{this.isBinary?t.setRequestHeader("Content-type","application/octet-stream"):t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{t.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in t&&(t.withCredentials=this.withCredentials),this.requestTimeout&&(t.timeout=this.requestTimeout),this.hasXDR()?(t.onload=function(){r.onLoad()},t.onerror=function(){r.onError(t.responseText)}):t.onreadystatechange=function(){if(t.readyState===2)try{var o=t.getResponseHeader("Content-Type");(r.supportsBinary&&o==="application/octet-stream"||o==="application/octet-stream; charset=UTF-8")&&(t.responseType="arraybuffer")}catch{}t.readyState===4&&(t.status===200||t.status===1223?r.onLoad():setTimeout(function(){r.onError(typeof t.status=="number"?t.status:0)},0))},debug$3("xhr data %s",this.data),t.send(this.data)}catch(o){setTimeout(function(){r.onError(o)},0);return}typeof document<"u"&&(this.index=Request.requestsCount++,Request.requests[this.index]=this)};Request.prototype.onSuccess=function(){this.emit("success"),this.cleanup()};Request.prototype.onData=function(e){this.emit("data",e),this.onSuccess()};Request.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)};Request.prototype.cleanup=function(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=empty$1:this.xhr.onreadystatechange=empty$1,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Request.requests[this.index],this.xhr=null}};Request.prototype.onLoad=function(){var e;try{var t;try{t=this.xhr.getResponseHeader("Content-Type")}catch{}t==="application/octet-stream"||t==="application/octet-stream; charset=UTF-8"?e=this.xhr.response||this.xhr.responseText:e=this.xhr.responseText}catch(r){this.onError(r)}e!=null&&this.onData(e)};Request.prototype.hasXDR=function(){return typeof XDomainRequest<"u"&&!this.xs&&this.enablesXDR};Request.prototype.abort=function(){this.cleanup()};Request.requestsCount=0;Request.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",unloadHandler);else if(typeof addEventListener=="function"){var terminationEvent="onpagehide"in globalThis$2?"pagehide":"unload";addEventListener(terminationEvent,unloadHandler,!1)}}function unloadHandler(){for(var e in Request.requests)Request.requests.hasOwnProperty(e)&&Request.requests[e].abort()}var Polling=polling$1,inherit$1=componentInherit,globalThis$1=globalThis_browser,pollingJsonp=JSONPPolling,rNewline=/\n/g,rEscapedNewline=/\\n/g,callbacks;function empty(){}function JSONPPolling(e){Polling.call(this,e),this.query=this.query||{},callbacks||(callbacks=globalThis$1.___eio=globalThis$1.___eio||[]),this.index=callbacks.length;var t=this;callbacks.push(function(r){t.onData(r)}),this.query.j=this.index,typeof addEventListener=="function"&&addEventListener("beforeunload",function(){t.script&&(t.script.onerror=empty)},!1)}inherit$1(JSONPPolling,Polling);JSONPPolling.prototype.supportsBinary=!1;JSONPPolling.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),Polling.prototype.doClose.call(this)};JSONPPolling.prototype.doPoll=function(){var e=this,t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=function(o){e.onError("jsonp poll error",o)};var r=document.getElementsByTagName("script")[0];r?r.parentNode.insertBefore(t,r):(document.head||document.body).appendChild(t),this.script=t;var n=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);n&&setTimeout(function(){var o=document.createElement("iframe");document.body.appendChild(o),document.body.removeChild(o)},100)};JSONPPolling.prototype.doWrite=function(e,t){var r=this;if(!this.form){var n=document.createElement("form"),o=document.createElement("textarea"),a=this.iframeId="eio_iframe_"+this.index,l;n.className="socketio",n.style.position="absolute",n.style.top="-1000px",n.style.left="-1000px",n.target=a,n.method="POST",n.setAttribute("accept-charset","utf-8"),o.name="d",n.appendChild(o),document.body.appendChild(n),this.form=n,this.area=o}this.form.action=this.uri();function c(){u(),t()}function u(){if(r.iframe)try{r.form.removeChild(r.iframe)}catch(b){r.onError("jsonp polling iframe removal error",b)}try{var g='