diff --git a/frontend/dist/VERSION b/frontend/dist/VERSION index ee94dd83..b60d7196 100644 --- a/frontend/dist/VERSION +++ b/frontend/dist/VERSION @@ -1 +1 @@ -0.8.3 +0.8.4 diff --git a/frontend/dist/assets/Contacts-BeK0Kmc9.js b/frontend/dist/assets/Contacts-CXyTpkLI.js similarity index 95% rename from frontend/dist/assets/Contacts-BeK0Kmc9.js rename to frontend/dist/assets/Contacts-CXyTpkLI.js index dc39cae0..8b9dae63 100644 --- a/frontend/dist/assets/Contacts-BeK0Kmc9.js +++ b/frontend/dist/assets/Contacts-CXyTpkLI.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-MW3JurnF.js","assets/index-CghAavBY.js","assets/recharts-bmHCCfxU.js","assets/maplibre-gl-CFO9X1Ek.js","assets/index-DRIJpMsz.css","assets/maplibre-gl-DkWLRH05.js","assets/maplibre-gl-B1CfjdFi.css","assets/HashBadge-DRvoJWUk.js","assets/loader-circle-BpG1hWSi.js","assets/info-2P1yfKNj.js","assets/house-B5TO9LE2.js","assets/refresh-cw-CLeY-Xmk.js","assets/trending-up-1mclTNuB.js","assets/map-Bw1EBCOb.js","assets/SignalIndicator-DvUTpR-7.js","assets/triangle-alert-WpF8_xK8.js","assets/zap-D4Tr6Fc8.js","assets/activity-DNdDThXC.js","assets/PageLayout-tjMSgERr.js","assets/users-Cb56Pa85.js"])))=>i.map(i=>d[i]); -import{c as e,j as t,_ as s,z as a,y as n,X as r,A as l,B as i,E as o,g as c,F as d,G as h,H as m,f as x,R as u,C as p,I as g}from"./index-CghAavBY.js";import{b,g as j,c as y,d as v,h as f,T as N,f as w,e as k,L as C}from"./recharts-bmHCCfxU.js";import{a as M}from"./SignalIndicator-DvUTpR-7.js";import{T as S}from"./triangle-alert-WpF8_xK8.js";import{T as H,Z as L,M as _}from"./zap-D4Tr6Fc8.js";import{A as E}from"./activity-DNdDThXC.js";import{T as $,N as R}from"./trending-up-1mclTNuB.js";import{M as A,H as P}from"./HashBadge-DRvoJWUk.js";import{P as T,a as O,C as z,b as F}from"./PageLayout-tjMSgERr.js";import{U as q}from"./users-Cb56Pa85.js";const K=e("arrow-left-right",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]),D=e("arrow-up-down",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]),B=e("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),I=e("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),W=e("messages-square",[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]]),V=e("monitor-smartphone",[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]]),U=e("ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]),G=e("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),Z=e("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Y=e("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);class J extends b.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){var e;return this.state.hasError?t.jsx("div",{className:"glass-card h-[400px] flex items-center justify-center",children:t.jsxs("div",{className:"text-center text-white/50 p-4",children:[t.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),t.jsx("p",{className:"text-sm text-white/30",children:(null==(e=this.state.error)?void 0:e.message)||"Unknown error"})]})}):this.props.children}}const Q=b.lazy(()=>s(()=>import("./ContactsMapMapLibre-MW3JurnF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));function X({neighbors:e,localNode:s,localHash:a,onRemoveNode:n,selectedNodeHash:r,onNodeSelected:l,highlightedEdgeKey:i}){return t.jsx(J,{children:t.jsx(b.Suspense,{fallback:t.jsx("div",{className:"glass-card h-[500px] flex items-center justify-center",children:t.jsx("div",{className:"text-white/50",children:"Loading map..."})}),children:t.jsx(Q,{neighbors:e,localNode:s,localHash:a,onRemoveNode:n,selectedNodeHash:r,onNodeSelected:l,highlightedEdgeKey:i})})})}function ee(e){return e>=.7?"text-accent-success":e>=.5?"text-accent-secondary":e>=.3?"text-signal-poor":"text-accent-danger"}function te(e){return`${Math.round(100*e)}%`}const se=b.memo(function({path:e,isHighlighted:s,onHighlight:a}){const n=function(e){return e>.2?{icon:t.jsx($,{className:"w-3 h-3"}),color:"text-accent-success"}:e<-.2?{icon:t.jsx(H,{className:"w-3 h-3"}),color:"text-accent-danger"}:{icon:t.jsx(_,{className:"w-3 h-3"}),color:"text-text-muted"}}(e.observationTrend),r=e.weakestLinkKey&&e.weakestLinkConfidence<.5;return t.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md transition-colors cursor-pointer "+(s?"bg-accent-primary/20 border border-accent-primary/40":"hover:bg-white/5"),onClick:()=>a(s?null:e.weakestLinkKey),children:[t.jsx("div",{className:"flex-shrink-0 w-12 text-center py-1 rounded-md "+(l=e.healthScore,l>=.7?"bg-accent-success/10":l>=.5?"bg-accent-secondary/10":l>=.3?"bg-signal-poor/10":"bg-accent-danger/10"),children:t.jsx("span",{className:`text-xs font-semibold tabular-nums ${ee(e.healthScore)}`,children:te(e.healthScore)})}),t.jsx("div",{className:"flex-1 flex items-center gap-0.5 overflow-x-auto min-w-0",children:e.hops.map((s,a)=>{var n;return t.jsxs("span",{className:"flex items-center",children:[t.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded "+(r&&(null==(n=e.weakestLinkKey)?void 0:n.includes(s))?"bg-accent-danger/20 text-accent-danger":"bg-white/10 text-text-secondary"),children:s}),al.slice(0,e),[l,e]),d=b.useMemo(()=>0===l.length?null:{avgHealth:l.reduce((e,t)=>e+t.healthScore,0)/l.length,declining:l.filter(e=>e.observationTrend<-.2).length,weakLinks:l.filter(e=>e.weakestLinkConfidence<.5).length},[l]),h=e=>{null==s||s(e)};return 0===l.length?null:t.jsxs("div",{className:"chart-container",children:[t.jsxs("button",{onClick:()=>o(!i),className:"w-full chart-header hover:bg-white/5 transition-colors rounded-t-lg cursor-pointer",children:[t.jsxs("div",{className:"chart-title",children:[t.jsx(I,{className:"chart-title-icon"}),"Path Health",t.jsxs("span",{className:"ml-2 text-[10px] font-normal text-text-muted",children:["(",l.length," paths)"]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[d&&t.jsxs("div",{className:"flex items-center gap-3 text-[10px]",children:[t.jsxs("span",{className:`tabular-nums ${ee(d.avgHealth)}`,children:["Avg: ",te(d.avgHealth)]}),d.weakLinks>0&&t.jsxs("span",{className:"text-accent-danger flex items-center gap-1",children:[t.jsx(S,{className:"w-3 h-3"}),d.weakLinks," weak"]}),d.declining>0&&t.jsxs("span",{className:"text-signal-poor flex items-center gap-1",children:[t.jsx(H,{className:"w-3 h-3"}),d.declining," declining"]})]}),i?t.jsx(B,{className:"w-4 h-4 text-text-muted"}):t.jsx(n,{className:"w-4 h-4 text-text-muted"})]})]}),i&&t.jsxs("div",{className:"p-3 pt-0 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-text-muted pb-2 border-b border-white/5",children:[t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-success"})," Healthy (≥70%)"]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-secondary"})," Fair (50-70%)"]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-signal-poor"})," Weak (30-50%)"]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-danger"})," Critical (<30%)"]})]}),t.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:c.map(e=>t.jsx(se,{path:e,isHighlighted:r===e.weakestLinkKey,onHighlight:h},e.pathKey))}),l.length>e&&t.jsxs("div",{className:"text-center text-[10px] text-text-muted pt-2",children:["Showing top ",e," of ",l.length," paths"]})]})]})}),ne=b.memo(function({isOpen:e,title:s="Confirm",message:a,confirmLabel:n="Confirm",cancelLabel:l="Cancel",variant:i="default",onConfirm:o,onCancel:c}){if(b.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&c()};window.addEventListener("keydown",t);const s=document.body.style.overflow,a=document.body.style.position,n=document.body.style.width,r=document.body.style.top,l=window.scrollY;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${l}px`,()=>{window.removeEventListener("keydown",t),document.body.style.overflow=s,document.body.style.position=a,document.body.style.width=n,document.body.style.top=r,window.scrollTo(0,l)}},[e,c]),!e)return null;const d={danger:{icon:"text-accent-danger",button:"bg-accent-danger hover:bg-red-600"},warning:{icon:"text-accent-secondary",button:"bg-accent-secondary hover:bg-yellow-600 text-bg-body"},default:{icon:"text-accent-primary",button:"bg-accent-primary hover:bg-violet-500 text-bg-body"}}[i];return j.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-md z-[10010] flex items-end sm:items-center justify-center",onClick:c,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-modal-title",children:t.jsxs("div",{className:y("glass-card w-full max-w-sm overflow-hidden","sm:mx-4 sm:rounded-xl","rounded-t-2xl rounded-b-none sm:rounded-b-xl","pb-safe"),onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border-subtle",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:y("p-2 rounded-lg bg-bg-subtle",d.icon),children:t.jsx(S,{className:"w-5 h-5"})}),t.jsx("h3",{id:"confirm-modal-title",className:"text-base font-semibold text-text-primary",children:s})]}),t.jsx("button",{onClick:c,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors",children:t.jsx(r,{className:"w-5 h-5"})})]}),t.jsx("div",{className:"p-4",children:t.jsx("p",{className:"text-sm text-text-secondary",children:a})}),t.jsxs("div",{className:"flex gap-3 p-4 pt-0",children:[t.jsx("button",{onClick:c,className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium text-text-secondary bg-bg-subtle hover:bg-bg-elevated border border-border-subtle transition-colors",children:l}),t.jsx("button",{onClick:o,className:y("flex-1 px-4 py-2.5 rounded-lg text-sm font-medium text-text-primary transition-colors",d.button),children:n})]})]})}),document.body)}),re="var(--signal-critical)",le="var(--signal-poor)",ie="var(--signal-fair)",oe="var(--signal-good)",ce="var(--signal-excellent)",de="var(--text-muted)";function he({active:e,payload:s}){if(!e||!s||!s.length)return null;const a=s[0].payload,n=new Date(a.timestamp),r=`${(n.getMonth()+1).toString().padStart(2,"0")}/${n.getDate().toString().padStart(2,"0")}`;return t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded px-1.5 py-0.5 text-[10px] shadow-xl",children:[t.jsx("span",{className:"text-text-muted",children:r}),t.jsx("span",{className:"ml-1.5 font-semibold tabular-nums",children:a.count})]})}const me=b.memo(function({nodeHash:e,width:s=60,height:a=20,color:n,showArea:r=!0,showTooltip:o=!1,className:c=""}){const d=l(e),h=i(),m=n??(d.length>0?function(e){if(0===e.length)return re;const t=e.slice(-4),s=t.reduce((e,t)=>e+t.count,0),a=s/t.length,n=e.reduce((e,t)=>e+t.count,0)/e.length;if(0===s)return re;if(n>0){const e=a/n;return e>=1.2?ce:e>=.8?oe:e>=.4?ie:e>=.1?le:re}return s>=10?ce:s>=5?oe:s>=2?ie:s>=1?le:re}(d):de),x={width:s,height:a};if(d.length<2){const e="number"==typeof s?s:60,n=h?de:re;return t.jsx("div",{className:`flex items-center justify-center ${c}`,style:{...x,color:n},children:t.jsx("svg",{width:"100%",height:a,viewBox:`0 0 ${e} ${a}`,preserveAspectRatio:"none",children:t.jsx("line",{x1:4,y1:a/2,x2:e-4,y2:a/2,stroke:"currentColor",strokeWidth:1.5,strokeDasharray:"3,2",className:h?"animate-pulse":""})})})}const u=`sparkline-gradient-${e.slice(-6)}`;return t.jsx("div",{className:c,style:x,children:t.jsx(v,{width:"100%",height:"100%",children:r?t.jsxs(f,{data:d,margin:{top:1,right:1,bottom:1,left:1},children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:u,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:m,stopOpacity:.35}),t.jsx("stop",{offset:"100%",stopColor:m,stopOpacity:.05})]})}),o&&t.jsx(N,{content:t.jsx(he,{}),cursor:{stroke:"rgba(255,255,255,0.2)",strokeWidth:1}}),t.jsx(w,{type:"monotone",dataKey:"count",stroke:"none",fill:`url(#${u})`,isAnimationActive:!1}),t.jsx(k,{type:"monotone",dataKey:"count",stroke:m,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]}):t.jsxs(C,{data:d,margin:{top:1,right:1,bottom:1,left:1},children:[o&&t.jsx(N,{content:t.jsx(he,{}),cursor:{stroke:"rgba(255,255,255,0.2)",strokeWidth:1}}),t.jsx(k,{type:"monotone",dataKey:"count",stroke:m,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})})});function xe(e,t,s,a){const n=(s-e)*Math.PI/180,r=(a-t)*Math.PI/180,l=Math.sin(n/2)*Math.sin(n/2)+Math.cos(e*Math.PI/180)*Math.cos(s*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371e3}const ue=Object.freeze(Object.defineProperty({__proto__:null,default:function(){const{stats:e}=o(),s=c(),a=d(),n=h(),l=m(),i=x(),[j,y]=b.useState(null),[v,f]=b.useState("lastHeard"),[N,w]=b.useState("desc"),[k,C]=b.useState(""),[S,H]=b.useState(!1),[L,_]=b.useState(null),[$,B]=b.useState(null),I=b.useMemo(()=>(null==e?void 0:e.neighbors)??{},[null==e?void 0:e.neighbors]),J=b.useMemo(()=>Object.fromEntries(Object.entries(I).filter(([e])=>!s.has(e))),[I,s]),Q=b.useMemo(()=>{var t;return(null==(t=null==e?void 0:e.config)?void 0:t.repeater)?{latitude:e.config.repeater.latitude,longitude:e.config.repeater.longitude,name:e.config.node_name||"Local Node"}:void 0},[e]),ee=null==e?void 0:e.local_hash,te=b.useMemo(()=>{const e=new Map;if(!(null==Q?void 0:Q.latitude)||!(null==Q?void 0:Q.longitude))return e;for(const[t,s]of Object.entries(J))s.latitude&&s.longitude&&0!==s.latitude&&0!==s.longitude?e.set(t,xe(Q.latitude,Q.longitude,s.latitude,s.longitude)):e.set(t,null);return e},[J,Q]),{neighborHashSet:se,neighborSignalMap:re}=b.useMemo(()=>{const e=new Set,t=new Map;for(const s of i)e.add(s.hash),t.set(s.hash,{avgRssi:s.avgRssi,avgSnr:s.avgSnr});return{neighborHashSet:e,neighborSignalMap:t}},[i]),le=b.useMemo(()=>{const e=k.toLowerCase().trim(),t="neighbor"===e||"neighbors"===e,s=S||t;return Object.fromEntries(Object.entries(J).filter(([a,n])=>{if(s&&!se.has(a))return!1;if(t)return!0;if(!e)return!0;const r=(n.node_name||n.name||"").toLowerCase(),l=a.slice(2,4).toLowerCase();return r.includes(e)||l.includes(e)||a.toLowerCase().includes(e)}))},[J,k,S,se]),ie=b.useMemo(()=>Object.entries(le).sort(([e,t],[s,a])=>{let n=0;switch(v){case"lastHeard":n=(t.last_seen||0)-(a.last_seen||0);break;case"distance":{const t=te.get(e)??null,a=te.get(s)??null;n=null===t&&null===a?0:null===t?1:null===a?-1:t-a;break}case"centrality":n=(l.get(e)||0)-(l.get(s)||0)}return"desc"===N?-n:n}),[le,v,N,te,l]),oe=ie.filter(([,e])=>e.latitude&&e.longitude&&0!==e.latitude&&0!==e.longitude).length,ce=b.useMemo(()=>new Set(n),[n]),de=b.useCallback(e=>{v===e?w(e=>"desc"===e?"asc":"desc"):(f(e),w("desc"))},[v]),he=b.useCallback(e=>{const t=J[e];(null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&0!==t.latitude&&0!==t.longitude&&_(e)},[J]),ue=b.useCallback(()=>{_(null)},[]);return t.jsxs(T,{children:[t.jsx(O,{title:"Contacts",icon:t.jsx(q,{}),controls:t.jsxs("div",{className:"flex items-baseline gap-3 sm:gap-4",children:[t.jsxs("span",{className:"roster-title tabular-nums",children:[ie.length," node",1!==ie.length?"s":""]}),oe>0&&t.jsxs("span",{className:"roster-title flex items-baseline gap-1.5 tabular-nums",children:[t.jsx(A,{className:"w-3.5 h-3.5 relative top-[2px]"}),oe," with location"]})]})}),t.jsx("div",{className:"relative",children:t.jsx(X,{neighbors:J,localNode:Q,localHash:ee,onRemoveNode:a,selectedNodeHash:L,onNodeSelected:ue,highlightedEdgeKey:$})}),t.jsx(ae,{maxPaths:10,highlightedEdge:$,onHighlightEdge:B}),t.jsxs(z,{noPadding:!0,children:[t.jsx(F,{listHeader:!0,icon:t.jsx(q,{className:"icon-sm"}),title:"Discovered Contacts",actions:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[se.size>0&&t.jsxs("button",{onClick:()=>H(!S),className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg transition-colors min-h-[32px] order-1 sm:order-1 "+(S?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-secondary hover:bg-white/5 border border-transparent"),title:S?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[t.jsx(u,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"hidden sm:inline",children:"Neighbors"}),t.jsx("span",{className:"sm:hidden",children:se.size}),S&&t.jsx("span",{className:"text-[10px] font-semibold tabular-nums",children:se.size})]}),t.jsxs("div",{className:"relative order-2 sm:order-2",children:[t.jsx(G,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted"}),t.jsx("input",{type:"text",value:k,onChange:e=>C(e.target.value),placeholder:"Search...",className:"w-28 sm:w-32 pl-7 pr-7 py-1.5 text-xs bg-white/5 border border-white/10 rounded-lg text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-primary/50"}),k&&t.jsx("button",{onClick:()=>{C(""),"neighbor"!==k.toLowerCase().trim()&&"neighbors"!==k.toLowerCase().trim()||H(!1)},className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary p-0.5",children:t.jsx(r,{className:"w-3.5 h-3.5"})})]}),t.jsxs("div",{className:"flex items-center gap-1 order-1 sm:order-2",children:[t.jsxs("button",{onClick:()=>de("lastHeard"),className:"flex items-center gap-1 px-2.5 py-1.5 text-xs rounded-lg transition-colors min-h-[32px] "+("lastHeard"===v?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by last heard",children:[t.jsx(p,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"hidden sm:inline",children:"Recent"}),"lastHeard"===v&&t.jsx(D,{className:"w-3 h-3 "+("asc"===N?"rotate-180":"")})]}),t.jsxs("button",{onClick:()=>de("distance"),className:"flex items-center gap-1 px-2.5 py-1.5 text-xs rounded-lg transition-colors min-h-[32px] "+("distance"===v?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by distance",children:[t.jsx(U,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"hidden sm:inline",children:"Distance"}),"distance"===v&&t.jsx(D,{className:"w-3 h-3 "+("asc"===N?"rotate-180":"")})]}),t.jsxs("button",{onClick:()=>de("centrality"),className:"flex items-center gap-1 px-2.5 py-1.5 text-xs rounded-lg transition-colors min-h-[32px] "+("centrality"===v?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by network centrality",children:[t.jsx(E,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"hidden sm:inline",children:"Centrality"}),"centrality"===v&&t.jsx(D,{className:"w-3 h-3 "+("asc"===N?"rotate-180":"")})]})]})]})}),ie.length>0?t.jsx("div",{className:"roster-list",children:ie.map(([e,s],a)=>{var n,r;const i=s.latitude&&s.longitude&&0!==s.latitude&&0!==s.longitude,o=s.node_name||s.name||"Unknown",c=ce.has(e),d=se.has(e),h=te.get(e),m=l.get(e)||0,x=d?re.get(e):void 0,u=d&&x;return t.jsxs("div",{children:[t.jsxs("div",{className:`roster-row ${c?"bg-amber-500/5 border-l-2 border-l-amber-400":""} ${i?"cursor-pointer hover:bg-white/[0.02]":""}`,onClick:()=>he(e),children:[t.jsxs("div",{className:"relative flex-shrink-0",children:[t.jsx("div",{className:"roster-icon",children:(()=>{var e;const a=null==(e=s.contact_type)?void 0:e.toLowerCase(),n="room server"===a||"room_server"===a||"room"===a||"server"===a,r="companion"===a||"client"===a||"cli"===a,l=s.is_repeater||"repeater"===a||"rep"===a,i="#4338CA",o="#F59E0B";return n&&l?t.jsxs("div",{className:"relative w-5 h-5",children:[t.jsx(W,{className:"w-5 h-5 absolute inset-0",style:{color:o}}),t.jsx(Z,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5",style:{color:i}})]}):n?t.jsx(W,{className:"w-5 h-5",style:{color:o}}):r?t.jsx(V,{className:"w-5 h-5 text-text-muted"}):l?d?t.jsx(K,{className:"w-5 h-5 text-accent-success"}):t.jsx(Z,{className:"w-5 h-5",style:{color:i}}):t.jsx(V,{className:"w-5 h-5 text-text-muted"})})()}),u&&null!==(null==x?void 0:x.avgSnr)&&t.jsx("div",{className:`absolute -top-0.5 -right-0.5 w-2.5 h-2.5 rounded-full ${b=x.avgSnr,void 0===b?"bg-[var(--signal-unknown)]":b>=5?"bg-[var(--signal-excellent)]":b>=0?"bg-[var(--signal-good)]":b>=-5?"bg-[var(--signal-fair)]":b>=-10?"bg-[var(--signal-poor)]":"bg-[var(--signal-critical)]"} border-2 border-bg-surface`})]}),t.jsxs("div",{className:"roster-content min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:"roster-title",children:o}),d&&t.jsx("span",{className:"type-badge px-1.5 py-0.5 rounded",style:{backgroundColor:"rgba(57, 217, 138, 0.2)",color:"#39D98A"},children:"NBR"}),c&&t.jsxs("span",{className:"type-badge px-1.5 py-0.5 rounded flex items-center gap-1",style:{backgroundColor:"rgba(251, 191, 36, 0.2)",color:"#FBBF24"},children:[t.jsx(R,{className:"w-3 h-3"}),"HUB"]}),(s.is_repeater||"repeater"===(null==(n=s.contact_type)?void 0:n.toLowerCase())||"rep"===(null==(r=s.contact_type)?void 0:r.toLowerCase()))&&t.jsx("span",{className:"pill-tag",children:"RPT"})]}),t.jsx("div",{className:"hidden md:block",children:t.jsx(P,{hash:e,size:"sm",full:!0})}),t.jsx("div",{className:"md:hidden",children:t.jsx(P,{hash:e,size:"sm",prefixLength:8,suffixLength:6})})]}),t.jsxs("div",{className:"roster-metrics flex-shrink-0",children:[u&&null!==(null==x?void 0:x.avgRssi)&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(M,{rssi:x.avgRssi,className:"w-3.5 h-3.5"}),t.jsx("span",{className:"type-data-xs tabular-nums",children:Math.round(x.avgRssi)})]}),u&&null!==(null==x?void 0:x.avgSnr)&&t.jsx("div",{className:"flex items-center gap-1.5",children:t.jsxs("span",{className:"type-data-xs tabular-nums",children:[x.avgSnr.toFixed(1)," dB"]})}),null!=h&&t.jsxs("div",{className:"flex items-center gap-1 text-accent-tertiary",children:[t.jsx(U,{className:"w-3 h-3"}),t.jsx("span",{className:"type-data-xs tabular-nums",children:(p=h,p<1e3?`${Math.round(p)}m`:`${(p/1e3).toFixed(1)}km`)})]}),m>0&&t.jsxs("div",{className:"flex items-center gap-1 text-amber-400/70",children:[t.jsx(E,{className:"w-3 h-3"}),t.jsxs("span",{className:"type-data-xs tabular-nums",children:[(100*m).toFixed(0),"%"]})]}),t.jsx("div",{className:"hidden sm:block",children:t.jsx(me,{nodeHash:e,width:48,height:16})})]}),t.jsx("div",{className:"roster-metric flex-shrink-0",children:s.last_seen?g(s.last_seen):"—"}),t.jsx("button",{onClick:t=>{t.stopPropagation(),y({hash:e,name:o})},className:"ml-2 p-1.5 rounded-lg text-text-muted/50 hover:text-red-400 hover:bg-red-500/10 transition-colors flex-shrink-0",title:"Remove contact",children:t.jsx(Y,{className:"w-4 h-4"})})]}),a{j&&a(j.hash),y(null)},onCancel:()=>y(null)})]})}},Symbol.toStringTag,{value:"Module"}));export{ne as C,I as G,W as M,me as N,Y as T,ue as a}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-Cu_poy9C.js","assets/index-CdRF8vVQ.js","assets/recharts-bmHCCfxU.js","assets/maplibre-gl-CFO9X1Ek.js","assets/index-DRIJpMsz.css","assets/maplibre-gl-B8VKi8hi.js","assets/maplibre-gl-B1CfjdFi.css","assets/HashBadge-NQ19jVvM.js","assets/loader-circle-BGRieeTW.js","assets/info-lO6hs_0s.js","assets/house-529B6MyG.js","assets/refresh-cw-BYGR8_G5.js","assets/trending-up-Bn6V5R3a.js","assets/map-BceOJy6E.js","assets/SignalIndicator-PFR99EHr.js","assets/triangle-alert-CS670Iqt.js","assets/zap-CWYA_VUV.js","assets/activity-XYItBmUY.js","assets/PageLayout-CUN38fny.js","assets/users-wZVlsBad.js"])))=>i.map(i=>d[i]); +import{c as e,j as t,_ as s,z as a,y as n,X as r,A as l,B as i,E as o,g as c,F as d,G as h,H as m,f as x,R as u,C as p,I as g}from"./index-CdRF8vVQ.js";import{b,g as j,c as y,d as v,h as f,T as N,f as w,e as k,L as C}from"./recharts-bmHCCfxU.js";import{a as M}from"./SignalIndicator-PFR99EHr.js";import{T as S}from"./triangle-alert-CS670Iqt.js";import{T as H,Z as L,M as _}from"./zap-CWYA_VUV.js";import{A as E}from"./activity-XYItBmUY.js";import{T as $,N as R}from"./trending-up-Bn6V5R3a.js";import{M as A,H as P}from"./HashBadge-NQ19jVvM.js";import{P as T,a as O,C as z,b as F}from"./PageLayout-CUN38fny.js";import{U as q}from"./users-wZVlsBad.js";const K=e("arrow-left-right",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]),D=e("arrow-up-down",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]),B=e("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),I=e("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),W=e("messages-square",[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]]),V=e("monitor-smartphone",[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]]),U=e("ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]),G=e("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),Z=e("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Y=e("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);class J extends b.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){var e;return this.state.hasError?t.jsx("div",{className:"glass-card h-[400px] flex items-center justify-center",children:t.jsxs("div",{className:"text-center text-white/50 p-4",children:[t.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),t.jsx("p",{className:"text-sm text-white/30",children:(null==(e=this.state.error)?void 0:e.message)||"Unknown error"})]})}):this.props.children}}const Q=b.lazy(()=>s(()=>import("./ContactsMapMapLibre-Cu_poy9C.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));function X({neighbors:e,localNode:s,localHash:a,onRemoveNode:n,selectedNodeHash:r,onNodeSelected:l,highlightedEdgeKey:i}){return t.jsx(J,{children:t.jsx(b.Suspense,{fallback:t.jsx("div",{className:"glass-card h-[500px] flex items-center justify-center",children:t.jsx("div",{className:"text-white/50",children:"Loading map..."})}),children:t.jsx(Q,{neighbors:e,localNode:s,localHash:a,onRemoveNode:n,selectedNodeHash:r,onNodeSelected:l,highlightedEdgeKey:i})})})}function ee(e){return e>=.7?"text-accent-success":e>=.5?"text-accent-secondary":e>=.3?"text-signal-poor":"text-accent-danger"}function te(e){return`${Math.round(100*e)}%`}const se=b.memo(function({path:e,isHighlighted:s,onHighlight:a}){const n=function(e){return e>.2?{icon:t.jsx($,{className:"w-3 h-3"}),color:"text-accent-success"}:e<-.2?{icon:t.jsx(H,{className:"w-3 h-3"}),color:"text-accent-danger"}:{icon:t.jsx(_,{className:"w-3 h-3"}),color:"text-text-muted"}}(e.observationTrend),r=e.weakestLinkKey&&e.weakestLinkConfidence<.5;return t.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md transition-colors cursor-pointer "+(s?"bg-accent-primary/20 border border-accent-primary/40":"hover:bg-white/5"),onClick:()=>a(s?null:e.weakestLinkKey),children:[t.jsx("div",{className:"flex-shrink-0 w-12 text-center py-1 rounded-md "+(l=e.healthScore,l>=.7?"bg-accent-success/10":l>=.5?"bg-accent-secondary/10":l>=.3?"bg-signal-poor/10":"bg-accent-danger/10"),children:t.jsx("span",{className:`text-xs font-semibold tabular-nums ${ee(e.healthScore)}`,children:te(e.healthScore)})}),t.jsx("div",{className:"flex-1 flex items-center gap-0.5 overflow-x-auto min-w-0",children:e.hops.map((s,a)=>{var n;return t.jsxs("span",{className:"flex items-center",children:[t.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded "+(r&&(null==(n=e.weakestLinkKey)?void 0:n.includes(s))?"bg-accent-danger/20 text-accent-danger":"bg-white/10 text-text-secondary"),children:s}),al.slice(0,e),[l,e]),d=b.useMemo(()=>0===l.length?null:{avgHealth:l.reduce((e,t)=>e+t.healthScore,0)/l.length,declining:l.filter(e=>e.observationTrend<-.2).length,weakLinks:l.filter(e=>e.weakestLinkConfidence<.5).length},[l]),h=e=>{null==s||s(e)};return 0===l.length?null:t.jsxs("div",{className:"chart-container",children:[t.jsxs("button",{onClick:()=>o(!i),className:"w-full chart-header hover:bg-white/5 transition-colors rounded-t-lg cursor-pointer",children:[t.jsxs("div",{className:"chart-title",children:[t.jsx(I,{className:"chart-title-icon"}),"Path Health",t.jsxs("span",{className:"ml-2 text-[10px] font-normal text-text-muted",children:["(",l.length," paths)"]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[d&&t.jsxs("div",{className:"flex items-center gap-3 text-[10px]",children:[t.jsxs("span",{className:`tabular-nums ${ee(d.avgHealth)}`,children:["Avg: ",te(d.avgHealth)]}),d.weakLinks>0&&t.jsxs("span",{className:"text-accent-danger flex items-center gap-1",children:[t.jsx(S,{className:"w-3 h-3"}),d.weakLinks," weak"]}),d.declining>0&&t.jsxs("span",{className:"text-signal-poor flex items-center gap-1",children:[t.jsx(H,{className:"w-3 h-3"}),d.declining," declining"]})]}),i?t.jsx(B,{className:"w-4 h-4 text-text-muted"}):t.jsx(n,{className:"w-4 h-4 text-text-muted"})]})]}),i&&t.jsxs("div",{className:"p-3 pt-0 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-text-muted pb-2 border-b border-white/5",children:[t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-success"})," Healthy (≥70%)"]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-secondary"})," Fair (50-70%)"]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-signal-poor"})," Weak (30-50%)"]}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-danger"})," Critical (<30%)"]})]}),t.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:c.map(e=>t.jsx(se,{path:e,isHighlighted:r===e.weakestLinkKey,onHighlight:h},e.pathKey))}),l.length>e&&t.jsxs("div",{className:"text-center text-[10px] text-text-muted pt-2",children:["Showing top ",e," of ",l.length," paths"]})]})]})}),ne=b.memo(function({isOpen:e,title:s="Confirm",message:a,confirmLabel:n="Confirm",cancelLabel:l="Cancel",variant:i="default",onConfirm:o,onCancel:c}){if(b.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&c()};window.addEventListener("keydown",t);const s=document.body.style.overflow,a=document.body.style.position,n=document.body.style.width,r=document.body.style.top,l=window.scrollY;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${l}px`,()=>{window.removeEventListener("keydown",t),document.body.style.overflow=s,document.body.style.position=a,document.body.style.width=n,document.body.style.top=r,window.scrollTo(0,l)}},[e,c]),!e)return null;const d={danger:{icon:"text-accent-danger",button:"bg-accent-danger hover:bg-red-600"},warning:{icon:"text-accent-secondary",button:"bg-accent-secondary hover:bg-yellow-600 text-bg-body"},default:{icon:"text-accent-primary",button:"bg-accent-primary hover:bg-violet-500 text-bg-body"}}[i];return j.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-md z-[10010] flex items-end sm:items-center justify-center",onClick:c,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-modal-title",children:t.jsxs("div",{className:y("glass-card w-full max-w-sm overflow-hidden","sm:mx-4 sm:rounded-xl","rounded-t-2xl rounded-b-none sm:rounded-b-xl","pb-safe"),onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border-subtle",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:y("p-2 rounded-lg bg-bg-subtle",d.icon),children:t.jsx(S,{className:"w-5 h-5"})}),t.jsx("h3",{id:"confirm-modal-title",className:"text-base font-semibold text-text-primary",children:s})]}),t.jsx("button",{onClick:c,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors",children:t.jsx(r,{className:"w-5 h-5"})})]}),t.jsx("div",{className:"p-4",children:t.jsx("p",{className:"text-sm text-text-secondary",children:a})}),t.jsxs("div",{className:"flex gap-3 p-4 pt-0",children:[t.jsx("button",{onClick:c,className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium text-text-secondary bg-bg-subtle hover:bg-bg-elevated border border-border-subtle transition-colors",children:l}),t.jsx("button",{onClick:o,className:y("flex-1 px-4 py-2.5 rounded-lg text-sm font-medium text-text-primary transition-colors",d.button),children:n})]})]})}),document.body)}),re="var(--signal-critical)",le="var(--signal-poor)",ie="var(--signal-fair)",oe="var(--signal-good)",ce="var(--signal-excellent)",de="var(--text-muted)";function he({active:e,payload:s}){if(!e||!s||!s.length)return null;const a=s[0].payload,n=new Date(a.timestamp),r=`${(n.getMonth()+1).toString().padStart(2,"0")}/${n.getDate().toString().padStart(2,"0")}`;return t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded px-1.5 py-0.5 text-[10px] shadow-xl",children:[t.jsx("span",{className:"text-text-muted",children:r}),t.jsx("span",{className:"ml-1.5 font-semibold tabular-nums",children:a.count})]})}const me=b.memo(function({nodeHash:e,width:s=60,height:a=20,color:n,showArea:r=!0,showTooltip:o=!1,className:c=""}){const d=l(e),h=i(),m=n??(d.length>0?function(e){if(0===e.length)return re;const t=e.slice(-4),s=t.reduce((e,t)=>e+t.count,0),a=s/t.length,n=e.reduce((e,t)=>e+t.count,0)/e.length;if(0===s)return re;if(n>0){const e=a/n;return e>=1.2?ce:e>=.8?oe:e>=.4?ie:e>=.1?le:re}return s>=10?ce:s>=5?oe:s>=2?ie:s>=1?le:re}(d):de),x={width:s,height:a};if(d.length<2){const e="number"==typeof s?s:60,n=h?de:re;return t.jsx("div",{className:`flex items-center justify-center ${c}`,style:{...x,color:n},children:t.jsx("svg",{width:"100%",height:a,viewBox:`0 0 ${e} ${a}`,preserveAspectRatio:"none",children:t.jsx("line",{x1:4,y1:a/2,x2:e-4,y2:a/2,stroke:"currentColor",strokeWidth:1.5,strokeDasharray:"3,2",className:h?"animate-pulse":""})})})}const u=`sparkline-gradient-${e.slice(-6)}`;return t.jsx("div",{className:c,style:x,children:t.jsx(v,{width:"100%",height:"100%",children:r?t.jsxs(f,{data:d,margin:{top:1,right:1,bottom:1,left:1},children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:u,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:m,stopOpacity:.35}),t.jsx("stop",{offset:"100%",stopColor:m,stopOpacity:.05})]})}),o&&t.jsx(N,{content:t.jsx(he,{}),cursor:{stroke:"rgba(255,255,255,0.2)",strokeWidth:1}}),t.jsx(w,{type:"monotone",dataKey:"count",stroke:"none",fill:`url(#${u})`,isAnimationActive:!1}),t.jsx(k,{type:"monotone",dataKey:"count",stroke:m,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]}):t.jsxs(C,{data:d,margin:{top:1,right:1,bottom:1,left:1},children:[o&&t.jsx(N,{content:t.jsx(he,{}),cursor:{stroke:"rgba(255,255,255,0.2)",strokeWidth:1}}),t.jsx(k,{type:"monotone",dataKey:"count",stroke:m,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})})});function xe(e,t,s,a){const n=(s-e)*Math.PI/180,r=(a-t)*Math.PI/180,l=Math.sin(n/2)*Math.sin(n/2)+Math.cos(e*Math.PI/180)*Math.cos(s*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371e3}const ue=Object.freeze(Object.defineProperty({__proto__:null,default:function(){const{stats:e}=o(),s=c(),a=d(),n=h(),l=m(),i=x(),[j,y]=b.useState(null),[v,f]=b.useState("lastHeard"),[N,w]=b.useState("desc"),[k,C]=b.useState(""),[S,H]=b.useState(!1),[L,_]=b.useState(null),[$,B]=b.useState(null),I=b.useMemo(()=>(null==e?void 0:e.neighbors)??{},[null==e?void 0:e.neighbors]),J=b.useMemo(()=>Object.fromEntries(Object.entries(I).filter(([e])=>!s.has(e))),[I,s]),Q=b.useMemo(()=>{var t;return(null==(t=null==e?void 0:e.config)?void 0:t.repeater)?{latitude:e.config.repeater.latitude,longitude:e.config.repeater.longitude,name:e.config.node_name||"Local Node"}:void 0},[e]),ee=null==e?void 0:e.local_hash,te=b.useMemo(()=>{const e=new Map;if(!(null==Q?void 0:Q.latitude)||!(null==Q?void 0:Q.longitude))return e;for(const[t,s]of Object.entries(J))s.latitude&&s.longitude&&0!==s.latitude&&0!==s.longitude?e.set(t,xe(Q.latitude,Q.longitude,s.latitude,s.longitude)):e.set(t,null);return e},[J,Q]),{neighborHashSet:se,neighborSignalMap:re}=b.useMemo(()=>{const e=new Set,t=new Map;for(const s of i)e.add(s.hash),t.set(s.hash,{avgRssi:s.avgRssi,avgSnr:s.avgSnr});return{neighborHashSet:e,neighborSignalMap:t}},[i]),le=b.useMemo(()=>{const e=k.toLowerCase().trim(),t="neighbor"===e||"neighbors"===e,s=S||t;return Object.fromEntries(Object.entries(J).filter(([a,n])=>{if(s&&!se.has(a))return!1;if(t)return!0;if(!e)return!0;const r=(n.node_name||n.name||"").toLowerCase(),l=a.slice(2,4).toLowerCase();return r.includes(e)||l.includes(e)||a.toLowerCase().includes(e)}))},[J,k,S,se]),ie=b.useMemo(()=>Object.entries(le).sort(([e,t],[s,a])=>{let n=0;switch(v){case"lastHeard":n=(t.last_seen||0)-(a.last_seen||0);break;case"distance":{const t=te.get(e)??null,a=te.get(s)??null;n=null===t&&null===a?0:null===t?1:null===a?-1:t-a;break}case"centrality":n=(l.get(e)||0)-(l.get(s)||0)}return"desc"===N?-n:n}),[le,v,N,te,l]),oe=ie.filter(([,e])=>e.latitude&&e.longitude&&0!==e.latitude&&0!==e.longitude).length,ce=b.useMemo(()=>new Set(n),[n]),de=b.useCallback(e=>{v===e?w(e=>"desc"===e?"asc":"desc"):(f(e),w("desc"))},[v]),he=b.useCallback(e=>{const t=J[e];(null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&0!==t.latitude&&0!==t.longitude&&_(e)},[J]),ue=b.useCallback(()=>{_(null)},[]);return t.jsxs(T,{children:[t.jsx(O,{title:"Contacts",icon:t.jsx(q,{}),controls:t.jsxs("div",{className:"flex items-baseline gap-3 sm:gap-4",children:[t.jsxs("span",{className:"roster-title tabular-nums",children:[ie.length," node",1!==ie.length?"s":""]}),oe>0&&t.jsxs("span",{className:"roster-title flex items-baseline gap-1.5 tabular-nums",children:[t.jsx(A,{className:"w-3.5 h-3.5 relative top-[2px]"}),oe," with location"]})]})}),t.jsx("div",{className:"relative",children:t.jsx(X,{neighbors:J,localNode:Q,localHash:ee,onRemoveNode:a,selectedNodeHash:L,onNodeSelected:ue,highlightedEdgeKey:$})}),t.jsx(ae,{maxPaths:10,highlightedEdge:$,onHighlightEdge:B}),t.jsxs(z,{noPadding:!0,children:[t.jsx(F,{listHeader:!0,icon:t.jsx(q,{className:"icon-sm"}),title:"Discovered Contacts",actions:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[se.size>0&&t.jsxs("button",{onClick:()=>H(!S),className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-lg transition-colors min-h-[32px] order-1 sm:order-1 "+(S?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-secondary hover:bg-white/5 border border-transparent"),title:S?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[t.jsx(u,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"hidden sm:inline",children:"Neighbors"}),t.jsx("span",{className:"sm:hidden",children:se.size}),S&&t.jsx("span",{className:"text-[10px] font-semibold tabular-nums",children:se.size})]}),t.jsxs("div",{className:"relative order-2 sm:order-2",children:[t.jsx(G,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted"}),t.jsx("input",{type:"text",value:k,onChange:e=>C(e.target.value),placeholder:"Search...",className:"w-28 sm:w-32 pl-7 pr-7 py-1.5 text-xs bg-white/5 border border-white/10 rounded-lg text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-primary/50"}),k&&t.jsx("button",{onClick:()=>{C(""),"neighbor"!==k.toLowerCase().trim()&&"neighbors"!==k.toLowerCase().trim()||H(!1)},className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary p-0.5",children:t.jsx(r,{className:"w-3.5 h-3.5"})})]}),t.jsxs("div",{className:"flex items-center gap-1 order-1 sm:order-2",children:[t.jsxs("button",{onClick:()=>de("lastHeard"),className:"flex items-center gap-1 px-2.5 py-1.5 text-xs rounded-lg transition-colors min-h-[32px] "+("lastHeard"===v?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by last heard",children:[t.jsx(p,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"hidden sm:inline",children:"Recent"}),"lastHeard"===v&&t.jsx(D,{className:"w-3 h-3 "+("asc"===N?"rotate-180":"")})]}),t.jsxs("button",{onClick:()=>de("distance"),className:"flex items-center gap-1 px-2.5 py-1.5 text-xs rounded-lg transition-colors min-h-[32px] "+("distance"===v?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by distance",children:[t.jsx(U,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"hidden sm:inline",children:"Distance"}),"distance"===v&&t.jsx(D,{className:"w-3 h-3 "+("asc"===N?"rotate-180":"")})]}),t.jsxs("button",{onClick:()=>de("centrality"),className:"flex items-center gap-1 px-2.5 py-1.5 text-xs rounded-lg transition-colors min-h-[32px] "+("centrality"===v?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by network centrality",children:[t.jsx(E,{className:"w-3.5 h-3.5"}),t.jsx("span",{className:"hidden sm:inline",children:"Centrality"}),"centrality"===v&&t.jsx(D,{className:"w-3 h-3 "+("asc"===N?"rotate-180":"")})]})]})]})}),ie.length>0?t.jsx("div",{className:"roster-list",children:ie.map(([e,s],a)=>{var n,r;const i=s.latitude&&s.longitude&&0!==s.latitude&&0!==s.longitude,o=s.node_name||s.name||"Unknown",c=ce.has(e),d=se.has(e),h=te.get(e),m=l.get(e)||0,x=d?re.get(e):void 0,u=d&&x;return t.jsxs("div",{children:[t.jsxs("div",{className:`roster-row ${c?"bg-amber-500/5 border-l-2 border-l-amber-400":""} ${i?"cursor-pointer hover:bg-white/[0.02]":""}`,onClick:()=>he(e),children:[t.jsxs("div",{className:"relative flex-shrink-0",children:[t.jsx("div",{className:"roster-icon",children:(()=>{var e;const a=null==(e=s.contact_type)?void 0:e.toLowerCase(),n="room server"===a||"room_server"===a||"room"===a||"server"===a,r="companion"===a||"client"===a||"cli"===a,l=s.is_repeater||"repeater"===a||"rep"===a,i="#4338CA",o="#F59E0B";return n&&l?t.jsxs("div",{className:"relative w-5 h-5",children:[t.jsx(W,{className:"w-5 h-5 absolute inset-0",style:{color:o}}),t.jsx(Z,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5",style:{color:i}})]}):n?t.jsx(W,{className:"w-5 h-5",style:{color:o}}):r?t.jsx(V,{className:"w-5 h-5 text-text-muted"}):l?d?t.jsx(K,{className:"w-5 h-5 text-accent-success"}):t.jsx(Z,{className:"w-5 h-5",style:{color:i}}):t.jsx(V,{className:"w-5 h-5 text-text-muted"})})()}),u&&null!==(null==x?void 0:x.avgSnr)&&t.jsx("div",{className:`absolute -top-0.5 -right-0.5 w-2.5 h-2.5 rounded-full ${b=x.avgSnr,void 0===b?"bg-[var(--signal-unknown)]":b>=5?"bg-[var(--signal-excellent)]":b>=0?"bg-[var(--signal-good)]":b>=-5?"bg-[var(--signal-fair)]":b>=-10?"bg-[var(--signal-poor)]":"bg-[var(--signal-critical)]"} border-2 border-bg-surface`})]}),t.jsxs("div",{className:"roster-content min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:"roster-title",children:o}),d&&t.jsx("span",{className:"type-badge px-1.5 py-0.5 rounded",style:{backgroundColor:"rgba(57, 217, 138, 0.2)",color:"#39D98A"},children:"NBR"}),c&&t.jsxs("span",{className:"type-badge px-1.5 py-0.5 rounded flex items-center gap-1",style:{backgroundColor:"rgba(251, 191, 36, 0.2)",color:"#FBBF24"},children:[t.jsx(R,{className:"w-3 h-3"}),"HUB"]}),(s.is_repeater||"repeater"===(null==(n=s.contact_type)?void 0:n.toLowerCase())||"rep"===(null==(r=s.contact_type)?void 0:r.toLowerCase()))&&t.jsx("span",{className:"pill-tag",children:"RPT"})]}),t.jsx("div",{className:"hidden md:block",children:t.jsx(P,{hash:e,size:"sm",full:!0})}),t.jsx("div",{className:"md:hidden",children:t.jsx(P,{hash:e,size:"sm",prefixLength:8,suffixLength:6})})]}),t.jsxs("div",{className:"roster-metrics flex-shrink-0",children:[u&&null!==(null==x?void 0:x.avgRssi)&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(M,{rssi:x.avgRssi,className:"w-3.5 h-3.5"}),t.jsx("span",{className:"type-data-xs tabular-nums",children:Math.round(x.avgRssi)})]}),u&&null!==(null==x?void 0:x.avgSnr)&&t.jsx("div",{className:"flex items-center gap-1.5",children:t.jsxs("span",{className:"type-data-xs tabular-nums",children:[x.avgSnr.toFixed(1)," dB"]})}),null!=h&&t.jsxs("div",{className:"flex items-center gap-1 text-accent-tertiary",children:[t.jsx(U,{className:"w-3 h-3"}),t.jsx("span",{className:"type-data-xs tabular-nums",children:(p=h,p<1e3?`${Math.round(p)}m`:`${(p/1e3).toFixed(1)}km`)})]}),m>0&&t.jsxs("div",{className:"flex items-center gap-1 text-amber-400/70",children:[t.jsx(E,{className:"w-3 h-3"}),t.jsxs("span",{className:"type-data-xs tabular-nums",children:[(100*m).toFixed(0),"%"]})]}),t.jsx("div",{className:"hidden sm:block",children:t.jsx(me,{nodeHash:e,width:48,height:16})})]}),t.jsx("div",{className:"roster-metric flex-shrink-0",children:s.last_seen?g(s.last_seen):"—"}),t.jsx("button",{onClick:t=>{t.stopPropagation(),y({hash:e,name:o})},className:"ml-2 p-1.5 rounded-lg text-text-muted/50 hover:text-red-400 hover:bg-red-500/10 transition-colors flex-shrink-0",title:"Remove contact",children:t.jsx(Y,{className:"w-4 h-4"})})]}),a{j&&a(j.hash),y(null)},onCancel:()=>y(null)})]})}},Symbol.toStringTag,{value:"Module"}));export{ne as C,I as G,W as M,me as N,Y as T,ue as a}; diff --git a/frontend/dist/assets/ContactsMapMapLibre-Cu_poy9C.js b/frontend/dist/assets/ContactsMapMapLibre-Cu_poy9C.js new file mode 100644 index 00000000..26aaf83c --- /dev/null +++ b/frontend/dist/assets/ContactsMapMapLibre-Cu_poy9C.js @@ -0,0 +1 @@ +var e,t,n=Object.defineProperty,s=(e,t,s)=>((e,t,s)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);import{c as r,j as i,I as o,X as a,_ as l,a2 as c,ag as u,ah as h,f as d,ai as f}from"./index-CdRF8vVQ.js";import{b as p,g,c as m,r as _}from"./recharts-bmHCCfxU.js";import{u as y,a as b,P as v,S as x,L as w,M as E,N as T,b as S}from"./maplibre-gl-B8VKi8hi.js";import{G as A,N as R,T as C,M as P,C as k}from"./Contacts-CXyTpkLI.js";import{a as I,C as M}from"./HashBadge-NQ19jVvM.js";import{L}from"./loader-circle-BGRieeTW.js";import{I as N}from"./info-lO6hs_0s.js";import{H as O}from"./house-529B6MyG.js";import{R as F}from"./refresh-cw-BYGR8_G5.js";import{N as D}from"./trending-up-Bn6V5R3a.js";import{M as B}from"./map-BceOJy6E.js";import"./maplibre-gl-CFO9X1Ek.js";import"./SignalIndicator-PFR99EHr.js";import"./triangle-alert-CS670Iqt.js";import"./zap-CWYA_VUV.js";import"./activity-XYItBmUY.js";import"./PageLayout-CUN38fny.js";import"./users-wZVlsBad.js";const U=r("car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]),j=r("chart-no-axes-column",[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]]),G=r("chevrons-left-right-ellipsis",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"m17 7 5 5-5 5",key:"1xlxn0"}],["path",{d:"m7 7-5 5 5 5",key:"19njba"}],["path",{d:"M8 12h.01",key:"czm47f"}]]),V=r("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),z=r("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),W=r("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]),H=r("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),$=r("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),X=r("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),q=r("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),Y=r("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]);function K(e,t){const n=Math.max(5,Math.min(e,300)),s=Math.log(5),r=Math.log(300);return 1+(Math.log(n)-s)/(r-s)*5}const Z="#4338CA";function Q({label:e,icon:t,status:n,detail:s}){return i.jsxs("div",{className:m("flex items-center gap-3 py-3 px-4 rounded-xl transition-all duration-300","active"===n&&"bg-[#4338CA]/10","complete"===n&&"bg-accent-success/10","pending"===n&&"opacity-40"),children:[i.jsx("div",{className:m("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300","active"===n&&"bg-[#4338CA]/20","complete"===n&&"bg-accent-success/20","pending"===n&&"bg-white/5"),children:"complete"===n?i.jsx(I,{className:"w-4 h-4 text-accent-success"}):"active"===n?i.jsx(L,{className:"w-4 h-4 animate-spin",style:{color:Z}}):i.jsx("span",{className:"text-text-muted",children:t})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:m("text-sm font-medium transition-colors","active"===n&&"text-[#4338CA]","complete"===n&&"text-accent-success","pending"===n&&"text-text-muted"),children:e}),s&&"pending"!==n&&i.jsx("div",{className:"text-xs text-text-muted mt-0.5 truncate",children:s})]})]})}const J=p.memo(function({isOpen:e,currentStep:t,packetCount:n,onClose:s}){if(p.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&s&&s()};window.addEventListener("keydown",t);const n=document.body.style.overflow,r=document.body.style.position,i=document.body.style.width,o=document.body.style.top,a=window.scrollY;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${a}px`,()=>{window.removeEventListener("keydown",t),document.body.style.overflow=n,document.body.style.position=r,document.body.style.width=i,document.body.style.top=o,window.scrollTo(0,a)}},[e,s]),!e)return null;const r="complete"===t,o=e=>{const n=["fetching","analyzing","building","complete"],s=n.indexOf(t),r=n.indexOf(e);return r0?`${n.toLocaleString()} packets`:"Loading database..."}),i.jsx(Q,{label:"Analyzing Database",icon:i.jsx(z,{className:"w-4 h-4"}),status:o("analyzing"),detail:"Processing packet paths"}),i.jsx(Q,{label:"Building Topology",icon:i.jsx(A,{className:"w-4 h-4"}),status:o("building"),detail:"Computing mesh edges"})]}),i.jsx("p",{className:"text-xs text-text-muted text-center mt-5",children:"This may take a few seconds..."})]})})]}),document.body)}),ee="#4338CA",te="#FBBF24",ne="#6366F1",se="#F97316",re="#F59E0B",ie="#FBBF24",oe="#4B5563",ae="#6B7280",le="#374151",ce="#5EEAD4",ue="#6366F1",he="#9CA3AF",de="#6B7280",fe="#FBBF24",pe=2e3;function ge({text:e}){return i.jsxs("span",{className:"group relative cursor-help",children:[i.jsx(N,{className:"w-3 h-3 text-text-muted"}),i.jsx("div",{className:"absolute bottom-full left-0 mb-1 hidden group-hover:block w-44 p-2 text-[10px] leading-tight rounded-lg z-10",style:{background:"rgba(20, 20, 22, 0.98)",border:"1px solid rgba(140, 160, 200, 0.3)"},children:e})]})}function me(e){const t=new Date(1e3*e);return`${(t.getMonth()+1).toString().padStart(2,"0")}/${t.getDate().toString().padStart(2,"0")}`}function _e({hash:e,hashPrefix:t,name:n,isHub:s,isZeroHop:r,isMobile:a,isRoomServer:l,isStale:c,lastSeenTimestamp:u,centrality:h,affinity:d,meanSnr:f,meanRssi:g,neighbor:m,onRemove:_,txDelayRec:y}){const[b,v]=p.useState(!1),x=r?"Direct":(null==d?void 0:d.typicalHopPosition)?`${d.typicalHopPosition}-hop`:null,w=[{label:"Packets",value:(null==d?void 0:d.frequency)||0},{label:"Adverts",value:m.advert_count||0}];r&&void 0!==f&&w.push({label:"SNR",value:`${f.toFixed(1)} dB`}),r&&void 0!==g&&w.push({label:"RSSI",value:`${Math.round(g)} dBm`});const E=y&&!y.insufficientData,T={hub:{bg:"bg-amber-500/20",text:"text-amber-400",title:"Hub: High-connectivity node (4+ neighbors) that bridges many paths"},backbone:{bg:"bg-purple-500/20",text:"text-purple-400",title:"Backbone: Critical relay with 4+ neighbors and high traffic"},relay:{bg:"bg-cyan-500/20",text:"text-cyan-400",title:"Relay: Standard forwarding node with symmetric traffic"},edge:{bg:"bg-gray-500/20",text:"text-gray-400",title:"Edge: Peripheral node with few connections"}},S={high:{bg:"bg-green-500/20",text:"text-green-400",title:"1000+ packets observed"},medium:{bg:"bg-amber-500/20",text:"text-amber-400",title:"500-999 packets observed"},low:{bg:"bg-red-500/20",text:"text-red-400",title:"100-499 packets observed"},insufficient:{bg:"bg-gray-500/20",text:"text-gray-400",title:"Insufficient data for analysis"}};return i.jsxs("div",{className:"w-[220px] pr-3",children:[i.jsx("div",{className:"text-[14px] font-semibold text-text-primary leading-snug truncate mb-0.5",children:n}),i.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[i.jsx("code",{className:"font-mono text-[10px] text-text-muted/70 bg-white/5 px-1 py-px rounded",children:t}),i.jsx("button",{onClick:()=>{navigator.clipboard.writeText(e),v(!0),setTimeout(()=>v(!1),1500)},className:"p-0.5 hover:bg-white/10 rounded transition-colors",title:"Copy full hash",children:b?i.jsx(I,{className:"w-2.5 h-2.5 text-accent-success"}):i.jsx(M,{className:"w-2.5 h-2.5 text-text-muted/50"})}),s&&i.jsx("span",{className:"px-1 py-px text-[8px] font-bold uppercase rounded",style:{backgroundColor:"#FBBF24",color:"#000"},children:"Hub"}),x&&i.jsx("span",{className:"px-1 py-px text-[8px] font-bold uppercase rounded",style:{backgroundColor:r?ie:"rgba(255,255,255,0.08)",color:r?"#000":"rgba(255,255,255,0.5)"},children:x}),a&&i.jsx("span",{className:"px-1 py-px text-[8px] font-bold uppercase rounded bg-orange-500/25 text-orange-300",children:"Mobile"}),m.is_repeater&&i.jsx("span",{className:"px-1 py-px text-[8px] font-bold uppercase rounded bg-cyan-500/20 text-cyan-400",children:"Rptr"}),l&&i.jsx("span",{className:"px-1 py-px text-[8px] font-bold uppercase rounded bg-amber-500/25 text-amber-400",children:"Room"}),c&&u&&i.jsxs("span",{className:"px-1 py-px text-[8px] font-medium rounded bg-gray-500/30 text-gray-300",title:"Neighbor not heard in 7+ days",children:["Idle ",me(u)]})]}),i.jsxs("div",{className:"text-[10px] text-text-muted/60 mb-2 leading-tight",children:[i.jsx("span",{children:o(m.last_seen)}),(null==d?void 0:d.distanceMeters)&&i.jsxs("span",{className:"font-medium text-text-muted/80",children:[" · ",(A=d.distanceMeters,null===A?"—":A<1e3?`${Math.round(A)}m`:`${(A/1e3).toFixed(1)}km`)]}),m.latitude&&m.longitude&&0!==m.latitude&&0!==m.longitude&&i.jsxs("span",{className:"font-mono text-[9px]",children:[" · ",m.latitude.toFixed(4),", ",m.longitude.toFixed(4)]})]}),i.jsx("div",{className:"mb-2",children:i.jsx(R,{nodeHash:e,width:"100%",height:28,showArea:!0,showTooltip:!0})}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-[11px] mb-2",children:[w.map((e,t)=>i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-text-muted/50",children:e.label}),i.jsx("span",{className:"font-semibold tabular-nums "+("highlight"in e&&e.highlight?"text-amber-400":""),children:e.value})]},t)),E&&y.networkRole&&i.jsx(i.Fragment,{children:i.jsxs("div",{className:"flex items-center justify-between col-span-2 mt-1 pt-1 border-t border-white/5",children:[i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"text-text-muted/50",children:"Role"}),i.jsx("span",{className:`px-1.5 py-px text-[8px] font-bold uppercase rounded ${T[y.networkRole].bg} ${T[y.networkRole].text}`,title:T[y.networkRole].title,children:y.networkRole})]}),y.dataConfidence&&i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"text-text-muted/50",children:"Data"}),i.jsx("span",{className:`px-1.5 py-px text-[8px] font-bold uppercase rounded ${S[y.dataConfidence].bg} ${S[y.dataConfidence].text}`,title:S[y.dataConfidence].title,children:y.dataConfidence})]})]})})]}),(E||_)&&i.jsxs("div",{className:"pt-1.5 border-t border-white/5",children:[E&&i.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[i.jsx("span",{className:"text-text-muted/50",children:"TX Delay"}),i.jsxs("span",{className:"font-semibold tabular-nums text-amber-400",children:["×",(y.floodFactor??y.txDelayFactor).toFixed(1)]}),i.jsx("span",{className:"text-text-muted/30",children:"flood"}),i.jsxs("span",{className:"font-semibold tabular-nums text-amber-400",children:["×",(y.directFactor??y.directTxDelayFactor).toFixed(1)]}),i.jsx("span",{className:"text-text-muted/30",children:"direct"})]}),_&&i.jsx("div",{className:"flex justify-end "+(E?"mt-1.5":""),children:i.jsx("button",{onClick:_,className:"flex items-center gap-0.5 p-1 text-[10px] text-text-muted/30 hover:text-red-400 hover:bg-red-500/10 rounded transition-colors",title:"Remove from contacts",children:i.jsx(C,{className:"w-3 h-3"})})})]})]});var A}function ye({showTopology:e,validatedPolylineCount:t,filteredNeighborCount:n,hasLocalNode:s,meshTopology:r,zeroHopNeighbors:o,neighborsWithLocation:a}){return i.jsxs("div",{className:"absolute bottom-4 left-4 z-[600] text-xs",style:{background:"rgba(20, 20, 22, 0.95)",borderRadius:"0.75rem",padding:"0.625rem",border:"1px solid rgba(140, 160, 200, 0.2)",maxWidth:"150px"},children:[i.jsxs("div",{className:"text-text-secondary font-medium mb-1.5 flex items-center gap-1",children:["Nodes",i.jsx(ge,{text:"Node type shown by shape/color. Yellow outer ring = direct RF neighbor."})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"12px",height:"12px",background:"transparent",border:`4px solid ${ee}`,boxSizing:"border-box"}}),i.jsx("span",{className:"text-text-muted",children:"Node"}),i.jsx(ge,{text:"Standard mesh node. Can be a repeater, client, or companion device."})]}),r.gatewayNodes.length>0&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"12px",height:"12px",backgroundColor:ee}}),i.jsx("span",{className:"text-text-muted",children:"Gateway"}),i.jsx(ge,{text:"Significant traffic forwarder (7-10% of last-hop traffic). Gateways relay substantial traffic to the local node."})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"12px",height:"12px",backgroundColor:ne}}),i.jsx("span",{className:"text-text-muted",children:"Hub"}),i.jsx(ge,{text:"Network hub (≥10% of last-hop traffic). Hubs are central to mesh traffic flow and may use higher TX delays."})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(O,{className:"w-3 h-3 flex-shrink-0",style:{color:te},strokeWidth:2.5}),i.jsx("span",{className:"text-text-muted",children:"Local"}),i.jsx(ge,{text:"Your repeater. This is the node running pyMC_Repeater that you're connected to."})]}),(l=a,l.some(([,e])=>{var t;const n=null==(t=e.contact_type)?void 0:t.toLowerCase();return"room server"===n||"room_server"===n||"room"===n||"server"===n})&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(P,{className:"w-3 h-3 flex-shrink-0",style:{color:re},strokeWidth:2.5}),i.jsx("span",{className:"text-text-muted",children:"Room"}),i.jsx(ge,{text:"Room Server identity. Hosts a chat room that clients can sync messages with."})]})),r.mobileNodes.length>0&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"12px",height:"12px",background:"transparent",border:`4px solid ${se}`,boxSizing:"border-box"}}),i.jsx("span",{className:"text-text-muted",children:"Mobile"}),i.jsx(ge,{text:"Volatile node that frequently appears/disappears from paths. Likely a portable or vehicle-mounted device."})]}),o.size>0&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsxs("div",{className:"relative flex-shrink-0",style:{width:"14px",height:"14px"},children:[i.jsx("div",{className:"absolute rounded-full",style:{top:"-2px",left:"-2px",width:"18px",height:"18px",background:"transparent",border:`2px solid ${ie}`,boxSizing:"border-box",opacity:.85}}),i.jsx("div",{className:"absolute rounded-full",style:{top:"1px",left:"1px",width:"12px",height:"12px",background:"transparent",border:`4px solid ${ee}`,boxSizing:"border-box"}})]}),i.jsx("span",{className:"text-text-muted",children:"Neighbor"}),i.jsx(ge,{text:"Zero-hop direct RF contact. We receive their ADVERTs directly without any relay hops."})]})]}),o.size>0&&i.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-white/10",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"flex-shrink-0",style:{width:"14px",height:"2px",backgroundImage:`repeating-linear-gradient(90deg, ${de} 0, ${de} 3px, transparent 3px, transparent 5px)`,borderRadius:"1px"}}),i.jsx("span",{className:"text-text-muted",children:"Neighbor"}),i.jsx(ge,{text:"Dashed gray → yellow on hover. Direct RF contact with local."})]})}),e&&t>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"text-text-secondary font-medium mt-2 pt-2 border-t border-white/10 mb-1 flex items-center gap-1",children:["Topology",i.jsx(ge,{text:"Links with 5+ validations. Thickness = relative strength."})]}),i.jsxs("div",{className:"flex flex-col gap-0.5 text-text-muted",children:[i.jsxs("div",{className:"flex justify-between tabular-nums",children:[i.jsx("span",{children:"Nodes"}),i.jsx("span",{className:"text-text-secondary",children:n+(s?1:0)})]}),i.jsxs("div",{className:"flex justify-between tabular-nums",children:[i.jsx("span",{children:"Links"}),i.jsx("span",{className:"text-text-secondary",children:t})]}),r.hubNodes.length>0&&i.jsxs("div",{className:"flex justify-between tabular-nums",children:[i.jsx("span",{children:"Hubs"}),i.jsx("span",{style:{color:ne},children:r.hubNodes.length})]})]}),i.jsxs("div",{className:"flex flex-col gap-1 mt-1.5 pt-1.5 border-t border-white/10",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"flex-shrink-0",style:{width:"14px",height:"3px",backgroundColor:oe,borderRadius:"1px"}}),i.jsx("span",{className:"text-text-muted",children:"Link"}),i.jsx(ge,{text:"Gray at rest. Hover to reveal type (teal=direct, indigo=loop)."})]}),r.loops.length>0&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsxs("div",{className:"flex-shrink-0 flex flex-col gap-0.5",style:{width:"14px"},children:[i.jsx("div",{style:{height:"2px",backgroundColor:oe,borderRadius:"1px"}}),i.jsx("div",{style:{height:"2px",backgroundColor:oe,borderRadius:"1px"}})]}),i.jsx("span",{className:"text-text-muted",children:"Redundant"})]})]}),r.loops.length>0&&i.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-white/10",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(F,{className:"w-3 h-3 flex-shrink-0",style:{color:ue}}),i.jsxs("div",{className:"flex flex-col",children:[i.jsxs("span",{style:{color:ue},className:"font-medium",children:[r.loops.length," ",1===r.loops.length?"Loop":"Loops"]}),i.jsx("span",{className:"text-text-muted text-[10px] leading-tight",children:"Redundant paths"})]})]})})]})]});var l}const be={background:"rgba(20, 20, 22, 0.95)",borderRadius:"0.75rem",border:"1px solid rgba(140, 160, 200, 0.2)"},ve=(e,t=.4)=>({background:e,borderRadius:"0.75rem",border:`1px solid ${e.replace(/[\d.]+\)$/,`${t})`)}`});function xe({isDeepLoading:e,showDeepAnalysisModal:t,onDeepAnalysis:n,showTopology:s,onToggleTopology:r,hasValidatedPolylines:o,soloHubs:a,onToggleSoloHubs:l,hasHubNodes:c,soloDirect:u,onToggleSoloDirect:h,hasZeroHopNeighbors:d,isFullscreen:f,onToggleFullscreen:p}){return i.jsxs("div",{className:"absolute top-4 right-4 z-[600] flex gap-2",children:[i.jsxs("button",{onClick:n,disabled:e||t,className:"px-3 py-2 flex items-center gap-2 transition-colors hover:bg-white/10 disabled:opacity-50 disabled:cursor-not-allowed",style:be,title:"Deep Analysis - Load full packet history and rebuild topology",children:[i.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Deep Analysis"}),i.jsx(j,{className:"w-4 h-4 text-accent-primary"})]}),o&&i.jsx("button",{onClick:r,className:"p-2 transition-colors hover:bg-white/10",style:s?ve("rgba(74, 222, 128, 0.2)"):be,title:s?"Hide topology lines":"Show topology lines",children:s?i.jsx(A,{className:"w-4 h-4 text-green-400"}):i.jsx($,{className:"w-4 h-4 text-text-secondary"})}),c&&i.jsx("button",{onClick:l,className:"p-2 transition-colors hover:bg-white/10",style:a?{...be,background:"rgba(251, 191, 36, 0.25)",border:"1px solid rgba(251, 191, 36, 0.5)"}:be,title:a?"Show all nodes":"Solo hubs & connections",children:i.jsx(D,{className:"w-4 h-4 "+(a?"text-amber-400":"text-text-secondary")})}),d&&i.jsx("button",{onClick:h,className:"p-2 transition-colors hover:bg-white/10",style:u?{...be,background:"rgba(67, 56, 202, 0.35)",border:"1px solid rgba(67, 56, 202, 0.6)"}:be,title:u?"Show all nodes":"Solo direct (0-hop) nodes",children:i.jsx(G,{className:"w-4 h-4 "+(u?"text-indigo-400":"text-text-secondary")})}),i.jsx("button",{onClick:p,className:"p-2 transition-colors hover:bg-white/10",style:be,title:f?"Exit fullscreen":"Fullscreen",children:f?i.jsx(Y,{className:"w-4 h-4 text-text-secondary"}):i.jsx(q,{className:"w-4 h-4 text-text-secondary"})})]})}const we={background:"rgba(20, 20, 22, 0.95)",borderRadius:"0.75rem",border:"1px solid rgba(140, 160, 200, 0.2)"},Ee={background:"rgba(245, 158, 11, 0.25)",borderRadius:"0.75rem",border:"1px solid rgba(245, 158, 11, 0.5)"};function Te({isActive:e,onClick:t}){return i.jsx("div",{className:"absolute bottom-8 right-4 z-[600]",children:i.jsx("button",{onClick:t,className:"p-2 transition-colors hover:bg-white/10",style:e?Ee:we,title:e?"Configure wardriving coverage":"Show wardriving coverage",children:i.jsx(U,{className:"w-4 h-4 "+(e?"text-amber-400":"text-text-secondary")})})})}function Se({status:e,isLoading:t}){if(!t)return null;const n={idle:"",connecting:"Connecting to server...",loading:"Fetching coverage data...",processing:"Processing coverage points...",success:"",error:""}[e];return n?i.jsxs("div",{className:"flex items-center gap-3 p-4 bg-amber-500/10 border border-amber-500/30 rounded-xl",children:[i.jsx("div",{className:"relative",children:i.jsx(L,{className:"w-5 h-5 text-amber-400 animate-spin"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-sm text-amber-400 font-medium",children:n}),i.jsx("div",{className:"mt-2 h-1 bg-amber-500/20 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-amber-400 rounded-full transition-all duration-300",style:{width:"connecting"===e?"30%":"loading"===e?"60%":"90%"}})})]})]}):null}function Ae({isOpen:e,onClose:t,state:n,isLoading:s,onLoadCoverage:r,onClearCoverage:o,onToggleVisibility:l,onSetUrl:c}){const[u,h]=p.useState(n.url),d=p.useCallback(async()=>{await r(u)},[u,r]),f=p.useCallback(()=>{h(""),o()},[o]),g=p.useCallback(e=>{"Enter"!==e.key||e.shiftKey||s||(e.preventDefault(),d())},[d,s]),m=p.useCallback(e=>{const t=e.target.value;h(t),c(t)},[c]);if(!e)return null;const _=n.stats.coverageCount>0,y=u.trim().length>0&&!s;return i.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:s?void 0:t}),i.jsxs("div",{className:"relative bg-surface border border-border rounded-2xl shadow-2xl w-full max-w-md mx-4 overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 rounded-lg bg-amber-500/20",children:i.jsx(U,{className:"w-5 h-5 text-amber-400"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Wardriving Coverage"}),i.jsx("p",{className:"text-xs text-text-muted",children:"Overlay RF coverage heatmap"})]})]}),i.jsx("button",{onClick:t,disabled:s,className:"p-2 rounded-lg hover:bg-white/10 transition-colors disabled:opacity-50",children:i.jsx(a,{className:"w-5 h-5 text-text-secondary"})})]}),i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Coverage Server URL"}),i.jsx("input",{type:"url",value:u,onChange:m,onKeyDown:g,placeholder:"https://coverage.wcmesh.com",className:"w-full px-4 py-3 bg-black/30 border border-border rounded-xl text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500/50 transition-all disabled:opacity-50",disabled:s}),i.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:"Enter the base URL of a wardriving coverage server (e.g., coverage.wcmesh.com)"})]}),i.jsx(Se,{status:n.status,isLoading:s}),"error"===n.status&&n.error&&i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/30 rounded-xl",children:[i.jsx(V,{className:"w-5 h-5 text-red-400 flex-shrink-0 mt-0.5"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-red-400 font-medium",children:"Connection Failed"}),i.jsx("p",{className:"text-xs text-red-400/80 mt-0.5",children:n.error})]})]}),"success"===n.status&&_&&i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-green-500/10 border border-green-500/30 rounded-xl",children:[i.jsx(I,{className:"w-5 h-5 text-green-400 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-sm text-green-400 font-medium",children:"Data Loaded Successfully"}),i.jsxs("p",{className:"text-xs text-green-400/80 mt-0.5",children:[n.stats.coverageCount.toLocaleString()," coverage points • ",n.stats.repeaterCount.toLocaleString()," repeaters"]})]})]}),_&&!s&&"success"!==n.status&&i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-amber-500/10 border border-amber-500/30 rounded-xl",children:[i.jsx(B,{className:"w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-sm text-amber-400 font-medium",children:"Coverage Data Loaded"}),i.jsxs("p",{className:"text-xs text-amber-400/80 mt-0.5",children:[n.stats.coverageCount.toLocaleString()," points •",n.stats.lastUpdated&&` Last updated ${n.stats.lastUpdated.toLocaleTimeString()}`]})]})]})]}),i.jsxs("div",{className:"flex items-center justify-between gap-3 p-4 border-t border-border bg-black/20",children:[i.jsx("div",{className:"flex items-center gap-2",children:_&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:l,disabled:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-text-secondary hover:text-text-primary hover:bg-white/5 rounded-lg transition-colors disabled:opacity-50",title:n.isVisible?"Hide heatmap":"Show heatmap",children:n.isVisible?i.jsxs(i.Fragment,{children:[i.jsx($,{className:"w-3.5 h-3.5"})," Hide"]}):i.jsxs(i.Fragment,{children:[i.jsx(X,{className:"w-3.5 h-3.5"})," Show"]})}),i.jsxs("button",{onClick:f,disabled:s,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-red-400/80 hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-colors disabled:opacity-50",title:"Clear coverage data",children:[i.jsx(C,{className:"w-3.5 h-3.5"})," Clear"]})]})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:t,disabled:s,className:"px-4 py-2 text-sm font-medium text-text-secondary hover:bg-white/10 rounded-lg transition-colors disabled:opacity-50",children:_?"Done":"Cancel"}),i.jsx("button",{onClick:d,disabled:!y,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium bg-amber-500 hover:bg-amber-400 text-black rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:s?i.jsxs(i.Fragment,{children:[i.jsx(L,{className:"w-4 h-4 animate-spin"}),"Loading..."]}):_?i.jsxs(i.Fragment,{children:[i.jsx(W,{className:"w-4 h-4"}),"Refresh"]}):i.jsxs(i.Fragment,{children:[i.jsx(H,{className:"w-4 h-4"}),"Connect"]})})]})]})]})]})}function Re(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const Ce=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Pe="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Pe&&parseFloat(Pe[1]);const ke=globalThis,Ie=globalThis.process||{},Me=globalThis.navigator||{};function Le(e){var t,n;if("undefined"!=typeof window&&"renderer"===(null==(t=window.process)?void 0:t.type))return!0;if("undefined"!=typeof process&&Boolean(null==(n=process.versions)?void 0:n.electron))return!0;const s="undefined"!=typeof navigator&&navigator.userAgent;return Boolean(s&&s.indexOf("Electron")>=0)}function Ne(){return!("object"==typeof process&&"[object process]"===String(process)&&!(null==process?void 0:process.browser))||Le()}const Oe="4.1.0";class Fe{constructor(e,t,n="sessionStorage"){this.storage=function(e){try{const t=window[e],n="__storage_test__";return t.setItem(n,n),t.removeItem(n),t}catch(di){return null}}(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}var De,Be;function Ue(e){return"string"!=typeof e?e:(e=e.toUpperCase(),De[e]||De.WHITE)}function je(e,t){if(!e)throw new Error("Assertion failed")}function Ge(){var e,t,n;let s;if(Ne()&&ke.performance)s=null==(t=null==(e=null==ke?void 0:ke.performance)?void 0:e.now)?void 0:t.call(e);else if("hrtime"in Ie){const e=null==(n=null==Ie?void 0:Ie.hrtime)?void 0:n.call(Ie);s=1e3*e[0]+e[1]/1e6}else s=Date.now();return s}(Be=De||(De={}))[Be.BLACK=30]="BLACK",Be[Be.RED=31]="RED",Be[Be.GREEN=32]="GREEN",Be[Be.YELLOW=33]="YELLOW",Be[Be.BLUE=34]="BLUE",Be[Be.MAGENTA=35]="MAGENTA",Be[Be.CYAN=36]="CYAN",Be[Be.WHITE=37]="WHITE",Be[Be.BRIGHT_BLACK=90]="BRIGHT_BLACK",Be[Be.BRIGHT_RED=91]="BRIGHT_RED",Be[Be.BRIGHT_GREEN=92]="BRIGHT_GREEN",Be[Be.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",Be[Be.BRIGHT_BLUE=94]="BRIGHT_BLUE",Be[Be.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",Be[Be.BRIGHT_CYAN=96]="BRIGHT_CYAN",Be[Be.BRIGHT_WHITE=97]="BRIGHT_WHITE";const Ve={debug:Ne()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},ze={enabled:!0,level:0};function We(){}const He={},$e={once:!0};class Xe{constructor({id:e}={id:""}){this.VERSION=Oe,this._startTs=Ge(),this._deltaTs=Ge(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Fe(`__probe-${this.id}__`,ze),this.timeStamp(`${this.id} started`),function(e,t=["constructor"]){const n=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(n),r=e;for(const i of s){const n=r[i];"function"==typeof n&&(t.find(e=>i===e)||(r[i]=n.bind(e)))}}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Ge()-this._startTs).toPrecision(10))}getDelta(){return Number((Ge()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,Ve.warn,arguments,$e)}error(e){return this._getLogFunction(0,e,Ve.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,Ve.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Ve.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Ve.debug||Ve.info,arguments,$e)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||We,n&&[n],{tag:Ke(t)}):We}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||We)}group(e,t,n={collapsed:!1}){const s=Ye({logLevel:e,message:t,opts:n}),{collapsed:r}=n;return s.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||We)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=qe(e)}_getLogFunction(e,t,n,s,r){if(this._shouldLog(e)){r=Ye({logLevel:e,message:t,args:s,opts:r}),je(n=n||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Ge();const i=r.tag||r.message;if(r.once&&i){if(He[i])return We;He[i]=Ge()}return t=function(e,t,n){if("string"==typeof t){const o=n.time?function(e,t=8){const n=Math.max(t-e.length,0);return`${" ".repeat(n)}${e}`}(function(e){let t;return t=e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`,t}(n.total)):"";s=t=n.time?`${e}: ${o} ${t}`:`${e}: ${t}`,r=n.color,i=n.background,Ne||"string"!=typeof s||(r&&(s=`[${Ue(r)}m${s}`),i&&(s=`[${Ue(i)+10}m${s}`)),t=s}var s,r,i;return t}(this.id,r.message,r),n.bind(console,t,...r.args)}return We}}function qe(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return je(Number.isFinite(t)&&t>=0),t}function Ye(e){const{logLevel:t,message:n}=e;e.logLevel=qe(t);const s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==n;);switch(typeof t){case"string":case"function":void 0!==n&&s.unshift(n),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return je("string"===r||"object"===r),Object.assign(e,{args:s},e.opts)}function Ke(e){for(const t in e)for(const n in e[t])return n||"untitled";return"empty"}Xe.VERSION=Oe;const Ze="4.3.3",Qe=Ze[0]>="0"&&Ze[0]<="9"?`v${Ze}`:"",Je=function(){const e=new Xe({id:"loaders.gl"});return globalThis.loaders=globalThis.loaders||{},globalThis.loaders.log=e,globalThis.loaders.version=Qe,globalThis.probe=globalThis.probe||{},globalThis.probe.loaders=e,e}();function et(e,t){return tt(e||{},t)}function tt(e,t,n=0){if(n>3)return t;const s={...e};for(const[r,i]of Object.entries(t))i&&"object"==typeof i&&!Array.isArray(i)?s[r]=tt(s[r]||{},t[r],n+1):s[r]=t[r];return s}var nt;function st(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(null==(nt=globalThis._loadersgl_)?void 0:nt.version)||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version;const rt="object"!=typeof process||"[object process]"!==String(process)||process.browser,it="undefined"!=typeof window&&void 0!==window.orientation,ot="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);ot&&parseFloat(ot[1]);class at{constructor(e,t){s(this,"name"),s(this,"workerThread"),s(this,"isRunning",!0),s(this,"result"),s(this,"_resolve",()=>{}),s(this,"_reject",()=>{}),this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){st(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){st(this.isRunning),this.isRunning=!1,this._reject(e)}}class lt{terminate(){}}const ct=new Map;function ut(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function ht(e,t=!0,n){const s=n||new Set;if(e)if(dt(e))s.add(e);else if(dt(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const r in e)ht(e[r],t,s);return void 0===n?Array.from(s):[]}function dt(e){return!!e&&(e instanceof ArrayBuffer||"undefined"!=typeof MessagePort&&e instanceof MessagePort||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)}const ft=()=>{};class pt{constructor(e){s(this,"name"),s(this,"source"),s(this,"url"),s(this,"terminated",!1),s(this,"worker"),s(this,"onMessage"),s(this,"onError"),s(this,"_loadableURL","");const{name:t,source:n,url:r}=e;st(n||r),this.name=t,this.source=n,this.url=r,this.onMessage=ft,this.onError=e=>{},this.worker=rt?this._createBrowserWorker():this._createNodeWorker()}static isSupported(){return"undefined"!=typeof Worker&&rt||void 0!==lt&&!rt}destroy(){this.onMessage=ft,this.onError=ft,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||ht(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=function(e){st(e.source&&!e.url||!e.source&&e.url);let t=ct.get(e.source||e.url);return t||(e.url&&(t=(n=e.url).startsWith("http")?ut(`try {\n importScripts('${n}');\n} catch (error) {\n console.error(error);\n throw error;\n}`):n,ct.set(e.url,t)),e.source&&(t=ut(e.source),ct.set(e.source,t))),st(t),t;var n}({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>{},e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new lt(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new lt(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}class gt{constructor(e){s(this,"name","unnamed"),s(this,"source"),s(this,"url"),s(this,"maxConcurrency",1),s(this,"maxMobileConcurrency",1),s(this,"onDebug",()=>{}),s(this,"reuseWorkers",!0),s(this,"props",{}),s(this,"jobQueue",[]),s(this,"idleQueue",[]),s(this,"count",0),s(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}static isSupported(){return pt.isSupported()}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,n)=>e.done(n),n=(e,t)=>e.error(t)){const s=new Promise(s=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:s}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const s=new at(t.name,e);e.onMessage=e=>t.onMessage(s,e.type,e.payload),e.onError=e=>t.onError(s,e),t.onStart(s);try{await s.result}catch(n){}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!rt||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},_t=class e{constructor(e){s(this,"props"),s(this,"workerPools",new Map),this.props={...mt},this.setProps(e),this.workerPools=new Map}static isSupported(){return pt.isSupported()}static getWorkerFarm(t={}){return e._workerFarm=e._workerFarm||new e({}),e._workerFarm.setProps(t),e._workerFarm}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:n,url:s}=e;let r=this.workerPools.get(t);return r||(r=new gt({name:t,source:n,url:s}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};s(_t,"_workerFarm");let yt=_t;async function bt(e,t,n,s,r){const i=e.id,o=function(e,t={}){const n=t[e.id]||{},s=rt?`${e.id}-worker.js`:`${e.id}-worker-node.js`;let r=n.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r=rt?`modules/${e.module}/dist/${s}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!r){let t=e.version;"latest"===t&&(t="latest");const n=t?`@${t}`:"";r=`https://unpkg.com/@loaders.gl/${e.module}${n}/dist/${s}`}return st(r),r}(e,n),a=yt.getWorkerFarm(n).getWorkerPool({name:i,url:o});n=JSON.parse(JSON.stringify(n)),s=JSON.parse(JSON.stringify(s||{}));const l=await a.startJob("process-on-worker",vt.bind(null,r));l.postMessage("process",{input:t,options:n,context:s});const c=await l.result;return await c.result}async function vt(e,t,n,s){switch(n){case"done":t.done(s);break;case"error":t.error(new Error(s.error));break;case"process":const{id:n,input:i,options:o}=s;try{const s=await e(i,o);t.postMessage("done",{id:n,result:s})}catch(r){const e=r instanceof Error?r.message:"unknown error";t.postMessage("error",{id:n,error:e})}}}function xt(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}class wt{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=xt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(xt()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class Et{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){const{name:t,type:n}=e;let s=this.stats[t];return s||(s=e instanceof wt?e:new wt(t,n),this.stats[t]=s),s}}const Tt={};function St(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return e;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function At(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}const Rt=e=>"function"==typeof e,Ct=e=>null!==e&&"object"==typeof e,Pt=e=>Ct(e)&&e.constructor==={}.constructor,kt=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,It=e=>"undefined"!=typeof Blob&&e instanceof Blob,Mt=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||Ct(e)&&Rt(e.tee)&&Rt(e.cancel)&&Rt(e.getReader))(e)||(e=>Ct(e)&&Rt(e.read)&&Rt(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e);class Lt extends Error{constructor(e,t){super(e),s(this,"reason"),s(this,"url"),s(this,"response"),this.reason=t.reason,this.url=t.url,this.response=t.response}}const Nt=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Ot=/^([-\w.]+\/[-\w.+]+)/;function Ft(e,t){return e.toLowerCase()===t.toLowerCase()}function Dt(e){const t=Nt.exec(e);return t?t[1]:""}const Bt=/\?.*/;function Ut(e){return e.replace(Bt,"")}function jt(e){return kt(e)?e.url:It(e)?e.name||"":"string"==typeof e?e:""}function Gt(e){if(kt(e)){const t=e,n=t.headers.get("content-type")||"",s=Ut(t.url);return function(e){const t=Ot.exec(e);return t?t[1]:e}(n)||Dt(s)}return It(e)?e.type||"":"string"==typeof e?Dt(e):""}async function Vt(e){if(kt(e))return e;const t={},n=function(e){return kt(e)?e.headers["content-length"]||-1:It(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);n>=0&&(t["content-length"]=String(n));const s=jt(e),r=Gt(e);r&&(t["content-type"]=r);const i=await async function(e){if("string"==typeof e)return`data:,${e.slice(0,5)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const n=new FileReader;n.onload=t=>{var n;return e(null==(n=null==t?void 0:t.target)?void 0:n.result)},n.readAsDataURL(t)})}return e instanceof ArrayBuffer?`data:base64,${function(e){let t="";const n=new Uint8Array(e);for(let s=0;s{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const $t={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){s(this,"console"),this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Ce,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Xt={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function qt(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function Yt(){const e=qt();return e.globalOptions=e.globalOptions||{...$t},e.globalOptions}function Kt(e,t,n,s,r){const i=t||"Top level",o=t?`${t}.`:"";for(const a in e){const l=!t&&Ct(e[a]);if(!(a in n)&&("baseUri"!==a||t)&&("workerUrl"!==a||!t))if(a in s)Wt.warn(`${i} loader option '${o}${a}' no longer supported, use '${s[a]}'`)();else if(!l){const e=Zt(a,r);Wt.warn(`${i} loader option '${o}${a}' not recognized. ${e}`)()}}}function Zt(e,t){const n=e.toLowerCase();let s="";for(const r of t)for(const t in r.options){if(e===t)return`Did you mean '${r.id}.${t}'?`;const i=t.toLowerCase();(n.startsWith(i)||i.startsWith(n))&&(s=s||`Did you mean '${r.id}.${t}'?`)}return s}function Qt(e,t){for(const n in t)if(n in t){const s=t[n];Pt(s)&&Pt(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function Jt(e){return!!e&&(Array.isArray(e)&&(e=e[0]),Array.isArray(null==e?void 0:e.extensions))}function en(e){let t;return Re(e,"null loader"),Re(Jt(e),"invalid loader"),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),((null==e?void 0:e.parseTextSync)||(null==e?void 0:e.parseText))&&(e.text=!0),e.text||(e.binary=!0),e}const tn=()=>{const e=qt();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry},nn=/\.([^.]+)$/;function sn(e,t=[],n,s){if(!rn(e))return null;if(t&&!Array.isArray(t))return en(t);let r=[];t&&(r=r.concat(t)),(null==n?void 0:n.ignoreRegisteredLoaders)||r.push(...tn()),function(e){for(const t of e)en(t)}(r);const i=function(e,t,n,s){const r=jt(e),i=Gt(e),o=Ut(r)||(null==s?void 0:s.url);let a=null,l="";return(null==n?void 0:n.mimeType)&&(a=an(t,null==n?void 0:n.mimeType),l=`match forced by supplied MIME type ${null==n?void 0:n.mimeType}`),a=a||function(e,t){const n=t&&nn.exec(t),s=n&&n[1];return s?function(e,t){t=t.toLowerCase();for(const n of e)for(const e of n.extensions)if(e.toLowerCase()===t)return n;return null}(e,s):null}(t,o),l=l||(a?`matched url ${o}`:""),a=a||an(t,i),l=l||(a?`matched MIME type ${i}`:""),a=a||function(e,t){if(!t)return null;for(const n of e)if("string"==typeof t){if(ln(t,n))return n}else if(ArrayBuffer.isView(t)){if(cn(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer&&cn(t,0,n))return n;return null}(t,e),l=l||(a?`matched initial data ${un(e)}`:""),(null==n?void 0:n.fallbackMimeType)&&(a=a||an(t,null==n?void 0:n.fallbackMimeType),l=l||(a?`matched fallback MIME type ${i}`:"")),l&&Je.log(1,`selectLoader selected ${null==a?void 0:a.name}: ${l}.`),a}(e,r,n,s);if(!i&&!(null==n?void 0:n.nothrow))throw new Error(on(e));return i}function rn(e){return!(e instanceof Response&&204===e.status)}function on(e){const t=jt(e),n=Gt(e);let s="No valid loader found (";s+=t?`${At(t)}, `:"no url provided, ",s+=`MIME type: ${n?`"${n}"`:"not provided"}, `;const r=e?un(e):"";return s+=r?` first bytes: "${r}"`:"first bytes: not available",s+=")",s}function an(e,t){var n;for(const s of e){if(null==(n=s.mimeTypes)?void 0:n.some(e=>Ft(t,e)))return s;if(Ft(t,`application/x.${s.id}`))return s}return null}function ln(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function cn(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(n=>function(e,t,n,s){if(s instanceof ArrayBuffer)return function(e,t,n){if(n=n||e.byteLength,e.byteLength100?`${s.slice(0,100)}...`:s;const r={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");r.reason=!e.bodyUsed&&(null==t?void 0:t.includes("application/json"))?await e.json():await e.text()}catch(t){}return new Lt(s,r)}(e);throw t}}(n),t.binary?await n.arrayBuffer():await n.text()}if(Mt(e)&&(e=function(e,t){if("string"==typeof e)return function*(e,t){const n=(null==t?void 0:t.chunkSize)||262144;let s=0;const r=new TextEncoder;for(;se&&"function"==typeof e[Symbol.asyncIterator])(e))return async function(e){const t=[];for await(const n of e)t.push(n);return function(...e){return function(e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),n=t.reduce((e,t)=>e+t.byteLength,0),s=new Uint8Array(n);let r=0;for(const i of t)s.set(i,r),r+=i.byteLength;return s.buffer}(e)}(...t)}(e);var r;throw new Error(pn)}function mn(e,t){const n=Yt(),s=e||n;return"function"==typeof s.fetch?s.fetch:Ct(s.fetch)?e=>zt(e,s.fetch):(null==t?void 0:t.fetch)?null==t?void 0:t.fetch:zt}async function _n(e,t,n,s){!t||Array.isArray(t)||Jt(t)||(s=void 0,n=t,t=void 0),n=n||{};const r=jt(e=await e),i=function(e,t){if(e&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];n=n?[...n,...e]:e}return n&&n.length?n:void 0}(t,s),o=await async function(e,t=[],n,s){if(!rn(e))return null;let r=sn(e,t,{...n,nothrow:!0},s);if(r)return r;if(It(e)&&(r=sn(e=await e.slice(0,10).arrayBuffer(),t,n,s)),!r&&!(null==n?void 0:n.nothrow))throw new Error(on(e));return r}(e,i,n);return o?(s=function(e,t,n){if(n)return n;const s={fetch:mn(t,e),...e};if(s.url){const e=Ut(s.url);s.baseUrl=e,s.queryString=function(e){const t=e.match(Bt);return t&&t[0]}(s.url),s.filename=At(e),s.baseUrl=function(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}(e)}return Array.isArray(s.loaders)||(s.loaders=null),s}({url:r,_parse:_n,loaders:i},n=function(e,t,n,s){return n=n||[],function(e,t){Kt(e,null,$t,Xt,t);for(const n of t){const s=e&&e[n.id]||{},r=n.options&&n.options[n.id]||{},i=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};Kt(s,n.id,r,i,t)}}(e,n=Array.isArray(n)?n:[n]),function(e,t,n){const s={...e.options||{}};return function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)}(s,n),null===s.log&&(s.log=new Ht),Qt(s,Yt()),Qt(s,t),s}(t,e,s)}(n,o,i,r),s||null),await async function(e,t,n,s){if(function(e){st(e,"no worker provided");e.version}(e),n=et(e.options,n),kt(t)){const e=t,{ok:n,redirected:r,status:i,statusText:o,type:a,url:l}=e,c=Object.fromEntries(e.headers.entries());s.response={headers:c,ok:n,redirected:r,status:i,statusText:o,type:a,url:l}}t=await gn(t,e,n);const r=e;if(r.parseTextSync&&"string"==typeof t)return r.parseTextSync(t,n,s);if(function(e,t){return!!yt.isSupported()&&!(!rt&&!(null==t?void 0:t._nodeWorkers))&&e.worker&&(null==t?void 0:t.worker)}(e,n))return await bt(e,t,n,s,_n);if(r.parseText&&"string"==typeof t)return await r.parseText(t,n,s);if(r.parse)return await r.parse(t,n,s);throw st(!r.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(o,e,n,s)):null}async function yn(e,t,n,s){let r,i;Array.isArray(t)||Jt(t)?(r=t,i=n):(r=[],i=t);const o=mn(i);let a=e;return"string"==typeof e&&(a=await o(e)),It(e)&&(a=await o(e)),Array.isArray(r),await _n(a,r,i)}const bn=null==(e=globalThis.loaders)?void 0:e.parseImageNode,vn="undefined"!=typeof Image,xn="undefined"!=typeof ImageBitmap,wn=Boolean(bn),En=!!Ce||wn;const Tn=/^data:image\/svg\+xml/,Sn=/\.svg((\?|#).*)?$/;function An(e){return e&&(Tn.test(e)||Sn.test(e))}function Rn(e,t){if(An(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Cn(e,t,n){const s=function(e,t){if(An(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(n){throw new Error(n.message)}return`data:image/svg+xml;base64,${btoa(t)}`}return Rn(e,t)}(e,n),r=self.URL||self.webkitURL,i="string"!=typeof s&&r.createObjectURL(s);try{return await async function(e,t){const n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((e,t)=>{try{n.onload=()=>e(n),n.onerror=e=>{const n=e instanceof Error?e.message:"error";t(new Error(n))}}catch(s){t(s)}})}(i||s,t)}finally{i&&r.revokeObjectURL(i)}}const Pn={};let kn=!0;const In=!1,Mn=!0;function Ln(e){const t=Nn(e);return function(e){const t=Nn(e);return t.byteLength>=24&&2303741511===t.getUint32(0,In)?{mimeType:"image/png",width:t.getUint32(16,In),height:t.getUint32(20,In)}:null}(t)||function(e){const t=Nn(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,In)&&255===t.getUint8(2)))return null;const{tableMarkers:n,sofMarkers:s}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}();let r=2;for(;r+9=10&&1195984440===t.getUint32(0,In)?{mimeType:"image/gif",width:t.getUint16(6,Mn),height:t.getUint16(8,Mn)}:null}(t)||function(e){const t=Nn(e);return t.byteLength>=14&&16973===t.getUint16(0,In)&&t.getUint32(2,Mn)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,Mn),height:t.getUint32(22,Mn)}:null}(t)||function(e){const t=function(e){return function(e,t,n=0){const s=(r="ftyp",[...r].map(e=>e.charCodeAt(0)));var r;for(let i=0;iBoolean(Ln(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},Fn=new Xe({id:"deck"});let Dn={};function Bn(e){Dn=e}function Un(e,t,n,s){Fn.level>0&&Dn[e]&&Dn[e].call(null,t,n,s)}const jn={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:function(e){const t=e[0],n=e[e.length-1];return"{"===t&&"}"===n||"["===t&&"]"===n},parseTextSync:JSON.parse},Gn=function(){const e="9.2.5",t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw new Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(Fn.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:Fn,_registerLoggers:Bn},function(e){const t=tn();e=Array.isArray(e)?e:[e];for(const n of e){const e=en(n);t.find(t=>e===t)||t.unshift(e)}}([jn,[On,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}();function Vn(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}const zn={number:{type:"number",validate:(e,t)=>Number.isFinite(e)&&"object"==typeof t&&(void 0===t.max||e<=t.max)&&(void 0===t.min||e>=t.min)},array:{type:"array",validate:(e,t)=>Array.isArray(e)||ArrayBuffer.isView(e)}};function Wn(e){let t=Hn(e);if("object"!==t)return{value:e,...zn[t],type:t};if("object"==typeof e)return e?void 0!==e.type?{...e,...zn[e.type],type:e.type}:void 0===e.value?{type:"object",value:e}:(t=Hn(e.value),{...e,...zn[t],type:t}):{type:"object",value:null};throw new Error("props")}function Hn(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}const $n={vertex:"#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n",fragment:"#ifdef MODULE_MATERIAL\n fragColor = material_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n fragColor = lighting_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_FOG\n fragColor = fog_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_PICKING\n fragColor = picking_filterHighlightColor(fragColor);\n fragColor = picking_filterPickingColor(fragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n"},Xn=/void\s+main\s*\([^)]*\)\s*\{\n?/,qn=/}\n?[^{}]*$/,Yn=[],Kn="__LUMA_INJECT_DECLARATIONS__";function Zn(e){const t={vertex:{},fragment:{}};for(const n in e){let s=e[n];"string"==typeof s&&(s={order:0,injection:s}),t[Qn(n)][n]=s}return t}function Qn(e){const t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function Jn(e,t,n,s=!1){const r="vertex"===t;for(const i in n){const t=n[i];t.sort((e,t)=>e.order-t.order),Yn.length=t.length;for(let e=0,n=t.length;ee+s));break;case"vs:#main-end":r&&(e=e.replace(qn,e=>s+e));break;case"fs:#decl":r||(e=e.replace(Kn,s));break;case"fs:#main-start":r||(e=e.replace(Xn,e=>e+s));break;case"fs:#main-end":r||(e=e.replace(qn,e=>s+e));break;default:e=e.replace(i,e=>e+s)}}return e=e.replace(Kn,""),s&&(e=e.replace(/\}\s*$/,e=>e+$n[t])),e}function es(e){e.map(e=>function(e){if(e.instance)return;es(e.dependencies||[]);const{propTypes:t={},deprecations:n=[],inject:s={}}=e,r={normalizedInjections:Zn(s),parsedDeprecations:ns(n)};t&&(r.propValidators=function(e){const t={};for(const[n,s]of Object.entries(e))t[n]=Wn(s);return t}(t)),e.instance=r;let i={};t&&(i=Object.entries(t).reduce((e,[t,n])=>{const s=null==n?void 0:n.value;return s&&(e[t]=s),e},{})),e.defaultUniforms={...e.defaultUniforms,...i}}(e))}function ts(e,t,n){var s;null==(s=e.deprecations)||s.forEach(e=>{var s;(null==(s=e.regex)?void 0:s.test(t))&&(e.deprecated?n.deprecated(e.old,e.new)():n.removed(e.old,e.new)())})}function ns(e){return e.forEach(e=>{"function"===e.type?e.regex=new RegExp(`\\b${e.old}\\(`):e.regex=new RegExp(`${e.type} ${e.old};`)}),e}function ss(e){es(e);const t={},n={};rs({modules:e,level:0,moduleMap:t,moduleDepth:n});const s=Object.keys(n).sort((e,t)=>n[t]-n[e]).map(e=>t[e]);return es(s),s}function rs(e){const{modules:t,level:n,moduleMap:s,moduleDepth:r}=e;if(n>=5)throw new Error("Possible loop in shader dependency graph");for(const i of t)s[i.name]=i,(void 0===r[i.name]||r[i.name]e.order-t.order);for(const t of e)n+=` ${t.injection}\n`}r.footer&&(n+=` ${r.footer}`),n+="}\n"}return n}function hs(e){const t={vertex:{},fragment:{}};for(const n of e){let e,s;"string"!=typeof n?(e=n,s=e.hook):(e={},s=n),s=s.trim();const[r,i]=s.split(":"),o=s.replace(/\(.+/,""),a=Object.assign(e,{signature:i});switch(r){case"vs":t.vertex[o]=a;break;case"fs":t.fragment[o]=a;break;default:throw new Error(r)}}return t}function ds(e,t="unnamed"){const n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return n?n[1]:t}function fs(e){let t=100;const n=e.match(/[^\s]+/g);if(n&&n.length>=2&&"#version"===n[0]){const e=parseInt(n[1],10);Number.isFinite(e)&&(t=e)}if(100!==t&&300!==t)throw new Error(`Invalid GLSL version ${t}`);return t}const ps=`\n\n${Kn}\n`;function gs(e,t){var n;const{source:s,stage:r,modules:i,hookFunctions:o=[],inject:a={},log:l}=t;Vn("string"==typeof s,"shader source must be a string");const c=s;let u="";const h=hs(o),d={},f={},p={};for(const m in a){const e="string"==typeof a[m]?{injection:a[m],order:0}:a[m],t=/^(v|f)s:(#)?([\w-]+)$/.exec(m);if(t){const n=t[2],s=t[3];n?"decl"===s?f[m]=[e]:p[m]=[e]:d[m]=[e]}else p[m]=[e]}const g=i;for(const m of g){l&&ts(m,c,l),u+=ys(m,"wgsl");const e=(null==(n=m.injections)?void 0:n[r])||{};for(const t in e){const n=/^(v|f)s:#([\w-]+)$/.exec(t);if(n){const s="decl"===n[2]?f:p;s[t]=s[t]||[],s[t].push(e[t])}else d[t]=d[t]||[],d[t].push(e[t])}}return u+=ps,u=Jn(u,r,f),u+=us(h[r],d),u+=c,u=Jn(u,r,p),u}function ms(e,t){var n;const{source:s,stage:r,language:i="glsl",modules:o,defines:a={},hookFunctions:l=[],inject:c={},prologue:u=!0,log:h}=t;Vn("string"==typeof s,"shader source must be a string");const d="glsl"===i?function(e){return{name:ds(e,void 0),language:"glsl",version:fs(e)}}(s).version:-1,f=e.shaderLanguageVersion,p=100===d?"#version 100":"#version 300 es",g=s.split("\n").slice(1).join("\n"),m={};o.forEach(e=>{Object.assign(m,e.defines)}),Object.assign(m,a);let _="";switch(i){case"wgsl":break;case"glsl":_=u?`${p}\n\n// ----- PROLOGUE -------------------------\n#define SHADER_TYPE_${r.toUpperCase()}\n\n${function(e){switch(null==e?void 0:e.gpu.toLowerCase()){case"apple":return"#define APPLE_GPU\n// Apple optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"nvidia":return"#define NVIDIA_GPU\n// Nvidia optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n// Intel optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n// Prevent driver from optimizing away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Headless Chrome's software shader 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// If the GPU doesn't have full 32 bits precision, will causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e)}\n${"fragment"===r?"precision highp float;\n":""}\n\n// ----- APPLICATION DEFINES -------------------------\n\n${function(e={}){let t="";for(const n in e){const s=e[n];(s||Number.isFinite(s))&&(t+=`#define ${n.toUpperCase()} ${e[n]}\n`)}return t}(m)}\n\n`:`${p}\n`}const y=hs(l),b={},v={},x={};for(const w in c){const e="string"==typeof c[w]?{injection:c[w],order:0}:c[w],t=/^(v|f)s:(#)?([\w-]+)$/.exec(w);if(t){const n=t[2],s=t[3];n?"decl"===s?v[w]=[e]:x[w]=[e]:b[w]=[e]}else x[w]=[e]}for(const w of o){h&&ts(w,g,h),_+=ys(w,r);const e=(null==(n=w.instance)?void 0:n.normalizedInjections[r])||{};for(const t in e){const n=/^(v|f)s:#([\w-]+)$/.exec(t);if(n){const s="decl"===n[2]?v:x;s[t]=s[t]||[],s[t].push(e[t])}else b[t]=b[t]||[],b[t].push(e[t])}}return _+="// ----- MAIN SHADER SOURCE -------------------------",_+=ps,_=Jn(_,r,v),_+=us(y[r],b),_+=g,_=Jn(_,r,x),"glsl"===i&&d!==f&&(_=function(e,t){var n;if(300!==Number((null==(n=e.match(/^#version[ \t]+(\d+)/m))?void 0:n[1])||100))throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return ls(e,os);case"fragment":return ls(e,as);default:throw new Error(t)}}(_,r)),_.trim()}function _s(e){return function(t){var n;const s={};for(const r of e){const e=null==(n=r.getUniforms)?void 0:n.call(r,t,s);Object.assign(s,e)}return s}}function ys(e,t){let n;switch(t){case"vertex":n=e.vs||"";break;case"fragment":n=e.fs||"";break;case"wgsl":n=e.source||"";break;default:Vn(!1)}if(!e.name)throw new Error("Shader module must have a name");const s=e.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let r=`// ----- MODULE ${e.name} ---------------\n\n`;return"wgsl"!==t&&(r+=`#define MODULE_${s}\n`),r+=`${n}\n`,r}const bs=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,vs=/^\s*\#\s*endif\s*$/,xs=class e{constructor(){s(this,"_hookFunctions",[]),s(this,"_defaultModules",[])}static getDefaultShaderAssembler(){return e.defaultShaderAssembler=e.defaultShaderAssembler||new e,e.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===("string"==typeof e?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){const t=this._getModuleList(e.modules),n=this._hookFunctions,{source:s,getUniforms:r}=function(e){const t=ss(e.modules||[]);return{source:gs(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t}),getUniforms:_s(t)}}({...e,source:e.source,modules:t,hookFunctions:n}),i="wgsl"===e.platformInfo.shaderLanguage?function(e){const t=e.split("\n"),n=[];let s=!0,r=null;for(const i of t){const e=i.match(bs),t=i.match(vs);e?(r=e[1],s=Boolean(null==void 0?void 0:undefined[r])):t?s=!0:s&&n.push(i)}return n.join("\n")}(s):s;return{source:i,getUniforms:r,modules:t}}assembleGLSLShaderPair(e){const t=this._getModuleList(e.modules),n=this._hookFunctions,s=function(e){const{vs:t,fs:n}=e,s=ss(e.modules||[]);return{vs:ms(e.platformInfo,{...e,source:t,stage:"vertex",modules:s}),fs:ms(e.platformInfo,{...e,source:n,stage:"fragment",modules:s}),getUniforms:_s(s)}}({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:n});return{...s,modules:t}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),n={};let s=0;for(let r=0,i=this._defaultModules.length;rt===e[4]);if(!n)throw new Error(t.name);return n[0]}function Ns(e){const[,,,,t]=Os[e];return t}const Os={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function Fs(e){let t;e.endsWith("-webgl")&&(e.replace("-webgl",""),t=!0);const[n,s]=e.split("x"),r=n,i=s?parseInt(s):1,o=Is(r),a={type:r,components:i,byteLength:o.byteLength*i,integer:o.integer,signed:o.signed,normalized:o.normalized};return t&&(a.webglOnly=!0),a}function Ds(e,t,n){if(!t||t>4)throw new Error(`size ${t}`);const s=t;return function(e,t,n){const s=n?function(e){const t=e;switch(t){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return t}}(e):e;switch(s){case"unorm8":return 1===t?"unorm8":3===t?"unorm8x3-webgl":`${s}x${t}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(1===t||3===t)throw new Error(`size: ${t}`);return`${s}x${t}`;default:return 1===t?s:`${s}x${t}`}}(Ls(e),s,n)}const Bs="texture-compression-bc",Us="texture-compression-astc",js="texture-compression-etc2",Gs="texture-compression-pvrtc-webgl",Vs="texture-compression-atc-webgl",zs="float32-renderable-webgl",Ws="float16-renderable-webgl",Hs="snorm8-renderable-webgl",$s="norm16-renderable-webgl",Xs="snorm16-renderable-webgl",qs="float32-filterable",Ys="float16-filterable-webgl";function Ks(e){const t=Zs[e];if(!t)throw new Error(`Unsupported texture format ${e}`);return t}const Zs={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:Hs},rg8snorm:{render:Hs},"rgb8snorm-webgl":{},rgba8snorm:{render:Hs},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:$s},rg16unorm:{render:$s},"rgb16unorm-webgl":{f:$s},rgba16unorm:{render:$s},r16snorm:{f:Xs},rg16snorm:{render:Xs},"rgb16snorm-webgl":{f:$s},rgba16snorm:{render:Xs},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Ws,filter:"float16-filterable-webgl"},rg16float:{render:Ws,filter:Ys},rgba16float:{render:Ws,filter:Ys},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:zs,filter:qs},rg32float:{render:!1,filter:qs},"rgb32float-webgl":{render:zs,filter:qs},rgba32float:{render:zs,filter:qs},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:"rgb9e5ufloat-renderable-webgl"},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:zs},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0},"bc1-rgb-unorm-webgl":{f:Bs},"bc1-rgb-unorm-srgb-webgl":{f:Bs},"bc1-rgba-unorm":{f:Bs},"bc1-rgba-unorm-srgb":{f:Bs},"bc2-rgba-unorm":{f:Bs},"bc2-rgba-unorm-srgb":{f:Bs},"bc3-rgba-unorm":{f:Bs},"bc3-rgba-unorm-srgb":{f:Bs},"bc4-r-unorm":{f:Bs},"bc4-r-snorm":{f:Bs},"bc5-rg-unorm":{f:Bs},"bc5-rg-snorm":{f:Bs},"bc6h-rgb-ufloat":{f:Bs},"bc6h-rgb-float":{f:Bs},"bc7-rgba-unorm":{f:Bs},"bc7-rgba-unorm-srgb":{f:Bs},"etc2-rgb8unorm":{f:js},"etc2-rgb8unorm-srgb":{f:js},"etc2-rgb8a1unorm":{f:js},"etc2-rgb8a1unorm-srgb":{f:js},"etc2-rgba8unorm":{f:js},"etc2-rgba8unorm-srgb":{f:js},"eac-r11unorm":{f:js},"eac-r11snorm":{f:js},"eac-rg11unorm":{f:js},"eac-rg11snorm":{f:js},"astc-4x4-unorm":{f:Us},"astc-4x4-unorm-srgb":{f:Us},"astc-5x4-unorm":{f:Us},"astc-5x4-unorm-srgb":{f:Us},"astc-5x5-unorm":{f:Us},"astc-5x5-unorm-srgb":{f:Us},"astc-6x5-unorm":{f:Us},"astc-6x5-unorm-srgb":{f:Us},"astc-6x6-unorm":{f:Us},"astc-6x6-unorm-srgb":{f:Us},"astc-8x5-unorm":{f:Us},"astc-8x5-unorm-srgb":{f:Us},"astc-8x6-unorm":{f:Us},"astc-8x6-unorm-srgb":{f:Us},"astc-8x8-unorm":{f:Us},"astc-8x8-unorm-srgb":{f:Us},"astc-10x5-unorm":{f:Us},"astc-10x5-unorm-srgb":{f:Us},"astc-10x6-unorm":{f:Us},"astc-10x6-unorm-srgb":{f:Us},"astc-10x8-unorm":{f:Us},"astc-10x8-unorm-srgb":{f:Us},"astc-10x10-unorm":{f:Us},"astc-10x10-unorm-srgb":{f:Us},"astc-12x10-unorm":{f:Us},"astc-12x10-unorm-srgb":{f:Us},"astc-12x12-unorm":{f:Us},"astc-12x12-unorm-srgb":{f:Us},"pvrtc-rgb4unorm-webgl":{f:Gs},"pvrtc-rgba4unorm-webgl":{f:Gs},"pvrtc-rbg2unorm-webgl":{f:Gs},"pvrtc-rgba2unorm-webgl":{f:Gs},"etc1-rbg-unorm-webgl":{f:"texture-compression-etc1-webgl"},"atc-rgb-unorm-webgl":{f:Vs},"atc-rgba-unorm-webgl":{f:Vs},"atc-rgbai-unorm-webgl":{f:Vs}},Qs=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Js=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,er=new class{getInfo(e){return tr(e)}isColor(e){return e.startsWith("rgba")||e.startsWith("bgra")||e.startsWith("rgb")}isDepthStencil(e){return e.startsWith("depth")||e.startsWith("stencil")}isCompressed(e){return Qs.some(t=>e.startsWith(t))}getCapabilities(e){const t=Ks(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},s=tr(e),r=e.startsWith("depth")||e.startsWith("stencil"),i=null==s?void 0:s.signed,o=null==s?void 0:s.integer,a=null==s?void 0:s.webgl;return n.render&&(n.render=!i),n.filter&&(n.filter=!(r||i||o||a)),n}};function tr(e){let t=function(e){var t;const n=Ks(e),s=n.bytesPerPixel||1,r=n.bitsPerChannel||[8,8,8,8];delete n.bitsPerChannel,delete n.bytesPerPixel,delete n.f,delete n.render,delete n.filter,delete n.blend,delete n.store;return{...n,format:e,attachment:n.attachment||"color",channels:n.channels||"r",components:n.components||(null==(t=n.channels)?void 0:t.length)||1,bytesPerPixel:s,bitsPerChannel:r,dataType:n.dataType||"uint8",srgb:n.srgb??!1,packed:n.packed??!1,webgl:n.webgl??!1,integer:n.integer??!1,signed:n.signed??!1,normalized:n.normalized??!1,compressed:n.compressed??!1}}(e);if(er.isCompressed(e)){t.channels="rgb",t.components=3,t.bytesPerPixel=1,t.srgb=!1,t.compressed=!0;const n=function(e){const t=/.*-(\d+)x(\d+)-.*/.exec(e);if(t){const[,e,n]=t;return{blockWidth:Number(e),blockHeight:Number(n)}}return null}(e);n&&(t.blockWidth=n.blockWidth,t.blockHeight=n.blockHeight)}const n=Js.exec(e);if(n){const[,s,r,i,o,a]=n,l=Is(`${i}${r}`),c=8*l.byteLength,u=s.length,h=[c,u>=2?c:0,u>=3?c:0,u>=4?c:0];t={format:e,attachment:t.attachment,dataType:l.signedType,components:u,channels:s,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:h,bytesPerPixel:l.byteLength*s.length,packed:t.packed,srgb:t.srgb},"-webgl"===a&&(t.webgl=!0),"-srgb"===o&&(t.srgb=!0)}return e.endsWith("-webgl")&&(t.webgl=!0),e.endsWith("-srgb")&&(t.srgb=!0),t}class nr{}class sr{constructor(e=[],t){s(this,"features"),s(this,"disabledFeatures"),this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){var t;return!(null==(t=this.disabledFeatures)?void 0:t[e])&&this.features.has(e)}}const rr=class e{constructor(t){s(this,"id"),s(this,"props"),s(this,"userData",{}),s(this,"statsManager",Ts),s(this,"timestamp",0),s(this,"_reused",!1),s(this,"_lumaData",{}),s(this,"_textureCaps",{}),this.props={...e.defaultProps,...t},this.id=this.props.id||Rs(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(e){return Fs(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return er.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){const s=Math.max(e,t,n);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return function(e){return"undefined"!=typeof ImageData&&e instanceof ImageData||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas}(e)}getExternalImageSize(e){return function(e){if("undefined"!=typeof ImageData&&e instanceof ImageData||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if("undefined"!=typeof VideoFrame&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw new Error("Unknown image type")}(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return er.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){var e;null==(e=this.commandEncoder)||e.popDebugGroup()}insertDebugMarker(e){var t;null==(t=this.commandEncoder)||t.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...n){return this.props.onError(e,t)?()=>{}:Ss.error(e.message,t,...n)}debug(){if(this.props.debug);else{const e="'Type luma.log.set({debug: true}) in console to enable debug breakpoints',\nor create a device with the 'debug: true' prop.";Ss.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}static _getCanvasContextProps(e){return!0===e.createCanvasContext?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const t=er.getCapabilities(e),n=e=>("string"==typeof e?this.features.has(e):e)??!0,s=n(t.create);return{format:e,create:s,render:s&&n(t.render),filter:s&&n(t.filter),blend:s&&n(t.blend),store:s&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&ks.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array&&(t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}};s(rr,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{const[n,s]=e.getDevicePixelSize();Ss.log(1,`${e} resized => ${n}x${s}px`)()},onPositionChange:(e,t)=>{const[n,s]=e.getPosition();Ss.log(1,`${e} repositioned => ${n},${s}`)()},onVisibilityChange:e=>Ss.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>Ss.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:Ss.get("debug")||void 0,debugShaders:Ss.get("debug-shaders")||void 0,debugFramebuffers:Boolean(Ss.get("debug-framebuffers")),debugFactories:Boolean(Ss.get("debug-factories")),debugWebGL:Boolean(Ss.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});let ir=rr;const or="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",ar=class e{constructor(){if(s(this,"stats",Ts),s(this,"log",Ss),s(this,"VERSION","9.2.5"),s(this,"spector"),s(this,"preregisteredAdapters",new Map),globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw Ss.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),Ss.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");Ss.error("This version of luma.gl has already been initialized")()}Ss.log(1,`${this.VERSION} - set luma.log.level=1 (or higher) to trace rendering`)(),globalThis.luma=this}async createDevice(t={}){const n={...e.defaultProps,...t},s=this.selectAdapter(n.type,n.adapters);if(!s)throw new Error(or);return n.waitForPageLoad&&await s.pageLoaded,await s.create(n)}async attachDevice(e,t){var n;const s=this._getTypeFromHandle(e,t.adapters),r=s&&this.selectAdapter(s,t.adapters);if(!r)throw new Error(or);return await(null==(n=null==r?void 0:r.attach)?void 0:n.call(r,e,t))}registerAdapters(e){for(const t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){const t=this._getAdapterMap(e);return Array.from(t).map(([,e])=>e).filter(e=>{var t;return null==(t=e.isSupported)?void 0:t.call(e)}).map(e=>e.type)}getBestAvailableAdapterType(e=[]){var t,n;const s=["webgpu","webgl","null"],r=this._getAdapterMap(e);for(const i of s)if(null==(n=null==(t=r.get(i))?void 0:t.isSupported)?void 0:n.call(t))return i;return null}selectAdapter(e,t=[]){let n=e;"best-available"===e&&(n=this.getBestAvailableAdapterType(t));const s=this._getAdapterMap(t);return n&&s.get(n)||null}enforceWebGL2(e=!0,t=[]){var n;const s=this._getAdapterMap(t).get("webgl");s||Ss.warn("enforceWebGL2: webgl adapter not found")(),null==(n=null==s?void 0:s.enforceWebGL2)||n.call(s,e)}setDefaultDeviceProps(t){Object.assign(e.defaultProps,t)}_getAdapterMap(e=[]){const t=new Map(this.preregisteredAdapters);for(const n of e)t.set(n.type,n);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":"undefined"!=typeof GPUDevice&&e instanceof GPUDevice||(null==e?void 0:e.queue)?"webgpu":null===e?"null":(e instanceof WebGLRenderingContext?Ss.warn("WebGL1 is not supported",e)():Ss.warn("Unknown handle type",e)(),null)}};s(ar,"defaultProps",{...ir.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});const lr=new ar;class cr{get pageLoaded(){return dr||(dr=hr()||"undefined"==typeof window?Promise.resolve():new Promise(e=>window.addEventListener("load",()=>e()))),dr}}const ur=Ne()&&"undefined"!=typeof document,hr=()=>ur&&"complete"===document.readyState;let dr=null;const fr=class e{constructor(t){var n,r;if(s(this,"id"),s(this,"props"),s(this,"canvas"),s(this,"htmlCanvas"),s(this,"offscreenCanvas"),s(this,"type"),s(this,"initialized"),s(this,"isInitialized",!1),s(this,"isVisible",!0),s(this,"cssWidth"),s(this,"cssHeight"),s(this,"devicePixelRatio"),s(this,"devicePixelWidth"),s(this,"devicePixelHeight"),s(this,"drawingBufferWidth"),s(this,"drawingBufferHeight"),s(this,"_initializedResolvers",function(){let e,t;return{promise:new Promise((n,s)=>{e=n,t=s}),resolve:e,reject:t}}()),s(this,"_resizeObserver"),s(this,"_intersectionObserver"),s(this,"_position"),s(this,"destroyed",!1),this.props={...e.defaultProps,...t},t=this.props,this.initialized=this._initializedResolvers.promise,Ne()?t.canvas?"string"==typeof t.canvas?this.canvas=function(e){const t=document.getElementById(e);if(!pr.isHTMLCanvas(t))throw new Error("Object is not a canvas element");return t}(t.canvas):this.canvas=t.canvas:this.canvas=function(e){const{width:t,height:n}=e,s=document.createElement("canvas");s.id=Rs("lumagl-auto-created-canvas"),s.width=t||1,s.height=n||1,s.style.width=Number.isFinite(t)?`${t}px`:"100%",s.style.height=Number.isFinite(n)?`${n}px`:"100%",(null==e?void 0:e.visible)||(s.style.visibility="hidden");const r=function(e){if("string"==typeof e){const t=document.getElementById(e);if(!t)throw new Error(`${e} is not an HTML element`);return t}return e||document.body}((null==e?void 0:e.container)||null);return r.insertBefore(s,r.firstChild),s}(t):this.canvas={width:t.width||1,height:t.height||1},e.isHTMLCanvas(this.canvas)?(this.id=t.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):e.isOffscreenCanvas(this.canvas)?(this.id=t.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=t.id||"node-canvas-context",this.type="node"),this.cssWidth=(null==(n=this.htmlCanvas)?void 0:n.clientWidth)||this.canvas.width,this.cssHeight=(null==(r=this.htmlCanvas)?void 0:r.clientHeight)||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],e.isHTMLCanvas(this.canvas)){this._intersectionObserver=new IntersectionObserver(e=>this._handleIntersection(e)),this._intersectionObserver.observe(this.canvas),this._resizeObserver=new ResizeObserver(e=>this._handleResize(e));try{this._resizeObserver.observe(this.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.canvas,{box:"content-box"})}setTimeout(()=>this._observeDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}static isHTMLCanvas(e){return"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){const e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){this.canvas.width=e,this.canvas.height=t,this.drawingBufferWidth=e,this.drawingBufferHeight=t}getDevicePixelRatio(){return"undefined"!=typeof window&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){const n=this.cssToDeviceRatio(),[s,r]=this.getDrawingBufferSize();return function(e,t,n,s,r){const i=e,o=gr(i[0],t,n);let a=mr(i[1],t,s,r),l=gr(i[0]+1,t,n);const c=l===n-1?l:l-1;let u;return l=mr(i[1]+1,t,s,r),r?(l=0===l?l:l+1,u=a,a=l):u=l===s-1?l:l-1,{x:o,y:a,width:Math.max(c-o+1,1),height:Math.max(u-a+1,1)}}(e,n,s,r,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){const[e,t]=this.getDevicePixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){var t;"lumagl-auto-created-canvas"===(null==(t=this.htmlCanvas)?void 0:t.id)&&(this.htmlCanvas.id=e)}_handleIntersection(e){const t=e.find(e=>e.target===this.canvas);if(!t)return;const n=t.isIntersecting;this.isVisible!==n&&(this.isVisible=n,this.device.props.onVisibilityChange(this))}_handleResize(e){var t,n;const s=e.find(e=>e.target===this.canvas);if(!s)return;this.cssWidth=s.contentBoxSize[0].inlineSize,this.cssHeight=s.contentBoxSize[0].blockSize;const r=this.getDevicePixelSize(),i=(null==(t=s.devicePixelContentBoxSize)?void 0:t[0].inlineSize)||s.contentBoxSize[0].inlineSize*devicePixelRatio,o=(null==(n=s.devicePixelContentBoxSize)?void 0:n[0].blockSize)||s.contentBoxSize[0].blockSize*devicePixelRatio,[a,l]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(i,a)),this.devicePixelHeight=Math.max(1,Math.min(o,l)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:r})}_updateDrawingBufferSize(){if(this.props.autoResize){if("number"==typeof this.props.useDevicePixels){const e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._updateDevice()}this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_observeDevicePixelRatio(){const e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){const t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){var e,t,n;const s=null==(e=this.htmlCanvas)?void 0:e.getBoundingClientRect();if(s){const e=[s.left,s.top];if(this._position??(this._position=e),e[0]!==this._position[0]||e[1]!==this._position[1]){const s=this._position;this._position=e,null==(n=(t=this.device.props).onPositionChange)||n.call(t,this,{oldPosition:s})}}}};s(fr,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});let pr=fr;function gr(e,t,n){return Math.min(Math.round(e*t),n-1)}function mr(e,t,n,s){return s?Math.max(0,n-1-Math.round(e*t)):Math.min(Math.round(e*t),n-1)}const _r=class e extends Cs{get[Symbol.toStringTag](){return"Sampler"}constructor(t,n){super(t,n=e.normalizeProps(t,n),e.defaultProps)}static normalizeProps(e,t){return t}};s(_r,"defaultProps",{...Cs.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});let yr=_r;const br={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},vr=class e extends Cs{constructor(t,n){if(super(t,n=e.normalizeProps(t,n),e.defaultProps),s(this,"dimension"),s(this,"baseDimension"),s(this,"format"),s(this,"width"),s(this,"height"),s(this,"depth"),s(this,"mipLevels"),s(this,"updateTimestamp"),this.dimension=this.props.dimension,this.baseDimension=br[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,void 0===this.props.width||void 0===this.props.height)if(t.isExternalImage(n.data)){const e=t.getExternalImageSize(n.data);this.width=(null==e?void 0:e.width)||1,this.height=(null==e?void 0:e.height)||1}else this.width=1,this.height=1,void 0!==this.props.width&&void 0!==this.props.height||Ss.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=t.incrementTimestamp()}get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}setSampler(e){this.sampler=e instanceof yr?e:this.device.createSampler(e)}clone(e){return this.device.createTexture({...this.props,...e})}static normalizeProps(e,t){const n={...t},{width:s,height:r}=n;return"number"==typeof s&&(n.width=Math.max(1,Math.ceil(s))),"number"==typeof r&&(n.height=Math.max(1,Math.ceil(r))),n}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(t){const{width:n,height:s,depth:r}=this,i={...e.defaultCopyDataOptions,width:n,height:s,depth:r,...t},o=this.device.getTextureFormatInfo(this.format);if(!t.bytesPerRow&&!o.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return i.bytesPerRow=t.bytesPerRow||n*(o.bytesPerPixel||4),i.rowsPerImage=t.rowsPerImage||s,i}_normalizeCopyExternalImageOptions(t){const n=this.device.getExternalImageSize(t.image),s={...e.defaultCopyExternalImageOptions,...n,...t};return s.width=Math.min(s.width,this.width-s.x),s.height=Math.min(s.height,this.height-s.y),s}};s(vr,"SAMPLE",4),s(vr,"STORAGE",8),s(vr,"RENDER",16),s(vr,"COPY_SRC",1),s(vr,"COPY_DST",2),s(vr,"TEXTURE",4),s(vr,"RENDER_ATTACHMENT",16),s(vr,"defaultProps",{...Cs.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:vr.TEXTURE|vr.RENDER_ATTACHMENT|vr.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),s(vr,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),s(vr,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1});let xr=vr;const wr=class e extends Cs{get[Symbol.toStringTag](){return"TextureView"}constructor(t,n){super(t,n,e.defaultProps)}};s(wr,"defaultProps",{...Cs.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});let Er=wr;function Tr(e,t,n,s){if(null==s?void 0:s.inlineSource){const s=function(e,t){let n="";for(let s=t-2;s<=t;s++){const r=e[s-1];void 0!==r&&(n+=Sr(r,t,undefined))}return n}(t,n);return`\n${s}${e.linePos>0?`${" ".repeat(e.linePos+5)}^^^\n`:""}${e.type.toUpperCase()}: ${e.message}\n\n`}const r="error"===e.type?"red":"#8B4000";return(null==s?void 0:s.html)?`
${e.type.toUpperCase()}: ${e.message}
`:`${e.type.toUpperCase()}: ${e.message}`}function Sr(e,t,n){const s=(null==n?void 0:n.html)?e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'"):e;return`${function(e){let t="";for(let n=e.length;n<4;++n)t+=" ";return t+e}(String(t))}: ${s}${(null==n?void 0:n.html)?"
":"\n"}`}const Ar=class e extends Cs{constructor(t,n){super(t,{id:Cr(n={...n,debugShaders:n.debugShaders||t.props.debugShaders||"errors"}),...n},e.defaultProps),s(this,"stage"),s(this,"source"),s(this,"compilationStatus","pending"),this.stage=this.props.stage,this.source=this.props.source}get[Symbol.toStringTag](){return"Shader"}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){const e=this.props.debugShaders;switch(e){case"never":return;case"errors":if("success"===this.compilationStatus)return}const t=await this.getCompilationInfo();"warnings"===e&&0===(null==t?void 0:t.length)||this._displayShaderLog(t,this.id)}_displayShaderLog(e,t){var n;if("undefined"==typeof document||!(null==document?void 0:document.createElement))return;const s=t,r=`${this.stage} shader "${s}"`;let i=function(e,t,n){let s="";const r=t.split(/\r?\n/),i=e.slice().sort((e,t)=>e.lineNum-t.lineNum);switch((null==n?void 0:n.showSourceCode)||"no"){case"all":let t=0;for(let e=1;e<=r.length;e++)for(s+=Sr(r[e-1],e,n);i.length>t&&i[t].lineNum===e;){const e=i[t++];s+=Tr(e,r,e.lineNum,{...n,inlineSource:!1})}for(;i.length>t;)s+=Tr(i[t++],[],0,{...n,inlineSource:!1});return s;case"issues":case"no":for(const i of e)s+=Tr(i,r,i.lineNum,{inlineSource:"no"!==(null==n?void 0:n.showSourceCode)});return s}}(e,this.source,{showSourceCode:"all",html:!0});const o=this.getTranslatedSource();o&&(i+=`

Translated Source



${o}
`);const a=document.createElement("Button");a.innerHTML=`\n

Compilation error in ${r}



\n
\n${i}\n
`,a.style.top="10px",a.style.left="10px",a.style.position="absolute",a.style.zIndex="9999",a.style.width="100%",a.style.textAlign="left",document.body.appendChild(a),null==(n=document.getElementsByClassName("luma-compiler-log-error")[0])||n.scrollIntoView(),a.onclick=()=>{const e=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(e)}}};s(Ar,"defaultProps",{...Cs.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let Rr=Ar;function Cr(e){return function(e,t="unnamed"){const n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return n?n[1]:t}(e.source)||e.id||Rs(`unnamed ${e.stage}-shader`)}const Pr=class e extends Cs{constructor(t,n={}){super(t,n,e.defaultProps),s(this,"width"),s(this,"height"),this.width=this.props.width,this.height=this.props.height}get[Symbol.toStringTag](){return"Framebuffer"}clone(e){const t=this.colorAttachments.map(t=>t.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,colorAttachments:t,depthStencilAttachment:n})}resize(e){let t=!e;if(e){const[n,s]=Array.isArray(e)?e:[e.width,e.height];t=t||s!==this.height||n!==this.width,this.width=n,this.height=s}t&&(Ss.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(0===this.props.colorAttachments.length&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((e,t)=>{if("string"==typeof e){const n=this.createColorTexture(e,t);return this.attachResource(n),n.view}return e instanceof xr?e.view:e});const e=this.props.depthStencilAttachment;if(e)if("string"==typeof e){const t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else this.depthStencilAttachment=e instanceof xr?e.view:e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:xr.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:xr.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let n=0;n":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},Wr={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}};function Hr(e,t){const n={};for(const s of e.attributes){const r=$r(e,t,s.name);r&&(n[s.name]=r)}return n}function $r(e,t,n){const s=function(e,t){const n=e.attributes.find(e=>e.name===t);return n||Ss.warn(`shader layout attribute "${t}" not present in shader`),n||null}(e,n),r=function(e,t){!function(e){for(const t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&Ss.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}(e);let n=function(e,t){for(const n of e)if(n.format&&n.name===t)return{attributeName:n.name,bufferName:t,stepMode:n.stepMode,vertexFormat:n.format,byteOffset:0,byteStride:n.byteStride||0};return null}(e,t);return n||(n=function(e,t){var n;for(const s of e){let e=s.byteStride;if("number"!=typeof s.byteStride)for(const t of s.attributes||[])e+=Fs(t.format).byteLength;const r=null==(n=s.attributes)?void 0:n.find(e=>e.attribute===t);if(r)return{attributeName:r.attribute,bufferName:s.name,stepMode:s.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:e}}return null}(e,t),n||(Ss.warn(`layout for attribute "${t}" not present in buffer layout`),null))}(t,n);if(!s)return null;const i=function(e){const[t,n]=zr[e];return{primitiveType:t,components:n,byteLength:Vr[t]*n,integer:"i32"===t||"u32"===t,signed:"u32"!==t}}(s.type),o=function(e){let t;switch(e.primitiveType){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return 1===e.components?t:`${t}x${e.components}`}(i),a=(null==r?void 0:r.vertexFormat)||o,l=Fs(a);return{attributeName:(null==r?void 0:r.attributeName)||s.name,bufferName:(null==r?void 0:r.bufferName)||s.name,location:s.location,shaderType:s.type,primitiveType:i.primitiveType,shaderComponents:i.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:i.integer,stepMode:(null==r?void 0:r.stepMode)||s.stepMode||"vertex",byteOffset:(null==r?void 0:r.byteOffset)||0,byteStride:(null==r?void 0:r.byteStride)||0}}const Xr=class e extends Cs{constructor(t,n){super(t,n,e.defaultProps),s(this,"maxVertexAttributes"),s(this,"attributeInfos"),s(this,"indexBuffer",null),s(this,"attributes"),this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=function(e,t,n=16){const s=Hr(e,t),r=new Array(n).fill(null);for(const i of Object.values(s))r[i.location]=i;return r}(n.shaderLayout,n.bufferLayout,this.maxVertexAttributes)}get[Symbol.toStringTag](){return"VertexArray"}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}};s(Xr,"defaultProps",{...Cs.defaultProps,shaderLayout:void 0,bufferLayout:[]});let qr=Xr;const Yr=class e extends Cs{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(t,n){super(t,n,e.defaultProps)}};s(Yr,"defaultProps",{...Cs.defaultProps,layout:void 0,buffers:{}});let Kr=Yr;const Zr=class e extends Cs{get[Symbol.toStringTag](){return"QuerySet"}constructor(t,n){super(t,n,e.defaultProps)}};s(Zr,"defaultProps",{...Cs.defaultProps,type:void 0,count:void 0});let Qr,Jr=Zr;function ei(e){return(!Qr||Qr.byteLength"uniform"===t.type&&t.name===(null==e?void 0:e.name));if(!n)throw new Error(null==e?void 0:e.name);const s=n;for(const e of s.uniforms||[])this.bindingLayout[e.name]=e}}setUniforms(e){for(const[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){var n;(function(e,t){if(e!==t)return!1;const n=e,s=t;if(!ti(n))return!1;if(ti(s)&&n.length===s.length)for(let r=0;r`}}class ci extends ii{constructor(e,t,n){super(e,n),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class ui extends ii{constructor(e,t,n,s){super(e,n),this.format=t,this.access=s}get isTemplate(){return!0}getTypeName(){let e=this.name;if(null!==this.format){if("vec2"===e||"vec3"===e||"vec4"===e||"mat2x2"===e||"mat2x3"===e||"mat2x4"===e||"mat3x2"===e||"mat3x3"===e||"mat3x4"===e||"mat4x2"===e||"mat4x3"===e||"mat4x4"===e){if("f32"===this.format.name)return e+="f",e;if("i32"===this.format.name)return e+="i",e;if("u32"===this.format.name)return e+="u",e;if("bool"===this.format.name)return e+="b",e;if("f16"===this.format.name)return e+="h",e}e+=`<${this.format.name}>`}else if("vec2"===e||"vec3"===e||"vec4"===e)return e;return e}}var hi,di;(di=hi||(hi={}))[di.Uniform=0]="Uniform",di[di.Storage=1]="Storage",di[di.Texture=2]="Texture",di[di.Sampler=3]="Sampler",di[di.StorageTexture=4]="StorageTexture";class fi{constructor(e,t,n,s,r,i,o){this.name=e,this.type=t,this.group=n,this.binding=s,this.attributes=r,this.resourceType=i,this.access=o}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class pi{constructor(e,t){this.name=e,this.type=t}}class gi{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s,this.interpolation=null}}class mi{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s}}class _i{constructor(e,t,n,s){this.name=e,this.type=t,this.attributes=n,this.id=s}}class yi{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n}}class bi{constructor(e,t=null,n){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=n}}class vi{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function xi(e){var t=(32768&e)>>15,n=(31744&e)>>10,s=1023&e;return 0==n?(t?-1:1)*Math.pow(2,-14)*(s/Math.pow(2,10)):31==n?s?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,n-15)*(1+s/Math.pow(2,10))}const wi=new Float32Array(1),Ei=new Int32Array(wi.buffer),Ti=new Uint16Array(1);function Si(e){wi[0]=e;const t=Ei[0],n=t>>31&1;let s=t>>23&255,r=8388607&t;if(255===s)return Ti[0]=n<<15|31744|(0!==r?512:0),Ti[0];if(0===s){if(0===r)return Ti[0]=n<<15,Ti[0];r|=8388608;let e=113;for(;!(8388608&r);)r<<=1,e--;return s=127-e,r&=8388607,s>0?(r=(r>>126-s)+(r>>127-s&1),Ti[0]=n<<15|s<<10|r>>13,Ti[0]):(Ti[0]=n<<15,Ti[0])}return s=s-127+15,s>=31?(Ti[0]=n<<15|31744,Ti[0]):s<=0?s<-10?(Ti[0]=n<<15,Ti[0]):(r=(8388608|r)>>1-s,Ti[0]=n<<15|r>>13,Ti[0]):(r>>=13,Ti[0]=n<<15|s<<10|r,Ti[0])}const Ai=new Uint32Array(1),Ri=new Float32Array(Ai.buffer,0,1);function Ci(e){const t=112+(e>>6&31)<<23|(63&e)<<17;return Ai[0]=t,Ri[0]}function Pi(e,t,n,s){const r=[0,0,0,0];for(let i=0;i{e.increment="++",e.decrement="--"})($i||($i={})),(e=>{e.parse=function(t){const n=t;if("parse"==n)throw new Error("Invalid value for IncrementOperator");return e[n]}})($i||($i={}));class Ki extends Fi{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(e=>{e.assign="=",e.addAssign="+=",e.subtractAssin="-=",e.multiplyAssign="*=",e.divideAssign="/=",e.moduloAssign="%=",e.andAssign="&=",e.orAssign="|=",e.xorAssign="^=",e.shiftLeftAssign="<<=",e.shiftRightAssign=">>="})(Xi||(Xi={})),(Xi||(Xi={})).parse=function(e){const t=e;if("parse"==t)throw new Error("Invalid value for AssignOperator");return t};class Zi extends Fi{constructor(e,t,n){super(),this.operator=e,this.variable=t,this.value=n}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class Qi extends Fi{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return Oi.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class Ji extends Fi{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),null===(t=this.continuing)||void 0===t||t.search(e)}}class eo extends Fi{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){e(this);for(const t of this.cases)t.search(e)}}class to extends Fi{constructor(e,t,n,s){super(),this.condition=e,this.body=t,this.elseif=n,this.else=s}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class no extends Fi{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class so extends Fi{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class ro extends Fi{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class io extends Fi{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class oo extends Fi{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class ao extends Fi{constructor(){super()}get astNodeType(){return"discard"}}class lo extends Fi{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}class co extends Fi{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}}class uo extends Fi{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if("f32"===t.name)return t;for(let n=1;n`}else if("vec2"===e||"vec3"===e||"vec4"===e)return e;return e}}po.vec2f=new po("vec2",uo.f32,null),po.vec3f=new po("vec3",uo.f32,null),po.vec4f=new po("vec4",uo.f32,null),po.vec2i=new po("vec2",uo.i32,null),po.vec3i=new po("vec3",uo.i32,null),po.vec4i=new po("vec4",uo.i32,null),po.vec2u=new po("vec2",uo.u32,null),po.vec3u=new po("vec3",uo.u32,null),po.vec4u=new po("vec4",uo.u32,null),po.vec2h=new po("vec2",uo.f16,null),po.vec3h=new po("vec3",uo.f16,null),po.vec4h=new po("vec4",uo.f16,null),po.vec2b=new po("vec2",uo.bool,null),po.vec3b=new po("vec3",uo.bool,null),po.vec4b=new po("vec4",uo.bool,null),po.mat2x2f=new po("mat2x2",uo.f32,null),po.mat2x3f=new po("mat2x3",uo.f32,null),po.mat2x4f=new po("mat2x4",uo.f32,null),po.mat3x2f=new po("mat3x2",uo.f32,null),po.mat3x3f=new po("mat3x3",uo.f32,null),po.mat3x4f=new po("mat3x4",uo.f32,null),po.mat4x2f=new po("mat4x2",uo.f32,null),po.mat4x3f=new po("mat4x3",uo.f32,null),po.mat4x4f=new po("mat4x4",uo.f32,null),po.mat2x2h=new po("mat2x2",uo.f16,null),po.mat2x3h=new po("mat2x3",uo.f16,null),po.mat2x4h=new po("mat2x4",uo.f16,null),po.mat3x2h=new po("mat3x2",uo.f16,null),po.mat3x3h=new po("mat3x3",uo.f16,null),po.mat3x4h=new po("mat3x4",uo.f16,null),po.mat4x2h=new po("mat4x2",uo.f16,null),po.mat4x3h=new po("mat4x3",uo.f16,null),po.mat4x4h=new po("mat4x4",uo.f16,null),po.mat2x2i=new po("mat2x2",uo.i32,null),po.mat2x3i=new po("mat2x3",uo.i32,null),po.mat2x4i=new po("mat2x4",uo.i32,null),po.mat3x2i=new po("mat3x2",uo.i32,null),po.mat3x3i=new po("mat3x3",uo.i32,null),po.mat3x4i=new po("mat3x4",uo.i32,null),po.mat4x2i=new po("mat4x2",uo.i32,null),po.mat4x3i=new po("mat4x3",uo.i32,null),po.mat4x4i=new po("mat4x4",uo.i32,null),po.mat2x2u=new po("mat2x2",uo.u32,null),po.mat2x3u=new po("mat2x3",uo.u32,null),po.mat2x4u=new po("mat2x4",uo.u32,null),po.mat3x2u=new po("mat3x2",uo.u32,null),po.mat3x3u=new po("mat3x3",uo.u32,null),po.mat3x4u=new po("mat3x4",uo.u32,null),po.mat4x2u=new po("mat4x2",uo.u32,null),po.mat4x3u=new po("mat4x3",uo.u32,null),po.mat4x4u=new po("mat4x4",uo.u32,null);class go extends uo{constructor(e,t,n,s){super(e),this.storage=t,this.type=n,this.access=s}get astNodeType(){return"pointer"}}class mo extends uo{constructor(e,t,n,s){super(e),this.attributes=t,this.format=n,this.count=s}get astNodeType(){return"array"}get isArray(){return!0}}class _o extends uo{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"sampler"}}class yo extends Mi{constructor(){super(),this.postfix=null}}class bo extends yo{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class vo extends yo{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class xo extends yo{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return Oi.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class wo extends yo{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class Eo extends yo{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){const t=e.evalExpression(this.initializer,e.context);return null!==t&&this.postfix?t.getSubData(e,this.postfix,e.context):t}return null}search(e){this.initializer.search(e)}}class To extends yo{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return void 0!==t&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof Go}get isVector(){return this.value instanceof zo||this.value instanceof Wo}get scalarValue(){return this.value instanceof Go?this.value.value:0}get vectorValue(){return this.value instanceof zo||this.value instanceof Wo?this.value.data:new Float32Array(0)}}class So extends yo{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class Ao extends yo{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class Ro extends yo{constructor(){super()}}class Co extends Ro{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class Po extends Ro{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:"f32"===e.name||"f32"===t.name?uo.f32:"u32"===e.name||"u32"===t.name?uo.u32:uo.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class ko extends Mi{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class Io extends yo{constructor(){super()}get astNodeType(){return"default"}}class Mo extends ko{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class Lo extends ko{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class No extends Mi{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"argument"}}class Oo extends Mi{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Fo extends Mi{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"member"}}class Do extends Mi{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class Bo{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=Bo._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,n,s){}getSubData(e,t,n){return null}toString(){return`<${this.typeInfo.getTypeName()}>`}}Bo._id=0;class Uo extends Bo{constructor(){super(new ii("void",null),null)}toString(){return"void"}}Uo.void=new Uo;class jo extends Bo{constructor(e){super(new ci("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,n,s){this.reference.setDataValue(e,t,n,s)}getSubData(e,t,n){return t?this.reference.getSubData(e,t,n):this}toString(){return`&${this.reference.toString()}`}}class Go extends Bo{constructor(e,t,n=null){super(t,n),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:"x32"===this.typeInfo.name?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):"i32"===this.typeInfo.name||"bool"===this.typeInfo.name?this.data=new Int32Array([e]):"u32"===this.typeInfo.name?this.data=new Uint32Array([e]):("f32"===this.typeInfo.name||"f16"===this.typeInfo.name)&&(this.data=new Float32Array([e]))}clone(){if(this.data instanceof Float32Array)return new Go(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Go(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Go(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,n,s){if(n)return;if(!(t instanceof Go))return;let r=t.data[0];"i32"===this.typeInfo.name||"u32"===this.typeInfo.name?r=Math.floor(r):"bool"===this.typeInfo.name&&(r=r?1:0),this.data[0]=r}getSubData(e,t,n){return t?null:this}toString(){return`${this.value}`}}function Vo(e,t,n){const s=t.length;return 2===s?"f32"===n?new zo(new Float32Array(t),e.getTypeInfo("vec2f")):"i32"===n||"bool"===n?new zo(new Int32Array(t),e.getTypeInfo("vec2i")):"u32"===n?new zo(new Uint32Array(t),e.getTypeInfo("vec2u")):"f16"===n?new zo(new Float32Array(t),e.getTypeInfo("vec2h")):null:3===s?"f32"===n?new zo(new Float32Array(t),e.getTypeInfo("vec3f")):"i32"===n||"bool"===n?new zo(new Int32Array(t),e.getTypeInfo("vec3i")):"u32"===n?new zo(new Uint32Array(t),e.getTypeInfo("vec3u")):"f16"===n?new zo(new Float32Array(t),e.getTypeInfo("vec3h")):null:4===s?"f32"===n?new zo(new Float32Array(t),e.getTypeInfo("vec4f")):"i32"===n||"bool"===n?new zo(new Int32Array(t),e.getTypeInfo("vec4i")):"u32"===n?new zo(new Uint32Array(t),e.getTypeInfo("vec4u")):"f16"===n?new zo(new Float32Array(t),e.getTypeInfo("vec4h")):null:null}class zo extends Bo{constructor(e,t,n=null){if(super(t,n),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?this.data=new Float32Array(e):"vec2i"===t||"vec3i"===t||"vec4i"===t?this.data=new Int32Array(e):"vec2u"===t||"vec3u"===t||"vec4u"===t?this.data=new Uint32Array(e):"vec2h"===t||"vec3h"===t||"vec4h"===t?this.data=new Float32Array(e):"vec2b"===t||"vec3b"===t||"vec4b"===t?this.data=new Int32Array(e):("vec2"===t||"vec3"===t||"vec4"===t)&&(this.data=new Float32Array(e))}}clone(){if(this.data instanceof Float32Array)return new zo(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new zo(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new zo(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,n,s){n instanceof bo||t instanceof zo&&(this.data=t.data)}getSubData(e,t,n){if(null===t)return this;let s=e.getTypeInfo("f32");if(this.typeInfo instanceof ui)s=this.typeInfo.format||s;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?s=e.getTypeInfo("f32"):"vec2i"===t||"vec3i"===t||"vec4i"===t?s=e.getTypeInfo("i32"):"vec2b"===t||"vec3b"===t||"vec4b"===t?s=e.getTypeInfo("bool"):"vec2u"===t||"vec3u"===t||"vec4u"===t?s=e.getTypeInfo("u32"):("vec2h"===t||"vec3h"===t||"vec4h"===t)&&(s=e.getTypeInfo("f16"))}let r=this;for(;null!==t&&null!==r;){if(t instanceof Ao){const i=t.index;let o=-1;if(i instanceof To){if(!(i.value instanceof Go))return null;o=i.value.value}else{const t=e.evalExpression(i,n);if(!(t instanceof Go))return null;o=t.value}if(o<0||o>=r.data.length)return null;if(r.data instanceof Float32Array){const e=new Float32Array(r.data.buffer,r.data.byteOffset+4*o,1);return new Go(e,s)}if(r.data instanceof Int32Array){const e=new Int32Array(r.data.buffer,r.data.byteOffset+4*o,1);return new Go(e,s)}if(r.data instanceof Uint32Array){const e=new Uint32Array(r.data.buffer,r.data.byteOffset+4*o,1);return new Go(e,s)}throw"GetSubData: Invalid data type"}if(!(t instanceof bo))return null;{const n=t.value.toLowerCase();if(1===n.length){let e=0;if("x"===n||"r"===n)e=0;else if("y"===n||"g"===n)e=1;else if("z"===n||"b"===n)e=2;else{if("w"!==n&&"a"!==n)return null;e=3}if(this.data instanceof Float32Array){let t=new Float32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Go(t,s,this)}if(this.data instanceof Int32Array){let t=new Int32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Go(t,s,this)}if(this.data instanceof Uint32Array){let t=new Uint32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Go(t,s,this)}}const i=[];for(const e of n)"x"===e||"r"===e?i.push(this.data[0]):"y"===e||"g"===e?i.push(this.data[1]):"z"===e||"b"===e?i.push(this.data[2]):("w"===e||"a"===e)&&i.push(this.data[3]);r=Vo(e,i,s.name)}t=t.postfix}return r}toString(){let e=`${this.data[0]}`;for(let t=1;t=this.data.length)return null;const o=s.endsWith("h")?"h":"f";let a;if("mat2x2"===s||"mat2x2f"===s||"mat2x2h"===s||"mat3x2"===s||"mat3x2f"===s||"mat3x2h"===s||"mat4x2"===s||"mat4x2f"===s||"mat4x2h"===s)a=new zo(new Float32Array(this.data.buffer,this.data.byteOffset+2*i*4,2),e.getTypeInfo(`vec2${o}`));else if("mat2x3"===s||"mat2x3f"===s||"mat2x3h"===s||"mat3x3"===s||"mat3x3f"===s||"mat3x3h"===s||"mat4x3"===s||"mat4x3f"===s||"mat4x3h"===s)a=new zo(new Float32Array(this.data.buffer,this.data.byteOffset+3*i*4,3),e.getTypeInfo(`vec3${o}`));else{if("mat2x4"!==s&&"mat2x4f"!==s&&"mat2x4h"!==s&&"mat3x4"!==s&&"mat3x4f"!==s&&"mat3x4h"!==s&&"mat4x4"!==s&&"mat4x4f"!==s&&"mat4x4h"!==s)return null;a=new zo(new Float32Array(this.data.buffer,this.data.byteOffset+4*i*4,4),e.getTypeInfo(`vec4${o}`))}return t.postfix?a.getSubData(e,t.postfix,n):a}return null}toString(){let e=`${this.data[0]}`;for(let t=1;t"!==i&&"x32"!==i)if("u32"!==i&&"atomic"!==i)if("bool"!==i){if("vec2f"===i||"vec2h"===i){const e=new Float32Array(this.buffer,s,2);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3f"===i||"vec3h"===i){const e=new Float32Array(this.buffer,s,3);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4f"===i||"vec4h"===i){const e=new Float32Array(this.buffer,s,4);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2i"===i){const e=new Int32Array(this.buffer,s,2);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3i"===i){const e=new Int32Array(this.buffer,s,3);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4i"===i){const e=new Int32Array(this.buffer,s,4);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2u"===i){const e=new Uint32Array(this.buffer,s,2);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3u"===i){const e=new Uint32Array(this.buffer,s,3);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4u"===i){const e=new Uint32Array(this.buffer,s,4);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2b"===i){const e=new Uint32Array(this.buffer,s,2);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3b"===i){const e=new Uint32Array(this.buffer,s,3);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4b"===i){const e=new Uint32Array(this.buffer,s,4);return void(t instanceof zo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x2f"===i||"mat2x2h"===i){const e=new Float32Array(this.buffer,s,4);return void(t instanceof Wo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x3f"===i||"mat2x3h"===i){const e=new Float32Array(this.buffer,s,6);return void(t instanceof Wo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat2x4f"===i||"mat2x4h"===i){const e=new Float32Array(this.buffer,s,8);return void(t instanceof Wo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7]))}if("mat3x2f"===i||"mat3x2h"===i){const e=new Float32Array(this.buffer,s,6);return void(t instanceof Wo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat3x3f"===i||"mat3x3h"===i){const e=new Float32Array(this.buffer,s,9);return void(t instanceof Wo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8]))}if("mat3x4f"===i||"mat3x4h"===i){const e=new Float32Array(this.buffer,s,12);return void(t instanceof Wo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11]))}if("mat4x2f"===i||"mat4x2h"===i){const e=new Float32Array(this.buffer,s,8);return void(t instanceof Wo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7]))}if("mat4x3f"===i||"mat4x3h"===i){const e=new Float32Array(this.buffer,s,12);return void(t instanceof Wo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11]))}if("mat4x4f"===i||"mat4x4h"===i){const e=new Float32Array(this.buffer,s,16);return void(t instanceof Wo?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11],e[12]=t.data[12],e[13]=t.data[13],e[14]=t.data[14],e[15]=t.data[15]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}if(t instanceof Ho&&n===t.typeInfo)return void new Uint8Array(this.buffer,s,t.buffer.byteLength).set(new Uint8Array(t.buffer))}else t instanceof Go&&(new Int32Array(this.buffer,s,1)[0]=t.value);else t instanceof Go&&(new Uint32Array(this.buffer,s,1)[0]=t.value);else t instanceof Go&&(new Int32Array(this.buffer,s,1)[0]=t.value);else t instanceof Go&&(new Float32Array(this.buffer,s,1)[0]=t.value)}getSubData(e,t,n){var s,r;if(null===t)return this;let i=this.offset,o=this.typeInfo;for(;t;){if(t instanceof Ao){const s=t.index,r=s instanceof yo?e.evalExpression(s,n):s;let a=0;if(r instanceof Go?a=r.value:"number"==typeof r&&(a=r),o instanceof li)i+=a*o.stride,o=o.format;else{const t=o.getTypeName();("mat4x4"===t||"mat4x4f"===t||"mat4x4h"===t)&&(i+=16*a,o=e.getTypeInfo("vec4f"))}}else{if(!(t instanceof bo))return null;{const n=t.value;if(o instanceof ai){let e=!1;for(const t of o.members)if(t.name===n){i+=t.offset,o=t.type,e=!0;break}if(!e)return null}else if(o instanceof ii){const t=o.getTypeName();if("vec2f"===t||"vec3f"===t||"vec4f"===t||"vec2i"===t||"vec3i"===t||"vec4i"===t||"vec2u"===t||"vec3u"===t||"vec4u"===t||"vec2b"===t||"vec3b"===t||"vec4b"===t||"vec2h"===t||"vec3h"===t||"vec4h"===t||"vec2"===t||"vec3"===t||"vec4"===t){if(n.length>0&&n.length<5){let s="f";const r=[];for(let o=0;o=this.buffer.byteLength)return null;const e=new Float32Array(this.buffer,i,3);r.push(e[l])}else if("vec4f"===t)r.push(new Float32Array(this.buffer,i,4)[l]);else if("vec2i"===t)s="i",r.push(new Int32Array(this.buffer,i,2)[l]);else if("vec3i"===t)s="i",r.push(new Int32Array(this.buffer,i,3)[l]);else if("vec4i"===t)s="i",r.push(new Int32Array(this.buffer,i,4)[l]);else if("vec2u"===t){s="u";const e=new Uint32Array(this.buffer,i,2);r.push(e[l])}else"vec3u"===t?(s="u",r.push(new Uint32Array(this.buffer,i,3)[l])):"vec4u"===t&&(s="u",r.push(new Uint32Array(this.buffer,i,4)[l]))}return 2===r.length?o=e.getTypeInfo(`vec2${s}`):3===r.length?o=e.getTypeInfo(`vec3${s}`):4===r.length&&(o=e.getTypeInfo(`vec4${s}`)),new zo(r,o,null)}return null}return null}}}t=t.postfix}const a=o.getTypeName();return"f32"===a?new Go(new Float32Array(this.buffer,i,1),o,this):"i32"===a?new Go(new Int32Array(this.buffer,i,1),o,this):"u32"===a?new Go(new Uint32Array(this.buffer,i,1),o,this):"vec2f"===a?new zo(new Float32Array(this.buffer,i,2),o,this):"vec3f"===a?new zo(new Float32Array(this.buffer,i,3),o,this):"vec4f"===a?new zo(new Float32Array(this.buffer,i,4),o,this):"vec2i"===a?new zo(new Int32Array(this.buffer,i,2),o,this):"vec3i"===a?new zo(new Int32Array(this.buffer,i,3),o,this):"vec4i"===a?new zo(new Int32Array(this.buffer,i,4),o,this):"vec2u"===a?new zo(new Uint32Array(this.buffer,i,2),o,this):"vec3u"===a?new zo(new Uint32Array(this.buffer,i,3),o,this):"vec4u"===a?new zo(new Uint32Array(this.buffer,i,4),o,this):o instanceof ui&&"atomic"===o.name?"u32"===(null===(s=o.format)||void 0===s?void 0:s.name)?new Go(new Uint32Array(this.buffer,i,1)[0],o.format,this):"i32"===(null===(r=o.format)||void 0===r?void 0:r.name)?new Go(new Int32Array(this.buffer,i,1)[0],o.format,this):null:new Ho(this.buffer,o,i,this)}toString(){let e="";if(this.typeInfo instanceof li)if("f32"===this.typeInfo.format.name){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n0?null!==(e=n[0])&&void 0!==e?e:0:n instanceof Object&&null!==(t=n.width)&&void 0!==t?t:0}get height(){var e,t;const n=this.descriptor.size;return n instanceof Array&&n.length>1?null!==(e=n[1])&&void 0!==e?e:0:n instanceof Object&&null!==(t=n.height)&&void 0!==t?t:0}get depthOrArrayLayers(){var e,t;const n=this.descriptor.size;return n instanceof Array&&n.length>2?null!==(e=n[2])&&void 0!==e?e:0:n instanceof Object&&null!==(t=n.depthOrArrayLayers)&&void 0!==t?t:0}get format(){var e;return this.descriptor&&null!==(e=this.descriptor.format)&&void 0!==e?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&null!==(e=this.descriptor.sampleCount)&&void 0!==e?e:1}get mipLevelCount(){var e;return this.descriptor&&null!==(e=this.descriptor.mipLevelCount)&&void 0!==e?e:1}get dimension(){var e;return this.descriptor&&null!==(e=this.descriptor.dimension)&&void 0!==e?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];const t=[this.width,this.height,this.depthOrArrayLayers];for(let n=0;n>e);return t}get texelByteSize(){const e=this.format,t=Ii[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=Ii[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=Ii[e],n=this.width;if(!e||n<=0||!t)return-1;const s=this.height,r=this.depthOrArrayLayers,i=this.dimension;return n/t.blockWidth*("1d"===i?1:s/t.blockHeight)*t.bytesPerBlock*r}getPixel(e,t,n=0,s=0){const r=this.texelByteSize,i=this.bytesPerRow,o=this.height,a=this.data[s];return function(e,t,n,s,r,i,o,a,l){const c=s*(o>>=r)*(i>>=r)+n*o+t*a;switch(l){case"r8unorm":return[Pi(e,c,"8unorm",1)[0]];case"r8snorm":return[Pi(e,c,"8snorm",1)[0]];case"r8uint":return[Pi(e,c,"8uint",1)[0]];case"r8sint":return[Pi(e,c,"8sint",1)[0]];case"rg8unorm":{const t=Pi(e,c,"8unorm",2);return[t[0],t[1]]}case"rg8snorm":{const t=Pi(e,c,"8snorm",2);return[t[0],t[1]]}case"rg8uint":{const t=Pi(e,c,"8uint",2);return[t[0],t[1]]}case"rg8sint":{const t=Pi(e,c,"8sint",2);return[t[0],t[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const t=Pi(e,c,"8unorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8snorm":{const t=Pi(e,c,"8snorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8uint":{const t=Pi(e,c,"8uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba8sint":{const t=Pi(e,c,"8sint",4);return[t[0],t[1],t[2],t[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const t=Pi(e,c,"8unorm",4);return[t[2],t[1],t[0],t[3]]}case"r16uint":return[Pi(e,c,"16uint",1)[0]];case"r16sint":return[Pi(e,c,"16sint",1)[0]];case"r16float":return[Pi(e,c,"16float",1)[0]];case"rg16uint":{const t=Pi(e,c,"16uint",2);return[t[0],t[1]]}case"rg16sint":{const t=Pi(e,c,"16sint",2);return[t[0],t[1]]}case"rg16float":{const t=Pi(e,c,"16float",2);return[t[0],t[1]]}case"rgba16uint":{const t=Pi(e,c,"16uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16sint":{const t=Pi(e,c,"16sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16float":{const t=Pi(e,c,"16float",4);return[t[0],t[1],t[2],t[3]]}case"r32uint":return[Pi(e,c,"32uint",1)[0]];case"r32sint":return[Pi(e,c,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[Pi(e,c,"32float",1)[0]];case"rg32uint":{const t=Pi(e,c,"32uint",2);return[t[0],t[1]]}case"rg32sint":{const t=Pi(e,c,"32sint",2);return[t[0],t[1]]}case"rg32float":{const t=Pi(e,c,"32float",2);return[t[0],t[1]]}case"rgba32uint":{const t=Pi(e,c,"32uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32sint":{const t=Pi(e,c,"32sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32float":{const t=Pi(e,c,"32float",4);return[t[0],t[1],t[2],t[3]]}case"rg11b10ufloat":{const t=new Uint32Array(e.buffer,c,1)[0],n=(4192256&t)>>11,s=(4290772992&t)>>22;return[Ci(2047&t),Ci(n),function(e){const t=112+(e>>5&31)<<23|(31&e)<<18;return Ai[0]=t,Ri[0]}(s),1]}}return null}(new Uint8Array(a),e,t,n,s,o,i,r,this.format)}setPixel(e,t,n,s,r){const i=this.texelByteSize,o=this.bytesPerRow,a=this.height,l=this.data[s];!function(e,t,n,s,r,i,o,a,l,c){const u=s*(o>>=r)*(i>>=r)+n*o+t*a;switch(l){case"r8unorm":return void ki(e,u,"8unorm",1,c);case"r8snorm":return void ki(e,u,"8snorm",1,c);case"r8uint":return void ki(e,u,"8uint",1,c);case"r8sint":return void ki(e,u,"8sint",1,c);case"rg8unorm":return void ki(e,u,"8unorm",2,c);case"rg8snorm":return void ki(e,u,"8snorm",2,c);case"rg8uint":return void ki(e,u,"8uint",2,c);case"rg8sint":return void ki(e,u,"8sint",2,c);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void ki(e,u,"8unorm",4,c);case"rgba8snorm":return void ki(e,u,"8snorm",4,c);case"rgba8uint":return void ki(e,u,"8uint",4,c);case"rgba8sint":return void ki(e,u,"8sint",4,c);case"r16uint":return void ki(e,u,"16uint",1,c);case"r16sint":return void ki(e,u,"16sint",1,c);case"r16float":return void ki(e,u,"16float",1,c);case"rg16uint":return void ki(e,u,"16uint",2,c);case"rg16sint":return void ki(e,u,"16sint",2,c);case"rg16float":return void ki(e,u,"16float",2,c);case"rgba16uint":return void ki(e,u,"16uint",4,c);case"rgba16sint":return void ki(e,u,"16sint",4,c);case"rgba16float":return void ki(e,u,"16float",4,c);case"r32uint":return void ki(e,u,"32uint",1,c);case"r32sint":return void ki(e,u,"32sint",1,c);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void ki(e,u,"32float",1,c);case"rg32uint":return void ki(e,u,"32uint",2,c);case"rg32sint":return void ki(e,u,"32sint",2,c);case"rg32float":return void ki(e,u,"32float",2,c);case"rgba32uint":return void ki(e,u,"32uint",4,c);case"rgba32sint":return void ki(e,u,"32sint",4,c);case"rgba32float":ki(e,u,"32float",4,c)}}(new Uint8Array(l),e,t,n,s,a,o,i,this.format,r)}}(e=>{e[e.token=0]="token",e[e.keyword=1]="keyword",e[e.reserved=2]="reserved"})(Yi||(Yi={}));class Xo{constructor(e,t,n){this.name=e,this.type=t,this.rule=n}toString(){return this.name}}class qo{}qi=qo,qo.none=new Xo("",Yi.reserved,""),qo.eof=new Xo("EOF",Yi.token,""),qo.reserved={asm:new Xo("asm",Yi.reserved,"asm"),bf16:new Xo("bf16",Yi.reserved,"bf16"),do:new Xo("do",Yi.reserved,"do"),enum:new Xo("enum",Yi.reserved,"enum"),f16:new Xo("f16",Yi.reserved,"f16"),f64:new Xo("f64",Yi.reserved,"f64"),handle:new Xo("handle",Yi.reserved,"handle"),i8:new Xo("i8",Yi.reserved,"i8"),i16:new Xo("i16",Yi.reserved,"i16"),i64:new Xo("i64",Yi.reserved,"i64"),mat:new Xo("mat",Yi.reserved,"mat"),premerge:new Xo("premerge",Yi.reserved,"premerge"),regardless:new Xo("regardless",Yi.reserved,"regardless"),typedef:new Xo("typedef",Yi.reserved,"typedef"),u8:new Xo("u8",Yi.reserved,"u8"),u16:new Xo("u16",Yi.reserved,"u16"),u64:new Xo("u64",Yi.reserved,"u64"),unless:new Xo("unless",Yi.reserved,"unless"),using:new Xo("using",Yi.reserved,"using"),vec:new Xo("vec",Yi.reserved,"vec"),void:new Xo("void",Yi.reserved,"void")},qo.keywords={array:new Xo("array",Yi.keyword,"array"),atomic:new Xo("atomic",Yi.keyword,"atomic"),bool:new Xo("bool",Yi.keyword,"bool"),f32:new Xo("f32",Yi.keyword,"f32"),i32:new Xo("i32",Yi.keyword,"i32"),mat2x2:new Xo("mat2x2",Yi.keyword,"mat2x2"),mat2x3:new Xo("mat2x3",Yi.keyword,"mat2x3"),mat2x4:new Xo("mat2x4",Yi.keyword,"mat2x4"),mat3x2:new Xo("mat3x2",Yi.keyword,"mat3x2"),mat3x3:new Xo("mat3x3",Yi.keyword,"mat3x3"),mat3x4:new Xo("mat3x4",Yi.keyword,"mat3x4"),mat4x2:new Xo("mat4x2",Yi.keyword,"mat4x2"),mat4x3:new Xo("mat4x3",Yi.keyword,"mat4x3"),mat4x4:new Xo("mat4x4",Yi.keyword,"mat4x4"),ptr:new Xo("ptr",Yi.keyword,"ptr"),sampler:new Xo("sampler",Yi.keyword,"sampler"),sampler_comparison:new Xo("sampler_comparison",Yi.keyword,"sampler_comparison"),struct:new Xo("struct",Yi.keyword,"struct"),texture_1d:new Xo("texture_1d",Yi.keyword,"texture_1d"),texture_2d:new Xo("texture_2d",Yi.keyword,"texture_2d"),texture_2d_array:new Xo("texture_2d_array",Yi.keyword,"texture_2d_array"),texture_3d:new Xo("texture_3d",Yi.keyword,"texture_3d"),texture_cube:new Xo("texture_cube",Yi.keyword,"texture_cube"),texture_cube_array:new Xo("texture_cube_array",Yi.keyword,"texture_cube_array"),texture_multisampled_2d:new Xo("texture_multisampled_2d",Yi.keyword,"texture_multisampled_2d"),texture_storage_1d:new Xo("texture_storage_1d",Yi.keyword,"texture_storage_1d"),texture_storage_2d:new Xo("texture_storage_2d",Yi.keyword,"texture_storage_2d"),texture_storage_2d_array:new Xo("texture_storage_2d_array",Yi.keyword,"texture_storage_2d_array"),texture_storage_3d:new Xo("texture_storage_3d",Yi.keyword,"texture_storage_3d"),texture_depth_2d:new Xo("texture_depth_2d",Yi.keyword,"texture_depth_2d"),texture_depth_2d_array:new Xo("texture_depth_2d_array",Yi.keyword,"texture_depth_2d_array"),texture_depth_cube:new Xo("texture_depth_cube",Yi.keyword,"texture_depth_cube"),texture_depth_cube_array:new Xo("texture_depth_cube_array",Yi.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new Xo("texture_depth_multisampled_2d",Yi.keyword,"texture_depth_multisampled_2d"),texture_external:new Xo("texture_external",Yi.keyword,"texture_external"),u32:new Xo("u32",Yi.keyword,"u32"),vec2:new Xo("vec2",Yi.keyword,"vec2"),vec3:new Xo("vec3",Yi.keyword,"vec3"),vec4:new Xo("vec4",Yi.keyword,"vec4"),bitcast:new Xo("bitcast",Yi.keyword,"bitcast"),block:new Xo("block",Yi.keyword,"block"),break:new Xo("break",Yi.keyword,"break"),case:new Xo("case",Yi.keyword,"case"),continue:new Xo("continue",Yi.keyword,"continue"),continuing:new Xo("continuing",Yi.keyword,"continuing"),default:new Xo("default",Yi.keyword,"default"),diagnostic:new Xo("diagnostic",Yi.keyword,"diagnostic"),discard:new Xo("discard",Yi.keyword,"discard"),else:new Xo("else",Yi.keyword,"else"),enable:new Xo("enable",Yi.keyword,"enable"),fallthrough:new Xo("fallthrough",Yi.keyword,"fallthrough"),false:new Xo("false",Yi.keyword,"false"),fn:new Xo("fn",Yi.keyword,"fn"),for:new Xo("for",Yi.keyword,"for"),function:new Xo("function",Yi.keyword,"function"),if:new Xo("if",Yi.keyword,"if"),let:new Xo("let",Yi.keyword,"let"),const:new Xo("const",Yi.keyword,"const"),loop:new Xo("loop",Yi.keyword,"loop"),while:new Xo("while",Yi.keyword,"while"),private:new Xo("private",Yi.keyword,"private"),read:new Xo("read",Yi.keyword,"read"),read_write:new Xo("read_write",Yi.keyword,"read_write"),return:new Xo("return",Yi.keyword,"return"),requires:new Xo("requires",Yi.keyword,"requires"),storage:new Xo("storage",Yi.keyword,"storage"),switch:new Xo("switch",Yi.keyword,"switch"),true:new Xo("true",Yi.keyword,"true"),alias:new Xo("alias",Yi.keyword,"alias"),type:new Xo("type",Yi.keyword,"type"),uniform:new Xo("uniform",Yi.keyword,"uniform"),var:new Xo("var",Yi.keyword,"var"),override:new Xo("override",Yi.keyword,"override"),workgroup:new Xo("workgroup",Yi.keyword,"workgroup"),write:new Xo("write",Yi.keyword,"write"),r8unorm:new Xo("r8unorm",Yi.keyword,"r8unorm"),r8snorm:new Xo("r8snorm",Yi.keyword,"r8snorm"),r8uint:new Xo("r8uint",Yi.keyword,"r8uint"),r8sint:new Xo("r8sint",Yi.keyword,"r8sint"),r16uint:new Xo("r16uint",Yi.keyword,"r16uint"),r16sint:new Xo("r16sint",Yi.keyword,"r16sint"),r16float:new Xo("r16float",Yi.keyword,"r16float"),rg8unorm:new Xo("rg8unorm",Yi.keyword,"rg8unorm"),rg8snorm:new Xo("rg8snorm",Yi.keyword,"rg8snorm"),rg8uint:new Xo("rg8uint",Yi.keyword,"rg8uint"),rg8sint:new Xo("rg8sint",Yi.keyword,"rg8sint"),r32uint:new Xo("r32uint",Yi.keyword,"r32uint"),r32sint:new Xo("r32sint",Yi.keyword,"r32sint"),r32float:new Xo("r32float",Yi.keyword,"r32float"),rg16uint:new Xo("rg16uint",Yi.keyword,"rg16uint"),rg16sint:new Xo("rg16sint",Yi.keyword,"rg16sint"),rg16float:new Xo("rg16float",Yi.keyword,"rg16float"),rgba8unorm:new Xo("rgba8unorm",Yi.keyword,"rgba8unorm"),rgba8unorm_srgb:new Xo("rgba8unorm_srgb",Yi.keyword,"rgba8unorm_srgb"),rgba8snorm:new Xo("rgba8snorm",Yi.keyword,"rgba8snorm"),rgba8uint:new Xo("rgba8uint",Yi.keyword,"rgba8uint"),rgba8sint:new Xo("rgba8sint",Yi.keyword,"rgba8sint"),bgra8unorm:new Xo("bgra8unorm",Yi.keyword,"bgra8unorm"),bgra8unorm_srgb:new Xo("bgra8unorm_srgb",Yi.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new Xo("rgb10a2unorm",Yi.keyword,"rgb10a2unorm"),rg11b10float:new Xo("rg11b10float",Yi.keyword,"rg11b10float"),rg32uint:new Xo("rg32uint",Yi.keyword,"rg32uint"),rg32sint:new Xo("rg32sint",Yi.keyword,"rg32sint"),rg32float:new Xo("rg32float",Yi.keyword,"rg32float"),rgba16uint:new Xo("rgba16uint",Yi.keyword,"rgba16uint"),rgba16sint:new Xo("rgba16sint",Yi.keyword,"rgba16sint"),rgba16float:new Xo("rgba16float",Yi.keyword,"rgba16float"),rgba32uint:new Xo("rgba32uint",Yi.keyword,"rgba32uint"),rgba32sint:new Xo("rgba32sint",Yi.keyword,"rgba32sint"),rgba32float:new Xo("rgba32float",Yi.keyword,"rgba32float"),static_assert:new Xo("static_assert",Yi.keyword,"static_assert")},qo.tokens={decimal_float_literal:new Xo("decimal_float_literal",Yi.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new Xo("hex_float_literal",Yi.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new Xo("int_literal",Yi.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new Xo("uint_literal",Yi.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new Xo("name",Yi.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new Xo("ident",Yi.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new Xo("and",Yi.token,"&"),and_and:new Xo("and_and",Yi.token,"&&"),arrow:new Xo("arrow ",Yi.token,"->"),attr:new Xo("attr",Yi.token,"@"),forward_slash:new Xo("forward_slash",Yi.token,"/"),bang:new Xo("bang",Yi.token,"!"),bracket_left:new Xo("bracket_left",Yi.token,"["),bracket_right:new Xo("bracket_right",Yi.token,"]"),brace_left:new Xo("brace_left",Yi.token,"{"),brace_right:new Xo("brace_right",Yi.token,"}"),colon:new Xo("colon",Yi.token,":"),comma:new Xo("comma",Yi.token,","),equal:new Xo("equal",Yi.token,"="),equal_equal:new Xo("equal_equal",Yi.token,"=="),not_equal:new Xo("not_equal",Yi.token,"!="),greater_than:new Xo("greater_than",Yi.token,">"),greater_than_equal:new Xo("greater_than_equal",Yi.token,">="),shift_right:new Xo("shift_right",Yi.token,">>"),less_than:new Xo("less_than",Yi.token,"<"),less_than_equal:new Xo("less_than_equal",Yi.token,"<="),shift_left:new Xo("shift_left",Yi.token,"<<"),modulo:new Xo("modulo",Yi.token,"%"),minus:new Xo("minus",Yi.token,"-"),minus_minus:new Xo("minus_minus",Yi.token,"--"),period:new Xo("period",Yi.token,"."),plus:new Xo("plus",Yi.token,"+"),plus_plus:new Xo("plus_plus",Yi.token,"++"),or:new Xo("or",Yi.token,"|"),or_or:new Xo("or_or",Yi.token,"||"),paren_left:new Xo("paren_left",Yi.token,"("),paren_right:new Xo("paren_right",Yi.token,")"),semicolon:new Xo("semicolon",Yi.token,";"),star:new Xo("star",Yi.token,"*"),tilde:new Xo("tilde",Yi.token,"~"),underscore:new Xo("underscore",Yi.token,"_"),xor:new Xo("xor",Yi.token,"^"),plus_equal:new Xo("plus_equal",Yi.token,"+="),minus_equal:new Xo("minus_equal",Yi.token,"-="),times_equal:new Xo("times_equal",Yi.token,"*="),division_equal:new Xo("division_equal",Yi.token,"/="),modulo_equal:new Xo("modulo_equal",Yi.token,"%="),and_equal:new Xo("and_equal",Yi.token,"&="),or_equal:new Xo("or_equal",Yi.token,"|="),xor_equal:new Xo("xor_equal",Yi.token,"^="),shift_right_equal:new Xo("shift_right_equal",Yi.token,">>="),shift_left_equal:new Xo("shift_left_equal",Yi.token,"<<=")},qo.simpleTokens={"@":qi.tokens.attr,"{":qi.tokens.brace_left,"}":qi.tokens.brace_right,":":qi.tokens.colon,",":qi.tokens.comma,"(":qi.tokens.paren_left,")":qi.tokens.paren_right,";":qi.tokens.semicolon},qo.literalTokens={"&":qi.tokens.and,"&&":qi.tokens.and_and,"->":qi.tokens.arrow,"/":qi.tokens.forward_slash,"!":qi.tokens.bang,"[":qi.tokens.bracket_left,"]":qi.tokens.bracket_right,"=":qi.tokens.equal,"==":qi.tokens.equal_equal,"!=":qi.tokens.not_equal,">":qi.tokens.greater_than,">=":qi.tokens.greater_than_equal,">>":qi.tokens.shift_right,"<":qi.tokens.less_than,"<=":qi.tokens.less_than_equal,"<<":qi.tokens.shift_left,"%":qi.tokens.modulo,"-":qi.tokens.minus,"--":qi.tokens.minus_minus,".":qi.tokens.period,"+":qi.tokens.plus,"++":qi.tokens.plus_plus,"|":qi.tokens.or,"||":qi.tokens.or_or,"*":qi.tokens.star,"~":qi.tokens.tilde,_:qi.tokens.underscore,"^":qi.tokens.xor,"+=":qi.tokens.plus_equal,"-=":qi.tokens.minus_equal,"*=":qi.tokens.times_equal,"/=":qi.tokens.division_equal,"%=":qi.tokens.modulo_equal,"&=":qi.tokens.and_equal,"|=":qi.tokens.or_equal,"^=":qi.tokens.xor_equal,">>=":qi.tokens.shift_right_equal,"<<=":qi.tokens.shift_left_equal},qo.regexTokens={decimal_float_literal:qi.tokens.decimal_float_literal,hex_float_literal:qi.tokens.hex_float_literal,int_literal:qi.tokens.int_literal,uint_literal:qi.tokens.uint_literal,ident:qi.tokens.ident},qo.storage_class=[qi.keywords.function,qi.keywords.private,qi.keywords.workgroup,qi.keywords.uniform,qi.keywords.storage],qo.access_mode=[qi.keywords.read,qi.keywords.write,qi.keywords.read_write],qo.sampler_type=[qi.keywords.sampler,qi.keywords.sampler_comparison],qo.sampled_texture_type=[qi.keywords.texture_1d,qi.keywords.texture_2d,qi.keywords.texture_2d_array,qi.keywords.texture_3d,qi.keywords.texture_cube,qi.keywords.texture_cube_array],qo.multisampled_texture_type=[qi.keywords.texture_multisampled_2d],qo.storage_texture_type=[qi.keywords.texture_storage_1d,qi.keywords.texture_storage_2d,qi.keywords.texture_storage_2d_array,qi.keywords.texture_storage_3d],qo.depth_texture_type=[qi.keywords.texture_depth_2d,qi.keywords.texture_depth_2d_array,qi.keywords.texture_depth_cube,qi.keywords.texture_depth_cube_array,qi.keywords.texture_depth_multisampled_2d],qo.texture_external_type=[qi.keywords.texture_external],qo.any_texture_type=[...qi.sampled_texture_type,...qi.multisampled_texture_type,...qi.storage_texture_type,...qi.depth_texture_type,...qi.texture_external_type],qo.texel_format=[qi.keywords.r8unorm,qi.keywords.r8snorm,qi.keywords.r8uint,qi.keywords.r8sint,qi.keywords.r16uint,qi.keywords.r16sint,qi.keywords.r16float,qi.keywords.rg8unorm,qi.keywords.rg8snorm,qi.keywords.rg8uint,qi.keywords.rg8sint,qi.keywords.r32uint,qi.keywords.r32sint,qi.keywords.r32float,qi.keywords.rg16uint,qi.keywords.rg16sint,qi.keywords.rg16float,qi.keywords.rgba8unorm,qi.keywords.rgba8unorm_srgb,qi.keywords.rgba8snorm,qi.keywords.rgba8uint,qi.keywords.rgba8sint,qi.keywords.bgra8unorm,qi.keywords.bgra8unorm_srgb,qi.keywords.rgb10a2unorm,qi.keywords.rg11b10float,qi.keywords.rg32uint,qi.keywords.rg32sint,qi.keywords.rg32float,qi.keywords.rgba16uint,qi.keywords.rgba16sint,qi.keywords.rgba16float,qi.keywords.rgba32uint,qi.keywords.rgba32sint,qi.keywords.rgba32float],qo.const_literal=[qi.tokens.int_literal,qi.tokens.uint_literal,qi.tokens.decimal_float_literal,qi.tokens.hex_float_literal,qi.keywords.true,qi.keywords.false],qo.literal_or_ident=[qi.tokens.ident,qi.tokens.int_literal,qi.tokens.uint_literal,qi.tokens.decimal_float_literal,qi.tokens.hex_float_literal,qi.tokens.name],qo.element_count_expression=[qi.tokens.int_literal,qi.tokens.uint_literal,qi.tokens.ident],qo.template_types=[qi.keywords.vec2,qi.keywords.vec3,qi.keywords.vec4,qi.keywords.mat2x2,qi.keywords.mat2x3,qi.keywords.mat2x4,qi.keywords.mat3x2,qi.keywords.mat3x3,qi.keywords.mat3x4,qi.keywords.mat4x2,qi.keywords.mat4x3,qi.keywords.mat4x4,qi.keywords.atomic,qi.keywords.bitcast,...qi.any_texture_type],qo.attribute_name=[qi.tokens.ident,qi.keywords.block,qi.keywords.diagnostic],qo.assignment_operators=[qi.tokens.equal,qi.tokens.plus_equal,qi.tokens.minus_equal,qi.tokens.times_equal,qi.tokens.division_equal,qi.tokens.modulo_equal,qi.tokens.and_equal,qi.tokens.or_equal,qi.tokens.xor_equal,qi.tokens.shift_right_equal,qi.tokens.shift_left_equal],qo.increment_operators=[qi.tokens.plus_plus,qi.tokens.minus_minus];class Yo{constructor(e,t,n,s,r){this.type=e,this.lexeme=t,this.line=n,this.start=s,this.end=r}toString(){return this.lexeme}isTemplateType(){return-1!=qo.template_types.indexOf(this.type)}isArrayType(){return this.type==qo.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class Ko{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=null!=e?e:""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Yo(qo.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if("\n"==e)return this._line++,!0;if(this._isWhitespace(e))return!0;if("/"==e){if("/"==this._peekAhead()){for(;"\n"!=e;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}if("*"==this._peekAhead()){this._advance();let t=1;for(;t>0;){if(this._isAtEnd())return!0;if(e=this._advance(),"\n"==e)this._line++;else if("*"==e){if("/"==this._peekAhead()&&(this._advance(),t--,0==t))return!0}else"/"==e&&"*"==this._peekAhead()&&(this._advance(),t++)}return!0}}const t=qo.simpleTokens[e];if(t)return this._addToken(t),!0;let n=qo.none;const s=this._isAlpha(e),r="_"===e;if(this._isAlphaNumeric(e)){let t=this._peekAhead();for(;this._isAlphaNumeric(t);)e+=this._advance(),t=this._peekAhead()}if(s){const t=qo.keywords[e];if(t)return this._addToken(t),!0}if(s||r)return this._addToken(qo.tokens.ident),!0;for(;;){let t=this._findType(e);const s=this._peekAhead();if("-"==e&&this._tokens.length>0){if("="==s)return this._current++,e+=s,this._addToken(qo.tokens.minus_equal),!0;if("-"==s)return this._current++,e+=s,this._addToken(qo.tokens.minus_minus),!0;const n=this._tokens.length-1;if((-1!=qo.literal_or_ident.indexOf(this._tokens[n].type)||this._tokens[n].type==qo.tokens.paren_right)&&">"!=s)return this._addToken(t),!0}if(">"==e&&(">"==s||"="==s)){let e=!1,n=this._tokens.length-1;for(let t=0;t<5&&n>=0&&-1===qo.assignment_operators.indexOf(this._tokens[n].type);++t,--n)if(this._tokens[n].type===qo.tokens.less_than){n>0&&this._tokens[n-1].isArrayOrTemplateType()&&(e=!0);break}if(e)return this._addToken(t),!0}if(t===qo.none){let s=e,r=0;const i=2;for(let e=0;e=this._source.length}_isAlpha(e){return!this._isNumeric(e)&&!this._isWhitespace(e)&&"_"!==e&&"."!==e&&"("!==e&&")"!==e&&"["!==e&&"]"!==e&&"{"!==e&&"}"!==e&&","!==e&&";"!==e&&":"!==e&&"="!==e&&"!"!==e&&"<"!==e&&">"!==e&&"+"!==e&&"-"!==e&&"*"!==e&&"/"!==e&&"%"!==e&&"&"!==e&&"|"!==e&&"^"!==e&&"~"!==e&&"@"!==e&&"#"!==e&&"?"!==e&&"'"!==e&&"`"!==e&&'"'!==e&&"\\"!==e&&"\n"!==e&&"\r"!==e&&"\t"!==e&&"\0"!==e}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||"_"===e}_isWhitespace(e){return" "==e||"\t"==e||"\r"==e}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const t=this._source.substring(this._start,this._current);this._tokens.push(new Yo(e,t,this._line,this._start,this._current))}}function Zo(e){return Array.isArray(e)||(null==e?void 0:e.buffer)instanceof ArrayBuffer}const Qo=new Float32Array(1),Jo=new Uint32Array(Qo.buffer),ea=new Uint32Array(Qo.buffer),ta=new Int32Array(1),na=new Float32Array(ta.buffer),sa=new Uint32Array(ta.buffer),ra=new Uint32Array(1),ia=new Float32Array(ra.buffer),oa=new Int32Array(ra.buffer);function aa(e,t,n){if(t===n)return e;if("f32"===t){if("i32"===n||"x32"===n)return Qo[0]=e,Jo[0];if("u32"===n)return Qo[0]=e,ea[0]}else if("i32"===t||"x32"===t){if("f32"===n)return ta[0]=e,na[0];if("u32"===n)return ta[0]=e,sa[0]}else if("u32"===t){if("f32"===n)return ra[0]=e,ia[0];if("i32"===n||"x32"===n)return ra[0]=e,oa[0]}return e}class la{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class ca{constructor(e,t){this.align=e,this.size=t}}class ua{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new vi,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return"texture_storage_1d"==e.name||"texture_storage_2d"==e.name||"texture_storage_2d_array"==e.name||"texture_storage_3d"==e.name}updateAST(e){for(const t of e)t instanceof Di&&this._functions.set(t.name,new la(t));for(const t of e)if(t instanceof fo){const e=this.getTypeInfo(t,null);e instanceof ai&&this.structs.push(e)}for(const t of e)if(t instanceof oo)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof zi){const e=t,n=this._getAttributeNum(e.attributes,"id",0),s=null!=e.type?this.getTypeInfo(e.type,e.attributes):null;this.overrides.push(new _i(e.name,s,e.attributes,n));continue}if(this._isUniformVar(t)){const e=t,n=this._getAttributeNum(e.attributes,"group",0),s=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),i=new fi(e.name,r,n,s,e.attributes,hi.Uniform,e.access);i.access||(i.access="read"),this.uniforms.push(i);continue}if(this._isStorageVar(t)){const e=t,n=this._getAttributeNum(e.attributes,"group",0),s=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),i=this._isStorageTexture(r),o=new fi(e.name,r,n,s,e.attributes,i?hi.StorageTexture:hi.Storage,e.access);o.access||(o.access="read"),this.storage.push(o);continue}if(this._isTextureVar(t)){const e=t,n=this._getAttributeNum(e.attributes,"group",0),s=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),i=this._isStorageTexture(r),o=new fi(e.name,r,n,s,e.attributes,i?hi.StorageTexture:hi.Texture,e.access);o.access||(o.access="read"),i?this.storage.push(o):this.textures.push(o);continue}if(this._isSamplerVar(t)){const e=t,n=this._getAttributeNum(e.attributes,"group",0),s=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),i=new fi(e.name,r,n,s,e.attributes,hi.Sampler,e.access);this.samplers.push(i);continue}}for(const t of e)if(t instanceof Di){const e=this._getAttribute(t,"vertex"),n=this._getAttribute(t,"fragment"),s=this._getAttribute(t,"compute"),r=e||n||s,i=new bi(t.name,null==r?void 0:r.name,t.attributes);i.attributes=t.attributes,i.startLine=t.startLine,i.endLine=t.endLine,this.functions.push(i),this._functions.get(t.name).info=i,r&&(this._functions.get(t.name).inUse=!0,i.inUse=!0,i.resources=this._findResources(t,!!r),i.inputs=this._getInputs(t.args),i.outputs=this._getOutputs(t.returnType),this.entry[r.name].push(i)),i.arguments=t.args.map(e=>new yi(e.name,this.getTypeInfo(e.type,e.attributes),e.attributes)),i.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(const t of this._functions.values())t.info&&(t.info.inUse=t.inUse,this._addCalls(t.node,t.info.calls));for(const t of this._functions.values())t.node.search(e=>{var n,s,r;if(e instanceof Do){if(e.value)if(Zo(e.value))for(const i of e.value)for(const e of this.overrides)i===e.name&&(null===(n=t.info)||void 0===n||n.overrides.push(e));else for(const i of this.overrides)e.value===i.name&&(null===(s=t.info)||void 0===s||s.overrides.push(i))}else if(e instanceof wo)for(const i of this.overrides)e.name===i.name&&(null===(r=t.info)||void 0===r||r.overrides.push(i))});for(const t of this.uniforms)this._markStructsInUse(t.type);for(const t of this.storage)this._markStructsInUse(t.type)}getFunctionInfo(e){for(const t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(const t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(const t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var n;for(const s of e.calls){const e=null===(n=this._functions.get(s.name))||void 0===n?void 0:n.info;e&&t.add(e)}}findResource(e,t,n){if(n){for(const s of this.entry.compute)if(s.name===n)for(const n of s.resources)if(n.group==e&&n.binding==t)return n;for(const s of this.entry.vertex)if(s.name===n)for(const n of s.resources)if(n.group==e&&n.binding==t)return n;for(const s of this.entry.fragment)if(s.name===n)for(const n of s.resources)if(n.group==e&&n.binding==t)return n}for(const s of this.uniforms)if(s.group==e&&s.binding==t)return s;for(const s of this.storage)if(s.group==e&&s.binding==t)return s;for(const s of this.textures)if(s.group==e&&s.binding==t)return s;for(const s of this.samplers)if(s.group==e&&s.binding==t)return s;return null}_findResource(e){for(const t of this.uniforms)if(t.name==e)return t;for(const t of this.storage)if(t.name==e)return t;for(const t of this.textures)if(t.name==e)return t;for(const t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){const t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){const n=[],s=this,r=[];return e.search(i=>{if(i instanceof Li)r.push({});else if(i instanceof Ni)r.pop();else if(i instanceof Vi){const e=i;t&&null!==e.type&&this._markStructsFromAST(e.type),r.length>0&&(r[r.length-1][e.name]=e)}else if(i instanceof vo){const e=i;t&&null!==e.type&&this._markStructsFromAST(e.type)}else if(i instanceof Wi){const e=i;t&&null!==e.type&&this._markStructsFromAST(e.type),r.length>0&&(r[r.length-1][e.name]=e)}else if(i instanceof wo){const e=i;if(r.length>0&&r[r.length-1][e.name])return;const t=s._findResource(e.name);t&&n.push(t)}else if(i instanceof xo){const r=i,o=s._functions.get(r.name);o&&(t&&(o.inUse=!0),e.calls.add(o.node),null===o.resources&&(o.resources=s._findResources(o.node,t)),n.push(...o.resources))}else if(i instanceof Qi){const r=i,o=s._functions.get(r.name);o&&(t&&(o.inUse=!0),e.calls.add(o.node),null===o.resources&&(o.resources=s._findResources(o.node,t)),n.push(...o.resources))}}),[...new Map(n.map(e=>[e.name,e])).values()]}getBindGroups(){const e=[];function t(t,n){t>=e.length&&(e.length=t+1),void 0===e[t]&&(e[t]=[]),n>=e[t].length&&(e[t].length=n+1)}for(const n of this.uniforms)t(n.group,n.binding),e[n.group][n.binding]=n;for(const n of this.storage)t(n.group,n.binding),e[n.group][n.binding]=n;for(const n of this.textures)t(n.group,n.binding),e[n.group][n.binding]=n;for(const n of this.samplers)t(n.group,n.binding),e[n.group][n.binding]=n;return e}_getOutputs(e,t=void 0){if(void 0===t&&(t=[]),e instanceof fo)this._getStructOutputs(e,t);else{const n=this._getOutputInfo(e);null!==n&&t.push(n)}return t}_getStructOutputs(e,t){for(const n of e.members)if(n.type instanceof fo)this._getStructOutputs(n.type,t);else{const e=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(null!==e){const s=this.getTypeInfo(n.type,n.type.attributes),r=this._parseInt(e.value),i=new mi(n.name,s,e.name,r);t.push(i)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const n=this.getTypeInfo(e,e.attributes),s=this._parseInt(t.value);return new mi("",n,t.name,s)}return null}_getInputs(e,t=void 0){void 0===t&&(t=[]);for(const n of e)if(n.type instanceof fo)this._getStructInputs(n.type,t);else{const e=this._getInputInfo(n);null!==e&&t.push(e)}return t}_getStructInputs(e,t){for(const n of e.members)if(n.type instanceof fo)this._getStructInputs(n.type,t);else{const e=this._getInputInfo(n);null!==e&&t.push(e)}}_getInputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const n=this._getAttribute(e,"interpolation"),s=this.getTypeInfo(e.type,e.attributes),r=this._parseInt(t.value),i=new gi(e.name,s,t.name,r);return null!==n&&(i.interpolation=this._parseString(n.value)),i}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(const t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new pi(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const t of this.structs)if(t.name==e)return t;for(const t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof go){const n=e.type?this.getTypeInfo(e.type,e.attributes):null,s=new ci(e.name,n,t);return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof mo){const n=e,s=n.format?this.getTypeInfo(n.format,n.attributes):null,r=new li(n.name,t);return r.format=s,r.count=n.count,this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof fo){const n=e,s=new ai(n.name,t);s.startLine=n.startLine,s.endLine=n.endLine;for(const e of n.members){const t=this.getTypeInfo(e.type,e.attributes);s.members.push(new oi(e.name,t,e.attributes))}return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof _o){const n=e,s=n.format instanceof uo,r=n.format?s?this.getTypeInfo(n.format,null):new ii(n.format,null):null,i=new ui(n.name,r,t,n.access);return this._types.set(e,i),this._updateTypeInfo(i),i}if(e instanceof po){const n=e,s=n.format?this.getTypeInfo(n.format,null):null,r=new ui(n.name,s,t,n.access);return this._types.set(e,r),this._updateTypeInfo(r),r}const n=new ii(e.name,t);return this._types.set(e,n),this._updateTypeInfo(n),n}_updateTypeInfo(e){var t,n,s;const r=this._getTypeSize(e);if(e.size=null!==(t=null==r?void 0:r.size)&&void 0!==t?t:0,e instanceof li&&e.format){const t=this._getTypeSize(e.format);e.stride=Math.max(null!==(n=null==t?void 0:t.size)&&void 0!==n?n:0,null!==(s=null==t?void 0:t.align)&&void 0!==s?s:0),this._updateTypeInfo(e.format)}e instanceof ci&&this._updateTypeInfo(e.format),e instanceof ai&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let n=0,s=0,r=0,i=0;for(let o=0,a=e.members.length;oe.name),ua._samplerTypes=qo.sampler_type.map(e=>e.name);let ha=0;class da{constructor(e,t,n){this.id=ha++,this.name=e,this.value=t,this.node=n}clone(){return new da(this.name,this.value,this.node)}}class fa{constructor(e){this.id=ha++,this.name=e.name,this.node=e}clone(){return new fa(this.node)}}class pa{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=ha++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?null!==(t=this.variables.get(e))&&void 0!==t?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?null!==(t=this.functions.get(e))&&void 0!==t?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,n){this.variables.set(e,new da(e,t,null!=n?n:null))}setVariable(e,t,n){const s=this.getVariable(e);null!==s?s.value=t:this.createVariable(e,t,n)}getVariableValue(e){var t;const n=this.getVariable(e);return null!==(t=null==n?void 0:n.value)&&void 0!==t?t:null}clone(){return new pa(this)}}class ga{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class ma{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){const n=this.exec.evalExpression(e.args[0],t);let s=!0;if(n instanceof zo)return n.data.forEach(e=>{e||(s=!1)}),new Go(s?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo){const e=n.data.some(e=>e);return new Go(e?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){const n=this.exec.evalExpression(e.args[2],t);if(!(n instanceof Go))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return n.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.evalExpression(n,t);if(s instanceof Ho&&0===s.typeInfo.size){const e=s.typeInfo,t=s.buffer.byteLength/e.stride;return new Go(t,this.getTypeInfo("u32"))}return new Go(s.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.abs(e)),n.typeInfo);const s=n;return new Go(Math.abs(s.value),s.typeInfo)}Acos(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.acos(e)),n.typeInfo);const s=n;return new Go(Math.acos(s.value),n.typeInfo)}Acosh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.acosh(e)),n.typeInfo);const s=n;return new Go(Math.acosh(s.value),n.typeInfo)}Asin(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.asin(e)),n.typeInfo);const s=n;return new Go(Math.asin(s.value),n.typeInfo)}Asinh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.asinh(e)),n.typeInfo);const s=n;return new Go(Math.asinh(s.value),n.typeInfo)}Atan(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.atan(e)),n.typeInfo);const s=n;return new Go(Math.atan(s.value),n.typeInfo)}Atanh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.atanh(e)),n.typeInfo);const s=n;return new Go(Math.atanh(s.value),n.typeInfo)}Atan2(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof zo&&s instanceof zo)return new zo(n.data.map((e,t)=>Math.atan2(e,s.data[t])),n.typeInfo);const r=n,i=s;return new Go(Math.atan2(r.value,i.value),n.typeInfo)}Ceil(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.ceil(e)),n.typeInfo);const s=n;return new Go(Math.ceil(s.value),n.typeInfo)}_clamp(e,t,n){return Math.min(Math.max(e,t),n)}Clamp(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(n instanceof zo&&s instanceof zo&&r instanceof zo)return new zo(n.data.map((e,t)=>this._clamp(e,s.data[t],r.data[t])),n.typeInfo);const i=n,o=s,a=r;return new Go(this._clamp(i.value,o.value,a.value),n.typeInfo)}Cos(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.cos(e)),n.typeInfo);const s=n;return new Go(Math.cos(s.value),n.typeInfo)}Cosh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.cosh(e)),n.typeInfo);const s=n;return new Go(Math.cos(s.value),n.typeInfo)}CountLeadingZeros(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.clz32(e)),n.typeInfo);const s=n;return new Go(Math.clz32(s.value),n.typeInfo)}_countOneBits(e){let t=0;for(;0!==e;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>this._countOneBits(e)),n.typeInfo);const s=n;return new Go(this._countOneBits(s.value),n.typeInfo)}_countTrailingZeros(e){if(0===e)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>this._countTrailingZeros(e)),n.typeInfo);const s=n;return new Go(this._countTrailingZeros(s.value),n.typeInfo)}Cross(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof zo&&s instanceof zo){if(3!==n.data.length||3!==s.data.length)return null;const e=n.data,t=s.data;return new zo([e[1]*t[2]-t[1]*e[2],e[2]*t[0]-t[2]*e[0],e[0]*t[1]-t[0]*e[1]],n.typeInfo)}return null}Degrees(e,t){const n=this.exec.evalExpression(e.args[0],t),s=180/Math.PI;return n instanceof zo?new zo(n.data.map(e=>e*s),n.typeInfo):new Go(n.value*s,this.getTypeInfo("f32"))}Determinant(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof Wo){const e=n.data,t=n.typeInfo.getTypeName(),s=t.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t)return new Go(e[0]*e[3]-e[1]*e[2],s);if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t)return new Go(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),s);if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t);else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t);else if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t)return new Go(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),s)}return null}Distance(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof zo&&s instanceof zo){let e=0;for(let t=0;tMath.exp(e)),n.typeInfo);const s=n;return new Go(Math.exp(s.value),n.typeInfo)}Exp2(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.pow(2,e)),n.typeInfo);const s=n;return new Go(Math.pow(2,s.value),n.typeInfo)}ExtractBits(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if("u32"!==s.typeInfo.name&&"x32"!==s.typeInfo.name)return null;if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return null;const i=s.value,o=r.value;if(n instanceof zo)return new zo(n.data.map(e=>e>>i&(1<>i&(1<-e),n.typeInfo)}return null}_firstLeadingBit(e){return 0===e?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>this._firstLeadingBit(e)),n.typeInfo);const s=n;return new Go(this._firstLeadingBit(s.value),n.typeInfo)}_firstTrailingBit(e){return 0===e?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>this._firstTrailingBit(e)),n.typeInfo);const s=n;return new Go(this._firstTrailingBit(s.value),n.typeInfo)}Floor(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.floor(e)),n.typeInfo);const s=n;return new Go(Math.floor(s.value),n.typeInfo)}Fma(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(n instanceof zo&&s instanceof zo&&r instanceof zo)return n.data.length!==s.data.length||n.data.length!==r.data.length?null:new zo(n.data.map((e,t)=>e*s.data[t]+r.data[t]),n.typeInfo);const i=n,o=s,a=r;return new Go(i.value*o.value+a.value,i.typeInfo)}Fract(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>e-Math.floor(e)),n.typeInfo);const s=n;return new Go(s.value-Math.floor(s.value),n.typeInfo)}Frexp(e,t){return null}InsertBits(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t),i=this.exec.evalExpression(e.args[3],t);if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return null;const o=r.value,a=(1<e&l|s.data[t]<1/Math.sqrt(e)),n.typeInfo);const s=n;return new Go(1/Math.sqrt(s.value),n.typeInfo)}Ldexp(e,t){return null}Length(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo){let e=0;return n.data.forEach(t=>{e+=t*t}),new Go(Math.sqrt(e),this.getTypeInfo("f32"))}const s=n;return new Go(Math.abs(s.value),n.typeInfo)}Log(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.log(e)),n.typeInfo);const s=n;return new Go(Math.log(s.value),n.typeInfo)}Log2(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.log2(e)),n.typeInfo);const s=n;return new Go(Math.log2(s.value),n.typeInfo)}Max(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof zo&&s instanceof zo)return new zo(n.data.map((e,t)=>Math.max(e,s.data[t])),n.typeInfo);const r=n,i=s;return new Go(Math.max(r.value,i.value),n.typeInfo)}Min(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof zo&&s instanceof zo)return new zo(n.data.map((e,t)=>Math.min(e,s.data[t])),n.typeInfo);const r=n,i=s;return new Go(Math.min(r.value,i.value),n.typeInfo)}Mix(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(n instanceof zo&&s instanceof zo&&r instanceof zo)return new zo(n.data.map((e,t)=>n.data[t]*(1-r.data[t])+s.data[t]*r.data[t]),n.typeInfo);const i=s,o=r;return new Go(n.value*(1-o.value)+i.value*o.value,n.typeInfo)}Modf(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof zo&&s instanceof zo)return new zo(n.data.map((e,t)=>e%s.data[t]),n.typeInfo);const r=s;return new Go(n.value%r.value,n.typeInfo)}Normalize(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo){const s=this.Length(e,t).value;return new zo(n.data.map(e=>e/s),n.typeInfo)}return null}Pow(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof zo&&s instanceof zo)return new zo(n.data.map((e,t)=>Math.pow(e,s.data[t])),n.typeInfo);const r=n,i=s;return new Go(Math.pow(r.value,i.value),n.typeInfo)}QuantizeToF16(e,t){const n=this.exec.evalExpression(e.args[0],t);return n instanceof zo?new zo(n.data.map(e=>e),n.typeInfo):new Go(n.value,n.typeInfo)}Radians(e,t){const n=this.exec.evalExpression(e.args[0],t);return n instanceof zo?new zo(n.data.map(e=>e*Math.PI/180),n.typeInfo):new Go(n.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof zo&&s instanceof zo){const e=this._dot(n.data,s.data);return new zo(n.data.map((t,n)=>t-2*e*s.data[n]),n.typeInfo)}return null}Refract(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(n instanceof zo&&s instanceof zo&&r instanceof Go){const e=this._dot(s.data,n.data);return new zo(n.data.map((t,n)=>{const i=1-r.value*r.value*(1-e*e);if(i<0)return 0;const o=Math.sqrt(i);return r.value*t-(r.value*e+o)*s.data[n]}),n.typeInfo)}return null}ReverseBits(e,t){return null}Round(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.round(e)),n.typeInfo);const s=n;return new Go(Math.round(s.value),n.typeInfo)}Saturate(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.min(Math.max(e,0),1)),n.typeInfo);const s=n;return new Go(Math.min(Math.max(s.value,0),1),n.typeInfo)}Sign(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.sign(e)),n.typeInfo);const s=n;return new Go(Math.sign(s.value),n.typeInfo)}Sin(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.sin(e)),n.typeInfo);const s=n;return new Go(Math.sin(s.value),n.typeInfo)}Sinh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.sinh(e)),n.typeInfo);const s=n;return new Go(Math.sinh(s.value),n.typeInfo)}_smoothstep(e,t,n){const s=Math.min(Math.max((n-e)/(t-e),0),1);return s*s*(3-2*s)}SmoothStep(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(r instanceof zo&&n instanceof zo&&s instanceof zo)return new zo(r.data.map((e,t)=>this._smoothstep(n.data[t],s.data[t],e)),r.typeInfo);const i=n,o=s,a=r;return new Go(this._smoothstep(i.value,o.value,a.value),r.typeInfo)}Sqrt(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.sqrt(e)),n.typeInfo);const s=n;return new Go(Math.sqrt(s.value),n.typeInfo)}Step(e,t){const n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(s instanceof zo&&n instanceof zo)return new zo(s.data.map((e,t)=>eMath.tan(e)),n.typeInfo);const s=n;return new Go(Math.tan(s.value),n.typeInfo)}Tanh(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.tanh(e)),n.typeInfo);const s=n;return new Go(Math.tanh(s.value),n.typeInfo)}_getTransposeType(e){const t=e.getTypeName();return"mat2x2f"===t||"mat2x2h"===t?e:"mat2x3f"===t?this.getTypeInfo("mat3x2f"):"mat2x3h"===t?this.getTypeInfo("mat3x2h"):"mat2x4f"===t?this.getTypeInfo("mat4x2f"):"mat2x4h"===t?this.getTypeInfo("mat4x2h"):"mat3x2f"===t?this.getTypeInfo("mat2x3f"):"mat3x2h"===t?this.getTypeInfo("mat2x3h"):"mat3x3f"===t||"mat3x3h"===t?e:"mat3x4f"===t?this.getTypeInfo("mat4x3f"):"mat3x4h"===t?this.getTypeInfo("mat4x3h"):"mat4x2f"===t?this.getTypeInfo("mat2x4f"):"mat4x2h"===t?this.getTypeInfo("mat2x4h"):"mat4x3f"===t?this.getTypeInfo("mat3x4f"):"mat4x3h"===t?this.getTypeInfo("mat3x4h"):e}Transpose(e,t){const n=this.exec.evalExpression(e.args[0],t);if(!(n instanceof Wo))return null;const s=this._getTransposeType(n.typeInfo);if("mat2x2"===n.typeInfo.name||"mat2x2f"===n.typeInfo.name||"mat2x2h"===n.typeInfo.name){const e=n.data;return new Wo([e[0],e[2],e[1],e[3]],s)}if("mat2x3"===n.typeInfo.name||"mat2x3f"===n.typeInfo.name||"mat2x3h"===n.typeInfo.name){const e=n.data;return new Wo([e[0],e[3],e[6],e[1],e[4],e[7]],s)}if("mat2x4"===n.typeInfo.name||"mat2x4f"===n.typeInfo.name||"mat2x4h"===n.typeInfo.name){const e=n.data;return new Wo([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13]],s)}if("mat3x2"===n.typeInfo.name||"mat3x2f"===n.typeInfo.name||"mat3x2h"===n.typeInfo.name){const e=n.data;return new Wo([e[0],e[3],e[1],e[4],e[2],e[5]],s)}if("mat3x3"===n.typeInfo.name||"mat3x3f"===n.typeInfo.name||"mat3x3h"===n.typeInfo.name){const e=n.data;return new Wo([e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]],s)}if("mat3x4"===n.typeInfo.name||"mat3x4f"===n.typeInfo.name||"mat3x4h"===n.typeInfo.name){const e=n.data;return new Wo([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14]],s)}if("mat4x2"===n.typeInfo.name||"mat4x2f"===n.typeInfo.name||"mat4x2h"===n.typeInfo.name){const e=n.data;return new Wo([e[0],e[4],e[1],e[5],e[2],e[6]],s)}if("mat4x3"===n.typeInfo.name||"mat4x3f"===n.typeInfo.name||"mat4x3h"===n.typeInfo.name){const e=n.data;return new Wo([e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]],s)}if("mat4x4"===n.typeInfo.name||"mat4x4f"===n.typeInfo.name||"mat4x4h"===n.typeInfo.name){const e=n.data;return new Wo([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]],s)}return null}Trunc(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof zo)return new zo(n.data.map(e=>Math.trunc(e)),n.typeInfo);const s=n;return new Go(Math.trunc(s.value),n.typeInfo)}Dpdx(e,t){return null}DpdxCoarse(e,t){return null}DpdxFine(e,t){return null}Dpdy(e,t){return null}DpdyCoarse(e,t){return null}DpdyFine(e,t){return null}Fwidth(e,t){return null}FwidthCoarse(e,t){return null}FwidthFine(e,t){return null}TextureDimensions(e,t){const n=e.args[0],s=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(n instanceof wo){const e=n.name,r=t.getVariableValue(e);if(r instanceof $o){if(s<0||s>=r.mipLevelCount)return null;const e=r.getMipLevelSize(s),t=r.dimension;return"1d"===t?new Go(e[0],this.getTypeInfo("u32")):"3d"===t?new zo(e,this.getTypeInfo("vec3u")):"2d"===t?new zo(e.slice(0,2),this.getTypeInfo("vec2u")):null}return null}return null}TextureGather(e,t){return null}TextureGatherCompare(e,t){return null}TextureLoad(e,t){const n=e.args[0],s=this.exec.evalExpression(e.args[1],t),r=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(s instanceof zo)||2!==s.data.length)return null;if(n instanceof wo){const e=n.name,i=t.getVariableValue(e);if(i instanceof $o){const e=Math.floor(s.data[0]),t=Math.floor(s.data[1]);if(e<0||e>=i.width||t<0||t>=i.height)return null;const n=i.getPixel(e,t,0,r);return null===n?null:new zo(n,this.getTypeInfo("vec4f"))}return null}return null}TextureNumLayers(e,t){const n=e.args[0];if(n instanceof wo){const e=n.name,s=t.getVariableValue(e);return s instanceof $o?new Go(s.depthOrArrayLayers,this.getTypeInfo("u32")):null}return null}TextureNumLevels(e,t){const n=e.args[0];if(n instanceof wo){const e=n.name,s=t.getVariableValue(e);return s instanceof $o?new Go(s.mipLevelCount,this.getTypeInfo("u32")):null}return null}TextureNumSamples(e,t){const n=e.args[0];if(n instanceof wo){const e=n.name,s=t.getVariableValue(e);return s instanceof $o?new Go(s.sampleCount,this.getTypeInfo("u32")):null}return null}TextureSample(e,t){return null}TextureSampleBias(e,t){return null}TextureSampleCompare(e,t){return null}TextureSampleCompareLevel(e,t){return null}TextureSampleGrad(e,t){return null}TextureSampleLevel(e,t){return null}TextureSampleBaseClampToEdge(e,t){return null}TextureStore(e,t){const n=e.args[0],s=this.exec.evalExpression(e.args[1],t),r=4===e.args.length?this.exec.evalExpression(e.args[2],t).value:0,i=4===e.args.length?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(4!==i.length)return null;if(!(s instanceof zo)||2!==s.data.length)return null;if(n instanceof wo){const e=n.name,o=t.getVariableValue(e);if(o instanceof $o){const e=o.getMipLevelSize(0),t=Math.floor(s.data[0]),n=Math.floor(s.data[1]);return t<0||t>=e[0]||n<0||n>=e[1]||o.setPixel(t,n,0,r,Array.from(i)),null}return null}return null}AtomicLoad(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.getVariableName(n,t);return t.getVariable(s).value.getSubData(this.exec,n.postfix,t)}AtomicStore(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let i=e.args[1];const o=this.exec.evalExpression(i,t),a=r.value.getSubData(this.exec,n.postfix,t);return a instanceof Go&&o instanceof Go&&(a.value=o.value),r.value instanceof Ho&&r.value.setDataValue(this.exec,a,n.postfix,t),null}AtomicAdd(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let i=e.args[1];const o=this.exec.evalExpression(i,t),a=r.value.getSubData(this.exec,n.postfix,t),l=new Go(a.value,a.typeInfo);return a instanceof Go&&o instanceof Go&&(a.value+=o.value),r.value instanceof Ho&&r.value.setDataValue(this.exec,a,n.postfix,t),l}AtomicSub(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let i=e.args[1];const o=this.exec.evalExpression(i,t),a=r.value.getSubData(this.exec,n.postfix,t),l=new Go(a.value,a.typeInfo);return a instanceof Go&&o instanceof Go&&(a.value-=o.value),r.value instanceof Ho&&r.value.setDataValue(this.exec,a,n.postfix,t),l}AtomicMax(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let i=e.args[1];const o=this.exec.evalExpression(i,t),a=r.value.getSubData(this.exec,n.postfix,t),l=new Go(a.value,a.typeInfo);return a instanceof Go&&o instanceof Go&&(a.value=Math.max(a.value,o.value)),r.value instanceof Ho&&r.value.setDataValue(this.exec,a,n.postfix,t),l}AtomicMin(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let i=e.args[1];const o=this.exec.evalExpression(i,t),a=r.value.getSubData(this.exec,n.postfix,t),l=new Go(a.value,a.typeInfo);return a instanceof Go&&o instanceof Go&&(a.value=Math.min(a.value,o.value)),r.value instanceof Ho&&r.value.setDataValue(this.exec,a,n.postfix,t),l}AtomicAnd(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let i=e.args[1];const o=this.exec.evalExpression(i,t),a=r.value.getSubData(this.exec,n.postfix,t),l=new Go(a.value,a.typeInfo);return a instanceof Go&&o instanceof Go&&(a.value=a.value&o.value),r.value instanceof Ho&&r.value.setDataValue(this.exec,a,n.postfix,t),l}AtomicOr(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let i=e.args[1];const o=this.exec.evalExpression(i,t),a=r.value.getSubData(this.exec,n.postfix,t),l=new Go(a.value,a.typeInfo);return a instanceof Go&&o instanceof Go&&(a.value=a.value|o.value),r.value instanceof Ho&&r.value.setDataValue(this.exec,a,n.postfix,t),l}AtomicXor(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let i=e.args[1];const o=this.exec.evalExpression(i,t),a=r.value.getSubData(this.exec,n.postfix,t),l=new Go(a.value,a.typeInfo);return a instanceof Go&&o instanceof Go&&(a.value=a.value^o.value),r.value instanceof Ho&&r.value.setDataValue(this.exec,a,n.postfix,t),l}AtomicExchange(e,t){let n=e.args[0];n instanceof Co&&(n=n.right);const s=this.exec.getVariableName(n,t),r=t.getVariable(s);let i=e.args[1];const o=this.exec.evalExpression(i,t),a=r.value.getSubData(this.exec,n.postfix,t),l=new Go(a.value,a.typeInfo);return a instanceof Go&&o instanceof Go&&(a.value=o.value),r.value instanceof Ho&&r.value.setDataValue(this.exec,a,n.postfix,t),l}AtomicCompareExchangeWeak(e,t){return null}Pack4x8snorm(e,t){return null}Pack4x8unorm(e,t){return null}Pack4xI8(e,t){return null}Pack4xU8(e,t){return null}Pack4x8Clamp(e,t){return null}Pack4xU8Clamp(e,t){return null}Pack2x16snorm(e,t){return null}Pack2x16unorm(e,t){return null}Pack2x16float(e,t){return null}Unpack4x8snorm(e,t){return null}Unpack4x8unorm(e,t){return null}Unpack4xI8(e,t){return null}Unpack4xU8(e,t){return null}Unpack2x16snorm(e,t){return null}Unpack2x16unorm(e,t){return null}Unpack2x16float(e,t){return null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return null}SubgroupExclusiveAdd(e,t){return null}SubgroupInclusiveAdd(e,t){return null}SubgroupAll(e,t){return null}SubgroupAnd(e,t){return null}SubgroupAny(e,t){return null}SubgroupBallot(e,t){return null}SubgroupBroadcast(e,t){return null}SubgroupBroadcastFirst(e,t){return null}SubgroupElect(e,t){return null}SubgroupMax(e,t){return null}SubgroupMin(e,t){return null}SubgroupMul(e,t){return null}SubgroupExclusiveMul(e,t){return null}SubgroupInclusiveMul(e,t){return null}SubgroupOr(e,t){return null}SubgroupShuffle(e,t){return null}SubgroupShuffleDown(e,t){return null}SubgroupShuffleUp(e,t){return null}SubgroupShuffleXor(e,t){return null}SubgroupXor(e,t){return null}QuadBroadcast(e,t){return null}QuadSwapDiagonal(e,t){return null}QuadSwapX(e,t){return null}QuadSwapY(e,t){return null}}const _a={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},ya={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class ba extends ga{constructor(e,t){var n;super(),this.ast=null!=e?e:[],this.reflection=new ua,this.reflection.updateAST(this.ast),this.context=null!==(n=null==t?void 0:t.clone())&&void 0!==n?n:new pa,this.builtins=new ma(this),this.typeInfo={bool:this.getTypeInfo(uo.bool),i32:this.getTypeInfo(uo.i32),u32:this.getTypeInfo(uo.u32),f32:this.getTypeInfo(uo.f32),f16:this.getTypeInfo(uo.f16),vec2f:this.getTypeInfo(po.vec2f),vec2u:this.getTypeInfo(po.vec2u),vec2i:this.getTypeInfo(po.vec2i),vec2h:this.getTypeInfo(po.vec2h),vec3f:this.getTypeInfo(po.vec3f),vec3u:this.getTypeInfo(po.vec3u),vec3i:this.getTypeInfo(po.vec3i),vec3h:this.getTypeInfo(po.vec3h),vec4f:this.getTypeInfo(po.vec4f),vec4u:this.getTypeInfo(po.vec4u),vec4i:this.getTypeInfo(po.vec4i),vec4h:this.getTypeInfo(po.vec4h),mat2x2f:this.getTypeInfo(po.mat2x2f),mat2x3f:this.getTypeInfo(po.mat2x3f),mat2x4f:this.getTypeInfo(po.mat2x4f),mat3x2f:this.getTypeInfo(po.mat3x2f),mat3x3f:this.getTypeInfo(po.mat3x3f),mat3x4f:this.getTypeInfo(po.mat3x4f),mat4x2f:this.getTypeInfo(po.mat4x2f),mat4x3f:this.getTypeInfo(po.mat4x3f),mat4x4f:this.getTypeInfo(po.mat4x4f)}}getVariableValue(e){var t,n;const s=null!==(n=null===(t=this.context.getVariable(e))||void 0===t?void 0:t.value)&&void 0!==n?n:null;if(null===s)return null;if(s instanceof Go)return s.value;if(s instanceof zo)return Array.from(s.data);if(s instanceof Wo)return Array.from(s.data);if(s instanceof Ho&&s.typeInfo instanceof li){if("u32"===s.typeInfo.format.name)return Array.from(new Uint32Array(s.buffer,s.offset,s.typeInfo.count));if("i32"===s.typeInfo.format.name)return Array.from(new Int32Array(s.buffer,s.offset,s.typeInfo.count));if("f32"===s.typeInfo.format.name)return Array.from(new Float32Array(s.buffer,s.offset,s.typeInfo.count))}return null}execute(e){(e=null!=e?e:{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,n,s){const r=this.context.clone();(s=null!=s?s:{}).constants&&this._setOverrides(s.constants,r),this._execStatements(this.ast,r);const i=r.getFunction(e);if(!i)return;if("number"==typeof t)t=[t,1,1];else{if(0===t.length)return;1===t.length?t=[t[0],1,1]:2===t.length?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}const o=t[0],a=t[1],l=t[2],c=this.getTypeInfo("vec3u");r.setVariable("@num_workgroups",new zo(t,c));const u=this.reflection.getFunctionInfo(e);for(const h in n)for(const e in n[h]){const t=n[h][e];r.variables.forEach(n=>{var s;const r=n.node;if(null==r?void 0:r.attributes){let i=null,o=null;for(const e of r.attributes)"binding"===e.name?i=e.value:"group"===e.name&&(o=e.value);if(e==i&&h==o){let i=!1;for(const t of u.resources)if(t.name===n.name&&t.group===parseInt(h)&&t.binding===parseInt(e)){i=!0;break}if(i)if(void 0!==t.texture&&void 0!==t.descriptor){const e=new $o(t.texture,this.getTypeInfo(r.type),t.descriptor,null!==(s=t.texture.view)&&void 0!==s?s:null);n.value=e}else void 0!==t.uniform?n.value=new Ho(t.uniform,this.getTypeInfo(r.type)):n.value=new Ho(t,this.getTypeInfo(r.type))}}})}for(let h=0;h0){const e=n.getVariableValue(c.value[0]);s[0]=e instanceof Go?e.value:parseInt(c.value[0])}if(c.value.length>1){const e=n.getVariableValue(c.value[1]);s[1]=e instanceof Go?e.value:parseInt(c.value[1])}if(c.value.length>2){const e=n.getVariableValue(c.value[2]);s[2]=e instanceof Go?e.value:parseInt(c.value[2])}}const r=this.getTypeInfo("vec3u"),i=this.getTypeInfo("u32");n.setVariable("@workgroup_size",new zo(s,r));const o=s[0],a=s[1],l=s[2];for(let c=0,u=0;c",r=null;if(e.variable instanceof Co){const n=this._getVariableData(e.variable,t),s=this.evalExpression(e.value,t),r=e.operator;if("="===r){if(n instanceof Go||n instanceof zo||n instanceof Wo){if(s instanceof Go||s instanceof zo||s instanceof Wo&&n.data.length===s.data.length)return void n.data.set(s.data)}else if(n instanceof Ho&&s instanceof Ho&&n.buffer.byteLength-n.offset>=s.buffer.byteLength-s.offset)return void(n.buffer.byteLength%4==0?new Uint32Array(n.buffer,n.offset,n.typeInfo.size/4).set(new Uint32Array(s.buffer,s.offset,s.typeInfo.size/4)):new Uint8Array(n.buffer,n.offset,n.typeInfo.size).set(new Uint8Array(s.buffer,s.offset,s.typeInfo.size)));return null}if("+="===r)return(n instanceof Go||n instanceof zo||n instanceof Wo)&&(s instanceof Go||s instanceof zo||s instanceof Wo)?void n.data.set(s.data.map((e,t)=>n.data[t]+e)):void 0;if("-="===r)return(n instanceof Go||n instanceof zo||n instanceof Wo)&&(s instanceof Go||s instanceof zo||s instanceof Wo)?void n.data.set(s.data.map((e,t)=>n.data[t]-e)):void 0}if(e.variable instanceof Co){if("*"===e.variable.operator){s=this.getVariableName(e.variable.right,t);const r=t.getVariable(s);if(!(r&&r.value instanceof jo))return;n=r.value.reference;let i=e.variable.postfix;if(!i){let t=e.variable.right;for(;t instanceof Co;){if(t.postfix){i=t.postfix;break}t=t.right}}i&&(n=n.getSubData(this,i,t))}}else{r=e.variable.postfix,s=this.getVariableName(e.variable,t);const i=t.getVariable(s);if(null===i)return;n=i.value}if(n instanceof jo&&(n=n.reference),null===n)return;const i=this.evalExpression(e.value,t),o=e.operator;if("="!==o){const e=n.getSubData(this,r,t);if(e instanceof zo&&i instanceof Go){const t=e.data,n=i.value;if("+="===o)for(let e=0;e>="===o)for(let e=0;e>=n}else if(e instanceof zo&&i instanceof zo){const t=e.data,n=i.data;if(t.length!==n.length)return;if("+="===o)for(let e=0;e>="===o)for(let e=0;e>=n[e]}else{if(!(e instanceof Go&&i instanceof Go))return;"+="===o?e.value+=i.value:"-="===o?e.value-=i.value:"*="===o?e.value*=i.value:"/="===o?e.value/=i.value:"%="===o?e.value%=i.value:"&="===o?e.value&=i.value:"|="===o?e.value|=i.value:"^="===o?e.value^=i.value:"<<="===o?e.value<<=i.value:">>="===o&&(e.value>>=i.value)}return void(n instanceof Ho&&n.setDataValue(this,e,r,t))}if(n instanceof Ho)n.setDataValue(this,i,r,t);else if(r){if(!(n instanceof zo||n instanceof Wo))return;if(r instanceof Ao){const e=this.evalExpression(r.index,t).value;if(n instanceof zo){if(!(i instanceof Go))return;n.data[e]=i.value}else{if(!(n instanceof Wo))return;{const e=this.evalExpression(r.index,t).value;if(e<0)return;if(!(i instanceof zo))return;{const t=n.typeInfo.getTypeName();if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t){if(!(e<2&&2===i.data.length))return;n.data[2*e]=i.data[0],n.data[2*e+1]=i.data[1]}else if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t){if(!(e<2&&3===i.data.length))return;n.data[3*e]=i.data[0],n.data[3*e+1]=i.data[1],n.data[3*e+2]=i.data[2]}else if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t){if(!(e<2&&4===i.data.length))return;n.data[4*e]=i.data[0],n.data[4*e+1]=i.data[1],n.data[4*e+2]=i.data[2],n.data[4*e+3]=i.data[3]}else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t){if(!(e<3&&2===i.data.length))return;n.data[2*e]=i.data[0],n.data[2*e+1]=i.data[1]}else if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t){if(!(e<3&&3===i.data.length))return;n.data[3*e]=i.data[0],n.data[3*e+1]=i.data[1],n.data[3*e+2]=i.data[2]}else if("mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t){if(!(e<3&&4===i.data.length))return;n.data[4*e]=i.data[0],n.data[4*e+1]=i.data[1],n.data[4*e+2]=i.data[2],n.data[4*e+3]=i.data[3]}else if("mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t){if(!(e<4&&2===i.data.length))return;n.data[2*e]=i.data[0],n.data[2*e+1]=i.data[1]}else if("mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t){if(!(e<4&&3===i.data.length))return;n.data[3*e]=i.data[0],n.data[3*e+1]=i.data[1],n.data[3*e+2]=i.data[2]}else{if("mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t)return;if(!(e<4&&4===i.data.length))return;n.data[4*e]=i.data[0],n.data[4*e+1]=i.data[1],n.data[4*e+2]=i.data[2],n.data[4*e+3]=i.data[3]}}}}}else if(r instanceof bo){const e=r.value;if(!(n instanceof zo))return;if(i instanceof Go){if(e.length>1)return;if("x"===e)n.data[0]=i.value;else if("y"===e){if(n.data.length<2)return;n.data[1]=i.value}else if("z"===e){if(n.data.length<3)return;n.data[2]=i.value}else if("w"===e){if(n.data.length<4)return;n.data[3]=i.value}}else{if(!(i instanceof zo))return;if(e.length!==i.data.length)return;for(let t=0;t+e);return new zo(e,n.typeInfo)}const e=s,t=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new Go(+e,t)}case"-":{if(Zo(s)){const e=s.map((e,t)=>-e);return new zo(e,n.typeInfo)}const e=s,t=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new Go(-e,t)}case"!":{if(Zo(s)){const e=s.map((e,t)=>e?0:1);return new zo(e,n.typeInfo)}const e=s,t=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new Go(e?0:1,t)}case"~":{if(Zo(s)){const e=s.map((e,t)=>~e);return new zo(e,n.typeInfo)}const e=s,t=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new Go(~e,t)}}return null}_evalBinaryOp(e,t){const n=this.evalExpression(e.left,t),s=this.evalExpression(e.right,t),r=n instanceof Go?n.value:n instanceof zo||n instanceof Wo?Array.from(n.data):null,i=s instanceof Go?s.value:s instanceof zo||s instanceof Wo?Array.from(s.data):null;switch(e.operator){case"+":{if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e+t[n]);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t+e);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e+t);return new zo(t,s.typeInfo)}const e=r,t=i,o=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new Go(e+t,o)}case"-":{if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e-t[n]);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t-e);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e-t);return new zo(t,s.typeInfo)}const e=r,t=i,o=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new Go(e-t,o)}case"*":{if(Zo(r)&&Zo(i)){const e=r,t=i;if(n instanceof Wo&&s instanceof Wo){const r=function(e,t,n,s){if(void 0===ya[t.name]||void 0===ya[s.name])return null;const r=ya[t.name][0],i=ya[t.name][1],o=ya[s.name][0];if(r!==ya[s.name][1])return null;const a=new Array(o*i);for(let l=0;le*t[n]);return new zo(s,n.typeInfo)}}if(Zo(r)){const e=i,t=r.map((t,n)=>t*e);return n instanceof Wo?new Wo(t,n.typeInfo):new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e*t);return s instanceof Wo?new Wo(t,s.typeInfo):new zo(t,s.typeInfo)}const e=r,t=i,o=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new Go(e*t,o)}case"%":{if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e%t[n]);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t%e);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e%t);return new zo(t,s.typeInfo)}const e=r,t=i,o=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new Go(e%t,o)}case"/":{if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e/t[n]);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t/e);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e/t);return new zo(t,s.typeInfo)}const e=r,t=i,o=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new Go(e/t,o)}case"&":{if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e&t[n]);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t&e);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e&t);return new zo(t,s.typeInfo)}const e=r,t=i,o=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new Go(e&t,o)}case"|":{if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e|t[n]);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t|e);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e|t);return new zo(t,s.typeInfo)}const e=r,t=i,o=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new Go(e|t,o)}case"^":{if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e^t[n]);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t^e);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e^t);return new zo(t,s.typeInfo)}const e=r,t=i,o=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new Go(e^t,o)}case"<<":{if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e<t<e<>":{if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e>>t[n]);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t>>e);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e>>t);return new zo(t,s.typeInfo)}const e=r,t=i,o=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new Go(e>>t,o)}case">":if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e>t[n]?1:0);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t>e?1:0);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e>t?1:0);return new zo(t,s.typeInfo)}return new Go(r>i?1:0,this.getTypeInfo("bool"));case"<":if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>etee===t[n]?1:0);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t==e?1:0);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e==t?1:0);return new zo(t,s.typeInfo)}return new Go(r===i?1:0,this.getTypeInfo("bool"));case"!=":if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e!==t[n]?1:0);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t!==e?1:0);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e!==t?1:0);return new zo(t,s.typeInfo)}return new Go(r!==i?1:0,this.getTypeInfo("bool"));case">=":if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e>=t[n]?1:0);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t>=e?1:0);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e>=t?1:0);return new zo(t,s.typeInfo)}return new Go(r>=i?1:0,this.getTypeInfo("bool"));case"<=":if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e<=t[n]?1:0);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t<=e?1:0);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e<=t?1:0);return new zo(t,s.typeInfo)}return new Go(r<=i?1:0,this.getTypeInfo("bool"));case"&&":if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e&&t[n]?1:0);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t&&e?1:0);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e&&t?1:0);return new zo(t,s.typeInfo)}return new Go(r&&i?1:0,this.getTypeInfo("bool"));case"||":if(Zo(r)&&Zo(i)){const e=r,t=i;if(e.length!==t.length)return null;const s=e.map((e,n)=>e||t[n]?1:0);return new zo(s,n.typeInfo)}if(Zo(r)){const e=i,t=r.map((t,n)=>t||e?1:0);return new zo(t,n.typeInfo)}if(Zo(i)){const e=r,t=i.map((t,n)=>e||t?1:0);return new zo(t,s.typeInfo)}return new Go(r||i?1:0,this.getTypeInfo("bool"))}return null}_evalCall(e,t){if(null!==e.cachedReturnValue)return e.cachedReturnValue;const n=t.clone();n.currentFunctionName=e.name;const s=t.getFunction(e.name);if(!s)return e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)?this._evalCreate(e,t):null;for(let r=0;rr?i.slice(0,r):i,n).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const n=this.getTypeInfo(e.type),s=e.type.getTypeName(),r=ya[s];if(void 0===r)return null;const i=[];if(e instanceof To)if(e.isVector){const t=e.vectorValue;for(const e of t)i.push(e)}else i.push(e.scalarValue);else if(e.args)for(const o of e.args){const e=this.evalExpression(o,t);e instanceof zo?i.push(...e.data):e instanceof Go?i.push(e.value):e instanceof Wo&&i.push(...e.data)}if(n instanceof ui&&null===n.format&&(n.format=this.getTypeInfo("f32")),0===i.length){const s=new Array(r[2]).fill(0);return new Wo(s,n).getSubData(this,e.postfix,t)}return i.length!==r[2]?null:new Wo(i,n).getSubData(this,e.postfix,t)}}ba._breakObj=new Bo(new ii("BREAK",null),null),ba._continueObj=new Bo(new ii("CONTINUE",null),null),ba._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class va{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class xa{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new va,this._exec=new ba,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const t=[];for(;!this._isAtEnd();){const e=this._global_decl_or_directive();if(!e)break;t.push(e)}if(this._deferArrayCountEval.length>0){for(const e of this._deferArrayCountEval){const t=e.arrayType,s=e.countNode;if(s instanceof wo){const e=s.name,r=this._context.constants.get(e);if(r)try{const e=r.constEvaluate(this._exec);t.count=e}catch(n){}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const s of t)s.search(e=>{e instanceof Fo||e instanceof go?e.type=this._forwardType(e.type):e instanceof mo?e.format=this._forwardType(e.format):e instanceof Vi||e instanceof Wi||e instanceof Hi?e.type=this._forwardType(e.type):e instanceof Di?e.returnType=this._forwardType(e.returnType):e instanceof No&&(e.type=this._forwardType(e.type))});return t}_forwardType(e){if(e instanceof ho){const t=this._getType(e.name);if(t)return t}else e instanceof go?e.type=this._forwardType(e.type):e instanceof mo&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if("string"==typeof e){const t=new Ko(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=null!=t?t:this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==qo.eof}_match(e){if(e instanceof Xo)return!!this._check(e)&&(this._advance(),!0);for(let t=0,n=e.length;t0){const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t,this._check(qo.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(qo.keywords.continue)){const t=this._updateNode(new co);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return null!=e&&this._consume(qo.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(qo.keywords.static_assert))return null;const e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new Bi(t),e)}_while_statement(){if(!this._match(qo.keywords.while))return null;const e=this._updateNode(new Ui(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(qo.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){const e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match(qo.keywords.continuing))return null;const t=this._currentLine,n=this._compound_statement();return this._updateNode(new ji(n,e),t)}_for_statement(){if(!this._match(qo.keywords.for))return null;this._consume(qo.tokens.paren_left,"Expected '('.");const e=this._updateNode(new Gi(null,null,null,null));return this._currentLoop.push(e),e.init=this._check(qo.tokens.semicolon)?null:this._for_init(),this._consume(qo.tokens.semicolon,"Expected ';'."),e.condition=this._check(qo.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume(qo.tokens.semicolon,"Expected ';'."),e.increment=this._check(qo.tokens.paren_right)?null:this._for_increment(),this._consume(qo.tokens.paren_right,"Expected ')'."),this._check(qo.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(qo.keywords.var)){const e=this._variable_decl();if(null===e)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(qo.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new Vi(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(qo.keywords.let)){const e=this._currentLine,t=this._consume(qo.tokens.name,"Expected name for let.").toString();let n=null;if(this._match(qo.tokens.colon)){const e=this._attribute();n=this._type_decl(),null!=n&&(n.attributes=e)}this._consume(qo.tokens.equal,"Expected '=' for let.");const s=this._short_circuit_or_expression();return this._updateNode(new Wi(t,n,null,null,s),e)}if(this._match(qo.keywords.const)){const e=this._currentLine,t=this._consume(qo.tokens.name,"Expected name for const.").toString();let n=null;if(this._match(qo.tokens.colon)){const e=this._attribute();n=this._type_decl(),null!=n&&(n.attributes=e)}this._consume(qo.tokens.equal,"Expected '=' for const.");const s=this._short_circuit_or_expression();return null===n&&s instanceof To&&(n=s.type),this._updateNode(new Hi(t,n,null,null,s),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(null==t)return null;if(!this._check(qo.increment_operators))return this._current=e,null;const n=this._consume(qo.increment_operators,"Expected increment operator");return this._updateNode(new Ki(n.type===qo.tokens.plus_plus?$i.increment:$i.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check(qo.tokens.brace_right))return null;let n=this._match(qo.tokens.underscore);if(n||(e=this._unary_expression()),!n&&null==e)return null;const s=this._consume(qo.assignment_operators,"Expected assignment operator."),r=this._short_circuit_or_expression();return this._updateNode(new Zi(Xi.parse(s.lexeme),e,r),t)}_func_call_statement(){if(!this._check(qo.tokens.ident))return null;const e=this._currentLine,t=this._current,n=this._consume(qo.tokens.ident,"Expected function name."),s=this._argument_expression_list();return null===s?(this._current=t,null):this._updateNode(new Qi(n.lexeme,s),e)}_loop_statement(){if(!this._match(qo.keywords.loop))return null;this._check(qo.tokens.attr)&&this._attribute(),this._consume(qo.tokens.brace_left,"Expected '{' for loop.");const e=this._updateNode(new Ji([],null));this._currentLoop.push(e);let t=this._statement();for(;null!==t;){if(Array.isArray(t))for(let n of t)e.body.push(n);else e.body.push(t);if(t instanceof ji){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume(qo.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match(qo.keywords.switch))return null;const e=this._updateNode(new eo(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(qo.tokens.attr)&&this._attribute(),this._consume(qo.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),null==e.cases||0==e.cases.length)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(qo.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){const e=[];let t=!1;for(;this._check([qo.keywords.default,qo.keywords.case]);){if(this._match(qo.keywords.case)){const n=this._case_selectors();for(const e of n)if(e instanceof Io){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match(qo.tokens.colon),this._check(qo.tokens.attr)&&this._attribute(),this._consume(qo.tokens.brace_left,"Exected '{' for switch case.");const s=this._case_body();this._consume(qo.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new Mo(n,s)))}if(this._match(qo.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match(qo.tokens.colon),this._check(qo.tokens.attr)&&this._attribute(),this._consume(qo.tokens.brace_left,"Exected '{' for switch default.");const n=this._case_body();this._consume(qo.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new Lo(n)))}}return e}_case_selectors(){const e=[];for(this._match(qo.keywords.default)?e.push(this._updateNode(new Io)):e.push(this._shift_expression());this._match(qo.tokens.comma);)this._match(qo.keywords.default)?e.push(this._updateNode(new Io)):e.push(this._shift_expression());return e}_case_body(){if(this._match(qo.keywords.fallthrough))return this._consume(qo.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(null==e)return[];e instanceof Array||(e=[e]);const t=this._case_body();return 0==t.length?e:[...e,t[0]]}_if_statement(){if(!this._match(qo.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check(qo.tokens.attr)&&this._attribute();const n=this._compound_statement();let s=[];this._match_elseif()&&(this._check(qo.tokens.attr)&&this._attribute(),s=this._elseif_statement(s));let r=null;return this._match(qo.keywords.else)&&(this._check(qo.tokens.attr)&&this._attribute(),r=this._compound_statement()),this._updateNode(new to(t,n,s,r),e)}_match_elseif(){return this._tokens[this._current].type===qo.keywords.else&&this._tokens[this._current+1].type===qo.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){const t=this._optional_paren_expression(),n=this._compound_statement();return e.push(this._updateNode(new Oo(t,n))),this._match_elseif()&&(this._check(qo.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(qo.keywords.return))return null;const e=this._short_circuit_or_expression();return this._updateNode(new no(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(qo.tokens.or_or);)e=this._updateNode(new Po(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(qo.tokens.and_and);)e=this._updateNode(new Po(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(qo.tokens.or);)e=this._updateNode(new Po(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(qo.tokens.xor);)e=this._updateNode(new Po(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match(qo.tokens.and);)e=this._updateNode(new Po(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){const e=this._relational_expression();return this._match([qo.tokens.equal_equal,qo.tokens.not_equal])?this._updateNode(new Po(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([qo.tokens.less_than,qo.tokens.greater_than,qo.tokens.less_than_equal,qo.tokens.greater_than_equal]);)e=this._updateNode(new Po(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([qo.tokens.shift_left,qo.tokens.shift_right]);)e=this._updateNode(new Po(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([qo.tokens.plus,qo.tokens.minus]);)e=this._updateNode(new Po(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([qo.tokens.star,qo.tokens.forward_slash,qo.tokens.modulo]);)e=this._updateNode(new Po(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([qo.tokens.minus,qo.tokens.bang,qo.tokens.tilde,qo.tokens.star,qo.tokens.and])?this._updateNode(new Co(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(qo.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume(qo.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new Ao(e)),n=this._postfix_expression();return n&&(t.postfix=n),t}if(this._match(qo.tokens.period)){const e=this._consume(qo.tokens.name,"Expected member name."),t=this._postfix_expression(),n=this._updateNode(new bo(e.lexeme));return t&&(n.postfix=t),n}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){const t=this._getStruct(e);if(null!==t)return t;switch(e){case"void":return uo.void;case"bool":return uo.bool;case"i32":return uo.i32;case"u32":return uo.u32;case"f32":return uo.f32;case"f16":return uo.f16;case"vec2f":return po.vec2f;case"vec3f":return po.vec3f;case"vec4f":return po.vec4f;case"vec2i":return po.vec2i;case"vec3i":return po.vec3i;case"vec4i":return po.vec4i;case"vec2u":return po.vec2u;case"vec3u":return po.vec3u;case"vec4u":return po.vec4u;case"vec2h":return po.vec2h;case"vec3h":return po.vec3h;case"vec4h":return po.vec4h;case"mat2x2f":return po.mat2x2f;case"mat2x3f":return po.mat2x3f;case"mat2x4f":return po.mat2x4f;case"mat3x2f":return po.mat3x2f;case"mat3x3f":return po.mat3x3f;case"mat3x4f":return po.mat3x4f;case"mat4x2f":return po.mat4x2f;case"mat4x3f":return po.mat4x3f;case"mat4x4f":return po.mat4x4f;case"mat2x2h":return po.mat2x2h;case"mat2x3h":return po.mat2x3h;case"mat2x4h":return po.mat2x4h;case"mat3x2h":return po.mat3x2h;case"mat3x3h":return po.mat3x3h;case"mat3x4h":return po.mat3x4h;case"mat4x2h":return po.mat4x2h;case"mat4x3h":return po.mat4x3h;case"mat4x4h":return po.mat4x4h;case"mat2x2i":return po.mat2x2i;case"mat2x3i":return po.mat2x3i;case"mat2x4i":return po.mat2x4i;case"mat3x2i":return po.mat3x2i;case"mat3x3i":return po.mat3x3i;case"mat3x4i":return po.mat3x4i;case"mat4x2i":return po.mat4x2i;case"mat4x3i":return po.mat4x3i;case"mat4x4i":return po.mat4x4i;case"mat2x2u":return po.mat2x2u;case"mat2x3u":return po.mat2x3u;case"mat2x4u":return po.mat2x4u;case"mat3x2u":return po.mat3x2u;case"mat3x3u":return po.mat3x3u;case"mat3x4u":return po.mat3x4u;case"mat4x2u":return po.mat4x2u;case"mat4x3u":return po.mat4x3u;case"mat4x4u":return po.mat4x4u}return null}_validateTypeRange(e,t){if("i32"===t.name){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if("u32"===t.name&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match(qo.tokens.ident)){const e=this._previous().toString();if(this._check(qo.tokens.paren_left)){const t=this._argument_expression_list(),n=this._getType(e);return null!==n?this._updateNode(new vo(n,t)):this._updateNode(new xo(e,t))}if(this._context.constants.has(e)){const t=this._context.constants.get(e);return this._updateNode(new Eo(e,t.value))}return this._updateNode(new wo(e))}if(this._match(qo.tokens.int_literal)){const e=this._previous().toString();let t=e.endsWith("i")||e.endsWith("i")?uo.i32:e.endsWith("u")||e.endsWith("U")?uo.u32:uo.x32;const n=parseInt(e);return this._validateTypeRange(n,t),this._updateNode(new To(new Go(n,this._exec.getTypeInfo(t)),t))}if(this._match(qo.tokens.uint_literal)){const e=parseInt(this._previous().toString());return this._validateTypeRange(e,uo.u32),this._updateNode(new To(new Go(e,this._exec.getTypeInfo(uo.u32)),uo.u32))}if(this._match([qo.tokens.decimal_float_literal,qo.tokens.hex_float_literal])){let e=this._previous().toString(),t=e.endsWith("h");t&&(e=e.substring(0,e.length-1));const n=parseFloat(e);this._validateTypeRange(n,t?uo.f16:uo.f32);const s=t?uo.f16:uo.f32;return this._updateNode(new To(new Go(n,this._exec.getTypeInfo(s)),s))}if(this._match([qo.keywords.true,qo.keywords.false])){let e=this._previous().toString()===qo.keywords.true.rule;return this._updateNode(new To(new Go(e?1:0,this._exec.getTypeInfo(uo.bool)),uo.bool))}if(this._check(qo.tokens.paren_left))return this._paren_expression();if(this._match(qo.keywords.bitcast)){this._consume(qo.tokens.less_than,"Expected '<'.");const e=this._type_decl();this._consume(qo.tokens.greater_than,"Expected '>'.");const t=this._paren_expression();return this._updateNode(new So(e,t))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new vo(e,t))}_argument_expression_list(){if(!this._match(qo.tokens.paren_left))return null;const e=[];do{if(this._check(qo.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match(qo.tokens.comma));return this._consume(qo.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(qo.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match(qo.tokens.paren_right),e}_paren_expression(){this._consume(qo.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume(qo.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match(qo.keywords.struct))return null;const e=this._currentLine,t=this._consume(qo.tokens.ident,"Expected name for struct.").toString();this._consume(qo.tokens.brace_left,"Expected '{' for struct body.");const n=[];for(;!this._check(qo.tokens.brace_right);){const e=this._attribute(),t=this._consume(qo.tokens.name,"Expected variable name.").toString();this._consume(qo.tokens.colon,"Expected ':' for struct member type.");const s=this._attribute(),r=this._type_decl();null!=r&&(r.attributes=s),this._check(qo.tokens.brace_right)?this._match(qo.tokens.comma):this._consume(qo.tokens.comma,"Expected ',' for struct member."),n.push(this._updateNode(new Fo(t,r,e)))}this._consume(qo.tokens.brace_right,"Expected '}' after struct body.");const s=this._currentLine,r=this._updateNode(new fo(t,n,e,s),e);return this._context.structs.set(t,r),r}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match(qo.tokens.equal)){const t=this._const_expression();e.value=t}if(null!==e.type&&e.value instanceof To){if("x32"!==e.value.type.name&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else null===e.type&&e.value instanceof To&&(e.type="x32"===e.value.type.name?uo.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){const e=this._override_decl();return e&&this._match(qo.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match(qo.keywords.const))return null;const t=this._consume(qo.tokens.name,"Expected variable name"),n=this._currentLine;let s=null;if(this._match(qo.tokens.colon)){const e=this._attribute();s=this._type_decl(),null!=s&&(s.attributes=e)}let r=null;this._consume(qo.tokens.equal,"const declarations require an assignment");const i=this._short_circuit_or_expression();try{let e=[uo.f32],n=i.constEvaluate(this._exec,e);n instanceof Go&&this._validateTypeRange(n.value,e[0]),e[0]instanceof po&&null===e[0].format&&n.typeInfo instanceof ui&&null!==n.typeInfo.format&&("f16"===n.typeInfo.format.name?e[0].format=uo.f16:"f32"===n.typeInfo.format.name?e[0].format=uo.f32:"i32"===n.typeInfo.format.name?e[0].format=uo.i32:"u32"===n.typeInfo.format.name?e[0].format=uo.u32:"bool"===n.typeInfo.format.name&&(e[0].format=uo.bool)),r=this._updateNode(new To(n,e[0])),this._exec.context.setVariable(t.toString(),n)}catch(a){r=i}if(null!==s&&r instanceof To){if("x32"!==r.type.name&&s.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${s.name}. Line:${this._currentLine}`);r.type=s,r.isScalar&&this._validateTypeRange(r.scalarValue,r.type)}else null===s&&r instanceof To&&(s=null!==(e=null==r?void 0:r.type)&&void 0!==e?e:uo.f32,s===uo.x32&&(s=uo.i32));const o=this._updateNode(new Hi(t.toString(),s,"","",r),n);return this._context.constants.set(o.name,o),o}_global_let_decl(){if(!this._match(qo.keywords.let))return null;const e=this._currentLine,t=this._consume(qo.tokens.name,"Expected variable name");let n=null;if(this._match(qo.tokens.colon)){const e=this._attribute();n=this._type_decl(),null!=n&&(n.attributes=e)}let s=null;if(this._match(qo.tokens.equal)&&(s=this._const_expression()),null!==n&&s instanceof To){if("x32"!==s.type.name&&n.getTypeName()!==s.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${s.type.name} to ${n.name}. Line:${this._currentLine}`);s.type=n}else null===n&&s instanceof To&&(n="x32"===s.type.name?uo.i32:s.type);return s instanceof To&&s.isScalar&&this._validateTypeRange(s.scalarValue,n),this._updateNode(new Wi(t.toString(),n,"","",s),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(qo.keywords.var))return null;const e=this._currentLine;let t="",n="";this._match(qo.tokens.less_than)&&(t=this._consume(qo.storage_class,"Expected storage_class.").toString(),this._match(qo.tokens.comma)&&(n=this._consume(qo.access_mode,"Expected access_mode.").toString()),this._consume(qo.tokens.greater_than,"Expected '>'."));const s=this._consume(qo.tokens.name,"Expected variable name");let r=null;if(this._match(qo.tokens.colon)){const e=this._attribute();r=this._type_decl(),null!=r&&(r.attributes=e)}return this._updateNode(new Vi(s.toString(),r,t,n,null),e)}_override_decl(){if(!this._match(qo.keywords.override))return null;const e=this._consume(qo.tokens.name,"Expected variable name");let t=null;if(this._match(qo.tokens.colon)){const e=this._attribute();t=this._type_decl(),null!=t&&(t.attributes=e)}return this._updateNode(new zi(e.toString(),t,null))}_diagnostic(){this._consume(qo.tokens.paren_left,"Expected '('");const e=this._consume(qo.tokens.ident,"Expected severity control name.");this._consume(qo.tokens.comma,"Expected ','");let t=this._consume(qo.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(qo.tokens.period)&&(t+=`.${this._consume(qo.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(qo.tokens.paren_right,"Expected ')'"),this._updateNode(new io(e.toString(),t))}_enable_directive(){const e=this._consume(qo.tokens.ident,"identity expected.");return this._updateNode(new so(e.toString()))}_requires_directive(){const e=[this._consume(qo.tokens.ident,"identity expected.").toString()];for(;this._match(qo.tokens.comma);){const t=this._consume(qo.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new ro(e))}_type_alias(){const e=this._consume(qo.tokens.ident,"identity expected.");this._consume(qo.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(null===t)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);const n=this._updateNode(new oo(e.toString(),t));return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([qo.tokens.ident,...qo.texel_format,qo.keywords.bool,qo.keywords.f32,qo.keywords.i32,qo.keywords.u32])){const e=this._advance().toString();if(this._context.structs.has(e))return this._context.structs.get(e);if(this._context.aliases.has(e))return this._context.aliases.get(e).type;if(!this._getType(e)){const t=this._updateNode(new ho(e));return this._forwardTypeCount++,t}return this._updateNode(new uo(e))}let e=this._texture_sampler_types();if(e)return e;if(this._check(qo.template_types)){let e=this._advance().toString(),t=null,n=null;return this._match(qo.tokens.less_than)&&(t=this._type_decl(),n=null,this._match(qo.tokens.comma)&&(n=this._consume(qo.access_mode,"Expected access_mode for pointer").toString()),this._consume(qo.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new po(e,t,n))}if(this._match(qo.keywords.ptr)){let e=this._previous().toString();this._consume(qo.tokens.less_than,"Expected '<' for pointer.");const t=this._consume(qo.storage_class,"Expected storage_class for pointer");this._consume(qo.tokens.comma,"Expected ',' for pointer.");const n=this._type_decl();let s=null;return this._match(qo.tokens.comma)&&(s=this._consume(qo.access_mode,"Expected access_mode for pointer").toString()),this._consume(qo.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new go(e,t.toString(),n,s))}const t=this._attribute();if(this._match(qo.keywords.array)){let e=null,s=-1;const r=this._previous();let i=null;if(this._match(qo.tokens.less_than)){e=this._type_decl(),this._context.aliases.has(e.name)&&(e=this._context.aliases.get(e.name).type);let t="";if(this._match(qo.tokens.comma)){i=this._shift_expression();try{t=i.constEvaluate(this._exec).toString(),i=null}catch(n){t="1"}}this._consume(qo.tokens.greater_than,"Expected '>' for array."),s=t?parseInt(t):0}const o=this._updateNode(new mo(r.toString(),t,e,s));return i&&this._deferArrayCountEval.push({arrayType:o,countNode:i}),o}return null}_texture_sampler_types(){if(this._match(qo.sampler_type))return this._updateNode(new _o(this._previous().toString(),null,null));if(this._match(qo.depth_texture_type))return this._updateNode(new _o(this._previous().toString(),null,null));if(this._match(qo.sampled_texture_type)||this._match(qo.multisampled_texture_type)){const e=this._previous();this._consume(qo.tokens.less_than,"Expected '<' for sampler type.");const t=this._type_decl();return this._consume(qo.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new _o(e.toString(),t,null))}if(this._match(qo.storage_texture_type)){const e=this._previous();this._consume(qo.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume(qo.texel_format,"Invalid texel format.").toString();this._consume(qo.tokens.comma,"Expected ',' after texel format.");const n=this._consume(qo.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(qo.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new _o(e.toString(),t,n))}return null}_attribute(){let e=[];for(;this._match(qo.tokens.attr);){const t=this._consume(qo.attribute_name,"Expected attribute name"),n=this._updateNode(new Do(t.toString(),null));if(this._match(qo.tokens.paren_left)){if(n.value=this._consume(qo.literal_or_ident,"Expected attribute value").toString(),this._check(qo.tokens.comma)){this._advance();do{const e=this._consume(qo.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(e)}while(this._match(qo.tokens.comma))}this._consume(qo.tokens.paren_right,"Expected ')'")}e.push(n)}return 0==e.length?null:e}}class wa extends ua{constructor(e){super(),e&&this.update(e)}update(e){const t=(new xa).parse(e);this.updateAST(t)}}function Ea(e){return(null==e?void 0:e.format)?`${e.name}<${e.format.name}>`:e.name}globalThis.mathgl=globalThis.mathgl||{config:{EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1}};const Ta=globalThis.mathgl.config;function Sa(e,{precision:t=Ta.precision}={}){return e=function(e){return Math.round(e/Ta.EPSILON)*Ta.EPSILON}(e),`${parseFloat(e.toPrecision(t))}`}function Aa(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ra(e,t,n){return function(e,t,n){if(Aa(e)){const s=e;n=n||function(e){return e.clone?e.clone():new Array(e.length)}(s);for(let r=0;rMath.max(t,Math.min(n,e)))}function Ca(e,t,n){return Aa(e)?e.map((e,s)=>Ca(e,t[s],n)):n*t+(1-n)*e}function Pa(e,t,n){const s=Ta.EPSILON;try{if(e===t)return!0;if(Aa(e)&&Aa(t)){if(e.length!==t.length)return!1;for(let n=0;n0?", ":"")+Sa(this[n],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t=0&&e=0&&e2*Math.PI)throw Error("expected radians")}function dl(e,t=[],n=0){const s=Math.fround(e),r=e-s;return t[n]=s,t[n+1]=r,t}const fl={name:"fp64arithmetic",vs:"\nuniform fp64arithmeticUniforms {\n uniform float ONE;\n} fp64;\n\n/*\nAbout LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n\nThe purpose of this workaround is to prevent shader compilers from\noptimizing away necessary arithmetic operations by swapping their sequences\nor transform the equation to some 'equivalent' form.\n\nThe method is to multiply an artifical variable, ONE, which will be known to\nthe compiler to be 1 only at runtime. The whole expression is then represented\nas a polynomial with respective to ONE. In the coefficients of all terms, only one a\nand one b should appear\n\nerr = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE\n*/\n\n// Divide float number to high and low floats to extend fraction bits\nvec2 split(float a) {\n const float SPLIT = 4097.0;\n float t = a * SPLIT;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float a_hi = t * fp64.ONE - (t - a);\n float a_lo = a * fp64.ONE - a_hi;\n#else\n float a_hi = t - (t - a);\n float a_lo = a - a_hi;\n#endif\n return vec2(a_hi, a_lo);\n}\n\n// Divide float number again when high float uses too many fraction bits\nvec2 split2(vec2 a) {\n vec2 b = split(a.x);\n b.y += a.y;\n return b;\n}\n\n// Special sum operation when a > b\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float sum = (a + b) * fp64.ONE;\n float err = b - (sum - a) * fp64.ONE;\n#else\n float sum = a + b;\n float err = b - (sum - a);\n#endif\n return vec2(sum, err);\n}\n\n// General sum operation\nvec2 twoSum(float a, float b) {\n float s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);\n#else\n float v = s - a;\n float err = (a - (s - v)) + (b - v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSub(float a, float b) {\n float s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);\n#else\n float v = s - a;\n float err = (a - (s - v)) - (b + v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSqr(float a) {\n float prod = a * a;\n vec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *\n a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\n return vec2(prod, err);\n}\n\nvec2 twoProd(float a, float b) {\n float prod = a * b;\n vec2 a_fp64 = split(a);\n vec2 b_fp64 = split(b);\n float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +\n a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;\n return vec2(prod, err);\n}\n\nvec2 sum_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSum(a.x, b.x);\n t = twoSum(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 sub_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSub(a.x, b.x);\n t = twoSub(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 mul_fp64(vec2 a, vec2 b) {\n vec2 prod = twoProd(a.x, b.x);\n // y component is for the error\n prod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n prod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nvec2 div_fp64(vec2 a, vec2 b) {\n float xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n vec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\n vec2 yn = a * xn;\n#endif\n float diff = (sub_fp64(a, mul_fp64(b, yn))).x;\n vec2 prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nvec2 sqrt_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n\n float x = 1.0 / sqrt(a.x);\n float yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n vec2 yn_sqr = twoSqr(yn) * fp64.ONE;\n#else\n vec2 yn_sqr = twoSqr(yn);\n#endif\n float diff = sub_fp64(a, yn_sqr).x;\n vec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n",defaultUniforms:{ONE:1},uniformTypes:{ONE:"f32"},fp64ify:dl,fp64LowPart:function(e){return e-Math.fround(e)},fp64ifyMatrix4:function(e){const t=new Float32Array(32);for(let n=0;n<4;++n)for(let s=0;s<4;++s){const r=4*n+s;dl(e[4*s+n],t,2*r)}return t}},pl={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:[0,1,1,1]},vs:"uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useFloatColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nout vec4 picking_vRGBcolor_Avalid;\n\n// Normalize unsigned byte color to 0-1 range\nvec3 picking_normalizeColor(vec3 color) {\n return picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\n\n// Normalize unsigned byte color to 0-1 range\nvec4 picking_normalizeColor(vec4 color) {\n return picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\n\nbool picking_isColorZero(vec3 color) {\n return dot(color, vec3(1.0)) < 0.00001;\n}\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.00001;\n}\n\n// Check if this vertex is highlighted \nbool isVertexHighlighted(vec3 vertexColor) {\n vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n return\n bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\n\n// Set the current picking color\nvoid picking_setPickingColor(vec3 pickingColor) {\n pickingColor = picking_normalizeColor(pickingColor);\n\n if (bool(picking.isActive)) {\n // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!bool(picking.isAttribute)) {\n // Stores the picking color so that the fragment shader can render it during picking\n picking_vRGBcolor_Avalid.rgb = pickingColor;\n }\n } else {\n // Do the comparison with selected item color in vertex shader as it should mean fewer compares\n picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec2 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec3 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n",fs:"uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useFloatColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nin vec4 picking_vRGBcolor_Avalid;\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 picking_filterHighlightColor(vec4 color) {\n // If we are still picking, we don't highlight\n if (picking.isActive > 0.5) {\n return color;\n }\n\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n // Blend in highlight color based on its alpha value\n float highLightAlpha = picking.highlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 picking_filterPickingColor(vec4 color) {\n if (bool(picking.isActive)) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 picking_filterColor(vec4 color) {\n vec4 highlightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highlightColor);\n}\n",getUniforms:function(e={},t){const n={};if(void 0===e.highlightedObjectColor);else if(null===e.highlightedObjectColor)n.isHighlightActive=!1;else{n.isHighlightActive=!0;const t=e.highlightedObjectColor.slice(0,3);n.highlightedObjectColor=t}if(e.highlightColor){const t=Array.from(e.highlightColor,e=>e/255);Number.isFinite(t[3])||(t[3]=1),n.highlightColor=t}return void 0!==e.isActive&&(n.isActive=Boolean(e.isActive),n.isAttribute=Boolean(e.isAttribute)),void 0!==e.useFloatColors&&(n.useFloatColors=Boolean(e.useFloatColors)),n}},gl="uniform layerUniforms {\n uniform float opacity;\n} layer;\n",ml={name:"layer",vs:gl,fs:gl,getUniforms:e=>({opacity:Math.pow(e.opacity,1/2.2)}),uniformTypes:{opacity:"f32"}},_l={name:"color",dependencies:[],source:"\n\nstruct ColorUniforms {\n opacity: f32,\n};\n\nvar color: ColorUniforms = ColorUniforms(1.0);\n// TODO (kaapp) avoiding binding index collisions to handle layer opacity \n// requires some thought.\n// @group(0) @binding(0) var color: ColorUniforms;\n\n@must_use\nfn deckgl_premultiplied_alpha(fragColor: vec4) -> vec4 {\n return vec4(fragColor.rgb * fragColor.a, fragColor.a); \n};\n",getUniforms:e=>({}),uniformTypes:{opacity:"f32"}},yl="#define SMOOTH_EDGE_RADIUS 0.5",bl={name:"geometry",source:"const SMOOTH_EDGE_RADIUS: f32 = 0.5;\n\nstruct VertexGeometry {\n position: vec4,\n worldPosition: vec3,\n worldPositionAlt: vec3,\n normal: vec3,\n uv: vec2,\n pickingColor: vec3,\n};\n\nvar geometry_: VertexGeometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0, 0.0, 0.0),\n vec3(0.0, 0.0, 0.0),\n vec3(0.0, 0.0, 0.0),\n vec2(0.0, 0.0),\n vec3(0.0, 0.0, 0.0)\n);\n\nstruct FragmentGeometry {\n uv: vec2,\n};\n\nvar fragmentGeometry: FragmentGeometry;\n\nfn smoothedge(edge: f32, x: f32) -> f32 {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n",vs:`${yl}\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n`,fs:`${yl}\n\nstruct FragmentGeometry {\n vec2 uv;\n} geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n`};var vl,xl,wl,El,Tl,Sl;(xl=vl||(vl={}))[xl.Start=1]="Start",xl[xl.Move=2]="Move",xl[xl.End=4]="End",xl[xl.Cancel=8]="Cancel",(El=wl||(wl={}))[El.None=0]="None",El[El.Left=1]="Left",El[El.Right=2]="Right",El[El.Up=4]="Up",El[El.Down=8]="Down",El[El.Horizontal=3]="Horizontal",El[El.Vertical=12]="Vertical",El[El.All=15]="All",(Sl=Tl||(Tl={}))[Sl.Possible=1]="Possible",Sl[Sl.Began=2]="Began",Sl[Sl.Changed=4]="Changed",Sl[Sl.Ended=8]="Ended",Sl[Sl.Recognized=8]="Recognized",Sl[Sl.Cancelled=16]="Cancelled",Sl[Sl.Failed=32]="Failed";const Al="manipulation",Rl="none",Cl="pan-x",Pl="pan-y";class kl{constructor(e,t){this.actions="",this.manager=e,this.set(t)}set(e){"compute"===e&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(const t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return function(e){if(e.includes(Rl))return Rl;const t=e.includes(Cl),n=e.includes(Pl);return t&&n?Rl:t||n?t?Cl:Pl:e.includes(Al)?Al:"auto"}(e.join(" "))}}function Il(e){return e.trim().split(/\s+/g)}function Ml(e,t,n){if(e)for(const s of Il(t))e.addEventListener(s,n,!1)}function Ll(e,t,n){if(e)for(const s of Il(t))e.removeEventListener(s,n,!1)}function Nl(e){return(e.ownerDocument||e).defaultView}function Ol(e){const t=e.length;if(1===t)return{x:Math.round(e[0].clientX),y:Math.round(e[0].clientY)};let n=0,s=0,r=0;for(;r=Math.abs(t)?e<0?wl.Left:wl.Right:t<0?wl.Up:wl.Down}function Gl(e,t,n){return{x:t/e||0,y:n/e||0}}let Vl=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=e=>{this.manager.options.enable&&this.handler(e)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){!function(e,t,n){const s=n.pointers.length,r=n.changedPointers.length,i=t&vl.Start&&s-r===0,o=t&(vl.End|vl.Cancel)&&s-r===0;n.isFirst=Boolean(i),n.isFinal=Boolean(o),i&&(e.session={}),n.eventType=t;const a=function(e,t){const{session:n}=e,{pointers:s}=t,{length:r}=s;n.firstInput||(n.firstInput=Fl(t)),r>1&&!n.firstMultiple?n.firstMultiple=Fl(t):1===r&&(n.firstMultiple=!1);const{firstInput:i,firstMultiple:o}=n,a=o?o.center:i.center,l=t.center=Ol(s);t.timeStamp=Date.now(),t.deltaTime=t.timeStamp-i.timeStamp,t.angle=function(e,t){const n=t.x-e.x,s=t.y-e.y;return 180*Math.atan2(s,n)/Math.PI}(a,l),t.distance=Dl(a,l);const{deltaX:c,deltaY:u}=function(e,t){const n=t.center;let s=e.offsetDelta,r=e.prevDelta;const i=e.prevInput;return t.eventType!==vl.Start&&(null==i?void 0:i.eventType)!==vl.End||(r=e.prevDelta={x:(null==i?void 0:i.deltaX)||0,y:(null==i?void 0:i.deltaY)||0},s=e.offsetDelta={x:n.x,y:n.y}),{deltaX:r.x+(n.x-s.x),deltaY:r.y+(n.y-s.y)}}(n,t);t.deltaX=c,t.deltaY=u,t.offsetDirection=jl(t.deltaX,t.deltaY);const h=Gl(t.deltaTime,t.deltaX,t.deltaY);var d,f;t.overallVelocityX=h.x,t.overallVelocityY=h.y,t.overallVelocity=Math.abs(h.x)>Math.abs(h.y)?h.x:h.y,t.scale=o?(d=o.pointers,Bl((f=s)[0],f[1])/Bl(d[0],d[1])):1,t.rotation=o?function(e,t){return Ul(t[1],t[0])-Ul(e[1],e[0])}(o.pointers,s):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length;let p=e.element;return function(e,t){let n=e;for(;n;){if(n===t)return!0;n=n.parentNode}return!1}(t.srcEvent.target,p)&&(p=t.srcEvent.target),t.target=p,function(e,t){const n=e.lastInterval||t,s=t.timeStamp-n.timeStamp;let r,i,o,a;if(t.eventType!==vl.Cancel&&(s>25||void 0===n.velocity)){const l=t.deltaX-n.deltaX,c=t.deltaY-n.deltaY,u=Gl(s,l,c);i=u.x,o=u.y,r=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=jl(l,c),e.lastInterval=t}else r=n.velocity,i=n.velocityX,o=n.velocityY,a=n.direction;t.velocity=r,t.velocityX=i,t.velocityY=o,t.direction=a}(n,t),t}(e,n);e.emit("hammer.input",a),e.recognize(a),e.session.prevInput=a}(this.manager,e,t)}init(){Ml(this.element,this.evEl,this.domHandler),Ml(this.target,this.evTarget,this.domHandler),Ml(Nl(this.element),this.evWin,this.domHandler)}destroy(){Ll(this.element,this.evEl,this.domHandler),Ll(this.target,this.evTarget,this.domHandler),Ll(Nl(this.element),this.evWin,this.domHandler)}};const zl={pointerdown:vl.Start,pointermove:vl.Move,pointerup:vl.End,pointercancel:vl.Cancel,pointerout:vl.Cancel};class Wl extends Vl{constructor(e){super(e),this.evEl="pointerdown",this.evWin="pointermove pointerup pointercancel",this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){const{store:t}=this;let n=!1;const s=zl[e.type],r=e.pointerType,i="touch"===r;let o=t.findIndex(t=>t.pointerId===e.pointerId);s&vl.Start&&(e.buttons||i)?o<0&&(t.push(e),o=t.length-1):s&(vl.End|vl.Cancel)&&(n=!0),o<0||(t[o]=e,this.callback(s,{pointers:t,changedPointers:[e],eventType:s,pointerType:r,srcEvent:e}),n&&t.splice(o,1))}}const Hl=["","webkit","Moz","MS","ms","o"];function $l(e,t){const n=t[0].toUpperCase()+t.slice(1);for(const s of Hl){const r=s?s+n:t;if(r in e)return r}}const Xl={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}};class ql{constructor(e,t){this.options={...Xl,...t,cssProps:{...Xl.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new Wl(this),this.touchAction=new kl(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?2:1}recognize(e){const{session:t}=this;if(t.stopped)return;let n;this.session.prevented&&e.srcEvent.preventDefault();const{recognizers:s}=this;let{curRecognizer:r}=t;(!r||r&&r.state&Tl.Recognized)&&(r=t.curRecognizer=null);let i=0;for(;i-1&&this.requireFail.splice(e,1)}return this}hasRequireFailures(){return Boolean(this.requireFail.find(e=>e.options.enable))}canRecognizeWith(e){return Boolean(this.simultaneous[e.id])}emit(e){if(!e)return;const{state:t}=this;t=Tl.Ended&&this.manager.emit(this.options.event+Kl(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=Tl.Failed}canEmit(){let e=0;for(;e{this.state=Tl.Recognized,this.tryEmit(this._input)},t.interval),Tl.Began):Tl.Recognized}return Tl.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=Tl.Failed},this.options.interval),Tl.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===Tl.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}}const ec=["","start","move","end","cancel","up","down","left","right"];class tc extends Ql{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:wl.All,...e}),this.pX=null,this.pY=null}getTouchAction(){const{options:{direction:e}}=this,t=[];return e&wl.Horizontal&&t.push(Pl),e&wl.Vertical&&t.push(Cl),t}getEventNames(){return ec.map(e=>this.options.event+e)}directionTest(e){const{options:t}=this;let n=!0,{distance:s}=e,{direction:r}=e;const i=e.deltaX,o=e.deltaY;return r&t.direction||(t.direction&wl.Horizontal?(r=0===i?wl.None:i<0?wl.Left:wl.Right,n=i!==this.pX,s=Math.abs(e.deltaX)):(r=0===o?wl.None:o<0?wl.Up:wl.Down,n=o!==this.pY,s=Math.abs(e.deltaY))),e.direction=r,n&&s>t.threshold&&Boolean(r&t.direction)}attrTest(e){return super.attrTest(e)&&(Boolean(this.state&Tl.Began)||!(this.state&Tl.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;const t=wl[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}}const nc=["","start","move","end","cancel","in","out"];class sc{constructor(e,t,n){this.element=e,this.callback=t,this.options=n}}const rc=-1!==("undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"").indexOf("firefox"),ic=4.000244140625;class oc extends sc{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{if(!this.options.enable)return;let t=e.deltaY;globalThis.WheelEvent&&(rc&&e.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(t/=globalThis.devicePixelRatio),e.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(t*=40)),0!==t&&t%ic===0&&(t=Math.floor(t/ic)),e.shiftKey&&t&&(t*=.25),this.callback({type:"wheel",center:{x:e.clientX,y:e.clientY},delta:-t,srcEvent:e,pointerType:"mouse",target:e.target})},e.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(e,t){"wheel"===e&&(this.options.enable=t)}}const ac=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"];class lc extends sc{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{this.handleOverEvent(e),this.handleOutEvent(e),this.handleEnterEvent(e),this.handleLeaveEvent(e),this.handleMoveEvent(e)},this.pressed=!1;const{enable:s}=this.options;this.enableMoveEvent=s,this.enableLeaveEvent=s,this.enableEnterEvent=s,this.enableOutEvent=s,this.enableOverEvent=s,ac.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){ac.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){switch(e){case"pointermove":this.enableMoveEvent=t;break;case"pointerover":this.enableOverEvent=t;break;case"pointerout":this.enableOutEvent=t;break;case"pointerenter":this.enableEnterEvent=t;break;case"pointerleave":this.enableLeaveEvent=t}}handleOverEvent(e){this.enableOverEvent&&"mouseover"===e.type&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&"mouseout"===e.type&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&"mouseenter"===e.type&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&"mouseleave"===e.type&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":0===e.buttons&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}}const cc=["keydown","keyup"];class uc extends sc{constructor(e,t,n){super(e,t,{enable:!0,tabIndex:0,...n}),this.handleEvent=e=>{const t=e.target||e.srcElement;"INPUT"===t.tagName&&"text"===t.type||"TEXTAREA"===t.tagName||(this.enableDownEvent&&"keydown"===e.type&&this.callback({type:"keydown",srcEvent:e,key:e.key,target:e.target}),this.enableUpEvent&&"keyup"===e.type&&this.callback({type:"keyup",srcEvent:e,key:e.key,target:e.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline="none",cc.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){cc.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){"keydown"===e&&(this.enableDownEvent=t),"keyup"===e&&(this.enableUpEvent=t)}}class hc extends sc{constructor(e,t,n){super(e,t,n),this.handleEvent=e=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:"mouse",target:e.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,t){"contextmenu"===e&&(this.options.enable=t)}}const dc={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4};function fc(e){const t=dc[e.srcEvent.type];if(!t)return null;const{buttons:n,button:s}=e.srcEvent;let r=!1,i=!1,o=!1;return 2===t?(r=Boolean(1&n),i=Boolean(4&n),o=Boolean(2&n)):(r=0===s,i=1===s,o=2===s),{leftButton:r,middleButton:i,rightButton:o}}function pc(e,t){const n=e.center;if(!n)return null;const s=t.getBoundingClientRect(),r=s.width/t.offsetWidth||1,i=s.height/t.offsetHeight||1;return{center:n,offsetCenter:{x:(n.x-s.left-t.clientLeft)/r,y:(n.y-s.top-t.clientTop)/i}}}const gc={srcElement:"root",priority:0};class mc{constructor(e,t){this.handleEvent=e=>{if(this.isEmpty())return;const t=this._normalizeEvent(e);let n=e.srcEvent.target;for(;n&&n!==t.rootElement;){if(this._emit(t,n),t.handled)return;n=n.parentNode}this._emit(t,"root")},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,n,s=!1,r=!1){const{handlers:i,handlersByElement:o}=this,a={...gc,...n};let l=o.get(a.srcElement);l||(l=[],o.set(a.srcElement,l));const c={type:e,handler:t,srcElement:a.srcElement,priority:a.priority};s&&(c.once=!0),r&&(c.passive=!0),i.push(c),this._active=this._active||!c.passive;let u=l.length-1;for(;u>=0&&!(l[u].priority>=c.priority);)u--;l.splice(u+1,0,c)}remove(e,t){const{handlers:n,handlersByElement:s}=this;for(let r=n.length-1;r>=0;r--){const i=n[r];if(i.type===e&&i.handler===t){n.splice(r,1);const e=s.get(i.srcElement);e.splice(e.indexOf(i),1),0===e.length&&s.delete(i.srcElement)}}this._active=n.some(e=>!e.passive)}_emit(e,t){const n=this.handlersByElement.get(t);if(n){let t=!1;const s=()=>{e.handled=!0},r=()=>{e.handled=!0,t=!0},i=[];for(let o=0;o{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}}function _c(e){if("recognizer"in e)return e;let t;const n=Array.isArray(e)?[...e]:[e];return t="function"==typeof n[0]?new(n.shift())(n.shift()||{}):n.shift(),{recognizer:t,recognizeWith:"string"==typeof n[0]?[n[0]]:n[0],requireFailure:"string"==typeof n[1]?[n[1]]:n[1]}}class yc{constructor(e=null,t={}){if(this._onBasicInput=e=>{this.manager.emit(e.srcEvent.type,e)},this._onOtherEvent=e=>{this.manager.emit(e.type,e)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,e){this.manager=new ql(e,this.options);for(const e of this.options.recognizers){const{recognizer:t,recognizeWith:n,requireFailure:s}=_c(e);this.manager.add(t),n&&t.recognizeWith(n),s&&t.requireFailure(s)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new oc(e,this._onOtherEvent,{enable:!1}),this.moveInput=new lc(e,this._onOtherEvent,{enable:!1}),this.keyInput=new uc(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new hc(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,t,n){this._addEventHandler(e,t,n,!1)}once(e,t,n){this._addEventHandler(e,t,n,!0)}watch(e,t,n){this._addEventHandler(e,t,n,!1,!0)}off(e,t){this._removeEventHandler(e,t)}_toggleRecognizer(e,t){var n,s,r,i;const{manager:o}=this;if(!o)return;const a=o.get(e);a&&(a.set({enable:t}),o.touchAction.update()),null==(n=this.wheelInput)||n.enableEventType(e,t),null==(s=this.moveInput)||s.enableEventType(e,t),null==(r=this.keyInput)||r.enableEventType(e,t),null==(i=this.contextmenuInput)||i.enableEventType(e,t)}_addEventHandler(e,t,n,s,r){if("string"!=typeof e){n=t;for(const[t,i]of Object.entries(e))this._addEventHandler(t,i,n,s,r);return}const{manager:i,events:o}=this;if(!i)return;let a=o.get(e);if(!a){const t=this._getRecognizerName(e)||e;a=new mc(this,t),o.set(e,a),i&&i.on(e,a.handleEvent)}a.add(e,t,n,s,r),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(e,t){if("string"!=typeof e){for(const[t,n]of Object.entries(e))this._removeEventHandler(t,n);return}const{events:n}=this,s=n.get(e);if(s&&(s.remove(e,t),s.isEmpty())){const{recognizerName:e}=s;let t=!1;for(const s of n.values())if(s.recognizerName===e&&!s.isEmpty()){t=!0;break}t||this._toggleRecognizer(e,!1)}}_getRecognizerName(e){var t;return null==(t=this.manager.recognizers.find(t=>t.getEventNames().includes(e)))?void 0:t.options.event}}const bc={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(bc,"IDENTITY",{get:()=>(Fn.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const vc={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},xc={common:0,meters:1,pixels:2},wc={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},Ec={multipan:[tc,{threshold:10,direction:wl.Vertical,pointers:2}],pinch:[class extends Ql{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[Rl]}getEventNames(){return nc.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||Boolean(this.state&Tl.Began))}emit(e){if(1!==e.scale){const t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}super.emit(e)}},{},null,["multipan"]],pan:[tc,{threshold:1},["pinch"],["multipan"]],dblclick:[Jl,{event:"dblclick",taps:2}],click:[Jl,{event:"click"},null,["dblclick"]]};function Tc(e,t){if(e===t)return!0;if(Array.isArray(e)){const n=e.length;if(!t||t.length!==n)return!1;for(let s=0;s{for(const r in s)if(!Tc(s[r],n[r])){t=e(s),n=s;break}return t}}const Ac=[0,0,0,0],Rc=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],Cc=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Pc=[0,0,0],kc=[0,0,0],Ic=Sc(function({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:s}){const{projectionCenter:r,viewProjectionMatrix:i,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:l,geospatialOrigin:c}=function(e,t,n){const{viewMatrixUncentered:s,projectionMatrix:r}=e;let{viewMatrix:i,viewProjectionMatrix:o}=e,a=Ac,l=Ac,c=e.cameraPosition;const{geospatialOrigin:u,shaderCoordinateOrigin:h,offsetMode:d}=Mc(e,t,n);return d&&(l=e.projectPosition(u||h),c=[c[0]-l[0],c[1]-l[1],c[2]-l[2]],l[3]=1,a=el([],l,o),i=s||i,o=qa([],r,i),o=qa([],o,Rc)),{viewMatrix:i,viewProjectionMatrix:o,projectionCenter:a,originCommon:l,cameraPosCommon:c,shaderCoordinateOrigin:h,geospatialOrigin:u}}(e,n,s),u=e.getDistanceScales(),h=[e.width*t,e.height*t],d=el([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,f={coordinateSystem:n,projectionMode:e.projectionMode,coordinateOrigin:l,commonOrigin:o.slice(0,3),center:r,pseudoMeters:Boolean(e._pseudoMeters),viewportSize:h,devicePixelRatio:t,focalDistance:d,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:Pc,scale:e.scale,wrapLongitude:!1,viewProjectionMatrix:i,modelMatrix:Cc,cameraPosition:a};if(c){const t=e.getDistanceScales(c);switch(n){case bc.METER_OFFSETS:f.commonUnitsPerWorldUnit=t.unitsPerMeter,f.commonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case bc.LNGLAT:case bc.LNGLAT_OFFSETS:e._pseudoMeters||(f.commonUnitsPerMeter=t.unitsPerMeter),f.commonUnitsPerWorldUnit=t.unitsPerDegree,f.commonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case bc.CARTESIAN:f.commonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],f.commonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]]}}return f});function Mc(e,t,n=kc){n.length<3&&(n=[n[0],n[1],0]);let s,r=n,i=!0;switch(s=t===bc.LNGLAT_OFFSETS||t===bc.METER_OFFSETS?n:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case vc.WEB_MERCATOR:t!==bc.LNGLAT&&t!==bc.CARTESIAN||(s=[0,0,0],i=!1);break;case vc.WEB_MERCATOR_AUTO_OFFSET:t===bc.LNGLAT?r=s:t===bc.CARTESIAN&&(r=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],s=e.unprojectPosition(r),r[0]-=n[0],r[1]-=n[1],r[2]-=n[2]);break;case vc.IDENTITY:r=e.position.map(Math.fround),r[2]=r[2]||0;break;case vc.GLOBE:i=!1,s=null;break;default:i=!1}return{geospatialOrigin:s,shaderCoordinateOrigin:r,offsetMode:i}}const Lc=`${Object.keys(bc).map(e=>`const COORDINATE_SYSTEM_${e}: i32 = ${bc[e]};`).join("")}\n${Object.keys(vc).map(e=>`const PROJECTION_MODE_${e}: i32 = ${vc[e]};`).join("")}\n${Object.keys(xc).map(e=>`const UNIT_${e.toUpperCase()}: i32 = ${xc[e]};`).join("")}\n\nconst TILE_SIZE: f32 = 512.0;\nconst PI: f32 = 3.1415926536;\nconst WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0);\nconst ZERO_64_LOW: vec3 = vec3(0.0, 0.0, 0.0);\nconst EARTH_RADIUS: f32 = 6370972.0; // meters\nconst GLOBE_RADIUS: f32 = 256.0;\n\n// -----------------------------------------------------------------------------\n// Uniform block (converted from GLSL uniform block)\n// -----------------------------------------------------------------------------\nstruct ProjectUniforms {\n wrapLongitude: i32,\n coordinateSystem: i32,\n commonUnitsPerMeter: vec3,\n projectionMode: i32,\n scale: f32,\n commonUnitsPerWorldUnit: vec3,\n commonUnitsPerWorldUnit2: vec3,\n center: vec4,\n modelMatrix: mat4x4,\n viewProjectionMatrix: mat4x4,\n viewportSize: vec2,\n devicePixelRatio: f32,\n focalDistance: f32,\n cameraPosition: vec3,\n coordinateOrigin: vec3,\n commonOrigin: vec3,\n pseudoMeters: i32,\n};\n\n@group(0) @binding(0)\nvar project: ProjectUniforms;\n\n// -----------------------------------------------------------------------------\n// Geometry data\n// (In your GLSL code, "geometry" was assumed to be available globally. In WGSL,\n// you might supply this via vertex attributes or a uniform. Here we define a\n// uniform struct for demonstration.)\n// -----------------------------------------------------------------------------\n\n// Structure to carry additional geometry data used by deck.gl filters.\nstruct Geometry {\n worldPosition: vec3,\n worldPositionAlt: vec3,\n position: vec4,\n normal: vec3,\n uv: vec2,\n pickingColor: vec3,\n};\n\n// @group(0) @binding(1)\nvar geometry: Geometry;\n\n\n// -----------------------------------------------------------------------------\n// Functions\n// -----------------------------------------------------------------------------\n\n// Returns an adjustment factor for commonUnitsPerMeter\nfn _project_size_at_latitude(lat: f32) -> f32 {\n let y = clamp(lat, -89.9, 89.9);\n return 1.0 / cos(radians(y));\n}\n\n// Overloaded version: scales a value in meters at a given latitude.\nfn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 {\n return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat);\n}\n\n// Computes a non-linear scale factor based on geometry.\n// (Note: This function relies on "geometry" being provided.)\nfn project_size() -> f32 {\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&\n project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\n project.pseudoMeters == 0) {\n if (geometry.position.w == 0.0) {\n return _project_size_at_latitude(geometry.worldPosition.y);\n }\n let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\n let y2 = y * y;\n let y4 = y2 * y2;\n let y6 = y4 * y2;\n return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n }\n return 1.0;\n}\n\n// Overloads to scale offsets (meters to world units)\nfn project_size_float(meters: f32) -> f32 {\n return meters * project.commonUnitsPerMeter.z * project_size();\n}\n\nfn project_size_vec2(meters: vec2) -> vec2 {\n return meters * project.commonUnitsPerMeter.xy * project_size();\n}\n\nfn project_size_vec3(meters: vec3) -> vec3 {\n return meters * project.commonUnitsPerMeter * project_size();\n}\n\nfn project_size_vec4(meters: vec4) -> vec4 {\n return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);\n}\n\n// Returns a rotation matrix aligning the z‑axis with the given up vector.\nfn project_get_orientation_matrix(up: vec3) -> mat3x3 {\n let uz = normalize(up);\n let ux = select(\n vec3(1.0, 0.0, 0.0),\n normalize(vec3(uz.y, -uz.x, 0.0)),\n abs(uz.z) == 1.0\n );\n let uy = cross(uz, ux);\n return mat3x3(ux, uy, uz);\n}\n\n// Since WGSL does not support "out" parameters, we return a struct.\nstruct RotationResult {\n needsRotation: bool,\n transform: mat3x3,\n};\n\nfn project_needs_rotation(commonPosition: vec3) -> RotationResult {\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n return RotationResult(true, project_get_orientation_matrix(commonPosition));\n } else {\n return RotationResult(false, mat3x3()); // identity alternative if needed\n };\n}\n\n// Projects a normal vector from the current coordinate system to world space.\nfn project_normal(vector: vec3) -> vec3 {\n let normal_modelspace = project.modelMatrix * vec4(vector, 0.0);\n var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);\n let rotResult = project_needs_rotation(geometry.position.xyz);\n if (rotResult.needsRotation) {\n n = rotResult.transform * n;\n }\n return n;\n}\n\n// Applies a scale offset based on y-offset (dy)\nfn project_offset_(offset: vec4) -> vec4 {\n let dy: f32 = offset.y;\n let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;\n return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\n\n// Projects lng/lat coordinates to a unit tile [0,1]\nfn project_mercator_(lnglat: vec2) -> vec2 {\n var x = lnglat.x;\n if (project.wrapLongitude != 0) {\n x = ((x + 180.0) % 360.0) - 180.0;\n }\n let y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// Projects lng/lat/z coordinates for a globe projection.\nfn project_globe_(lnglatz: vec3) -> vec3 {\n let lambda = radians(lnglatz.x);\n let phi = radians(lnglatz.y);\n let cosPhi = cos(phi);\n let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\n return vec3(\n sin(lambda) * cosPhi,\n -cos(lambda) * cosPhi,\n sin(phi)\n ) * D;\n}\n\n// Projects positions (with an optional 64-bit low part) from the input\n// coordinate system to the common space.\nfn project_position_vec4_f64(position: vec4, position64Low: vec3) -> vec4 {\n var position_world = project.modelMatrix * position;\n\n // Work around for a Mac+NVIDIA bug:\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4(\n project_mercator_(position_world.xy),\n _project_size_at_latitude_m(position_world.z, position_world.y),\n position_world.w\n );\n }\n if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\n position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w);\n }\n }\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4(\n project_globe_(position_world.xyz),\n position_world.w\n );\n }\n }\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {\n return vec4(\n project_mercator_(position_world.xy) - project.commonOrigin.xy,\n project_size_float(position_world.z),\n position_world.w\n );\n }\n }\n }\n if (project.projectionMode == PROJECTION_MODE_IDENTITY ||\n (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\n position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w);\n }\n\n return project_offset_(position_world) +\n project_offset_(project.modelMatrix * vec4(position64Low, 0.0));\n}\n\n// Overloaded versions for different input types.\nfn project_position_vec4_f32(position: vec4) -> vec4 {\n return project_position_vec4_f64(position, ZERO_64_LOW);\n}\n\nfn project_position_vec3_f64(position: vec3, position64Low: vec3) -> vec3 {\n let projected_position = project_position_vec4_f64(vec4(position, 1.0), position64Low);\n return projected_position.xyz;\n}\n\nfn project_position_vec3_f32(position: vec3) -> vec3 {\n let projected_position = project_position_vec4_f64(vec4(position, 1.0), ZERO_64_LOW);\n return projected_position.xyz;\n}\n\nfn project_position_vec2_f32(position: vec2) -> vec2 {\n let projected_position = project_position_vec4_f64(vec4(position, 0.0, 1.0), ZERO_64_LOW);\n return projected_position.xy;\n}\n\n// Transforms a common space position to clip space.\nfn project_common_position_to_clipspace_with_projection(position: vec4, viewProjectionMatrix: mat4x4, center: vec4) -> vec4 {\n return viewProjectionMatrix * position + center;\n}\n\n// Uses the project viewProjectionMatrix and center.\nfn project_common_position_to_clipspace(position: vec4) -> vec4 {\n return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center);\n}\n\n// Returns a clip space offset corresponding to a given number of screen pixels.\nfn project_pixel_size_to_clipspace(pixels: vec2) -> vec2 {\n let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;\n return offset * project.focalDistance;\n}\n\nfn project_meter_size_to_pixel(meters: f32) -> f32 {\n return project_size_float(meters) * project.scale;\n}\n\nfn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 {\n if (unit == UNIT_METERS) {\n return project_meter_size_to_pixel(size);\n } else if (unit == UNIT_COMMON) {\n return size * project.scale;\n }\n // UNIT_PIXELS: no scaling applied.\n return size;\n}\n\nfn project_pixel_size_float(pixels: f32) -> f32 {\n return pixels / project.scale;\n}\n\nfn project_pixel_size_vec2(pixels: vec2) -> vec2 {\n return pixels / project.scale;\n}\n`,Nc=Object.keys(bc).map(e=>`const int COORDINATE_SYSTEM_${e} = ${bc[e]};`).join(""),Oc=Object.keys(vc).map(e=>`const int PROJECTION_MODE_${e} = ${vc[e]};`).join(""),Fc=Object.keys(xc).map(e=>`const int UNIT_${e.toUpperCase()} = ${xc[e]};`).join(""),Dc={},Bc={name:"project",dependencies:[{name:"fp32",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n\n// All these functions are for substituting tan() function from Intel GPU only\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\n\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\n\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\n\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3!\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5!\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9!\n\nfloat sin_taylor_fp32(float a) {\n float r, s, t, x;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n x = -a * a;\n s = a;\n r = a;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_3;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_5;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_7;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_9;\n s = s + t;\n\n return s;\n}\n\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\n if (a == 0.0) {\n sin_t = 0.0;\n cos_t = 1.0;\n }\n sin_t = sin_taylor_fp32(a);\n cos_t = sqrt(1.0 - sin_t * sin_t);\n}\n\nfloat tan_taylor_fp32(float a) {\n float sin_a;\n float cos_a;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n // 2pi range reduction\n float z = floor(a / TWO_PI);\n float r = a - TWO_PI * z;\n\n float t;\n float q = floor(r / PI_2 + 0.5);\n int j = int(q);\n\n if (j < -2 || j > 2) {\n return 1.0 / 0.0;\n }\n\n t = r - PI_2 * q;\n\n q = floor(t / PI_16 + 0.5);\n int k = int(q);\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return 1.0 / 0.0;\n } else {\n t = t - PI_16 * q;\n }\n\n float u = 0.0;\n float v = 0.0;\n\n float sin_t, cos_t;\n float s, c;\n sincos_taylor_fp32(t, sin_t, cos_t);\n\n if (k == 0) {\n s = sin_t;\n c = cos_t;\n } else {\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0;\n v = SIN_TABLE_0;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1;\n v = SIN_TABLE_1;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2;\n v = SIN_TABLE_2;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3;\n v = SIN_TABLE_3;\n }\n if (k > 0) {\n s = u * sin_t + v * cos_t;\n c = u * cos_t - v * sin_t;\n } else {\n s = u * sin_t - v * cos_t;\n c = u * cos_t + v * sin_t;\n }\n }\n\n if (j == 0) {\n sin_a = s;\n cos_a = c;\n } else if (j == 1) {\n sin_a = c;\n cos_a = -s;\n } else if (j == -1) {\n sin_a = -c;\n cos_a = s;\n } else {\n sin_a = -s;\n cos_a = -c;\n }\n return sin_a / cos_a;\n}\n#endif\n\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n return tan_taylor_fp32(a);\n#else\n return tan(a);\n#endif\n}\n"},bl],source:Lc,vs:`${Nc}\n${Oc}\n${Fc}\nuniform projectUniforms {\nbool wrapLongitude;\nint coordinateSystem;\nvec3 commonUnitsPerMeter;\nint projectionMode;\nfloat scale;\nvec3 commonUnitsPerWorldUnit;\nvec3 commonUnitsPerWorldUnit2;\nvec4 center;\nmat4 modelMatrix;\nmat4 viewProjectionMatrix;\nvec2 viewportSize;\nfloat devicePixelRatio;\nfloat focalDistance;\nvec3 cameraPosition;\nvec3 coordinateOrigin;\nvec3 commonOrigin;\nbool pseudoMeters;\n} project;\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / (PI * 2.0);\nconst vec3 ZERO_64_LOW = vec3(0.0);\nconst float EARTH_RADIUS = 6370972.0;\nconst float GLOBE_RADIUS = 256.0;\nfloat project_size_at_latitude(float lat) {\nfloat y = clamp(lat, -89.9, 89.9);\nreturn 1.0 / cos(radians(y));\n}\nfloat project_size() {\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&\nproject.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\nproject.pseudoMeters == false) {\nif (geometry.position.w == 0.0) {\nreturn project_size_at_latitude(geometry.worldPosition.y);\n}\nfloat y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\nfloat y2 = y * y;\nfloat y4 = y2 * y2;\nfloat y6 = y4 * y2;\nreturn 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n}\nreturn 1.0;\n}\nfloat project_size_at_latitude(float meters, float lat) {\nreturn meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat);\n}\nfloat project_size(float meters) {\nreturn meters * project.commonUnitsPerMeter.z * project_size();\n}\nvec2 project_size(vec2 meters) {\nreturn meters * project.commonUnitsPerMeter.xy * project_size();\n}\nvec3 project_size(vec3 meters) {\nreturn meters * project.commonUnitsPerMeter * project_size();\n}\nvec4 project_size(vec4 meters) {\nreturn vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);\n}\nmat3 project_get_orientation_matrix(vec3 up) {\nvec3 uz = normalize(up);\nvec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));\nvec3 uy = cross(uz, ux);\nreturn mat3(ux, uy, uz);\n}\nbool project_needs_rotation(vec3 commonPosition, out mat3 transform) {\nif (project.projectionMode == PROJECTION_MODE_GLOBE) {\ntransform = project_get_orientation_matrix(commonPosition);\nreturn true;\n}\nreturn false;\n}\nvec3 project_normal(vec3 vector) {\nvec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0);\nvec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);\nmat3 rotation;\nif (project_needs_rotation(geometry.position.xyz, rotation)) {\nn = rotation * n;\n}\nreturn n;\n}\nvec4 project_offset_(vec4 offset) {\nfloat dy = offset.y;\nvec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;\nreturn vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\nvec2 project_mercator_(vec2 lnglat) {\nfloat x = lnglat.x;\nif (project.wrapLongitude) {\nx = mod(x + 180., 360.0) - 180.;\n}\nfloat y = clamp(lnglat.y, -89.9, 89.9);\nreturn vec2(\nradians(x) + PI,\nPI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n) * WORLD_SCALE;\n}\nvec3 project_globe_(vec3 lnglatz) {\nfloat lambda = radians(lnglatz.x);\nfloat phi = radians(lnglatz.y);\nfloat cosPhi = cos(phi);\nfloat D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\nreturn vec3(\nsin(lambda) * cosPhi,\n-cos(lambda) * cosPhi,\nsin(phi)\n) * D;\n}\nvec4 project_position(vec4 position, vec3 position64Low) {\nvec4 position_world = project.modelMatrix * position;\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_mercator_(position_world.xy),\nproject_size_at_latitude(position_world.z, position_world.y),\nposition_world.w\n);\n}\nif (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\nposition_world.xyz += project.coordinateOrigin;\n}\n}\nif (project.projectionMode == PROJECTION_MODE_GLOBE) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_globe_(position_world.xyz),\nposition_world.w\n);\n}\n}\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nif (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {\nreturn vec4(\nproject_mercator_(position_world.xy) - project.commonOrigin.xy,\nproject_size(position_world.z),\nposition_world.w\n);\n}\n}\n}\nif (project.projectionMode == PROJECTION_MODE_IDENTITY ||\n(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\nposition_world.xyz -= project.coordinateOrigin;\n}\nreturn project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0));\n}\nvec4 project_position(vec4 position) {\nreturn project_position(position, ZERO_64_LOW);\n}\nvec3 project_position(vec3 position, vec3 position64Low) {\nvec4 projected_position = project_position(vec4(position, 1.0), position64Low);\nreturn projected_position.xyz;\n}\nvec3 project_position(vec3 position) {\nvec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);\nreturn projected_position.xyz;\n}\nvec2 project_position(vec2 position) {\nvec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);\nreturn projected_position.xy;\n}\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\nreturn viewProjectionMatrix * position + center;\n}\nvec4 project_common_position_to_clipspace(vec4 position) {\nreturn project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center);\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\nvec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;\nreturn offset * project.focalDistance;\n}\nfloat project_size_to_pixel(float meters) {\nreturn project_size(meters) * project.scale;\n}\nfloat project_size_to_pixel(float size, int unit) {\nif (unit == UNIT_METERS) return project_size_to_pixel(size);\nif (unit == UNIT_COMMON) return size * project.scale;\nreturn size;\n}\nfloat project_pixel_size(float pixels) {\nreturn pixels / project.scale;\n}\nvec2 project_pixel_size(vec2 pixels) {\nreturn pixels / project.scale;\n}\n`,getUniforms:function(e=Dc){return"viewport"in e?function({viewport:e,devicePixelRatio:t=1,modelMatrix:n=null,coordinateSystem:s=bc.DEFAULT,coordinateOrigin:r=kc,autoWrapLongitude:i=!1}){s===bc.DEFAULT&&(s=e.isGeospatial?bc.LNGLAT:bc.CARTESIAN);const o=Ic({viewport:e,devicePixelRatio:t,coordinateSystem:s,coordinateOrigin:r});return o.wrapLongitude=i,o.modelMatrix=n||Cc,o}(e):{}},uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3",commonUnitsPerWorldUnit2:"vec3",center:"vec4",modelMatrix:"mat4x4",viewProjectionMatrix:"mat4x4",viewportSize:"vec2",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3",coordinateOrigin:"vec3",commonOrigin:"vec3",pseudoMeters:"f32"}},Uc={name:"project32",dependencies:[Bc],source:"// Define a structure to hold both the clip-space position and the common position.\nstruct ProjectResult {\n clipPosition: vec4,\n commonPosition: vec4,\n};\n\n// This function mimics the GLSL version with the 'out' parameter by returning both values.\nfn project_position_to_clipspace_and_commonspace(\n position: vec3,\n position64Low: vec3,\n offset: vec3\n) -> ProjectResult {\n // Compute the projected position.\n let projectedPosition: vec3 = project_position_vec3_f64(position, position64Low);\n\n // Start with the provided offset.\n var finalOffset: vec3 = offset;\n\n // Get whether a rotation is needed and the rotation matrix.\n let rotationResult = project_needs_rotation(projectedPosition);\n\n // If rotation is needed, update the offset.\n if (rotationResult.needsRotation) {\n finalOffset = rotationResult.transform * offset;\n }\n\n // Compute the common position.\n let commonPosition: vec4 = vec4(projectedPosition + finalOffset, 1.0);\n\n // Convert to clip-space.\n let clipPosition: vec4 = project_common_position_to_clipspace(commonPosition);\n\n return ProjectResult(clipPosition, commonPosition);\n}\n\n// A convenience overload that returns only the clip-space position.\nfn project_position_to_clipspace(\n position: vec3,\n position64Low: vec3,\n offset: vec3\n) -> vec4 {\n return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition;\n}\n",vs:"vec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"};function jc(e,t){const n=el([],t,e);return Ja(n,n,1/n[3]),n}function Gc(e,t){const n=e%t;return n<0?t+n:n}function Vc(e,t,n){return en?n:e}const zc=Math.log2||function(e){return Math.log(e)*Math.LOG2E};function Wc(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}const Hc=Math.PI,$c=Hc/4,Xc=Hc/180,qc=180/Hc,Yc=512,Kc=85.051129,Zc=1.5;function Qc(e){const[t,n]=e;Wc(Number.isFinite(t)),Wc(Number.isFinite(n)&&n>=-90&&n<=90,"invalid latitude");const s=n*Xc;return[Yc*(t*Xc+Hc)/(2*Hc),Yc*(Hc+Math.log(Math.tan($c+.5*s)))/(2*Hc)]}function Jc(e){const[t,n]=e,s=t/Yc*(2*Hc)-Hc,r=2*(Math.atan(Math.exp(n/Yc*(2*Hc)-Hc))-$c);return[s*qc,r*qc]}function eu(e){return 12790407194604047e-21/Math.cos(e*Xc)}function tu(e){const{latitude:t,longitude:n,highPrecision:s=!1}=e;Wc(Number.isFinite(t)&&Number.isFinite(n));const r=Math.cos(t*Xc),i=512/360,o=i/r,a=12790407194604047e-21/r,l={unitsPerMeter:[a,a,a],metersPerUnit:[1/a,1/a,1/a],unitsPerDegree:[i,o,a],degreesPerUnit:[.703125,1/o,1/a]};if(s){const e=Xc*Math.tan(t*Xc)/r,n=i*e/2,s=12790407194604047e-21*e,c=s/o*a;l.unitsPerDegree2=[0,n,s],l.unitsPerMeter2=[c,0,c]}return l}function nu(e,t){const[n,s,r]=e,[i,o,a]=t,{unitsPerMeter:l,unitsPerMeter2:c}=tu({longitude:n,latitude:s,highPrecision:!0}),u=Qc(e);u[0]+=i*(l[0]+c[0]*o),u[1]+=o*(l[1]+c[1]*o);const h=Jc(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[h[0],h[1],d]:h}function su(e){return 2*Math.atan(.5/e)*qc}function ru(e){return.5/Math.tan(.5*e*Xc)}function iu(e,t){const[n,s,r=0]=e;return Wc(Number.isFinite(n)&&Number.isFinite(s)&&Number.isFinite(r)),jc(t,[n,s,r,1])}function ou(e,t,n=0){const[s,r,i]=e;if(Wc(Number.isFinite(s)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(i))return jc(t,[s,r,i,1]);const o=jc(t,[s,r,0,1]),a=jc(t,[s,r,1,1]),l=o[2],c=a[2];return Ba([],o,a,l===c?0:((n||0)-l)/(c-l))}const au=Math.PI/180;function lu(e,t,n){const{pixelUnprojectionMatrix:s}=e,r=jc(s,[t,0,1,1]),i=jc(s,[t,e.height,1,1]),o=Jc(Ba([],r,i,(n*e.distanceScales.unitsPerMeter[2]-r[2])/(i[2]-r[2])));return o.push(n),o}const cu="\nuniform shadowUniforms {\n bool drawShadowMap;\n bool useShadowMap;\n vec4 color;\n highp int lightId;\n float lightCount;\n mat4 viewProjectionMatrix0;\n mat4 viewProjectionMatrix1;\n vec4 projectCenter0;\n vec4 projectCenter1;\n} shadow;\n",uu=`\n${cu}\n\nconst int max_lights = 2;\n\nout vec3 shadow_vPosition[max_lights];\n\nvec4 shadow_setVertexPosition(vec4 position_commonspace) {\n mat4 viewProjectionMatrices[max_lights];\n viewProjectionMatrices[0] = shadow.viewProjectionMatrix0;\n viewProjectionMatrices[1] = shadow.viewProjectionMatrix1;\n vec4 projectCenters[max_lights];\n projectCenters[0] = shadow.projectCenter0;\n projectCenters[1] = shadow.projectCenter1;\n\n if (shadow.drawShadowMap) {\n return project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[shadow.lightId], projectCenters[shadow.lightId]);\n }\n if (shadow.useShadowMap) {\n for (int i = 0; i < max_lights; i++) {\n if(i < int(shadow.lightCount)) {\n vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[i], projectCenters[i]);\n shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;\n }\n }\n }\n return gl_Position;\n}\n\n`,hu=`\n${cu}\n\nconst int max_lights = 2;\nuniform sampler2D shadow_uShadowMap0;\nuniform sampler2D shadow_uShadowMap1;\n\nin vec3 shadow_vPosition[max_lights];\n\nconst vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);\nconst vec4 bitUnpackShift = 1.0 / bitPackShift;\nconst vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n\nfloat shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {\n vec4 rgbaDepth = texture(shadowMap, position.xy);\n\n float z = dot(rgbaDepth, bitUnpackShift);\n return smoothstep(0.001, 0.01, position.z - z);\n}\n\nvec4 shadow_filterShadowColor(vec4 color) {\n if (shadow.drawShadowMap) {\n vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n return rgbaDepth;\n }\n if (shadow.useShadowMap) {\n float shadowAlpha = 0.0;\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);\n if(shadow.lightCount > 1.0) {\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);\n }\n shadowAlpha *= shadow.color.a / shadow.lightCount;\n float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);\n\n return vec4(\n mix(color.rgb, shadow.color.rgb, shadowAlpha / blendedAlpha),\n blendedAlpha\n );\n }\n return color;\n}\n\n`,du=Sc(function({viewport:e,center:t}){return new ll(e.viewProjectionMatrix).invert().transform(t)}),fu=Sc(function({viewport:e,shadowMatrices:t}){const n=[],s=e.pixelUnprojectionMatrix,r=e.isGeospatial?void 0:1,i=[[0,0,r],[e.width,0,r],[0,e.height,r],[e.width,e.height,r],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(e=>function(e,t){const[n,s,r]=e,i=ou([n,s,r],t);return Number.isFinite(r)?i:[i[0],i[1],0]}(e,s));for(const o of t){const t=o.clone().translate(new Ha(e.center).negate()),s=i.map(e=>t.transform(e)),r=(new ll).ortho({left:Math.min(...s.map(e=>e[0])),right:Math.max(...s.map(e=>e[0])),bottom:Math.min(...s.map(e=>e[1])),top:Math.max(...s.map(e=>e[1])),near:Math.min(...s.map(e=>-e[2])),far:Math.max(...s.map(e=>-e[2]))});n.push(r.multiplyRight(o))}return n}),pu=[0,0,0,1],gu=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],mu={name:"shadow",dependencies:[Bc],vs:uu,fs:hu,inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n position = shadow_setVertexPosition(geometry.position);\n ","fs:DECKGL_FILTER_COLOR":"\n color = shadow_filterShadowColor(color);\n "},getUniforms:function(e){const{shadowEnabled:t=!0,project:n}=e;if(!(t&&n&&e.shadowMatrices&&e.shadowMatrices.length))return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};const s=Bc.getUniforms(n),r=du({viewport:n.viewport,center:s.center}),i=[],o=fu({shadowMatrices:e.shadowMatrices,viewport:n.viewport}).slice();for(let l=0;l0,color:e.shadowColor||pu,lightId:e.shadowLightId||0,lightCount:e.shadowMatrices.length,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};for(let l=0;l",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4",viewProjectionMatrix1:"mat4x4",projectCenter0:"vec4",projectCenter1:"vec4"}},_u={...pl,defaultUniforms:{...pl.defaultUniforms,useFloatColors:!1},inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n // for picking depth values\n picking_setPickingAttribute(position.z / position.w);\n ","vs:DECKGL_FILTER_COLOR":"\n picking_setPickingColor(geometry.pickingColor);\n ","fs:DECKGL_FILTER_COLOR":{order:99,injection:"\n // use highlight color if this fragment belongs to the selected object.\n color = picking_filterHighlightColor(color);\n\n // use picking color if rendering to picking FBO.\n color = picking_filterPickingColor(color);\n "}}},yu=[bl],bu=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],vu=[];function xu(e){const t=ws.getDefaultShaderAssembler();for(const s of yu)t.addDefaultModule(s);t._hookFunctions.length=0;const n="glsl"===e?bu:vu;for(const s of n)t.addShaderHook(s);return t}const wu=[255,255,255],Eu=1;let Tu=0;class Su{constructor(e={}){this.type="ambient";const{color:t=wu}=e,{intensity:n=Eu}=e;this.id=e.id||"ambient-"+Tu++,this.color=t,this.intensity=n}}const Au=[255,255,255],Ru=1,Cu=[0,0,-1];let Pu=0;class ku{constructor(e={}){this.type="directional";const{color:t=Au}=e,{intensity:n=Ru}=e,{direction:s=Cu}=e,{_shadow:r=!1}=e;this.id=e.id||"directional-"+Pu++,this.color=t,this.intensity=n,this.type="directional",this.direction=new Ha(s).normalize().toArray(),this.shadow=r}getProjectedLight(e){return this}}class Iu{constructor(e,t={id:"pass"}){const{id:n}=t;this.id=n,this.device=e,this.props={...t}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}}class Mu extends Iu{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){const[t,n]=this.device.canvasContext.getDrawingBufferSize(),s=e.clearCanvas??!0,r=e.clearColor??(!!s&&[0,0,0,0]),i=!!s&&1,o=!!s&&0,a=e.colorMask??15,l={viewport:[0,0,t,n]};e.colorMask&&(l.colorMask=a),e.scissorRect&&(l.scissorRect=e.scissorRect);const c=this.device.beginRenderPass({framebuffer:e.target,parameters:l,clearColor:r,clearDepth:i,clearStencil:o});try{return this._drawLayers(c,e)}finally{c.end(),this.device.submit()}}_drawLayers(e,t){const{target:n,shaderModuleProps:s,viewports:r,views:i,onViewportActive:o,clearStack:a=!0}=t;t.pass=t.pass||"unknown",a&&(this._lastRenderIndex=-1);const l=[];for(const c of r){const r=i&&i[c.id];null==o||o(c);const a=this._getDrawLayerParams(c,t),u=c.subViewports||[c];for(const i of u){const o=this._drawLayersInViewport(e,{target:n,shaderModuleProps:s,viewport:i,view:r,pass:t.pass,layers:t.layers},a);l.push(o)}}return l}_getDrawLayerParams(e,{layers:t,pass:n,isPicking:s=!1,layerFilter:r,cullRect:i,effects:o,shaderModuleProps:a},l=!1){var c;const u=[],h=Lu(this._lastRenderIndex+1),d={layer:t[0],viewport:e,isPicking:s,renderPass:n,cullRect:i},f={};for(let p=0;pe/255):!1===t&&(e=!1),void 0!==n&&(i=n),void 0!==s&&(o=s),this.device.beginRenderPass({framebuffer:r,parameters:{viewport:l,scissorRect:l},clearColor:e,clearDepth:i,clearStencil:o}).end()}}const c={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let h=0;h{const o=r.props._offset,a=r.id,l=r.parent&&r.parent.id;let c;if(l&&!(l in t)&&s(r.parent,!1),l in n){const e=n[l]=n[l]||Lu(t[l],t);c=e(r,i),n[a]=e}else Number.isFinite(o)?(c=o+(t[l]||0),n[a]=null):c=e;return i&&c>=e&&(e=c+1),t[a]=c,c};return s}function Nu(e,...t){for(const n of t)if(n)for(const t in n)e[t]?Object.assign(e[t],n[t]):e[t]=n[t];return e}class Ou extends Mu{constructor(e,t){super(e,t);const n=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),s=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[n],depthStencilAttachment:s})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){const t=this.fbo,n=this.device.canvasContext.cssToDeviceRatio(),s=e.viewports[0],r=s.width*n,i=s.height*n;r===t.width&&i===t.height||t.resize({width:r,height:i}),super.render({...e,clearColor:[1,1,1,1],target:t,pass:"shadow"})}getLayerParameters(e,t,n){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return!1!==e.props.shadowEnabled}getShaderModuleProps(e,t,n){return{shadow:{project:n.project,drawToShadowMap:!0}}}}const Fu={color:[255,255,255],intensity:1},Du=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],Bu=[0,0,0,200/255];class Uu{constructor(e={}){this.id="lighting-effect",this.shadowColor=Bu,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;const{device:t,deck:n}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),n._addDefaultShaderModule(mu),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(const t in e){const n=e[t];switch(n.type){case"ambient":this.ambientLight=n;break;case"directional":this.directionalLights.push(n);break;case"point":this.pointLights.push(n)}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(e=>e.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:n,onViewportActive:s,views:r}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let i=0;ie.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},s={enabled:!0,ambientLight:this.ambientLight,directionalLights:this.directionalLights.map(t=>t.getProjectedLight({layer:e})),pointLights:this.pointLights.map(t=>t.getProjectedLight({layer:e}))},r=e.props.material;return{shadow:n,lighting:s,phongMaterial:r,gouraudMaterial:r}}cleanup(e){for(const t of this.shadowPasses)t.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(mu))}_calculateMatrices(){const e=[];for(const t of this.directionalLights){const n=(new ll).lookAt({eye:new Ha(t.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let t=0;ts&&(r=s);const i=this._pool,o=e.BYTES_PER_ELEMENT*r,a=i.findIndex(e=>e.byteLength>=o);if(a>=0){const t=new e(i.splice(a,1)[0],0,r);return n&&t.fill(0),t}return new e(r)}_release(e){if(!ArrayBuffer.isView(e))return;const t=this._pool,{buffer:n}=e,{byteLength:s}=n,r=t.findIndex(e=>e.byteLength>=s);r<0?t.push(n):(r>0||t.lengththis.opts.poolSize&&t.shift()}},Gu=new Ha;function Vu(e,t,n,s){Gu.set(e,t,n);const r=Gu.len();return{distance:s/r,normal:new Ha(-e/r,-t/r,-n/r)}}function zu(e){return e-Math.fround(e)}let Wu;function Hu(e,t){const{size:n=1,startIndex:s=0}=t,r=void 0!==t.endIndex?t.endIndex:e.length,i=(r-s)/n;Wu=ju.allocate(Wu,i,{type:Float32Array,size:2*n});let o=s,a=0;for(;o(90-e.pitch)*au-.01?(l=lu(e,0,t),c=lu(e,n,t)):(l=r([0,0],i),c=r([n,0],i)),[o,a,c,l]}(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(e,t={}){const{width:n,height:s}=this,{longitude:r,latitude:i,zoom:o}=function(e){const{width:t,height:n,bounds:s,minExtent:r=0,maxZoom:i=24,offset:o=[0,0]}=e,[[a,l],[c,u]]=s,h=function(e=0){return"number"==typeof e?{top:e,bottom:e,left:e,right:e}:(Wc(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}(e.padding),d=Qc([a,Vc(u,-85.051129,Kc)]),f=Qc([c,Vc(l,-85.051129,Kc)]),p=[Math.max(Math.abs(f[0]-d[0]),r),Math.max(Math.abs(f[1]-d[1]),r)],g=[t-h.left-h.right-2*Math.abs(o[0]),n-h.top-h.bottom-2*Math.abs(o[1])];Wc(g[0]>0&&g[1]>0);const m=g[0]/p[0],_=g[1]/p[1],y=(h.right-h.left)/2/m,b=(h.top-h.bottom)/2/_,v=Jc([(f[0]+d[0])/2+y,(f[1]+d[1])/2+b]),x=Math.min(i,zc(Math.abs(Math.min(m,_))));return Wc(Number.isFinite(x)),{longitude:v[0],latitude:v[1],zoom:x}}({width:n,height:s,bounds:e,...t});return new Qu({width:n,height:s,longitude:r,latitude:i,zoom:o})}}Qu.displayName="WebMercatorViewport";const Ju=[0,0,0];function eh(e,t,n=!1){const s=t.projectPosition(e);if(n&&t instanceof Qu){const[n,r,i=0]=e,o=t.getDistanceScales([n,r]);s[2]=i*o.unitsPerMeter[2]}return s}function th(e,{viewport:t,modelMatrix:n,coordinateSystem:s,coordinateOrigin:r,offsetMode:i}){let[o,a,l=0]=e;switch(n&&([o,a,l]=el([],[o,a,l,1],n)),s){case bc.LNGLAT:return eh([o,a,l],t,i);case bc.LNGLAT_OFFSETS:return eh([o+r[0],a+r[1],l+(r[2]||0)],t,i);case bc.METER_OFFSETS:return eh(nu(r,[o,a,l]),t,i);default:return t.isGeospatial?[o+r[0],a+r[1],l+r[2]]:t.projectPosition([o,a,l])}}let nh=1,sh=1;class rh{constructor(){s(this,"time",0),s(this,"channels",new Map),s(this,"animations",new Map),s(this,"playing",!1),s(this,"lastEngineTime",-1)}addChannel(e){const{delay:t=0,duration:n=Number.POSITIVE_INFINITY,rate:s=1,repeat:r=1}=e,i=nh++,o={time:0,delay:t,duration:n,rate:s,repeat:r};return this._setChannelTime(o,this.time),this.channels.set(i,o),i}removeChannel(e){this.channels.delete(e);for(const[t,n]of this.animations)n.channel===e&&this.detachAnimation(t)}isFinished(e){const t=this.channels.get(e);return void 0!==t&&this.time>=t.delay+t.duration*t.repeat}getTime(e){if(void 0===e)return this.time;const t=this.channels.get(e);return void 0===t?-1:t.time}setTime(e){this.time=Math.max(0,e);const t=this.channels.values();for(const s of t)this._setChannelTime(s,this.time);const n=this.animations.values();for(const s of n){const{animation:e,channel:t}=s;e.setTime(this.getTime(t))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){const n=sh++;return this.animations.set(n,{animation:e,channel:t}),e.setTime(this.getTime(t)),n}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){const n=t-e.delay;n>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}}let ih=0;const oh=class e{constructor(t){if(s(this,"device",null),s(this,"canvas",null),s(this,"props"),s(this,"animationProps",null),s(this,"timeline",null),s(this,"stats"),s(this,"cpuTime"),s(this,"gpuTime"),s(this,"frameRate"),s(this,"display"),s(this,"needsRedraw","initialized"),s(this,"_initialized",!1),s(this,"_running",!1),s(this,"_animationFrameId",null),s(this,"_nextFramePromise",null),s(this,"_resolveNextFrame",null),s(this,"_cpuStartTime",0),s(this,"_error",null),this.props={...e.defaultAnimationLoopProps,...t},!(t=this.props).device)throw new Error("No device provided");this.stats=t.stats||new Et({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:t.autoResizeViewport}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(!1!==e&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){const t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){var e;return(null==(e=this.device)?void 0:e.isLost)||this._error||(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers()),this}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){var e;this._running&&(this._animationFrameId=(e=this._animationFrame.bind(this),"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1e3/60)))}_cancelAnimationFrame(){var e;null!==this._animationFrameId&&(e=this._animationFrameId,"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame(e):clearTimeout(e),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){var t;this.display?this.display._renderFrame(e):(this.props.onRender(this._getAnimationProps()),null==(t=this.device)||t.submit())}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){var e;const t=null==(e=this.device)?void 0:e.getDefaultCanvasContext();if(!this.device||!t)throw new Error("loop");const n=null==t?void 0:t.canvas,s=t.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:t,canvas:n,useDevicePixels:s,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;const{width:e,height:t,aspect:n}=this._getSizeAndAspect();e===this.animationProps.width&&t===this.animationProps.height||this.setNeedsRedraw("drawing buffer resized"),n!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=n,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){const e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";const t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);const n=this.props.onAddHTML(t);n&&(t.innerHTML=n)}}_getSizeAndAspect(){var e,t;if(!this.device)return{width:1,height:1,aspect:1};const[n,s]=(null==(e=this.device)?void 0:e.getDefaultCanvasContext().getDevicePixelSize())||[1,1];let r=1;const i=null==(t=this.device)?void 0:t.getDefaultCanvasContext().canvas;return i&&i.clientHeight?r=i.clientWidth/i.clientHeight:n>0&&s>0&&(r=n/s),{width:n,height:s,aspect:r}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}};s(oh,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>{},stats:lr.stats.get("animation-loop-"+ih++),autoResizeViewport:!1});let ah=oh;const lh={};function ch(e="id"){return lh[e]=lh[e]||1,`${e}-${lh[e]++}`}class uh{constructor(e){if(s(this,"id"),s(this,"userData",{}),s(this,"topology"),s(this,"bufferLayout",[]),s(this,"vertexCount"),s(this,"indices"),s(this,"attributes"),this.id=e.id||ch("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&ks.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){var e;null==(e=this.indices)||e.destroy();for(const t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}const hh=class e{constructor(e){s(this,"device"),s(this,"cachingEnabled"),s(this,"destroyPolicy"),s(this,"debug"),s(this,"_hashCounter",0),s(this,"_hashes",{}),s(this,"_renderPipelineCache",{}),s(this,"_computePipelineCache",{}),this.device=e,this.cachingEnabled=e.props._cachePipelines,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=e.props.debugFactories}static getDefaultPipelineFactory(t){return t._lumaData.defaultPipelineFactory=t._lumaData.defaultPipelineFactory||new e(t),t._lumaData.defaultPipelineFactory}get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}createRenderPipeline(e){var t;if(!this.cachingEnabled)return this.device.createRenderPipeline(e);const n={...Mr.defaultProps,...e},s=this._renderPipelineCache,r=this._hashRenderPipeline(n);let i=null==(t=s[r])?void 0:t.pipeline;return i?(s[r].useCount++,this.debug&&Ss.log(3,`${this}: ${s[r].pipeline} reused, count=${s[r].useCount}, (id=${e.id})`)()):(i=this.device.createRenderPipeline({...n,id:n.id?`${n.id}-cached`:ch("unnamed-cached")}),i.hash=r,s[r]={pipeline:i,useCount:1},this.debug&&Ss.log(3,`${this}: ${i} created, count=${s[r].useCount}`)()),i}createComputePipeline(e){var t;if(!this.cachingEnabled)return this.device.createComputePipeline(e);const n={...Fr.defaultProps,...e},s=this._computePipelineCache,r=this._hashComputePipeline(n);let i=null==(t=s[r])?void 0:t.pipeline;return i?(s[r].useCount++,this.debug&&Ss.log(3,`${this}: ${s[r].pipeline} reused, count=${s[r].useCount}, (id=${e.id})`)()):(i=this.device.createComputePipeline({...n,id:n.id?`${n.id}-cached`:void 0}),i.hash=r,s[r]={pipeline:i,useCount:1},this.debug&&Ss.log(3,`${this}: ${i} created, count=${s[r].useCount}`)()),i}release(e){if(!this.cachingEnabled)return void e.destroy();const t=this._getCache(e),n=e.hash;t[n].useCount--,0===t[n].useCount?(this._destroyPipeline(e),this.debug&&Ss.log(3,`${this}: ${e} released and destroyed`)()):t[n].useCount<0?(Ss.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[n].useCount=0):this.debug&&Ss.log(3,`${this}: ${e} released, count=${t[n].useCount}`)()}_destroyPipeline(e){const t=this._getCache(e);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete t[e.hash],e.destroy(),!0}}_getCache(e){let t;if(e instanceof Fr&&(t=this._computePipelineCache),e instanceof Mr&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){const{type:t}=this.device;return`${t}/C/${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){const t=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,s=this._getHash(JSON.stringify(e.bufferLayout)),{type:r}=this.device;if("webgl"===r)return`${r}/R/${t}/${n}V-BL${s}`;{const i=this._getHash(JSON.stringify(e.parameters));return`${r}/R/${t}/${n}V-T${e.topology}P${i}BL${s}`}}_getHash(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};s(hh,"defaultProps",{...Mr.defaultProps});let dh=hh;const fh=class e{constructor(e){s(this,"device"),s(this,"cachingEnabled"),s(this,"destroyPolicy"),s(this,"debug"),s(this,"_cache",{}),this.device=e,this.cachingEnabled=e.props._cacheShaders,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=!0}static getDefaultShaderFactory(t){var n;return(n=t._lumaData).defaultShaderFactory||(n.defaultShaderFactory=new e(t)),t._lumaData.defaultShaderFactory}get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}createShader(e){if(!this.cachingEnabled)return this.device.createShader(e);const t=this._hashShader(e);let n=this._cache[t];if(n)n.useCount++,this.debug&&Ss.log(3,`${this}: Reusing shader ${n.shader.id} count=${n.useCount}`)();else{const s=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=n={shader:s,useCount:1},this.debug&&Ss.log(3,`${this}: Created new shader ${s.id}`)()}return n.shader}release(e){if(!this.cachingEnabled)return void e.destroy();const t=this._hashShader(e),n=this._cache[t];if(n)if(n.useCount--,0===n.useCount)"unused"===this.destroyPolicy&&(delete this._cache[t],n.shader.destroy(),this.debug&&Ss.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(n.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.debug&&Ss.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}};s(fh,"defaultProps",{...Rr.defaultProps});let ph=fh,gh=null,mh=null;function _h(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let s=0;st.name===e)||null}getAttributeNamesForBuffer(e){var t;return e.attributes?null==(t=e.attributes)?void 0:t.map(e=>e.attribute):[e.name]}mergeBufferLayouts(e,t){const n=[...e];for(const s of t){const e=n.findIndex(e=>e.name===s.name);e<0?n.push(s):n[e]=s}return n}getBufferIndex(e){const t=this.bufferLayouts.findIndex(t=>t.name===e);return-1===t&&Ss.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}}function bh(e){const t={bindings:{},uniforms:{}};return Object.keys(e).forEach(n=>{const s=e[n];var r;!function(e){return function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}(e)||function(e){return!!Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}(e)}(r=s)&&"number"!=typeof r&&"boolean"!=typeof r?t.bindings[n]=s:t.uniforms[n]=s}),t}class vh{constructor(e,t){s(this,"options",{disableWarnings:!1}),s(this,"modules"),s(this,"moduleUniforms"),s(this,"moduleBindings"),Object.assign(this.options,t);const n=ss(Object.values(e).filter(e=>e.dependencies));for(const s of n)e[s.name]=s;Ss.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[s,r]of Object.entries(e))this._addModule(r),r.name&&s!==r.name&&!this.options.disableWarnings&&Ss.warn(`Module name: ${s} vs ${r.name}`)()}destroy(){}setProps(e){var t;for(const n of Object.keys(e)){const s=n,r=e[s]||{},i=this.modules[s];if(!i){this.options.disableWarnings||Ss.warn(`Module ${n} not found`)();continue}const o=this.moduleUniforms[s],a=this.moduleBindings[s],l=(null==(t=i.getUniforms)?void 0:t.call(i,r,o))||r,{uniforms:c,bindings:u}=bh(l);this.moduleUniforms[s]={...o,...c},this.moduleBindings[s]={...a,...u}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){var e;const t={};for(const[n,s]of Object.entries(this.moduleUniforms))for(const[r,i]of Object.entries(s))t[`${n}.${r}`]={type:null==(e=this.modules[n].uniformTypes)?void 0:e[r],value:String(i)};return t}_addModule(e){const t=e.name;this.moduleUniforms[t]=e.defaultUniforms||{},this.moduleBindings[t]={}}}const xh=["+X","-X","+Y","-Y","+Z","-Z"],wh=["+X","-X","+Y","-Y","+Z","-Z"],Eh=class e{constructor(t,n){s(this,"device"),s(this,"id"),s(this,"props"),s(this,"texture"),s(this,"sampler"),s(this,"view"),s(this,"ready"),s(this,"isReady",!1),s(this,"destroyed",!1),s(this,"resolveReady",()=>{}),s(this,"rejectReady",()=>{}),this.device=t;const r=ch("async-texture");this.props={...e.defaultProps,id:r,...n},this.id=this.props.id,"string"==typeof(null==(n={...n})?void 0:n.data)&&"2d"===n.dimension&&(n.data=async function(e){const t=new Image;return t.crossOrigin="anonymous",t.src=e.startsWith("http")?e:""+e,await t.decode(),await createImageBitmap(t)}(n.data)),n.mipmaps&&(n.mipLevels="auto"),this.ready=new Promise((e,t)=>{this.resolveReady=()=>{this.isReady=!0,e()},this.rejectReady=t}),this.initAsync(n)}get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}async initAsync(e){const t=e.data,n=await Sh(t).then(void 0,this.rejectReady);if(this.destroyed)return;const s=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(n);if(!s)throw new Error("Texture size could not be determined");const r={...s,...e,data:void 0,mipLevels:1},i=this.device.getMipLevelCount(r.width,r.height);if(r.mipLevels="auto"===this.props.mipLevels?i:Math.min(i,this.props.mipLevels),this.texture=this.device.createTexture(r),this.sampler=this.texture.sampler,this.view=this.texture.view,e.data)switch(this.props.dimension){case"1d":this._setTexture1DData(this.texture,n);break;case"2d":this._setTexture2DData(n);break;case"3d":this._setTexture3DData(this.texture,n);break;case"2d-array":this._setTextureArrayData(this.texture,n);break;case"cube":this._setTextureCubeData(this.texture,n);break;case"cube-array":this._setTextureCubeArrayData(this.texture,n)}this.props.mipmaps&&this.generateMipmaps(),Ss.info(1,`${this} loaded`),this.resolveReady()}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}generateMipmaps(){this.texture.generateMipmapsWebGL()}setSampler(e={}){this.texture.setSampler(e instanceof yr?e:this.device.createSampler(e))}resize(e){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(e.width===this.texture.width&&e.height===this.texture.height)return!1;if(this.texture){const t=this.texture;this.texture=t.clone(e),t.destroy()}return!0}isTextureLevelData(e){const t=null==e?void 0:e.data;return ArrayBuffer.isView(t)}getTextureDataSize(e){if(!e)return null;if(ArrayBuffer.isView(e))return null;if(Array.isArray(e))return this.getTextureDataSize(e[0]);if(this.device.isExternalImage(e))return this.device.getExternalImageSize(e);if(e&&"object"==typeof e&&e.constructor===Object){const t=Object.values(e)[0];return{width:t.width,height:t.height}}throw new Error("texture size deduction failed")}getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}setTextureData(e){}_setTexture1DData(e,t){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(e,t=0){if(!this.texture)throw new Error("Texture not initialized");const n=this._normalizeTextureData(e);n.length>1&&!1!==this.props.mipmaps&&Ss.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let s=0;s1&&!1!==this.props.mipmaps&&Ss.warn(`${this.id} has mipmap and multiple LODs.`)();const r=xh.indexOf(n);this._setTexture2DData(t,r)}_normalizeTextureData(e){const t=this.texture;let n;return n=ArrayBuffer.isView(e)?[{data:e,width:t.width,height:t.height}]:Array.isArray(e)?e:[e],n}};s(Eh,"defaultProps",{...xr.defaultProps,data:null,mipmaps:!1});let Th=Eh;async function Sh(e){if(e=await e,Array.isArray(e))return await Promise.all(e.map(Sh));if(e&&"object"==typeof e&&e.constructor===Object){const t=e,n=await Promise.all(Object.values(t)),s=Object.keys(t),r={};for(let e=0;e[e.name,e]))||[]),c=n.shaderInputs||new vh(l,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(c);const u=function(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}(t),h=((null==(i=this.props.modules)?void 0:i.length)>0?this.props.modules:null==(o=this.shaderInputs)?void 0:o.getModules())||[];if("webgpu"===this.device.type&&this.props.source){const{source:e,getUniforms:t}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:u,...this.props,modules:h});this.source=e,this._getModuleUniforms=t,(a=this.props).shaderLayout||(a.shaderLayout=function(e){var t;const n={attributes:[],bindings:[]};let s;try{s=function(e){try{return new wa(e)}catch(t){if(t instanceof Error)throw t;let e="WGSL parse error";throw"object"==typeof t&&(null==t?void 0:t.message)&&(e+=`: ${t.message} `),"object"==typeof t&&(null==t?void 0:t.token)&&(e+=t.token.line||""),new Error(e,{cause:t})}}(e)}catch(o){return Ss.error(o.message)(),n}for(const a of s.uniforms){const e=[];for(const n of(null==(t=a.type)?void 0:t.members)||[])e.push({name:n.name,type:Ea(n.type)});n.bindings.push({type:"uniform",name:a.name,group:a.group,location:a.binding,members:e})}for(const a of s.textures)n.bindings.push({type:"texture",name:a.name,group:a.group,location:a.binding});for(const a of s.samplers)n.bindings.push({type:"sampler",name:a.name,group:a.group,location:a.binding});const r=s.entry.vertex[0],i=(null==r?void 0:r.inputs.length)||0;for(let a=0;athis._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||(this._needsRedraw=e)}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){const t=this._areBindingsLoading();if(t)return Ss.info(2,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();const t=this._getBindings();this.pipeline.setBindings(t,{disableWarnings:this.props.disableWarnings});const{indexBuffer:s}=this.vertexArray,r=s?s.byteLength/("uint32"===s.indexType?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:r,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",n}setGeometry(e){var t;null==(t=this._gpuGeometry)||t.destroy();const n=e&&function(e,t){if(t instanceof uh)return t;const n=function(e,t){if(!t.indices)return;const n=t.indices.value;return e.createBuffer({usage:ks.INDEX,data:n})}(e,t),{attributes:s,bufferLayout:r}=function(e,t){const n=[],s={};for(const[r,i]of Object.entries(t.attributes)){let t=r;switch(r){case"POSITION":t="positions";break;case"NORMAL":t="normals";break;case"TEXCOORD_0":t="texCoords";break;case"COLOR_0":t="colors"}if(i){s[t]=e.createBuffer({data:i.value,id:`${r}-buffer`});const{value:o,size:a,normalized:l}=i;n.push({name:t,format:Ds(o,a,l)})}}return{attributes:s,bufferLayout:n,vertexCount:t._calculateVertexCount(t.attributes,t.indices)}}(e,t);return new uh({topology:t.topology||"triangle-list",bufferLayout:r,vertexCount:t.vertexCount,indices:n,attributes:s})}(this.device,e);if(n){this.setTopology(n.topology||"triangle-list");const e=new yh(this.bufferLayout);this.bufferLayout=e.mergeBufferLayouts(n.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(n)}this._gpuGeometry=n}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){const t=new yh(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){_h(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,void 0===this.isInstanced&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new ri(this.shaderInputs.modules);for(const[t,n]of Object.entries(this.shaderInputs.modules))if(Ch(n)){const e=this._uniformStore.getManagedUniformBuffer(this.device,t);this.bindings[`${t}Uniforms`]=e}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindingValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){const n=(null==t?void 0:t.disableWarnings)??this.props.disableWarnings;e.indices&&Ss.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=function(e,t){const n=Object.fromEntries(e.attributes.map(e=>[e.name,e.location])),s=t.slice();return s.sort((e,t)=>{const s=e.attributes?e.attributes.map(e=>e.attribute):[e.name],r=t.attributes?t.attributes.map(e=>e.attribute):[t.name];return Math.min(...s.map(e=>n[e]))-Math.min(...r.map(e=>n[e]))}),s}(this.pipeline.shaderLayout,this.bufferLayout);const s=new yh(this.bufferLayout);for(const[r,i]of Object.entries(e)){const e=s.getBufferLayout(r);if(!e){n||Ss.warn(`Model(${this.id}): Missing layout for buffer "${r}".`)();continue}const t=s.getAttributeNamesForBuffer(e);let o=!1;for(const n of t){const e=this._attributeInfos[n];if(e){const t="webgpu"===this.device.type?s.getBufferIndex(e.bufferName):e.location;this.vertexArray.setBuffer(t,i),o=!0}}o||n||Ss.warn(`Model(${this.id}): Ignoring buffer "${i.id}" for unknown attribute "${r}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[n,s]of Object.entries(e)){const e=this._attributeInfos[n];e?this.vertexArray.setConstantWebGL(e.location,s):((null==t?void 0:t.disableWarnings)??this.props.disableWarnings)||Ss.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(const e of Object.values(this.bindings))if(e instanceof Th&&!e.isReady)return e.id;return!1}_getBindings(){const e={};for(const[t,n]of Object.entries(this.bindings))n instanceof Th?n.isReady&&(e[t]=n.texture):e[t]=n;return e}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof Er?e=Math.max(e,t.texture.updateTimestamp):t instanceof ks||t instanceof xr?e=Math.max(e,t.updateTimestamp):t instanceof Th?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof yr||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const t={...e.attributes};for(const[n]of Object.entries(t))this.pipeline.shaderLayout.attributes.find(e=>e.name===n)||"positions"===n||delete t[n];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||(this._pipelineNeedsUpdate=e),this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(Ss.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let s=null;this.source?s=n:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:n,fs:s}),this._attributeInfos=Hr(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_logDrawCallStart(){const e=Ss.level>3?0:1e4;Ss.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Ss.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=function(e){var t;const n={},s="Values";if(0===e.attributes.length&&!(null==(t=e.varyings)?void 0:t.length))return{"No attributes or varyings":{[s]:"N/A"}};for(const r of e.attributes)r&&(n[`in ${r.location} ${r.name}: ${r.type}`]={[s]:r.stepMode||"vertex"});for(const r of e.varyings||[])n[`out ${r.location} ${r.name}`]={[s]:JSON.stringify(r)};return n}(this.pipeline.shaderLayout,this.id);Ss.table(2,e)();const t=this.shaderInputs.getDebugTable();Ss.table(2,t)();const n=this._getAttributeDebugTable();Ss.table(2,this._attributeInfos)(),Ss.table(2,n)(),Ss.groupEnd(2)(),this._logOpen=!1}}_logFramebuffer(e){const t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;const n=e.props.framebuffer;n&&function(e,{id:t,minimap:n,opaque:s,top:r="0",left:i="0",rgbaScale:o=1}){gh||(gh=document.createElement("canvas"),gh.id=t,gh.title=t,gh.style.zIndex="100",gh.style.position="absolute",gh.style.top=r,gh.style.left=i,gh.style.border="blue 5px solid",gh.style.transform="scaleY(-1)",document.body.appendChild(gh),mh=gh.getContext("2d")),gh.width===e.width&&gh.height===e.height||(gh.width=e.width/2,gh.height=e.height/2,gh.style.width="400px",gh.style.height="400px");const a=e.device.readPixelsToArrayWebGL(e),l=null==mh?void 0:mh.createImageData(e.width,e.height);if(l){const e=0;for(let t=0;t=1&&(n=Math.min(n,e.length/t))}return n}}const Mh={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"};class Lh extends Mu{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:t,views:n,viewports:s,onViewportActive:r,pickingFBO:i,deviceRect:{x:o,y:a,width:l,height:c},cullRect:u,effects:h,pass:d="picking",pickZ:f,shaderModuleProps:p}){this.pickZ=f;const g=this._resetColorEncoder(f),m=[o,a,l,c],_=super.render({target:i,layers:e,layerFilter:t,views:n,viewports:s,onViewportActive:r,cullRect:u,effects:null==h?void 0:h.filter(e=>e.useInPicking),pass:d,isPicking:!0,shaderModuleProps:p,clearColor:[0,0,0,0],colorMask:15,scissorRect:m});return this._colorEncoderState=null,{decodePickingColor:g&&Nh.bind(null,g),stats:_}}shouldDrawLayer(e){const{pickable:t,operation:n}=e.props;return t&&n.includes("draw")||n.includes("terrain")||n.includes("mask")}getShaderModuleProps(e,t,n){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,t,n){const s={...e.props.parameters},{pickable:r,operation:i}=e.props;return!this._colorEncoderState||i.includes("terrain")?s.blend=!1:r&&i.includes("draw")&&(Object.assign(s,Mh),s.blend=!0,s.blendColor=function(e,t,n){const{byLayer:s,byAlpha:r}=e;let i,o=s.get(t);return o?(o.viewports.push(n),i=o.a):(i=s.size+1,i<=255?(o={a:i,layer:t,viewports:[n]},s.set(t,o),r[i]=o):(Fn.warn("Too many pickable layers, only picking the first 255")(),i=0)),[0,0,0,i/255]}(this._colorEncoderState,e,n)),s}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function Nh(e,t){const n=e.byAlpha[t[3]];return n&&{pickedLayer:n.layer,pickedViewports:n.viewports,pickedObjectIndex:n.layer.decodePickingColor(t)}}const Oh=Symbol.for("component"),Fh=Symbol.for("propTypes"),Dh=Symbol.for("deprecatedProps"),Bh=Symbol.for("asyncPropDefaults"),Uh=Symbol.for("asyncPropOriginal"),jh=Symbol.for("asyncPropResolved");function Gh(e,t=()=>!0){return Array.isArray(e)?Vh(e,t,[]):t(e)?[e]:[]}function Vh(e,t,n){let s=-1;for(;++s0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;const n=++this._loadCount;let s=e;"string"==typeof e&&(s=yn(e)),s instanceof Promise?(this.isLoaded=!1,this._loader=s.then(e=>{this._loadCount===n&&(this.isLoaded=!0,this._error=void 0,this._content=e)}).catch(e=>{this._loadCount===n&&(this.isLoaded=!0,this._error=e||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(const r of this._subscribers)r.onChange(this.getData())}}class Hh{constructor(e){var t;this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:null==(t=e.device)?void 0:t.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return!!e.startsWith(this.protocol)||e in this._resources}add({resourceId:e,data:t,forceUpdate:n=!1,persistent:s=!0}){let r=this._resources[e];r?r.setData(t,n):(r=new Wh(e,t,this._context),this._resources[e]=r),r.persistent=s}remove(e){const t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){const t=this._consumers[e];if(t){for(const e in t){const n=t[e],s=this._resources[n.resourceId];s&&s.unsubscribe(n)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:n,requestId:s="default"}){const{_resources:r,protocol:i}=this;e.startsWith(i)&&(r[e=e.replace(i,"")]||this.add({resourceId:e,data:null,persistent:!1}));const o=r[e];if(this._track(n,s,o,t),o)return o.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const e in this._resources)this._resources[e].delete()}_track(e,t,n,s){const r=this._consumers,i=r[e]=r[e]||{};let o=i[t];const a=o&&o.resourceId&&this._resources[o.resourceId];a&&(a.unsubscribe(o),this.prune()),n&&(o?(o.onChange=s,o.resourceId=n.id):o={onChange:s,resourceId:n.id},i[t]=o,n.subscribe(o))}_prune(){this._pruneRequest=null;for(const e of Object.keys(this._resources)){const t=this._resources[e];t.persistent||t.inUse()||(t.delete(),delete this._resources[e])}}}class $h{constructor(e,t){var n;this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=e=>{Un("layerManager.activateViewport",this,e),e&&(this.context.viewport=e)};const{deck:s,stats:r,viewport:i,timeline:o}=t||{};this.layers=[],this.resourceManager=new Hh({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:null==e?void 0:e.gl,deck:s,shaderAssembler:xu((null==(n=null==e?void 0:e.info)?void 0:n.shadingLanguage)||"glsl"),defaultShaderModules:[ml],renderPass:void 0,stats:r||new Et({id:"deck.gl"}),viewport:i||new Zu({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new rh,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(const n of this.layers){const s=n.getNeedsRedraw(e);t=t||s}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(e=>0===t.id.indexOf(e))):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){Un("layerManager.setLayers",this,t,e),this._lastRenderedLayers=e;const n=Gh(e,Boolean);for(const s of n)s.context=this.context;this._updateLayers(this.layers,n)}updateLayers(){const e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){const{defaultShaderModules:t}=this.context;t.find(t=>t.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){const{defaultShaderModules:t}=this.context,n=t.findIndex(t=>t.name===e.name);n>=0&&(t.splice(n,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,n){n.raiseError(t,`${e} of ${n}`)}_updateLayers(e,t){const n={};for(const i of e)n[i.id]?Fn.warn(`Multiple old layers with same id ${i.id}`)():n[i.id]=i;if(this._defaultShaderModulesChanged){for(const t of e)t.setNeedsUpdate(),t.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}const s=[];this._updateSublayersRecursively(t,n,s),this._finalizeOldLayers(n);let r=!1;for(const i of s)if(i.hasUniformTransition()){r=`Uniform transition in ${i}`;break}this._needsUpdate=r,this.layers=s}_updateSublayersRecursively(e,t,n){for(const r of e){r.context=this.context;const e=t[r.id];null===e&&Fn.warn(`Multiple new layers with same id ${r.id}`)(),t[r.id]=null;let i=null;try{this._debug&&e!==r&&r.validateProps(),e?(this._transferLayerState(e,r),this._updateLayer(r)):this._initializeLayer(r),n.push(r),i=r.isComposite?r.getSubLayers():null}catch(s){this._handleError("matching",s,r)}i&&this._updateSublayersRecursively(i,t,n)}}_finalizeOldLayers(e){for(const t in e){const n=e[t];n&&this._finalizeLayer(n)}}_initializeLayer(e){try{e._initialize(),e.lifecycle="Initialized"}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle="Matched. State transferred from previous layer",t!==e&&(e.lifecycle="Discarded. Awaiting garbage collection")}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle="No longer matched. Awaiting garbage collection";try{e._finalize(),e.lifecycle="Finalized! Awaiting garbage collection"}catch(t){this._handleError("finalization",t,e)}}}function Xh(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let s=0;st.containsPixel(e)):this._viewports}getViews(){const e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){const t="string"==typeof e?this.getView(e):e,n=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(n):n}getViewport(e){return this._viewportMap[e]}unproject(e,t){const n=this.getViewports(),s={x:e[0],y:e[1]};for(let r=n.length-1;r>=0;--r){const i=n[r];if(i.containsPixel(s)){const n=e.slice();return n[0]-=i.x,n[1]-=i.y,i.unproject(n,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){e===this.width&&t===this.height||(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Gh(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!Xh(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):Fn.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){const n=new(0,t.type)({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>{var n;return null==(n=this.getView(e.id))?void 0:n.makeViewport({viewState:t,width:this.width,height:this.height})}});return n}_updateController(e,t,n,s){const r=e.controller;if(r&&n){const i={...t,...r,id:e.id,x:n.x,y:n.y,width:n.width,height:n.height};return s&&s.constructor===r.type||(s=this._createController(e,i)),s&&s.setProps(i),s}return null}_rebuildViewports(){const{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let n=!1;for(let s=e.length;s--;){const r=e[s],i=this.getViewState(r),o=r.makeViewport({viewState:i,width:this.width,height:this.height});let a=t[r.id];const l=Boolean(r.controller);l&&!a&&(n=!0),!n&&l||!a||(a.finalize(),a=null),this.controllers[r.id]=this._updateController(r,i,o,a),o&&this._viewports.unshift(o)}for(const s in t){const e=t[s];e&&!this.controllers[s]&&e.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length||e.some((n,s)=>!e[s].equals(t[s]))}}const Yh=/([0-9]+\.?[0-9]*)(%|px)/;function Kh(e){switch(typeof e){case"number":return{position:e,relative:!1};case"string":const t=Yh.exec(e);if(t&&t.length>=3){const e="%"===t[2],n=parseFloat(t[1]);return{position:e?n/100:n,relative:e}}default:throw new Error(`Could not parse position string ${e}`)}}function Zh(e,t){return e.relative?Math.round(e.position*t):e.position}class Qh{constructor(e){const{id:t,x:n=0,y:s=0,width:r="100%",height:i="100%",padding:o=null}=e;this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=Kh(n),this._y=Kh(s),this._width=Kh(r),this._height=Kh(i),this._padding=o&&{left:Kh(o.left||0),right:Kh(o.right||0),top:Kh(o.top||0),bottom:Kh(o.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e||this.constructor===e.constructor&&Xh(this.props,e.props,2)}clone(e){return new(0,this.constructor)({...this.props,...e})}makeViewport({width:e,height:t,viewState:n}){n=this.filterViewState(n);const s=this.getDimensions({width:e,height:t});return s.height&&s.width?new(this.getViewportType(n))({...n,...this.props,...s}):null}getViewStateId(){const{viewState:e}=this.props;return"string"==typeof e?e:(null==e?void 0:e.id)||this.id}filterViewState(e){if(this.props.viewState&&"object"==typeof this.props.viewState){if(!this.props.viewState.id)return this.props.viewState;const t={...e};for(const e in this.props.viewState)"id"!==e&&(t[e]=this.props.viewState[e]);return t}return e}getDimensions({width:e,height:t}){const n={x:Zh(this._x,e),y:Zh(this._y,t),width:Zh(this._width,e),height:Zh(this._height,t)};return this._padding&&(n.padding={left:Zh(this._padding.left,e),top:Zh(this._padding.top,t),right:Zh(this._padding.right,e),bottom:Zh(this._padding.bottom,t)}),n}get controller(){const e=this.props.controller;return e?!0===e?{type:this.ControllerType}:"function"==typeof e?{type:e}:{type:this.ControllerType,...e}:null}}class Jh{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){var t,n;this.cancel(),this.settings=e,this._inProgress=!0,null==(n=(t=this.settings).onStart)||n.call(t,this)}end(){var e,t;this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,null==(t=(e=this.settings).onEnd)||t.call(e,this))}cancel(){var e,t;this._inProgress&&(null==(t=(e=this.settings).onInterrupt)||t.call(e,this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){var e,t;if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),null==(t=(e=this.settings).onUpdate)||t.call(e,this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const ed=()=>{},td=e=>e;class nd{constructor(e){this._onTransitionUpdate=e=>{const{time:t,settings:{interpolator:n,startProps:s,endProps:r,duration:i,easing:o}}=e,a=o(t/i),l=n.interpolateProps(s,r,a);this.propsInTransition=this.getControllerState({...this.props,...l}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new Jh(e.timeline),this.onViewStateChange=e.onViewStateChange||ed,this.onStateChange=e.onStateChange||ed}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1;const n=this.props;if(this.props=e,!n||this._shouldIgnoreViewportChange(n,e))return!1;if(this._isTransitionEnabled(e)){let s=n;if(this.transition.inProgress){const{interruption:e,endProps:t}=this.transition.settings;s={...n,...2===e?t:this.propsInTransition||n}}this._triggerTransition(s,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){const{transitionDuration:t,transitionInterpolator:n}=e;return(t>0||"auto"===t)&&Boolean(n)}_isUpdateDueToCurrentTransition(e){return!(!this.transition.inProgress||!this.propsInTransition)&&this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition)}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?3===this.transition.settings.interruption||this._isUpdateDueToCurrentTransition(t):!this._isTransitionEnabled(t)||t.transitionInterpolator.arePropsEqual(e,t)}_triggerTransition(e,t){const n=this.getControllerState(e),s=this.getControllerState(t).shortestPathFrom(n),r=t.transitionInterpolator,i=r.getDuration?r.getDuration(e,t):t.transitionDuration;if(0===i)return;const o=r.initializeProps(e,s);this.propsInTransition={};const a={duration:i,easing:t.transitionEasing||td,interpolator:r,interruption:t.transitionInterruption||1,startProps:o.start,endProps:o.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(a),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),null==e||e(t)}}}function sd(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}class rd{constructor(e){const{compare:t,extract:n,required:s}=e;this._propsToCompare=t,this._propsToExtract=n||t,this._requiredProps=s}arePropsEqual(e,t){for(const n of this._propsToCompare)if(!(n in e)||!(n in t)||!Pa(e[n],t[n]))return!1;return!0}initializeProps(e,t){const n={},s={};for(const r of this._propsToExtract)(r in e||r in t)&&(n[r]=e[r],s[r]=t[r]);return this._checkRequiredProps(n),this._checkRequiredProps(s),{start:n,end:s}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{const n=e[t];sd(Number.isFinite(n)||Array.isArray(n),`${t} is required for transition`)})}}const id=["longitude","latitude","zoom","bearing","pitch"],od=["longitude","latitude","zoom"];class ad extends rd{constructor(e={}){const t=Array.isArray(e)?e:e.transitionProps,n=Array.isArray(e)?{}:e;n.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:id,required:od},super(n.transitionProps),this.opts=n}initializeProps(e,t){const n=super.initializeProps(e,t),{makeViewport:s,around:r}=this.opts;if(s&&r){const i=s(e),o=s(t),a=i.unproject(r);n.start.around=r,Object.assign(n.end,{around:o.project(a),aroundPosition:a,width:t.width,height:t.height})}return n}interpolateProps(e,t,n){const s={};for(const r of this._propsToExtract)s[r]=Ca(e[r]||0,t[r]||0,n);if(t.aroundPosition&&this.opts.makeViewport){const r=this.opts.makeViewport({...t,...s});Object.assign(s,r.panByPosition(t.aroundPosition,Ca(e.around,t.around,n)))}return s}}const ld={transitionDuration:0},cd=e=>1-(1-e)*(1-e),ud=["wheel"],hd=["panstart","panmove","panend"],dd=["pinchstart","pinchmove","pinchend"],fd=["multipanstart","multipanmove","multipanend"],pd=["dblclick"],gd=["keydown"],md={};class _d{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new nd({...e,getControllerState:e=>new this.ControllerState(e),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){var e;for(const t in this._events)this._events[t]&&(null==(e=this.eventManager)||e.off(t,this.handleEvent));this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;const t=this._eventStartBlocked;switch(e.type){case"panstart":return!t&&this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return!t&&this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"multipanstart":return!t&&this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){const{x:t,y:n}=this.props,{offsetCenter:s}=e;return[s.x-t,s.y-n]}isPointInBounds(e,t){const{width:n,height:s}=this.props;if(t&&t.handled)return!1;const r=e[0]>=0&&e[0]<=n&&e[1]>=0&&e[1]<=s;return r&&t&&t.stopPropagation(),r}isFunctionKeyPressed(e){const{srcEvent:t}=e;return Boolean(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){const t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);const{inertia:t}=e;this.inertia=Number.isFinite(t)?t:!0===t?300:0;const{scrollZoom:n=!0,dragPan:s=!0,dragRotate:r=!0,doubleClickZoom:i=!0,touchZoom:o=!0,touchRotate:a=!1,keyboard:l=!0}=e,c=Boolean(this.onViewStateChange);this.toggleEvents(ud,c&&n),this.toggleEvents(hd,c),this.toggleEvents(dd,c&&(o||a)),this.toggleEvents(fd,c&&a),this.toggleEvents(pd,c&&i),this.toggleEvents(gd,c&&l),this.scrollZoom=n,this.dragPan=s,this.dragRotate=r,this.doubleClickZoom=i,this.touchZoom=o,this.touchRotate=a,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(e=>{this._events[e]!==t&&(this._events[e]=t,t?this.eventManager.on(e,this.handleEvent):this.eventManager.off(e,this.handleEvent))})}updateViewport(e,t=null,n={}){const s={...e.getViewportProps(),...t},r=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(n),r){const e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:s,interactionState:this._interactionState,oldViewState:e,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||"pan"===this.dragMode)&&(n=!n);const s=this.controllerState[n?"panStart":"rotateStart"]({pos:t});return this._panMove=n,this.updateViewport(s,ld,{isDragging:!0}),!0}_onPan(e){return!!this.isDragging()&&(this._panMove?this._onPanMove(e):this._onPanRotate(e))}_onPanEnd(e){return!!this.isDragging()&&(this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e))}_onPanMove(e){if(!this.dragPan)return!1;const t=this.getCenter(e),n=this.controllerState.pan({pos:t});return this.updateViewport(n,ld,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:t}=this;if(this.dragPan&&t&&e.velocity){const n=this.getCenter(e),s=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],r=this.controllerState.pan({pos:s}).panEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:cd},{isDragging:!1,isPanning:!0})}else{const e=this.controllerState.panEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const t=this.getCenter(e),n=this.controllerState.rotate({pos:t});return this.updateViewport(n,ld,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){const n=this.getCenter(e),s=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],r=this.controllerState.rotate({pos:s}).rotateEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:cd},{isDragging:!1,isRotating:!0})}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();const{speed:n=.01,smooth:s=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:r}=e;let i=2/(1+Math.exp(-Math.abs(r*n)));r<0&&0!==i&&(i=1/i);const o=s?{...this._getTransitionProps({around:t}),transitionDuration:250}:ld,a=this.controllerState.zoom({pos:t,scale:i});return this.updateViewport(a,o,{isZooming:!0,isPanning:!0}),!0}_onMultiPanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const n=this.controllerState.rotateStart({pos:t});return this.updateViewport(n,ld,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate)return!1;if(!this.isDragging())return!1;const t=this.getCenter(e);t[0]-=e.deltaX;const n=this.controllerState.rotate({pos:t});return this.updateViewport(n,ld,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){const n=this.getCenter(e),s=[n[0],n[1]+=e.velocityY*t/2],r=this.controllerState.rotate({pos:s});this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:cd},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const n=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return md._startPinchRotation=e.rotation,md._lastPinchEvent=e,this.updateViewport(n,ld,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate)return!1;if(!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){const{scale:n}=e,s=this.getCenter(e);t=t.zoom({pos:s,scale:n})}if(this.touchRotate){const{rotation:n}=e;t=t.rotate({deltaAngleX:md._startPinchRotation-n})}return this.updateViewport(t,ld,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),md._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this,{_lastPinchEvent:n}=md;if(this.touchZoom&&t&&n&&e.scale!==n.scale){const s=this.getCenter(e);let r=this.controllerState.rotateEnd();const i=Math.log2(e.scale),o=(i-Math.log2(n.scale))/(e.deltaTime-n.deltaTime),a=Math.pow(2,i+o*t/2);r=r.zoom({pos:s,scale:a}).zoomEnd(),this.updateViewport(r,{...this._getTransitionProps({around:s}),transitionDuration:t,transitionEasing:cd},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{const e=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return md._startPinchRotation=null,md._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const n=this.isFunctionKeyPressed(e),s=this.controllerState.zoom({pos:t,scale:n?.5:2});return this.updateViewport(s,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;const t=this.isFunctionKeyPressed(e),{zoomSpeed:n,moveSpeed:s,rotateSpeedX:r,rotateSpeedY:i}=!0===this.keyboard?{}:this.keyboard,{controllerState:o}=this;let a;const l={};switch(e.srcEvent.code){case"Minus":a=t?o.zoomOut(n).zoomOut(n):o.zoomOut(n),l.isZooming=!0;break;case"Equal":a=t?o.zoomIn(n).zoomIn(n):o.zoomIn(n),l.isZooming=!0;break;case"ArrowLeft":t?(a=o.rotateLeft(r),l.isRotating=!0):(a=o.moveLeft(s),l.isPanning=!0);break;case"ArrowRight":t?(a=o.rotateRight(r),l.isRotating=!0):(a=o.moveRight(s),l.isPanning=!0);break;case"ArrowUp":t?(a=o.rotateUp(i),l.isRotating=!0):(a=o.moveUp(s),l.isPanning=!0);break;case"ArrowDown":t?(a=o.rotateDown(i),l.isRotating=!0):(a=o.moveDown(s),l.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),l),!0}_getTransitionProps(e){const{transition:t}=this;return t&&t.transitionInterpolator?e?{...t,transitionInterpolator:new ad({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t:ld}}class yd{constructor(e,t){this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}}class bd extends yd{constructor(e){const{width:t,height:n,latitude:s,longitude:r,zoom:i,bearing:o=0,pitch:a=0,altitude:l=1.5,position:c=[0,0,0],maxZoom:u=20,minZoom:h=0,maxPitch:d=60,minPitch:f=0,startPanLngLat:p,startZoomLngLat:g,startRotatePos:m,startBearing:_,startPitch:y,startZoom:b,normalize:v=!0}=e;sd(Number.isFinite(r)),sd(Number.isFinite(s)),sd(Number.isFinite(i)),super({width:t,height:n,latitude:s,longitude:r,zoom:i,bearing:o,pitch:a,altitude:l,maxZoom:u,minZoom:h,maxPitch:d,minPitch:f,normalize:v,position:c},{startPanLngLat:p,startZoomLngLat:g,startRotatePos:m,startBearing:_,startPitch:y,startZoom:b}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){const n=this.getState().startPanLngLat||this._unproject(t);if(!n)return this;const s=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(s)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){const{startRotatePos:s,startBearing:r,startPitch:i}=this.getState();if(!s||void 0===r||void 0===i)return this;let o;return o=e?this._getNewRotation(e,s,i,r):{bearing:r+t,pitch:i+n},this._getUpdatedState(o)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:s,startZoomLngLat:r}=this.getState();if(r||(s=this.getViewportProps().zoom,r=this._unproject(t)||this._unproject(e)),!r)return this;const{maxZoom:i,minZoom:o}=this.getViewportProps();let a=s+Math.log2(n);a=Ra(a,o,i);const l=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...l.panByPosition(r,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){const t=e.getViewportProps(),n={...this.getViewportProps()},{bearing:s,longitude:r}=n;return Math.abs(s-t.bearing)>180&&(n.bearing=s<0?s+360:s-360),Math.abs(r-t.longitude)>180&&(n.longitude=r<0?r+360:r-360),n}applyConstraints(e){const{maxZoom:t,minZoom:n,zoom:s}=e;e.zoom=Ra(s,n,t);const{maxPitch:r,minPitch:i,pitch:o}=e;e.pitch=Ra(o,i,r);const{normalize:a=!0}=e;return a&&Object.assign(e,function(e){const{width:t,height:n,pitch:s=0}=e;let{longitude:r,latitude:i,zoom:o,bearing:a=0}=e;(r<-180||r>180)&&(r=Gc(r+180,360)-180),(a<-180||a>180)&&(a=Gc(a+180,360)-180);const l=zc(n/512);if(o<=l)o=l,i=0;else{const e=n/2/Math.pow(2,o),t=Jc([0,e])[1];if(it&&(i=t)}}return{width:t,height:n,longitude:r,latitude:i,zoom:o,pitch:s,bearing:a}}(e)),e}_zoomFromCenter(e){const{width:t,height:n}=this.getViewportProps();return this.zoom({pos:[t/2,n/2],scale:e})}_panFromCenter(e){const{width:t,height:n}=this.getViewportProps();return this.pan({startPos:[t/2,n/2],pos:[t/2+e[0],n/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){const t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_getNewRotation(e,t,n,s){const r=e[0]-t[0],i=e[1]-t[1],o=e[1],a=t[1],{width:l,height:c}=this.getViewportProps(),u=r/l;let h=0;i>0?Math.abs(c-a)>5&&(h=i/(a-c)*1.2):i<0&&a>5&&(h=1-o/a),h=Ra(h,-1,1);const{minPitch:d,maxPitch:f}=this.getViewportProps();let p=n;return h>0?p=n+h*(f-n):h<0&&(p=n-h*(d-n)),{pitch:p,bearing:s+180*u}}}class vd extends _d{constructor(){super(...arguments),this.ControllerState=bd,this.transition={transitionDuration:300,transitionInterpolator:new ad({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];const t=this.props;super.setProps(e),(!t||t.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}}class xd extends Qh{constructor(e={}){super(e)}getViewportType(){return Qu}get ControllerType(){return vd}}xd.displayName="MapView";const wd=new Uu;class Ed{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){const t=this._defaultEffects;if(!t.find(t=>t.id===e.id)){const n=t.findIndex(t=>function(e,t){return(e.order??1/0)-(t.order??1/0)}(t,e)>0);n<0?t.push(e):t.splice(n,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Xh(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){const t={};for(const s of this.effects)t[s.id]=s;const n=[];for(const s of e){const e=t[s.id];let r=s;e&&e!==s?e.setProps?(e.setProps(s.props),r=e):e.cleanup(this._context):e||s.setup(this._context),n.push(r),delete t[s.id]}for(const s in t)t[s].cleanup(this._context);this.effects=n,this._resolvedEffects=n.concat(this._defaultEffects),e.some(e=>e instanceof Uu)||this._resolvedEffects.push(wd),this._needsRedraw="effects changed"}finalize(){for(const e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class Td extends Mu{shouldDrawLayer(e){const{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}}class Sd{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Td(e),this.pickLayersPass=new Lh(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;const t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,n={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};n.effects&&this._preRender(n.effects,n);const s=this.lastPostProcessEffect?this.renderBuffers[0]:n.target;this.lastPostProcessEffect&&(n.clearColor=[0,0,0,0],n.clearCanvas=!0);const r=t.render({...n,target:s});n.effects&&(this.lastPostProcessEffect&&(n.clearCanvas=void 0===e.clearCanvas||e.clearCanvas),this._postRender(n.effects,n)),this.renderCount++,Un("deckRenderer.renderLayers",this,r,e)}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){const{renderBuffers:e}=this;for(const t of e)t.delete();e.length=0}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(const n of e)t.preRenderStats[n.id]=n.preRender(t),n.postRender&&(this.lastPostProcessEffect=n.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){const{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize(),[n,s]=t;0===e.length&&[0,1].map(t=>{const r=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:n,height:s});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${t}`,colorAttachments:[r]}))});for(const r of e)r.resize(t)}_postRender(e,t){const{renderBuffers:n}=this,s={...t,inputBuffer:n[0],swapBuffer:n[1]};for(const r of e)if(r.postRender){s.target=r.id===this.lastPostProcessEffect?t.target:void 0;const e=r.postRender(s);s.inputBuffer=e,s.swapBuffer=e===n[0]?n[1]:n[0]}}}const Ad={pickedColor:null,pickedObjectIndex:-1};function Rd({pickedColors:e,decodePickingColor:t,deviceX:n,deviceY:s,deviceRadius:r,deviceRect:i}){const{x:o,y:a,width:l,height:c}=i;let u=r*r,h=-1,d=0;for(let f=0;fu)d+=4*l;else for(let s=0;s=0){const e=s+o-n,t=e*e+r;t<=u&&(u=t,h=d)}d+=4}}if(h>=0){const n=e.slice(h,h+4),s=t(n);if(s){const e=Math.floor(h/4/l),t=h/4-e*l;return{...s,pickedColor:n,pickedX:o+t,pickedY:a+e}}Fn.error("Picked non-existent layer. Is picking buffer corrupt?")()}return Ad}function Cd({pickedColors:e,decodePickingColor:t}){const n=new Map;if(e)for(let s=0;s=0){const r=e.slice(s,s+4),i=r.join(",");if(!n.has(i)){const e=t(r);e?n.set(i,{...e,color:r}):Fn.error("Picked non-existent layer. Is picking buffer corrupt?")()}}return Array.from(n.values())}function Pd({pickInfo:e,viewports:t,pixelRatio:n,x:s,y:r,z:i}){let o,a=t[0];if(t.length>1&&(a=function(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.containsPixel(t))return s}return e[0]}((null==e?void 0:e.pickedViewports)||t,{x:s,y:r})),a){const e=[s-a.x,r-a.y];void 0!==i&&(e[2]=i),o=a.unproject(e)}return{color:null,layer:null,viewport:a,index:-1,picked:!1,x:s,y:r,pixel:[s,r],coordinate:o,devicePixel:e&&"pickedX"in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:n}}function kd(e){const{pickInfo:t,lastPickedInfo:n,mode:s,layers:r}=e,{pickedColor:i,pickedLayer:o,pickedObjectIndex:a}=t,l=o?[o]:[];if("hover"===s){const e=n.index,t=n.layerId,s=o?o.props.id:null;if(s!==t||a!==e){if(s!==t){const e=r.find(e=>e.props.id===t);e&&l.unshift(e)}n.layerId=s,n.index=a,n.info=null}}const c=Pd(e),u=new Map;return u.set(null,c),l.forEach(e=>{let t={...c};e===o&&(t.color=i,t.index=a,t.picked=!0),t=Id({layer:e,info:t,mode:s});const r=t.layer;e===o&&"hover"===s&&(n.info=t),u.set(r.id,t),"hover"===s&&r.updateAutoHighlight(t)}),u}function Id({layer:e,info:t,mode:n}){for(;e&&t;){const s=t.layer||null;t.sourceLayer=s,t.layer=e,t=e.getPickingInfo({info:t,mode:n,sourceLayer:s}),e=e.parent}return t}class Md{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new Lh(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:n,viewports:s},r=this.lastPickedInfo.info){const i=r&&r.layer&&r.layer.id,o=r&&r.viewport&&r.viewport.id,a=i?n.find(e=>e.id===i):null,l=o&&s.find(e=>e.id===o)||s[0],c=l&&l.unproject([e-l.x,t-l.y]),u={x:e,y:t,viewport:l,coordinate:c,layer:a};return{...r,...u}}_resizeBuffer(){var e,t;if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){const e=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=e}const{canvas:n}=this.device.getDefaultCanvasContext();null==(e=this.pickingFBO)||e.resize({width:n.width,height:n.height}),null==(t=this.depthFBO)||t.resize({width:n.width,height:n.height})}_getPickable(e){if(!1===this._pickable)return null;const t=e.filter(e=>this.pickLayersPass.shouldDrawLayer(e)&&!e.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:n,x:s,y:r,radius:i=0,depth:o=1,mode:a="query",unproject3D:l,onViewportActive:c,effects:u}){const h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||0===n.length)return{result:[],emptyInfo:Pd({viewports:n,x:s,y:r,pixelRatio:h})};this._resizeBuffer();const f=this.device.canvasContext.cssToDevicePixels([s,r],!0),p=[f.x+Math.floor(f.width/2),f.y+Math.floor(f.height/2)],g=Math.round(i*h),{width:m,height:_}=this.pickingFBO,y=this._getPickingRect({deviceX:p[0],deviceY:p[1],deviceRadius:g,deviceWidth:m,deviceHeight:_}),b={x:s-i,y:r-i,width:2*i+1,height:2*i+1};let v;const x=[],w=new Set;for(let E=0;E=l);T++){const e=v[T];let t={color:e.pickedColor,layer:null,index:e.pickedObjectIndex,picked:!0,x:s,y:r,pixelRatio:d};t=Id({layer:e.pickedLayer,info:t,mode:a});const n=t.layer.id;x.has(n)||x.set(n,new Set);const i=x.get(n),o=t.object??t.index;i.has(o)||(i.add(o),w.push(t))}return w}_pickVisibleObjects({layers:e,views:t,viewports:n,x:s,y:r,width:i=1,height:o=1,mode:a="query",maxObjects:l=null,onViewportActive:c,effects:u}){const h=this._getPickable(e);if(!h||0===n.length)return[];this._resizeBuffer();const d=this.device.canvasContext.cssToDeviceRatio(),f=this.device.canvasContext.cssToDevicePixels([s,r],!0),p=f.x,g=f.y+f.height,m=this.device.canvasContext.cssToDevicePixels([s+i,r+o],!0),_=m.x+m.width,y=m.y,b={x:p,y:y,width:_-p,height:g-y},v=Cd(this._drawAndSample({layers:h,views:t,viewports:n,onViewportActive:c,deviceRect:b,cullRect:{x:s,y:r,width:i,height:o},effects:u,pass:`picking:${a}`})),x=new Map,w=[],E=Number.isFinite(l);for(let T=0;T=l);T++){const e=v[T];let t={color:e.pickedColor,layer:null,index:e.pickedObjectIndex,picked:!0,x:s,y:r,pixelRatio:d};t=Id({layer:e.pickedLayer,info:t,mode:a});const n=t.layer.id;x.has(n)||x.set(n,new Set);const i=x.get(n),o=t.object??t.index;i.has(o)||(i.add(o),w.push(t))}return w}async _drawAndSampleAsync({layers:e,views:t,viewports:n,onViewportActive:s,deviceRect:r,cullRect:i,effects:o,pass:a},l=!1){const c=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:s,pickingFBO:c,deviceRect:r,cullRect:i,effects:o,pass:a,pickZ:l,preRenderStats:{},isPicking:!0};for(const _ of o)_.useInPicking&&(u.preRenderStats[_.id]=_.preRender(u));const{decodePickingColor:h}=this.pickLayersPass.render(u),{x:d,y:f,width:p,height:g}=r,m=new(l?Float32Array:Uint8Array)(p*g*4);return this.device.readPixelsToArrayWebGL(c,{sourceX:d,sourceY:f,sourceWidth:p,sourceHeight:g,target:m}),{pickedColors:m,decodePickingColor:h}}_drawAndSample({layers:e,views:t,viewports:n,onViewportActive:s,deviceRect:r,cullRect:i,effects:o,pass:a},l=!1){const c=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:s,pickingFBO:c,deviceRect:r,cullRect:i,effects:o,pass:a,pickZ:l,preRenderStats:{},isPicking:!0};for(const _ of o)_.useInPicking&&(u.preRenderStats[_.id]=_.preRender(u));const{decodePickingColor:h}=this.pickLayersPass.render(u),{x:d,y:f,width:p,height:g}=r,m=new(l?Float32Array:Uint8Array)(p*g*4);return this.device.readPixelsToArrayWebGL(c,{sourceX:d,sourceY:f,sourceWidth:p,sourceHeight:g,target:m}),{pickedColors:m,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:n,deviceWidth:s,deviceHeight:r}){const i=Math.max(0,e-n),o=Math.max(0,t-n),a=Math.min(s,e+n+1)-i,l=Math.min(r,t+n+1)-o;return a<=0||l<=0?null:{x:i,y:o,width:a,height:l}}}const Ld={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},Nd="top-left",Od="__root";class Fd{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,null==t||t.classList.add("deck-widget-container"),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!Xh(e.widgets,this.widgets,1)){const t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(const e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(const e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){var n,s;const r=e.reduce((e,t)=>(e[t.id]=t,e),{});for(const i of this.getWidgets()){const{viewId:o}=i;if(o){const e=r[o];e&&(i.onViewportChange&&i.onViewportChange(e),null==(n=i.onRedraw)||n.call(i,{viewports:[e],layers:t}))}else{if(i.onViewportChange)for(const t of e)i.onViewportChange(t);null==(s=i.onRedraw)||s.call(i,{viewports:e,layers:t})}}this.lastViewports=r,this._updateContainers()}onHover(e,t){var n,s;for(const r of this.getWidgets()){const{viewId:i}=r;i&&i!==(null==(n=e.viewport)?void 0:n.id)||null==(s=r.onHover)||s.call(r,e,t)}}onEvent(e,t){var n,s;const r=wc[t.type];if(r)for(const i of this.getWidgets()){const{viewId:o}=i;o&&o!==(null==(n=e.viewport)?void 0:n.id)||null==(s=i[r])||s.call(i,e,t)}}_setWidgets(e){const t={};for(const n of this.resolvedWidgets)t[n.id]=n;this.resolvedWidgets.length=0;for(const n of this.defaultWidgets)t[n.id]=null,this.resolvedWidgets.push(n);for(let n of e){const e=t[n.id];e?e.viewId!==n.viewId||e.placement!==n.placement?(this._removeWidget(e),this._addWidget(n)):n!==e&&(e.setProps(n.props),n=e):this._addWidget(n),t[n.id]=null,this.resolvedWidgets.push(n)}for(const n in t){const e=t[n];e&&this._removeWidget(e)}this.widgets=e}_addWidget(e){const{viewId:t=null,placement:n=Nd}=e;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(t,n).append(e.rootElement),e.updateHTML()}_removeWidget(e){var t;null==(t=e.onRemove)||t.call(e),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){var n;const s=e||Od;let r=this.containers[s];r||(r=document.createElement("div"),r.style.pointerEvents="none",r.style.position="absolute",r.style.overflow="hidden",null==(n=this.parentElement)||n.append(r),this.containers[s]=r);let i=r.querySelector(`.${t}`);return i||(i=globalThis.document.createElement("div"),i.className=t,i.style.position="absolute",i.style.zIndex="2",Object.assign(i.style,Ld[t]),r.append(i)),i}_updateContainers(){const e=this.deck.width,t=this.deck.height;for(const n in this.containers){const s=this.lastViewports[n]||null,r=n===Od||s,i=this.containers[n];r?(i.style.display="block",i.style.left=`${s?s.x:0}px`,i.style.top=`${s?s.y:0}px`,i.style.width=`${s?s.width:e}px`,i.style.height=`${s?s.height:t}px`):i.style.display="none"}}}function Dd(e,t){t&&Object.entries(t).map(([t,n])=>{t.startsWith("--")?e.style.setProperty(t,n):e.style[t]=n})}class Bd{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){const t=this.props,n=this.rootElement;var s,r;n&&t.className!==e.className&&(t.className&&n.classList.remove(t.className),e.className&&n.classList.add(e.className)),n&&!Xh(t.style,e.style,1)&&(s=n,(r=t.style)&&Object.keys(r).map(e=>{e.startsWith("--")?s.style.removeProperty(e):s.style[e]=""}),Dd(n,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}onCreateRootElement(){const e=["deck-widget",this.className,this.props.className],t=document.createElement("div");return e.filter(e=>"string"==typeof e&&e.length>0).forEach(e=>t.classList.add(e)),Dd(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}}Bd.defaultProps={id:"widget",style:{},className:""};const Ud={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class jd extends Bd{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){const e=document.createElement("div");return e.className=this.className,Object.assign(e.style,Ud),e}onRenderHTML(e){}onViewportChange(e){var t;this.isVisible&&e.id===(null==(t=this.lastViewport)?void 0:t.id)&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){const{deck:t}=this,n=t&&t.props.getTooltip;if(!n)return;const s=n(e);this.setTooltip(s,e.x,e.y)}setTooltip(e,t,n){const s=this.rootElement;if(s){if("string"==typeof e)s.innerText=e;else{if(!e)return this.isVisible=!1,void(s.style.display="none");e.text&&(s.innerText=e.text),e.html&&(s.innerHTML=e.html),e.className&&(s.className=e.className)}this.isVisible=!0,s.style.display="block",s.style.transform=`translate(${t}px, ${n}px)`,e&&"object"==typeof e&&"style"in e&&Object.assign(s.style,e.style)}}}var Gd,Vd;jd.defaultProps={...Bd.defaultProps},(Vd=Gd||(Gd={}))[Vd.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",Vd[Vd.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",Vd[Vd.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",Vd[Vd.POINTS=0]="POINTS",Vd[Vd.LINES=1]="LINES",Vd[Vd.LINE_LOOP=2]="LINE_LOOP",Vd[Vd.LINE_STRIP=3]="LINE_STRIP",Vd[Vd.TRIANGLES=4]="TRIANGLES",Vd[Vd.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",Vd[Vd.TRIANGLE_FAN=6]="TRIANGLE_FAN",Vd[Vd.ZERO=0]="ZERO",Vd[Vd.ONE=1]="ONE",Vd[Vd.SRC_COLOR=768]="SRC_COLOR",Vd[Vd.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",Vd[Vd.SRC_ALPHA=770]="SRC_ALPHA",Vd[Vd.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",Vd[Vd.DST_ALPHA=772]="DST_ALPHA",Vd[Vd.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",Vd[Vd.DST_COLOR=774]="DST_COLOR",Vd[Vd.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",Vd[Vd.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",Vd[Vd.CONSTANT_COLOR=32769]="CONSTANT_COLOR",Vd[Vd.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",Vd[Vd.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",Vd[Vd.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",Vd[Vd.FUNC_ADD=32774]="FUNC_ADD",Vd[Vd.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",Vd[Vd.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",Vd[Vd.BLEND_EQUATION=32777]="BLEND_EQUATION",Vd[Vd.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",Vd[Vd.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",Vd[Vd.BLEND_DST_RGB=32968]="BLEND_DST_RGB",Vd[Vd.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",Vd[Vd.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",Vd[Vd.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",Vd[Vd.BLEND_COLOR=32773]="BLEND_COLOR",Vd[Vd.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",Vd[Vd.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",Vd[Vd.LINE_WIDTH=2849]="LINE_WIDTH",Vd[Vd.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",Vd[Vd.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",Vd[Vd.CULL_FACE_MODE=2885]="CULL_FACE_MODE",Vd[Vd.FRONT_FACE=2886]="FRONT_FACE",Vd[Vd.DEPTH_RANGE=2928]="DEPTH_RANGE",Vd[Vd.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",Vd[Vd.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",Vd[Vd.DEPTH_FUNC=2932]="DEPTH_FUNC",Vd[Vd.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",Vd[Vd.STENCIL_FUNC=2962]="STENCIL_FUNC",Vd[Vd.STENCIL_FAIL=2964]="STENCIL_FAIL",Vd[Vd.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",Vd[Vd.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",Vd[Vd.STENCIL_REF=2967]="STENCIL_REF",Vd[Vd.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",Vd[Vd.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",Vd[Vd.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",Vd[Vd.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",Vd[Vd.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",Vd[Vd.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",Vd[Vd.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",Vd[Vd.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",Vd[Vd.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",Vd[Vd.VIEWPORT=2978]="VIEWPORT",Vd[Vd.SCISSOR_BOX=3088]="SCISSOR_BOX",Vd[Vd.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",Vd[Vd.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",Vd[Vd.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",Vd[Vd.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",Vd[Vd.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",Vd[Vd.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",Vd[Vd.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",Vd[Vd.RED_BITS=3410]="RED_BITS",Vd[Vd.GREEN_BITS=3411]="GREEN_BITS",Vd[Vd.BLUE_BITS=3412]="BLUE_BITS",Vd[Vd.ALPHA_BITS=3413]="ALPHA_BITS",Vd[Vd.DEPTH_BITS=3414]="DEPTH_BITS",Vd[Vd.STENCIL_BITS=3415]="STENCIL_BITS",Vd[Vd.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",Vd[Vd.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",Vd[Vd.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",Vd[Vd.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",Vd[Vd.SAMPLES=32937]="SAMPLES",Vd[Vd.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",Vd[Vd.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",Vd[Vd.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",Vd[Vd.VENDOR=7936]="VENDOR",Vd[Vd.RENDERER=7937]="RENDERER",Vd[Vd.VERSION=7938]="VERSION",Vd[Vd.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",Vd[Vd.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",Vd[Vd.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",Vd[Vd.STATIC_DRAW=35044]="STATIC_DRAW",Vd[Vd.STREAM_DRAW=35040]="STREAM_DRAW",Vd[Vd.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",Vd[Vd.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Vd[Vd.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",Vd[Vd.BUFFER_SIZE=34660]="BUFFER_SIZE",Vd[Vd.BUFFER_USAGE=34661]="BUFFER_USAGE",Vd[Vd.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",Vd[Vd.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",Vd[Vd.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",Vd[Vd.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",Vd[Vd.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",Vd[Vd.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",Vd[Vd.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",Vd[Vd.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",Vd[Vd.CULL_FACE=2884]="CULL_FACE",Vd[Vd.FRONT=1028]="FRONT",Vd[Vd.BACK=1029]="BACK",Vd[Vd.FRONT_AND_BACK=1032]="FRONT_AND_BACK",Vd[Vd.BLEND=3042]="BLEND",Vd[Vd.DEPTH_TEST=2929]="DEPTH_TEST",Vd[Vd.DITHER=3024]="DITHER",Vd[Vd.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",Vd[Vd.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",Vd[Vd.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",Vd[Vd.SCISSOR_TEST=3089]="SCISSOR_TEST",Vd[Vd.STENCIL_TEST=2960]="STENCIL_TEST",Vd[Vd.NO_ERROR=0]="NO_ERROR",Vd[Vd.INVALID_ENUM=1280]="INVALID_ENUM",Vd[Vd.INVALID_VALUE=1281]="INVALID_VALUE",Vd[Vd.INVALID_OPERATION=1282]="INVALID_OPERATION",Vd[Vd.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",Vd[Vd.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",Vd[Vd.CW=2304]="CW",Vd[Vd.CCW=2305]="CCW",Vd[Vd.DONT_CARE=4352]="DONT_CARE",Vd[Vd.FASTEST=4353]="FASTEST",Vd[Vd.NICEST=4354]="NICEST",Vd[Vd.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",Vd[Vd.BYTE=5120]="BYTE",Vd[Vd.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",Vd[Vd.SHORT=5122]="SHORT",Vd[Vd.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",Vd[Vd.INT=5124]="INT",Vd[Vd.UNSIGNED_INT=5125]="UNSIGNED_INT",Vd[Vd.FLOAT=5126]="FLOAT",Vd[Vd.DOUBLE=5130]="DOUBLE",Vd[Vd.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",Vd[Vd.ALPHA=6406]="ALPHA",Vd[Vd.RGB=6407]="RGB",Vd[Vd.RGBA=6408]="RGBA",Vd[Vd.LUMINANCE=6409]="LUMINANCE",Vd[Vd.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",Vd[Vd.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",Vd[Vd.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",Vd[Vd.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",Vd[Vd.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",Vd[Vd.VERTEX_SHADER=35633]="VERTEX_SHADER",Vd[Vd.COMPILE_STATUS=35713]="COMPILE_STATUS",Vd[Vd.DELETE_STATUS=35712]="DELETE_STATUS",Vd[Vd.LINK_STATUS=35714]="LINK_STATUS",Vd[Vd.VALIDATE_STATUS=35715]="VALIDATE_STATUS",Vd[Vd.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",Vd[Vd.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",Vd[Vd.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",Vd[Vd.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",Vd[Vd.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",Vd[Vd.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",Vd[Vd.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",Vd[Vd.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",Vd[Vd.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",Vd[Vd.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",Vd[Vd.SHADER_TYPE=35663]="SHADER_TYPE",Vd[Vd.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",Vd[Vd.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",Vd[Vd.NEVER=512]="NEVER",Vd[Vd.LESS=513]="LESS",Vd[Vd.EQUAL=514]="EQUAL",Vd[Vd.LEQUAL=515]="LEQUAL",Vd[Vd.GREATER=516]="GREATER",Vd[Vd.NOTEQUAL=517]="NOTEQUAL",Vd[Vd.GEQUAL=518]="GEQUAL",Vd[Vd.ALWAYS=519]="ALWAYS",Vd[Vd.KEEP=7680]="KEEP",Vd[Vd.REPLACE=7681]="REPLACE",Vd[Vd.INCR=7682]="INCR",Vd[Vd.DECR=7683]="DECR",Vd[Vd.INVERT=5386]="INVERT",Vd[Vd.INCR_WRAP=34055]="INCR_WRAP",Vd[Vd.DECR_WRAP=34056]="DECR_WRAP",Vd[Vd.NEAREST=9728]="NEAREST",Vd[Vd.LINEAR=9729]="LINEAR",Vd[Vd.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",Vd[Vd.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",Vd[Vd.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",Vd[Vd.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",Vd[Vd.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",Vd[Vd.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",Vd[Vd.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",Vd[Vd.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",Vd[Vd.TEXTURE_2D=3553]="TEXTURE_2D",Vd[Vd.TEXTURE=5890]="TEXTURE",Vd[Vd.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",Vd[Vd.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",Vd[Vd.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",Vd[Vd.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",Vd[Vd.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",Vd[Vd.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",Vd[Vd.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",Vd[Vd.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",Vd[Vd.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",Vd[Vd.TEXTURE0=33984]="TEXTURE0",Vd[Vd.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",Vd[Vd.REPEAT=10497]="REPEAT",Vd[Vd.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",Vd[Vd.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",Vd[Vd.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",Vd[Vd.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",Vd[Vd.FLOAT_VEC2=35664]="FLOAT_VEC2",Vd[Vd.FLOAT_VEC3=35665]="FLOAT_VEC3",Vd[Vd.FLOAT_VEC4=35666]="FLOAT_VEC4",Vd[Vd.INT_VEC2=35667]="INT_VEC2",Vd[Vd.INT_VEC3=35668]="INT_VEC3",Vd[Vd.INT_VEC4=35669]="INT_VEC4",Vd[Vd.BOOL=35670]="BOOL",Vd[Vd.BOOL_VEC2=35671]="BOOL_VEC2",Vd[Vd.BOOL_VEC3=35672]="BOOL_VEC3",Vd[Vd.BOOL_VEC4=35673]="BOOL_VEC4",Vd[Vd.FLOAT_MAT2=35674]="FLOAT_MAT2",Vd[Vd.FLOAT_MAT3=35675]="FLOAT_MAT3",Vd[Vd.FLOAT_MAT4=35676]="FLOAT_MAT4",Vd[Vd.SAMPLER_2D=35678]="SAMPLER_2D",Vd[Vd.SAMPLER_CUBE=35680]="SAMPLER_CUBE",Vd[Vd.LOW_FLOAT=36336]="LOW_FLOAT",Vd[Vd.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",Vd[Vd.HIGH_FLOAT=36338]="HIGH_FLOAT",Vd[Vd.LOW_INT=36339]="LOW_INT",Vd[Vd.MEDIUM_INT=36340]="MEDIUM_INT",Vd[Vd.HIGH_INT=36341]="HIGH_INT",Vd[Vd.FRAMEBUFFER=36160]="FRAMEBUFFER",Vd[Vd.RENDERBUFFER=36161]="RENDERBUFFER",Vd[Vd.RGBA4=32854]="RGBA4",Vd[Vd.RGB5_A1=32855]="RGB5_A1",Vd[Vd.RGB565=36194]="RGB565",Vd[Vd.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",Vd[Vd.STENCIL_INDEX=6401]="STENCIL_INDEX",Vd[Vd.STENCIL_INDEX8=36168]="STENCIL_INDEX8",Vd[Vd.DEPTH_STENCIL=34041]="DEPTH_STENCIL",Vd[Vd.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",Vd[Vd.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",Vd[Vd.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",Vd[Vd.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",Vd[Vd.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",Vd[Vd.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",Vd[Vd.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",Vd[Vd.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",Vd[Vd.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",Vd[Vd.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",Vd[Vd.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",Vd[Vd.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",Vd[Vd.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",Vd[Vd.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",Vd[Vd.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",Vd[Vd.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",Vd[Vd.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",Vd[Vd.NONE=0]="NONE",Vd[Vd.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",Vd[Vd.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",Vd[Vd.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",Vd[Vd.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",Vd[Vd.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",Vd[Vd.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",Vd[Vd.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",Vd[Vd.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",Vd[Vd.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",Vd[Vd.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",Vd[Vd.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",Vd[Vd.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",Vd[Vd.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",Vd[Vd.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",Vd[Vd.READ_BUFFER=3074]="READ_BUFFER",Vd[Vd.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",Vd[Vd.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",Vd[Vd.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",Vd[Vd.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",Vd[Vd.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",Vd[Vd.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",Vd[Vd.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",Vd[Vd.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",Vd[Vd.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",Vd[Vd.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",Vd[Vd.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",Vd[Vd.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",Vd[Vd.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",Vd[Vd.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",Vd[Vd.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",Vd[Vd.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",Vd[Vd.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",Vd[Vd.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",Vd[Vd.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",Vd[Vd.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",Vd[Vd.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",Vd[Vd.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",Vd[Vd.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",Vd[Vd.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",Vd[Vd.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",Vd[Vd.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",Vd[Vd.RED=6403]="RED",Vd[Vd.RGB8=32849]="RGB8",Vd[Vd.RGBA8=32856]="RGBA8",Vd[Vd.RGB10_A2=32857]="RGB10_A2",Vd[Vd.TEXTURE_3D=32879]="TEXTURE_3D",Vd[Vd.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",Vd[Vd.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",Vd[Vd.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",Vd[Vd.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",Vd[Vd.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",Vd[Vd.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",Vd[Vd.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",Vd[Vd.SRGB=35904]="SRGB",Vd[Vd.SRGB8=35905]="SRGB8",Vd[Vd.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",Vd[Vd.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",Vd[Vd.RGBA32F=34836]="RGBA32F",Vd[Vd.RGB32F=34837]="RGB32F",Vd[Vd.RGBA16F=34842]="RGBA16F",Vd[Vd.RGB16F=34843]="RGB16F",Vd[Vd.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",Vd[Vd.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",Vd[Vd.R11F_G11F_B10F=35898]="R11F_G11F_B10F",Vd[Vd.RGB9_E5=35901]="RGB9_E5",Vd[Vd.RGBA32UI=36208]="RGBA32UI",Vd[Vd.RGB32UI=36209]="RGB32UI",Vd[Vd.RGBA16UI=36214]="RGBA16UI",Vd[Vd.RGB16UI=36215]="RGB16UI",Vd[Vd.RGBA8UI=36220]="RGBA8UI",Vd[Vd.RGB8UI=36221]="RGB8UI",Vd[Vd.RGBA32I=36226]="RGBA32I",Vd[Vd.RGB32I=36227]="RGB32I",Vd[Vd.RGBA16I=36232]="RGBA16I",Vd[Vd.RGB16I=36233]="RGB16I",Vd[Vd.RGBA8I=36238]="RGBA8I",Vd[Vd.RGB8I=36239]="RGB8I",Vd[Vd.RED_INTEGER=36244]="RED_INTEGER",Vd[Vd.RGB_INTEGER=36248]="RGB_INTEGER",Vd[Vd.RGBA_INTEGER=36249]="RGBA_INTEGER",Vd[Vd.R8=33321]="R8",Vd[Vd.RG8=33323]="RG8",Vd[Vd.R16F=33325]="R16F",Vd[Vd.R32F=33326]="R32F",Vd[Vd.RG16F=33327]="RG16F",Vd[Vd.RG32F=33328]="RG32F",Vd[Vd.R8I=33329]="R8I",Vd[Vd.R8UI=33330]="R8UI",Vd[Vd.R16I=33331]="R16I",Vd[Vd.R16UI=33332]="R16UI",Vd[Vd.R32I=33333]="R32I",Vd[Vd.R32UI=33334]="R32UI",Vd[Vd.RG8I=33335]="RG8I",Vd[Vd.RG8UI=33336]="RG8UI",Vd[Vd.RG16I=33337]="RG16I",Vd[Vd.RG16UI=33338]="RG16UI",Vd[Vd.RG32I=33339]="RG32I",Vd[Vd.RG32UI=33340]="RG32UI",Vd[Vd.R8_SNORM=36756]="R8_SNORM",Vd[Vd.RG8_SNORM=36757]="RG8_SNORM",Vd[Vd.RGB8_SNORM=36758]="RGB8_SNORM",Vd[Vd.RGBA8_SNORM=36759]="RGBA8_SNORM",Vd[Vd.RGB10_A2UI=36975]="RGB10_A2UI",Vd[Vd.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",Vd[Vd.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",Vd[Vd.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",Vd[Vd.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",Vd[Vd.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",Vd[Vd.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",Vd[Vd.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",Vd[Vd.HALF_FLOAT=5131]="HALF_FLOAT",Vd[Vd.RG=33319]="RG",Vd[Vd.RG_INTEGER=33320]="RG_INTEGER",Vd[Vd.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",Vd[Vd.CURRENT_QUERY=34917]="CURRENT_QUERY",Vd[Vd.QUERY_RESULT=34918]="QUERY_RESULT",Vd[Vd.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",Vd[Vd.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",Vd[Vd.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",Vd[Vd.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",Vd[Vd.DRAW_BUFFER0=34853]="DRAW_BUFFER0",Vd[Vd.DRAW_BUFFER1=34854]="DRAW_BUFFER1",Vd[Vd.DRAW_BUFFER2=34855]="DRAW_BUFFER2",Vd[Vd.DRAW_BUFFER3=34856]="DRAW_BUFFER3",Vd[Vd.DRAW_BUFFER4=34857]="DRAW_BUFFER4",Vd[Vd.DRAW_BUFFER5=34858]="DRAW_BUFFER5",Vd[Vd.DRAW_BUFFER6=34859]="DRAW_BUFFER6",Vd[Vd.DRAW_BUFFER7=34860]="DRAW_BUFFER7",Vd[Vd.DRAW_BUFFER8=34861]="DRAW_BUFFER8",Vd[Vd.DRAW_BUFFER9=34862]="DRAW_BUFFER9",Vd[Vd.DRAW_BUFFER10=34863]="DRAW_BUFFER10",Vd[Vd.DRAW_BUFFER11=34864]="DRAW_BUFFER11",Vd[Vd.DRAW_BUFFER12=34865]="DRAW_BUFFER12",Vd[Vd.DRAW_BUFFER13=34866]="DRAW_BUFFER13",Vd[Vd.DRAW_BUFFER14=34867]="DRAW_BUFFER14",Vd[Vd.DRAW_BUFFER15=34868]="DRAW_BUFFER15",Vd[Vd.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",Vd[Vd.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",Vd[Vd.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",Vd[Vd.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",Vd[Vd.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",Vd[Vd.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",Vd[Vd.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",Vd[Vd.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",Vd[Vd.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",Vd[Vd.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",Vd[Vd.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",Vd[Vd.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",Vd[Vd.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",Vd[Vd.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",Vd[Vd.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",Vd[Vd.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",Vd[Vd.SAMPLER_3D=35679]="SAMPLER_3D",Vd[Vd.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",Vd[Vd.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",Vd[Vd.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",Vd[Vd.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",Vd[Vd.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",Vd[Vd.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",Vd[Vd.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",Vd[Vd.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",Vd[Vd.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",Vd[Vd.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",Vd[Vd.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",Vd[Vd.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",Vd[Vd.MAX_SAMPLES=36183]="MAX_SAMPLES",Vd[Vd.SAMPLER_BINDING=35097]="SAMPLER_BINDING",Vd[Vd.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",Vd[Vd.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",Vd[Vd.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",Vd[Vd.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",Vd[Vd.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",Vd[Vd.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",Vd[Vd.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",Vd[Vd.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",Vd[Vd.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",Vd[Vd.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",Vd[Vd.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",Vd[Vd.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",Vd[Vd.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",Vd[Vd.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",Vd[Vd.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",Vd[Vd.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",Vd[Vd.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",Vd[Vd.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",Vd[Vd.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",Vd[Vd.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",Vd[Vd.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",Vd[Vd.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",Vd[Vd.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",Vd[Vd.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",Vd[Vd.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",Vd[Vd.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",Vd[Vd.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",Vd[Vd.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",Vd[Vd.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",Vd[Vd.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",Vd[Vd.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",Vd[Vd.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",Vd[Vd.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",Vd[Vd.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",Vd[Vd.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",Vd[Vd.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",Vd[Vd.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",Vd[Vd.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",Vd[Vd.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",Vd[Vd.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",Vd[Vd.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",Vd[Vd.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",Vd[Vd.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",Vd[Vd.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",Vd[Vd.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",Vd[Vd.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",Vd[Vd.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",Vd[Vd.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",Vd[Vd.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",Vd[Vd.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",Vd[Vd.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",Vd[Vd.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",Vd[Vd.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",Vd[Vd.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",Vd[Vd.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",Vd[Vd.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",Vd[Vd.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",Vd[Vd.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",Vd[Vd.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",Vd[Vd.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",Vd[Vd.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",Vd[Vd.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",Vd[Vd.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",Vd[Vd.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",Vd[Vd.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",Vd[Vd.UNIFORM_TYPE=35383]="UNIFORM_TYPE",Vd[Vd.UNIFORM_SIZE=35384]="UNIFORM_SIZE",Vd[Vd.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",Vd[Vd.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",Vd[Vd.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",Vd[Vd.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",Vd[Vd.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",Vd[Vd.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",Vd[Vd.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",Vd[Vd.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",Vd[Vd.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",Vd[Vd.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",Vd[Vd.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",Vd[Vd.OBJECT_TYPE=37138]="OBJECT_TYPE",Vd[Vd.SYNC_CONDITION=37139]="SYNC_CONDITION",Vd[Vd.SYNC_STATUS=37140]="SYNC_STATUS",Vd[Vd.SYNC_FLAGS=37141]="SYNC_FLAGS",Vd[Vd.SYNC_FENCE=37142]="SYNC_FENCE",Vd[Vd.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",Vd[Vd.UNSIGNALED=37144]="UNSIGNALED",Vd[Vd.SIGNALED=37145]="SIGNALED",Vd[Vd.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",Vd[Vd.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",Vd[Vd.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",Vd[Vd.WAIT_FAILED=37149]="WAIT_FAILED",Vd[Vd.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",Vd[Vd.COLOR=6144]="COLOR",Vd[Vd.DEPTH=6145]="DEPTH",Vd[Vd.STENCIL=6146]="STENCIL",Vd[Vd.MIN=32775]="MIN",Vd[Vd.MAX=32776]="MAX",Vd[Vd.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",Vd[Vd.STREAM_READ=35041]="STREAM_READ",Vd[Vd.STREAM_COPY=35042]="STREAM_COPY",Vd[Vd.STATIC_READ=35045]="STATIC_READ",Vd[Vd.STATIC_COPY=35046]="STATIC_COPY",Vd[Vd.DYNAMIC_READ=35049]="DYNAMIC_READ",Vd[Vd.DYNAMIC_COPY=35050]="DYNAMIC_COPY",Vd[Vd.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",Vd[Vd.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",Vd[Vd.INVALID_INDEX=4294967295]="INVALID_INDEX",Vd[Vd.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",Vd[Vd.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",Vd[Vd.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",Vd[Vd.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",Vd[Vd.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",Vd[Vd.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",Vd[Vd.R16_EXT=33322]="R16_EXT",Vd[Vd.RG16_EXT=33324]="RG16_EXT",Vd[Vd.RGB16_EXT=32852]="RGB16_EXT",Vd[Vd.RGBA16_EXT=32859]="RGBA16_EXT",Vd[Vd.R16_SNORM_EXT=36760]="R16_SNORM_EXT",Vd[Vd.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",Vd[Vd.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",Vd[Vd.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",Vd[Vd.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",Vd[Vd.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",Vd[Vd.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",Vd[Vd.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",Vd[Vd.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",Vd[Vd.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",Vd[Vd.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",Vd[Vd.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",Vd[Vd.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",Vd[Vd.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",Vd[Vd.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",Vd[Vd.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",Vd[Vd.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",Vd[Vd.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",Vd[Vd.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",Vd[Vd.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",Vd[Vd.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",Vd[Vd.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",Vd[Vd.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",Vd[Vd.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",Vd[Vd.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",Vd[Vd.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",Vd[Vd.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",Vd[Vd.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",Vd[Vd.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",Vd[Vd.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",Vd[Vd.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",Vd[Vd.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",Vd[Vd.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",Vd[Vd.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",Vd[Vd.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",Vd[Vd.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",Vd[Vd.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",Vd[Vd.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",Vd[Vd.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",Vd[Vd.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",Vd[Vd.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",Vd[Vd.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",Vd[Vd.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",Vd[Vd.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",Vd[Vd.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",Vd[Vd.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",Vd[Vd.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",Vd[Vd.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",Vd[Vd.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",Vd[Vd.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",Vd[Vd.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",Vd[Vd.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",Vd[Vd.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",Vd[Vd.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",Vd[Vd.LINE_WEBGL=6913]="LINE_WEBGL",Vd[Vd.FILL_WEBGL=6914]="FILL_WEBGL",Vd[Vd.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",Vd[Vd.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",Vd[Vd.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",Vd[Vd.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",Vd[Vd.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",Vd[Vd.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",Vd[Vd.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",Vd[Vd.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",Vd[Vd.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",Vd[Vd.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",Vd[Vd.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",Vd[Vd.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",Vd[Vd.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",Vd[Vd.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",Vd[Vd.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",Vd[Vd.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",Vd[Vd.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",Vd[Vd.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",Vd[Vd.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",Vd[Vd.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",Vd[Vd.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",Vd[Vd.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",Vd[Vd.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",Vd[Vd.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT";const zd={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},Wd=e=>({drawBuffersWEBGL:t=>e.drawBuffers(t),COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),Hd=e=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES:()=>e.createVertexArray(),deleteVertexArrayOES:t=>e.deleteVertexArray(t),isVertexArrayOES:t=>e.isVertexArray(t),bindVertexArrayOES:t=>e.bindVertexArray(t)}),$d=e=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE:(...t)=>e.drawArraysInstanced(...t),drawElementsInstancedANGLE:(...t)=>e.drawElementsInstanced(...t),vertexAttribDivisorANGLE:(...t)=>e.vertexAttribDivisor(...t)});async function Xd(e,t){const n=document.getElementsByTagName("head")[0];if(!n)throw new Error("loadScript");const s=document.createElement("script");return s.setAttribute("type","text/javascript"),s.setAttribute("src",e),new Promise((t,r)=>{s.onload=t,s.onerror=t=>r(new Error(`Unable to load script '${e}': ${t}`)),n.appendChild(s)})}let qd=null,Yd=!1;const Kd={debugSpectorJS:Ss.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};function Zd(e){return e.luma=e.luma||{},e.luma}function Qd(e,t={}){return t.debugWebGL||t.traceWebGL?function(e,t){if(!globalThis.WebGLDebugUtils)return Ss.warn("webgl-debug not loaded")(),e;const n=Zd(e);if(n.debugContext)return n.debugContext;globalThis.WebGLDebugUtils.init({...Gd,...e});const s=globalThis.WebGLDebugUtils.makeDebugContext(e,ef.bind(null,t),tf.bind(null,t));for(const o in Gd)o in s||"number"!=typeof Gd[o]||(s[o]=Gd[o]);class r{}Object.setPrototypeOf(s,Object.getPrototypeOf(e)),Object.setPrototypeOf(r,s);const i=Object.create(r);return n.realContext=e,n.debugContext=i,i.debug=!0,i}(e,t):function(e){const t=Zd(e);return t.realContext?t.realContext:e}(e)}function Jd(e,t){t=Array.from(t).map(e=>void 0===e?"undefined":e);let n=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return n=`${n.slice(0,100)}${n.length>100?"...":""}`,`gl.${e}(${n})`}function ef(e,t,n,s){s=Array.from(s).map(e=>void 0===e?"undefined":e);const r=`${globalThis.WebGLDebugUtils.glEnumToString(t)} in gl.${n}(${globalThis.WebGLDebugUtils.glFunctionArgsToString(n,s)})`;Ss.error(r)()}function tf(e,t,n){let s="";Ss.level>=1&&(s=Jd(t,n),e.traceWebGL&&Ss.log(1,s)());for(const r of n)void 0===r&&(s=s||Jd(t,n))}const nf=new class extends cr{constructor(){super(),s(this,"type","webgl"),ir.defaultProps={...ir.defaultProps,...Kd}}enforceWebGL2(e){!function(e=!0){const t=HTMLCanvasElement.prototype;if(!e&&t.originalGetContext)return t.getContext=t.originalGetContext,void(t.originalGetContext=void 0);t.originalGetContext=t.getContext,t.getContext=function(e,t){if("webgl"===e||"experimental-webgl"===e){const e=this.originalGetContext("webgl2",t);return e instanceof HTMLElement&&function(e){e.getExtension("EXT_color_buffer_float");const t={...zd,WEBGL_disjoint_timer_query:e.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:Wd(e),OES_vertex_array_object:Hd(e),ANGLE_instanced_arrays:$d(e)},n=e.getExtension;e.getExtension=function(s){return n.call(e,s)||(s in t?t[s]:null)};const s=e.getSupportedExtensions;e.getSupportedExtensions=function(){const n=s.apply(e)||[];return null==n?void 0:n.concat(Object.keys(t))}}(e),e}return this.originalGetContext(e,t)}}(e)}isSupported(){return"undefined"!=typeof WebGL2RenderingContext}isDeviceHandle(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||("undefined"!=typeof WebGLRenderingContext&&e instanceof WebGLRenderingContext&&Ss.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:n}=await l(async()=>{const{WebGLDevice:e}=await Promise.resolve().then(()=>Np);return{WebGLDevice:e}},void 0);if(e instanceof n)return e;if((null==e?void 0:e.device)instanceof n)return e.device;if(!function(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||Boolean(e&&Number.isFinite(e._version))}(e))throw new Error("Invalid WebGL2RenderingContext");const s=!0===t.createCanvasContext?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){const{WebGLDevice:t}=await l(async()=>{const{WebGLDevice:e}=await Promise.resolve().then(()=>Np);return{WebGLDevice:e}},void 0);Ss.groupCollapsed(1,"WebGLDevice created")();try{const n=[];(e.debugWebGL||e.debug)&&n.push(async function(){Ne()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Xd("https://unpkg.com/webgl-debug@2.0.1/index.js"))}()),e.debugSpectorJS&&n.push(async function(e){if(!globalThis.SPECTOR)try{await Xd(e.debugSpectorJSUrl||Kd.debugSpectorJSUrl)}catch(t){Ss.warn(String(t))}}(e));const s=await Promise.allSettled(n);for(const e of s)"rejected"===e.status&&Ss.error(`Failed to initialize debug libraries ${e.reason}`)();const r=new t(e),i=`${r._reused?"Reusing":"Created"} device with WebGL2 ${r.props.debug?"debug ":""}context: ${r.info.vendor}, ${r.info.renderer} for canvas: ${r.canvasContext.id}`;return Ss.probe(1,i)(),Ss.table(1,r.info)(),r}finally{Ss.groupEnd(1)()}}},sf={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},rf=(e,t,n)=>t?e.enable(n):e.disable(n),of=(e,t,n)=>e.hint(n,t),af=(e,t,n)=>e.pixelStorei(n,t),lf=(e,t,n)=>{const s=36006===n?36009:36008;return e.bindFramebuffer(s,t)},cf=(e,t,n)=>{const s={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[n];e.bindBuffer(s,t)};function uf(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}const hf={3042:rf,32773:(e,t)=>e.blendColor(...t),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:rf,2885:(e,t)=>e.cullFace(t),2929:rf,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:rf,35723:of,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>{var n;return null==(n=e.bindTransformFeedback)?void 0:n.call(e,36386,t)},34229:(e,t)=>e.bindVertexArray(t),36006:lf,36010:lf,34964:cf,36662:cf,36663:cf,35053:cf,35055:cf,2886:(e,t)=>e.frontFace(t),33170:of,2849:(e,t)=>e.lineWidth(t),32823:rf,32824:"polygonOffset",10752:"polygonOffset",35977:rf,32926:rf,32928:rf,32938:"sampleCoverage",32939:"sampleCoverage",3089:rf,3088:(e,t)=>e.scissor(...t),2960:rf,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(e,t)=>e.viewport(...t),34383:rf,10754:rf,12288:rf,12289:rf,12290:rf,12291:rf,12292:rf,12293:rf,12294:rf,12295:rf,3333:af,3317:af,37440:af,37441:af,37443:af,3330:af,3332:af,3331:af,3314:af,32878:af,3316:af,3315:af,32877:af,framebuffer:(e,t)=>{const n=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,n)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{const n="number"==typeof t?[t,t]:t;e.blendEquationSeparate(...n)},blendFunc:(e,t)=>{const n=2===(null==t?void 0:t.length)?[...t,...t]:t;e.blendFuncSeparate(...n)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(t[0],t[1]||!1),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=uf(t)?t:[t,t];const[n,s]=t;e.stencilMaskSeparate(1028,n),e.stencilMaskSeparate(1029,s)},stencilFunc:(e,t)=>{t=uf(t)&&3===t.length?[...t,...t]:t;const[n,s,r,i,o,a]=t;e.stencilFuncSeparate(1028,n,s,r),e.stencilFuncSeparate(1029,i,o,a)},stencilOp:(e,t)=>{t=uf(t)&&3===t.length?[...t,...t]:t;const[n,s,r,i,o,a]=t;e.stencilOpSeparate(1028,n,s,r),e.stencilOpSeparate(1029,i,o,a)},viewport:(e,t)=>e.viewport(...t)};function df(e,t,n){return void 0!==t[e]?t[e]:n[e]}const ff={blendEquation:(e,t,n)=>e.blendEquationSeparate(df(32777,t,n),df(34877,t,n)),blendFunc:(e,t,n)=>e.blendFuncSeparate(df(32969,t,n),df(32968,t,n),df(32971,t,n),df(32970,t,n)),polygonOffset:(e,t,n)=>e.polygonOffset(df(32824,t,n),df(10752,t,n)),sampleCoverage:(e,t,n)=>e.sampleCoverage(df(32938,t,n),df(32939,t,n)),stencilFuncFront:(e,t,n)=>e.stencilFuncSeparate(1028,df(2962,t,n),df(2967,t,n),df(2963,t,n)),stencilFuncBack:(e,t,n)=>e.stencilFuncSeparate(1029,df(34816,t,n),df(36003,t,n),df(36004,t,n)),stencilOpFront:(e,t,n)=>e.stencilOpSeparate(1028,df(2964,t,n),df(2965,t,n),df(2966,t,n)),stencilOpBack:(e,t,n)=>e.stencilOpSeparate(1029,df(34817,t,n),df(34818,t,n),df(34819,t,n))},pf={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,n)=>e({[t]:n}),hint:(e,t,n)=>e({[t]:n}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,n)=>e({36007:n}),bindTransformFeedback:(e,t,n)=>e({36389:n}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,n)=>{switch(t){case 36160:return e({36006:n,36010:n});case 36009:return e({36006:n});case 36008:return e({36010:n});default:return null}},bindBuffer:(e,t,n)=>{const s={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return s?e({[s]:n}):{valueChanged:!0}},blendColor:(e,t,n,s,r)=>e({32773:new Float32Array([t,n,s,r])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,n)=>e({32777:t,34877:n}),blendFunc:(e,t,n)=>e({32969:t,32968:n,32971:t,32970:n}),blendFuncSeparate:(e,t,n,s,r)=>e({32969:t,32968:n,32971:s,32970:r}),clearColor:(e,t,n,s,r)=>e({3106:new Float32Array([t,n,s,r])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,n,s,r)=>e({3107:[t,n,s,r]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,n)=>e({2928:new Float32Array([t,n])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,n)=>e({32824:t,10752:n}),sampleCoverage:(e,t,n)=>e({32938:t,32939:n}),scissor:(e,t,n,s,r)=>e({3088:new Int32Array([t,n,s,r])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,n)=>e({[1028===t?2968:36005]:n}),stencilFunc:(e,t,n,s)=>e({2962:t,2967:n,2963:s,34816:t,36003:n,36004:s}),stencilFuncSeparate:(e,t,n,s,r)=>e({[1028===t?2962:34816]:n,[1028===t?2967:36003]:s,[1028===t?2963:36004]:r}),stencilOp:(e,t,n,s)=>e({2964:t,2965:n,2966:s,34817:t,34818:n,34819:s}),stencilOpSeparate:(e,t,n,s,r)=>e({[1028===t?2964:34817]:n,[1028===t?2965:34818]:s,[1028===t?2966:34819]:r}),viewport:(e,t,n,s,r)=>e({2978:[t,n,s,r]})},gf=(e,t)=>e.isEnabled(t),mf={3042:gf,2884:gf,2929:gf,3024:gf,32823:gf,32926:gf,32928:gf,3089:gf,2960:gf,35977:gf},_f=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function yf(e,t){if(function(e){for(const t in e)return!1;return!0}(t))return;const n={};for(const r in t){const s=Number(r),i=hf[r];i&&("string"==typeof i?n[i]=!0:i(e,t[r],s))}const s=e.state&&e.state.cache;if(s)for(const r in n)(0,ff[r])(e,t,s)}function bf(e,t=sf){if("number"==typeof t){const n=t,s=mf[n];return s?s(e,n):e.getParameter(n)}const n=Array.isArray(t)?t:Object.keys(t),s={};for(const r of n){const t=mf[r];s[r]=t?t(e,Number(r)):e.getParameter(Number(r))}return s}function vf(e,t){if(e===t)return!0;if(xf(e)&&xf(t)&&e.length===t.length){for(let n=0;n{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}static get(e){return e.state}push(e={}){this.stateStack.push({})}pop(){const e=this.stateStack[this.stateStack.length-1];yf(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=(null==t?void 0:t.copyState)?bf(e):Object.assign({},sf),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.state=this,function(e){const t=e.useProgram.bind(e);e.useProgram=function(n){const s=wf.get(e);s.program!==n&&(t(n),s.program=n)}}(e);for(const n in pf)Tf(e,n,pf[n]);Ef(e,"getParameter"),Ef(e,"isEnabled")}_updateCache(e){let t,n=!1;const s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const r in e){const i=e[r],o=this.cache[r];vf(i,o)||(n=!0,t=o,s&&!(r in s)&&(s[r]=o),this.cache[r]=i)}return{valueChanged:n,oldValue:t}}}function Ef(e,t){const n=e[t].bind(e);e[t]=function(t){if(void 0===t||_f.has(t))return n(t);const s=wf.get(e);return t in s.cache||(s.cache[t]=n(t)),s.enable?s.cache[t]:n(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function Tf(e,t,n){if(!e[t])return;const s=e[t].bind(e);e[t]=function(...t){const r=wf.get(e),{valueChanged:i,oldValue:o}=n(r._updateCache,...t);return i&&s(...t),o},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function Sf(e,t,n){return void 0===n[t]&&(n[t]=e.getExtension(t)||null),n[t]}function Af(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function Rf(e){switch(e){case"uint8":case"unorm8":return 5121;case"sint8":case"snorm8":return 5120;case"uint16":case"unorm16":return 5123;case"sint16":case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}const Cf="WEBGL_compressed_texture_s3tc",Pf="WEBGL_compressed_texture_s3tc_srgb",kf="EXT_texture_compression_rgtc",If="EXT_texture_compression_bptc",Mf="EXT_texture_norm16",Lf="EXT_render_snorm",Nf={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat-renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[Lf],"norm16-renderable-webgl":[Mf],"snorm16-renderable-webgl":[Mf,Lf],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Cf,Pf,kf,If],"texture-compression-bc5-webgl":[kf],"texture-compression-bc7-webgl":[If],"texture-compression-etc2":["WEBGL_compressed_texture_etc"],"texture-compression-astc":["WEBGL_compressed_texture_astc"],"texture-compression-etc1-webgl":["WEBGL_compressed_texture_etc1"],"texture-compression-pvrtc-webgl":["WEBGL_compressed_texture_pvrtc"],"texture-compression-atc-webgl":["WEBGL_compressed_texture_atc"]},Of={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0},r16unorm:{gl:33322,rb:!0},r16snorm:{gl:36760},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0},rg16unorm:{gl:33324},rg16snorm:{gl:36761},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326},rgb9e5ufloat:{gl:35901},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852},"rgb16snorm-webgl":{gl:36762},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842},rgba16unorm:{gl:32859,rb:!0},rgba16snorm:{gl:36763},"rgb32float-webgl":{gl:34837,x:"EXT_color_buffer_float",dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Cf},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Pf},"bc1-rgba-unorm":{gl:33777,x:Cf},"bc1-rgba-unorm-srgb":{gl:35916,x:Pf},"bc2-rgba-unorm":{gl:33778,x:Cf},"bc2-rgba-unorm-srgb":{gl:35918,x:Pf},"bc3-rgba-unorm":{gl:33779,x:Cf},"bc3-rgba-unorm-srgb":{gl:35919,x:Pf},"bc4-r-unorm":{gl:36283,x:kf},"bc4-r-snorm":{gl:36284,x:kf},"bc5-rg-unorm":{gl:36285,x:kf},"bc5-rg-snorm":{gl:36286,x:kf},"bc6h-rgb-ufloat":{gl:36495,x:If},"bc6h-rgb-float":{gl:36494,x:If},"bc7-rgba-unorm":{gl:36492,x:If},"bc7-rgba-unorm-srgb":{gl:36493,x:If},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37819},"astc-10x5-unorm-srgb":{gl:37851},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rbg2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function Ff(e){var t;const n=Of[e],s=function(e){const t=Of[e],n=null==t?void 0:t.gl;if(void 0===n)throw new Error(`Unsupported texture format ${e}`);return n}(e),r=er.getInfo(e);return r.compressed&&(n.dataFormat=s),{internalFormat:s,format:(null==n?void 0:n.dataFormat)||Df(r.channels,r.integer,r.normalized,s),type:r.dataType?Rf(r.dataType):(null==(t=null==n?void 0:n.types)?void 0:t[0])||5121,compressed:r.compressed||!1}}function Df(e,t,n,s){if(6408===s||6407===s)return s;switch(e){case"r":return t&&!n?36244:6403;case"rg":return t&&!n?33320:33319;case"rgb":return t&&!n?36248:6407;case"rgba":return t&&!n?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}const Bf={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class Uf extends sr{constructor(e,t,n){super([],n),s(this,"gl"),s(this,"extensions"),s(this,"testedFeatures",new Set),this.gl=e,this.extensions=t,Sf(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){const e=this.getFeatures();for(const t of e)this.has(t)&&(yield t);return[]}has(e){var t;return!(null==(t=this.disabledFeatures)?void 0:t[e])&&(this.testedFeatures.has(e)||(this.testedFeatures.add(e),function(e){return e in Nf}(e)&&function(e,t,n){return(Nf[t]||[]).every(t=>Sf(e,t,n))}(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){const e=this.getFeatures().filter(e=>"polygon-mode-webgl"!==e);for(const t of e)this.has(t)}getFeatures(){return[...Object.keys(Bf),...Object.keys(Nf)]}getWebGLFeature(e){const t=Bf[e];return"string"==typeof t?Boolean(Sf(this.gl,t,this.extensions)):Boolean(t)}}class jf extends nr{constructor(e){super(),s(this,"gl"),s(this,"limits",{}),this.gl=e}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(e){return void 0===this.limits[e]&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}class Gf extends kr{constructor(e,t){super(e,t),s(this,"device"),s(this,"gl"),s(this,"handle"),s(this,"colorAttachments",[]),s(this,"depthStencilAttachment",null);const n=null===t.handle;this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),n||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),this.destroyed||null===this.handle||this.gl.deleteFramebuffer(this.handle)}updateAttachments(){const e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const e=this.device.gl.getShaderInfoLog(this.handle);return e?function(e){const t=e.split(/\r?\n/),n=[];for(const s of t){if(s.length<=1)continue;const e=s.split(":");if(2===e.length){const[t,s]=e;n.push({message:s.trim(),type:$f(t),lineNum:0,linePos:0});continue}const[t,r,i,...o]=e;let a=parseInt(i,10);isNaN(a)&&(a=0);let l=parseInt(r,10);isNaN(l)&&(l=0),n.push({message:o.join(":").trim(),type:$f(t),lineNum:a,linePos:l})}return n}(e):[]}getTranslatedSource(){const e=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return(null==e?void 0:e.getTranslatedShaderSource(this.handle))||null}async _compile(e){e=e.startsWith("#version ")?e:`#version 300 es\n${e}`;const{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),this.device.props.debug){if(this.device.features.has("compilation-status-async-webgl"))Ss.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),Ss.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader();else if(this._getCompilationStatus(),this.debugShader(),"error"===this.compilationStatus)throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`)}else this.compilationStatus="pending"}async _waitForCompilationComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void(await e(10));const{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}function qf(e,t){return Qf(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Yf(e,t){return Qf(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function Kf(e,t){return Qf(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Zf(e,t,n="color"){return Qf(e,t,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:"color"===n?32769:32771,"one-minus-constant":"color"===n?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function Qf(e,t,n){if(!(t in n))throw new Error(function(e,t){return`Illegal parameter ${t} for ${e}`}(e,t));return n[t]}function Jf(e){const t={};return e.addressModeU&&(t[10242]=ep(e.addressModeU)),e.addressModeV&&(t[10243]=ep(e.addressModeV)),e.addressModeW&&(t[32882]=ep(e.addressModeW)),e.magFilter&&(t[10240]=tp(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=function(e,t="none"){if(!t)return tp(e);switch(t){case"none":return tp(e);case"nearest":switch(e){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(e){case"nearest":return 9986;case"linear":return 9987}}}(e.minFilter||"linear",e.mipmapFilter)),void 0!==e.lodMinClamp&&(t[33082]=e.lodMinClamp),void 0!==e.lodMaxClamp&&(t[33083]=e.lodMaxClamp),"comparison-sampler"===e.type&&(t[34892]=34894),e.compare&&(t[34893]=qf("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function ep(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function tp(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}class np extends yr{constructor(e,t){super(e,t),s(this,"device"),s(this,"handle"),s(this,"parameters"),this.device=e,this.parameters=Jf(t),this.handle=t.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(const[t,n]of Object.entries(e)){const e=Number(t);switch(e){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,e,n);break;default:this.device.gl.samplerParameteri(this.handle,e,n)}}}}function sp(e,t,n){if(function(e){for(const t in e)return!1;return!0}(t))return n(e);const{nocatch:s=!0}=t,r=wf.get(e);let i;if(r.push(),yf(e,t),s)i=n(e),r.pop();else try{i=n(e)}finally{r.pop()}return i}class rp extends Er{constructor(e,t){super(e,{...xr.defaultProps,...t}),s(this,"device"),s(this,"gl"),s(this,"handle"),s(this,"texture"),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}class ip extends xr{constructor(e,t){super(e,t),s(this,"device"),s(this,"gl"),s(this,"handle"),s(this,"sampler"),s(this,"view"),s(this,"glTarget"),s(this,"glFormat"),s(this,"glType"),s(this,"glInternalFormat"),s(this,"compressed"),s(this,"_textureUnit",0),this.device=e,this.gl=this.device.gl;const n=Ff(this.props.format);this.glTarget=function(e){switch(e){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866}throw new Error(e)}(this.props.dimension),this.glInternalFormat=n.internalFormat,this.glFormat=n.format,this.glType=n.type,this.compressed=n.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);const{dimension:r,width:i,height:o,depth:a,mipLevels:l,glTarget:c,glInternalFormat:u}=this;switch(r){case"2d":case"cube":this.gl.texStorage2D(c,l,u,i,o);break;case"2d-array":case"3d":this.gl.texStorage3D(c,l,u,i,o,a);break;default:throw new Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data),this.setSampler(this.props.sampler),this.view=new rp(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}createView(e){return new rp(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);const t=Jf(this.sampler.props);this._setSamplerParameters(t)}copyImageData(e){const t=this._normalizeCopyImageDataOptions(e),n=t.data,{width:s,height:r,depth:i}=this,{mipLevel:o=0,byteOffset:a=0,x:l=0,y:c=0,z:u=0}=t,{glFormat:h,glType:d,compressed:f}=this,p=op(this.glTarget,this.dimension,u);let g;if(!this.compressed){const{bytesPerPixel:e}=this.device.getTextureFormatInfo(this.format);if(e){if(t.bytesPerRow%e!==0)throw new Error(`bytesPerRow (${t.bytesPerRow}) must be a multiple of bytesPerPixel (${e}) for ${this.format}`);g=t.bytesPerRow/e}}const m=this.compressed?{}:{...void 0!==g?{3314:g}:{},32878:t.rowsPerImage};this.gl.bindTexture(p,this.handle),sp(this.gl,m,()=>{switch(this.dimension){case"2d":case"cube":f?this.gl.compressedTexSubImage2D(p,o,l,c,s,r,h,n,a):this.gl.texSubImage2D(p,o,l,c,s,r,h,d,n,a);break;case"2d-array":case"3d":f?this.gl.compressedTexSubImage3D(p,o,l,c,u,s,r,i,h,n,a):this.gl.texSubImage3D(p,o,l,c,u,s,r,i,h,d,n,a)}}),this.gl.bindTexture(p,null)}copyExternalImage(e){const t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");const{glFormat:n,glType:s}=this,{image:r,depth:i,mipLevel:o,x:a,y:l,z:c,width:u,height:h}=t,d=op(this.glTarget,this.dimension,i),f=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),sp(this.gl,f,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(d,o,a,l,u,h,n,s,r);break;case"2d-array":case"3d":this.gl.texSubImage3D(d,o,a,l,c,u,h,i,n,s,r)}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}generateMipmapsWebGL(e){if(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format)||(Ss.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),null==e?void 0:e.force))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(t){Ss.warn(`Error generating mipmap for ${this}: ${t.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){Ss.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(const[t,n]of Object.entries(e)){const e=Number(t),s=n;switch(e){case 33082:case 33083:this.gl.texParameterf(this.glTarget,e,s);break;case 10240:case 10241:case 10242:case 10243:case 32882:case 34892:case 34893:this.gl.texParameteri(this.glTarget,e,s);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,e,s)}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){const{gl:t}=this;return void 0!==e&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){const{gl:t}=this;return void 0!==e&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}}function op(e,t,n){return"cube"===t?34069+n:e}function ap(e){return up[e]}function lp(e){return Boolean(hp[e])}function cp(e){return hp[e]}const up={5126:"f32",35664:"vec2",35665:"vec3",35666:"vec4",5124:"i32",35667:"vec2",35668:"vec3",35669:"vec4",5125:"u32",36294:"vec2",36295:"vec3",36296:"vec4",35670:"f32",35671:"vec2",35672:"vec3",35673:"vec4",35674:"mat2x2",35685:"mat2x3",35686:"mat2x4",35687:"mat3x2",35675:"mat3x3",35688:"mat3x4",35689:"mat4x2",35690:"mat4x3",35676:"mat4x4"},hp={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},dp={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function fp(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(e);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${e}`);return{name:t[1],length:t[2]?1:0,isArray:Boolean(t[2])}}function pp(e,t,n,s){const r=e;let i=s;!0===i&&(i=1),!1===i&&(i=0);const o="number"==typeof i?[i]:i;switch(n){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if("number"!=typeof s)throw new Error("samplers must be set to integers");return e.uniform1i(t,s);case 5126:return e.uniform1fv(t,o);case 35664:return e.uniform2fv(t,o);case 35665:return e.uniform3fv(t,o);case 35666:return e.uniform4fv(t,o);case 5124:case 35670:return e.uniform1iv(t,o);case 35667:case 35671:return e.uniform2iv(t,o);case 35668:case 35672:return e.uniform3iv(t,o);case 35669:case 35673:return e.uniform4iv(t,o);case 5125:return r.uniform1uiv(t,o,1);case 36294:return r.uniform2uiv(t,o,2);case 36295:return r.uniform3uiv(t,o,3);case 36296:return r.uniform4uiv(t,o,4);case 35674:return e.uniformMatrix2fv(t,!1,o);case 35675:return e.uniformMatrix3fv(t,!1,o);case 35676:return e.uniformMatrix4fv(t,!1,o);case 35685:return r.uniformMatrix2x3fv(t,!1,o);case 35686:return r.uniformMatrix2x4fv(t,!1,o);case 35687:return r.uniformMatrix3x2fv(t,!1,o);case 35688:return r.uniformMatrix3x4fv(t,!1,o);case 35689:return r.uniformMatrix4x2fv(t,!1,o);case 35690:return r.uniformMatrix4x3fv(t,!1,o)}throw new Error("Illegal uniform")}class gp extends Mr{constructor(e,t){super(e,t),s(this,"device"),s(this,"handle"),s(this,"vs"),s(this,"fs"),s(this,"introspectedLayout"),s(this,"uniforms",{}),s(this,"bindings",{}),s(this,"varyings",null),s(this,"_uniformCount",0),s(this,"_uniformSetters",{}),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.vs=t.vs,this.fs=t.fs;const{varyings:n,bufferMode:r=35981}=t;n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,r)),this._linkShaders(),Ss.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=function(e,t){const n={attributes:[],bindings:[]};n.attributes=function(e,t){const n=[],s=e.getProgramParameter(t,35721);for(let r=0;r=0){const e=ap(o),t=/instance/i.test(i)?"instance":"vertex";n.push({name:i,location:a,stepMode:t,type:e})}}return n.sort((e,t)=>e.location-t.location),n}(e,t);const s=function(e,t){const n=(n,s)=>e.getActiveUniformBlockParameter(t,n,s),s=[],r=e.getProgramParameter(t,35382);for(let i=0;ie.location-t.location),s}(e,t);for(const a of s){const e=a.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));n.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:e})}const r=function(e,t){const n=[],s=e.getProgramParameter(t,35718);for(let r=0;r1)for(let r=0;re.location-t.location),n}(e,t);return(null==o?void 0:o.length)&&(n.varyings=o),n}(this.device.gl,this.handle),Ss.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=t.shaderLayout?function(e,t){const n={...e,attributes:e.attributes.map(e=>({...e}))};for(const s of(null==t?void 0:t.attributes)||[]){const e=n.attributes.find(e=>e.name===s.name);e?(e.type=s.type||e.type,e.stepMode=s.stepMode||e.stepMode):Ss.warn(`shader layout attribute ${s.name} not present in shader`)}return n}(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}destroy(){this.handle&&(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.destroyed=!0,this.handle.destroyed=!0,this.handle=null)}setBindings(e,t){for(const[n,s]of Object.entries(e)){const e=this.shaderLayout.bindings.find(e=>e.name===n)||this.shaderLayout.bindings.find(e=>e.name===`${n}Uniforms`);if(!e){const e=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(", ");(null==t?void 0:t.disableWarnings)||Ss.warn(`No binding "${n}" in render pipeline "${this.id}", expected one of ${e}`,s)();continue}switch(s||Ss.warn(`Unsetting binding "${n}" in render pipeline "${this.id}"`)(),e.type){case"uniform":if(!(s instanceof Hf||s.buffer instanceof Hf))throw new Error("buffer value");break;case"texture":if(!(s instanceof rp||s instanceof ip||s instanceof Gf))throw new Error(`${this} Bad texture binding for ${n}`);break;case"sampler":Ss.warn(`Ignoring sampler ${n}`)();break;default:throw new Error(e.type)}this.bindings[n]=s}}draw(e){var t;const{renderPass:n,parameters:s=this.props.parameters,topology:r=this.props.topology,vertexArray:i,vertexCount:o,instanceCount:a,isInstanced:l=!1,firstVertex:c=0,transformFeedback:u}=e,h=function(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(e)}}(r),d=Boolean(i.indexBuffer),f=null==(t=i.indexBuffer)?void 0:t.glIndexType;if("success"!==this.linkStatus)return Ss.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return Ss.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),i.bindBeforeRender(n),u&&u.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const p=n;return function(e,t,n,s){if(function(e){let t=!0;for(const n in e){t=!1;break}return t}(t))return s(e);const r=e;r.pushState();try{return function(e,t){const n=e,{gl:s}=n;if(t.cullMode)switch(t.cullMode){case"none":s.disable(2884);break;case"front":s.enable(2884),s.cullFace(1028);break;case"back":s.enable(2884),s.cullFace(1029)}if(t.frontFace&&s.frontFace(Qf("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&s.enable(34383),void 0!==t.depthBias&&(s.enable(32823),s.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has("provoking-vertex-webgl")){const e=n.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,s=Qf("provokingVertex",t.provokingVertex,{first:36429,last:36430});null==e||e.provokingVertexWEBGL(s)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){const e=n.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,s=Qf("polygonMode",t.polygonMode,{fill:6914,line:6913});null==e||e.polygonModeWEBGL(1028,s),null==e||e.polygonModeWEBGL(1029,s)}t.polygonOffsetLine&&s.enable(10754)}if(e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&s.enable(12288),t.clipDistance1&&s.enable(12289),t.clipDistance2&&s.enable(12290),t.clipDistance3&&s.enable(12291),t.clipDistance4&&s.enable(12292),t.clipDistance5&&s.enable(12293),t.clipDistance6&&s.enable(12294),t.clipDistance7&&s.enable(12295)),void 0!==t.depthWriteEnabled&&s.depthMask(t.depthWriteEnabled),t.depthCompare&&("always"!==t.depthCompare?s.enable(2929):s.disable(2929),s.depthFunc(qf("depthCompare",t.depthCompare))),t.stencilWriteMask){const e=t.stencilWriteMask;s.stencilMaskSeparate(1028,e),s.stencilMaskSeparate(1029,e)}if(t.stencilReadMask&&Ss.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){const e=t.stencilReadMask||4294967295,n=qf("depthCompare",t.stencilCompare);"always"!==t.stencilCompare?s.enable(2960):s.disable(2960),s.stencilFuncSeparate(1028,n,0,e),s.stencilFuncSeparate(1029,n,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){const e=Yf("stencilPassOperation",t.stencilPassOperation),n=Yf("stencilFailOperation",t.stencilFailOperation),r=Yf("stencilDepthFailOperation",t.stencilDepthFailOperation);s.stencilOpSeparate(1028,n,r,e),s.stencilOpSeparate(1029,n,r,e)}switch(t.blend){case!0:s.enable(3042);break;case!1:s.disable(3042)}if(t.blendColorOperation||t.blendAlphaOperation){const e=Kf("blendColorOperation",t.blendColorOperation||"add"),n=Kf("blendAlphaOperation",t.blendAlphaOperation||"add");s.blendEquationSeparate(e,n);const r=Zf("blendColorSrcFactor",t.blendColorSrcFactor||"one"),i=Zf("blendColorDstFactor",t.blendColorDstFactor||"zero"),o=Zf("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),a=Zf("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");s.blendFuncSeparate(r,i,o,a)}}(e,t),yf(r.gl,n),s(e)}finally{r.popState()}}(this.device,s,p.glParameters,()=>{d&&l?this.device.gl.drawElementsInstanced(h,o||0,f,c,a||0):d?this.device.gl.drawElements(h,o||0,f,c):l?this.device.gl.drawArraysInstanced(h,c,o||0,a||0):this.device.gl.drawArrays(h,c,o||0),u&&u.end()}),i.unbindAfterRender(n),!0}async _linkShaders(){const{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),Ss.time(4,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),Ss.timeEnd(4,`linkProgram for ${this.id}`)(),Ss.level,!this.device.features.has("compilation-status-async-webgl")){const e=this._getLinkStatus();return void this._reportLinkStatus(e)}Ss.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),Ss.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){var t;if("success"!==e){const n="link-error"===e?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${n} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader()}switch(null==(t=this.fs)?void 0:t.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${n} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader()}const s=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${n} during ${e}: ${s}`),this)(),this.device.debug()}}_getLinkStatus(){const{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}async _waitForLinkComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void(await e(10));const{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(const t of this.shaderLayout.bindings)this.bindings[t.name]||this.bindings[t.name.replace(/Uniforms$/,"")]||(Ss.warn(`Binding ${t.name} not found in ${this.id}`)(),e=!1);return e}_applyBindings(){if("success"!==this.linkStatus)return;const{gl:e}=this.device;e.useProgram(this.handle);let t=0,n=0;for(const s of this.shaderLayout.bindings){const r=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!r)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":const{name:i}=s,o=e.getUniformBlockIndex(this.handle,i);if(4294967295===o)throw new Error(`Invalid uniform block name ${i}`);e.uniformBlockBinding(this.handle,n,o),r instanceof Hf?e.bindBufferBase(35345,n,r.handle):e.bindBufferRange(35345,n,r.buffer.handle,r.offset||0,r.size||r.buffer.byteLength-r.offset),n+=1;break;case"texture":if(!(r instanceof rp||r instanceof ip||r instanceof Gf))throw new Error("texture");let a;if(r instanceof rp)a=r.texture;else if(r instanceof ip)a=r;else{if(!(r instanceof Gf&&r.colorAttachments[0]instanceof rp))throw new Error("No texture");Ss.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),a=r.colorAttachments[0].texture}e.activeTexture(33984+t),e.bindTexture(a.glTarget,a.handle),t+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(const e of this.shaderLayout.uniforms||[]){const{name:t,location:n,type:s,textureUnit:r}=e,i=this.uniforms[t]??r;void 0!==i&&pp(this.device.gl,n,s,i)}}}class mp extends jr{constructor(e){super(e,{}),s(this,"device"),s(this,"handle",null),s(this,"commands",[]),this.device=e}_executeCommands(e=this.commands){for(const t of e)switch(t.name){case"copy-buffer-to-buffer":_p(this.device,t.options);break;case"copy-buffer-to-texture":yp(this.device,t.options);break;case"copy-texture-to-buffer":bp(this.device,t.options);break;case"copy-texture-to-texture":vp(this.device,t.options);break;default:throw new Error(t.name)}}}function _p(e,t){const n=t.sourceBuffer,s=t.destinationBuffer;e.gl.bindBuffer(36662,n.handle),e.gl.bindBuffer(36663,s.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function yp(e,t){throw new Error("Not implemented")}function bp(e,t){const{sourceTexture:n,mipLevel:s=0,aspect:r="all",width:i=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:a=0,origin:l=[0,0],destinationBuffer:c,byteOffset:u=0,bytesPerRow:h,rowsPerImage:d}=t;if("all"!==r)throw new Error("aspect not supported in WebGL");if(0!==s||0!==a||h||d)throw new Error("not implemented");const{framebuffer:f,destroyFramebuffer:p}=xp(n);let g;try{const t=c,n=i||f.width,s=o||f.height,r=Ff(f.colorAttachments[0].texture.props.format),a=r.format,h=r.type;e.gl.bindBuffer(35051,t.handle),g=e.gl.bindFramebuffer(36160,f.handle),e.gl.readPixels(l[0],l[1],n,s,a,h,u)}finally{e.gl.bindBuffer(35051,null),void 0!==g&&e.gl.bindFramebuffer(36160,g),p&&f.destroy()}}function vp(e,t){const{sourceTexture:n,destinationMipLevel:s=0,origin:r=[0,0],destinationOrigin:i=[0,0],destinationTexture:o}=t;let{width:a=t.destinationTexture.width,height:l=t.destinationTexture.height}=t;const{framebuffer:c,destroyFramebuffer:u}=xp(n),[h,d]=r,[f,p,g]=i,m=e.gl.bindFramebuffer(36160,c.handle);let _,y;if(!(o instanceof ip))throw new Error("invalid destination");switch(_=o,a=Number.isFinite(a)?a:_.width,l=Number.isFinite(l)?l:_.height,_._bind(0),y=_.glTarget,y){case 3553:case 34067:e.gl.copyTexSubImage2D(y,s,f,p,h,d,a,l);break;case 35866:case 32879:e.gl.copyTexSubImage3D(y,s,f,p,g,h,d,a,l)}_&&_._unbind(),e.gl.bindFramebuffer(36160,m),u&&c.destroy()}function xp(e){if(e instanceof xr){const{width:t,height:n,id:s}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${s}`,width:t,height:n,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}const wp=[1,2,4,8];class Ep extends Nr{constructor(e,t){var n;let r;if(super(e,t),s(this,"device"),s(this,"handle",null),s(this,"glParameters",{}),this.device=e,!(null==(n=null==t?void 0:t.parameters)?void 0:n.viewport))if(null==t?void 0:t.framebuffer){const{width:e,height:n}=t.framebuffer;r=[0,0,e,n]}else{const[t,n]=e.getDefaultCanvasContext().getDrawingBufferSize();r=[0,0,t,n]}this.device.pushState(),this.setParameters({viewport:r,...this.props.parameters});const i=this.props.framebuffer;if(this.props.framebuffer&&(null==i?void 0:i.handle)){const e=this.props.framebuffer.colorAttachments.map((e,t)=>36064+t);this.device.gl.drawBuffers(e)}else this.device.gl.drawBuffers([1029]);this.clear()}end(){this.device.popState()}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){const t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference&&(t[2967]=e.stencilReference),"colorMask"in e&&(t.colorMask=wp.map(t=>Boolean(t&e.colorMask))),this.glParameters=t,yf(this.device.gl,t)}beginOcclusionQuery(e){const t=this.props.occlusionQuerySet;null==t||t.beginOcclusionQuery()}endOcclusionQuery(){const e=this.props.occlusionQuerySet;null==e||e.endOcclusionQuery()}clear(){const e={...this.glParameters};let t=0;this.props.clearColors&&this.props.clearColors.forEach((e,t)=>{e&&this.clearColorBuffer(t,e)}),!1!==this.props.clearColor&&void 0===this.props.clearColors&&(t|=16384,e.clearColor=this.props.clearColor),!1!==this.props.clearDepth&&(t|=256,e.clearDepth=this.props.clearDepth),!1!==this.props.clearStencil&&(t|=1024,e.clearStencil=this.props.clearStencil),0!==t&&sp(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){sp(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}class Tp extends Br{constructor(e,t){super(e,t),s(this,"device"),s(this,"handle",null),s(this,"commandBuffer"),this.device=e,this.commandBuffer=new mp(e)}destroy(){}finish(){return this.commandBuffer}beginRenderPass(e){return new Ep(this.device,e)}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,n){}}class Sp extends qr{constructor(e,t){super(e,t),s(this,"device"),s(this,"handle"),s(this,"buffer",null),s(this,"bufferValue",null),this.device=e,this.handle=this.device.gl.createVertexArray()}get[Symbol.toStringTag](){return"VertexArray"}static isConstantAttributeZeroSupported(e){return"Chrome"==(Ne()?Le()?"Electron":(Me.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node")}destroy(){var e;super.destroy(),this.buffer&&(null==(e=this.buffer)||e.destroy()),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){const t=e;if(t&&34963!==t.glTarget)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){const n=t;if(34963===n.glTarget)throw new Error("Use .setIndexBuffer()");const{size:s,type:r,stride:i,offset:o,normalized:a,integer:l,divisor:c}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),l?this.device.gl.vertexAttribIPointer(e,s,r,i,o):this.device.gl.vertexAttribPointer(e,s,r,a,i,o),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,c||0),this.attributes[e]=n,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{for(const t in e)this.setBuffer(t,e[t])})}setBuffer(e,t){const n=this._getVaryingIndex(e),{buffer:s,byteLength:r,byteOffset:i}=this._getBufferRange(t);if(n<0)return this.unusedBuffers[e]=s,void Ss.warn(`${this.id} unusedBuffers varying buffer ${e}`)();this.buffers[n]={buffer:s,byteLength:r,byteOffset:i},this.bindOnUse||this._bindBuffer(n,s,i,r)}getBuffer(e){if(Rp(e))return this.buffers[e]||null;const t=this._getVaryingIndex(e);return t>=0?this.buffers[t]:null}bind(e=this.handle){if("function"!=typeof e)return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof Hf)return{buffer:e,byteOffset:0,byteLength:e.byteLength};const{buffer:t,byteOffset:n=0,byteLength:s=e.buffer.byteLength}=e;return{buffer:t,byteOffset:n,byteLength:s}}_getVaryingIndex(e){if(Rp(e))return Number(e);for(const t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(const e in this.buffers){const{buffer:t,byteLength:n,byteOffset:s}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,s,n)}}_unbindBuffers(){for(const e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,n=0,s){const r=t&&t.handle;r&&void 0!==s?this.gl.bindBufferRange(35982,e,r,n,s):this.gl.bindBufferBase(35982,e,r)}}function Rp(e){return"number"==typeof e?Number.isInteger(e):/^\d+$/.test(e)}class Cp extends Jr{constructor(e,t){if(super(e,t),s(this,"device"),s(this,"handle"),s(this,"target",null),s(this,"_queryPending",!1),s(this,"_pollingPromise",null),this.device=e,t.count>1)throw new Error("WebGL QuerySet can only have one value");const n=this.device.gl.createQuery();if(!n)throw new Error("WebGL query not supported");this.handle=n,Object.seal(this)}get[Symbol.toStringTag](){return"Query"}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin((null==e?void 0:e.conservative)?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let t=0;return this._pollingPromise=new Promise((n,s)=>{const r=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):t++>e?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(r)};requestAnimationFrame(r)}),this._pollingPromise}}function Pp(e){switch(e){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}const kp={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"};function Ip(e){return e instanceof kr?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:Mp(e),deleteFramebuffer:!0}}function Mp(e,t){const{device:n,width:s,height:r,id:i}=e;return n.createFramebuffer({...t,id:`framebuffer-for-${i}`,width:s,height:r,colorAttachments:[e]})}class Lp extends ir{constructor(e){var t,n;super({...e,id:e.id||Wf("webgl-device")}),s(this,"type","webgl"),s(this,"handle"),s(this,"features"),s(this,"limits"),s(this,"info"),s(this,"canvasContext"),s(this,"preferredColorFormat","rgba8unorm"),s(this,"preferredDepthFormat","depth24plus"),s(this,"commandEncoder"),s(this,"lost"),s(this,"_resolveContextLost"),s(this,"gl"),s(this,"_constants"),s(this,"_extensions",{}),s(this,"_polyfilled",!1),s(this,"spectorJS");const r=ir._getCanvasContextProps(e);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=null==(n=null==(t=r.canvas)?void 0:t.gl)?void 0:n.device;if(i)throw new Error(`WebGL context already attached to device ${i.id}`);this.canvasContext=new Vf(this,r),this.lost=new Promise(e=>{this._resolveContextLost=e});const o={...e.webgl};"premultiplied"===r.alphaMode&&(o.premultipliedAlpha=!0),void 0!==e.powerPreference&&(o.powerPreference=e.powerPreference);const a=this.props._handle||function(e,t,n){let s="";const r={preserveDrawingBuffer:!0,...n};let i=null;if(i||(i=e.getContext("webgl2",r)),r.failIfMajorPerformanceCaveat&&(s||(s="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.")),i||n.failIfMajorPerformanceCaveat||(r.failIfMajorPerformanceCaveat=!1,i=e.getContext("webgl2",r),i.luma||(i.luma={}),i.luma.softwareRenderer=!0),i||(i=e.getContext("webgl",{}),i&&(i=null,s||(s="Your browser only supports WebGL1"))),!i)throw s||(s="Your browser does not support WebGL"),new Error(`Failed to create WebGL context: ${s}`);const{onContextLost:o,onContextRestored:a}=t;return e.addEventListener("webglcontextlost",e=>o(e),!1),e.addEventListener("webglcontextrestored",e=>a(e),!1),i.luma||(i.luma={}),i}(this.canvasContext.canvas,{onContextLost:e=>{var t;return null==(t=this._resolveContextLost)?void 0:t.call(this,{reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})},onContextRestored:e=>{}},o);if(!a)throw new Error("WebGL context creation failed");if(i=a.device,i){if(e._reuseDevices)return Ss.log(1,`Not creating a new Device, instead returning a reference to Device ${i.id} already attached to WebGL context`,i)(),i._reused=!0,i;throw new Error(`WebGL context already attached to device ${i.id}`)}this.handle=a,this.gl=a,this.spectorJS=function(e){var t;if(!(e={...Kd,...e}).debugSpectorJS)return null;if(!qd&&globalThis.SPECTOR&&!(null==(t=globalThis.luma)?void 0:t.spector)){Ss.probe(1,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:e}=globalThis.SPECTOR;qd=new e,globalThis.luma&&(globalThis.luma.spector=qd)}if(!qd)return null;if(Yd||(Yd=!0,qd.spyCanvases(),null==qd||qd.onCaptureStarted.add(e=>Ss.info("Spector capture started:",e)()),null==qd||qd.onCapture.add(e=>{Ss.info("Spector capture complete:",e)(),null==qd||qd.getResultUI(),null==qd||qd.resultView.display(),null==qd||qd.resultView.addCapture(e)})),e.gl){const t=e.gl,n=t.device;null==qd||qd.startCapture(e.gl,500),t.device=n,new Promise(e=>setTimeout(e,2e3)).then(e=>{Ss.info("Spector capture stopped after 2 seconds")(),null==qd||qd.stopCapture()})}return qd}({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=function(e,t){const n=e.getParameter(7936),s=e.getParameter(7937);Sf(e,"WEBGL_debug_renderer_info",t);const r=t.WEBGL_debug_renderer_info,i=e.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936)||n,o=e.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937)||s,a=e.getParameter(7938),l=Af(i,o),c=function(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?"metal":/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?"opengl":"unknown"}(i,o),u=function(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(Af(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}(i,o);return{type:"webgl",gpu:l,gpuType:u,gpuBackend:c,vendor:i,renderer:o,version:a,shadingLanguage:"glsl",shadingLanguageVersion:300}}(this.gl,this._extensions),this.limits=new jf(this.gl),this.features=new Uf(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new wf(this.gl,{log:(...e)=>Ss.log(1,...e)()}).trackState(this.gl,{copyState:!1});const l=e.debugWebGL||e.debug,c=e.debugWebGL;l&&(this.gl=Qd(this.gl,{debugWebGL:l,traceWebGL:c}),Ss.warn("WebGL debug mode activated. Performance reduced.")(),e.debugWebGL&&(Ss.level=Math.max(Ss.level,1))),this.commandEncoder=new Tp(this,{id:`${this}-command-encoder`})}get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){return"unorm8x4-bgra"!==e}destroy(){this.props._reuseDevices||this._reused||delete this.gl.device}get isLost(){return this.gl.isContextLost()}getTextureByteAlignment(){return 4}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){const t=this._normalizeBufferProps(e);return new Hf(this,t)}createTexture(e){return new ip(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new np(this,e)}createShader(e){return new Xf(this,e)}createFramebuffer(e){return new Gf(this,e)}createVertexArray(e){return new Sp(this,e)}createTransformFeedback(e){return new Ap(this,e)}createQuerySet(e){return new Cp(this,e)}createRenderPipeline(e){return new gp(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new Tp(this,e)}submit(e){e||(e=this.commandEncoder.finish(),this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:`${this.id}-default-encoder`})),e._executeCommands()}readPixelsToArrayWebGL(e,t){return function(e,t){var n;const{sourceX:s=0,sourceY:r=0,sourceAttachment:i=0}=t||{};let{target:o=null,sourceWidth:a,sourceHeight:l,sourceDepth:c,sourceFormat:u,sourceType:h}=t||{};const{framebuffer:d,deleteFramebuffer:f}=Ip(e),{gl:p,handle:g}=d;a||(a=d.width),l||(l=d.height);const m=null==(n=d.colorAttachments[i])?void 0:n.texture;if(!m)throw new Error(`Invalid framebuffer attachment ${i}`);c=(null==m?void 0:m.depth)||1,u||(u=(null==m?void 0:m.glFormat)||6408),h||(h=(null==m?void 0:m.glType)||5121),_=o,y=h,b=u,v=a,x=l,o=_||(y||(y=5121),new(Ns(kp[y]))(v*x*Pp(b)));var _,y,b,v,x;const w=Ls(o);h=h||dp[w];const E=p.bindFramebuffer(36160,g);return p.readBuffer(36064+i),p.readPixels(s,r,a,l,u,h,o),p.readBuffer(36064),p.bindFramebuffer(36160,E||null),f&&d.destroy(),o}(e,t)}readPixelsToBufferWebGL(e,t){return function(e,t){const{target:n,sourceX:s=0,sourceY:r=0,sourceFormat:i=6408,targetByteOffset:o=0}=t||{};let{sourceWidth:a,sourceHeight:l,sourceType:c}=t||{};const{framebuffer:u,deleteFramebuffer:h}=Ip(e);a=a||u.width,l=l||u.height;const d=u;c=c||5121;let f=n;if(!f){const e=o+a*l*Pp(i)*function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}(c);f=d.device.createBuffer({byteLength:e})}const p=e.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:e,width:a,height:l,origin:[s,r],destinationBuffer:f,byteOffset:o}),p.destroy(),h&&u.destroy(),f}(e,t)}setParametersWebGL(e){yf(this.gl,e)}getParametersWebGL(e){return bf(this.gl,e)}withParametersWebGL(e,t){return sp(this.gl,e,t)}resetWebGL(){Ss.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),yf(this.gl,sf)}_getDeviceSpecificTextureFormatCapabilities(e){return function(e,t,n){let s=t.create;const r=Of[t.format];return void 0===(null==r?void 0:r.gl)&&(s=!1),(null==r?void 0:r.x)&&(s=s&&Boolean(Sf(e,r.x,n))),{format:t.format,create:s&&t.create,render:s&&t.render,filter:s&&t.filter,blend:s&&t.blend,store:s&&t.store}}(this.gl,e,this._extensions)}loseDevice(){var e;let t=!1;const n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(t=!0,n.loseContext()),null==(e=this._resolveContextLost)||e.call(this,{reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){wf.get(this.gl).push()}popState(){wf.get(this.gl).pop()}getGLKey(e,t){const n=Number(e);for(const s in this.gl)if(this.gl[s]===n)return`GL.${s}`;return(null==t?void 0:t.emptyIfUnknown)?"":String(e)}getGLKeys(e){const t={emptyIfUnknown:!0};return Object.entries(e).reduce((e,[n,s])=>(e[`${n}:${this.getGLKey(n,t)}`]=`${s}:${this.getGLKey(s,t)}`,e),{})}setConstantAttributeWebGL(e,t){const n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);const s=this._constants[e];switch(s&&function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;nFn.error(e.message,e.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:({isDragging:e})=>e?"grabbing":"grab",getTooltip:null,debug:!1,drawPickingColors:!1};class Dp{constructor(e){var t;this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Et({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this._lastPointerDownInfo=null,this._onPointerMove=e=>{const{_pickRequest:t}=this;if("pointerleave"===e.type)t.x=-1,t.y=-1,t.radius=0;else{if(e.leftButton||e.rightButton)return;{const n=e.offsetCenter;if(!n)return;t.x=n.x,t.y=n.y,t.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:t.x,y:t.y}),t.event=e},this._onEvent=e=>{const t=wc[e.type],n=e.offsetCenter;if(!t||!n||!this.layerManager)return;const s=this.layerManager.getLayers(),r=this.deckPicker.getLastPickedObject({x:n.x,y:n.y,layers:s,viewports:this.getViewports(n)},this._lastPointerDownInfo),{layer:i}=r,o=i&&(i[t]||i.props[t]),a=this.props[t];let l=!1;o&&(l=o.call(i,r,e)),l||(null==a||a(r,e),this.widgetManager.onEvent(r,e))},this._onPointerDown=e=>{var t;if("webgpu"===(null==(t=this.device)?void 0:t.type))return;const n=e.offsetCenter,s=this._pick("pickObject","pickObject Time",{x:n.x,y:n.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=s.result[0]||s.emptyInfo},this.props={...Fp,...e},(e=this.props).viewState&&e.initialViewState&&Fn.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device);let n=this.device;if(!n&&e.gl){e.gl instanceof WebGLRenderingContext&&Fn.error("WebGL1 context not supported.")();const s=null==(t=this.props.deviceProps)?void 0:t.onResize;n=nf.attach(e.gl,{...this.props.deviceProps,onResize:(e,t)=>{const{width:n,height:r}=e.canvas;e.drawingBufferWidth=n,e.drawingBufferHeight=r,this._needsRedraw="Canvas resized",null==s||s(e,t)}})}n||(n=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(n,e),this.setProps(e),e._typedArrayManagerProps&&ju.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){var e,t,n,s,r,i,o,a,l,c;null==(e=this.animationLoop)||e.stop(),null==(t=this.animationLoop)||t.destroy(),this.animationLoop=null,this._lastPointerDownInfo=null,null==(n=this.layerManager)||n.finalize(),this.layerManager=null,null==(s=this.viewManager)||s.finalize(),this.viewManager=null,null==(r=this.effectManager)||r.finalize(),this.effectManager=null,null==(i=this.deckRenderer)||i.finalize(),this.deckRenderer=null,null==(o=this.deckPicker)||o.finalize(),this.deckPicker=null,null==(a=this.eventManager)||a.destroy(),this.eventManager=null,null==(l=this.widgetManager)||l.finalize(),this.widgetManager=null,this.props.canvas||this.props.device||this.props.gl||!this.canvas||(null==(c=this.canvas.parentElement)||c.removeChild(this.canvas),this.canvas=null)}setProps(e){var t,n,s,r,i,o,a;this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&Fn.removed("onLayerHover","onHover")(),"onLayerClick"in e&&Fn.removed("onLayerClick","onClick")(),e.initialViewState&&!Xh(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);const l=Object.create(this.props);Object.assign(l,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),e.device&&e.device.id!==(null==(t=this.device)?void 0:t.id)&&(null==(n=this.animationLoop)||n.stop(),this.canvas!==(null==(s=e.device.canvasContext)?void 0:s.canvas)&&(null==(r=this.canvas)||r.remove(),null==(i=this.eventManager)||i.destroy(),this.canvas=null),Fn.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),null==(o=this.animationLoop)||o.setProps(l),void 0!==e.useDevicePixels&&(null==(a=this.device)?void 0:a.canvasContext)&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(l),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(l),this.effectManager.setProps(l),this.deckRenderer.setProps(l),this.deckPicker.setProps(l),this.widgetManager.setProps(l)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);const n=this.viewManager.needsRedraw(e),s=this.layerManager.needsRedraw(e),r=this.effectManager.needsRedraw(e),i=this.deckRenderer.needsRedraw(e);return t=t||n||s||r||i,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return null!==this.viewManager}getViews(){return sd(this.viewManager),this.viewManager.views}getViewports(e){return sd(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){const t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_addResources(e,t=!1){for(const n in e)this.layerManager.resourceManager.add({resourceId:n,data:e[n],forceUpdate:t})}_removeResources(e){for(const t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){var t;null==(t=this.layerManager)||t.removeDefaultShaderModule(e)}_pick(e,t,n){sd(this.deckPicker);const{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(t).timeStart();const r=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return s.get(t).timeEnd(),r}_createCanvas(e){let t=e.canvas;return"string"==typeof t&&(t=document.getElementById(t),sd(t)),t||(t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay",e.width&&"number"==typeof e.width&&(t.width=e.width),e.height&&"number"==typeof e.height&&(t.height=e.height),(e.parent||document.body).appendChild(t)),Object.assign(t.style,e.style),t}_setCanvasSize(e){var t;if(!this.canvas)return;const{width:n,height:s}=e;if(n||0===n){const e=Number.isFinite(n)?`${n}px`:n;this.canvas.style.width=e}if(s||0===s){const n=Number.isFinite(s)?`${s}px`:s;this.canvas.style.position=(null==(t=e.style)?void 0:t.position)||"absolute",this.canvas.style.height=n}}_updateCanvasSize(){var e,t;const{canvas:n}=this;if(!n)return;const s=n.clientWidth??n.width,r=n.clientHeight??n.height;s===this.width&&r===this.height||(this.width=s,this.height=r,null==(e=this.viewManager)||e.setProps({width:s,height:r}),null==(t=this.layerManager)||t.activateViewport(this.getViewports()[0]),this.props.onResize({width:s,height:r}))}_createAnimationLoop(e,t){const{gl:n,onError:s}=t;return new ah({device:e,autoResizeDrawingBuffer:!n,autoResizeViewport:!1,onInitialize:e=>this._setDevice(e.device),onRender:this._onRenderFrame.bind(this),onError:s})}_createDevice(e){var t,n,s;const r=null==(t=this.props.deviceProps)?void 0:t.createCanvasContext,i="object"==typeof r?r:void 0,o={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};o.adapters.includes(nf)||o.adapters.push(nf);const a={alphaMode:"webgpu"===(null==(n=this.props.deviceProps)?void 0:n.type)?"premultiplied":void 0},l=null==(s=this.props.deviceProps)?void 0:s.onResize;return lr.createDevice({_reuseDevices:!0,type:"webgl",...o,createCanvasContext:{...a,...i,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(e,t)=>{this._needsRedraw="Canvas resized",null==l||l(e,t)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){const{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new xd({id:"default-view"})];return t.length&&this.props.controller&&(t[0].props.controller=this.props.controller),t}_onContextLost(){const{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){var e,t,n,s;if("webgpu"===(null==(e=this.device)?void 0:e.type))return;const{_pickRequest:r}=this;if(r.event){const{result:e,emptyInfo:i}=this._pick("pickObject","pickObject Time",r);this.cursorState.isHovering=e.length>0;let o=i,a=!1;for(const n of e)o=n,a=(null==(t=n.layer)?void 0:t.onHover(n,r.event))||a;a||(null==(s=(n=this.props).onHover)||s.call(n,o,r.event),this.widgetManager.onHover(o,r.event)),r.event=null}}_updateCursor(){const e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){var t,n;if(this.device=e,!this.animationLoop)return;this.canvas||(this.canvas=null==(t=this.device.canvasContext)?void 0:t.canvas,!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild)),"webgl"===this.device.type&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),"webgl"===this.device.type&&this.props.onWebGLInitialized(this.device.gl);const s=new rh;s.play(),this.animationLoop.attachTimeline(s),this.eventManager=new yc(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizers:Object.keys(Ec).map(e=>{var t;const[n,s,r,i]=Ec[e];return{recognizer:new n({...s,...null==(t=this.props.eventRecognizerOptions)?void 0:t[e],event:e}),recognizeWith:r,requestFailure:i}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(const i in wc)this.eventManager.on(i,this._onEvent);this.viewManager=new qh({timeline:s,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});const r=this.viewManager.getViewports()[0];this.layerManager=new $h(this.device,{deck:this,stats:this.stats,viewport:r,timeline:s}),this.effectManager=new Ed({deck:this,device:this.device}),this.deckRenderer=new Sd(this.device),this.deckPicker=new Md(this.device),this.widgetManager=new Fd({deck:this,parentElement:null==(n=this.canvas)?void 0:n.parentElement}),this.widgetManager.addDefault(new jd),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,t){var n;const{device:s,gl:r}=this.layerManager.context;this.props.onBeforeRender({device:s,gl:r});const i={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};null==(n=this.deckRenderer)||n.renderLayers(i),"screen"===i.pass&&this.widgetManager.onRedraw({viewports:i.viewports,layers:i.layers}),this.props.onAfterRender({device:s,gl:r})}_onRenderFrame(){var e;this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),Fn.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),"webgpu"!==(null==(e=this.device)?void 0:e.type)&&this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){const t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){const{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();const t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){const{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();const n=lr.stats.get("Memory Usage");e.bufferMemory=n.get("Buffer Memory").count,e.textureMemory=n.get("Texture Memory").count,e.renderbufferMemory=n.get("Renderbuffer Memory").count,e.gpuMemory=n.get("GPU Memory").count}}Dp.defaultProps=Fp,Dp.VERSION=Gn;const Bp=Ls;function Up(e,t,n){const s="webgpu"===n&&"uint8"===t.type?"unorm8":t.type;return{attribute:e,format:t.size>1?`${s}x${t.size}`:t.type,byteOffset:t.offset||0}}function jp(e){return e.stride||e.size*e.bytesPerElement}function Gp(e,t){t.offset&&Fn.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const n=jp(e),s=(void 0!==t.vertexOffset?t.vertexOffset:e.vertexOffset||0)*n+(t.elementOffset||0)*e.bytesPerElement+(e.offset||0);return{...t,offset:s,stride:n}}class Vp{constructor(e,t,n){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;const s=t.logicalType||t.type,r="float64"===s;let i,{defaultValue:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0),i=r?"float32":!s&&t.isIndexed?"uint32":s||"float32";let a=function(e){switch(e){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Ns(e)}}(s||i);this.doublePrecision=r,r&&!1===t.fp64&&(a=Float32Array),this.value=null,this.settings={...t,defaultType:a,defaultValue:o,logicalType:s,type:i,normalized:i.includes("norm"),size:this.size,bytesPerElement:a.BYTES_PER_ELEMENT},this.state={...n,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){const e=this.getAccessor();return e.vertexOffset?e.vertexOffset*jp(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),ju.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){const n={};if(this.state.constant){const s=this.value;if(t){const r=Gp(this.getAccessor(),t),i=r.offset/s.BYTES_PER_ELEMENT,o=r.size||this.size;n[e]=s.subarray(i,i+o)}else n[e]=s}else n[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?n[`${e}64Low`]=n[e]:n[`${e}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(e=this.id,t=null){const n=this.getAccessor(),s=[],r={name:this.id,byteStride:jp(n),attributes:s};if(this.doublePrecision){const r=function(e,t){const n=Gp(e,t);return{high:n,low:{...n,offset:n.offset+4*e.size}}}(n,t||{});s.push(Up(e,{...n,...r.high},this.device.type),Up(`${e}64Low`,{...n,...r.low},this.device.type))}else if(t){const r=Gp(n,t);s.push(Up(e,{...n,...r},this.device.type))}else s.push(Up(e,n,this.device.type));return r}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){const t=Array.from(this.value);e=[t,t]}else{const{value:t,numInstances:n,size:s}=this,r=n*s;if(t&&r&&t.length>=r){const n=new Array(s).fill(1/0),i=new Array(s).fill(-1/0);for(let e=0;ei[r]&&(i[r]=s)}e=[n,i]}}return this.state.bounds=e,e}setData(e){const{state:t}=this;let n;n=ArrayBuffer.isView(e)?{value:e}:e instanceof ks?{buffer:e}:e;const s={...this.settings,...n};if(ArrayBuffer.isView(n.value)){if(!n.type)if(this.doublePrecision&&n.value instanceof Float64Array)s.type="float32";else{const e=Bp(n.value);s.type=s.normalized?e.replace("int","norm"):e}s.bytesPerElement=n.value.BYTES_PER_ELEMENT,s.stride=jp(s)}if(t.bounds=null,n.constant){let e=n.value;if(e=this._normalizeValue(e,[],0),this.settings.normalized&&(e=this.normalizeConstant(e)),t.constant&&this._areValuesEqual(e,this.value))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(e)?e:new Float32Array(e)}else if(n.buffer){const e=n.buffer;t.externalBuffer=e,t.constant=!1,this.value=n.value||null}else if(n.value){this._checkExternalBuffer(n);let e=n.value;t.externalBuffer=null,t.constant=!1,this.value=e;let{buffer:r}=this;const i=jp(s),o=(s.vertexOffset||0)*i;if(this.doublePrecision&&e instanceof Float64Array&&(e=Hu(e,s)),this.settings.isIndexed){const t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}const a=e.byteLength+o+2*i;(!r||r.byteLength(e+128)/255*2-1);case"snorm16":return new Float32Array(e).map(e=>(e+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(e=>e/255);case"unorm16":return new Float32Array(e).map(e=>e/65535);default:return e}}_normalizeValue(e,t,n){const{defaultValue:s,size:r}=this.settings;if(Number.isFinite(e))return t[n]=e,t;if(!e){let e=r;for(;--e>=0;)t[n+e]=s[e];return t}switch(r){case 4:t[n+3]=Number.isFinite(e[3])?e[3]:s[3];case 3:t[n+2]=Number.isFinite(e[2])?e[2]:s[2];case 2:t[n+1]=Number.isFinite(e[1])?e[1]:s[1];case 1:t[n+0]=Number.isFinite(e[0])?e[0]:s[0];break;default:let i=r;for(;--i>=0;)t[n+i]=Number.isFinite(e[i])?e[i]:s[i]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;const{size:n}=this;for(let s=0;s0&&(Wp.length=e.length,s=Wp):s=zp,(t>0||Number.isFinite(n))&&(s=(Array.isArray(s)?s:Array.from(s)).slice(t,n),r.index=t-1),{iterable:s,objectInfo:r}}function $p(e){return e&&e[Symbol.asyncIterator]}function Xp(e,t){const{size:n,stride:s,offset:r,startIndices:i,nested:o}=t,a=e.BYTES_PER_ELEMENT,l=s?s/a:n,c=r?r/a:0,u=Math.floor((e.length-c)/l);return(t,{index:s,target:r})=>{if(!i){const t=s*l+c;for(let s=0;se},spring:{stiffness:.05,damping:.5}};function Zp(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});const n=e.type||"interpolation";return{...Kp[n],...t,...e,type:n}}class Qp extends Vp{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Yp}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){const t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t,n,s;(t=this.state).layoutChanged||(t.layoutChanged=(n=e,s=this.getAccessor(),!(n.type===s.type&&n.size===s.size&&jp(n)===jp(s)&&(n.offset||0)===(s.offset||0)))),super.setAccessor(e)}getUpdateTriggers(){const{accessor:e}=this.settings;return[this.id].concat("function"!=typeof e&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;const{accessor:t}=this.settings,n=this.settings.transition;return Zp(Array.isArray(t)?e[t.find(t=>e[t])]:e[t],n)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){const{startRow:e=0,endRow:n=1/0}=t;this.state.updateRanges=function(e,t){if(e===Yp)return e;if(t[0]<0&&(t[0]=0),t[0]>=t[1])return e;const n=[],s=e.length;let r=0;for(let i=0;it[1]?n.push(s):t=[Math.min(s[0],t[0]),Math.max(s[1],t[1])]}return n.splice(r,0,t),n}(this.state.updateRanges,[e,n])}else this.state.updateRanges=Yp}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=qp}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){const{state:t,settings:n}=this;return!n.noAlloc&&!!n.update&&(super.allocate(e,t.updateRanges!==Yp),!0)}updateBuffer({numInstances:e,data:t,props:n,context:s}){if(!this.needsUpdate())return!1;const{state:{updateRanges:r},settings:{update:i,noAlloc:o}}=this;let a=!0;if(i){for(const[o,a]of r)i.call(s,this,{data:t,startRow:o,endRow:a,props:n,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthr[h]),sd("function"==typeof f,`accessor "${h}" is not a function`);let p=e.getVertexOffset(n);const{iterable:g,objectInfo:m}=Hp(t,n,s);for(const _ of g){m.index++;let t=f(_,m);if(d&&(t=d.call(this,t)),u){const n=(m.indexc?l.set(t,p):(e._normalizeValue(t,m.target,0),zh({target:l,source:m.target,start:p,count:n}));p+=n*c}else e._normalizeValue(t,l,p),p+=c}}_validateAttributeUpdaters(){const{settings:e}=this;if(!e.noAlloc&&"function"!=typeof e.update)throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){const{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let n=!0;switch(t){case 4:n=n&&Number.isFinite(e[3]);case 3:n=n&&Number.isFinite(e[2]);case 2:n=n&&Number.isFinite(e[1]);case 1:n=n&&Number.isFinite(e[0]);break;default:n=!1}if(!n)throw new Error(`Illegal attribute generated for ${this.id}`)}}}function Jp(e){const{source:t,target:n,start:s=0,size:r,getData:i}=e,o=e.end||n.length,a=t.length,l=o-s;if(a>l)return void n.set(t.subarray(0,l),s);if(n.set(t,s),!i)return;let c=a;for(;ce}){const a=n.doublePrecision&&n.value instanceof Float64Array?2:1,l=n.size*a,c=n.byteOffset,u=n.settings.bytesPerElement<4?c/n.settings.bytesPerElement*4:c,h=n.startIndices,d=i&&h,f=n.isConstant;if(!d&&t&&s>=r)return t;const p=n.value instanceof Float64Array?Float32Array:n.value.constructor,g=f?n.value:new p(n.getBuffer().readSyncWebGL(c,r*p.BYTES_PER_ELEMENT).buffer);if(n.settings.normalized&&!f){const e=o;o=(t,s)=>n.normalizeConstant(e(t,s))}const m=f?(e,t)=>o(g,t):(e,t)=>o(g.subarray(e+c,e+c+l),t),_=t?new Float32Array(t.readSyncWebGL(u,4*s).buffer):new Float32Array(0),y=new Float32Array(r);return function({source:e,target:t,size:n,getData:s,sourceStartIndices:r,targetStartIndices:i}){if(!r||!i)return Jp({source:e,target:t,size:n,getData:s}),t;let o=0,a=0;const l=s&&((e,t)=>s(e+a,t)),c=Math.min(r.length,i.length);for(let u=1;u EPSILON || length(aTo - aCur) > EPSILON;\n vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0;\n\n vNext = getNextValue(aCur, aPrev, aTo);\n gl_Position = vec4(0, 0, 0, 1);\n gl_PointSize = 100.0;\n}\n",fs:"#version 300 es\n#define SHADER_NAME spring-transition-is-transitioning-fragment-shader\n\nin float vIsTransitioningFlag;\n\nout vec4 fragColor;\n\nvoid main(void) {\n if (vIsTransitioningFlag == 0.0) {\n discard;\n }\n fragColor = vec4(1.0);\n}",bufferLayout:[{name:"aPrev",format:s},{name:"aCur",format:s},{name:"aTo",format:t.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[lg],defines:{ATTRIBUTE_TYPE:n},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}(e,t)}start(e,t){const n=this.currentLength,s=this.currentStartIndices;super.start(e,t);const{buffers:r,attribute:i}=this;for(let a=0;a<2;a++)r[a]=rg({device:this.device,buffer:r[a],attribute:i,fromLength:n,toLength:this.currentLength,fromStartIndices:s,getData:e.enter});r[2]=sg({device:this.device,source:r[0],target:r[2]}),this.setBuffer(r[1]);const{model:o}=this.transform;o.setVertexCount(Math.floor(this.currentLength/i.size)),i.isConstant?o.setConstantAttributes({aTo:i.value}):o.setAttributes({aTo:i.getBuffer()})}onUpdate(){const{buffers:e,transform:t,framebuffer:n,transition:s}=this,r=this.settings;t.model.setAttributes({aPrev:e[0],aCur:e[1]}),t.transformFeedback.setBuffers({vNext:e[2]});const i={stiffness:r.stiffness,damping:r.damping};t.model.shaderInputs.setProps({spring:i}),t.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),ng(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(n)[0]>0||s.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}};class ug{constructor(e,{id:t,timeline:n}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=t,this.device=e,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(const e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:n}){this.numInstances=n||1;for(const s in e){const n=e[s],r=n.getTransitionSetting(t);r&&this._updateAttribute(s,n,r)}for(const s in this.transitions){const n=e[s];n&&n.getTransitionSetting(t)||this._removeTransition(s)}}hasAttribute(e){const t=this.transitions[e];return t&&t.inProgress}getAttributes(){const e={};for(const t in this.transitions){const n=this.transitions[t];n.inProgress&&(e[t]=n.attributeInTransition)}return e}run(){if(0===this.numInstances)return!1;for(const t in this.transitions)this.transitions[t].update()&&(this.needsRedraw=!0);const e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,n){const s=this.transitions[e];let r=!s||s.type!==n.type;if(r){s&&this._removeTransition(e);const i=cg[n.type];i?this.transitions[e]=new i({attribute:t,timeline:this.timeline,device:this.device}):(Fn.error(`unsupported transition type '${n.type}'`)(),r=!1)}(r||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}}const hg="attributeManager.invalidate";class dg{constructor(e,{id:t="attribute-manager",stats:n,timeline:s}={}){this.mergeBoundsMemoized=Sc($u),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new ug(e,{id:`${t}-transitions`,timeline:s}),Object.seal(this)}finalize(){for(const e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){const t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(const t of e)void 0!==this.attributes[t]&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){const n=this._invalidateTrigger(e,t);Un(hg,this,e,n)}invalidateAll(e){for(const t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);Un(hg,this,"all")}update({data:e,numInstances:t,startIndices:n=null,transitions:s,props:r={},buffers:i={},context:o={}}){let a=!1;Un("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const l in this.attributes){const s=this.attributes[l],c=s.settings.accessor;s.startIndices=n,s.numInstances=t,r[l]&&Fn.removed(`props.${l}`,`data.attributes.${l}`)(),s.setExternalBuffer(i[l])||s.setBinaryValue("string"==typeof c?i[c]:void 0,e.startIndices)||"string"==typeof c&&!i[c]&&s.setConstantValue(o,r[c])||s.needsUpdate()&&(a=!0,this._updateAttribute({attribute:s,numInstances:t,data:e,props:r,context:o})),this.needsRedraw=this.needsRedraw||s.needsRedraw()}a&&Un("attributeManager.updateEnd",this,t),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:s})}updateTransition(){const{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){const t=e.map(e=>{var t;return null==(t=this.attributes[e])?void 0:t.getBounds()});return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){const{attributes:t,attributeTransitionManager:n}=this,s={...n.getAttributes()};for(const r in t){const i=t[r];i.needsRedraw(e)&&!n.hasAttribute(r)&&(s[r]=i)}return s}getBufferLayouts(e){return Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_add(e,t){for(const n in e){const s=e[n],r={...s,id:n,size:(s.isIndexed?1:s.size)||1,...t};this.attributes[n]=new Qp(this.device,r)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){const e={};for(const t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(n=>{e[n]||(e[n]=[]),e[n].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){const{attributes:n,updateTriggers:s}=this,r=s[e];return r&&r.forEach(e=>{const s=n[e];s&&s.setNeedsUpdate(s.id,t)}),r}_updateAttribute(e){const{attribute:t,numInstances:n}=e;Un("attribute.updateStart",t),t.constant?t.setConstantValue(e.context,t.value):(t.allocate(n)&&Un("attribute.allocate",t,n),t.updateBuffer(e)&&(this.needsRedraw=!0,Un("attribute.updateEnd",t,n)))}}const fg=1e-5;function pg(e,t,n,s,r){const i=t-e;return(n-t)*r+-i*s+i+t}function gg(e,t){if(Array.isArray(e)){let n=0;for(let s=0;s0}add(e,t,n,s){const{transitions:r}=this;if(r.has(e)){const n=r.get(e),{value:s=n.settings.fromValue}=n;t=s,this.remove(e)}if(!(s=Zp(s)))return;const i=mg[s.type];if(!i)return void Fn.error(`unsupported transition type '${s.type}'`)();const o=new i(this.timeline);o.start({...s,fromValue:t,toValue:n}),r.set(e,o)}remove(e){const{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){const e={};for(const[t,n]of this.transitions)n.update(),e[t]=n.value,n.inProgress||this.remove(t);return e}clear(){for(const e of this.transitions.keys())this.remove(e)}}function yg(e,t){if(!e.transitions)return!1;const n={},s=e[Fh];let r=!1;for(const i in e.transitions){const o=s[i],a=o&&o.type;("number"===a||"color"===a||"array"===a)&&vg(e[i],t[i],o)&&(n[i]=!0,r=!0)}return!!r&&n}function bg({newProps:e,oldProps:t,ignoreProps:n={},propTypes:s={},triggerName:r="props"}){if(t===e)return!1;if("object"!=typeof e||null===e)return`${r} changed shallowly`;if("object"!=typeof t||null===t)return`${r} changed shallowly`;for(const i of Object.keys(e))if(!(i in n)){if(!(i in t))return`${r}.${i} added`;const n=vg(e[i],t[i],s[i]);if(n)return`${r}.${i} ${n}`}for(const i of Object.keys(t))if(!(i in n)){if(!(i in e))return`${r}.${i} dropped`;if(!Object.hasOwnProperty.call(e,i)){const n=vg(e[i],t[i],s[i]);if(n)return`${r}.${i} ${n}`}}return!1}function vg(e,t,n){let s=n&&n.equal;return s&&!s(e,t,n)?"changed deeply":s||(s=e&&t&&e.equals,!s||s.call(e,t))?s||t===e?null:"changed shallowly":"changed deeply"}function xg(e,t){if(null===t)return!0;const n=t.extensions,{extensions:s}=e;if(s===n)return!1;if(!n||!s)return!0;if(s.length!==n.length)return!0;for(let r=0;r"project64"===e.name))){const e=n.modules.findIndex(e=>"project32"===e.name);e>=0&&n.modules.splice(e,1)}if("inject"in t)if(e.inject){const s={...e.inject};for(const e in t.inject)s[e]=(s[e]||"")+t.inject[e];n.inject=s}else n.inject=t.inject;return n}const Tg={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Sg={},Ag={boolean:{validate:(e,t)=>!0,equal:(e,t,n)=>Boolean(e)===Boolean(t)},number:{validate:(e,t)=>Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)},color:{validate:(e,t)=>t.optional&&!e||Pg(e)&&(3===e.length||4===e.length),equal:(e,t,n)=>Xh(e,t,1)},accessor:{validate(e,t){const n=kg(e);return"function"===n||n===kg(t.value)},equal:(e,t,n)=>"function"==typeof t||Xh(e,t,1)},array:{validate:(e,t)=>t.optional&&!e||Pg(e),equal(e,t,n){const{compare:s}=n,r=Number.isInteger(s)?s:s?1:0;return s?Xh(e,t,r):e===t}},object:{equal(e,t,n){if(n.ignore)return!0;const{compare:s}=n,r=Number.isInteger(s)?s:s?1:0;return s?Xh(e,t,r):e===t}},function:{validate:(e,t)=>t.optional&&!e||"function"==typeof e,equal:(e,t,n)=>!n.compare&&!1!==n.ignore||e===t},data:{transform:(e,t,n)=>{if(!e)return e;const{dataTransform:s}=n.props;return s?s(e):"string"==typeof e.shape&&e.shape.endsWith("-table")&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,n)=>{const s=n.context;return s&&s.device?function(e,t,n,s){if(n instanceof xr)return n;n.constructor&&"Object"!==n.constructor.name&&(n={data:n});let r=null;n.compressed&&(r={minFilter:"linear",mipmapFilter:n.data.length>1?"nearest":"linear"});const{width:i,height:o}=n.data,a=t.createTexture({...n,sampler:{...Tg,...r,...s},mipLevels:t.getMipLevelCount(i,o)});return a.generateMipmapsWebGL(),Sg[a.id]=e,a}(n.id,s.device,e,{...t.parameters,...n.props.textureParameters}):null},release:(e,t,n)=>{var s,r;s=n.id,(r=e)&&r instanceof xr&&Sg[r.id]===s&&(r.delete(),delete Sg[r.id])}}};function Rg(e,t){switch(kg(t)){case"object":return Cg(e,t);case"array":return Cg(e,{type:"array",value:t,compare:!1});case"boolean":return Cg(e,{type:"boolean",value:t});case"number":return Cg(e,{type:"number",value:t});case"function":return Cg(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function Cg(e,t){return"type"in t?{name:e,...Ag[t.type],...t}:"value"in t?{name:e,type:kg(t.value),...t}:{name:e,type:"object",value:t}}function Pg(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function kg(e){return Pg(e)?"array":null===e?"null":typeof e}function Ig(e,t){if(!(e instanceof Fg.constructor))return{};let n="_mergedDefaultProps";if(t)for(const s of t){const e=s.constructor;e&&(n+=`:${e.extensionName||e.name}`)}return Ng(e,n)||(e[n]=function(e,t){if(!e.prototype)return null;const n=Ig(Object.getPrototypeOf(e)),s=function(e){const t={},n={},s={};for(const[r,i]of Object.entries(e)){const e=null==i?void 0:i.deprecatedFor;if(e)s[r]=Array.isArray(e)?e:[e];else{const e=Rg(r,i);t[r]=e,n[r]=e.value}}return{propTypes:t,defaultProps:n,deprecatedProps:s}}(Ng(e,"defaultProps")||{}),r=Object.assign(Object.create(null),n,s.defaultProps),i=Object.assign(Object.create(null),null==n?void 0:n[Fh],s.propTypes),o=Object.assign(Object.create(null),null==n?void 0:n[Dh],s.deprecatedProps);for(const a of t){const e=Ig(a.constructor);e&&(Object.assign(r,e),Object.assign(i,e[Fh]),Object.assign(o,e[Dh]))}return function(e,t){const n=function(e){const t=e.componentName;return t||Fn.warn(`${e.name}.componentName not specified`)(),t||e.name}(t);Object.defineProperties(e,{id:{writable:!0,value:n}})}(r,e),function(e,t){const n={},s={};for(const r in t){const e=t[r],{name:i,value:o}=e;e.async&&(n[i]=o,s[i]=Mg(i))}e[Bh]=n,e[Uh]={},Object.defineProperties(e,s)}(r,i),function(e,t){for(const n in t)Object.defineProperty(e,n,{enumerable:!1,set(e){const s=`${this.id}: ${n}`;for(const r of t[n])Lg(this,r)||(this[r]=e);Fn.deprecated(s,t[n].join("/"))()}})}(r,o),r[Fh]=i,r[Dh]=o,0!==t.length||Lg(e,"_propTypes")||(e._propTypes=i),r}(e,t||[]))}function Mg(e){return{enumerable:!0,set(t){"string"==typeof t||t instanceof Promise||$p(t)?this[Uh][e]=t:this[jh][e]=t},get(){if(this[jh]){if(e in this[jh])return this[jh][e]||this[Bh][e];if(e in this[Uh]){const t=this[Oh]&&this[Oh].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[Bh][e]}}return this[Bh][e]}}}function Lg(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ng(e,t){return Lg(e,t)&&e[t]}let Og=0;class Fg{constructor(...e){this.props=function(e,t){let n;for(let i=t.length-1;i>=0;i--){const e=t[i];"extensions"in e&&(n=e.extensions)}const s=Ig(e.constructor,n),r=Object.create(s);r[Oh]=e,r[Uh]={},r[jh]={};for(let i=0;i{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const e in this.asyncProps){const t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||Dg}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){const t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){const t=this.asyncProps[e];return Boolean(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(const t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[Oh]||this.component;const t=e[jh]||{},n=e[Uh]||e,s=e[Bh]||{};for(const r in t){const e=t[r];this._createAsyncPropData(r,s[r]),this._updateAsyncProp(r,e),t[r]=this.getAsyncProp(r)}for(const r in n){const e=n[r];this._createAsyncPropData(r,s[r]),this._updateAsyncProp(r,e)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){this._didAsyncInputValueChange(e,t)&&("string"==typeof t&&(t=this._fetch(e,t)),t instanceof Promise?this._watchPromise(e,t):$p(t)?this._resolveAsyncIterable(e,t):this._setPropValue(e,t))}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){const n=this.asyncProps[e];return t!==n.resolvedValue&&t!==n.lastValue&&(n.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();const n=this.asyncProps[e];n&&(t=this._postProcessValue(n,t),n.resolvedValue=t,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(e,t,n){const s=this.asyncProps[e];s&&n>=s.resolvedLoadCount&&void 0!==t&&(this._freezeAsyncOldProps(),s.resolvedValue=t,s.resolvedLoadCount=n,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){const n=this.asyncProps[e];if(n){n.pendingLoadCount++;const s=n.pendingLoadCount;t.then(t=>{this.component&&(t=this._postProcessValue(n,t),this._setAsyncPropValue(e,t,s),this._onResolve(e,t))}).catch(t=>{this._onError(e,t)})}}async _resolveAsyncIterable(e,t){if("data"!==e)return void this._setPropValue(e,t);const n=this.asyncProps[e];if(!n)return;n.pendingLoadCount++;const s=n.pendingLoadCount;let r=[],i=0;for await(const o of t){if(!this.component)return;const{dataTransform:t}=this.component.props;r=t?t(o,r):r.concat(o),Object.defineProperty(r,"__diff",{enumerable:!1,value:[{startRow:i,endRow:r.length}]}),i=r.length,this._setAsyncPropValue(e,r,s)}this._onResolve(e,r)}_postProcessValue(e,t){const n=e.type;return n&&this.component&&(n.release&&n.release(e.resolvedValue,n,this.component),n.transform)?n.transform(t,n,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){const n=this.component&&this.component.props[Fh];this.asyncProps[e]={type:n&&n[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}}class Ug extends Bg{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,t){const n=this.layer,s=null==n?void 0:n.props.fetch;return s?s(t,{propName:e,layer:n}):super._fetch(e,t)}_onResolve(e,t){const n=this.layer;if(n){const s=n.props.onDataLoad;"data"===e&&s&&s(t,{propName:e,layer:n})}}_onError(e,t){const n=this.layer;n&&n.raiseError(t,`loading ${e} of ${this.layer}`)}}const jg=2**24-1,Gg=Object.freeze([]),Vg=Sc(({oldViewport:e,viewport:t})=>e.equals(t));let zg=new Uint8ClampedArray(0);const Wg={data:{type:"data",value:Gg,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:e=>e&&e.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(e,{propName:t,layer:n,loaders:s,loadOptions:r,signal:i})=>{const{resourceManager:o}=n.context;r=r||n.getLoadOptions(),s=s||n.props.loaders,i&&(r={...r,fetch:{...null==r?void 0:r.fetch,signal:i}});let a=o.contains(e);return a||r||(o.add({resourceId:e,data:yn(e,s),persistent:!1}),a=!0),a?o.subscribe({resourceId:e,onChange:e=>{var s;return null==(s=n.internalState)?void 0:s.reloadAsyncProp(t,e)},consumerId:n.id,requestId:t}):yn(e,s,r)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:bc.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:e})=>[0,100*-e]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class Hg extends Fg{constructor(){super(...arguments),this.internalState=null,this.lifecycle="Awaiting state",this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){sd(this.internalState);const t=this.internalState.viewport||this.context.viewport,n=th(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[s,r,i]=iu(n,t.pixelProjectionMatrix);return 2===e.length?[s,r]:[s,r,i]}unproject(e){return sd(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){return sd(this.internalState),function(e,t){const{viewport:n,coordinateSystem:s,coordinateOrigin:r,modelMatrix:i,fromCoordinateSystem:o,fromCoordinateOrigin:a}=function(e){const{viewport:t,modelMatrix:n,coordinateOrigin:s}=e;let{coordinateSystem:r,fromCoordinateSystem:i,fromCoordinateOrigin:o}=e;return r===bc.DEFAULT&&(r=t.isGeospatial?bc.LNGLAT:bc.CARTESIAN),void 0===i&&(i=r),void 0===o&&(o=s),{viewport:t,coordinateSystem:r,coordinateOrigin:s,modelMatrix:n,fromCoordinateSystem:i,fromCoordinateOrigin:o}}(t),{autoOffset:l=!0}=t,{geospatialOrigin:c=Ju,shaderCoordinateOrigin:u=Ju,offsetMode:h=!1}=l?Mc(n,s,r):{},d=th(e,{viewport:n,modelMatrix:i,coordinateSystem:o,coordinateOrigin:a,offsetMode:h});if(h){const e=n.projectPosition(c||u);Ga(d,d,e)}return d}(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return!!this.internalState&&!this.internalState.isAsyncPropLoading()}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){const e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(const t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:e}=this.props;return e===bc.DEFAULT||e===bc.LNGLAT||e===bc.CARTESIAN}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){sd(e instanceof Uint8Array);const[t,n,s]=e;return t+256*n+65536*s-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&void 0!==this.state.numInstances?this.state.numInstances:function(e){if(null===(t=e)||"object"!=typeof t)throw new Error("count(): argument not an object");var t;if("function"==typeof e.count)return e.count();if(Number.isFinite(e.size))return e.size;if(Number.isFinite(e.length))return e.length;if(function(e){return null!==e&&"object"==typeof e&&e.constructor===Object}(e))return Object.keys(e).length;throw new Error("count(): argument not a container")}(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){var e;return null==(e=this.getAttributeManager())?void 0:e.getBounds(["positions","instancePositions"])}getShaders(e){e=Eg(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const t of this.props.extensions)e=Eg(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){const t=this.getAttributeManager(),{dataChanged:n}=e.changeFlags;if(n&&t)if(Array.isArray(n))for(const s of n)t.invalidateAll(s);else t.invalidateAll();if(t){const{props:n}=e,s=this.internalState.hasPickingBuffer,r=Number.isInteger(n.highlightedObjectIndex)||n.pickable||n.extensions.some(e=>e.getNeedsPickingBuffer.call(this,e));if(s!==r){this.internalState.hasPickingBuffer=r;const{pickingColors:e,instancePickingColors:n}=t.attributes,s=e||n;s&&(r&&s.constant&&(s.constant=!1,t.invalidate(s.id)),s.value||r||(s.constant=!0,s.value=[0,0,0]))}}}finalizeState(e){for(const n of this.getModels())n.destroy();const t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(const t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:n}){const{index:s}=e;return s>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[s]),e}raiseError(e,t){var n,s,r,i;t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),(null==(s=(n=this.props).onError)?void 0:s.call(n,e))||null==(i=null==(r=this.context)?void 0:r.onError)||i.call(r,e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return!!this.internalState&&(this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()))}hasUniformTransition(){var e;return(null==(e=this.internalState)?void 0:e.uniformTransitions.active)||!1}activateViewport(e){if(!this.internalState)return;const t=this.internalState.viewport;this.internalState.viewport=e,t&&Vg({oldViewport:t,viewport:e})||(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){const t=this.getAttributeManager();t&&("all"===e?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(const n in e)e[n].layoutChanged()&&(t=!0);for(const n of this.getModels())this._setModelAttributes(n,e,t)}_updateAttributes(){const e=this.getAttributeManager();if(!e)return;const t=this.props,n=this.getNumInstances(),s=this.getStartIndices();e.update({data:t.data,numInstances:n,startIndices:s,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});const r=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(r)}_updateAttributeTransition(){const e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){const{uniformTransitions:e}=this.internalState;if(e.active){const t=e.update(),n=Object.create(this.props);for(const e in t)Object.defineProperty(n,e,{value:t[e]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;const n=Math.floor(zg.length/4);if(this.internalState.usesPickingColorCache=!0,njg&&Fn.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),zg=ju.allocate(zg,t,{size:4,copy:!0,maxCount:Math.max(t,jg)});const e=Math.floor(zg.length/4),s=[0,0,0];for(let t=n;t(Fn.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new _g(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){Un("layer.matched",this,this===e);const{state:t,internalState:n}=e;this!==e&&(this.internalState=n,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const e=this.needsUpdate();if(Un("layer.update",this,e),!e)return;const t=this.props,n=this.context,s=this.internalState,r=n.viewport,i=this._updateUniformTransition();s.propsInTransition=i,n.viewport=s.viewport||r,this.props=i;try{const e=this._getUpdateParams(),t=this.getModels();if(n.device)this.updateState(e);else try{this.updateState(e)}catch(o){}for(const n of this.props.extensions)n.updateState.call(this,e,n);this.setNeedsRedraw(),this._updateAttributes();const s=this.getModels()[0]!==t[0];this._postUpdate(e,s)}finally{n.viewport=r,this.props=t,this._clearChangeFlags(),s.needsUpdate=!1,s.resetOldProps()}}_finalize(){Un("layer.finalize",this),this.finalizeState(this.context);for(const e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:n={},parameters:s={}}){this._updateAttributeTransition();const r=this.props,i=this.context;this.props=this.internalState.propsInTransition||r;try{t&&this.setShaderModuleProps(t);const{getPolygonOffset:r}=this.props,o=r&&r(n)||[0,0];i.device instanceof Lp&&i.device.setParametersWebGL({polygonOffset:o});for(const e of this.getModels())"webgpu"===e.device.type?e.setParameters({...e.parameters,...s}):e.setParameters(s);if(i.device instanceof Lp)i.device.withParametersWebGL(s,()=>{const r={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:s,context:i};for(const e of this.props.extensions)e.draw.call(this,r,e);this.draw(r)});else{const r={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:s,context:i};for(const e of this.props.extensions)e.draw.call(this,r,e);this.draw(r)}}finally{this.props=r}}getChangeFlags(){var e;return null==(e=this.internalState)?void 0:e.changeFlags}setChangeFlags(e){if(!this.internalState)return;const{changeFlags:t}=this.internalState;for(const s in e)if(e[s]){let n=!1;if("dataChanged"===s){const r=e[s],i=t[s];r&&Array.isArray(i)&&(t.dataChanged=Array.isArray(r)?i.concat(r):r,n=!0)}t[s]||(t[s]=e[s],n=!0),n&&Un("layer.changeFlag",this,s,e)}const n=Boolean(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=n,t.somethingChanged=n||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){var n;const s=function(e,t){const n=bg({newProps:e,oldProps:t,propTypes:e[Fh],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),s=function(e,t){if(null===t)return"oldProps is null, initial diff";let n=!1;const{dataComparator:s,_dataDiff:r}=e;return s?s(e.data,t.data)||(n="Data comparator detected a change"):e.data!==t.data&&(n="A new data container was supplied"),n&&r&&(n=r(e.data,t.data)||n),n}(e,t);let r=!1;return s||(r=function(e,t){if(null===t)return{all:!0};if("all"in e.updateTriggers&&wg(e,t,"all"))return{all:!0};const n={};let s=!1;for(const r in e.updateTriggers)"all"!==r&&wg(e,t,r)&&(n[r]=!0,s=!0);return!!s&&n}(e,t)),{dataChanged:s,propsChanged:n,updateTriggersChanged:r,extensionsChanged:xg(e,t),transitionsChanged:yg(e,t)}}(e,t);if(s.updateTriggersChanged)for(const r in s.updateTriggersChanged)s.updateTriggersChanged[r]&&this.invalidateAttribute(r);if(s.transitionsChanged)for(const r in s.transitionsChanged)this.internalState.uniformTransitions.add(r,t[r],e[r],null==(n=e.transitions)?void 0:n[r]);return this.setChangeFlags(s)}validateProps(){!function(e){const t=e[Fh];for(const n in t){const s=t[n],{validate:r}=s;if(r&&!r(e[n],s))throw new Error(`Invalid prop ${n}: ${e[n]}`)}}(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){const t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:n}=this.props;e.picked&&"function"==typeof n&&(t.highlightColor=n(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){const e=this.context;return new dg(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){const{props:n,oldProps:s}=e,r=this.state.model;(null==r?void 0:r.isInstanced)&&r.setInstanceCount(this.getNumInstances());const{autoHighlight:i,highlightedObjectIndex:o,highlightColor:a}=n;if(t||s.autoHighlight!==i||s.highlightedObjectIndex!==o||s.highlightColor!==a){const e={};Array.isArray(a)&&(e.highlightColor=a),(t||s.autoHighlight!==i||o!==s.highlightedObjectIndex)&&(e.highlightedObjectColor=Number.isFinite(o)&&o>=0?this.encodePickingColor(o):null),this.setShaderModuleProps({picking:e})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;const n=this.getAttributeManager(),s=!!n&&n.getNeedsRedraw(e);if(t=t||s,t)for(const r of this.props.extensions)r.onNeedsRedraw.call(this,r);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}Hg.defaultProps=Wg,Hg.layerName="Layer";const $g=Math.PI/180,Xg=180/Math.PI,qg=6370972,Yg=256;function Kg(){const e=4018225162502676e-20,t=Math.PI/180*Yg;return{unitsPerMeter:[e,e,e],unitsPerMeter2:[0,0,0],metersPerUnit:[24886.609375,24886.609375,24886.609375],unitsPerDegree:[t,t,e],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/t,1/t,24886.609375]}}class Zg extends Zu{constructor(e={}){const{longitude:t=0,zoom:n=0,nearZMultiplier:s=.5,farZMultiplier:r=1,resolution:i=10}=e;let{latitude:o=0,height:a,altitude:l=1.5,fovy:c}=e;o=Math.max(Math.min(o,Kc),-85.051129),a=a||1,c?l=ru(c):c=su(l);const u=1/Math.PI/Math.cos(o*Math.PI/180),h=Math.pow(2,n)*u,d=e.nearZ??s,f=e.farZ??(l+512*h/a)*r,p=(new ll).lookAt({eye:[0,-l,0],up:[0,0,1]});p.rotateX(o*$g),p.rotateZ(-t*$g),p.scale(h/a),super({...e,height:a,viewMatrix:p,longitude:t,latitude:o,zoom:n,distanceScales:Kg(),fovy:c,focalDistance:l,near:d,far:f}),this.scale=h,this.latitude=o,this.longitude=t,this.resolution=i}get projectionMode(){return vc.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){const t={targetZ:e.z||0},n=this.unproject([0,this.height/2],t),s=this.unproject([this.width/2,0],t),r=this.unproject([this.width,this.height/2],t),i=this.unproject([this.width/2,this.height],t);return r[0]this.longitude&&(n[0]-=360),[Math.min(n[0],r[0],s[0],i[0]),Math.min(n[1],r[1],s[1],i[1]),Math.max(n[0],r[0],s[0],i[0]),Math.max(n[1],r[1],s[1],i[1])]}unproject(e,{topLeft:t=!0,targetZ:n}={}){const[s,r,i]=e,o=t?r:this.height-r,{pixelUnprojectionMatrix:a}=this;let l;if(Number.isFinite(i))l=Qg(a,[s,o,i,1]);else{const e=Qg(a,[s,o,-1,1]),t=Qg(a,[s,o,1,1]),r=((n||0)/qg+1)*Yg,i=Va(Ga([],e,t)),c=Va(e),u=Va(t),h=(4*c*u-(i-c-u)**2)/16*4/i;l=function(e,t,n,s){const r=t[0],i=t[1],o=t[2];return e[0]=r+s*(n[0]-r),e[1]=i+s*(n[1]-i),e[2]=o+s*(n[2]-o),e}([],e,t,(Math.sqrt(c-h)-Math.sqrt(Math.max(0,r*r-h)))/Math.sqrt(i))}const[c,u,h]=this.unprojectPosition(l);return Number.isFinite(i)?[c,u,h]:Number.isFinite(n)?[c,u,n]:[c,u]}projectPosition(e){const[t,n,s=0]=e,r=t*$g,i=n*$g,o=Math.cos(i),a=(s/qg+1)*Yg;return[Math.sin(r)*o*a,-Math.cos(r)*o*a,Math.sin(i)*a]}unprojectPosition(e){const[t,n,s]=e,r=function(e){const t=e[0],n=e[1],s=e[2];return Math.sqrt(t*t+n*n+s*s)}(e),i=Math.asin(s/r);return[Math.atan2(t,-n)*Xg,i*Xg,(r/Yg-1)*qg]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition(e,t){const n=this.unproject(t);return{longitude:e[0]-n[0]+this.longitude,latitude:e[1]-n[1]+this.latitude}}}function Qg(e,t){const n=el([],t,e);return Ja(n,n,1/n[3]),n}class Jg extends bd{applyConstraints(e){const{maxZoom:t,minZoom:n,zoom:s}=e;e.zoom=Ra(s,n,t);const{longitude:r,latitude:i}=e;return(r<-180||r>180)&&(e.longitude=function(e){const t=e%360;return t<0?360+t:t}(r+180)-180),e.latitude=Ra(i,-85.051129,Kc),e}}class em extends _d{constructor(){super(...arguments),this.ControllerState=Jg,this.transition={transitionDuration:300,transitionInterpolator:new ad(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}}class tm extends Qh{constructor(e={}){super(e)}getViewportType(e){return e.zoom>12?Qu:Zg}get ControllerType(){return em}}tm.displayName="GlobeView";class nm{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;const{attributes:t={}}=e;this.typedArrayManager=ju,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);const{data:t,buffers:n={},getGeometry:s,geometryBuffer:r,positionFormat:i,dataChanged:o,normalize:a=!0}=this.opts;if(this.data=t,this.getGeometry=s,this.positionSize=r&&r.size||("XY"===i?2:3),this.buffers=n,this.normalize=a,r&&(sd(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(r),a||(n.vertexPositions=r)),this.geometryBuffer=n.vertexPositions,Array.isArray(o))for(const l of o)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){const t=e.value||e;return ArrayBuffer.isView(t)?Xp(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){const{attributes:n,buffers:s,_attributeDefs:r,typedArrayManager:i}=this;for(const o in r)if(o in s)i.release(n[o]),n[o]=null;else{const s=r[o];s.copy=t,n[o]=i.allocate(n[o],e,s)}}_forEachGeometry(e,t,n){const{data:s,getGeometry:r}=this,{iterable:i,objectInfo:o}=Hp(s,t,n);for(const a of i)o.index++,e(r?r(a,o):null,o.index)}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:n,instanceCount:s}=this;const{data:r,geometryBuffer:i}=this,{startRow:o=0,endRow:a=1/0}=e||{},l={};if(e||(t=[0],n=[0]),this.normalize||!i)this._forEachGeometry((e,t)=>{const s=e&&this.normalizeGeometry(e);l[t]=s,n[t+1]=n[t]+(s?this.getGeometrySize(s):0)},o,a),s=n[n.length-1];else if(n=r.startIndices,s=n[r.length]||0,ArrayBuffer.isView(i))s=s||i.length/this.positionSize;else if(i instanceof ks){const e=4*this.positionSize;s=s||i.byteLength/e}else if(i.buffer){const e=i.stride||4*this.positionSize;s=s||i.buffer.byteLength/e}else if(i.value){const e=i.value,t=i.stride/e.BYTES_PER_ELEMENT||this.positionSize;s=s||e.length/t}this._allocate(s,Boolean(e)),this.indexStarts=t,this.vertexStarts=n,this.instanceCount=s;const c={};this._forEachGeometry((e,r)=>{const i=l[r]||e;c.vertexStart=n[r],c.indexStart=t[r];const o=r{e.triggerRepaint(),null==s||s("")}};let o;return i.parameters={...lm(e,!0),...i.parameters},i.views||(i.views=um(e)),n&&n.props.gl!==t||(Object.assign(i,{gl:t,width:null,height:null,touchAction:"unset",viewState:hm(e)}),(null==n?void 0:n.isInitialized)?om(n,e):i.onLoad=()=>{null==r||r(),om(o,e)}),n?(o=n,n.setProps(i),n.userData.isExternal=!0):(o=new Dp(i),e.on("remove",()=>{am(e)})),o.userData.mapboxLayers=new Set,e.__deck=o,e.on("render",()=>{o.isInitialized&&function(e,t){const{mapboxLayers:n,isExternal:s}=e.userData;if(s){const s=Array.from(n,e=>e.id),r=Gh(e.props.layers,Boolean).some(e=>e&&!s.includes(e.id));let i=e.getViewports();const o=i.findIndex(e=>e.id===sm),a=i.length>1||o<0;(r||a)&&(o>=0&&(i=i.slice(),i[o]=dm(e,t)),e._drawLayers("mapbox-repaint",{viewports:i,layerFilter:t=>(!e.props.layerFilter||e.props.layerFilter(t))&&(t.viewport.id!==sm||!s.includes(t.layer.id)),clearCanvas:!1}))}e.userData.currentViewport=null}(o,e)}),o}function om(e,t){const n=()=>{e.isInitialized?function(e,t){e.setProps({viewState:hm(t)}),e.needsRedraw({clearRedrawFlags:!0})}(e,t):t.off("move",n)};t.on("move",n)}function am(e){var t;null==(t=e.__deck)||t.finalize(),e.__deck=null}function lm(e,t){const n=t?{depthWriteEnabled:!0,depthCompare:"less-equal",depthBias:0,blend:!0,blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"}:{};return"globe"===cm(e)&&(n.cullMode="back"),n}function cm(e){var t;const n=null==(t=e.getProjection)?void 0:t.call(e),s=(null==n?void 0:n.type)||(null==n?void 0:n.name);if("globe"===s)return"globe";if(s&&"mercator"!==s)throw new Error("Unsupported projection");return"mercator"}function um(e){return"globe"===cm(e)?new tm({id:sm}):new xd({id:sm})}function hm(e){var t;const{lng:n,lat:s}=e.getCenter(),r={longitude:(n+540)%360-180,latitude:s,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:e.getPadding(),repeat:e.getRenderWorldCopies()};return(null==(t=e.getTerrain)?void 0:t.call(e))&&function(e,t){if(e.getFreeCameraOptions){const{position:n}=e.getFreeCameraOptions();if(!n||void 0===n.z)return;const s=e.transform.height,{longitude:r,latitude:i,pitch:o}=t,a=512*n.x,l=512*(1-n.y),c=512*n.z,u=Qc([r,i]),h=a-u[0],d=l-u[1],f=Math.sqrt(h*h+d*d),p=o*rm,g=1.5*s,m=p<.001?g*Math.cos(p)/c:g*Math.sin(p)/f;t.zoom=Math.log2(m);const _=c-g*Math.cos(p)/m;t.position=[0,0,_/eu(i)]}else"number"==typeof e.transform.elevation&&(t.position=[0,0,e.transform.elevation])}(e,r),r}function dm(e,t,n){const s=hm(t),{views:r}=e.props,i=r&&Gh(r).find(e=>e.id===sm)||um(t);n&&(i.props.nearZMultiplier=.2);const o=(null==n?void 0:n.nearZ)??t.transform._nearZ,a=(null==n?void 0:n.farZ)??t.transform._farZ;return Number.isFinite(o)&&(s.nearZ=o/t.transform.height,s.farZ=a/t.transform.height),i.makeViewport({width:e.width,height:e.height,viewState:s})}function fm(e){if(e.userData.isExternal)return;const t=[];e.userData.mapboxLayers.forEach(e=>{const n=new(0,e.props.type)(e.props);t.push(n)}),e.setProps({layers:t})}class pm{constructor(e){if(!e.id)throw new Error("Layer must have an unique id");this.id=e.id,this.type="custom",this.renderingMode=e.renderingMode||"3d",this.slot=e.slot,this.map=null,this.deck=null,this.props=e}onAdd(e,t){var n;this.map=e,this.deck=im({map:e,gl:t,deck:this.props.deck}),(n=this.deck).userData.mapboxLayers.add(this),fm(n)}onRemove(){var e;this.deck&&((e=this.deck).userData.mapboxLayers.delete(this),fm(e))}setProps(e){Object.assign(this.props,e,{id:this.id}),this.deck&&fm(this.deck)}render(e,t){!function(e,t,n,s){let{currentViewport:r}=e.userData,i=!1;r||(r=dm(e,t,s),e.userData.currentViewport=r,i=!0),e.isInitialized&&e._drawLayers("mapbox-repaint",{viewports:[r],layerFilter:t=>(!e.props.layerFilter||e.props.layerFilter(t))&&(n.id===t.layer.id||t.layer.props.operation.includes("terrain")),clearStack:i,clearCanvas:!1})}(this.deck,this.map,this,t)}}const gm="__UNDEFINED__";function mm(e,t,n,s){if(!(e&&t&&e.style&&e.style._loaded))return;const r=Gh(s,Boolean);if(n!==s){const t=Gh(n,Boolean),s=new Set(t.map(e=>e.id));for(const e of r)s.delete(e.id);for(const n of s)e.getLayer(n)&&e.removeLayer(n)}for(const a of r){const n=e.getLayer(a.id);n?(n.implementation||n).setProps(a.props):e.addLayer(new pm({id:a.id,deck:t,slot:a.props.slot}),a.props.beforeId)}const i=e.style._order,o={};for(const a of r){let{beforeId:e}=a.props;e&&i.includes(e)||(e=gm),o[e]=o[e]||[],o[e].push(a.id)}for(const a in o){const t=o[a];let n=a===gm?i.length:i.indexOf(a),s=a===gm?void 0:a;for(let r=t.length-1;r>=0;r--){const o=t[r],a=i.indexOf(o);a!==n-1&&(e.moveLayer(o,s),a>n&&n++),n--,s=o}}}class _m{constructor(e){this._handleStyleChange=()=>{var e;mm(this._map,this._deck,this._props.layers,this._props.layers),this._map&&cm(this._map)&&!this._props.views&&(null==(e=this._deck)||e.setProps({views:um(this._map)}))},this._updateContainerSize=()=>{if(this._map&&this._container){const{clientWidth:e,clientHeight:t}=this._map.getContainer();Object.assign(this._container.style,{width:`${e}px`,height:`${t}px`})}},this._updateViewState=()=>{const e=this._deck,t=this._map;e&&t&&(e.setProps({views:this._props.views||um(t),viewState:hm(t)}),e.isInitialized&&e.redraw())},this._handleMouseEvent=e=>{const t=this._deck;if(!t||!t.isInitialized)return;const n={type:e.type,offsetCenter:e.point,srcEvent:e},s=this._lastMouseDownPoint;switch(!e.point&&s&&(n.deltaX=e.originalEvent.clientX-s.clientX,n.deltaY=e.originalEvent.clientY-s.clientY,n.offsetCenter={x:s.x+n.deltaX,y:s.y+n.deltaY}),n.type){case"mousedown":t._onPointerDown(n),this._lastMouseDownPoint={...e.point,clientX:e.originalEvent.clientX,clientY:e.originalEvent.clientY};break;case"dragstart":n.type="panstart",t._onEvent(n);break;case"drag":n.type="panmove",t._onEvent(n);break;case"dragend":n.type="panend",t._onEvent(n);break;case"click":n.tapCount=1,t._onEvent(n);break;case"dblclick":n.type="click",n.tapCount=2,t._onEvent(n);break;case"mousemove":n.type="pointermove",t._onPointerMove(n);break;case"mouseout":n.type="pointerleave",t._onPointerMove(n);break;default:return}};const{interleaved:t=!1}=e;this._interleaved=t,this._props=this.filterProps(e)}filterProps(e){const{interleaved:t=!1,useDevicePixels:n,...s}=e;return t||void 0===n||(s.useDevicePixels=n),s}setProps(e){this._interleaved&&e.layers&&mm(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,this.filterProps(e)),this._deck&&this._map&&this._deck.setProps({...this._props,parameters:{...lm(this._map,this._interleaved),...this._props.parameters}})}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){const t=document.createElement("div");return Object.assign(t.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=t,this._deck=new Dp({...this._props,parent:t,parameters:{...lm(e,!1),...this._props.parameters},views:this._props.views||um(e),viewState:hm(e)}),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousedown",this._handleMouseEvent),e.on("dragstart",this._handleMouseEvent),e.on("drag",this._handleMouseEvent),e.on("dragend",this._handleMouseEvent),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),t}_onAddInterleaved(e){const t=e.painter.context.gl;return t instanceof WebGLRenderingContext&&Fn.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=im({map:e,gl:t,deck:new Dp({...this._props,gl:t,parameters:{...lm(e,!0),...this._props.parameters}})}),e.on("styledata",this._handleStyleChange),mm(e,this._deck,[],this._props.layers),document.createElement("div")}onRemove(){const e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){var t;e.off("resize",this._updateContainerSize),e.off("render",this._updateViewState),e.off("mousedown",this._handleMouseEvent),e.off("dragstart",this._handleMouseEvent),e.off("drag",this._handleMouseEvent),e.off("dragend",this._handleMouseEvent),e.off("mousemove",this._handleMouseEvent),e.off("mouseout",this._handleMouseEvent),e.off("click",this._handleMouseEvent),e.off("dblclick",this._handleMouseEvent),null==(t=this._deck)||t.finalize()}_onRemoveInterleaved(e){e.off("styledata",this._handleStyleChange),mm(e,this._deck,this._props.layers,[]),am(e)}getDefaultPosition(){return"top-left"}pickObject(e){return sd(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return sd(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return sd(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}}const ym="uniform scatterplotUniforms {\n float radiusScale;\n float radiusMinPixels;\n float radiusMaxPixels;\n float lineWidthScale;\n float lineWidthMinPixels;\n float lineWidthMaxPixels;\n float stroked;\n float filled;\n bool antialiasing;\n bool billboard;\n highp int radiusUnits;\n highp int lineWidthUnits;\n} scatterplot;\n",bm={name:"scatterplot",vs:ym,fs:ym,source:"",uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}},vm=[0,0,0,255],xm={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:e=>e.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:vm},getLineColor:{type:"accessor",value:vm},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class wm extends Hg{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-vertex-shader\nin vec3 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceRadius;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin vec3 instancePickingColors;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout vec2 unitPosition;\nout float innerUnitRadius;\nout float outerRadiusPixels;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nouterRadiusPixels = clamp(\nproject_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits),\nscatterplot.radiusMinPixels, scatterplot.radiusMaxPixels\n);\nfloat lineWidthPixels = clamp(\nproject_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits),\nscatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels\n);\nouterRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;\nfloat edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;\nunitPosition = edgePadding * positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\ninnerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels;\nif (scatterplot.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = edgePadding * positions * outerRadiusPixels;\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-fragment-shader\nprecision highp float;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin vec2 unitPosition;\nin float innerUnitRadius;\nin float outerRadiusPixels;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition;\nfloat distToCenter = length(unitPosition) * outerRadiusPixels;\nfloat inCircle = scatterplot.antialiasing ?\nsmoothedge(distToCenter, outerRadiusPixels) :\nstep(distToCenter, outerRadiusPixels);\nif (inCircle == 0.0) {\ndiscard;\n}\nif (scatterplot.stroked > 0.5) {\nfloat isLine = scatterplot.antialiasing ?\nsmoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :\nstep(innerUnitRadius * outerRadiusPixels, distToCenter);\nif (scatterplot.filled > 0.5) {\nfragColor = mix(vFillColor, vLineColor, isLine);\n} else {\nif (isLine == 0.0) {\ndiscard;\n}\nfragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);\n}\n} else if (scatterplot.filled < 0.5) {\ndiscard;\n} else {\nfragColor = vFillColor;\n}\nfragColor.a *= inCircle;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:"// Main shaders\n\nstruct ScatterplotUniforms {\n radiusScale: f32,\n radiusMinPixels: f32,\n radiusMaxPixels: f32,\n lineWidthScale: f32,\n lineWidthMinPixels: f32,\n lineWidthMaxPixels: f32,\n stroked: f32,\n filled: i32,\n antialiasing: i32,\n billboard: i32,\n radiusUnits: i32,\n lineWidthUnits: i32,\n};\n\nstruct ConstantAttributeUniforms {\n instancePositions: vec3,\n instancePositions64Low: vec3,\n instanceRadius: f32,\n instanceLineWidths: f32,\n instanceFillColors: vec4,\n instanceLineColors: vec4,\n instancePickingColors: vec3,\n\n instancePositionsConstant: i32,\n instancePositions64LowConstant: i32,\n instanceRadiusConstant: i32,\n instanceLineWidthsConstant: i32,\n instanceFillColorsConstant: i32,\n instanceLineColorsConstant: i32,\n instancePickingColorsConstant: i32\n};\n\n@group(0) @binding(2) var scatterplot: ScatterplotUniforms;\n\nstruct ConstantAttributes {\n instancePositions: vec3,\n instancePositions64Low: vec3,\n instanceRadius: f32,\n instanceLineWidths: f32,\n instanceFillColors: vec4,\n instanceLineColors: vec4,\n instancePickingColors: vec3\n};\n\nconst constants = ConstantAttributes(\n vec3(0.0),\n vec3(0.0),\n 0.0,\n 0.0,\n vec4(0.0, 0.0, 0.0, 1.0),\n vec4(0.0, 0.0, 0.0, 1.0),\n vec3(0.0)\n);\n\nstruct Attributes {\n @builtin(instance_index) instanceIndex : u32,\n @builtin(vertex_index) vertexIndex : u32,\n @location(0) positions: vec3,\n @location(1) instancePositions: vec3,\n @location(2) instancePositions64Low: vec3,\n @location(3) instanceRadius: f32,\n @location(4) instanceLineWidths: f32,\n @location(5) instanceFillColors: vec4,\n @location(6) instanceLineColors: vec4,\n @location(7) instancePickingColors: vec3\n};\n\nstruct Varyings {\n @builtin(position) position: vec4,\n @location(0) vFillColor: vec4,\n @location(1) vLineColor: vec4,\n @location(2) unitPosition: vec2,\n @location(3) innerUnitRadius: f32,\n @location(4) outerRadiusPixels: f32,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n // Draw an inline geometry constant array clip space triangle to verify that rendering works.\n // var positions = array, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5));\n // if (attributes.instanceIndex == 0) {\n // varyings.position = vec4(positions[attributes.vertexIndex], 0.0, 1.0);\n // return varyings;\n // }\n\n // var geometry: Geometry;\n // geometry.worldPosition = instancePositions;\n\n // Multiply out radius and clamp to limits\n varyings.outerRadiusPixels = clamp(\n project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits),\n scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels\n );\n\n // Multiply out line width and clamp to limits\n let lineWidthPixels = clamp(\n project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits),\n scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels\n );\n\n // outer radius needs to offset by half stroke width\n varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;\n // Expand geometry to accommodate edge smoothing\n let edgePadding = select(\n (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels,\n 1.0,\n scatterplot.antialiasing != 0\n );\n\n // position on the containing square in [-1, 1] space\n varyings.unitPosition = edgePadding * attributes.positions.xy;\n geometry.uv = varyings.unitPosition;\n geometry.pickingColor = attributes.instancePickingColors;\n\n varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels;\n\n if (scatterplot.billboard != 0) {\n varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3(0.0)); // TODO , geometry.position);\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n let offset = attributes.positions; // * edgePadding * varyings.outerRadiusPixels;\n // DECKGL_FILTER_SIZE(offset, geometry);\n let clipPixels = project_pixel_size_to_clipspace(offset.xy);\n varyings.position.x = clipPixels.x;\n varyings.position.y = clipPixels.y;\n } else {\n let offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels);\n // DECKGL_FILTER_SIZE(offset, geometry);\n varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, offset); // TODO , geometry.position);\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n }\n\n // Apply opacity to instance color, or return instance picking color\n varyings.vFillColor = vec4(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * color.opacity);\n // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry);\n varyings.vLineColor = vec4(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * color.opacity);\n // DECKGL_FILTER_COLOR(varyings.vLineColor, geometry);\n\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4 {\n // var geometry: Geometry;\n // geometry.uv = unitPosition;\n\n let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels;\n let inCircle = select(\n smoothedge(distToCenter, varyings.outerRadiusPixels),\n step(distToCenter, varyings.outerRadiusPixels),\n scatterplot.antialiasing != 0\n );\n\n if (inCircle == 0.0) {\n discard;\n }\n\n var fragColor: vec4;\n\n if (scatterplot.stroked != 0) {\n let isLine = select(\n smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n scatterplot.antialiasing != 0\n );\n\n if (scatterplot.filled != 0) {\n fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine);\n } else {\n if (isLine == 0.0) {\n discard;\n }\n fragColor = vec4(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine);\n }\n } else if (scatterplot.filled == 0) {\n discard;\n } else {\n fragColor = varyings.vFillColor;\n }\n\n fragColor.a *= inCircle;\n // DECKGL_FILTER_COLOR(fragColor, geometry);\n\n // Apply premultiplied alpha as required by transparent canvas\n fragColor = deckgl_premultiplied_alpha(fragColor);\n\n return fragColor;\n // return vec4(0, 0, 1, 1);\n}\n",modules:[Uc,_l,_u,bm]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){var t;super.updateState(e),e.changeFlags.extensionsChanged&&(null==(t=this.state.model)||t.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{radiusUnits:t,radiusScale:n,radiusMinPixels:s,radiusMaxPixels:r,stroked:i,filled:o,billboard:a,antialiasing:l,lineWidthUnits:c,lineWidthScale:u,lineWidthMinPixels:h,lineWidthMaxPixels:d}=this.props,f={stroked:i,filled:o,billboard:a,antialiasing:l,radiusUnits:xc[t],radiusScale:n,radiusMinPixels:s,radiusMaxPixels:r,lineWidthUnits:xc[c],lineWidthScale:u,lineWidthMinPixels:h,lineWidthMaxPixels:d},p=this.state.model;p.shaderInputs.setProps({scatterplot:f}),"webgpu"===this.context.device.type&&(p.instanceCount=this.props.data.length),p.draw(this.context.renderPass)}_getModel(){const e="webgpu"===this.context.device.type?{depthWriteEnabled:!0,depthCompare:"less-equal"}:void 0;return new Rh(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ih({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0])}}}),isInstanced:!0,parameters:e})}}function Em(e,t){const n=t.length,s=e.length;if(s>0){let r=!0;for(let i=0;it[2]&&(n|=2),e[1]t[3]&&(n|=8),n}function Cm(e,t){const{size:n=2,broken:s=!1,gridResolution:r=10,gridOffset:i=[0,0],startIndex:o=0,endIndex:a=e.length}=t||{},l=(a-o)/n;let c=[];const u=[c],h=Sm(e,0,n,o);let d,f;const p=function(e,t,n,s){const r=Math.floor((e[0]-n[0])/t)*t+n[0],i=Math.floor((e[1]-n[1])/t)*t+n[1];return s[0]=r,s[1]=i,s[2]=r+t,s[3]=i+t,s}(h,r,i,[]),g=[];Em(c,h);for(let m=1;mn&&(c=[],u.push(c),Em(c,h)),f=Rm(d,p)}Em(c,d),Tm(h,d)}return s?u:u[0]}function Pm(e,t,n){8&n?(e[1]+=t,e[3]+=t):4&n?(e[1]-=t,e[3]-=t):2&n?(e[0]+=t,e[2]+=t):1&n&&(e[0]-=t,e[2]-=t)}function km(e,t){let n;const s=e.length/t;for(let i=0;i180||t<-180)&&(r-=360*Math.round(t/360)),e[o]=i=r}}(o,n,0,r-s);const a=Cm(o,{size:n,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(i)for(const l of a)km(l,n);return a}(r,{size:t}):r}(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(Mm(e)){let t=0;for(const n of e)t+=this.getGeometrySize(n);return t}const t=this.getPathLength(e);return t<2?0:this.isClosed(e)?t<3?0:t+2:t}updateGeometryAttributes(e,t){if(0!==t.geometrySize)if(e&&Mm(e))for(const n of e){const e=this.getGeometrySize(n);t.geometrySize=e,this.updateGeometryAttributes(n,t),t.vertexStart+=e}else this._updateSegmentTypes(e,t),this._updatePositions(e,t)}_updateSegmentTypes(e,t){const n=this.attributes.segmentTypes,s=!!e&&this.isClosed(e),{vertexStart:r,geometrySize:i}=t;n.fill(0,r,r+i),s?(n[r]=4,n[r+i-2]=4):(n[r]+=1,n[r+i-2]+=2),n[r+i-1]=4}_updatePositions(e,t){const{positions:n}=this.attributes;if(!n||!e)return;const{vertexStart:s,geometrySize:r}=t,i=new Array(3);for(let o=s,a=0;a=e.length&&(t+=1-e.length/s);const r=t*s;return n[0]=e[r],n[1]=e[r+1],n[2]=3===s&&e[r+2]||0,n}isClosed(e){if(!this.normalize)return Boolean(this.opts.loop);const{positionSize:t}=this,n=e.length-t;return e[0]===e[n]&&e[1]===e[n+1]&&(2===t||e[2]===e[n+2])}}function Mm(e){return Array.isArray(e[0])}const Lm="uniform pathUniforms {\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n float jointType;\n float capType;\n float miterLimit;\n bool billboard;\n highp int widthUnits;\n} path;\n",Nm={name:"path",vs:Lm,fs:Lm,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}},Om=[0,0,0,255],Fm={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:e=>e.path},getColor:{type:"accessor",value:Om},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},Dm={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class Bm extends Hg{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME path-layer-vertex-shader\nin vec2 positions;\nin float instanceTypes;\nin vec3 instanceStartPositions;\nin vec3 instanceEndPositions;\nin vec3 instanceLeftPositions;\nin vec3 instanceRightPositions;\nin vec3 instanceLeftPositions64Low;\nin vec3 instanceStartPositions64Low;\nin vec3 instanceEndPositions64Low;\nin vec3 instanceRightPositions64Low;\nin float instanceStrokeWidths;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nuniform float opacity;\nout vec4 vColor;\nout vec2 vCornerOffset;\nout float vMiterLength;\nout vec2 vPathPosition;\nout float vPathLength;\nout float vJointType;\nconst float EPSILON = 0.001;\nconst vec3 ZERO_OFFSET = vec3(0.0);\nfloat flipIfTrue(bool flag) {\nreturn -(float(flag) * 2. - 1.);\n}\nvec3 getLineJoinOffset(\nvec3 prevPoint, vec3 currPoint, vec3 nextPoint,\nvec2 width\n) {\nbool isEnd = positions.x > 0.0;\nfloat sideOfPath = positions.y;\nfloat isJoint = float(sideOfPath == 0.0);\nvec3 deltaA3 = (currPoint - prevPoint);\nvec3 deltaB3 = (nextPoint - currPoint);\nmat3 rotationMatrix;\nbool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix);\nif (needsRotation) {\ndeltaA3 = deltaA3 * rotationMatrix;\ndeltaB3 = deltaB3 * rotationMatrix;\n}\nvec2 deltaA = deltaA3.xy / width;\nvec2 deltaB = deltaB3.xy / width;\nfloat lenA = length(deltaA);\nfloat lenB = length(deltaB);\nvec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\nvec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\nvec2 perpA = vec2(-dirA.y, dirA.x);\nvec2 perpB = vec2(-dirB.y, dirB.x);\nvec2 tangent = dirA + dirB;\ntangent = length(tangent) > 0. ? normalize(tangent) : perpA;\nvec2 miterVec = vec2(-tangent.y, tangent.x);\nvec2 dir = isEnd ? dirA : dirB;\nvec2 perp = isEnd ? perpA : perpB;\nfloat L = isEnd ? lenA : lenB;\nfloat sinHalfA = abs(dot(miterVec, perp));\nfloat cosHalfA = abs(dot(dirA, miterVec));\nfloat turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);\nfloat cornerPosition = sideOfPath * turnDirection;\nfloat miterSize = 1.0 / max(sinHalfA, EPSILON);\nmiterSize = mix(\nmin(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),\nmiterSize,\nstep(0.0, cornerPosition)\n);\nvec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))\n* (sideOfPath + isJoint * turnDirection);\nbool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));\nbool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));\nbool isCap = isStartCap || isEndCap;\nif (isCap) {\noffsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint);\nvJointType = path.capType;\n} else {\nvJointType = path.jointType;\n}\nvPathLength = L;\nvCornerOffset = offsetVec;\nvMiterLength = dot(vCornerOffset, miterVec * turnDirection);\nvMiterLength = isCap ? isJoint : vMiterLength;\nvec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);\nvPathPosition = vec2(\ndot(offsetFromStartOfPath, perp),\ndot(offsetFromStartOfPath, dir)\n);\ngeometry.uv = vPathPosition;\nfloat isValid = step(instanceTypes, 3.5);\nvec3 offset = vec3(offsetVec * width * isValid, 0.0);\nif (needsRotation) {\noffset = rotationMatrix * offset;\n}\nreturn offset;\n}\nvoid clipLine(inout vec4 position, vec4 refPosition) {\nif (position.w < EPSILON) {\nfloat r = (EPSILON - refPosition.w) / (position.w - refPosition.w);\nposition = refPosition + (position - refPosition) * r;\n}\n}\nvoid main() {\ngeometry.pickingColor = instancePickingColors;\nvColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);\nfloat isEnd = positions.x;\nvec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);\nvec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);\nvec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\nvec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);\nvec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);\nvec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);\ngeometry.worldPosition = currPosition;\nvec2 widthPixels = vec2(clamp(\nproject_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits),\npath.widthMinPixels, path.widthMaxPixels) / 2.0);\nvec3 width;\nif (path.billboard) {\nvec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);\nvec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);\nvec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);\nclipLine(prevPositionScreen, currPositionScreen);\nclipLine(nextPositionScreen, currPositionScreen);\nclipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));\nwidth = vec3(widthPixels, 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(\nprevPositionScreen.xyz / prevPositionScreen.w,\ncurrPositionScreen.xyz / currPositionScreen.w,\nnextPositionScreen.xyz / nextPositionScreen.w,\nproject_pixel_size_to_clipspace(width.xy)\n);\nDECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);\ngl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);\n} else {\nprevPosition = project_position(prevPosition, prevPosition64Low);\ncurrPosition = project_position(currPosition, currPosition64Low);\nnextPosition = project_position(nextPosition, nextPosition64Low);\nwidth = vec3(project_pixel_size(widthPixels), 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);\ngeometry.position = vec4(currPosition + offset, 1.0);\ngl_Position = project_common_position_to_clipspace(geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME path-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 vCornerOffset;\nin float vMiterLength;\nin vec2 vPathPosition;\nin float vPathLength;\nin float vJointType;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vPathPosition;\nif (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {\nif (vJointType > 0.5 && length(vCornerOffset) > 1.0) {\ndiscard;\n}\nif (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) {\ndiscard;\n}\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[Uc,_u,Nm]})}get wrapLongitude(){return!1}getBounds(){var e;return null==(e=this.getAttributeManager())?void 0:e.getBounds(["vertexPositions"])}initializeState(){const e=!0;this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:Dm,accessor:"getPath",update:this.calculatePositions,noAlloc:e,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:e},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:Dm,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:Dm,defaultValue:Om},instancePickingColors:{size:4,type:"uint8",accessor:(e,{index:t,target:n})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,n)}}),this.setState({pathTesselator:new Im({fp64:this.use64bitPositions()})})}updateState(e){var t;super.updateState(e);const{props:n,changeFlags:s}=e,r=this.getAttributeManager();if(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getPath)){const{pathTesselator:e}=this.state,t=n.data.attributes||{};e.updateGeometry({data:n.data,geometryBuffer:t.getPath,buffers:t,normalize:!n._pathType,loop:"loop"===n._pathType,getGeometry:n.getPath,positionFormat:n.positionFormat,wrapLongitude:n.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:s.dataChanged}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts}),s.dataChanged||r.invalidateAll()}s.extensionsChanged&&(null==(t=this.state.model)||t.destroy(),this.state.model=this._getModel(),r.invalidateAll())}getPickingInfo(e){const t=super.getPickingInfo(e),{index:n}=t,s=this.props.data;return s[0]&&s[0].__source&&(t.object=s.find(e=>e.__source.index===n)),t}disablePickingIndex(e){const t=this.props.data;if(t[0]&&t[0].__source)for(let n=0;n=-90&&e.lat<=90&&e.lon>=-180&&e.lon<=180}function jm({coveragePoints:e,visible:t,opacity:n=.8}){const{current:s}=y(),r=p.useRef(null),i=p.useMemo(()=>e&&Array.isArray(e)?e.filter(Um):[],[e]);return p.useEffect(()=>{const e=null==s?void 0:s.getMap();if(e)return r.current||(r.current=new _m({interleaved:!0,layers:[]}),e.addControl(r.current)),()=>{if(r.current&&e){try{e.removeControl(r.current)}catch{}r.current=null}}},[s]),p.useEffect(()=>{if(!r.current)return;if(!t||0===i.length)return void r.current.setProps({layers:[]});i.length>0&&i[0];const e=new wm({id:"wardriving-heatmap",data:i,getPosition:e=>[e.lon,e.lat],getRadius:500,getFillColor:e=>function(e){const t=[[65,105,225],[0,191,255],[50,205,50],[255,215,0],[255,140,0],[255,69,0]],n=Math.max(0,Math.min(1,e))*(t.length-1),s=Math.floor(n),r=Math.min(s+1,t.length-1),i=n-s,o=t[s],a=t[r];return[Math.round(o[0]+(a[0]-o[0])*i),Math.round(o[1]+(a[1]-o[1])*i),Math.round(o[2]+(a[2]-o[2])*i),180]}(e.weight),radiusMinPixels:4,radiusMaxPixels:30,opacity:n,pickable:!1,stroked:!1});r.current.setProps({layers:[e]})},[i,t,n]),null}function Gm(e){let t=!0,n=-90,s=90,r=-180,i=180;for(const o of e.toLowerCase()){const e="0123456789bcdefghjkmnpqrstuvwxyz".indexOf(o);if(-1!==e)for(let o=4;o>=0;o--){const a=e>>o&1;if(t){const e=(r+i)/2;a?r=e:i=e}else{const e=(n+s)/2;a?n=e:s=e}t=!t}}return{lat:(n+s)/2,lon:(r+i)/2}}function Vm(e){const t=function(e){return new Date(6e4*e)}(e);return((new Date).getTime()-t.getTime())/864e5}function zm(e){return Math.exp(-e*Math.LN2/7)}Bm.defaultProps=Fm,Bm.layerName="PathLayer";const Wm="pymc-wardriving-url",Hm="pymc-wardriving-enabled";function $m(e){"undefined"!=typeof localStorage&&(e?localStorage.setItem(Wm,e):localStorage.removeItem(Wm))}function Xm(e){"undefined"!=typeof localStorage&&localStorage.setItem(Hm,String(e))}const qm=c((e,t)=>({status:"idle",isVisible:"undefined"!=typeof localStorage&&"true"===localStorage.getItem(Hm),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:"undefined"==typeof localStorage?"":localStorage.getItem(Wm)||"",isModalOpen:!1,openModal:()=>e({isModalOpen:!0}),closeModal:()=>e({isModalOpen:!1}),setUrl:t=>e({url:t}),toggleVisibility:()=>{const n=!t().isVisible;Xm(n),e({isVisible:n})},setVisible:t=>{Xm(t),e({isVisible:t})},loadCoverage:async t=>{if(!t.trim())return e({error:"Please enter a URL",status:"error"}),!1;try{new URL(t.trim())}catch{return e({error:"Invalid URL format",status:"error"}),!1}e({error:null,status:"connecting"});try{e({status:"loading"});const n=await async function(e){const t=e.replace(/\/+$/,""),n=await fetch(t,{headers:{Accept:"application/json"}});if(!n.ok)throw new Error(`Failed to fetch wardriving data: ${n.status} ${n.statusText}`);return n.json()}(t.trim());if(!n||"object"!=typeof n)throw new Error("Invalid response from server");if(!Array.isArray(n.coverage)&&!Array.isArray(n.samples))throw new Error("No coverage data found in response");e({status:"processing"});const s=function(e){const t=[],n=new Map;for(const s of e.coverage){const e=n.get(s.id)||{rcv:0,lost:0,time:0,repeaters:new Set};if(e.rcv+=s.rcv||0,e.lost+=s.lost||0,s.time&&s.time>e.time&&(e.time=s.time),s.rptr)for(const t of s.rptr)e.repeaters.add(t.toLowerCase());void 0!==s.snr&&(e.snr=s.snr),void 0!==s.rssi&&(e.rssi=s.rssi),n.set(s.id,e)}for(const s of e.samples){const e=s.id.substring(0,6),t=n.get(e)||{rcv:0,lost:0,time:0,repeaters:new Set};t.rcv+=s.heard||0,t.lost+=s.lost||0,s.time&&s.time>t.time&&(t.time=s.time);const r=s.path||s.rptr;if(r)for(const n of r)t.repeaters.add(n.toLowerCase());n.set(e,t)}for(const[s,r]of n){const{lat:e,lon:n}=Gm(s),i=r.rcv+r.lost;if(0===i)continue;const o=r.rcv/i,a=r.time?Vm(r.time):30,l=o*zm(a);t.push({lat:e,lon:n,successRate:o,weight:l,totalSamples:i,ageDays:a,geohash:s,repeaters:Array.from(r.repeaters)})}return t.length>0&&(t[0],t.map(e=>e.lat),t.map(e=>e.lon)),{coveragePoints:t,repeaters:e.repeaters.filter(e=>0!==e.lat&&0!==e.lon).map(e=>{const t=e.time?Vm(e.time):30;return{id:e.id,name:e.name,lat:e.lat,lon:e.lon,elev:e.elev,ageDays:t,isStale:t>2,isDead:t>8}})}}(n);if(0===s.coveragePoints.length)throw new Error("No valid coverage points found");return e({coveragePoints:s.coveragePoints,repeaters:s.repeaters,stats:{coverageCount:s.coveragePoints.length,repeaterCount:s.repeaters.length,lastUpdated:new Date},status:"success",isVisible:!0,url:t.trim()}),$m(t.trim()),Xm(!0),!0}catch(n){const t=n instanceof Error?n.message:"Failed to load coverage data";let s=t;return t.includes("Failed to fetch")||t.includes("NetworkError")?s="Could not connect to server. Check the URL and try again.":t.includes("CORS")?s="Server does not allow cross-origin requests.":t.includes("404")&&(s="Coverage endpoint not found. Check the URL."),e({error:s,status:"error"}),!1}},clearCoverage:()=>{e({coveragePoints:[],repeaters:[],stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},status:"idle",error:null,isVisible:!1,url:""}),$m(""),Xm(!1)}}));function Ym(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}function Km(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}var Zm,Qm={},Jm={};var e_,t_,n_={};var s_,r_,i_=(t_||(t_=1,s_=function(){if(Zm)return Jm;Zm=1;var e=_();function t(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n