open-plant 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -159,6 +159,6 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
159
159
  // Premultiplied alpha output: inner fill is black, so it only contributes alpha.
160
160
  outColor = vec4(color.rgb * ringAlpha, alpha);
161
161
  }
162
- }`),i=_e(e,r,"uCamera"),o=_e(e,r,"uPointSize"),s=_e(e,r,"uPointStrokeScale"),a=_e(e,r,"uPointInnerFillAlpha"),c=_e(e,r,"uPalette"),u=_e(e,r,"uPaletteSize"),h=e.createVertexArray(),l=e.createBuffer(),f=e.createBuffer(),d=e.createBuffer(),m=e.createBuffer(),p=e.createTexture();if(!h||!l||!f||!d||!m||!p)throw new Error("point buffer allocation failed");e.bindVertexArray(h),e.bindBuffer(e.ARRAY_BUFFER,l),e.bufferData(e.ARRAY_BUFFER,0,e.DYNAMIC_DRAW);const y=e.getAttribLocation(r,"aPosition");if(y<0)throw new Error("point position attribute not found");e.enableVertexAttribArray(y),e.vertexAttribPointer(y,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,0,e.DYNAMIC_DRAW);const b=e.getAttribLocation(r,"aTerm");if(b<0)throw new Error("point term attribute not found");e.enableVertexAttribArray(b),e.vertexAttribIPointer(b,1,e.UNSIGNED_SHORT,0,0),e.bindBuffer(e.ARRAY_BUFFER,d),e.bufferData(e.ARRAY_BUFFER,0,e.DYNAMIC_DRAW);const x=e.getAttribLocation(r,"aFillMode");if(x<0)throw new Error("point fill mode attribute not found");return e.enableVertexAttribArray(x),e.vertexAttribIPointer(x,1,e.UNSIGNED_BYTE,0,0),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m),e.bufferData(e.ELEMENT_ARRAY_BUFFER,0,e.DYNAMIC_DRAW),e.bindVertexArray(null),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),e.bindTexture(e.TEXTURE_2D,p),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([160,160,160,255])),e.bindTexture(e.TEXTURE_2D,null),{program:r,vao:h,posBuffer:l,termBuffer:f,fillModeBuffer:d,indexBuffer:m,paletteTexture:p,uCamera:i,uPointSize:o,uPointStrokeScale:s,uPointInnerFillAlpha:a,uPalette:c,uPaletteSize:u}}function gi(e){e.animation=null,e.frame!==null&&(cancelAnimationFrame(e.frame),e.frame=null)}function nl(e){const{state:t,camera:n,target:r,durationMs:i,easing:o,onUpdate:s}=e,a=n.getViewState();gi(t),t.animation={startMs:be(),durationMs:Math.max(0,i),from:a,to:r,easing:o};const c=()=>{const u=t.animation;if(!u)return;const h=Math.max(0,be()-u.startMs),l=u.durationMs<=0?1:W(h/u.durationMs,0,1);let f=l;try{f=u.easing(l)}catch{f=l}if(Number.isFinite(f)||(f=l),f=W(f,0,1),n.setViewState({zoom:u.from.zoom+(u.to.zoom-u.from.zoom)*f,offsetX:u.from.offsetX+(u.to.offsetX-u.from.offsetX)*f,offsetY:u.from.offsetY+(u.to.offsetY-u.from.offsetY)*f,rotationDeg:u.from.rotationDeg+(u.to.rotationDeg-u.from.rotationDeg)*f}),s(),l>=1){t.animation=null,t.frame=null;return}t.frame=requestAnimationFrame(c)};t.frame=requestAnimationFrame(c)}function rl(e){const t=Math.max(e*.5,1e-6),n=Math.max(1,e*8);return{minZoom:t,maxZoom:Math.max(t,n)}}function il(e,t,n){const r=rl(e);let i=t??r.minZoom,o=n??r.maxZoom;return i=Math.max(1e-6,i),o=Math.max(1e-6,o),i>o&&(i=o),{minZoom:i,maxZoom:o}}function ol(e,t,n,r,i){const o=e.getViewState(),s={zoom:typeof r.zoom=="number"&&Number.isFinite(r.zoom)?W(r.zoom,t,n):o.zoom,offsetX:typeof r.offsetX=="number"&&Number.isFinite(r.offsetX)?r.offsetX:o.offsetX,offsetY:typeof r.offsetY=="number"&&Number.isFinite(r.offsetY)?r.offsetY:o.offsetY,rotationDeg:typeof r.rotationDeg=="number"&&Number.isFinite(r.rotationDeg)?r.rotationDeg:o.rotationDeg};e.setViewState(s),i();const a=e.getViewState();return e.setViewState(o),a}function Pr(e,t,n,r,i){const o=Math.min(t/e.width,n/e.height),s=Number.isFinite(o)&&o>0?o:1,a=W(s,r,i),c=t/a,u=n/a;return{fitZoom:s,target:{zoom:a,offsetX:(e.width-c)*.5,offsetY:(e.height-u)*.5,rotationDeg:0}}}function sl(e,t,n,r,i,o){const s=e.getViewState(),a=W(s.zoom*r,t,n);if(a===s.zoom)return null;const[c,u]=e.screenToWorld(i,o),h=e.getViewportSize(),l=i-h.width*.5,f=o-h.height*.5,d=Vt(s.rotationDeg),m=Math.cos(d),p=Math.sin(d),y=l/a*m-f/a*p,b=l/a*p+f/a*m,x=c-y,C=u-b;return{zoom:a,offsetX:x-h.width/(2*a),offsetY:C-h.height/(2*a)}}function al(e,t,n,r,i,o){const s=e.getViewState(),a=W(r,t,n);if(a===s.zoom)return null;const[c,u]=e.screenToWorld(i,o),h=e.getViewportSize(),l=i-h.width*.5,f=o-h.height*.5,d=Vt(s.rotationDeg),m=Math.cos(d),p=Math.sin(d),y=l/a*m-f/a*p,b=l/a*p+f/a*m,x=c-y,C=u-b;return{zoom:a,offsetX:x-h.width/(2*a),offsetY:C-h.height/(2*a)}}const Tr=250;function _r(e,t){if(!e||e.length===0)return[];if(!t||t<=0)return[];const n=10/t;return e.map(r=>r/n).filter(r=>Number.isFinite(r)&&r>0).sort((r,i)=>r-i)}function ll(e,t,n,r){if(e.length===0)return null;const i=Math.max(t*.005,1e-8);if(n==="in"){for(const o of e)if(o>t+i)return{type:"snap",zoom:o};return null}for(let o=e.length-1;o>=0;o--)if(e[o]<t-i)return{type:"snap",zoom:e[o]};return r&&t<=e[0]+i?{type:"fit"}:null}function Fr(e,t,n,r,i){const o=e.camera.getViewState(),[s,a]=e.camera.screenToWorld(n,r),c=e.camera.getViewportSize(),u=W(t,e.minZoom,e.maxZoom);if(u===o.zoom)return;const h=Vt(o.rotationDeg),l=Math.cos(h),f=Math.sin(h),d=n-c.width*.5,m=r-c.height*.5;e.cancelViewAnimation();const p=x=>{const C=d/x*l-m/x*f,S=d/x*f+m/x*l;return{offsetX:s-C-c.width/(2*x),offsetY:a-S-c.height/(2*x)}},y=p(u);e.viewAnimationState.animation={startMs:be(),durationMs:Math.max(0,i),from:o,to:{zoom:u,offsetX:y.offsetX,offsetY:y.offsetY,rotationDeg:o.rotationDeg},easing:Tn};const b=()=>{const x=e.viewAnimationState.animation;if(!x)return;const C=Math.max(0,be()-x.startMs),S=W(C/i,0,1),A=W(S*S*(3-2*S),0,1),T=o.zoom+(u-o.zoom)*A,{offsetX:O,offsetY:z}=p(T);e.camera.setViewState({zoom:T,offsetX:O,offsetY:z,rotationDeg:o.rotationDeg});const G=S>=1;G&&(e.clampViewState(),e.viewAnimationState.animation=null,e.viewAnimationState.frame=null),e.onViewStateChange(e.camera.getViewState()),e.requestRender(),G||(e.viewAnimationState.frame=requestAnimationFrame(b))};e.viewAnimationState.frame=requestAnimationFrame(b)}class pi{constructor(t,n,r={}){R(this,"canvas");R(this,"source");R(this,"gl");R(this,"camera",new Br);R(this,"onViewStateChange");R(this,"onStats");R(this,"onTileError");R(this,"onContextLost");R(this,"onContextRestored");R(this,"resizeObserver");R(this,"tileProgram");R(this,"pointProgram");R(this,"tileScheduler");R(this,"zoomStack",{cnt:0,direction:null});R(this,"authToken");R(this,"destroyed",!1);R(this,"contextLost",!1);R(this,"frame",null);R(this,"frameSerial",0);R(this,"interactionState",{dragging:!1,mode:"none",rotateLastAngleRad:null,pointerId:null,lastPointerX:0,lastPointerY:0});R(this,"interactionLocked",!1);R(this,"ctrlDragRotate",!0);R(this,"rotationDragSensitivityDegPerPixel",mn);R(this,"maxCacheTiles");R(this,"fitZoom",1);R(this,"minZoom",1e-6);R(this,"maxZoom",1);R(this,"minZoomOverride",null);R(this,"maxZoomOverride",null);R(this,"viewTransitionDurationMs",0);R(this,"viewTransitionEasing",Tn);R(this,"viewAnimationState",{animation:null,frame:null});R(this,"pointCount",0);R(this,"usePointIndices",!1);R(this,"pointBuffersDirty",!0);R(this,"pointPaletteSize",1);R(this,"pointSizeStops",yn(pn));R(this,"pointStrokeScale",1);R(this,"pointInnerFillOpacity",0);R(this,"imageColorSettings",{brightness:0,contrast:0,saturation:0});R(this,"lastPointData",null);R(this,"lastPointPalette",null);R(this,"zeroFillModes",new Uint8Array(0));R(this,"cache",new Map);R(this,"zoomSnaps",[]);R(this,"zoomSnapFitAsMin",!1);R(this,"zoomSnapState",{accumulatedDelta:0,lastSnapTimeMs:0});R(this,"boundPointerDown");R(this,"boundPointerMove");R(this,"boundPointerUp");R(this,"boundWheel");R(this,"boundDoubleClick");R(this,"boundContextMenu");R(this,"boundContextLost");R(this,"boundContextRestored");this.canvas=t,this.source=n,this.onViewStateChange=r.onViewStateChange,this.onStats=r.onStats,this.onTileError=r.onTileError,this.onContextLost=r.onContextLost,this.onContextRestored=r.onContextRestored,this.authToken=r.authToken??"",this.maxCacheTiles=Math.max(32,Math.floor(r.maxCacheTiles??320)),this.ctrlDragRotate=r.ctrlDragRotate??!0,this.rotationDragSensitivityDegPerPixel=typeof r.rotationDragSensitivityDegPerPixel=="number"&&Number.isFinite(r.rotationDragSensitivityDegPerPixel)?Math.max(0,r.rotationDragSensitivityDegPerPixel):mn,this.pointSizeStops=Rr(r.pointSizeByZoom),this.pointStrokeScale=Mr(r.pointStrokeScale),this.pointInnerFillOpacity=Ar(r.pointInnerFillOpacity),this.imageColorSettings=vr(r.imageColorSettings),this.minZoomOverride=Pt(r.minZoom),this.maxZoomOverride=Pt(r.maxZoom),this.viewTransitionDurationMs=en(r.viewTransition?.duration),this.viewTransitionEasing=tn(r.viewTransition?.easing),this.zoomSnaps=_r(r.zoomSnaps,this.source.mpp),this.zoomSnapFitAsMin=!!r.zoomSnapFitAsMin;const i=t.getContext("webgl2",{alpha:!1,antialias:!1,depth:!1,stencil:!1,powerPreference:"high-performance"});if(!i)throw new Error("WebGL2 not supported");this.gl=i,this.tileProgram=Cr(this.gl),this.pointProgram=Ir(this.gl),this.tileScheduler=new fi({authToken:this.authToken,maxConcurrency:r.tileScheduler?.maxConcurrency??12,maxRetries:r.tileScheduler?.maxRetries??2,retryBaseDelayMs:r.tileScheduler?.retryBaseDelayMs??120,retryMaxDelayMs:r.tileScheduler?.retryMaxDelayMs??1200,onTileLoad:(s,a)=>Ha({gl:this.gl,cache:this.cache,tile:s,bitmap:a,frameSerial:this.frameSerial,maxCacheTiles:this.maxCacheTiles,destroyed:this.destroyed,contextLost:this.contextLost,requestRender:()=>this.requestRender()}),onTileError:(s,a,c)=>{this.onTileError?.({tile:s,error:a,attemptCount:c}),console.warn("tile load failed",s.url,a)}}),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(t);const o=Va({canvas:this.canvas,state:this.interactionState,getInteractionLocked:()=>this.interactionLocked,getCtrlDragRotate:()=>this.ctrlDragRotate,getRotationDragSensitivityDegPerPixel:()=>this.rotationDragSensitivityDegPerPixel,cancelViewAnimation:()=>this.cancelViewAnimation(),camera:this.camera,source:this.source,emitViewState:()=>this.onViewStateChange?.(this.camera.getViewState()),requestRender:()=>this.requestRender(),zoomBy:(s,a,c)=>this.zoomBy(s,a,c),getUseZoomSnaps:()=>this.zoomSnaps.length>0,onSnapZoom:(s,a,c)=>this.handleSnapZoom(s,a,c),zoomSnapState:this.zoomSnapState});this.boundPointerDown=o.pointerDown,this.boundPointerMove=o.pointerMove,this.boundPointerUp=o.pointerUp,this.boundWheel=o.wheel,this.boundDoubleClick=o.doubleClick,this.boundContextMenu=o.contextMenu,this.boundContextLost=s=>this.onWebGlContextLost(s),this.boundContextRestored=s=>this.onWebGlContextRestored(s),ma(t,this.getCanvasHandlers()),this.fitToImage({duration:0}),this.resize()}getCanvasHandlers(){return{pointerDown:this.boundPointerDown,pointerMove:this.boundPointerMove,pointerUp:this.boundPointerUp,wheel:this.boundWheel,doubleClick:this.boundDoubleClick,contextMenu:this.boundContextMenu,contextLost:this.boundContextLost,contextRestored:this.boundContextRestored}}applyZoomBounds(){const t=il(this.fitZoom,this.minZoomOverride,this.maxZoomOverride);this.minZoom=t.minZoom,this.maxZoom=t.maxZoom}resolveTargetViewState(t){return ol(this.camera,this.minZoom,this.maxZoom,t,()=>kt(this.camera,this.source))}cancelViewAnimation(){gi(this.viewAnimationState)}startViewAnimation(t,n,r){nl({state:this.viewAnimationState,camera:this.camera,target:t,durationMs:n,easing:r,onUpdate:()=>{kt(this.camera,this.source),this.onViewStateChange?.(this.camera.getViewState()),this.requestRender()}})}getPointBufferRuntime(){return{pointCount:this.pointCount,usePointIndices:this.usePointIndices,pointBuffersDirty:this.pointBuffersDirty,lastPointData:this.lastPointData,zeroFillModes:this.zeroFillModes,lastPointPalette:this.lastPointPalette,pointPaletteSize:this.pointPaletteSize}}applyPointBufferRuntime(t){this.pointCount=t.pointCount,this.usePointIndices=t.usePointIndices,this.pointBuffersDirty=t.pointBuffersDirty,this.lastPointData=t.lastPointData,this.zeroFillModes=t.zeroFillModes,this.lastPointPalette=t.lastPointPalette,this.pointPaletteSize=t.pointPaletteSize}applyViewStateAndRender(t,n=!0){n&&this.cancelViewAnimation(),this.camera.setViewState(t),this.onViewStateChange?.(this.camera.getViewState()),this.requestRender()}setAuthToken(t){this.authToken=String(t??""),this.tileScheduler.setAuthToken(this.authToken)}setZoomRange(t,n){const r=Pt(t),i=Pt(n);if(this.minZoomOverride===r&&this.maxZoomOverride===i)return;this.minZoomOverride=r,this.maxZoomOverride=i,this.applyZoomBounds();const o=this.resolveTargetViewState({}),s=this.camera.getViewState();cn(s,o)||this.applyViewStateAndRender(o)}setViewTransition(t){this.viewTransitionDurationMs=en(t?.duration),this.viewTransitionEasing=tn(t?.easing)}setViewState(t,n){const r=this.resolveTargetViewState(t),i=this.camera.getViewState();if(cn(i,r))return;const o=en(n?.duration??this.viewTransitionDurationMs),s=tn(n?.easing??this.viewTransitionEasing);if(o<=0){this.applyViewStateAndRender(r);return}this.startViewAnimation(r,o,s)}getViewState(){return this.camera.getViewState()}getZoomRange(){return{minZoom:this.minZoom,maxZoom:this.maxZoom}}isViewAnimating(){return this.viewAnimationState.animation!==null}setPointPalette(t){const n=Ja(this.getPointBufferRuntime(),this.gl,this.pointProgram,this.contextLost,t);this.applyPointBufferRuntime(n),!(!t||t.length===0)&&this.requestRender()}setPointData(t){const n=el(this.getPointBufferRuntime(),this.gl,this.pointProgram,this.contextLost,t);this.applyPointBufferRuntime(n),this.requestRender()}setInteractionLock(t){const n=!!t;this.interactionLocked!==n&&(this.interactionLocked=n,n&&this.cancelDrag())}setPointSizeByZoom(t){const n=Rr(t);Aa(this.pointSizeStops,n)||(this.pointSizeStops=n,this.requestRender())}setPointStrokeScale(t){const n=Mr(t);this.pointStrokeScale!==n&&(this.pointStrokeScale=n,this.requestRender())}setPointInnerFillOpacity(t){const n=Ar(t);this.pointInnerFillOpacity!==n&&(this.pointInnerFillOpacity=n,this.requestRender())}setImageColorSettings(t){const n=vr(t),r=this.imageColorSettings;r.brightness===n.brightness&&r.contrast===n.contrast&&r.saturation===n.saturation||(this.imageColorSettings=n,this.requestRender())}cancelDrag(){Xa(this.canvas,this.interactionState)}screenToWorld(t,n){const r=this.canvas.getBoundingClientRect(),i=t-r.left,o=n-r.top;return this.camera.screenToWorld(i,o)}worldToScreen(t,n){return this.camera.worldToScreen(t,n)}setViewCenter(t,n,r){if(!Number.isFinite(t)||!Number.isFinite(n))return;const i=this.camera.getViewState(),o=Math.max(1e-6,i.zoom),s=this.camera.getViewportSize();this.setViewState({offsetX:t-s.width/(2*o),offsetY:n-s.height/(2*o)},r)}getViewCorners(){return this.camera.getViewCorners()}getViewBounds(){return Xt(this.camera)}resetRotation(t){const n=this.camera.getViewState();Math.abs(n.rotationDeg)<1e-6||this.setViewState({rotationDeg:0},t)}getPointSizeByZoom(){const t=Math.max(1e-6,this.camera.getViewState().zoom),n=this.source.maxTierZoom+Math.log2(t),r=va(n,this.pointSizeStops);return W(r,gn,ya)}fitToImage(t){const n=this.canvas.getBoundingClientRect(),r=Math.max(1,n.width||1),i=Math.max(1,n.height||1),o=Pr(this.source,r,i,this.minZoom,this.maxZoom);this.fitZoom=o.fitZoom,this.applyZoomBounds(),this.setViewState(o.target,t)}zoomBy(t,n,r,i){const o=sl(this.camera,this.minZoom,this.maxZoom,t,n,r);o&&this.setViewState(o,i)}zoomTo(t,n,r,i){const o=al(this.camera,this.minZoom,this.maxZoom,t,n,r);o&&this.setViewState(o,i)}setZoomSnaps(t,n){this.zoomSnaps=_r(t,this.source.mpp),this.zoomSnapFitAsMin=!!n}getZoomPivotAnimationContext(){return{camera:this.camera,viewAnimationState:this.viewAnimationState,minZoom:this.minZoom,maxZoom:this.maxZoom,cancelViewAnimation:()=>this.cancelViewAnimation(),clampViewState:()=>kt(this.camera,this.source),onViewStateChange:t=>this.onViewStateChange?.(t),requestRender:()=>this.requestRender()}}handleSnapZoom(t,n,r){const i=this.viewAnimationState.animation,o=i?i.to.zoom:this.camera.getViewState().zoom,s=this.zoomSnaps.filter(u=>u>=this.minZoom&&u<=this.maxZoom),a=this.zoomStack;if(a.cnt>0&&s.length-1===a.cnt&&a.direction===t)return;a.direction!==t&&(a.cnt=0,a.direction=t),a.cnt+=1;const c=ll(s,o,t,this.zoomSnapFitAsMin);if(c){if(c.type==="fit"){const u=this.canvas.getBoundingClientRect(),h=Math.max(1,u.width||1),l=Math.max(1,u.height||1),f=Pr(this.source,h,l,this.minZoom,this.maxZoom);this.fitZoom=f.fitZoom,this.applyZoomBounds(),Fr(this.getZoomPivotAnimationContext(),f.target.zoom,n,r,Tr);return}Fr(this.getZoomPivotAnimationContext(),c.zoom,n,r,Tr)}}render(){if(this.destroyed||this.contextLost||this.gl.isContextLost())return;const t=this.onStats?be():0;this.frameSerial+=1;const n=tl({gl:this.gl,camera:this.camera,source:this.source,cache:this.cache,frameSerial:this.frameSerial,tileProgram:this.tileProgram,pointProgram:this.pointProgram,imageColorSettings:this.imageColorSettings,pointCount:this.pointCount,usePointIndices:this.usePointIndices,pointPaletteSize:this.pointPaletteSize,pointStrokeScale:this.pointStrokeScale,pointInnerFillOpacity:this.pointInnerFillOpacity,pointSizePx:this.getPointSizeByZoom()*Math.max(1,window.devicePixelRatio||1),tileScheduler:this.tileScheduler,getVisibleTiles:()=>za(this.camera,this.source),getVisibleTilesForTier:r=>mi(this.camera,this.source,r),getViewBounds:()=>Xt(this.camera),intersectsBounds:Ba});if(this.onStats){const r=this.tileScheduler.getSnapshot();this.onStats({tier:n.tier,visible:n.visible,rendered:n.rendered,points:n.points,fallback:n.fallback,cache:this.cache.size,inflight:r.inflight,queued:r.queued,retries:r.retries,failed:r.failed,aborted:r.aborted,cacheHits:n.cacheHits,cacheMisses:n.cacheMisses,drawCalls:n.drawCalls,frameMs:be()-t})}}requestRender(){this.frame!==null||this.destroyed||this.contextLost||this.gl.isContextLost()||(this.frame=requestAnimationFrame(()=>{this.frame=null,this.render()}))}resize(){pa(this.canvas,this.gl,this.camera),this.requestRender()}onWebGlContextLost(t){const n=$a({event:t,destroyed:this.destroyed,contextLost:this.contextLost,frame:this.frame,cancelViewAnimation:()=>this.cancelViewAnimation(),cancelDrag:()=>this.cancelDrag(),tileScheduler:this.tileScheduler,cache:this.cache,onContextLost:this.onContextLost});n.handled&&(this.frame=n.frame,this.contextLost=!0,this.pointBuffersDirty=!0)}onWebGlContextRestored(t){this.destroyed||(this.contextLost=!1,this.cache.clear(),this.tileProgram=Cr(this.gl),this.pointProgram=Ir(this.gl),this.pointBuffersDirty=!0,this.lastPointPalette&&this.lastPointPalette.length>0&&this.setPointPalette(this.lastPointPalette),this.lastPointData?this.setPointData(this.lastPointData):this.pointCount=0,this.resize(),this.onContextRestored?.())}destroy(){const t=Ka({destroyed:this.destroyed,frame:this.frame,cancelViewAnimation:()=>this.cancelViewAnimation(),resizeObserver:this.resizeObserver,removeCanvasEventListeners:()=>ga(this.canvas,this.getCanvasHandlers()),cancelDrag:()=>this.cancelDrag(),tileScheduler:this.tileScheduler,contextLost:this.contextLost,gl:this.gl,cache:this.cache,tileProgram:this.tileProgram,pointProgram:this.pointProgram});t.didDestroy&&(this.destroyed=!0,this.frame=t.frame)}}const cl=[];function ul({source:e,viewState:t,onViewStateChange:n,onStats:r,onTileError:i,onContextLost:o,onContextRestored:s,imageColorSettings:a=null,fitNonce:c=0,rotationResetNonce:u=0,authToken:h="",ctrlDragRotate:l=!0,minZoom:f,maxZoom:d,viewTransition:m,zoomSnaps:p,zoomSnapFitAsMin:y,onPointerWorldMove:b,debugOverlay:x=!1,debugOverlayStyle:C,className:S,style:A,children:T}){const O=g.useRef(null),z=g.useRef(null),G=g.useRef(null),D=g.useRef(null),q=g.useRef(null),re=g.useRef(null),I=g.useRef(cl),H=g.useRef(!1),N=g.useRef(new Set),k=g.useRef(n),Z=g.useRef(r),we=g.useRef(i),se=g.useRef(o),Re=g.useRef(s),[Ce,xe]=g.useState(0),[M,v]=g.useState(null),X=g.useRef(x);g.useEffect(()=>{k.current=n},[n]),g.useEffect(()=>{Z.current=r},[r]),g.useEffect(()=>{we.current=i},[i]),g.useEffect(()=>{se.current=o},[o]),g.useEffect(()=>{Re.current=s},[s]),g.useEffect(()=>{X.current=x,x||v(null)},[x]);const le=g.useMemo(()=>({position:"relative",width:"100%",height:"100%",...A}),[A]),Q=g.useMemo(()=>({position:"absolute",top:8,left:8,zIndex:7,margin:0,padding:"8px 10px",maxWidth:"min(420px, 80%)",pointerEvents:"none",whiteSpace:"pre-wrap",lineHeight:1.35,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:11,color:"#cde6ff",background:"rgba(6, 12, 20, 0.82)",border:"1px solid rgba(173, 216, 255, 0.28)",borderRadius:8,boxShadow:"0 8px 22px rgba(0,0,0,0.35)",...C}),[C]),ie=g.useCallback(_=>{Z.current?.(_),X.current&&v(_)},[]),he=g.useMemo(()=>M?[`tier ${M.tier} | frame ${M.frameMs?.toFixed(2)??"-"} ms | drawCalls ${M.drawCalls??"-"}`,`tiles visible ${M.visible} | rendered ${M.rendered} | fallback ${M.fallback}`,`cache size ${M.cache} | hit ${M.cacheHits??"-"} | miss ${M.cacheMisses??"-"}`,`queue inflight ${M.inflight} | queued ${M.queued??"-"} | retries ${M.retries??"-"} | failed ${M.failed??"-"} | aborted ${M.aborted??"-"}`,`points ${M.points}`].join(`
162
+ }`),i=_e(e,r,"uCamera"),o=_e(e,r,"uPointSize"),s=_e(e,r,"uPointStrokeScale"),a=_e(e,r,"uPointInnerFillAlpha"),c=_e(e,r,"uPalette"),u=_e(e,r,"uPaletteSize"),h=e.createVertexArray(),l=e.createBuffer(),f=e.createBuffer(),d=e.createBuffer(),m=e.createBuffer(),p=e.createTexture();if(!h||!l||!f||!d||!m||!p)throw new Error("point buffer allocation failed");e.bindVertexArray(h),e.bindBuffer(e.ARRAY_BUFFER,l),e.bufferData(e.ARRAY_BUFFER,0,e.DYNAMIC_DRAW);const y=e.getAttribLocation(r,"aPosition");if(y<0)throw new Error("point position attribute not found");e.enableVertexAttribArray(y),e.vertexAttribPointer(y,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,0,e.DYNAMIC_DRAW);const b=e.getAttribLocation(r,"aTerm");if(b<0)throw new Error("point term attribute not found");e.enableVertexAttribArray(b),e.vertexAttribIPointer(b,1,e.UNSIGNED_SHORT,0,0),e.bindBuffer(e.ARRAY_BUFFER,d),e.bufferData(e.ARRAY_BUFFER,0,e.DYNAMIC_DRAW);const x=e.getAttribLocation(r,"aFillMode");if(x<0)throw new Error("point fill mode attribute not found");return e.enableVertexAttribArray(x),e.vertexAttribIPointer(x,1,e.UNSIGNED_BYTE,0,0),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m),e.bufferData(e.ELEMENT_ARRAY_BUFFER,0,e.DYNAMIC_DRAW),e.bindVertexArray(null),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),e.bindTexture(e.TEXTURE_2D,p),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([160,160,160,255])),e.bindTexture(e.TEXTURE_2D,null),{program:r,vao:h,posBuffer:l,termBuffer:f,fillModeBuffer:d,indexBuffer:m,paletteTexture:p,uCamera:i,uPointSize:o,uPointStrokeScale:s,uPointInnerFillAlpha:a,uPalette:c,uPaletteSize:u}}function gi(e){e.animation=null,e.frame!==null&&(cancelAnimationFrame(e.frame),e.frame=null)}function nl(e){const{state:t,camera:n,target:r,durationMs:i,easing:o,onUpdate:s}=e,a=n.getViewState();gi(t),t.animation={startMs:be(),durationMs:Math.max(0,i),from:a,to:r,easing:o};const c=()=>{const u=t.animation;if(!u)return;const h=Math.max(0,be()-u.startMs),l=u.durationMs<=0?1:W(h/u.durationMs,0,1);let f=l;try{f=u.easing(l)}catch{f=l}if(Number.isFinite(f)||(f=l),f=W(f,0,1),n.setViewState({zoom:u.from.zoom+(u.to.zoom-u.from.zoom)*f,offsetX:u.from.offsetX+(u.to.offsetX-u.from.offsetX)*f,offsetY:u.from.offsetY+(u.to.offsetY-u.from.offsetY)*f,rotationDeg:u.from.rotationDeg+(u.to.rotationDeg-u.from.rotationDeg)*f}),s(),l>=1){t.animation=null,t.frame=null;return}t.frame=requestAnimationFrame(c)};t.frame=requestAnimationFrame(c)}function rl(e){const t=Math.max(e*.5,1e-6),n=Math.max(1,e*8);return{minZoom:t,maxZoom:Math.max(t,n)}}function il(e,t,n){const r=rl(e);let i=t??r.minZoom,o=n??r.maxZoom;return i=Math.max(1e-6,i),o=Math.max(1e-6,o),i>o&&(i=o),{minZoom:i,maxZoom:o}}function ol(e,t,n,r,i){const o=e.getViewState(),s={zoom:typeof r.zoom=="number"&&Number.isFinite(r.zoom)?W(r.zoom,t,n):o.zoom,offsetX:typeof r.offsetX=="number"&&Number.isFinite(r.offsetX)?r.offsetX:o.offsetX,offsetY:typeof r.offsetY=="number"&&Number.isFinite(r.offsetY)?r.offsetY:o.offsetY,rotationDeg:typeof r.rotationDeg=="number"&&Number.isFinite(r.rotationDeg)?r.rotationDeg:o.rotationDeg};e.setViewState(s),i();const a=e.getViewState();return e.setViewState(o),a}function Pr(e,t,n,r,i){const o=Math.min(t/e.width,n/e.height),s=Number.isFinite(o)&&o>0?o:1,a=W(s,r,i),c=t/a,u=n/a;return{fitZoom:s,target:{zoom:a,offsetX:(e.width-c)*.5,offsetY:(e.height-u)*.5,rotationDeg:0}}}function sl(e,t,n,r,i,o){const s=e.getViewState(),a=W(s.zoom*r,t,n);if(a===s.zoom)return null;const[c,u]=e.screenToWorld(i,o),h=e.getViewportSize(),l=i-h.width*.5,f=o-h.height*.5,d=Vt(s.rotationDeg),m=Math.cos(d),p=Math.sin(d),y=l/a*m-f/a*p,b=l/a*p+f/a*m,x=c-y,C=u-b;return{zoom:a,offsetX:x-h.width/(2*a),offsetY:C-h.height/(2*a)}}function al(e,t,n,r,i,o){const s=e.getViewState(),a=W(r,t,n);if(a===s.zoom)return null;const[c,u]=e.screenToWorld(i,o),h=e.getViewportSize(),l=i-h.width*.5,f=o-h.height*.5,d=Vt(s.rotationDeg),m=Math.cos(d),p=Math.sin(d),y=l/a*m-f/a*p,b=l/a*p+f/a*m,x=c-y,C=u-b;return{zoom:a,offsetX:x-h.width/(2*a),offsetY:C-h.height/(2*a)}}const Tr=250;function _r(e,t){if(!e||e.length===0)return[];if(!t||t<=0)return[];const n=10/t;return e.map(r=>r/n).filter(r=>Number.isFinite(r)&&r>0).sort((r,i)=>r-i)}function ll(e,t,n,r){if(e.length===0)return null;const i=Math.max(t*.005,1e-8);if(n==="in"){for(const o of e)if(o>t+i)return{type:"snap",zoom:o};return null}for(let o=e.length-1;o>=0;o--)if(e[o]<t-i)return{type:"snap",zoom:e[o]};return r&&t<=e[0]+i?{type:"fit"}:null}function Fr(e,t,n,r,i){const o=e.camera.getViewState(),[s,a]=e.camera.screenToWorld(n,r),c=e.camera.getViewportSize(),u=W(t,e.minZoom,e.maxZoom);if(u===o.zoom)return;const h=Vt(o.rotationDeg),l=Math.cos(h),f=Math.sin(h),d=n-c.width*.5,m=r-c.height*.5;e.cancelViewAnimation();const p=x=>{const C=d/x*l-m/x*f,S=d/x*f+m/x*l;return{offsetX:s-C-c.width/(2*x),offsetY:a-S-c.height/(2*x)}},y=p(u);e.viewAnimationState.animation={startMs:be(),durationMs:Math.max(0,i),from:o,to:{zoom:u,offsetX:y.offsetX,offsetY:y.offsetY,rotationDeg:o.rotationDeg},easing:Tn};const b=()=>{const x=e.viewAnimationState.animation;if(!x)return;const C=Math.max(0,be()-x.startMs),S=W(C/i,0,1),A=W(S*S*(3-2*S),0,1),T=o.zoom+(u-o.zoom)*A,{offsetX:O,offsetY:z}=p(T);e.camera.setViewState({zoom:T,offsetX:O,offsetY:z,rotationDeg:o.rotationDeg});const G=S>=1;G&&(e.clampViewState(),e.viewAnimationState.animation=null,e.viewAnimationState.frame=null),e.onViewStateChange(e.camera.getViewState()),e.requestRender(),G||(e.viewAnimationState.frame=requestAnimationFrame(b))};e.viewAnimationState.frame=requestAnimationFrame(b)}class pi{constructor(t,n,r={}){R(this,"canvas");R(this,"source");R(this,"gl");R(this,"camera",new Br);R(this,"onViewStateChange");R(this,"onStats");R(this,"onTileError");R(this,"onContextLost");R(this,"onContextRestored");R(this,"resizeObserver");R(this,"tileProgram");R(this,"pointProgram");R(this,"tileScheduler");R(this,"zoomStack",{cnt:0,direction:null});R(this,"authToken");R(this,"destroyed",!1);R(this,"contextLost",!1);R(this,"frame",null);R(this,"frameSerial",0);R(this,"interactionState",{dragging:!1,mode:"none",rotateLastAngleRad:null,pointerId:null,lastPointerX:0,lastPointerY:0});R(this,"interactionLocked",!1);R(this,"ctrlDragRotate",!0);R(this,"rotationDragSensitivityDegPerPixel",mn);R(this,"maxCacheTiles");R(this,"fitZoom",1);R(this,"minZoom",1e-6);R(this,"maxZoom",1);R(this,"minZoomOverride",null);R(this,"maxZoomOverride",null);R(this,"viewTransitionDurationMs",0);R(this,"viewTransitionEasing",Tn);R(this,"viewAnimationState",{animation:null,frame:null});R(this,"pointCount",0);R(this,"usePointIndices",!1);R(this,"pointBuffersDirty",!0);R(this,"pointPaletteSize",1);R(this,"pointSizeStops",yn(pn));R(this,"pointStrokeScale",1);R(this,"pointInnerFillOpacity",0);R(this,"imageColorSettings",{brightness:0,contrast:0,saturation:0});R(this,"lastPointData",null);R(this,"lastPointPalette",null);R(this,"zeroFillModes",new Uint8Array(0));R(this,"cache",new Map);R(this,"zoomSnaps",[]);R(this,"zoomSnapFitAsMin",!1);R(this,"zoomSnapState",{accumulatedDelta:0,lastSnapTimeMs:0});R(this,"boundPointerDown");R(this,"boundPointerMove");R(this,"boundPointerUp");R(this,"boundWheel");R(this,"boundDoubleClick");R(this,"boundContextMenu");R(this,"boundContextLost");R(this,"boundContextRestored");this.canvas=t,this.source=n,this.onViewStateChange=r.onViewStateChange,this.onStats=r.onStats,this.onTileError=r.onTileError,this.onContextLost=r.onContextLost,this.onContextRestored=r.onContextRestored,this.authToken=r.authToken??"",this.maxCacheTiles=Math.max(32,Math.floor(r.maxCacheTiles??320)),this.ctrlDragRotate=r.ctrlDragRotate??!0,this.rotationDragSensitivityDegPerPixel=typeof r.rotationDragSensitivityDegPerPixel=="number"&&Number.isFinite(r.rotationDragSensitivityDegPerPixel)?Math.max(0,r.rotationDragSensitivityDegPerPixel):mn,this.pointSizeStops=Rr(r.pointSizeByZoom),this.pointStrokeScale=Mr(r.pointStrokeScale),this.pointInnerFillOpacity=Ar(r.pointInnerFillOpacity),this.imageColorSettings=vr(r.imageColorSettings),this.minZoomOverride=Pt(r.minZoom),this.maxZoomOverride=Pt(r.maxZoom),this.viewTransitionDurationMs=en(r.viewTransition?.duration),this.viewTransitionEasing=tn(r.viewTransition?.easing),this.zoomSnaps=_r(r.zoomSnaps,this.source.mpp),this.zoomSnapFitAsMin=!!r.zoomSnapFitAsMin;const i=t.getContext("webgl2",{alpha:!1,antialias:!1,depth:!1,stencil:!1,powerPreference:"high-performance"});if(!i)throw new Error("WebGL2 not supported");this.gl=i,this.tileProgram=Cr(this.gl),this.pointProgram=Ir(this.gl),this.tileScheduler=new fi({authToken:this.authToken,maxConcurrency:r.tileScheduler?.maxConcurrency??12,maxRetries:r.tileScheduler?.maxRetries??2,retryBaseDelayMs:r.tileScheduler?.retryBaseDelayMs??120,retryMaxDelayMs:r.tileScheduler?.retryMaxDelayMs??1200,onTileLoad:(s,a)=>Ha({gl:this.gl,cache:this.cache,tile:s,bitmap:a,frameSerial:this.frameSerial,maxCacheTiles:this.maxCacheTiles,destroyed:this.destroyed,contextLost:this.contextLost,requestRender:()=>this.requestRender()}),onTileError:(s,a,c)=>{this.onTileError?.({tile:s,error:a,attemptCount:c}),console.warn("tile load failed",s.url,a)}}),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(t);const o=Va({canvas:this.canvas,state:this.interactionState,getInteractionLocked:()=>this.interactionLocked,getCtrlDragRotate:()=>this.ctrlDragRotate,getRotationDragSensitivityDegPerPixel:()=>this.rotationDragSensitivityDegPerPixel,cancelViewAnimation:()=>this.cancelViewAnimation(),camera:this.camera,source:this.source,emitViewState:()=>this.onViewStateChange?.(this.camera.getViewState()),requestRender:()=>this.requestRender(),zoomBy:(s,a,c)=>this.zoomBy(s,a,c),getUseZoomSnaps:()=>this.zoomSnaps.length>0,onSnapZoom:(s,a,c)=>this.handleSnapZoom(s,a,c),zoomSnapState:this.zoomSnapState});this.boundPointerDown=o.pointerDown,this.boundPointerMove=o.pointerMove,this.boundPointerUp=o.pointerUp,this.boundWheel=o.wheel,this.boundDoubleClick=o.doubleClick,this.boundContextMenu=o.contextMenu,this.boundContextLost=s=>this.onWebGlContextLost(s),this.boundContextRestored=s=>this.onWebGlContextRestored(s),ma(t,this.getCanvasHandlers()),this.fitToImage({duration:0}),this.resize()}getCanvasHandlers(){return{pointerDown:this.boundPointerDown,pointerMove:this.boundPointerMove,pointerUp:this.boundPointerUp,wheel:this.boundWheel,doubleClick:this.boundDoubleClick,contextMenu:this.boundContextMenu,contextLost:this.boundContextLost,contextRestored:this.boundContextRestored}}applyZoomBounds(){const t=il(this.fitZoom,this.minZoomOverride,this.maxZoomOverride);this.minZoom=t.minZoom,this.maxZoom=t.maxZoom}resolveTargetViewState(t){return ol(this.camera,this.minZoom,this.maxZoom,t,()=>kt(this.camera,this.source))}cancelViewAnimation(){gi(this.viewAnimationState)}startViewAnimation(t,n,r){nl({state:this.viewAnimationState,camera:this.camera,target:t,durationMs:n,easing:r,onUpdate:()=>{kt(this.camera,this.source),this.onViewStateChange?.(this.camera.getViewState()),this.requestRender()}})}getPointBufferRuntime(){return{pointCount:this.pointCount,usePointIndices:this.usePointIndices,pointBuffersDirty:this.pointBuffersDirty,lastPointData:this.lastPointData,zeroFillModes:this.zeroFillModes,lastPointPalette:this.lastPointPalette,pointPaletteSize:this.pointPaletteSize}}applyPointBufferRuntime(t){this.pointCount=t.pointCount,this.usePointIndices=t.usePointIndices,this.pointBuffersDirty=t.pointBuffersDirty,this.lastPointData=t.lastPointData,this.zeroFillModes=t.zeroFillModes,this.lastPointPalette=t.lastPointPalette,this.pointPaletteSize=t.pointPaletteSize}applyViewStateAndRender(t,n=!0){n&&this.cancelViewAnimation(),this.camera.setViewState(t),this.onViewStateChange?.(this.camera.getViewState()),this.requestRender()}setAuthToken(t){this.authToken=String(t??""),this.tileScheduler.setAuthToken(this.authToken)}setZoomRange(t,n){const r=Pt(t),i=Pt(n);if(this.minZoomOverride===r&&this.maxZoomOverride===i)return;this.minZoomOverride=r,this.maxZoomOverride=i,this.applyZoomBounds();const o=this.resolveTargetViewState({}),s=this.camera.getViewState();cn(s,o)||this.applyViewStateAndRender(o)}setViewTransition(t){this.viewTransitionDurationMs=en(t?.duration),this.viewTransitionEasing=tn(t?.easing)}setViewState(t,n){const r=this.resolveTargetViewState(t),i=this.camera.getViewState();if(cn(i,r))return;const o=en(n?.duration??this.viewTransitionDurationMs),s=tn(n?.easing??this.viewTransitionEasing);if(o<=0){this.applyViewStateAndRender(r);return}this.startViewAnimation(r,o,s)}getViewState(){return this.camera.getViewState()}getZoomRange(){return{minZoom:this.minZoom,maxZoom:this.maxZoom}}isViewAnimating(){return this.viewAnimationState.animation!==null}setPointPalette(t){const n=Ja(this.getPointBufferRuntime(),this.gl,this.pointProgram,this.contextLost,t);this.applyPointBufferRuntime(n),!(!t||t.length===0)&&this.requestRender()}setPointData(t){const n=el(this.getPointBufferRuntime(),this.gl,this.pointProgram,this.contextLost,t);this.applyPointBufferRuntime(n),this.requestRender()}setInteractionLock(t){const n=!!t;this.interactionLocked!==n&&(this.interactionLocked=n,n&&this.cancelDrag())}setPointSizeByZoom(t){const n=Rr(t);Aa(this.pointSizeStops,n)||(this.pointSizeStops=n,this.requestRender())}setPointStrokeScale(t){const n=Mr(t);this.pointStrokeScale!==n&&(this.pointStrokeScale=n,this.requestRender())}setPointInnerFillOpacity(t){const n=Ar(t);this.pointInnerFillOpacity!==n&&(this.pointInnerFillOpacity=n,this.requestRender())}setImageColorSettings(t){const n=vr(t),r=this.imageColorSettings;r.brightness===n.brightness&&r.contrast===n.contrast&&r.saturation===n.saturation||(this.imageColorSettings=n,this.requestRender())}cancelDrag(){Xa(this.canvas,this.interactionState)}screenToWorld(t,n){const r=this.canvas.getBoundingClientRect(),i=t-r.left,o=n-r.top;return this.camera.screenToWorld(i,o)}worldToScreen(t,n){return this.camera.worldToScreen(t,n)}setViewCenter(t,n,r){if(!Number.isFinite(t)||!Number.isFinite(n))return;const i=this.camera.getViewState(),o=Math.max(1e-6,i.zoom),s=this.camera.getViewportSize();this.setViewState({offsetX:t-s.width/(2*o),offsetY:n-s.height/(2*o)},r)}getViewCorners(){return this.camera.getViewCorners()}getViewBounds(){return Xt(this.camera)}resetRotation(t){const n=this.camera.getViewState();Math.abs(n.rotationDeg)<1e-6||this.setViewState({rotationDeg:0},t)}getPointSizeByZoom(){const t=Math.max(1e-6,this.camera.getViewState().zoom),n=this.source.maxTierZoom+Math.log2(t),r=va(n,this.pointSizeStops);return W(r,gn,ya)}fitToImage(t){const n=this.canvas.getBoundingClientRect(),r=Math.max(1,n.width||1),i=Math.max(1,n.height||1),o=Pr(this.source,r,i,this.minZoom,this.maxZoom);this.fitZoom=o.fitZoom,this.applyZoomBounds(),this.setViewState(o.target,t)}zoomBy(t,n,r,i){const o=sl(this.camera,this.minZoom,this.maxZoom,t,n,r);o&&this.setViewState(o,i)}zoomTo(t,n,r,i){const o=al(this.camera,this.minZoom,this.maxZoom,t,n,r);o&&this.setViewState(o,i)}setZoomSnaps(t,n){this.zoomSnaps=_r(t,this.source.mpp),this.zoomSnapFitAsMin=!!n}getZoomPivotAnimationContext(){return{camera:this.camera,viewAnimationState:this.viewAnimationState,minZoom:this.minZoom,maxZoom:this.maxZoom,cancelViewAnimation:()=>this.cancelViewAnimation(),clampViewState:()=>kt(this.camera,this.source),onViewStateChange:t=>this.onViewStateChange?.(t),requestRender:()=>this.requestRender()}}handleSnapZoom(t,n,r){const i=this.viewAnimationState.animation,o=i?i.to.zoom:this.camera.getViewState().zoom,s=this.zoomSnaps.filter(u=>u>=this.minZoom&&u<=this.maxZoom),a=this.zoomStack;if(a.cnt>0&&s.length-1===a.cnt&&a.direction===t)return;a.direction!==t&&(a.cnt=0,a.direction=null),i||(a.cnt=0),a.cnt+=1;const c=ll(s,o,t,this.zoomSnapFitAsMin);if(c){if(c.type==="fit"){const u=this.canvas.getBoundingClientRect(),h=Math.max(1,u.width||1),l=Math.max(1,u.height||1),f=Pr(this.source,h,l,this.minZoom,this.maxZoom);this.fitZoom=f.fitZoom,this.applyZoomBounds(),Fr(this.getZoomPivotAnimationContext(),f.target.zoom,n,r,Tr);return}Fr(this.getZoomPivotAnimationContext(),c.zoom,n,r,Tr)}}render(){if(this.destroyed||this.contextLost||this.gl.isContextLost())return;const t=this.onStats?be():0;this.frameSerial+=1;const n=tl({gl:this.gl,camera:this.camera,source:this.source,cache:this.cache,frameSerial:this.frameSerial,tileProgram:this.tileProgram,pointProgram:this.pointProgram,imageColorSettings:this.imageColorSettings,pointCount:this.pointCount,usePointIndices:this.usePointIndices,pointPaletteSize:this.pointPaletteSize,pointStrokeScale:this.pointStrokeScale,pointInnerFillOpacity:this.pointInnerFillOpacity,pointSizePx:this.getPointSizeByZoom()*Math.max(1,window.devicePixelRatio||1),tileScheduler:this.tileScheduler,getVisibleTiles:()=>za(this.camera,this.source),getVisibleTilesForTier:r=>mi(this.camera,this.source,r),getViewBounds:()=>Xt(this.camera),intersectsBounds:Ba});if(this.onStats){const r=this.tileScheduler.getSnapshot();this.onStats({tier:n.tier,visible:n.visible,rendered:n.rendered,points:n.points,fallback:n.fallback,cache:this.cache.size,inflight:r.inflight,queued:r.queued,retries:r.retries,failed:r.failed,aborted:r.aborted,cacheHits:n.cacheHits,cacheMisses:n.cacheMisses,drawCalls:n.drawCalls,frameMs:be()-t})}}requestRender(){this.frame!==null||this.destroyed||this.contextLost||this.gl.isContextLost()||(this.frame=requestAnimationFrame(()=>{this.frame=null,this.render()}))}resize(){pa(this.canvas,this.gl,this.camera),this.requestRender()}onWebGlContextLost(t){const n=$a({event:t,destroyed:this.destroyed,contextLost:this.contextLost,frame:this.frame,cancelViewAnimation:()=>this.cancelViewAnimation(),cancelDrag:()=>this.cancelDrag(),tileScheduler:this.tileScheduler,cache:this.cache,onContextLost:this.onContextLost});n.handled&&(this.frame=n.frame,this.contextLost=!0,this.pointBuffersDirty=!0)}onWebGlContextRestored(t){this.destroyed||(this.contextLost=!1,this.cache.clear(),this.tileProgram=Cr(this.gl),this.pointProgram=Ir(this.gl),this.pointBuffersDirty=!0,this.lastPointPalette&&this.lastPointPalette.length>0&&this.setPointPalette(this.lastPointPalette),this.lastPointData?this.setPointData(this.lastPointData):this.pointCount=0,this.resize(),this.onContextRestored?.())}destroy(){const t=Ka({destroyed:this.destroyed,frame:this.frame,cancelViewAnimation:()=>this.cancelViewAnimation(),resizeObserver:this.resizeObserver,removeCanvasEventListeners:()=>ga(this.canvas,this.getCanvasHandlers()),cancelDrag:()=>this.cancelDrag(),tileScheduler:this.tileScheduler,contextLost:this.contextLost,gl:this.gl,cache:this.cache,tileProgram:this.tileProgram,pointProgram:this.pointProgram});t.didDestroy&&(this.destroyed=!0,this.frame=t.frame)}}const cl=[];function ul({source:e,viewState:t,onViewStateChange:n,onStats:r,onTileError:i,onContextLost:o,onContextRestored:s,imageColorSettings:a=null,fitNonce:c=0,rotationResetNonce:u=0,authToken:h="",ctrlDragRotate:l=!0,minZoom:f,maxZoom:d,viewTransition:m,zoomSnaps:p,zoomSnapFitAsMin:y,onPointerWorldMove:b,debugOverlay:x=!1,debugOverlayStyle:C,className:S,style:A,children:T}){const O=g.useRef(null),z=g.useRef(null),G=g.useRef(null),D=g.useRef(null),q=g.useRef(null),re=g.useRef(null),I=g.useRef(cl),H=g.useRef(!1),N=g.useRef(new Set),k=g.useRef(n),Z=g.useRef(r),we=g.useRef(i),se=g.useRef(o),Re=g.useRef(s),[Ce,xe]=g.useState(0),[M,v]=g.useState(null),X=g.useRef(x);g.useEffect(()=>{k.current=n},[n]),g.useEffect(()=>{Z.current=r},[r]),g.useEffect(()=>{we.current=i},[i]),g.useEffect(()=>{se.current=o},[o]),g.useEffect(()=>{Re.current=s},[s]),g.useEffect(()=>{X.current=x,x||v(null)},[x]);const le=g.useMemo(()=>({position:"relative",width:"100%",height:"100%",...A}),[A]),Q=g.useMemo(()=>({position:"absolute",top:8,left:8,zIndex:7,margin:0,padding:"8px 10px",maxWidth:"min(420px, 80%)",pointerEvents:"none",whiteSpace:"pre-wrap",lineHeight:1.35,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:11,color:"#cde6ff",background:"rgba(6, 12, 20, 0.82)",border:"1px solid rgba(173, 216, 255, 0.28)",borderRadius:8,boxShadow:"0 8px 22px rgba(0,0,0,0.35)",...C}),[C]),ie=g.useCallback(_=>{Z.current?.(_),X.current&&v(_)},[]),he=g.useMemo(()=>M?[`tier ${M.tier} | frame ${M.frameMs?.toFixed(2)??"-"} ms | drawCalls ${M.drawCalls??"-"}`,`tiles visible ${M.visible} | rendered ${M.rendered} | fallback ${M.fallback}`,`cache size ${M.cache} | hit ${M.cacheHits??"-"} | miss ${M.cacheMisses??"-"}`,`queue inflight ${M.inflight} | queued ${M.queued??"-"} | retries ${M.retries??"-"} | failed ${M.failed??"-"} | aborted ${M.aborted??"-"}`,`points ${M.points}`].join(`
163
163
  `):"stats: waiting for first frame...",[M]),me=g.useCallback(()=>{const _=G.current;if(!_)return;const Y=_.getContext("2d");if(!Y)return;const J=Math.max(1,window.devicePixelRatio||1),oe=_.getBoundingClientRect(),L=Math.max(1,Math.round(oe.width*J)),K=Math.max(1,Math.round(oe.height*J));(_.width!==L||_.height!==K)&&(_.width=L,_.height=K);const ce=oe.width,ne=oe.height;Y.setTransform(1,0,0,1,0,0),Y.clearRect(0,0,_.width,_.height),Y.setTransform(J,0,0,J,0,0);const ue=I.current;for(let ze=0;ze<ue.length;ze+=1)Y.save(),ue[ze].draw(Y,ce,ne),Y.restore()},[]),$=g.useCallback(()=>{H.current||(H.current=!0,requestAnimationFrame(()=>{H.current=!1,me()}))},[me]),pe=g.useCallback((_,Y,J)=>{const oe=I.current.filter(L=>L.id!==_);oe.push({id:_,priority:Y,draw:J}),oe.sort((L,K)=>L.priority-K.priority),I.current=oe,$()},[$]),ye=g.useCallback(_=>{I.current=I.current.filter(Y=>Y.id!==_),$()},[$]),U=g.useCallback((_,Y)=>{Y?N.current.add(_):N.current.delete(_),D.current?.setInteractionLock(N.current.size>0)},[]),V=g.useCallback(()=>N.current.size>0,[]),ee=g.useCallback((_,Y)=>{const J=D.current;return J?En(J.worldToScreen(_,Y)):null},[]),B=g.useCallback((_,Y)=>{const J=D.current;if(!J)return null;const oe=J.screenToWorld(_,Y);if(!Array.isArray(oe)||oe.length<2)return null;const L=Number(oe[0]),K=Number(oe[1]);return!Number.isFinite(L)||!Number.isFinite(K)?null:[L,K]},[]),te=g.useCallback(_=>{k.current?.(_),q.current?.(),re.current?.(),$()},[$]);g.useEffect(()=>{const _=z.current;if(!_||!e)return;const Y=new pi(_,e,{onViewStateChange:te,onStats:ie,onTileError:J=>{we.current?.(J)},onContextLost:()=>{se.current?.()},onContextRestored:()=>{Re.current?.()},authToken:h,imageColorSettings:a,ctrlDragRotate:l,minZoom:f,maxZoom:d,viewTransition:m,zoomSnaps:p,zoomSnapFitAsMin:y});return D.current=Y,xe(J=>J+1),t&&Y.setViewState(t),Y.setInteractionLock(N.current.size>0),()=>{Y.destroy(),D.current=null}},[e,ie,l,te]),g.useEffect(()=>{D.current?.setAuthToken(h)},[h]),g.useEffect(()=>{const _=D.current;!_||!t||_.isViewAnimating()||_.setViewState(t)},[t]),g.useEffect(()=>{D.current?.fitToImage()},[c]),g.useEffect(()=>{D.current?.resetRotation()},[u]),g.useEffect(()=>{D.current?.setZoomRange(f,d)},[f,d]),g.useEffect(()=>{D.current?.setViewTransition(m)},[m]),g.useEffect(()=>{D.current?.setZoomSnaps(p,y)},[p,y]),g.useEffect(()=>{D.current?.setImageColorSettings(a)},[a]),g.useEffect(()=>{const _=G.current;if(!_)return;q.current=$,$();const Y=new ResizeObserver(()=>$());return Y.observe(_),()=>{Y.disconnect(),q.current===$&&(q.current=null)}},[$]);const de=g.useMemo(()=>({source:e,rendererRef:D,rendererSerial:Ce,canvasRef:z,containerRef:O,drawInvalidateRef:q,overviewInvalidateRef:re,worldToScreen:ee,screenToWorld:B,registerDrawCallback:pe,unregisterDrawCallback:ye,requestOverlayRedraw:$,setInteractionLock:U,isInteractionLocked:V}),[e,Ce,ee,B,pe,ye,$,U,V]),ae=g.useRef(b);g.useEffect(()=>{ae.current=b},[b]);const Me=g.useCallback(_=>{const Y=ae.current;if(!Y)return;const J=B(_.clientX,_.clientY),oe=!!J&&J[0]>=0&&J[1]>=0&&!!e&&J[0]<=e.width&&J[1]<=e.height;Y({coordinate:J,clientX:_.clientX,clientY:_.clientY,insideImage:oe})},[B,e]),Se=g.useCallback(()=>{ae.current?.({coordinate:null,clientX:-1,clientY:-1,insideImage:!1})},[]);return Ye.jsx(bs,{value:de,children:Ye.jsxs("div",{ref:O,className:S,style:le,onPointerMove:b?Me:void 0,onPointerLeave:b?Se:void 0,children:[Ye.jsx("canvas",{ref:z,className:"wsi-render-canvas",style:{position:"absolute",inset:0,zIndex:1,width:"100%",height:"100%",display:"block",touchAction:"none"}}),Ye.jsx("canvas",{ref:G,className:"wsi-overlay-canvas",style:{position:"absolute",inset:0,zIndex:2,width:"100%",height:"100%",display:"block",pointerEvents:"none",touchAction:"none"}}),T,x&&Ye.jsx("pre",{"data-open-plant-debug-overlay":!0,style:Q,children:he})]})})}function fl(e){const t=[];for(let n=0;n<e.length;n+=1){const r=e[n],i=yt([pt(r?.coordinates)]);if(i.length===0)continue;let o=0,s=1/0,a=1/0,c=-1/0,u=-1/0;for(const h of i)o+=h.area,h.minX<s&&(s=h.minX),h.minY<a&&(a=h.minY),h.maxX>c&&(c=h.maxX),h.maxY>u&&(u=h.maxY);!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(c)||!Number.isFinite(u)||t.push({regionId:r.id??n,regionIndex:n,polygons:i,area:Math.max(1e-6,o),minX:s,minY:a,maxX:c,maxY:u})}return t}const hl=128,nn=[];function rt(e,t,n,r,i){if(i<=1||n<=t)return 0;const o=(e-t)/r;return!Number.isFinite(o)||o<=0?0:o>=i-1?i-1:Math.floor(o)}function dl(e){if(e.length===0)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const h of e)h.minX<t&&(t=h.minX),h.minY<n&&(n=h.minY),h.maxX>r&&(r=h.maxX),h.maxY>i&&(i=h.maxY);if(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i))return null;const o=Math.ceil(Math.sqrt(e.length*2)),s=Math.max(1,Math.min(hl,o)),a=r>t?(r-t)/s:1,c=i>n?(i-n)/s:1,u=Array.from({length:s*s},()=>[]);for(let h=0;h<e.length;h+=1){const l=e[h],f=rt(l.minX,t,r,a,s),d=rt(l.maxX,t,r,a,s),m=rt(l.minY,n,i,c,s),p=rt(l.maxY,n,i,c,s);for(let y=m;y<=p;y+=1)for(let b=f;b<=d;b+=1)u[y*s+b].push(h)}return{minX:t,minY:n,maxX:r,maxY:i,gridSize:s,cellWidth:a,cellHeight:c,buckets:u}}function ml(e,t,n){if(!e||t<e.minX||t>e.maxX||n<e.minY||n>e.maxY)return nn;const r=rt(t,e.minX,e.maxX,e.cellWidth,e.gridSize),i=rt(n,e.minY,e.maxY,e.cellHeight,e.gridSize);return e.buckets[i*e.gridSize+r]??nn}function gl(e,t){if(Array.isArray(t)){const n=t[e];if(typeof n=="string"&&n.length>0)return n}if(t instanceof Map){const n=t.get(e);if(typeof n=="string"&&n.length>0)return n}return String(e)}function pl(e,t,n={}){const r=Math.max(0,Math.min(Math.floor(e?.count??0),Math.floor((e?.positions?.length??0)/2),e?.paletteIndices?.length??0,e?.fillModes instanceof Uint8Array?e.fillModes.length:Number.MAX_SAFE_INTEGER));let i=null;if(e?.drawIndices instanceof Uint32Array){const d=e.drawIndices;let m=d.length;for(let p=0;p<d.length;p+=1)d[p]<r||(m-=1);if(m===d.length)i=d;else if(m>0){const p=new Uint32Array(m);let y=0;for(let b=0;b<d.length;b+=1){const x=d[b];x>=r||(p[y]=x,y+=1)}i=p}else i=new Uint32Array(0)}const o=i?i.length:r,s=fl(t??[]);if(!e||o===0||s.length===0)return{groups:[],inputPointCount:o,pointsInsideAnyRegion:0,unmatchedPointCount:o};const a=new Map,c=new Map,u=dl(s);let h=0;for(let d=0;d<o;d+=1){const m=i?i[d]:d,p=e.positions[m*2],y=e.positions[m*2+1];if(!Number.isFinite(p)||!Number.isFinite(y))continue;let b=null;const x=ml(u,p,y);if(x.length===0)continue;for(const A of x){const T=s[A];let O=!1;for(const z of T.polygons)if(Wr(p,y,z)){O=!0;break}O&&(!b||T.area<b.area)&&(b=T)}if(!b)continue;h+=1;const C=e.paletteIndices[m]??0,S=a.get(b.regionIndex)??new Map;S.set(C,(S.get(C)??0)+1),a.set(b.regionIndex,S),c.set(b.regionIndex,(c.get(b.regionIndex)??0)+1)}const l=n.includeEmptyRegions??!1,f=[];for(const d of s){const m=c.get(d.regionIndex)??0;if(!l&&m<=0)continue;const p=a.get(d.regionIndex)??new Map,y=Array.from(p.entries()).map(([b,x])=>({termId:gl(b,n.paletteIndexToTermId),paletteIndex:b,count:x})).sort((b,x)=>x.count-b.count||b.paletteIndex-x.paletteIndex);f.push({regionId:d.regionId,regionIndex:d.regionIndex,totalCount:m,termCounts:y})}return{groups:f,inputPointCount:o,pointsInsideAnyRegion:h,unmatchedPointCount:Math.max(0,o-h)}}function Lr(e,t,n,r){return[Math.min(e,n),Math.min(t,r),Math.max(e,n),Math.max(t,r)]}function kr(e,t){return!(e[2]<t[0]||e[0]>t[2]||e[3]<t[1]||e[1]>t[3])}class yl{constructor(t=16){R(this,"targetNodeSize");R(this,"items",[]);R(this,"globalBounds",[0,0,0,0]);R(this,"gridSize",1);R(this,"cellWidth",1);R(this,"cellHeight",1);R(this,"buckets",[]);R(this,"visited",new Uint32Array(0));R(this,"querySerial",1);const n=Number.isFinite(t)?Math.floor(t):16;this.targetNodeSize=Math.max(1,n)}load(t){if(!Array.isArray(t)||t.length===0){this.items=[],this.globalBounds=[0,0,0,0],this.gridSize=1,this.cellWidth=1,this.cellHeight=1,this.buckets=[],this.visited=new Uint32Array(0),this.querySerial=1;return}const n=[];let r=1/0,i=1/0,o=-1/0,s=-1/0;for(const h of t){if(!h||!Number.isFinite(h.minX)||!Number.isFinite(h.minY)||!Number.isFinite(h.maxX)||!Number.isFinite(h.maxY))continue;const l=Lr(h.minX,h.minY,h.maxX,h.maxY);r=Math.min(r,l[0]),i=Math.min(i,l[1]),o=Math.max(o,l[2]),s=Math.max(s,l[3]),n.push({minX:l[0],minY:l[1],maxX:l[2],maxY:l[3],value:h.value})}if(this.items=n,this.visited=new Uint32Array(n.length),this.querySerial=1,n.length===0||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(o)||!Number.isFinite(s)){this.globalBounds=[0,0,0,0],this.gridSize=1,this.cellWidth=1,this.cellHeight=1,this.buckets=[];return}this.globalBounds=[r,i,o,s],this.gridSize=Math.max(1,Math.ceil(Math.sqrt(n.length/this.targetNodeSize)));const a=Math.max(0,o-r),c=Math.max(0,s-i);this.cellWidth=a>0?a/this.gridSize:1,this.cellHeight=c>0?c/this.gridSize:1;const u=this.gridSize*this.gridSize;this.buckets=Array.from({length:u},()=>[]);for(let h=0;h<n.length;h+=1){const l=n[h],f=this.toCellX(l.minX),d=this.toCellX(l.maxX),m=this.toCellY(l.minY),p=this.toCellY(l.maxY);for(let y=m;y<=p;y+=1)for(let b=f;b<=d;b+=1)this.buckets[y*this.gridSize+b].push(h)}}search(t){if(this.items.length===0)return[];if(!Array.isArray(t)||t.length<4)return[];const n=Lr(t[0],t[1],t[2],t[3]);if(!kr(n,this.globalBounds))return[];const r=this.toCellX(n[0]),i=this.toCellX(n[2]),o=this.toCellY(n[1]),s=this.toCellY(n[3]),a=this.nextSerial(),c=[];for(let u=o;u<=s;u+=1)for(let h=r;h<=i;h+=1){const l=this.buckets[u*this.gridSize+h];if(!(!l||l.length===0))for(const f of l){if(this.visited[f]===a)continue;this.visited[f]=a;const d=this.items[f];kr(n,[d.minX,d.minY,d.maxX,d.maxY])&&c.push(d)}}return c}nextSerial(){return this.querySerial+=1,this.querySerial===4294967295&&(this.visited.fill(0),this.querySerial=1),this.querySerial}toCellX(t){const n=this.globalBounds[0],r=this.globalBounds[2];if(this.gridSize<=1||r<=n)return 0;const i=(t-n)/this.cellWidth;return!Number.isFinite(i)||i<=0?0:i>=this.gridSize-1?this.gridSize-1:Math.max(0,Math.min(this.gridSize-1,Math.floor(i)))}toCellY(t){const n=this.globalBounds[1],r=this.globalBounds[3];if(this.gridSize<=1||r<=n)return 0;const i=(t-n)/this.cellHeight;return!Number.isFinite(i)||i<=0?0:i>=this.gridSize-1?this.gridSize-1:Math.max(0,Math.min(this.gridSize-1,Math.floor(i)))}}function bl(e){return new yl(e)}function wl(e){return e.replace(/^\s*SRID\s*=\s*\d+\s*;\s*/i,"")}function xl(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function Sl(e){return e>="0"&&e<="9"}function Nr(e){return e==="+"||e==="-"||e==="."||Sl(e)}class El{constructor(t){R(this,"text");R(this,"index",0);this.text=wl(t.trim())}parse(){if(!this.text)return null;const t=this.readWord();if(!t)return null;const n=t.toUpperCase();if(n!=="POLYGON"&&n!=="MULTIPOLYGON")return null;this.skipWhitespace();const r=this.peekWord();if(r){const s=r.toUpperCase();(s==="Z"||s==="M"||s==="ZM")&&(this.readWord(),this.skipWhitespace())}if(this.consumeWordIf("EMPTY"))return this.skipWhitespace(),this.isEof()?n==="POLYGON"?{type:"Polygon",coordinates:[]}:{type:"MultiPolygon",coordinates:[]}:null;let i;try{i=this.parseNestedList()}catch{return null}if(this.skipWhitespace(),!this.isEof())return null;if(n==="POLYGON"){const s=yi(i);return s?{type:"Polygon",coordinates:s}:null}const o=Ml(i);return o?{type:"MultiPolygon",coordinates:o}:null}isEof(){return this.index>=this.text.length}currentChar(){return this.text[this.index]??""}skipWhitespace(){for(;!this.isEof()&&/\s/.test(this.currentChar());)this.index+=1}readWord(){if(this.skipWhitespace(),this.isEof())return null;const t=this.index;for(;!this.isEof()&&xl(this.currentChar());)this.index+=1;return this.index===t?null:this.text.slice(t,this.index)}peekWord(){const t=this.index,n=this.readWord();return this.index=t,n}consumeWordIf(t){const n=this.index,r=this.readWord();return!r||r.toUpperCase()!==t.toUpperCase()?(this.index=n,!1):!0}parseNestedList(){if(this.skipWhitespace(),this.currentChar()!=="(")throw new Error("Expected '('");this.index+=1;const t=[];for(;;){this.skipWhitespace(),this.currentChar()==="("?t.push(this.parseNestedList()):t.push(this.parseCoordinateTuple()),this.skipWhitespace();const n=this.currentChar();if(n===","){this.index+=1;continue}if(n===")"){this.index+=1;break}throw new Error("Expected ',' or ')'")}return t}parseCoordinateTuple(){this.skipWhitespace();const t=[];for(;;){this.skipWhitespace();const n=this.currentChar();if(!n||!Nr(n))break;const r=this.readNumber();if(r===null)break;t.push(r),this.skipWhitespace();const i=this.currentChar();if(!i||i===","||i===")")break;if(!Nr(i))throw new Error("Invalid coordinate")}if(t.length<2)throw new Error("Coordinate requires at least x y");return[t[0],t[1]]}readNumber(){if(this.skipWhitespace(),this.isEof())return null;const n=this.text.slice(this.index).match(/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/);if(!n)return null;const r=Number(n[0]);return Number.isFinite(r)?(this.index+=n[0].length,r):null}}function Rl(e){return Array.isArray(e)&&e.length>=2&&typeof e[0]=="number"&&Number.isFinite(e[0])&&typeof e[1]=="number"&&Number.isFinite(e[1])}function yi(e){if(!Array.isArray(e))return null;const t=[];for(const n of e){if(!Array.isArray(n))return null;const r=[];for(const i of n){if(!Rl(i))return null;r.push([i[0],i[1]])}t.push(r)}return t}function Ml(e){if(!Array.isArray(e))return null;const t=[];for(const n of e){const r=yi(n);if(!r)return null;t.push(r)}return t}function Al(e){return typeof e!="string"?null:new El(e).parse()}exports.DEFAULT_POINT_COLOR=xn;exports.DrawLayer=ei;exports.DrawingLayer=ws;exports.M1TileRenderer=zr;exports.OverlayLayer=xs;exports.OverviewMap=vs;exports.PatchLayer=Is;exports.PointLayer=Js;exports.RegionLayer=fa;exports.TileScheduler=fi;exports.TileViewerCanvas=ha;exports.WsiTileRenderer=pi;exports.WsiViewer=ul;exports.buildPointSpatialIndexAsync=ui;exports.buildTermPalette=no;exports.calcScaleLength=eo;exports.calcScaleResolution=Sn;exports.clamp=W;exports.closeRing=Fe;exports.computeRoiPointGroups=pl;exports.createCircle=fn;exports.createRectangle=Yt;exports.createSpatialIndex=bl;exports.filterPointDataByPolygons=dt;exports.filterPointDataByPolygonsHybrid=si;exports.filterPointDataByPolygonsInWorker=li;exports.filterPointIndicesByPolygons=ri;exports.filterPointIndicesByPolygonsInWorker=Ds;exports.getWebGpuCapabilities=Ns;exports.hexToRgba=Xr;exports.isSameViewState=cn;exports.lookupCellIndex=ci;exports.normalizeImageInfo=Es;exports.parseWkt=Al;exports.prefilterPointsByBoundsWebGpu=oi;exports.terminatePointHitIndexWorker=Zs;exports.terminateRoiClipWorker=zs;exports.toBearerToken=to;exports.toRoiGeometry=pt;exports.toTileUrl=Pn;exports.useViewerContext=ot;
164
164
  //# sourceMappingURL=index.cjs.map