Files
pymc_console-dist/frontend/dist/assets/ContactsMapMapLibre-BsoXB40j.js
T
GitHub Actions Bot b86355e768 Sync build v0.9.69
Automated sync from private repository.
Commit: c692a066a1b1313daf1a017aa3dbee7a9c5762f2
2026-01-02 05:01:36 +00:00

2 lines
1.0 MiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var e,t,n=Object.defineProperty,r=(e,t,r)=>((e,t,r)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);import{c as i,j as s,K as o,a5 as a,X as A,_ as l,aj as c,ak as u,g as h,al as d}from"./index-DrB7gR15.js";import{b as f,g as p,c as g,r as m}from"./recharts-bmHCCfxU.js";import{u as _,a as b,P as v,S as y,L as w,M as x,N as E,b as T}from"./maplibre-gl-Ce8MxbYi.js";import{G as S,N as C,T as k,M as R,C as P}from"./Contacts-CJywlGuF.js";import{a as I,C as M,M as L}from"./HashBadge-Dx6rB1hw.js";import{L as N}from"./loader-circle-B2F7VDvf.js";import{I as B}from"./info-DLWJbESC.js";import{H as D}from"./house-BprJFl0C.js";import{R as O}from"./refresh-cw-FIL9dTez.js";import{N as F}from"./trending-up-BcsUDSmc.js";import{M as U}from"./map-B7L8rTxC.js";import{g as j}from"./maplibre-gl-CFO9X1Ek.js";import"./SignalIndicator-CN5IHoMH.js";import"./triangle-alert-C2MmhiQ5.js";import"./zap-D-peH-zg.js";import"./activity-D8CHUhXg.js";import"./PageLayout-C89FLGKJ.js";import"./users-7DSa13HD.js";const G=i("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"}]]),z=i("chart-no-axes-column",[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]]),V=i("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"}]]),W=i("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"}]]),H=i("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"}]]),$=i("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"}]]),X=i("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"}]]),Q=i("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"}]]),Y=i("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=i("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"}]]),K=i("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"}]]),Z=i("waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]);function J(e,t){const n=Math.max(5,Math.min(e,300)),r=Math.log(5),i=Math.log(300);return 1+(Math.log(n)-r)/(i-r)*5}const ee="#4338CA";function te({label:e,icon:t,status:n,detail:r}){return s.jsxs("div",{className:g("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:[s.jsx("div",{className:g("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?s.jsx(I,{className:"w-4 h-4 text-accent-success"}):"active"===n?s.jsx(N,{className:"w-4 h-4 animate-spin",style:{color:ee}}):s.jsx("span",{className:"text-text-muted",children:t})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:g("text-sm font-medium transition-colors","active"===n&&"text-[#4338CA]","complete"===n&&"text-accent-success","pending"===n&&"text-text-muted"),children:e}),r&&"pending"!==n&&s.jsx("div",{className:"text-xs text-text-muted mt-0.5 truncate",children:r})]})]})}const ne=f.memo(function({isOpen:e,currentStep:t,packetCount:n,onClose:r}){if(f.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&r&&r()};window.addEventListener("keydown",t);const n=document.body.style.overflow,i=document.body.style.position,s=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=i,document.body.style.width=s,document.body.style.top=o,window.scrollTo(0,a)}},[e,r]),!e)return null;const i="complete"===t,o=e=>{const n=["fetching","analyzing","building","complete"],r=n.indexOf(t),i=n.indexOf(e);return i<r?"complete":i===r?"active":"pending"};return p.createPortal(s.jsxs("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center",role:"dialog","aria-modal":"true","aria-labelledby":"deep-analysis-modal-title",children:[s.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),s.jsx("div",{className:"relative glass-card w-full max-w-sm mx-4 p-6 animate-in fade-in zoom-in-95 duration-200",style:{background:"rgba(20, 20, 22, 0.95)",border:"1px solid rgba(140, 160, 200, 0.15)"},children:i?s.jsxs("div",{className:"flex flex-col items-center py-6",children:[s.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 animate-in zoom-in-50 duration-300",style:{backgroundColor:"rgba(57, 217, 138, 0.2)"},children:s.jsx(I,{className:"w-8 h-8 text-accent-success"})}),s.jsx("h3",{className:"text-lg font-semibold text-accent-success",children:"Ready!"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{backgroundColor:"rgba(67, 56, 202, 0.15)"},children:s.jsx(S,{className:"w-5 h-5",style:{color:ee}})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Deep Analysis"}),s.jsx("p",{className:"text-xs text-text-muted",children:"Building mesh topology"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(te,{label:"Fetching Packets",icon:s.jsx($,{className:"w-4 h-4"}),status:o("fetching"),detail:n>0?`${n.toLocaleString()} packets`:"Loading database..."}),s.jsx(te,{label:"Analyzing Database",icon:s.jsx(H,{className:"w-4 h-4"}),status:o("analyzing"),detail:"Processing packet paths"}),s.jsx(te,{label:"Building Topology",icon:s.jsx(S,{className:"w-4 h-4"}),status:o("building"),detail:"Computing mesh edges"})]}),s.jsx("p",{className:"text-xs text-text-muted text-center mt-5",children:"This may take a few seconds..."})]})})]}),document.body)}),re="#4338CA",ie="#FBBF24",se="#6366F1",oe="#F97316",ae="#F59E0B",Ae="#FBBF24",le="#4B5563",ce="#6B7280",ue="#374151",he="#5EEAD4",de="#6366F1",fe="#9CA3AF",pe="#6B7280",ge="#FBBF24",me=2e3;function _e({text:e}){return s.jsxs("span",{className:"group relative cursor-help",children:[s.jsx(B,{className:"w-3 h-3 text-text-muted"}),s.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 be(e){const t=new Date(1e3*e);return`${(t.getMonth()+1).toString().padStart(2,"0")}/${t.getDate().toString().padStart(2,"0")}`}function ve({hash:e,hashPrefix:t,name:n,isHub:r,isZeroHop:i,isMobile:a,isRoomServer:A,isStale:l,lastSeenTimestamp:c,centrality:u,affinity:h,meanSnr:d,meanRssi:p,neighbor:g,onRemove:m,txDelayRec:_}){const[b,v]=f.useState(!1),y=i?"Direct":(null==h?void 0:h.typicalHopPosition)?`${h.typicalHopPosition}-hop`:null,w=[{label:"Packets",value:(null==h?void 0:h.frequency)||0},{label:"Adverts",value:g.advert_count||0}];i&&void 0!==d&&w.push({label:"SNR",value:`${d.toFixed(1)} dB`}),i&&void 0!==p&&w.push({label:"RSSI",value:`${Math.round(p)} dBm`});const x=_&&!_.insufficientData,E={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"}},T={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 s.jsxs("div",{className:"w-[220px] pr-3",children:[s.jsx("div",{className:"text-[14px] font-semibold text-text-primary leading-snug truncate mb-0.5",children:n}),s.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[s.jsx("code",{className:"font-mono text-[10px] text-text-muted/70 bg-white/5 px-1 py-px rounded",children:t}),s.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?s.jsx(I,{className:"w-2.5 h-2.5 text-accent-success"}):s.jsx(M,{className:"w-2.5 h-2.5 text-text-muted/50"})}),r&&s.jsx("span",{className:"px-1 py-px text-[8px] font-bold uppercase rounded",style:{backgroundColor:"#FBBF24",color:"#000"},children:"Hub"}),y&&s.jsx("span",{className:"px-1 py-px text-[8px] font-bold uppercase rounded",style:{backgroundColor:i?Ae:"rgba(255,255,255,0.08)",color:i?"#000":"rgba(255,255,255,0.5)"},children:y}),a&&s.jsx("span",{className:"px-1 py-px text-[8px] font-bold uppercase rounded bg-orange-500/25 text-orange-300",children:"Mobile"}),g.is_repeater&&s.jsx("span",{className:"px-1 py-px text-[8px] font-bold uppercase rounded bg-cyan-500/20 text-cyan-400",children:"Rptr"}),A&&s.jsx("span",{className:"px-1 py-px text-[8px] font-bold uppercase rounded bg-amber-500/25 text-amber-400",children:"Room"}),l&&c&&s.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 ",be(c)]})]}),s.jsxs("div",{className:"text-[10px] text-text-muted/60 mb-2 leading-tight",children:[s.jsx("span",{children:o(g.last_seen)}),(null==h?void 0:h.distanceMeters)&&s.jsxs("span",{className:"font-medium text-text-muted/80",children:[" · ",(S=h.distanceMeters,null===S?"—":S<1e3?`${Math.round(S)}m`:`${(S/1e3).toFixed(1)}km`)]}),g.latitude&&g.longitude&&0!==g.latitude&&0!==g.longitude&&s.jsxs("span",{className:"font-mono text-[9px]",children:[" · ",g.latitude.toFixed(4),", ",g.longitude.toFixed(4)]})]}),s.jsx("div",{className:"mb-2",children:s.jsx(C,{nodeHash:e,width:"100%",height:28,showArea:!0,showTooltip:!0})}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-[11px] mb-2",children:[w.map((e,t)=>s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-text-muted/50",children:e.label}),s.jsx("span",{className:"font-semibold tabular-nums "+("highlight"in e&&e.highlight?"text-amber-400":""),children:e.value})]},t)),x&&_.networkRole&&s.jsx(s.Fragment,{children:s.jsxs("div",{className:"flex items-center justify-between col-span-2 mt-1 pt-1 border-t border-white/5",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-text-muted/50",children:"Role"}),s.jsx("span",{className:`px-1.5 py-px text-[8px] font-bold uppercase rounded ${E[_.networkRole].bg} ${E[_.networkRole].text}`,title:E[_.networkRole].title,children:_.networkRole})]}),_.dataConfidence&&s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-text-muted/50",children:"Data"}),s.jsx("span",{className:`px-1.5 py-px text-[8px] font-bold uppercase rounded ${T[_.dataConfidence].bg} ${T[_.dataConfidence].text}`,title:T[_.dataConfidence].title,children:_.dataConfidence})]})]})})]}),(x||m)&&s.jsxs("div",{className:"pt-1.5 border-t border-white/5",children:[x&&s.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[s.jsx("span",{className:"text-text-muted/50",children:"TX Delay"}),s.jsxs("span",{className:"font-semibold tabular-nums text-amber-400",children:["×",(_.floodFactor??_.txDelayFactor).toFixed(1)]}),s.jsx("span",{className:"text-text-muted/30",children:"flood"}),s.jsxs("span",{className:"font-semibold tabular-nums text-amber-400",children:["×",(_.directFactor??_.directTxDelayFactor).toFixed(1)]}),s.jsx("span",{className:"text-text-muted/30",children:"direct"})]}),m&&s.jsx("div",{className:"flex justify-end "+(x?"mt-1.5":""),children:s.jsx("button",{onClick:m,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:s.jsx(k,{className:"w-3 h-3"})})})]})]});var S}function ye({showTopology:e,validatedPolylineCount:t,filteredNeighborCount:n,hasLocalNode:r,meshTopology:i,zeroHopNeighbors:o,neighborsWithLocation:a}){return s.jsxs("div",{className:"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)"},children:[s.jsxs("div",{className:"text-text-secondary font-medium mb-1.5 flex items-center gap-1",children:["Nodes",s.jsx(_e,{text:"Node type shown by shape/color. Yellow outer ring = direct RF neighbor."})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"12px",height:"12px",background:"transparent",border:`4px solid ${re}`,boxSizing:"border-box"}}),s.jsx("span",{className:"text-text-muted",children:"Node"}),s.jsx(_e,{text:"Standard mesh node. Can be a repeater, client, or companion device."})]}),i.gatewayNodes.length>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"12px",height:"12px",backgroundColor:re}}),s.jsx("span",{className:"text-text-muted",children:"Gateway"}),s.jsx(_e,{text:"Significant traffic forwarder (7-10% of last-hop traffic). Gateways relay substantial traffic to the local node."})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"12px",height:"12px",backgroundColor:se}}),s.jsx("span",{className:"text-text-muted",children:"Hub"}),s.jsx(_e,{text:"Network hub (≥10% of last-hop traffic). Hubs are central to mesh traffic flow and may use higher TX delays."})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(D,{className:"w-3 h-3 flex-shrink-0",style:{color:ie},strokeWidth:2.5}),s.jsx("span",{className:"text-text-muted",children:"Local"}),s.jsx(_e,{text:"Your repeater. This is the node running pyMC_Repeater that you're connected to."})]}),(A=a,A.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})&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(R,{className:"w-3 h-3 flex-shrink-0",style:{color:ae},strokeWidth:2.5}),s.jsx("span",{className:"text-text-muted",children:"Room"}),s.jsx(_e,{text:"Room Server identity. Hosts a chat room that clients can sync messages with."})]})),i.mobileNodes.length>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"12px",height:"12px",background:"transparent",border:`4px solid ${oe}`,boxSizing:"border-box"}}),s.jsx("span",{className:"text-text-muted",children:"Mobile"}),s.jsx(_e,{text:"Volatile node that frequently appears/disappears from paths. Likely a portable or vehicle-mounted device."})]}),o.size>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:"14px",height:"14px"},children:[s.jsx("div",{className:"absolute rounded-full",style:{top:"-2px",left:"-2px",width:"18px",height:"18px",background:"transparent",border:`2px solid ${Ae}`,boxSizing:"border-box",opacity:.85}}),s.jsx("div",{className:"absolute rounded-full",style:{top:"1px",left:"1px",width:"12px",height:"12px",background:"transparent",border:`4px solid ${re}`,boxSizing:"border-box"}})]}),s.jsx("span",{className:"text-text-muted",children:"Neighbor"}),s.jsx(_e,{text:"Zero-hop direct RF contact. We receive their ADVERTs directly without any relay hops."})]})]}),o.size>0&&s.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-white/10",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"flex-shrink-0",style:{width:"14px",height:"2px",backgroundImage:`repeating-linear-gradient(90deg, ${pe} 0, ${pe} 3px, transparent 3px, transparent 5px)`,borderRadius:"1px"}}),s.jsx("span",{className:"text-text-muted",children:"Neighbor"}),s.jsx(_e,{text:"Dashed gray → yellow on hover. Direct RF contact with local."})]})}),e&&t>0&&s.jsxs(s.Fragment,{children:[s.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",s.jsx(_e,{text:"Links with 5+ validations. Thickness = relative strength."})]}),s.jsxs("div",{className:"flex flex-col gap-0.5 text-text-muted",children:[s.jsxs("div",{className:"flex justify-between tabular-nums",children:[s.jsx("span",{children:"Nodes"}),s.jsx("span",{className:"text-text-secondary",children:n+(r?1:0)})]}),s.jsxs("div",{className:"flex justify-between tabular-nums",children:[s.jsx("span",{children:"Links"}),s.jsx("span",{className:"text-text-secondary",children:t})]}),i.hubNodes.length>0&&s.jsxs("div",{className:"flex justify-between tabular-nums",children:[s.jsx("span",{children:"Hubs"}),s.jsx("span",{style:{color:se},children:i.hubNodes.length})]})]}),s.jsxs("div",{className:"flex flex-col gap-1 mt-1.5 pt-1.5 border-t border-white/10",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"flex-shrink-0",style:{width:"14px",height:"3px",backgroundColor:le,borderRadius:"1px"}}),s.jsx("span",{className:"text-text-muted",children:"Link"}),s.jsx(_e,{text:"Gray at rest. Hover to reveal type (teal=direct, indigo=loop)."})]}),i.loops.length>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"flex-shrink-0 flex flex-col gap-0.5",style:{width:"14px"},children:[s.jsx("div",{style:{height:"2px",backgroundColor:le,borderRadius:"1px"}}),s.jsx("div",{style:{height:"2px",backgroundColor:le,borderRadius:"1px"}})]}),s.jsx("span",{className:"text-text-muted",children:"Redundant"})]})]}),i.loops.length>0&&s.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-white/10",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(O,{className:"w-3 h-3 flex-shrink-0",style:{color:de}}),s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("span",{style:{color:de},className:"font-medium",children:[i.loops.length," ",1===i.loops.length?"Loop":"Loops"]}),s.jsx("span",{className:"text-text-muted text-[10px] leading-tight",children:"Redundant paths"})]})]})})]})]});var A}const we={background:"rgba(20, 20, 22, 0.95)",borderRadius:"0.75rem",border:"1px solid rgba(140, 160, 200, 0.2)"},xe=(e,t=.4)=>({background:e,borderRadius:"0.75rem",border:`1px solid ${e.replace(/[\d.]+\)$/,`${t})`)}`});function Ee({isDeepLoading:e,showDeepAnalysisModal:t,onDeepAnalysis:n,showTopology:r,onToggleTopology:i,hasValidatedPolylines:o,showNeighborLines:a,onToggleNeighborLines:A,hasNeighborPolylines:l,showNodes:c,onToggleNodes:u,soloHubs:h,onToggleSoloHubs:d,hasHubNodes:f,soloDirect:p,onToggleSoloDirect:g,hasZeroHopNeighbors:m,isFullscreen:_,onToggleFullscreen:b}){return s.jsxs("div",{className:"absolute top-4 right-4 z-[600] flex gap-2",children:[s.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:we,title:"Deep Analysis - Load full packet history and rebuild topology",children:[s.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Deep Analysis"}),s.jsx(z,{className:"w-4 h-4 text-accent-primary"})]}),o&&s.jsx("button",{onClick:i,className:"p-2 transition-colors hover:bg-white/10",style:r?xe("rgba(74, 222, 128, 0.2)"):we,title:r?"Hide topology lines":"Show topology lines",children:r?s.jsx(S,{className:"w-4 h-4 text-green-400"}):s.jsx(Q,{className:"w-4 h-4 text-text-secondary"})}),l&&s.jsx("button",{onClick:A,className:"p-2 transition-colors hover:bg-white/10",style:a?{...we,background:"rgba(251, 191, 36, 0.2)",border:"1px solid rgba(251, 191, 36, 0.4)"}:we,title:a?"Hide neighbor lines":"Show neighbor lines",children:s.jsx(Z,{className:"w-4 h-4 "+(a?"text-amber-400":"text-text-secondary")})}),s.jsx("button",{onClick:u,className:"p-2 transition-colors hover:bg-white/10",style:c?{...we,background:"rgba(99, 102, 241, 0.2)",border:"1px solid rgba(99, 102, 241, 0.4)"}:we,title:c?"Hide all nodes":"Show all nodes",children:c?s.jsx(L,{className:"w-4 h-4 text-indigo-400"}):s.jsx(Q,{className:"w-4 h-4 text-text-secondary"})}),f&&s.jsx("button",{onClick:d,className:"p-2 transition-colors hover:bg-white/10",style:h?{...we,background:"rgba(251, 191, 36, 0.25)",border:"1px solid rgba(251, 191, 36, 0.5)"}:we,title:h?"Show all nodes":"Solo hubs & connections",children:s.jsx(F,{className:"w-4 h-4 "+(h?"text-amber-400":"text-text-secondary")})}),m&&s.jsx("button",{onClick:g,className:"p-2 transition-colors hover:bg-white/10",style:p?{...we,background:"rgba(67, 56, 202, 0.35)",border:"1px solid rgba(67, 56, 202, 0.6)"}:we,title:p?"Show all nodes":"Solo direct (0-hop) nodes",children:s.jsx(V,{className:"w-4 h-4 "+(p?"text-indigo-400":"text-text-secondary")})}),s.jsx("button",{onClick:b,className:"p-2 transition-colors hover:bg-white/10",style:we,title:_?"Exit fullscreen":"Fullscreen",children:_?s.jsx(K,{className:"w-4 h-4 text-text-secondary"}):s.jsx(q,{className:"w-4 h-4 text-text-secondary"})})]})}function Te({isActive:e,onClick:t}){return s.jsxs("button",{onClick:t,className:"flex items-center gap-2 w-full text-left transition-colors hover:bg-white/5",style:{padding:"0.5rem 0.625rem",borderRadius:"0.75rem",background:e?"rgba(245, 158, 11, 0.15)":"rgba(20, 20, 22, 0.95)",border:e?"1px solid rgba(245, 158, 11, 0.4)":"1px solid rgba(140, 160, 200, 0.2)"},title:e?"Configure wardriving coverage":"Show wardriving coverage",children:[s.jsx(G,{className:"w-3.5 h-3.5 flex-shrink-0 "+(e?"text-amber-400":"text-text-secondary")}),s.jsx("span",{className:"text-xs font-medium "+(e?"text-amber-400":"text-text-secondary"),children:"Wardrive"})]})}function Se(e){let t=!0,n=-90,r=90,i=-180,s=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=(i+s)/2;a?i=e:s=e}else{const e=(n+r)/2;a?n=e:r=e}t=!t}}return{lat:(n+r)/2,lon:(i+s)/2}}function Ce(e){return Math.exp(-e*Math.LN2/7)}const ke="pymc-wardriving-url",Re="pymc-wardriving-enabled";function Pe(e){"undefined"!=typeof localStorage&&(e?localStorage.setItem(ke,e):localStorage.removeItem(ke))}function Ie(e){"undefined"!=typeof localStorage&&localStorage.setItem(Re,String(e))}function Me(e,t=null){if(null!==e){const n=(Math.max(-12,Math.min(12,e))+12)/24;return null!==t?.8*n+(Math.max(-120,Math.min(-50,t))+120)/70*.2:n}return null!==t?(Math.max(-120,Math.min(-50,t))+120)/70:.5}const Le=a((e,t)=>({status:"idle",isVisible:"undefined"!=typeof localStorage&&"true"===localStorage.getItem(Re),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:"undefined"==typeof localStorage?"":localStorage.getItem(ke)||"",isModalOpen:!1,openModal:()=>e({isModalOpen:!0}),closeModal:()=>e({isModalOpen:!1}),setUrl:t=>e({url:t}),toggleVisibility:()=>{const n=!t().isVisible;Ie(n),e({isVisible:n})},setVisible:t=>{Ie(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(/\/+$/,"").replace(/\/get-nodes$/,"").replace(/\/get-samples$/,"")}/get-samples`,n=await fetch(t,{headers:{Accept:"application/json"}});if(!n.ok)throw new Error(`Failed to fetch precise samples: ${n.status}`);return n.json()}(t.trim());if(!n||"object"!=typeof n)throw new Error("Invalid response from server");if(!Array.isArray(n.keys))throw new Error("No sample data found in response");e({status:"processing"});const r=function(e){var t;const n=[];for(const r of e.keys){if(!r.observed)continue;const{lat:e,lon:i}=Se(r.hash),s=parseInt(r.time,10),o=isNaN(s)?30:(Date.now()-s)/864e5,a=Ce(o),A=Me(r.snr,r.rssi)*(.3+.7*a);n.push({lat:e,lon:i,successRate:r.observed?1:0,weight:A,totalSamples:1,ageDays:o,geohash:r.hash,repeaters:(null==(t=r.path)?void 0:t.map(e=>e.toLowerCase()))||[]})}return n}(n);if(0===r.length)throw new Error("No valid coverage points found");return e({coveragePoints:r,repeaters:[],stats:{coverageCount:r.length,repeaterCount:0,lastUpdated:new Date},status:"success",isVisible:!0,url:t.trim()}),Pe(t.trim()),Ie(!0),!0}catch(n){const t=n instanceof Error?n.message:"Failed to load coverage data";let r=t;return t.includes("Failed to fetch")||t.includes("NetworkError")?r="Could not connect to server. Check the URL and try again.":t.includes("CORS")?r="Server does not allow cross-origin requests.":t.includes("404")&&(r="Coverage endpoint not found. Check the URL."),e({error:r,status:"error"}),!1}},clearCoverage:()=>{e({coveragePoints:[],repeaters:[],stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},status:"idle",error:null,isVisible:!1,url:""}),Pe(""),Ie(!1)}}));function Ne({status:e}){if("connecting"!==e&&"loading"!==e&&"processing"!==e)return null;const t={idle:"",connecting:"Connecting to server...",loading:"Fetching coverage data...",processing:"Processing coverage points...",success:"",error:""}[e];return t?s.jsxs("div",{className:"flex items-center gap-3 p-4 bg-amber-500/10 border border-amber-500/30 rounded-xl",children:[s.jsx("div",{className:"relative",children:s.jsx(N,{className:"w-5 h-5 text-amber-400 animate-spin"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-amber-400 font-medium",children:t}),s.jsx("div",{className:"mt-2 h-1 bg-amber-500/20 rounded-full overflow-hidden",children:s.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 Be(){const{isModalOpen:e,closeModal:t,status:n,isVisible:r,stats:i,error:o,url:a,loadCoverage:l,clearCoverage:c,toggleVisibility:u,setUrl:h}=Le(),d="connecting"===n||"loading"===n||"processing"===n,[p,g]=f.useState(a),m=f.useCallback(async()=>{await l(p)},[p,l]),_=f.useCallback(()=>{g(""),c()},[c]),b=f.useCallback(e=>{"Enter"!==e.key||e.shiftKey||d||(e.preventDefault(),m())},[m,d]),v=f.useCallback(e=>{const t=e.target.value;g(t),h(t)},[h]);if(!e)return null;const y=i.coverageCount>0,w=p.trim().length>0&&!d;return s.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:d?void 0:t}),s.jsxs("div",{className:"relative bg-surface border border-border rounded-2xl shadow-2xl w-full max-w-md mx-4 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-amber-500/20",children:s.jsx(G,{className:"w-5 h-5 text-amber-400"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Wardriving Coverage"}),s.jsx("p",{className:"text-xs text-text-muted",children:"Overlay RF coverage heatmap"})]})]}),s.jsx("button",{onClick:t,disabled:d,className:"p-2 rounded-lg hover:bg-white/10 transition-colors disabled:opacity-50",children:s.jsx(A,{className:"w-5 h-5 text-text-secondary"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Coverage Server URL"}),s.jsx("input",{type:"url",value:p,onChange:v,onKeyDown:b,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:d}),s.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)"})]}),s.jsx(Ne,{status:n}),"error"===n&&o&&s.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/30 rounded-xl",children:[s.jsx(W,{className:"w-5 h-5 text-red-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-red-400 font-medium",children:"Connection Failed"}),s.jsx("p",{className:"text-xs text-red-400/80 mt-0.5",children:o})]})]}),"success"===n&&y&&s.jsxs("div",{className:"flex items-start gap-3 p-3 bg-green-500/10 border border-green-500/30 rounded-xl",children:[s.jsx(I,{className:"w-5 h-5 text-green-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-green-400 font-medium",children:"Data Loaded Successfully"}),s.jsxs("p",{className:"text-xs text-green-400/80 mt-0.5",children:[i.coverageCount.toLocaleString()," coverage points • ",i.repeaterCount.toLocaleString()," repeaters"]})]})]}),y&&!d&&"success"!==n&&s.jsxs("div",{className:"flex items-start gap-3 p-3 bg-amber-500/10 border border-amber-500/30 rounded-xl",children:[s.jsx(U,{className:"w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-amber-400 font-medium",children:"Coverage Data Loaded"}),s.jsxs("p",{className:"text-xs text-amber-400/80 mt-0.5",children:[i.coverageCount.toLocaleString()," points •",i.lastUpdated&&` Last updated ${i.lastUpdated.toLocaleTimeString()}`]})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3 p-4 border-t border-border bg-black/20",children:[s.jsx("div",{className:"flex items-center gap-2",children:y&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:u,disabled:d,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:r?"Hide heatmap":"Show heatmap",children:r?s.jsxs(s.Fragment,{children:[s.jsx(Q,{className:"w-3.5 h-3.5"})," Hide"]}):s.jsxs(s.Fragment,{children:[s.jsx(Y,{className:"w-3.5 h-3.5"})," Show"]})}),s.jsxs("button",{onClick:_,disabled:d,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:[s.jsx(k,{className:"w-3.5 h-3.5"})," Clear"]})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:t,disabled:d,className:"px-4 py-2 text-sm font-medium text-text-secondary hover:bg-white/10 rounded-lg transition-colors disabled:opacity-50",children:y?"Done":"Cancel"}),s.jsx("button",{onClick:m,disabled:!w,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:d?s.jsxs(s.Fragment,{children:[s.jsx(N,{className:"w-4 h-4 animate-spin"}),"Loading..."]}):y?s.jsxs(s.Fragment,{children:[s.jsx($,{className:"w-4 h-4"}),"Refresh"]}):s.jsxs(s.Fragment,{children:[s.jsx(X,{className:"w-4 h-4"}),"Connect"]})})]})]})]})]})}function De(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const Oe=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Fe="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Fe&&parseFloat(Fe[1]);const Ue=globalThis,je=globalThis.process||{},Ge=globalThis.navigator||{};function ze(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 r="undefined"!=typeof navigator&&navigator.userAgent;return Boolean(r&&r.indexOf("Electron")>=0)}function Ve(){return!("object"==typeof process&&"[object process]"===String(process)&&!(null==process?void 0:process.browser))||ze()}const We="4.1.0";class He{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(ys){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 $e,Xe;function Qe(e){return"string"!=typeof e?e:(e=e.toUpperCase(),$e[e]||$e.WHITE)}function Ye(e,t){if(!e)throw new Error("Assertion failed")}function qe(){var e,t,n;let r;if(Ve()&&Ue.performance)r=null==(t=null==(e=null==Ue?void 0:Ue.performance)?void 0:e.now)?void 0:t.call(e);else if("hrtime"in je){const e=null==(n=null==je?void 0:je.hrtime)?void 0:n.call(je);r=1e3*e[0]+e[1]/1e6}else r=Date.now();return r}(Xe=$e||($e={}))[Xe.BLACK=30]="BLACK",Xe[Xe.RED=31]="RED",Xe[Xe.GREEN=32]="GREEN",Xe[Xe.YELLOW=33]="YELLOW",Xe[Xe.BLUE=34]="BLUE",Xe[Xe.MAGENTA=35]="MAGENTA",Xe[Xe.CYAN=36]="CYAN",Xe[Xe.WHITE=37]="WHITE",Xe[Xe.BRIGHT_BLACK=90]="BRIGHT_BLACK",Xe[Xe.BRIGHT_RED=91]="BRIGHT_RED",Xe[Xe.BRIGHT_GREEN=92]="BRIGHT_GREEN",Xe[Xe.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",Xe[Xe.BRIGHT_BLUE=94]="BRIGHT_BLUE",Xe[Xe.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",Xe[Xe.BRIGHT_CYAN=96]="BRIGHT_CYAN",Xe[Xe.BRIGHT_WHITE=97]="BRIGHT_WHITE";const Ke={debug:Ve()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Ze={enabled:!0,level:0};function Je(){}const et={},tt={once:!0};class nt{constructor({id:e}={id:""}){this.VERSION=We,this._startTs=qe(),this._deltaTs=qe(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new He(`__probe-${this.id}__`,Ze),this.timeStamp(`${this.id} started`),function(e,t=["constructor"]){const n=Object.getPrototypeOf(e),r=Object.getOwnPropertyNames(n),i=e;for(const s of r){const n=i[s];"function"==typeof n&&(t.find(e=>s===e)||(i[s]=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((qe()-this._startTs).toPrecision(10))}getDelta(){return Number((qe()-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,Ke.warn,arguments,tt)}error(e){return this._getLogFunction(0,e,Ke.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,Ke.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Ke.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Ke.debug||Ke.info,arguments,tt)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||Je,n&&[n],{tag:st(t)}):Je}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||Je)}group(e,t,n={collapsed:!1}){const r=it({logLevel:e,message:t,opts:n}),{collapsed:i}=n;return r.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(r)}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Je)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=rt(e)}_getLogFunction(e,t,n,r,i){if(this._shouldLog(e)){i=it({logLevel:e,message:t,args:r,opts:i}),Ye(n=n||i.method),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=qe();const s=i.tag||i.message;if(i.once&&s){if(et[s])return Je;et[s]=qe()}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)):"";r=t=n.time?`${e}: ${o} ${t}`:`${e}: ${t}`,i=n.color,s=n.background,Ve||"string"!=typeof r||(i&&(r=`[${Qe(i)}m${r}`),s&&(r=`[${Qe(s)+10}m${r}`)),t=r}var r,i,s;return t}(this.id,i.message,i),n.bind(console,t,...i.args)}return Je}}function rt(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 Ye(Number.isFinite(t)&&t>=0),t}function it(e){const{logLevel:t,message:n}=e;e.logLevel=rt(t);const r=e.args?Array.from(e.args):[];for(;r.length&&r.shift()!==n;);switch(typeof t){case"string":case"function":void 0!==n&&r.unshift(n),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const i=typeof e.message;return Ye("string"===i||"object"===i),Object.assign(e,{args:r},e.opts)}function st(e){for(const t in e)for(const n in e[t])return n||"untitled";return"empty"}nt.VERSION=We;const ot="4.3.3",at=ot[0]>="0"&&ot[0]<="9"?`v${ot}`:"",At=function(){const e=new nt({id:"loaders.gl"});return globalThis.loaders=globalThis.loaders||{},globalThis.loaders.log=e,globalThis.loaders.version=at,globalThis.probe=globalThis.probe||{},globalThis.probe.loaders=e,e}();function lt(e,t){return ct(e||{},t)}function ct(e,t,n=0){if(n>3)return t;const r={...e};for(const[i,s]of Object.entries(t))s&&"object"==typeof s&&!Array.isArray(s)?r[i]=ct(r[i]||{},t[i],n+1):r[i]=t[i];return r}var ut;function ht(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(null==(ut=globalThis._loadersgl_)?void 0:ut.version)||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version;const dt="object"!=typeof process||"[object process]"!==String(process)||process.browser,ft="undefined"!=typeof window&&void 0!==window.orientation,pt="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);pt&&parseFloat(pt[1]);class gt{constructor(e,t){r(this,"name"),r(this,"workerThread"),r(this,"isRunning",!0),r(this,"result"),r(this,"_resolve",()=>{}),r(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){ht(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){ht(this.isRunning),this.isRunning=!1,this._reject(e)}}class mt{terminate(){}}const _t=new Map;function bt(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function vt(e,t=!0,n){const r=n||new Set;if(e)if(yt(e))r.add(e);else if(yt(e.buffer))r.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)vt(e[i],t,r);return void 0===n?Array.from(r):[]}function yt(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 wt=()=>{};class xt{constructor(e){r(this,"name"),r(this,"source"),r(this,"url"),r(this,"terminated",!1),r(this,"worker"),r(this,"onMessage"),r(this,"onError"),r(this,"_loadableURL","");const{name:t,source:n,url:i}=e;ht(n||i),this.name=t,this.source=n,this.url=i,this.onMessage=wt,this.onError=e=>{},this.worker=dt?this._createBrowserWorker():this._createNodeWorker()}static isSupported(){return"undefined"!=typeof Worker&&dt||void 0!==mt&&!dt}destroy(){this.onMessage=wt,this.onError=wt,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||vt(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){ht(e.source&&!e.url||!e.source&&e.url);let t=_t.get(e.source||e.url);return t||(e.url&&(t=(n=e.url).startsWith("http")?bt(`try {\n importScripts('${n}');\n} catch (error) {\n console.error(error);\n throw error;\n}`):n,_t.set(e.url,t)),e.source&&(t=bt(e.source),_t.set(e.source,t))),ht(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 mt(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new mt(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 Et{constructor(e){r(this,"name","unnamed"),r(this,"source"),r(this,"url"),r(this,"maxConcurrency",1),r(this,"maxMobileConcurrency",1),r(this,"onDebug",()=>{}),r(this,"reuseWorkers",!0),r(this,"props",{}),r(this,"jobQueue",[]),r(this,"idleQueue",[]),r(this,"count",0),r(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}static isSupported(){return xt.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 r=new Promise(r=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:r}),this));return this._startQueuedJob(),await r}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 r=new gt(t.name,e);e.onMessage=e=>t.onMessage(r,e.type,e.payload),e.onError=e=>t.onError(r,e),t.onStart(r);try{await r.result}catch(n){}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!dt||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<this._getMaxConcurrency()){this.count++;const e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new xt({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return ft?this.maxMobileConcurrency:this.maxConcurrency}}const Tt={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},St=class e{constructor(e){r(this,"props"),r(this,"workerPools",new Map),this.props={...Tt},this.setProps(e),this.workerPools=new Map}static isSupported(){return xt.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:r}=e;let i=this.workerPools.get(t);return i||(i=new Et({name:t,source:n,url:r}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};r(St,"_workerFarm");let Ct=St;async function kt(e,t,n,r,i){const s=e.id,o=function(e,t={}){const n=t[e.id]||{},r=dt?`${e.id}-worker.js`:`${e.id}-worker-node.js`;let i=n.workerUrl;if(i||"compression"!==e.id||(i=t.workerUrl),"test"===t._workerType&&(i=dt?`modules/${e.module}/dist/${r}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!i){let t=e.version;"latest"===t&&(t="latest");const n=t?`@${t}`:"";i=`https://unpkg.com/@loaders.gl/${e.module}${n}/dist/${r}`}return ht(i),i}(e,n),a=Ct.getWorkerFarm(n).getWorkerPool({name:s,url:o});n=JSON.parse(JSON.stringify(n)),r=JSON.parse(JSON.stringify(r||{}));const A=await a.startJob("process-on-worker",Rt.bind(null,i));A.postMessage("process",{input:t,options:n,context:r});const l=await A.result;return await l.result}async function Rt(e,t,n,r){switch(n){case"done":t.done(r);break;case"error":t.error(new Error(r.error));break;case"process":const{id:n,input:s,options:o}=r;try{const r=await e(s,o);t.postMessage("done",{id:n,result:r})}catch(i){const e=i instanceof Error?i.message:"unknown error";t.postMessage("error",{id:n,error:e})}}}function Pt(){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 It{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=Pt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Pt()-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 Mt{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 r=this.stats[t];return r||(r=e instanceof It?e:new It(t,n),this.stats[t]=r),r}}const Lt={};function Nt(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 Bt(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}const Dt=e=>"function"==typeof e,Ot=e=>null!==e&&"object"==typeof e,Ft=e=>Ot(e)&&e.constructor==={}.constructor,Ut=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,jt=e=>"undefined"!=typeof Blob&&e instanceof Blob,Gt=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||Ot(e)&&Dt(e.tee)&&Dt(e.cancel)&&Dt(e.getReader))(e)||(e=>Ot(e)&&Dt(e.read)&&Dt(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e);class zt extends Error{constructor(e,t){super(e),r(this,"reason"),r(this,"url"),r(this,"response"),this.reason=t.reason,this.url=t.url,this.response=t.response}}const Vt=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Wt=/^([-\w.]+\/[-\w.+]+)/;function Ht(e,t){return e.toLowerCase()===t.toLowerCase()}function $t(e){const t=Vt.exec(e);return t?t[1]:""}const Xt=/\?.*/;function Qt(e){return e.replace(Xt,"")}function Yt(e){return Ut(e)?e.url:jt(e)?e.name||"":"string"==typeof e?e:""}function qt(e){if(Ut(e)){const t=e,n=t.headers.get("content-type")||"",r=Qt(t.url);return function(e){const t=Wt.exec(e);return t?t[1]:e}(n)||$t(r)}return jt(e)?e.type||"":"string"==typeof e?$t(e):""}async function Kt(e){if(Ut(e))return e;const t={},n=function(e){return Ut(e)?e.headers["content-length"]||-1:jt(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 r=Yt(e),i=qt(e);i&&(t["content-type"]=i);const s=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 r=0;r<n.byteLength;r++)t+=String.fromCharCode(n[r]);return btoa(t)}(e.slice(0,5))}`:null}(e);s&&(t["x-first-bytes"]=s),"string"==typeof e&&(e=(new TextEncoder).encode(e));const o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:r}),o}async function Zt(e,t){var n,r;if("string"==typeof e){const i=function(e){for(const t in Lt)if(e.startsWith(t)){const n=Lt[t];e=e.replace(t,n)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${e}`),e}(e);return function(e){return!function(e){return e.startsWith("http:")||e.startsWith("https:")}(e)&&!function(e){return e.startsWith("data:")}(e)}(i)&&(null==(n=globalThis.loaders)?void 0:n.fetchNode)?null==(r=globalThis.loaders)?void 0:r.fetchNode(i,t):await fetch(i,t)}return await Kt(e)}const Jt=new nt({id:"loaders.gl"});class en{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const tn={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){r(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:Oe,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},nn={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 rn(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function sn(){const e=rn();return e.globalOptions=e.globalOptions||{...tn},e.globalOptions}function on(e,t,n,r,i){const s=t||"Top level",o=t?`${t}.`:"";for(const a in e){const A=!t&&Ot(e[a]);if(!(a in n)&&("baseUri"!==a||t)&&("workerUrl"!==a||!t))if(a in r)Jt.warn(`${s} loader option '${o}${a}' no longer supported, use '${r[a]}'`)();else if(!A){const e=an(a,i);Jt.warn(`${s} loader option '${o}${a}' not recognized. ${e}`)()}}}function an(e,t){const n=e.toLowerCase();let r="";for(const i of t)for(const t in i.options){if(e===t)return`Did you mean '${i.id}.${t}'?`;const s=t.toLowerCase();(n.startsWith(s)||s.startsWith(n))&&(r=r||`Did you mean '${i.id}.${t}'?`)}return r}function An(e,t){for(const n in t)if(n in t){const r=t[n];Ft(r)&&Ft(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function ln(e){return!!e&&(Array.isArray(e)&&(e=e[0]),Array.isArray(null==e?void 0:e.extensions))}function cn(e){let t;return De(e,"null loader"),De(ln(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 un=()=>{const e=rn();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry},hn=/\.([^.]+)$/;function dn(e,t=[],n,r){if(!fn(e))return null;if(t&&!Array.isArray(t))return cn(t);let i=[];t&&(i=i.concat(t)),(null==n?void 0:n.ignoreRegisteredLoaders)||i.push(...un()),function(e){for(const t of e)cn(t)}(i);const s=function(e,t,n,r){const i=Yt(e),s=qt(e),o=Qt(i)||(null==r?void 0:r.url);let a=null,A="";return(null==n?void 0:n.mimeType)&&(a=gn(t,null==n?void 0:n.mimeType),A=`match forced by supplied MIME type ${null==n?void 0:n.mimeType}`),a=a||function(e,t){const n=t&&hn.exec(t),r=n&&n[1];return r?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,r):null}(t,o),A=A||(a?`matched url ${o}`:""),a=a||gn(t,s),A=A||(a?`matched MIME type ${s}`:""),a=a||function(e,t){if(!t)return null;for(const n of e)if("string"==typeof t){if(mn(t,n))return n}else if(ArrayBuffer.isView(t)){if(_n(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer&&_n(t,0,n))return n;return null}(t,e),A=A||(a?`matched initial data ${bn(e)}`:""),(null==n?void 0:n.fallbackMimeType)&&(a=a||gn(t,null==n?void 0:n.fallbackMimeType),A=A||(a?`matched fallback MIME type ${s}`:"")),A&&At.log(1,`selectLoader selected ${null==a?void 0:a.name}: ${A}.`),a}(e,i,n,r);if(!s&&!(null==n?void 0:n.nothrow))throw new Error(pn(e));return s}function fn(e){return!(e instanceof Response&&204===e.status)}function pn(e){const t=Yt(e),n=qt(e);let r="No valid loader found (";r+=t?`${Bt(t)}, `:"no url provided, ",r+=`MIME type: ${n?`"${n}"`:"not provided"}, `;const i=e?bn(e):"";return r+=i?` first bytes: "${i}"`:"first bytes: not available",r+=")",r}function gn(e,t){var n;for(const r of e){if(null==(n=r.mimeTypes)?void 0:n.some(e=>Ht(t,e)))return r;if(Ht(t,`application/x.${r.id}`))return r}return null}function mn(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function _n(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(n=>function(e,t,n,r){if(r instanceof ArrayBuffer)return function(e,t,n){if(n=n||e.byteLength,e.byteLength<n||t.byteLength<n)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let s=0;s<r.length;++s)if(r[s]!==i[s])return!1;return!0}(r,e,r.byteLength);switch(typeof r){case"function":return r(e);case"string":return r===vn(e,t,r.length);default:return!1}}(e,t,0,n))}function bn(e,t=5){return"string"==typeof e?e.slice(0,t):ArrayBuffer.isView(e)?vn(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?vn(e,0,t):""}function vn(e,t,n){if(e.byteLength<t+n)return"";const r=new DataView(e);let i="";for(let s=0;s<n;s++)i+=String.fromCharCode(r.getUint8(t+s));return i}const yn=262144;function wn(e,t){return Oe?async function*(e,t){const n=e.getReader();let r;try{for(;;){const e=r||n.read();(null==t?void 0:t._streamReadAhead)&&(r=n.read());const{done:i,value:s}=await e;if(i)return;yield Nt(s)}}catch(i){n.releaseLock()}}(e,t):async function*(e){for await(const t of e)yield Nt(t)}(e)}const xn="Cannot convert supplied data type";async function En(e,t,n){const r=e instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||r)return function(e,t){if(t.text&&"string"==typeof e)return e;var n;if((n=e)&&"object"==typeof n&&n.isBuffer&&(e=e.buffer),e instanceof ArrayBuffer){const n=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(n):n}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let n=e.buffer;const r=e.byteLength||e.length;return 0===e.byteOffset&&r===n.byteLength||(n=n.slice(e.byteOffset,e.byteOffset+r)),n}throw new Error(xn)}(e,t);if(jt(e)&&(e=await Kt(e)),Ut(e)){const n=e;return await async function(e){if(!e.ok){const t=await async function(e){const n=function(e){if(e.length<50)return e;const t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}(e.url);let r=`Failed to fetch resource (${e.status}) ${e.statusText}: ${n}`;r=r.length>100?`${r.slice(0,100)}...`:r;const i={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");i.reason=!e.bodyUsed&&(null==t?void 0:t.includes("application/json"))?await e.json():await e.text()}catch(t){}return new zt(r,i)}(e);throw t}}(n),t.binary?await n.arrayBuffer():await n.text()}if(Gt(e)&&(e=function(e,t){if("string"==typeof e)return function*(e,t){const n=(null==t?void 0:t.chunkSize)||262144;let r=0;const i=new TextEncoder;for(;r<e.length;){const t=Math.min(e.length-r,n),s=e.slice(r,r+t);r+=t,yield i.encode(s)}}(e,t);if(e instanceof ArrayBuffer)return function*(e,t={}){const{chunkSize:n=yn}=t;let r=0;for(;r<e.byteLength;){const t=Math.min(e.byteLength-r,n),i=new ArrayBuffer(t),s=new Uint8Array(e,r,t);new Uint8Array(i).set(s),r+=t,yield i}}(e,t);if(jt(e))return async function*(e,t){const n=(null==t?void 0:t.chunkSize)||1048576;let r=0;for(;r<e.size;){const t=r+n,i=await e.slice(r,t).arrayBuffer();r=t,yield i}}(e,t);if(Gt(e))return wn(e,t);if(Ut(e))return wn(e.body,t);throw new Error("makeIterator")}(e,n)),i=e,Boolean(i)&&"function"==typeof i[Symbol.iterator]||(e=>e&&"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),r=new Uint8Array(n);let i=0;for(const s of t)r.set(s,i),i+=s.byteLength;return r.buffer}(e)}(...t)}(e);var i;throw new Error(xn)}function Tn(e,t){const n=sn(),r=e||n;return"function"==typeof r.fetch?r.fetch:Ot(r.fetch)?e=>Zt(e,r.fetch):(null==t?void 0:t.fetch)?null==t?void 0:t.fetch:Zt}async function Sn(e,t,n,r){!t||Array.isArray(t)||ln(t)||(r=void 0,n=t,t=void 0),n=n||{};const i=Yt(e=await e),s=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,r),o=await async function(e,t=[],n,r){if(!fn(e))return null;let i=dn(e,t,{...n,nothrow:!0},r);if(i)return i;if(jt(e)&&(i=dn(e=await e.slice(0,10).arrayBuffer(),t,n,r)),!i&&!(null==n?void 0:n.nothrow))throw new Error(pn(e));return i}(e,s,n);return o?(r=function(e,t,n){if(n)return n;const r={fetch:Tn(t,e),...e};if(r.url){const e=Qt(r.url);r.baseUrl=e,r.queryString=function(e){const t=e.match(Xt);return t&&t[0]}(r.url),r.filename=Bt(e),r.baseUrl=function(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}(e)}return Array.isArray(r.loaders)||(r.loaders=null),r}({url:i,_parse:Sn,loaders:s},n=function(e,t,n,r){return n=n||[],function(e,t){on(e,null,tn,nn,t);for(const n of t){const r=e&&e[n.id]||{},i=n.options&&n.options[n.id]||{},s=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};on(r,n.id,i,s,t)}}(e,n=Array.isArray(n)?n:[n]),function(e,t,n){const r={...e.options||{}};return function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)}(r,n),null===r.log&&(r.log=new en),An(r,sn()),An(r,t),r}(t,e,r)}(n,o,s,i),r||null),await async function(e,t,n,r){if(function(e){ht(e,"no worker provided");e.version}(e),n=lt(e.options,n),Ut(t)){const e=t,{ok:n,redirected:i,status:s,statusText:o,type:a,url:A}=e,l=Object.fromEntries(e.headers.entries());r.response={headers:l,ok:n,redirected:i,status:s,statusText:o,type:a,url:A}}t=await En(t,e,n);const i=e;if(i.parseTextSync&&"string"==typeof t)return i.parseTextSync(t,n,r);if(function(e,t){return!!Ct.isSupported()&&!(!dt&&!(null==t?void 0:t._nodeWorkers))&&e.worker&&(null==t?void 0:t.worker)}(e,n))return await kt(e,t,n,r,Sn);if(i.parseText&&"string"==typeof t)return await i.parseText(t,n,r);if(i.parse)return await i.parse(t,n,r);throw ht(!i.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(o,e,n,r)):null}async function Cn(e,t,n,r){let i,s;Array.isArray(t)||ln(t)?(i=t,s=n):(i=[],s=t);const o=Tn(s);let a=e;return"string"==typeof e&&(a=await o(e)),jt(e)&&(a=await o(e)),Array.isArray(i),await Sn(a,i,s)}const kn=null==(e=globalThis.loaders)?void 0:e.parseImageNode,Rn="undefined"!=typeof Image,Pn="undefined"!=typeof ImageBitmap,In=Boolean(kn),Mn=!!Oe||In;const Ln=/^data:image\/svg\+xml/,Nn=/\.svg((\?|#).*)?$/;function Bn(e){return e&&(Ln.test(e)||Nn.test(e))}function Dn(e,t){if(Bn(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function On(e,t,n){const r=function(e,t){if(Bn(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 Dn(e,t)}(e,n),i=self.URL||self.webkitURL,s="string"!=typeof r&&i.createObjectURL(r);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(r){t(r)}})}(s||r,t)}finally{s&&i.revokeObjectURL(s)}}const Fn={};let Un=!0;const jn=!1,Gn=!0;function zn(e){const t=Vn(e);return function(e){const t=Vn(e);return t.byteLength>=24&&2303741511===t.getUint32(0,jn)?{mimeType:"image/png",width:t.getUint32(16,jn),height:t.getUint32(20,jn)}:null}(t)||function(e){const t=Vn(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,jn)&&255===t.getUint8(2)))return null;const{tableMarkers:n,sofMarkers:r}=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 i=2;for(;i+9<t.byteLength;){const e=t.getUint16(i,jn);if(r.has(e))return{mimeType:"image/jpeg",height:t.getUint16(i+5,jn),width:t.getUint16(i+7,jn)};if(!n.has(e))return null;i+=2,i+=t.getUint16(i,jn)}return null}(t)||function(e){const t=Vn(e);return t.byteLength>=10&&1195984440===t.getUint32(0,jn)?{mimeType:"image/gif",width:t.getUint16(6,Gn),height:t.getUint16(8,Gn)}:null}(t)||function(e){const t=Vn(e);return t.byteLength>=14&&16973===t.getUint16(0,jn)&&t.getUint32(2,Gn)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,Gn),height:t.getUint32(22,Gn)}:null}(t)||function(e){const t=function(e){return function(e,t,n=0){const r=(i="ftyp",[...i].map(e=>e.charCodeAt(0)));var i;for(let s=0;s<r.length;++s)if(r[s]!==e[s+n])return!1;return!0}(e,0,4)&&96&e[8]?function(e){switch((t=e,String.fromCharCode(...t.slice(8,12))).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}var t}(e):null}(new Uint8Array(e instanceof DataView?e.buffer:e));return t?{mimeType:t.mimeType,width:0,height:0}:null}(t)}function Vn(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const Wn={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:"4.3.3",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],parse:async function(e,t,n){const r=((t=t||{}).image||{}).type||"auto",{url:i}=n||{};let s;switch(function(e){switch(e){case"auto":case"data":return function(){if(Pn)return"imagebitmap";if(Rn)return"image";if(Mn)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return Pn||Rn||Mn;case"imagebitmap":return Pn;case"image":return Rn;case"data":return Mn;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(r)){case"imagebitmap":s=await async function(e,t,n){let r;r=Bn(n)?await On(e,t,n):Dn(e,n);const i=t&&t.imagebitmap;return await async function(e,t=null){if(!function(e){for(const t in e||Fn)return!1;return!0}(t)&&Un||(t=null),t)try{return await createImageBitmap(e,t)}catch(n){Un=!1}return await createImageBitmap(e)}(r,i)}(e,t,i);break;case"image":s=await On(e,t,i);break;case"data":s=await async function(e){var t;const{mimeType:n}=zn(e)||{},r=null==(t=globalThis.loaders)?void 0:t.parseImageNode;return De(r),await r(e,n)}(e);break;default:De(!1)}return"data"===r&&(s=function(e){switch(function(e){const t=function(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&e instanceof Image?"image":e&&"object"==typeof e&&e.data&&e.width&&e.height?"data":null}(e);if(!t)throw new Error("Not an image");return t}(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}(s)),s},tests:[e=>Boolean(zn(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},Hn=new nt({id:"deck"});let $n={};function Xn(e){$n=e}function Qn(e,t,n,r){Hn.level>0&&$n[e]&&$n[e].call(null,t,n,r)}const Yn={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},qn=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||(Hn.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:Hn,_registerLoggers:Xn},function(e){const t=un();e=Array.isArray(e)?e:[e];for(const n of e){const e=cn(n);t.find(t=>e===t)||t.unshift(e)}}([Yn,[Wn,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}();function Kn(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 Jn(e){let t=er(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=er(e.value),{...e,...Zn[t],type:t}):{type:"object",value:null};throw new Error("props")}function er(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}const tr={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"},nr=/void\s+main\s*\([^)]*\)\s*\{\n?/,rr=/}\n?[^{}]*$/,ir=[],sr="__LUMA_INJECT_DECLARATIONS__";function or(e){const t={vertex:{},fragment:{}};for(const n in e){let r=e[n];"string"==typeof r&&(r={order:0,injection:r}),t[ar(n)][n]=r}return t}function ar(e){const t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function Ar(e,t,n,r=!1){const i="vertex"===t;for(const s in n){const t=n[s];t.sort((e,t)=>e.order-t.order),ir.length=t.length;for(let e=0,n=t.length;e<n;++e)ir[e]=t[e].injection;const r=`${ir.join("\n")}\n`;switch(s){case"vs:#decl":i&&(e=e.replace(sr,r));break;case"vs:#main-start":i&&(e=e.replace(nr,e=>e+r));break;case"vs:#main-end":i&&(e=e.replace(rr,e=>r+e));break;case"fs:#decl":i||(e=e.replace(sr,r));break;case"fs:#main-start":i||(e=e.replace(nr,e=>e+r));break;case"fs:#main-end":i||(e=e.replace(rr,e=>r+e));break;default:e=e.replace(s,e=>e+r)}}return e=e.replace(sr,""),r&&(e=e.replace(/\}\s*$/,e=>e+tr[t])),e}function lr(e){e.map(e=>function(e){if(e.instance)return;lr(e.dependencies||[]);const{propTypes:t={},deprecations:n=[],inject:r={}}=e,i={normalizedInjections:or(r),parsedDeprecations:ur(n)};t&&(i.propValidators=function(e){const t={};for(const[n,r]of Object.entries(e))t[n]=Jn(r);return t}(t)),e.instance=i;let s={};t&&(s=Object.entries(t).reduce((e,[t,n])=>{const r=null==n?void 0:n.value;return r&&(e[t]=r),e},{})),e.defaultUniforms={...e.defaultUniforms,...s}}(e))}function cr(e,t,n){var r;null==(r=e.deprecations)||r.forEach(e=>{var r;(null==(r=e.regex)?void 0:r.test(t))&&(e.deprecated?n.deprecated(e.old,e.new)():n.removed(e.old,e.new)())})}function ur(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 hr(e){lr(e);const t={},n={};dr({modules:e,level:0,moduleMap:t,moduleDepth:n});const r=Object.keys(n).sort((e,t)=>n[t]-n[e]).map(e=>t[e]);return lr(r),r}function dr(e){const{modules:t,level:n,moduleMap:r,moduleDepth:i}=e;if(n>=5)throw new Error("Possible loop in shader dependency graph");for(const s of t)r[s.name]=s,(void 0===i[s.name]||i[s.name]<n)&&(i[s.name]=n);for(const s of t)s.dependencies&&dr({modules:s.dependencies,level:n+1,moduleMap:r,moduleDepth:i})}const fr=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,"#version 300 es\n"],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],pr=[...fr,[_r("attribute"),"in $1"],[_r("varying"),"out $1"]],gr=[...fr,[_r("varying"),"in $1"]];function mr(e,t){for(const[n,r]of t)e=e.replace(n,r);return e}function _r(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function br(e,t){let n="";for(const r in e){const i=e[r];if(n+=`void ${i.signature} {\n`,i.header&&(n+=` ${i.header}`),t[r]){const e=t[r];e.sort((e,t)=>e.order-t.order);for(const t of e)n+=` ${t.injection}\n`}i.footer&&(n+=` ${i.footer}`),n+="}\n"}return n}function vr(e){const t={vertex:{},fragment:{}};for(const n of e){let e,r;"string"!=typeof n?(e=n,r=e.hook):(e={},r=n),r=r.trim();const[i,s]=r.split(":"),o=r.replace(/\(.+/,""),a=Object.assign(e,{signature:s});switch(i){case"vs":t.vertex[o]=a;break;case"fs":t.fragment[o]=a;break;default:throw new Error(i)}}return t}function yr(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 wr(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 xr=`\n\n${sr}\n`;function Er(e,t){var n;const{source:r,stage:i,modules:s,hookFunctions:o=[],inject:a={},log:A}=t;Kn("string"==typeof r,"shader source must be a string");const l=r;let c="";const u=vr(o),h={},d={},f={};for(const g in a){const e="string"==typeof a[g]?{injection:a[g],order:0}:a[g],t=/^(v|f)s:(#)?([\w-]+)$/.exec(g);if(t){const n=t[2],r=t[3];n?"decl"===r?d[g]=[e]:f[g]=[e]:h[g]=[e]}else f[g]=[e]}const p=s;for(const g of p){A&&cr(g,l,A),c+=Cr(g,"wgsl");const e=(null==(n=g.injections)?void 0:n[i])||{};for(const t in e){const n=/^(v|f)s:#([\w-]+)$/.exec(t);if(n){const r="decl"===n[2]?d:f;r[t]=r[t]||[],r[t].push(e[t])}else h[t]=h[t]||[],h[t].push(e[t])}}return c+=xr,c=Ar(c,i,d),c+=br(u[i],h),c+=l,c=Ar(c,i,f),c}function Tr(e,t){var n;const{source:r,stage:i,language:s="glsl",modules:o,defines:a={},hookFunctions:A=[],inject:l={},prologue:c=!0,log:u}=t;Kn("string"==typeof r,"shader source must be a string");const h="glsl"===s?function(e){return{name:yr(e,void 0),language:"glsl",version:wr(e)}}(r).version:-1,d=e.shaderLanguageVersion,f=100===h?"#version 100":"#version 300 es",p=r.split("\n").slice(1).join("\n"),g={};o.forEach(e=>{Object.assign(g,e.defines)}),Object.assign(g,a);let m="";switch(s){case"wgsl":break;case"glsl":m=c?`${f}\n\n// ----- PROLOGUE -------------------------\n#define SHADER_TYPE_${i.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"===i?"precision highp float;\n":""}\n\n// ----- APPLICATION DEFINES -------------------------\n\n${function(e={}){let t="";for(const n in e){const r=e[n];(r||Number.isFinite(r))&&(t+=`#define ${n.toUpperCase()} ${e[n]}\n`)}return t}(g)}\n\n`:`${f}\n`}const _=vr(A),b={},v={},y={};for(const w in l){const e="string"==typeof l[w]?{injection:l[w],order:0}:l[w],t=/^(v|f)s:(#)?([\w-]+)$/.exec(w);if(t){const n=t[2],r=t[3];n?"decl"===r?v[w]=[e]:y[w]=[e]:b[w]=[e]}else y[w]=[e]}for(const w of o){u&&cr(w,p,u),m+=Cr(w,i);const e=(null==(n=w.instance)?void 0:n.normalizedInjections[i])||{};for(const t in e){const n=/^(v|f)s:#([\w-]+)$/.exec(t);if(n){const r="decl"===n[2]?v:y;r[t]=r[t]||[],r[t].push(e[t])}else b[t]=b[t]||[],b[t].push(e[t])}}return m+="// ----- MAIN SHADER SOURCE -------------------------",m+=xr,m=Ar(m,i,v),m+=br(_[i],b),m+=p,m=Ar(m,i,y),"glsl"===s&&h!==d&&(m=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 mr(e,pr);case"fragment":return mr(e,gr);default:throw new Error(t)}}(m,i)),m.trim()}function Sr(e){return function(t){var n;const r={};for(const i of e){const e=null==(n=i.getUniforms)?void 0:n.call(i,t,r);Object.assign(r,e)}return r}}function Cr(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:Kn(!1)}if(!e.name)throw new Error("Shader module must have a name");const r=e.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let i=`// ----- MODULE ${e.name} ---------------\n\n`;return"wgsl"!==t&&(i+=`#define MODULE_${r}\n`),i+=`${n}\n`,i}const kr=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,Rr=/^\s*\#\s*endif\s*$/,Pr=class e{constructor(){r(this,"_hookFunctions",[]),r(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:r,getUniforms:i}=function(e){const t=hr(e.modules||[]);return{source:Er(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t}),getUniforms:Sr(t)}}({...e,source:e.source,modules:t,hookFunctions:n}),s="wgsl"===e.platformInfo.shaderLanguage?function(e){const t=e.split("\n"),n=[];let r=!0,i=null;for(const s of t){const e=s.match(kr),t=s.match(Rr);e?(i=e[1],r=Boolean(null==void 0?void 0:undefined[i])):t?r=!0:r&&n.push(s)}return n.join("\n")}(r):r;return{source:s,getUniforms:i,modules:t}}assembleGLSLShaderPair(e){const t=this._getModuleList(e.modules),n=this._hookFunctions,r=function(e){const{vs:t,fs:n}=e,r=hr(e.modules||[]);return{vs:Tr(e.platformInfo,{...e,source:t,stage:"vertex",modules:r}),fs:Tr(e.platformInfo,{...e,source:n,stage:"fragment",modules:r}),getUniforms:Sr(r)}}({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:n});return{...r,modules:t}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),n={};let r=0;for(let i=0,s=this._defaultModules.length;i<s;++i){const e=this._defaultModules[i],s=e.name;t[r++]=e,n[s]=!0}for(let i=0,s=e.length;i<s;++i){const s=e[i],o=s.name;n[o]||(t[r++]=s,n[o]=!0)}return t.length=r,lr(t),t}};r(Pr,"defaultShaderAssembler");let Ir=Pr;function Mr(e){const{input:t,inputChannels:n,output:r}={};if(!t)return"#version 300 es\nout vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}";if(!n)throw new Error("inputChannels");return`#version 300 es\nin ${function(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${e}`)}}(n)} ${t};\nout vec4 ${r};\nvoid main() {\n ${r} = ${function(e,t){switch(t){case 1:return`vec4(${e}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${e}, 0.0, 1.0)`;case 3:return`vec4(${e}, 1.0)`;case 4:return e;default:throw new Error(`invalid channels: ${t}`)}}(t,n)};\n}`}const Lr=new class{constructor(){r(this,"stats",new Map)}getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new Mt({id:e})),this.stats.get(e)}},Nr=new nt({id:"luma.gl"}),Br={};function Dr(e="id"){return Br[e]=Br[e]||1,`${e}-${Br[e]++}`}let Or=(t=class{constructor(e,t,n){if(r(this,"id"),r(this,"props"),r(this,"userData",{}),r(this,"_device"),r(this,"destroyed",!1),r(this,"allocatedBytes",0),r(this,"_attachedResources",new Set),!e)throw new Error("no device");this._device=e,this.props=function(e,t){const n={...t};for(const r in e)void 0!==e[r]&&(n[r]=e[r]);return n}(t,n);const i="undefined"!==this.props.id?this.props.id:Dr(this[Symbol.toStringTag]);this.props.id=i,this.id=i,this.userData=this.props.userData||{},this.addStats()}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}destroy(){this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(const e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){const n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){const t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}},r(t,"defaultProps",{id:"undefined",handle:void 0,userData:void 0}),t);const Fr=class e extends Or{constructor(t,n){const i={...n};(n.usage||0)&e.INDEX&&!n.indexType&&(n.data instanceof Uint32Array?i.indexType="uint32":n.data instanceof Uint16Array&&(i.indexType="uint16")),delete i.data,super(t,i,e.defaultProps),r(this,"usage"),r(this,"indexType"),r(this,"updateTimestamp"),r(this,"debugData",new ArrayBuffer(0)),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=t.incrementTimestamp()}get[Symbol.toStringTag](){return"Buffer"}clone(e){return this.device.createBuffer({...this.props,...e})}_setDebugData(t,n,r){const i=ArrayBuffer.isView(t)?t.buffer:t,s=Math.min(t?t.byteLength:r,e.DEBUG_DATA_MAX_LENGTH);null===i?this.debugData=new ArrayBuffer(s):0===n&&r===i.byteLength?this.debugData=i.slice(0,s):this.debugData=i.slice(n,n+s)}};r(Fr,"INDEX",16),r(Fr,"VERTEX",32),r(Fr,"UNIFORM",64),r(Fr,"STORAGE",128),r(Fr,"INDIRECT",256),r(Fr,"QUERY_RESOLVE",512),r(Fr,"MAP_READ",1),r(Fr,"MAP_WRITE",2),r(Fr,"COPY_SRC",4),r(Fr,"COPY_DST",8),r(Fr,"DEBUG_DATA_MAX_LENGTH",32),r(Fr,"defaultProps",{...Or.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});let Ur=Fr;function jr(e){const[t,n,r]=Wr[e],i=e.includes("norm");return{signedType:t,primitiveType:n,byteLength:r,normalized:i,integer:!i&&!e.startsWith("float"),signed:e.startsWith("s")}}function Gr(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}function zr(e){const t=ArrayBuffer.isView(e)?e.constructor:e;if(t===Uint8ClampedArray)return"uint8";const n=Object.values(Wr).find(e=>t===e[4]);if(!n)throw new Error(t.name);return n[0]}function Vr(e){const[,,,,t]=Wr[e];return t}const Wr={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 Hr(e){let t;e.endsWith("-webgl")&&(e.replace("-webgl",""),t=!0);const[n,r]=e.split("x"),i=n,s=r?parseInt(r):1,o=jr(i),a={type:i,components:s,byteLength:o.byteLength*s,integer:o.integer,signed:o.signed,normalized:o.normalized};return t&&(a.webglOnly=!0),a}function $r(e,t,n){if(!t||t>4)throw new Error(`size ${t}`);const r=t;return function(e,t,n){const r=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(r){case"unorm8":return 1===t?"unorm8":3===t?"unorm8x3-webgl":`${r}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`${r}x${t}`;default:return 1===t?r:`${r}x${t}`}}(zr(e),r,n)}const Xr="texture-compression-bc",Qr="texture-compression-astc",Yr="texture-compression-etc2",qr="texture-compression-pvrtc-webgl",Kr="texture-compression-atc-webgl",Zr="float32-renderable-webgl",Jr="float16-renderable-webgl",ei="snorm8-renderable-webgl",ti="norm16-renderable-webgl",ni="snorm16-renderable-webgl",ri="float32-filterable",ii="float16-filterable-webgl";function si(e){const t=oi[e];if(!t)throw new Error(`Unsupported texture format ${e}`);return t}const oi={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:ei},rg8snorm:{render:ei},"rgb8snorm-webgl":{},rgba8snorm:{render:ei},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:ti},rg16unorm:{render:ti},"rgb16unorm-webgl":{f:ti},rgba16unorm:{render:ti},r16snorm:{f:ni},rg16snorm:{render:ni},"rgb16snorm-webgl":{f:ti},rgba16snorm:{render:ni},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Jr,filter:"float16-filterable-webgl"},rg16float:{render:Jr,filter:ii},rgba16float:{render:Jr,filter:ii},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:Zr,filter:ri},rg32float:{render:!1,filter:ri},"rgb32float-webgl":{render:Zr,filter:ri},rgba32float:{render:Zr,filter:ri},"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:Zr},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:Xr},"bc1-rgb-unorm-srgb-webgl":{f:Xr},"bc1-rgba-unorm":{f:Xr},"bc1-rgba-unorm-srgb":{f:Xr},"bc2-rgba-unorm":{f:Xr},"bc2-rgba-unorm-srgb":{f:Xr},"bc3-rgba-unorm":{f:Xr},"bc3-rgba-unorm-srgb":{f:Xr},"bc4-r-unorm":{f:Xr},"bc4-r-snorm":{f:Xr},"bc5-rg-unorm":{f:Xr},"bc5-rg-snorm":{f:Xr},"bc6h-rgb-ufloat":{f:Xr},"bc6h-rgb-float":{f:Xr},"bc7-rgba-unorm":{f:Xr},"bc7-rgba-unorm-srgb":{f:Xr},"etc2-rgb8unorm":{f:Yr},"etc2-rgb8unorm-srgb":{f:Yr},"etc2-rgb8a1unorm":{f:Yr},"etc2-rgb8a1unorm-srgb":{f:Yr},"etc2-rgba8unorm":{f:Yr},"etc2-rgba8unorm-srgb":{f:Yr},"eac-r11unorm":{f:Yr},"eac-r11snorm":{f:Yr},"eac-rg11unorm":{f:Yr},"eac-rg11snorm":{f:Yr},"astc-4x4-unorm":{f:Qr},"astc-4x4-unorm-srgb":{f:Qr},"astc-5x4-unorm":{f:Qr},"astc-5x4-unorm-srgb":{f:Qr},"astc-5x5-unorm":{f:Qr},"astc-5x5-unorm-srgb":{f:Qr},"astc-6x5-unorm":{f:Qr},"astc-6x5-unorm-srgb":{f:Qr},"astc-6x6-unorm":{f:Qr},"astc-6x6-unorm-srgb":{f:Qr},"astc-8x5-unorm":{f:Qr},"astc-8x5-unorm-srgb":{f:Qr},"astc-8x6-unorm":{f:Qr},"astc-8x6-unorm-srgb":{f:Qr},"astc-8x8-unorm":{f:Qr},"astc-8x8-unorm-srgb":{f:Qr},"astc-10x5-unorm":{f:Qr},"astc-10x5-unorm-srgb":{f:Qr},"astc-10x6-unorm":{f:Qr},"astc-10x6-unorm-srgb":{f:Qr},"astc-10x8-unorm":{f:Qr},"astc-10x8-unorm-srgb":{f:Qr},"astc-10x10-unorm":{f:Qr},"astc-10x10-unorm-srgb":{f:Qr},"astc-12x10-unorm":{f:Qr},"astc-12x10-unorm-srgb":{f:Qr},"astc-12x12-unorm":{f:Qr},"astc-12x12-unorm-srgb":{f:Qr},"pvrtc-rgb4unorm-webgl":{f:qr},"pvrtc-rgba4unorm-webgl":{f:qr},"pvrtc-rbg2unorm-webgl":{f:qr},"pvrtc-rgba2unorm-webgl":{f:qr},"etc1-rbg-unorm-webgl":{f:"texture-compression-etc1-webgl"},"atc-rgb-unorm-webgl":{f:Kr},"atc-rgba-unorm-webgl":{f:Kr},"atc-rgbai-unorm-webgl":{f:Kr}},ai=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Ai=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,li=new class{getInfo(e){return ci(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 ai.some(t=>e.startsWith(t))}getCapabilities(e){const t=si(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},r=ci(e),i=e.startsWith("depth")||e.startsWith("stencil"),s=null==r?void 0:r.signed,o=null==r?void 0:r.integer,a=null==r?void 0:r.webgl;return n.render&&(n.render=!s),n.filter&&(n.filter=!(i||s||o||a)),n}};function ci(e){let t=function(e){var t;const n=si(e),r=n.bytesPerPixel||1,i=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:r,bitsPerChannel:i,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(li.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=Ai.exec(e);if(n){const[,r,i,s,o,a]=n,A=jr(`${s}${i}`),l=8*A.byteLength,c=r.length,u=[l,c>=2?l:0,c>=3?l:0,c>=4?l:0];t={format:e,attachment:t.attachment,dataType:A.signedType,components:c,channels:r,integer:A.integer,signed:A.signed,normalized:A.normalized,bitsPerChannel:u,bytesPerPixel:A.byteLength*r.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 ui{}class hi{constructor(e=[],t){r(this,"features"),r(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 di=class e{constructor(t){r(this,"id"),r(this,"props"),r(this,"userData",{}),r(this,"statsManager",Lr),r(this,"timestamp",0),r(this,"_reused",!1),r(this,"_lumaData",{}),r(this,"_textureCaps",{}),this.props={...e.defaultProps,...t},this.id=this.props.id||Dr(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(e){return Hr(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return li.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 r=Math.max(e,t,n);return 1+Math.floor(Math.log2(r))}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 li.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)?()=>{}:Nr.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.";Nr.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=li.getCapabilities(e),n=e=>("string"==typeof e?this.features.has(e):e)??!0,r=n(t.create);return{format:e,create:r,render:r&&n(t.render),filter:r&&n(t.filter),blend:r&&n(t.blend),store:r&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&Ur.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}};r(di,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{const[n,r]=e.getDevicePixelSize();Nr.log(1,`${e} resized => ${n}x${r}px`)()},onPositionChange:(e,t)=>{const[n,r]=e.getPosition();Nr.log(1,`${e} repositioned => ${n},${r}`)()},onVisibilityChange:e=>Nr.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>Nr.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:Nr.get("debug")||void 0,debugShaders:Nr.get("debug-shaders")||void 0,debugFramebuffers:Boolean(Nr.get("debug-framebuffers")),debugFactories:Boolean(Nr.get("debug-factories")),debugWebGL:Boolean(Nr.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 fi=di;const pi="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",gi=class e{constructor(){if(r(this,"stats",Lr),r(this,"log",Nr),r(this,"VERSION","9.2.5"),r(this,"spector"),r(this,"preregisteredAdapters",new Map),globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw Nr.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),Nr.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");Nr.error("This version of luma.gl has already been initialized")()}Nr.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},r=this.selectAdapter(n.type,n.adapters);if(!r)throw new Error(pi);return n.waitForPageLoad&&await r.pageLoaded,await r.create(n)}async attachDevice(e,t){var n;const r=this._getTypeFromHandle(e,t.adapters),i=r&&this.selectAdapter(r,t.adapters);if(!i)throw new Error(pi);return await(null==(n=null==i?void 0:i.attach)?void 0:n.call(i,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 r=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(const s of r)if(null==(n=null==(t=i.get(s))?void 0:t.isSupported)?void 0:n.call(t))return s;return null}selectAdapter(e,t=[]){let n=e;"best-available"===e&&(n=this.getBestAvailableAdapterType(t));const r=this._getAdapterMap(t);return n&&r.get(n)||null}enforceWebGL2(e=!0,t=[]){var n;const r=this._getAdapterMap(t).get("webgl");r||Nr.warn("enforceWebGL2: webgl adapter not found")(),null==(n=null==r?void 0:r.enforceWebGL2)||n.call(r,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?Nr.warn("WebGL1 is not supported",e)():Nr.warn("Unknown handle type",e)(),null)}};r(gi,"defaultProps",{...fi.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});const mi=new gi;class _i{get pageLoaded(){return yi||(yi=vi()||"undefined"==typeof window?Promise.resolve():new Promise(e=>window.addEventListener("load",()=>e()))),yi}}const bi=Ve()&&"undefined"!=typeof document,vi=()=>bi&&"complete"===document.readyState;let yi=null;const wi=class e{constructor(t){var n,i;if(r(this,"id"),r(this,"props"),r(this,"canvas"),r(this,"htmlCanvas"),r(this,"offscreenCanvas"),r(this,"type"),r(this,"initialized"),r(this,"isInitialized",!1),r(this,"isVisible",!0),r(this,"cssWidth"),r(this,"cssHeight"),r(this,"devicePixelRatio"),r(this,"devicePixelWidth"),r(this,"devicePixelHeight"),r(this,"drawingBufferWidth"),r(this,"drawingBufferHeight"),r(this,"_initializedResolvers",function(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}()),r(this,"_resizeObserver"),r(this,"_intersectionObserver"),r(this,"_position"),r(this,"destroyed",!1),this.props={...e.defaultProps,...t},t=this.props,this.initialized=this._initializedResolvers.promise,Ve()?t.canvas?"string"==typeof t.canvas?this.canvas=function(e){const t=document.getElementById(e);if(!xi.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,r=document.createElement("canvas");r.id=Dr("lumagl-auto-created-canvas"),r.width=t||1,r.height=n||1,r.style.width=Number.isFinite(t)?`${t}px`:"100%",r.style.height=Number.isFinite(n)?`${n}px`:"100%",(null==e?void 0:e.visible)||(r.style.visibility="hidden");const i=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 i.insertBefore(r,i.firstChild),r}(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==(i=this.htmlCanvas)?void 0:i.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(),[r,i]=this.getDrawingBufferSize();return function(e,t,n,r,i){const s=e,o=Ei(s[0],t,n);let a=Ti(s[1],t,r,i),A=Ei(s[0]+1,t,n);const l=A===n-1?A:A-1;let c;return A=Ti(s[1]+1,t,r,i),i?(A=0===A?A:A+1,c=a,a=A):c=A===r-1?A:A-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(c-a+1,1)}}(e,n,r,i,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 r=e.find(e=>e.target===this.canvas);if(!r)return;this.cssWidth=r.contentBoxSize[0].inlineSize,this.cssHeight=r.contentBoxSize[0].blockSize;const i=this.getDevicePixelSize(),s=(null==(t=r.devicePixelContentBoxSize)?void 0:t[0].inlineSize)||r.contentBoxSize[0].inlineSize*devicePixelRatio,o=(null==(n=r.devicePixelContentBoxSize)?void 0:n[0].blockSize)||r.contentBoxSize[0].blockSize*devicePixelRatio,[a,A]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(s,a)),this.devicePixelHeight=Math.max(1,Math.min(o,A)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:i})}_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 r=null==(e=this.htmlCanvas)?void 0:e.getBoundingClientRect();if(r){const e=[r.left,r.top];if(this._position??(this._position=e),e[0]!==this._position[0]||e[1]!==this._position[1]){const r=this._position;this._position=e,null==(n=(t=this.device.props).onPositionChange)||n.call(t,this,{oldPosition:r})}}}};r(wi,"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 xi=wi;function Ei(e,t,n){return Math.min(Math.round(e*t),n-1)}function Ti(e,t,n,r){return r?Math.max(0,n-1-Math.round(e*t)):Math.min(Math.round(e*t),n-1)}const Si=class e extends Or{get[Symbol.toStringTag](){return"Sampler"}constructor(t,n){super(t,n=e.normalizeProps(t,n),e.defaultProps)}static normalizeProps(e,t){return t}};r(Si,"defaultProps",{...Or.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 Ci=Si;const ki={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Ri=class e extends Or{constructor(t,n){if(super(t,n=e.normalizeProps(t,n),e.defaultProps),r(this,"dimension"),r(this,"baseDimension"),r(this,"format"),r(this,"width"),r(this,"height"),r(this,"depth"),r(this,"mipLevels"),r(this,"updateTimestamp"),this.dimension=this.props.dimension,this.baseDimension=ki[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||Nr.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 Ci?e:this.device.createSampler(e)}clone(e){return this.device.createTexture({...this.props,...e})}static normalizeProps(e,t){const n={...t},{width:r,height:i}=n;return"number"==typeof r&&(n.width=Math.max(1,Math.ceil(r))),"number"==typeof i&&(n.height=Math.max(1,Math.ceil(i))),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:r,depth:i}=this,s={...e.defaultCopyDataOptions,width:n,height:r,depth:i,...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 s.bytesPerRow=t.bytesPerRow||n*(o.bytesPerPixel||4),s.rowsPerImage=t.rowsPerImage||r,s}_normalizeCopyExternalImageOptions(t){const n=this.device.getExternalImageSize(t.image),r={...e.defaultCopyExternalImageOptions,...n,...t};return r.width=Math.min(r.width,this.width-r.x),r.height=Math.min(r.height,this.height-r.y),r}};r(Ri,"SAMPLE",4),r(Ri,"STORAGE",8),r(Ri,"RENDER",16),r(Ri,"COPY_SRC",1),r(Ri,"COPY_DST",2),r(Ri,"TEXTURE",4),r(Ri,"RENDER_ATTACHMENT",16),r(Ri,"defaultProps",{...Or.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:Ri.TEXTURE|Ri.RENDER_ATTACHMENT|Ri.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),r(Ri,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),r(Ri,"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 Pi=Ri;const Ii=class e extends Or{get[Symbol.toStringTag](){return"TextureView"}constructor(t,n){super(t,n,e.defaultProps)}};r(Ii,"defaultProps",{...Or.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});let Mi=Ii;function Li(e,t,n,r){if(null==r?void 0:r.inlineSource){const r=function(e,t){let n="";for(let r=t-2;r<=t;r++){const i=e[r-1];void 0!==i&&(n+=Ni(i,t,undefined))}return n}(t,n);return`\n${r}${e.linePos>0?`${" ".repeat(e.linePos+5)}^^^\n`:""}${e.type.toUpperCase()}: ${e.message}\n\n`}const i="error"===e.type?"red":"#8B4000";return(null==r?void 0:r.html)?`<div class='luma-compiler-log-error' style="color:${i};"><b> ${e.type.toUpperCase()}: ${e.message}</b></div>`:`${e.type.toUpperCase()}: ${e.message}`}function Ni(e,t,n){const r=(null==n?void 0:n.html)?e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;"):e;return`${function(e){let t="";for(let n=e.length;n<4;++n)t+=" ";return t+e}(String(t))}: ${r}${(null==n?void 0:n.html)?"<br/>":"\n"}`}const Bi=class e extends Or{constructor(t,n){super(t,{id:Oi(n={...n,debugShaders:n.debugShaders||t.props.debugShaders||"errors"}),...n},e.defaultProps),r(this,"stage"),r(this,"source"),r(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 r=t,i=`${this.stage} shader "${r}"`;let s=function(e,t,n){let r="";const i=t.split(/\r?\n/),s=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<=i.length;e++)for(r+=Ni(i[e-1],e,n);s.length>t&&s[t].lineNum===e;){const e=s[t++];r+=Li(e,i,e.lineNum,{...n,inlineSource:!1})}for(;s.length>t;)r+=Li(s[t++],[],0,{...n,inlineSource:!1});return r;case"issues":case"no":for(const s of e)r+=Li(s,i,s.lineNum,{inlineSource:"no"!==(null==n?void 0:n.showSourceCode)});return r}}(e,this.source,{showSourceCode:"all",html:!0});const o=this.getTranslatedSource();o&&(s+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${o}</pre></code>`);const a=document.createElement("Button");a.innerHTML=`\n<h1>Compilation error in ${i}</h1><br /><br />\n<code style="user-select:text;"><pre>\n${s}\n</pre></code>`,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)}}};r(Bi,"defaultProps",{...Or.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let Di=Bi;function Oi(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||Dr(`unnamed ${e.stage}-shader`)}const Fi=class e extends Or{constructor(t,n={}){super(t,n,e.defaultProps),r(this,"width"),r(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,r]=Array.isArray(e)?e:[e.width,e.height];t=t||r!==this.height||n!==this.width,this.width=n,this.height=r}t&&(Nr.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 Pi?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 Pi?e.view:e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:Pi.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:Pi.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){const r=this.colorAttachments[n].texture.clone({width:e,height:t});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=r.view,this.attachResource(r.view)}if(this.depthStencilAttachment){const n=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}};r(Fi,"defaultProps",{...Or.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});let Ui=Fi;const ji=class e extends Or{constructor(t,n){super(t,n,e.defaultProps),r(this,"shaderLayout"),r(this,"bufferLayout"),r(this,"linkStatus","pending"),r(this,"hash",""),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};r(ji,"defaultProps",{...Or.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Gi=ji;const zi=class e extends Or{get[Symbol.toStringTag](){return"RenderPass"}constructor(t,n){super(t,n=e.normalizeProps(t,n),e.defaultProps)}static normalizeProps(e,t){return t}};r(zi,"defaultClearColor",[0,0,0,1]),r(zi,"defaultClearDepth",1),r(zi,"defaultClearStencil",0),r(zi,"defaultProps",{...Or.defaultProps,framebuffer:null,parameters:void 0,clearColor:zi.defaultClearColor,clearColors:void 0,clearDepth:zi.defaultClearDepth,clearStencil:zi.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});let Vi=zi;const Wi=class e extends Or{constructor(t,n){super(t,n,e.defaultProps),r(this,"hash",""),r(this,"shaderLayout"),this.shaderLayout=n.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};r(Wi,"defaultProps",{...Or.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let Hi=Wi;const $i=class e extends Or{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(t,n){super(t,n,e.defaultProps)}};r($i,"defaultProps",{...Or.defaultProps,measureExecutionTime:void 0});let Xi=$i;const Qi=class e extends Or{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(t,n){super(t,n,e.defaultProps)}};r(Qi,"defaultProps",{...Or.defaultProps});let Yi=Qi;function qi(e){return Ji[e]}const Ki={f32:4,f16:2,i32:4,u32:4},Zi={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},Ji={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}};function es(e,t){const n={};for(const r of e.attributes){const i=ts(e,t,r.name);i&&(n[r.name]=i)}return n}function ts(e,t,n){const r=function(e,t){const n=e.attributes.find(e=>e.name===t);return n||Nr.warn(`shader layout attribute "${t}" not present in shader`),n||null}(e,n),i=function(e,t){!function(e){for(const t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&Nr.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 r of e){let e=r.byteStride;if("number"!=typeof r.byteStride)for(const t of r.attributes||[])e+=Hr(t.format).byteLength;const i=null==(n=r.attributes)?void 0:n.find(e=>e.attribute===t);if(i)return{attributeName:i.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:e}}return null}(e,t),n||(Nr.warn(`layout for attribute "${t}" not present in buffer layout`),null))}(t,n);if(!r)return null;const s=function(e){const[t,n]=Zi[e];return{primitiveType:t,components:n,byteLength:Ki[t]*n,integer:"i32"===t||"u32"===t,signed:"u32"!==t}}(r.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}`}(s),a=(null==i?void 0:i.vertexFormat)||o,A=Hr(a);return{attributeName:(null==i?void 0:i.attributeName)||r.name,bufferName:(null==i?void 0:i.bufferName)||r.name,location:r.location,shaderType:r.type,primitiveType:s.primitiveType,shaderComponents:s.components,vertexFormat:a,bufferDataType:A.type,bufferComponents:A.components,normalized:A.normalized,integer:s.integer,stepMode:(null==i?void 0:i.stepMode)||r.stepMode||"vertex",byteOffset:(null==i?void 0:i.byteOffset)||0,byteStride:(null==i?void 0:i.byteStride)||0}}const ns=class e extends Or{constructor(t,n){super(t,n,e.defaultProps),r(this,"maxVertexAttributes"),r(this,"attributeInfos"),r(this,"indexBuffer",null),r(this,"attributes"),this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=function(e,t,n=16){const r=es(e,t),i=new Array(n).fill(null);for(const s of Object.values(r))i[s.location]=s;return i}(n.shaderLayout,n.bufferLayout,this.maxVertexAttributes)}get[Symbol.toStringTag](){return"VertexArray"}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}};r(ns,"defaultProps",{...Or.defaultProps,shaderLayout:void 0,bufferLayout:[]});let rs=ns;const is=class e extends Or{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(t,n){super(t,n,e.defaultProps)}};r(is,"defaultProps",{...Or.defaultProps,layout:void 0,buffers:{}});let ss=is;const os=class e extends Or{get[Symbol.toStringTag](){return"QuerySet"}constructor(t,n){super(t,n,e.defaultProps)}};r(os,"defaultProps",{...Or.defaultProps,type:void 0,count:void 0});let as,As=os;function ls(e){return(!as||as.byteLength<e)&&(as=new ArrayBuffer(e)),as}function cs(e){return Array.isArray(e)?0===e.length||"number"==typeof e[0]:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}(e)}class us{constructor(e,t={}){r(this,"layout",{}),r(this,"byteLength");let n=0;for(const[r,s]of Object.entries(e)){const e=qi(s),{type:i,components:o}=e,a=o*((null==t?void 0:t[r])??1);n=Gr(n,a);const A=n;n+=a,this.layout[r]={type:i,size:a,offset:A}}n+=(4-n%4)%4;const i=4*n;this.byteLength=Math.max(i,1024)}getData(e){const t=ls(this.byteLength),n={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)};for(const[r,i]of Object.entries(e)){const e=this.layout[r];if(!e){Nr.warn(`Supplied uniform value ${r} not present in uniform block layout`)();continue}const{type:t,size:s,offset:o}=e,a=n[t];if(1===s){if("number"!=typeof i&&"boolean"!=typeof i){Nr.warn(`Supplied value for single component uniform ${r} is not a number: ${i}`)();continue}a[o]=Number(i)}else{if(!cs(i)){Nr.warn(`Supplied value for multi component / array uniform ${r} is not a numeric array: ${i}`)();continue}a.set(i,o)}}return new Uint8Array(t,0,this.byteLength)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}}class hs{constructor(e){var t;if(r(this,"name"),r(this,"uniforms",{}),r(this,"modifiedUniforms",{}),r(this,"modified",!0),r(this,"bindingLayout",{}),r(this,"needsRedraw","initialized"),this.name=(null==e?void 0:e.name)||"unnamed",(null==e?void 0:e.name)&&(null==e?void 0:e.shaderLayout)){const n=null==(t=null==e?void 0:e.shaderLayout.bindings)?void 0:t.find(t=>"uniform"===t.type&&t.name===(null==e?void 0:e.name));if(!n)throw new Error(null==e?void 0:e.name);const r=n;for(const e of r.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,r=t;if(!cs(n))return!1;if(cs(r)&&n.length===r.length)for(let i=0;i<n.length;++i)if(r[i]!==n[i])return!1;return!0})(this.uniforms[e],t)||(this.uniforms[e]=cs(n=t)?n.slice():n,this.modifiedUniforms[e]=!0,this.modified=!0)}}class ds{constructor(e){r(this,"uniformBlocks",new Map),r(this,"uniformBufferLayouts",new Map),r(this,"uniformBuffers",new Map);for(const[t,n]of Object.entries(e)){const e=t,r=new us(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(e,r);const i=new hs({name:t});i.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(e,i)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[n,r]of Object.entries(e))null==(t=this.uniformBlocks.get(n))||t.setUniforms(r);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return(null==(t=this.uniformBufferLayouts.get(e))?void 0:t.byteLength)||0}getUniformBufferData(e){var t,n;const r=(null==(t=this.uniformBlocks.get(e))?void 0:t.getAllUniforms())||{};return null==(n=this.uniformBufferLayouts.get(e))?void 0:n.getData(r)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);const r=this.getUniformBufferByteLength(t),i=e.createBuffer({usage:Ur.UNIFORM|Ur.COPY_DST,byteLength:r}),s=this.getUniformBufferData(t);return i.write(s),i}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const n=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:Ur.UNIFORM|Ur.COPY_DST,byteLength:n});this.uniformBuffers.set(t,r)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||(e=n)}return e&&Nr.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var t;const n=this.uniformBlocks.get(e);let r=this.uniformBuffers.get(e),i=!1;if(r&&(null==n?void 0:n.needsRedraw)){i||(i=n.needsRedraw);const s=this.getUniformBufferData(e);r=this.uniformBuffers.get(e),null==r||r.write(s);const o=null==(t=this.uniformBlocks.get(e))?void 0:t.getAllUniforms();Nr.log(4,`Writing to uniform buffer ${String(e)}`,s,o)()}return i}}class fs{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}get isPointer(){return!1}getTypeName(){return this.name}}class ps{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}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 gs extends fs{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class ms extends fs{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}getTypeName(){return`array<${this.format.getTypeName()}, ${this.count}>`}}class _s extends fs{constructor(e,t,n){super(e,n),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class bs extends fs{constructor(e,t,n,r){super(e,n),this.format=t,this.access=r}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 vs,ys;(ys=vs||(vs={}))[ys.Uniform=0]="Uniform",ys[ys.Storage=1]="Storage",ys[ys.Texture=2]="Texture",ys[ys.Sampler=3]="Sampler",ys[ys.StorageTexture=4]="StorageTexture";class ws{constructor(e,t,n,r,i,s,o){this.name=e,this.type=t,this.group=n,this.binding=r,this.attributes=i,this.resourceType=s,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 xs{constructor(e,t){this.name=e,this.type=t}}class Es{constructor(e,t,n,r){this.name=e,this.type=t,this.locationType=n,this.location=r,this.interpolation=null}}class Ts{constructor(e,t,n,r){this.name=e,this.type=t,this.locationType=n,this.location=r}}class Ss{constructor(e,t,n,r){this.name=e,this.type=t,this.attributes=n,this.id=r}}class Cs{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n}}class ks{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 Rs{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function Ps(e){var t=(32768&e)>>15,n=(31744&e)>>10,r=1023&e;return 0==n?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==n?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,n-15)*(1+r/Math.pow(2,10))}const Is=new Float32Array(1),Ms=new Int32Array(Is.buffer),Ls=new Uint16Array(1);function Ns(e){Is[0]=e;const t=Ms[0],n=t>>31&1;let r=t>>23&255,i=8388607&t;if(255===r)return Ls[0]=n<<15|31744|(0!==i?512:0),Ls[0];if(0===r){if(0===i)return Ls[0]=n<<15,Ls[0];i|=8388608;let e=113;for(;!(8388608&i);)i<<=1,e--;return r=127-e,i&=8388607,r>0?(i=(i>>126-r)+(i>>127-r&1),Ls[0]=n<<15|r<<10|i>>13,Ls[0]):(Ls[0]=n<<15,Ls[0])}return r=r-127+15,r>=31?(Ls[0]=n<<15|31744,Ls[0]):r<=0?r<-10?(Ls[0]=n<<15,Ls[0]):(i=(8388608|i)>>1-r,Ls[0]=n<<15|i>>13,Ls[0]):(i>>=13,Ls[0]=n<<15|r<<10|i,Ls[0])}const Bs=new Uint32Array(1),Ds=new Float32Array(Bs.buffer,0,1);function Os(e){const t=112+(e>>6&31)<<23|(63&e)<<17;return Bs[0]=t,Ds[0]}function Fs(e,t,n,r){const i=[0,0,0,0];for(let s=0;s<r;++s)switch(n){case"8unorm":i[s]=e[t]/255,t++;break;case"8snorm":i[s]=e[t]/255*2-1,t++;break;case"8uint":i[s]=e[t],t++;break;case"8sint":i[s]=e[t]-127,t++;break;case"16uint":i[s]=e[t]|e[t+1]<<8,t+=2;break;case"16sint":i[s]=(e[t]|e[t+1]<<8)-32768,t+=2;break;case"16float":i[s]=Ps(e[t]|e[t+1]<<8),t+=2;break;case"32uint":case"32sint":i[s]=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,t+=4;break;case"32float":i[s]=new Float32Array(e.buffer,t,1)[0],t+=4}return i}function Us(e,t,n,r,i){for(let s=0;s<r;++s)switch(n){case"8unorm":e[t]=255*i[s],t++;break;case"8snorm":e[t]=.5*(i[s]+1)*255,t++;break;case"8uint":e[t]=i[s],t++;break;case"8sint":e[t]=i[s]+127,t++;break;case"16uint":new Uint16Array(e.buffer,t,1)[0]=i[s],t+=2;break;case"16sint":new Int16Array(e.buffer,t,1)[0]=i[s],t+=2;break;case"16float":{const n=Ns(i[s]);new Uint16Array(e.buffer,t,1)[0]=n,t+=2;break}case"32uint":new Uint32Array(e.buffer,t,1)[0]=i[s],t+=4;break;case"32sint":new Int32Array(e.buffer,t,1)[0]=i[s],t+=4;break;case"32float":new Float32Array(e.buffer,t,1)[0]=i[s],t+=4}return i}const js={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"rgba8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bgra8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:"depth32float",channels:1},"depth24plus-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:"depth32float",channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},"depth32float-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:"depth32float",channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bc1-rgba-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc1-rgba-unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc4-r-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc4-r-snorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc5-rg-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc5-rg-snorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc6h-rgb-ufloat":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc6h-rgb-float":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"eac-r11unorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-r11snorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-rg11unorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"eac-rg11snorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"astc-4x4-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-4x4-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x5-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-5x5-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x6-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-6x6-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-8x5-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x5-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x6-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x6-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x8-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-8x8-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-10x5-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x5-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x6-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x6-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x8-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x8-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x10-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-10x10-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x12-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},"astc-12x12-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}};class Gs{constructor(){this.id=Gs._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return""}search(e){e(this)}searchBlock(e,t){if(e){t(zs.instance);for(const n of e)n instanceof Array?this.searchBlock(n,t):n.search(t);t(Vs.instance)}}constEvaluate(e,t){throw new Error("Cannot evaluate node")}constEvaluateString(e){return this.constEvaluate(e).toString()}}Gs._id=0;class zs extends Gs{}zs.instance=new zs;class Vs extends Gs{}Vs.instance=new Vs;const Ws=new Set(["all","all","any","select","arrayLength","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","countLeadingZeros","countOneBits","countTrailingZeros","cross","degrees","determinant","distance","dot","dot4U8Packed","dot4I8Packed","exp","exp2","extractBits","faceForward","firstLeadingBit","firstTrailingBit","floor","fma","fract","frexp","insertBits","inverseSqrt","ldexp","length","log","log2","max","min","mix","modf","normalize","pow","quantizeToF16","radians","reflect","refract","reverseBits","round","saturate","sign","sin","sinh","smoothStep","sqrt","step","tan","tanh","transpose","trunc","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","textureDimensions","textureGather","textureGatherCompare","textureLoad","textureNumLayers","textureNumLevels","textureNumSamples","textureSample","textureSampleBias","textureSampleCompare","textureSampleCompareLevel","textureSampleGrad","textureSampleLevel","textureSampleBaseClampToEdge","textureStore","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","pack4x8snorm","pack4x8unorm","pack4xI8","pack4xU8","pack4x8Clamp","pack4xU8Clamp","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack4xI8","unpack4xU8","unpack2x16snorm","unpack2x16unorm","unpack2x16float","storageBarrier","textureBarrier","workgroupBarrier","workgroupUniformLoad","subgroupAdd","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","subgroupAnd","subgroupAny","subgroupBallot","subgroupBroadcast","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","subgroupShuffleUp","subgroupShuffleXor","subgroupXor","quadBroadcast","quadSwapDiagonal","quadSwapX","quadSwapY"]);class Hs extends Gs{constructor(){super()}}class $s extends Hs{constructor(e,t,n,r,i,s){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=n,this.body=r,this.startLine=i,this.endLine=s}get astNodeType(){return"function"}search(e){if(this.attributes)for(const t of this.attributes)e(t);e(this);for(const t of this.args)e(t);this.searchBlock(this.body,e)}}class Xs extends Hs{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}}class Qs extends Hs{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Ys extends Hs{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}}class qs extends Hs{constructor(e,t,n,r){super(),this.init=e,this.condition=t,this.increment=n,this.body=r}get astNodeType(){return"for"}search(e){var t,n,r;null===(t=this.init)||void 0===t||t.search(e),null===(n=this.condition)||void 0===n||n.search(e),null===(r=this.increment)||void 0===r||r.search(e),this.searchBlock(this.body,e)}}class Ks extends Hs{constructor(e,t,n,r,i){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=r,this.value=i}get astNodeType(){return"var"}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}class Zs extends Hs{constructor(e,t,n){super(),this.attributes=null,this.name=e,this.type=t,this.value=n}get astNodeType(){return"override"}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class Js extends Hs{constructor(e,t,n,r,i){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=r,this.value=i}get astNodeType(){return"let"}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}class eo extends Hs{constructor(e,t,n,r,i){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=r,this.value=i}get astNodeType(){return"const"}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}var to,no,ro,io;(e=>{e.increment="++",e.decrement="--"})(to||(to={})),(e=>{e.parse=function(t){const n=t;if("parse"==n)throw new Error("Invalid value for IncrementOperator");return e[n]}})(to||(to={}));class so extends Hs{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=">>="})(no||(no={})),(no||(no={})).parse=function(e){const t=e;if("parse"==t)throw new Error("Invalid value for AssignOperator");return t};class oo extends Hs{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 ao extends Hs{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return Ws.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class Ao extends Hs{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 lo extends Hs{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 co extends Hs{constructor(e,t,n,r){super(),this.condition=e,this.body=t,this.elseif=n,this.else=r}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 uo extends Hs{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 ho extends Hs{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class fo extends Hs{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class po extends Hs{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class go extends Hs{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class mo extends Hs{constructor(){super()}get astNodeType(){return"discard"}}class _o extends Hs{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}class bo extends Hs{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}}class vo extends Hs{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<e.length;++n){const r=vo._priority.get(t.name);vo._priority.get(e[n].name)<r&&(t=e[n])}return"x32"===t.name?vo.i32:t}getTypeName(){return this.name}}vo.x32=new vo("x32"),vo.f32=new vo("f32"),vo.i32=new vo("i32"),vo.u32=new vo("u32"),vo.f16=new vo("f16"),vo.bool=new vo("bool"),vo.void=new vo("void"),vo._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class yo extends vo{constructor(e){super(e)}}class wo extends vo{constructor(e,t,n,r){super(e),this.members=t,this.startLine=n,this.endLine=r}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}search(e){for(const t of this.members)e(t)}}class xo extends vo{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"template"}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}}xo.vec2f=new xo("vec2",vo.f32,null),xo.vec3f=new xo("vec3",vo.f32,null),xo.vec4f=new xo("vec4",vo.f32,null),xo.vec2i=new xo("vec2",vo.i32,null),xo.vec3i=new xo("vec3",vo.i32,null),xo.vec4i=new xo("vec4",vo.i32,null),xo.vec2u=new xo("vec2",vo.u32,null),xo.vec3u=new xo("vec3",vo.u32,null),xo.vec4u=new xo("vec4",vo.u32,null),xo.vec2h=new xo("vec2",vo.f16,null),xo.vec3h=new xo("vec3",vo.f16,null),xo.vec4h=new xo("vec4",vo.f16,null),xo.vec2b=new xo("vec2",vo.bool,null),xo.vec3b=new xo("vec3",vo.bool,null),xo.vec4b=new xo("vec4",vo.bool,null),xo.mat2x2f=new xo("mat2x2",vo.f32,null),xo.mat2x3f=new xo("mat2x3",vo.f32,null),xo.mat2x4f=new xo("mat2x4",vo.f32,null),xo.mat3x2f=new xo("mat3x2",vo.f32,null),xo.mat3x3f=new xo("mat3x3",vo.f32,null),xo.mat3x4f=new xo("mat3x4",vo.f32,null),xo.mat4x2f=new xo("mat4x2",vo.f32,null),xo.mat4x3f=new xo("mat4x3",vo.f32,null),xo.mat4x4f=new xo("mat4x4",vo.f32,null),xo.mat2x2h=new xo("mat2x2",vo.f16,null),xo.mat2x3h=new xo("mat2x3",vo.f16,null),xo.mat2x4h=new xo("mat2x4",vo.f16,null),xo.mat3x2h=new xo("mat3x2",vo.f16,null),xo.mat3x3h=new xo("mat3x3",vo.f16,null),xo.mat3x4h=new xo("mat3x4",vo.f16,null),xo.mat4x2h=new xo("mat4x2",vo.f16,null),xo.mat4x3h=new xo("mat4x3",vo.f16,null),xo.mat4x4h=new xo("mat4x4",vo.f16,null),xo.mat2x2i=new xo("mat2x2",vo.i32,null),xo.mat2x3i=new xo("mat2x3",vo.i32,null),xo.mat2x4i=new xo("mat2x4",vo.i32,null),xo.mat3x2i=new xo("mat3x2",vo.i32,null),xo.mat3x3i=new xo("mat3x3",vo.i32,null),xo.mat3x4i=new xo("mat3x4",vo.i32,null),xo.mat4x2i=new xo("mat4x2",vo.i32,null),xo.mat4x3i=new xo("mat4x3",vo.i32,null),xo.mat4x4i=new xo("mat4x4",vo.i32,null),xo.mat2x2u=new xo("mat2x2",vo.u32,null),xo.mat2x3u=new xo("mat2x3",vo.u32,null),xo.mat2x4u=new xo("mat2x4",vo.u32,null),xo.mat3x2u=new xo("mat3x2",vo.u32,null),xo.mat3x3u=new xo("mat3x3",vo.u32,null),xo.mat3x4u=new xo("mat3x4",vo.u32,null),xo.mat4x2u=new xo("mat4x2",vo.u32,null),xo.mat4x3u=new xo("mat4x3",vo.u32,null),xo.mat4x4u=new xo("mat4x4",vo.u32,null);class Eo extends vo{constructor(e,t,n,r){super(e),this.storage=t,this.type=n,this.access=r}get astNodeType(){return"pointer"}}class To extends vo{constructor(e,t,n,r){super(e),this.attributes=t,this.format=n,this.count=r}get astNodeType(){return"array"}get isArray(){return!0}}class So extends vo{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"sampler"}}class Co extends Gs{constructor(){super(),this.postfix=null}}class ko extends Co{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class Ro extends Co{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 Po extends Co{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 Ws.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 Io extends Co{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 Mo extends Co{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 Lo extends Co{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 qo}get isVector(){return this.value instanceof Zo||this.value instanceof Jo}get scalarValue(){return this.value instanceof qo?this.value.value:0}get vectorValue(){return this.value instanceof Zo||this.value instanceof Jo?this.value.data:new Float32Array(0)}}class No extends Co{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class Bo extends Co{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class Do extends Co{constructor(){super()}}class Oo extends Do{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 Fo extends Do{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?vo.f32:"u32"===e.name||"u32"===t.name?vo.u32:vo.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class Uo extends Gs{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class jo extends Co{constructor(){super()}get astNodeType(){return"default"}}class Go extends Uo{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class zo extends Uo{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class Vo extends Gs{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"argument"}}class Wo extends Gs{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 Ho extends Gs{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"member"}}class $o extends Gs{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class Xo{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=Xo._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,n,r){}getSubData(e,t,n){return null}toString(){return`<${this.typeInfo.getTypeName()}>`}}Xo._id=0;class Qo extends Xo{constructor(){super(new fs("void",null),null)}toString(){return"void"}}Qo.void=new Qo;class Yo extends Xo{constructor(e){super(new _s("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,n,r){this.reference.setDataValue(e,t,n,r)}getSubData(e,t,n){return t?this.reference.getSubData(e,t,n):this}toString(){return`&${this.reference.toString()}`}}class qo extends Xo{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 qo(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new qo(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new qo(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,r){if(n)return;if(!(t instanceof qo))return;let i=t.data[0];"i32"===this.typeInfo.name||"u32"===this.typeInfo.name?i=Math.floor(i):"bool"===this.typeInfo.name&&(i=i?1:0),this.data[0]=i}getSubData(e,t,n){return t?null:this}toString(){return`${this.value}`}}function Ko(e,t,n){const r=t.length;return 2===r?"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===r?"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===r?"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 Xo{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,r){n instanceof ko||t instanceof Zo&&(this.data=t.data)}getSubData(e,t,n){if(null===t)return this;let r=e.getTypeInfo("f32");if(this.typeInfo instanceof bs)r=this.typeInfo.format||r;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?r=e.getTypeInfo("f32"):"vec2i"===t||"vec3i"===t||"vec4i"===t?r=e.getTypeInfo("i32"):"vec2b"===t||"vec3b"===t||"vec4b"===t?r=e.getTypeInfo("bool"):"vec2u"===t||"vec3u"===t||"vec4u"===t?r=e.getTypeInfo("u32"):("vec2h"===t||"vec3h"===t||"vec4h"===t)&&(r=e.getTypeInfo("f16"))}let i=this;for(;null!==t&&null!==i;){if(t instanceof Bo){const s=t.index;let o=-1;if(s instanceof Lo){if(!(s.value instanceof qo))return null;o=s.value.value}else{const t=e.evalExpression(s,n);if(!(t instanceof qo))return null;o=t.value}if(o<0||o>=i.data.length)return null;if(i.data instanceof Float32Array){const e=new Float32Array(i.data.buffer,i.data.byteOffset+4*o,1);return new qo(e,r)}if(i.data instanceof Int32Array){const e=new Int32Array(i.data.buffer,i.data.byteOffset+4*o,1);return new qo(e,r)}if(i.data instanceof Uint32Array){const e=new Uint32Array(i.data.buffer,i.data.byteOffset+4*o,1);return new qo(e,r)}throw"GetSubData: Invalid data type"}if(!(t instanceof ko))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 qo(t,r,this)}if(this.data instanceof Int32Array){let t=new Int32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new qo(t,r,this)}if(this.data instanceof Uint32Array){let t=new Uint32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new qo(t,r,this)}}const s=[];for(const e of n)"x"===e||"r"===e?s.push(this.data[0]):"y"===e||"g"===e?s.push(this.data[1]):"z"===e||"b"===e?s.push(this.data[2]):("w"===e||"a"===e)&&s.push(this.data[3]);i=Ko(e,s,r.name)}t=t.postfix}return i}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class Jo extends Xo{constructor(e,t,n=null){super(t,n),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new Jo(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,n,r){n instanceof ko||t instanceof Jo&&(this.data=t.data)}getSubData(e,t,n){if(null===t)return this;const r=this.typeInfo.name;if(e.getTypeInfo("f32"),this.typeInfo instanceof bs)this.typeInfo.format;else if(r.endsWith("f"))e.getTypeInfo("f32");else if(r.endsWith("i"))e.getTypeInfo("i32");else if(r.endsWith("u"))e.getTypeInfo("u32");else{if(!r.endsWith("h"))return null;e.getTypeInfo("f16")}if(t instanceof Bo){const i=t.index;let s=-1;if(i instanceof Lo){if(!(i.value instanceof qo))return null;s=i.value.value}else{const t=e.evalExpression(i,n);if(!(t instanceof qo))return null;s=t.value}if(s<0||s>=this.data.length)return null;const o=r.endsWith("h")?"h":"f";let a;if("mat2x2"===r||"mat2x2f"===r||"mat2x2h"===r||"mat3x2"===r||"mat3x2f"===r||"mat3x2h"===r||"mat4x2"===r||"mat4x2f"===r||"mat4x2h"===r)a=new Zo(new Float32Array(this.data.buffer,this.data.byteOffset+2*s*4,2),e.getTypeInfo(`vec2${o}`));else if("mat2x3"===r||"mat2x3f"===r||"mat2x3h"===r||"mat3x3"===r||"mat3x3f"===r||"mat3x3h"===r||"mat4x3"===r||"mat4x3f"===r||"mat4x3h"===r)a=new Zo(new Float32Array(this.data.buffer,this.data.byteOffset+3*s*4,3),e.getTypeInfo(`vec3${o}`));else{if("mat2x4"!==r&&"mat2x4f"!==r&&"mat2x4h"!==r&&"mat3x4"!==r&&"mat3x4f"!==r&&"mat3x4h"!==r&&"mat4x4"!==r&&"mat4x4f"!==r&&"mat4x4h"!==r)return null;a=new Zo(new Float32Array(this.data.buffer,this.data.byteOffset+4*s*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<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class ea extends Xo{constructor(e,t,n=0,r=null){super(t,r),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=n}clone(){const e=new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size));return new ea(e.buffer,this.typeInfo,0,null)}setDataValue(e,t,n,r){if(null===t)return;let i=this.offset,s=this.typeInfo;for(;n;){if(n instanceof Bo){if(s instanceof ms){const t=n.index;if(t instanceof Lo){if(!(t.value instanceof qo))return;i+=t.value.value*s.stride}else{const n=e.evalExpression(t,r);if(!(n instanceof qo))return;i+=n.value*s.stride}s=s.format}}else{if(!(n instanceof ko))return;{const e=n.value;if(s instanceof gs){let t=!1;for(const n of s.members)if(n.name===e){i+=n.offset,s=n.type,t=!0;break}if(!t)return}else if(s instanceof fs){const n=s.getTypeName();let r=0;if("x"===e||"r"===e)r=0;else if("y"===e||"g"===e)r=1;else if("z"===e||"b"===e)r=2;else{if("w"!==e&&"a"!==e)return;r=3}if(!(t instanceof qo))return;const o=t.value;return"vec2f"===n?void(new Float32Array(this.buffer,i,2)[r]=o):"vec3f"===n?void(new Float32Array(this.buffer,i,3)[r]=o):"vec4f"===n?void(new Float32Array(this.buffer,i,4)[r]=o):"vec2i"===n?void(new Int32Array(this.buffer,i,2)[r]=o):"vec3i"===n?void(new Int32Array(this.buffer,i,3)[r]=o):"vec4i"===n?void(new Int32Array(this.buffer,i,4)[r]=o):"vec2u"===n?void(new Uint32Array(this.buffer,i,2)[r]=o):"vec3u"===n?void(new Uint32Array(this.buffer,i,3)[r]=o):"vec4u"===n?void(new Uint32Array(this.buffer,i,4)[r]=o):void 0}}}n=n.postfix}this.setData(e,t,s,i,r)}setData(e,t,n,r,i){const s=n.getTypeName();if("f32"!==s&&"f16"!==s)if("i32"!==s&&"atomic<i32>"!==s&&"x32"!==s)if("u32"!==s&&"atomic<u32>"!==s)if("bool"!==s){if("vec2f"===s||"vec2h"===s){const e=new Float32Array(this.buffer,r,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"===s||"vec3h"===s){const e=new Float32Array(this.buffer,r,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"===s||"vec4h"===s){const e=new Float32Array(this.buffer,r,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"===s){const e=new Int32Array(this.buffer,r,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"===s){const e=new Int32Array(this.buffer,r,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"===s){const e=new Int32Array(this.buffer,r,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"===s){const e=new Uint32Array(this.buffer,r,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"===s){const e=new Uint32Array(this.buffer,r,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"===s){const e=new Uint32Array(this.buffer,r,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"===s){const e=new Uint32Array(this.buffer,r,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"===s){const e=new Uint32Array(this.buffer,r,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"===s){const e=new Uint32Array(this.buffer,r,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"===s||"mat2x2h"===s){const e=new Float32Array(this.buffer,r,4);return void(t instanceof Jo?(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"===s||"mat2x3h"===s){const e=new Float32Array(this.buffer,r,6);return void(t instanceof Jo?(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"===s||"mat2x4h"===s){const e=new Float32Array(this.buffer,r,8);return void(t instanceof Jo?(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"===s||"mat3x2h"===s){const e=new Float32Array(this.buffer,r,6);return void(t instanceof Jo?(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"===s||"mat3x3h"===s){const e=new Float32Array(this.buffer,r,9);return void(t instanceof Jo?(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"===s||"mat3x4h"===s){const e=new Float32Array(this.buffer,r,12);return void(t instanceof Jo?(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"===s||"mat4x2h"===s){const e=new Float32Array(this.buffer,r,8);return void(t instanceof Jo?(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"===s||"mat4x3h"===s){const e=new Float32Array(this.buffer,r,12);return void(t instanceof Jo?(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"===s||"mat4x4h"===s){const e=new Float32Array(this.buffer,r,16);return void(t instanceof Jo?(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 ea&&n===t.typeInfo)return void new Uint8Array(this.buffer,r,t.buffer.byteLength).set(new Uint8Array(t.buffer))}else t instanceof qo&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof qo&&(new Uint32Array(this.buffer,r,1)[0]=t.value);else t instanceof qo&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof qo&&(new Float32Array(this.buffer,r,1)[0]=t.value)}getSubData(e,t,n){var r,i;if(null===t)return this;let s=this.offset,o=this.typeInfo;for(;t;){if(t instanceof Bo){const r=t.index,i=r instanceof Co?e.evalExpression(r,n):r;let a=0;if(i instanceof qo?a=i.value:"number"==typeof i&&(a=i),o instanceof ms)s+=a*o.stride,o=o.format;else{const t=o.getTypeName();("mat4x4"===t||"mat4x4f"===t||"mat4x4h"===t)&&(s+=16*a,o=e.getTypeInfo("vec4f"))}}else{if(!(t instanceof ko))return null;{const n=t.value;if(o instanceof gs){let e=!1;for(const t of o.members)if(t.name===n){s+=t.offset,o=t.type,e=!0;break}if(!e)return null}else if(o instanceof fs){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 r="f";const i=[];for(let o=0;o<n.length;++o){const a=n[o].toLowerCase();let A=0;if("x"===a||"r"===a)A=0;else if("y"===a||"g"===a)A=1;else if("z"===a||"b"===a)A=2;else{if("w"!==a&&"a"!==a)return null;A=3}if(1===n.length){if(t.endsWith("f"))return this.buffer.byteLength<s+4*A+4?null:new qo(new Float32Array(this.buffer,s+4*A,1),e.getTypeInfo("f32"),this);if(t.endsWith("h"))return new qo(new Float32Array(this.buffer,s+4*A,1),e.getTypeInfo("f16"),this);if(t.endsWith("i"))return new qo(new Int32Array(this.buffer,s+4*A,1),e.getTypeInfo("i32"),this);if(t.endsWith("b"))return new qo(new Int32Array(this.buffer,s+4*A,1),e.getTypeInfo("bool"),this);if(t.endsWith("u"))return new qo(new Uint32Array(this.buffer,s+4*A,1),e.getTypeInfo("i32"),this)}if("vec2f"===t)i.push(new Float32Array(this.buffer,s,2)[A]);else if("vec3f"===t){if(s+12>=this.buffer.byteLength)return null;const e=new Float32Array(this.buffer,s,3);i.push(e[A])}else if("vec4f"===t)i.push(new Float32Array(this.buffer,s,4)[A]);else if("vec2i"===t)r="i",i.push(new Int32Array(this.buffer,s,2)[A]);else if("vec3i"===t)r="i",i.push(new Int32Array(this.buffer,s,3)[A]);else if("vec4i"===t)r="i",i.push(new Int32Array(this.buffer,s,4)[A]);else if("vec2u"===t){r="u";const e=new Uint32Array(this.buffer,s,2);i.push(e[A])}else"vec3u"===t?(r="u",i.push(new Uint32Array(this.buffer,s,3)[A])):"vec4u"===t&&(r="u",i.push(new Uint32Array(this.buffer,s,4)[A]))}return 2===i.length?o=e.getTypeInfo(`vec2${r}`):3===i.length?o=e.getTypeInfo(`vec3${r}`):4===i.length&&(o=e.getTypeInfo(`vec4${r}`)),new Zo(i,o,null)}return null}return null}}}t=t.postfix}const a=o.getTypeName();return"f32"===a?new qo(new Float32Array(this.buffer,s,1),o,this):"i32"===a?new qo(new Int32Array(this.buffer,s,1),o,this):"u32"===a?new qo(new Uint32Array(this.buffer,s,1),o,this):"vec2f"===a?new Zo(new Float32Array(this.buffer,s,2),o,this):"vec3f"===a?new Zo(new Float32Array(this.buffer,s,3),o,this):"vec4f"===a?new Zo(new Float32Array(this.buffer,s,4),o,this):"vec2i"===a?new Zo(new Int32Array(this.buffer,s,2),o,this):"vec3i"===a?new Zo(new Int32Array(this.buffer,s,3),o,this):"vec4i"===a?new Zo(new Int32Array(this.buffer,s,4),o,this):"vec2u"===a?new Zo(new Uint32Array(this.buffer,s,2),o,this):"vec3u"===a?new Zo(new Uint32Array(this.buffer,s,3),o,this):"vec4u"===a?new Zo(new Uint32Array(this.buffer,s,4),o,this):o instanceof bs&&"atomic"===o.name?"u32"===(null===(r=o.format)||void 0===r?void 0:r.name)?new qo(new Uint32Array(this.buffer,s,1)[0],o.format,this):"i32"===(null===(i=o.format)||void 0===i?void 0:i.name)?new qo(new Int32Array(this.buffer,s,1)[0],o.format,this):null:new ea(this.buffer,o,s,this)}toString(){let e="";if(this.typeInfo instanceof ms)if("f32"===this.typeInfo.format.name){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if("i32"===this.typeInfo.format.name){const t=new Int32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if("u32"===this.typeInfo.format.name){const t=new Uint32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if("vec2f"===this.typeInfo.format.name){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}]`;for(let n=1;n<t.length/2;++n)e+=`, [${t[2*n]}, ${t[2*n+1]}]`}else if("vec3f"===this.typeInfo.format.name){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}]`;for(let n=4;n<t.length;n+=4)e+=`, [${t[n]}, ${t[n+1]}, ${t[n+2]}]`}else if("vec4f"===this.typeInfo.format.name){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}]`;for(let n=4;n<t.length;n+=4)e+=`, [${t[n]}, ${t[n+1]}, ${t[n+2]}, ${t[n+3]}]`}else e="[...]";else this.typeInfo instanceof gs?e+="{...}":e="[...]";return e}}class ta extends Xo{constructor(e,t,n,r){super(t,null),this.data=e,this.descriptor=n,this.view=r}clone(){return new ta(this.data,this.typeInfo,this.descriptor,this.view)}get width(){var e,t;const n=this.descriptor.size;return n instanceof Array&&n.length>0?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<t.length;++n)t[n]=Math.max(1,t[n]>>e);return t}get texelByteSize(){const e=this.format,t=js[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=js[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=js[e],n=this.width;if(!e||n<=0||!t)return-1;const r=this.height,i=this.depthOrArrayLayers,s=this.dimension;return n/t.blockWidth*("1d"===s?1:r/t.blockHeight)*t.bytesPerBlock*i}getPixel(e,t,n=0,r=0){const i=this.texelByteSize,s=this.bytesPerRow,o=this.height,a=this.data[r];return function(e,t,n,r,i,s,o,a,A){const l=r*(o>>=i)*(s>>=i)+n*o+t*a;switch(A){case"r8unorm":return[Fs(e,l,"8unorm",1)[0]];case"r8snorm":return[Fs(e,l,"8snorm",1)[0]];case"r8uint":return[Fs(e,l,"8uint",1)[0]];case"r8sint":return[Fs(e,l,"8sint",1)[0]];case"rg8unorm":{const t=Fs(e,l,"8unorm",2);return[t[0],t[1]]}case"rg8snorm":{const t=Fs(e,l,"8snorm",2);return[t[0],t[1]]}case"rg8uint":{const t=Fs(e,l,"8uint",2);return[t[0],t[1]]}case"rg8sint":{const t=Fs(e,l,"8sint",2);return[t[0],t[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const t=Fs(e,l,"8unorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8snorm":{const t=Fs(e,l,"8snorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8uint":{const t=Fs(e,l,"8uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba8sint":{const t=Fs(e,l,"8sint",4);return[t[0],t[1],t[2],t[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const t=Fs(e,l,"8unorm",4);return[t[2],t[1],t[0],t[3]]}case"r16uint":return[Fs(e,l,"16uint",1)[0]];case"r16sint":return[Fs(e,l,"16sint",1)[0]];case"r16float":return[Fs(e,l,"16float",1)[0]];case"rg16uint":{const t=Fs(e,l,"16uint",2);return[t[0],t[1]]}case"rg16sint":{const t=Fs(e,l,"16sint",2);return[t[0],t[1]]}case"rg16float":{const t=Fs(e,l,"16float",2);return[t[0],t[1]]}case"rgba16uint":{const t=Fs(e,l,"16uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16sint":{const t=Fs(e,l,"16sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16float":{const t=Fs(e,l,"16float",4);return[t[0],t[1],t[2],t[3]]}case"r32uint":return[Fs(e,l,"32uint",1)[0]];case"r32sint":return[Fs(e,l,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[Fs(e,l,"32float",1)[0]];case"rg32uint":{const t=Fs(e,l,"32uint",2);return[t[0],t[1]]}case"rg32sint":{const t=Fs(e,l,"32sint",2);return[t[0],t[1]]}case"rg32float":{const t=Fs(e,l,"32float",2);return[t[0],t[1]]}case"rgba32uint":{const t=Fs(e,l,"32uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32sint":{const t=Fs(e,l,"32sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32float":{const t=Fs(e,l,"32float",4);return[t[0],t[1],t[2],t[3]]}case"rg11b10ufloat":{const t=new Uint32Array(e.buffer,l,1)[0],n=(4192256&t)>>11,r=(4290772992&t)>>22;return[Os(2047&t),Os(n),function(e){const t=112+(e>>5&31)<<23|(31&e)<<18;return Bs[0]=t,Ds[0]}(r),1]}}return null}(new Uint8Array(a),e,t,n,r,o,s,i,this.format)}setPixel(e,t,n,r,i){const s=this.texelByteSize,o=this.bytesPerRow,a=this.height,A=this.data[r];!function(e,t,n,r,i,s,o,a,A,l){const c=r*(o>>=i)*(s>>=i)+n*o+t*a;switch(A){case"r8unorm":return void Us(e,c,"8unorm",1,l);case"r8snorm":return void Us(e,c,"8snorm",1,l);case"r8uint":return void Us(e,c,"8uint",1,l);case"r8sint":return void Us(e,c,"8sint",1,l);case"rg8unorm":return void Us(e,c,"8unorm",2,l);case"rg8snorm":return void Us(e,c,"8snorm",2,l);case"rg8uint":return void Us(e,c,"8uint",2,l);case"rg8sint":return void Us(e,c,"8sint",2,l);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void Us(e,c,"8unorm",4,l);case"rgba8snorm":return void Us(e,c,"8snorm",4,l);case"rgba8uint":return void Us(e,c,"8uint",4,l);case"rgba8sint":return void Us(e,c,"8sint",4,l);case"r16uint":return void Us(e,c,"16uint",1,l);case"r16sint":return void Us(e,c,"16sint",1,l);case"r16float":return void Us(e,c,"16float",1,l);case"rg16uint":return void Us(e,c,"16uint",2,l);case"rg16sint":return void Us(e,c,"16sint",2,l);case"rg16float":return void Us(e,c,"16float",2,l);case"rgba16uint":return void Us(e,c,"16uint",4,l);case"rgba16sint":return void Us(e,c,"16sint",4,l);case"rgba16float":return void Us(e,c,"16float",4,l);case"r32uint":return void Us(e,c,"32uint",1,l);case"r32sint":return void Us(e,c,"32sint",1,l);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void Us(e,c,"32float",1,l);case"rg32uint":return void Us(e,c,"32uint",2,l);case"rg32sint":return void Us(e,c,"32sint",2,l);case"rg32float":return void Us(e,c,"32float",2,l);case"rgba32uint":return void Us(e,c,"32uint",4,l);case"rgba32sint":return void Us(e,c,"32sint",4,l);case"rgba32float":Us(e,c,"32float",4,l)}}(new Uint8Array(A),e,t,n,r,a,o,s,this.format,i)}}(e=>{e[e.token=0]="token",e[e.keyword=1]="keyword",e[e.reserved=2]="reserved"})(io||(io={}));class na{constructor(e,t,n){this.name=e,this.type=t,this.rule=n}toString(){return this.name}}class ra{}ro=ra,ra.none=new na("",io.reserved,""),ra.eof=new na("EOF",io.token,""),ra.reserved={asm:new na("asm",io.reserved,"asm"),bf16:new na("bf16",io.reserved,"bf16"),do:new na("do",io.reserved,"do"),enum:new na("enum",io.reserved,"enum"),f16:new na("f16",io.reserved,"f16"),f64:new na("f64",io.reserved,"f64"),handle:new na("handle",io.reserved,"handle"),i8:new na("i8",io.reserved,"i8"),i16:new na("i16",io.reserved,"i16"),i64:new na("i64",io.reserved,"i64"),mat:new na("mat",io.reserved,"mat"),premerge:new na("premerge",io.reserved,"premerge"),regardless:new na("regardless",io.reserved,"regardless"),typedef:new na("typedef",io.reserved,"typedef"),u8:new na("u8",io.reserved,"u8"),u16:new na("u16",io.reserved,"u16"),u64:new na("u64",io.reserved,"u64"),unless:new na("unless",io.reserved,"unless"),using:new na("using",io.reserved,"using"),vec:new na("vec",io.reserved,"vec"),void:new na("void",io.reserved,"void")},ra.keywords={array:new na("array",io.keyword,"array"),atomic:new na("atomic",io.keyword,"atomic"),bool:new na("bool",io.keyword,"bool"),f32:new na("f32",io.keyword,"f32"),i32:new na("i32",io.keyword,"i32"),mat2x2:new na("mat2x2",io.keyword,"mat2x2"),mat2x3:new na("mat2x3",io.keyword,"mat2x3"),mat2x4:new na("mat2x4",io.keyword,"mat2x4"),mat3x2:new na("mat3x2",io.keyword,"mat3x2"),mat3x3:new na("mat3x3",io.keyword,"mat3x3"),mat3x4:new na("mat3x4",io.keyword,"mat3x4"),mat4x2:new na("mat4x2",io.keyword,"mat4x2"),mat4x3:new na("mat4x3",io.keyword,"mat4x3"),mat4x4:new na("mat4x4",io.keyword,"mat4x4"),ptr:new na("ptr",io.keyword,"ptr"),sampler:new na("sampler",io.keyword,"sampler"),sampler_comparison:new na("sampler_comparison",io.keyword,"sampler_comparison"),struct:new na("struct",io.keyword,"struct"),texture_1d:new na("texture_1d",io.keyword,"texture_1d"),texture_2d:new na("texture_2d",io.keyword,"texture_2d"),texture_2d_array:new na("texture_2d_array",io.keyword,"texture_2d_array"),texture_3d:new na("texture_3d",io.keyword,"texture_3d"),texture_cube:new na("texture_cube",io.keyword,"texture_cube"),texture_cube_array:new na("texture_cube_array",io.keyword,"texture_cube_array"),texture_multisampled_2d:new na("texture_multisampled_2d",io.keyword,"texture_multisampled_2d"),texture_storage_1d:new na("texture_storage_1d",io.keyword,"texture_storage_1d"),texture_storage_2d:new na("texture_storage_2d",io.keyword,"texture_storage_2d"),texture_storage_2d_array:new na("texture_storage_2d_array",io.keyword,"texture_storage_2d_array"),texture_storage_3d:new na("texture_storage_3d",io.keyword,"texture_storage_3d"),texture_depth_2d:new na("texture_depth_2d",io.keyword,"texture_depth_2d"),texture_depth_2d_array:new na("texture_depth_2d_array",io.keyword,"texture_depth_2d_array"),texture_depth_cube:new na("texture_depth_cube",io.keyword,"texture_depth_cube"),texture_depth_cube_array:new na("texture_depth_cube_array",io.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new na("texture_depth_multisampled_2d",io.keyword,"texture_depth_multisampled_2d"),texture_external:new na("texture_external",io.keyword,"texture_external"),u32:new na("u32",io.keyword,"u32"),vec2:new na("vec2",io.keyword,"vec2"),vec3:new na("vec3",io.keyword,"vec3"),vec4:new na("vec4",io.keyword,"vec4"),bitcast:new na("bitcast",io.keyword,"bitcast"),block:new na("block",io.keyword,"block"),break:new na("break",io.keyword,"break"),case:new na("case",io.keyword,"case"),continue:new na("continue",io.keyword,"continue"),continuing:new na("continuing",io.keyword,"continuing"),default:new na("default",io.keyword,"default"),diagnostic:new na("diagnostic",io.keyword,"diagnostic"),discard:new na("discard",io.keyword,"discard"),else:new na("else",io.keyword,"else"),enable:new na("enable",io.keyword,"enable"),fallthrough:new na("fallthrough",io.keyword,"fallthrough"),false:new na("false",io.keyword,"false"),fn:new na("fn",io.keyword,"fn"),for:new na("for",io.keyword,"for"),function:new na("function",io.keyword,"function"),if:new na("if",io.keyword,"if"),let:new na("let",io.keyword,"let"),const:new na("const",io.keyword,"const"),loop:new na("loop",io.keyword,"loop"),while:new na("while",io.keyword,"while"),private:new na("private",io.keyword,"private"),read:new na("read",io.keyword,"read"),read_write:new na("read_write",io.keyword,"read_write"),return:new na("return",io.keyword,"return"),requires:new na("requires",io.keyword,"requires"),storage:new na("storage",io.keyword,"storage"),switch:new na("switch",io.keyword,"switch"),true:new na("true",io.keyword,"true"),alias:new na("alias",io.keyword,"alias"),type:new na("type",io.keyword,"type"),uniform:new na("uniform",io.keyword,"uniform"),var:new na("var",io.keyword,"var"),override:new na("override",io.keyword,"override"),workgroup:new na("workgroup",io.keyword,"workgroup"),write:new na("write",io.keyword,"write"),r8unorm:new na("r8unorm",io.keyword,"r8unorm"),r8snorm:new na("r8snorm",io.keyword,"r8snorm"),r8uint:new na("r8uint",io.keyword,"r8uint"),r8sint:new na("r8sint",io.keyword,"r8sint"),r16uint:new na("r16uint",io.keyword,"r16uint"),r16sint:new na("r16sint",io.keyword,"r16sint"),r16float:new na("r16float",io.keyword,"r16float"),rg8unorm:new na("rg8unorm",io.keyword,"rg8unorm"),rg8snorm:new na("rg8snorm",io.keyword,"rg8snorm"),rg8uint:new na("rg8uint",io.keyword,"rg8uint"),rg8sint:new na("rg8sint",io.keyword,"rg8sint"),r32uint:new na("r32uint",io.keyword,"r32uint"),r32sint:new na("r32sint",io.keyword,"r32sint"),r32float:new na("r32float",io.keyword,"r32float"),rg16uint:new na("rg16uint",io.keyword,"rg16uint"),rg16sint:new na("rg16sint",io.keyword,"rg16sint"),rg16float:new na("rg16float",io.keyword,"rg16float"),rgba8unorm:new na("rgba8unorm",io.keyword,"rgba8unorm"),rgba8unorm_srgb:new na("rgba8unorm_srgb",io.keyword,"rgba8unorm_srgb"),rgba8snorm:new na("rgba8snorm",io.keyword,"rgba8snorm"),rgba8uint:new na("rgba8uint",io.keyword,"rgba8uint"),rgba8sint:new na("rgba8sint",io.keyword,"rgba8sint"),bgra8unorm:new na("bgra8unorm",io.keyword,"bgra8unorm"),bgra8unorm_srgb:new na("bgra8unorm_srgb",io.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new na("rgb10a2unorm",io.keyword,"rgb10a2unorm"),rg11b10float:new na("rg11b10float",io.keyword,"rg11b10float"),rg32uint:new na("rg32uint",io.keyword,"rg32uint"),rg32sint:new na("rg32sint",io.keyword,"rg32sint"),rg32float:new na("rg32float",io.keyword,"rg32float"),rgba16uint:new na("rgba16uint",io.keyword,"rgba16uint"),rgba16sint:new na("rgba16sint",io.keyword,"rgba16sint"),rgba16float:new na("rgba16float",io.keyword,"rgba16float"),rgba32uint:new na("rgba32uint",io.keyword,"rgba32uint"),rgba32sint:new na("rgba32sint",io.keyword,"rgba32sint"),rgba32float:new na("rgba32float",io.keyword,"rgba32float"),static_assert:new na("static_assert",io.keyword,"static_assert")},ra.tokens={decimal_float_literal:new na("decimal_float_literal",io.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 na("hex_float_literal",io.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 na("int_literal",io.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new na("uint_literal",io.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new na("name",io.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new na("ident",io.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new na("and",io.token,"&"),and_and:new na("and_and",io.token,"&&"),arrow:new na("arrow ",io.token,"->"),attr:new na("attr",io.token,"@"),forward_slash:new na("forward_slash",io.token,"/"),bang:new na("bang",io.token,"!"),bracket_left:new na("bracket_left",io.token,"["),bracket_right:new na("bracket_right",io.token,"]"),brace_left:new na("brace_left",io.token,"{"),brace_right:new na("brace_right",io.token,"}"),colon:new na("colon",io.token,":"),comma:new na("comma",io.token,","),equal:new na("equal",io.token,"="),equal_equal:new na("equal_equal",io.token,"=="),not_equal:new na("not_equal",io.token,"!="),greater_than:new na("greater_than",io.token,">"),greater_than_equal:new na("greater_than_equal",io.token,">="),shift_right:new na("shift_right",io.token,">>"),less_than:new na("less_than",io.token,"<"),less_than_equal:new na("less_than_equal",io.token,"<="),shift_left:new na("shift_left",io.token,"<<"),modulo:new na("modulo",io.token,"%"),minus:new na("minus",io.token,"-"),minus_minus:new na("minus_minus",io.token,"--"),period:new na("period",io.token,"."),plus:new na("plus",io.token,"+"),plus_plus:new na("plus_plus",io.token,"++"),or:new na("or",io.token,"|"),or_or:new na("or_or",io.token,"||"),paren_left:new na("paren_left",io.token,"("),paren_right:new na("paren_right",io.token,")"),semicolon:new na("semicolon",io.token,";"),star:new na("star",io.token,"*"),tilde:new na("tilde",io.token,"~"),underscore:new na("underscore",io.token,"_"),xor:new na("xor",io.token,"^"),plus_equal:new na("plus_equal",io.token,"+="),minus_equal:new na("minus_equal",io.token,"-="),times_equal:new na("times_equal",io.token,"*="),division_equal:new na("division_equal",io.token,"/="),modulo_equal:new na("modulo_equal",io.token,"%="),and_equal:new na("and_equal",io.token,"&="),or_equal:new na("or_equal",io.token,"|="),xor_equal:new na("xor_equal",io.token,"^="),shift_right_equal:new na("shift_right_equal",io.token,">>="),shift_left_equal:new na("shift_left_equal",io.token,"<<=")},ra.simpleTokens={"@":ro.tokens.attr,"{":ro.tokens.brace_left,"}":ro.tokens.brace_right,":":ro.tokens.colon,",":ro.tokens.comma,"(":ro.tokens.paren_left,")":ro.tokens.paren_right,";":ro.tokens.semicolon},ra.literalTokens={"&":ro.tokens.and,"&&":ro.tokens.and_and,"->":ro.tokens.arrow,"/":ro.tokens.forward_slash,"!":ro.tokens.bang,"[":ro.tokens.bracket_left,"]":ro.tokens.bracket_right,"=":ro.tokens.equal,"==":ro.tokens.equal_equal,"!=":ro.tokens.not_equal,">":ro.tokens.greater_than,">=":ro.tokens.greater_than_equal,">>":ro.tokens.shift_right,"<":ro.tokens.less_than,"<=":ro.tokens.less_than_equal,"<<":ro.tokens.shift_left,"%":ro.tokens.modulo,"-":ro.tokens.minus,"--":ro.tokens.minus_minus,".":ro.tokens.period,"+":ro.tokens.plus,"++":ro.tokens.plus_plus,"|":ro.tokens.or,"||":ro.tokens.or_or,"*":ro.tokens.star,"~":ro.tokens.tilde,_:ro.tokens.underscore,"^":ro.tokens.xor,"+=":ro.tokens.plus_equal,"-=":ro.tokens.minus_equal,"*=":ro.tokens.times_equal,"/=":ro.tokens.division_equal,"%=":ro.tokens.modulo_equal,"&=":ro.tokens.and_equal,"|=":ro.tokens.or_equal,"^=":ro.tokens.xor_equal,">>=":ro.tokens.shift_right_equal,"<<=":ro.tokens.shift_left_equal},ra.regexTokens={decimal_float_literal:ro.tokens.decimal_float_literal,hex_float_literal:ro.tokens.hex_float_literal,int_literal:ro.tokens.int_literal,uint_literal:ro.tokens.uint_literal,ident:ro.tokens.ident},ra.storage_class=[ro.keywords.function,ro.keywords.private,ro.keywords.workgroup,ro.keywords.uniform,ro.keywords.storage],ra.access_mode=[ro.keywords.read,ro.keywords.write,ro.keywords.read_write],ra.sampler_type=[ro.keywords.sampler,ro.keywords.sampler_comparison],ra.sampled_texture_type=[ro.keywords.texture_1d,ro.keywords.texture_2d,ro.keywords.texture_2d_array,ro.keywords.texture_3d,ro.keywords.texture_cube,ro.keywords.texture_cube_array],ra.multisampled_texture_type=[ro.keywords.texture_multisampled_2d],ra.storage_texture_type=[ro.keywords.texture_storage_1d,ro.keywords.texture_storage_2d,ro.keywords.texture_storage_2d_array,ro.keywords.texture_storage_3d],ra.depth_texture_type=[ro.keywords.texture_depth_2d,ro.keywords.texture_depth_2d_array,ro.keywords.texture_depth_cube,ro.keywords.texture_depth_cube_array,ro.keywords.texture_depth_multisampled_2d],ra.texture_external_type=[ro.keywords.texture_external],ra.any_texture_type=[...ro.sampled_texture_type,...ro.multisampled_texture_type,...ro.storage_texture_type,...ro.depth_texture_type,...ro.texture_external_type],ra.texel_format=[ro.keywords.r8unorm,ro.keywords.r8snorm,ro.keywords.r8uint,ro.keywords.r8sint,ro.keywords.r16uint,ro.keywords.r16sint,ro.keywords.r16float,ro.keywords.rg8unorm,ro.keywords.rg8snorm,ro.keywords.rg8uint,ro.keywords.rg8sint,ro.keywords.r32uint,ro.keywords.r32sint,ro.keywords.r32float,ro.keywords.rg16uint,ro.keywords.rg16sint,ro.keywords.rg16float,ro.keywords.rgba8unorm,ro.keywords.rgba8unorm_srgb,ro.keywords.rgba8snorm,ro.keywords.rgba8uint,ro.keywords.rgba8sint,ro.keywords.bgra8unorm,ro.keywords.bgra8unorm_srgb,ro.keywords.rgb10a2unorm,ro.keywords.rg11b10float,ro.keywords.rg32uint,ro.keywords.rg32sint,ro.keywords.rg32float,ro.keywords.rgba16uint,ro.keywords.rgba16sint,ro.keywords.rgba16float,ro.keywords.rgba32uint,ro.keywords.rgba32sint,ro.keywords.rgba32float],ra.const_literal=[ro.tokens.int_literal,ro.tokens.uint_literal,ro.tokens.decimal_float_literal,ro.tokens.hex_float_literal,ro.keywords.true,ro.keywords.false],ra.literal_or_ident=[ro.tokens.ident,ro.tokens.int_literal,ro.tokens.uint_literal,ro.tokens.decimal_float_literal,ro.tokens.hex_float_literal,ro.tokens.name],ra.element_count_expression=[ro.tokens.int_literal,ro.tokens.uint_literal,ro.tokens.ident],ra.template_types=[ro.keywords.vec2,ro.keywords.vec3,ro.keywords.vec4,ro.keywords.mat2x2,ro.keywords.mat2x3,ro.keywords.mat2x4,ro.keywords.mat3x2,ro.keywords.mat3x3,ro.keywords.mat3x4,ro.keywords.mat4x2,ro.keywords.mat4x3,ro.keywords.mat4x4,ro.keywords.atomic,ro.keywords.bitcast,...ro.any_texture_type],ra.attribute_name=[ro.tokens.ident,ro.keywords.block,ro.keywords.diagnostic],ra.assignment_operators=[ro.tokens.equal,ro.tokens.plus_equal,ro.tokens.minus_equal,ro.tokens.times_equal,ro.tokens.division_equal,ro.tokens.modulo_equal,ro.tokens.and_equal,ro.tokens.or_equal,ro.tokens.xor_equal,ro.tokens.shift_right_equal,ro.tokens.shift_left_equal],ra.increment_operators=[ro.tokens.plus_plus,ro.tokens.minus_minus];class ia{constructor(e,t,n,r,i){this.type=e,this.lexeme=t,this.line=n,this.start=r,this.end=i}toString(){return this.lexeme}isTemplateType(){return-1!=ra.template_types.indexOf(this.type)}isArrayType(){return this.type==ra.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class sa{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 ia(ra.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=ra.simpleTokens[e];if(t)return this._addToken(t),!0;let n=ra.none;const r=this._isAlpha(e),i="_"===e;if(this._isAlphaNumeric(e)){let t=this._peekAhead();for(;this._isAlphaNumeric(t);)e+=this._advance(),t=this._peekAhead()}if(r){const t=ra.keywords[e];if(t)return this._addToken(t),!0}if(r||i)return this._addToken(ra.tokens.ident),!0;for(;;){let t=this._findType(e);const r=this._peekAhead();if("-"==e&&this._tokens.length>0){if("="==r)return this._current++,e+=r,this._addToken(ra.tokens.minus_equal),!0;if("-"==r)return this._current++,e+=r,this._addToken(ra.tokens.minus_minus),!0;const n=this._tokens.length-1;if((-1!=ra.literal_or_ident.indexOf(this._tokens[n].type)||this._tokens[n].type==ra.tokens.paren_right)&&">"!=r)return this._addToken(t),!0}if(">"==e&&(">"==r||"="==r)){let e=!1,n=this._tokens.length-1;for(let t=0;t<5&&n>=0&&-1===ra.assignment_operators.indexOf(this._tokens[n].type);++t,--n)if(this._tokens[n].type===ra.tokens.less_than){n>0&&this._tokens[n-1].isArrayOrTemplateType()&&(e=!0);break}if(e)return this._addToken(t),!0}if(t===ra.none){let r=e,i=0;const s=2;for(let e=0;e<s;++e)if(r+=this._peekAhead(e),t=this._findType(r),t!==ra.none){i=e;break}if(t===ra.none)return n!==ra.none&&(this._current--,this._addToken(n),!0);e=r,this._current+=i+1}if(n=t,this._isAtEnd())break;e+=this._advance()}return n!==ra.none&&(this._addToken(n),!0)}_findType(e){for(const t in ra.regexTokens){const n=ra.regexTokens[t];if(this._match(e,n.rule))return n}return ra.literalTokens[e]||ra.none}_match(e,t){const n=t.exec(e);return n&&0==n.index&&n[0]==e}_isAtEnd(){return this._current>=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 ia(e,t,this._line,this._start,this._current))}}function oa(e){return Array.isArray(e)||(null==e?void 0:e.buffer)instanceof ArrayBuffer}const aa=new Float32Array(1),Aa=new Uint32Array(aa.buffer),la=new Uint32Array(aa.buffer),ca=new Int32Array(1),ua=new Float32Array(ca.buffer),ha=new Uint32Array(ca.buffer),da=new Uint32Array(1),fa=new Float32Array(da.buffer),pa=new Int32Array(da.buffer);function ga(e,t,n){if(t===n)return e;if("f32"===t){if("i32"===n||"x32"===n)return aa[0]=e,Aa[0];if("u32"===n)return aa[0]=e,la[0]}else if("i32"===t||"x32"===t){if("f32"===n)return ca[0]=e,ua[0];if("u32"===n)return ca[0]=e,ha[0]}else if("u32"===t){if("f32"===n)return da[0]=e,fa[0];if("i32"===n||"x32"===n)return da[0]=e,pa[0]}return e}class ma{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class _a{constructor(e,t){this.align=e,this.size=t}}class ba{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Rs,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 $s&&this._functions.set(t.name,new ma(t));for(const t of e)if(t instanceof wo){const e=this.getTypeInfo(t,null);e instanceof gs&&this.structs.push(e)}for(const t of e)if(t instanceof go)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof Zs){const e=t,n=this._getAttributeNum(e.attributes,"id",0),r=null!=e.type?this.getTypeInfo(e.type,e.attributes):null;this.overrides.push(new Ss(e.name,r,e.attributes,n));continue}if(this._isUniformVar(t)){const e=t,n=this._getAttributeNum(e.attributes,"group",0),r=this._getAttributeNum(e.attributes,"binding",0),i=this.getTypeInfo(e.type,e.attributes),s=new ws(e.name,i,n,r,e.attributes,vs.Uniform,e.access);s.access||(s.access="read"),this.uniforms.push(s);continue}if(this._isStorageVar(t)){const e=t,n=this._getAttributeNum(e.attributes,"group",0),r=this._getAttributeNum(e.attributes,"binding",0),i=this.getTypeInfo(e.type,e.attributes),s=this._isStorageTexture(i),o=new ws(e.name,i,n,r,e.attributes,s?vs.StorageTexture:vs.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),r=this._getAttributeNum(e.attributes,"binding",0),i=this.getTypeInfo(e.type,e.attributes),s=this._isStorageTexture(i),o=new ws(e.name,i,n,r,e.attributes,s?vs.StorageTexture:vs.Texture,e.access);o.access||(o.access="read"),s?this.storage.push(o):this.textures.push(o);continue}if(this._isSamplerVar(t)){const e=t,n=this._getAttributeNum(e.attributes,"group",0),r=this._getAttributeNum(e.attributes,"binding",0),i=this.getTypeInfo(e.type,e.attributes),s=new ws(e.name,i,n,r,e.attributes,vs.Sampler,e.access);this.samplers.push(s);continue}}for(const t of e)if(t instanceof $s){const e=this._getAttribute(t,"vertex"),n=this._getAttribute(t,"fragment"),r=this._getAttribute(t,"compute"),i=e||n||r,s=new ks(t.name,null==i?void 0:i.name,t.attributes);s.attributes=t.attributes,s.startLine=t.startLine,s.endLine=t.endLine,this.functions.push(s),this._functions.get(t.name).info=s,i&&(this._functions.get(t.name).inUse=!0,s.inUse=!0,s.resources=this._findResources(t,!!i),s.inputs=this._getInputs(t.args),s.outputs=this._getOutputs(t.returnType),this.entry[i.name].push(s)),s.arguments=t.args.map(e=>new Cs(e.name,this.getTypeInfo(e.type,e.attributes),e.attributes)),s.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,r,i;if(e instanceof $o){if(e.value)if(oa(e.value))for(const s of e.value)for(const e of this.overrides)s===e.name&&(null===(n=t.info)||void 0===n||n.overrides.push(e));else for(const s of this.overrides)e.value===s.name&&(null===(r=t.info)||void 0===r||r.overrides.push(s))}else if(e instanceof Io)for(const s of this.overrides)e.name===s.name&&(null===(i=t.info)||void 0===i||i.overrides.push(s))});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 r of e.calls){const e=null===(n=this._functions.get(r.name))||void 0===n?void 0:n.info;e&&t.add(e)}}findResource(e,t,n){if(n){for(const r of this.entry.compute)if(r.name===n)for(const n of r.resources)if(n.group==e&&n.binding==t)return n;for(const r of this.entry.vertex)if(r.name===n)for(const n of r.resources)if(n.group==e&&n.binding==t)return n;for(const r of this.entry.fragment)if(r.name===n)for(const n of r.resources)if(n.group==e&&n.binding==t)return n}for(const r of this.uniforms)if(r.group==e&&r.binding==t)return r;for(const r of this.storage)if(r.group==e&&r.binding==t)return r;for(const r of this.textures)if(r.group==e&&r.binding==t)return r;for(const r of this.samplers)if(r.group==e&&r.binding==t)return r;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=[],r=this,i=[];return e.search(s=>{if(s instanceof zs)i.push({});else if(s instanceof Vs)i.pop();else if(s instanceof Ks){const e=s;t&&null!==e.type&&this._markStructsFromAST(e.type),i.length>0&&(i[i.length-1][e.name]=e)}else if(s instanceof Ro){const e=s;t&&null!==e.type&&this._markStructsFromAST(e.type)}else if(s instanceof Js){const e=s;t&&null!==e.type&&this._markStructsFromAST(e.type),i.length>0&&(i[i.length-1][e.name]=e)}else if(s instanceof Io){const e=s;if(i.length>0&&i[i.length-1][e.name])return;const t=r._findResource(e.name);t&&n.push(t)}else if(s instanceof Po){const i=s,o=r._functions.get(i.name);o&&(t&&(o.inUse=!0),e.calls.add(o.node),null===o.resources&&(o.resources=r._findResources(o.node,t)),n.push(...o.resources))}else if(s instanceof ao){const i=s,o=r._functions.get(i.name);o&&(t&&(o.inUse=!0),e.calls.add(o.node),null===o.resources&&(o.resources=r._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 wo)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 wo)this._getStructOutputs(n.type,t);else{const e=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(null!==e){const r=this.getTypeInfo(n.type,n.type.attributes),i=this._parseInt(e.value),s=new Ts(n.name,r,e.name,i);t.push(s)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const n=this.getTypeInfo(e,e.attributes),r=this._parseInt(t.value);return new Ts("",n,t.name,r)}return null}_getInputs(e,t=void 0){void 0===t&&(t=[]);for(const n of e)if(n.type instanceof wo)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 wo)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"),r=this.getTypeInfo(e.type,e.attributes),i=this._parseInt(t.value),s=new Es(e.name,r,t.name,i);return null!==n&&(s.interpolation=this._parseString(n.value)),s}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 xs(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 Eo){const n=e.type?this.getTypeInfo(e.type,e.attributes):null,r=new _s(e.name,n,t);return this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof To){const n=e,r=n.format?this.getTypeInfo(n.format,n.attributes):null,i=new ms(n.name,t);return i.format=r,i.count=n.count,this._types.set(e,i),this._updateTypeInfo(i),i}if(e instanceof wo){const n=e,r=new gs(n.name,t);r.startLine=n.startLine,r.endLine=n.endLine;for(const e of n.members){const t=this.getTypeInfo(e.type,e.attributes);r.members.push(new ps(e.name,t,e.attributes))}return this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof So){const n=e,r=n.format instanceof vo,i=n.format?r?this.getTypeInfo(n.format,null):new fs(n.format,null):null,s=new bs(n.name,i,t,n.access);return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof xo){const n=e,r=n.format?this.getTypeInfo(n.format,null):null,i=new bs(n.name,r,t,n.access);return this._types.set(e,i),this._updateTypeInfo(i),i}const n=new fs(e.name,t);return this._types.set(e,n),this._updateTypeInfo(n),n}_updateTypeInfo(e){var t,n,r;const i=this._getTypeSize(e);if(e.size=null!==(t=null==i?void 0:i.size)&&void 0!==t?t:0,e instanceof ms&&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!==(r=null==t?void 0:t.align)&&void 0!==r?r:0),this._updateTypeInfo(e.format)}e instanceof _s&&this._updateTypeInfo(e.format),e instanceof gs&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let n=0,r=0,i=0,s=0;for(let o=0,a=e.members.length;o<a;++o){const a=e.members[o],A=this._getTypeSize(a);if(!A)continue;null!==(t=this._getAlias(a.type.name))&&void 0!==t||a.type;const l=A.align,c=A.size;n=this._roundUp(l,n+r),r=c,i=n,s=Math.max(s,l),a.offset=n,a.size=c,this._updateTypeInfo(a.type)}e.size=this._roundUp(s,i+r),e.align=s}_getTypeSize(e){var t,n;if(null==e)return null;const r=this._getAttributeNum(e.attributes,"size",0),i=this._getAttributeNum(e.attributes,"align",0);if(e instanceof ps&&(e=e.type),e instanceof fs){const t=this._getAlias(e.name);null!==t&&(e=t)}{const n=ba._typeInfo[e.name];if(void 0!==n){const s="f16"===(null===(t=e.format)||void 0===t?void 0:t.name)?2:1;return new _a(Math.max(i,n.align/s),Math.max(r,n.size/s))}}{const t=ba._typeInfo[e.name.substring(0,e.name.length-1)];if(t){const n="h"===e.name[e.name.length-1]?2:1;return new _a(Math.max(i,t.align/n),Math.max(r,t.size/n))}}if(e instanceof ms){let t=e,s=8,o=8;const a=this._getTypeSize(t.format);return null!==a&&(o=a.size,s=a.align),o=t.count*this._getAttributeNum(null!==(n=null==e?void 0:e.attributes)&&void 0!==n?n:null,"stride",this._roundUp(s,o)),r&&(o=r),new _a(Math.max(i,s),Math.max(r,o))}if(e instanceof gs){let t=0,n=0,s=0,o=0,a=0;for(const r of e.members){const e=this._getTypeSize(r.type);null!==e&&(t=Math.max(e.align,t),s=this._roundUp(e.align,s+o),o=e.size,a=s)}return n=this._roundUp(t,a+o),new _a(Math.max(i,t),Math.max(r,n))}return null}_isUniformVar(e){return e instanceof Ks&&"uniform"==e.storage}_isStorageVar(e){return e instanceof Ks&&"storage"==e.storage}_isTextureVar(e){return e instanceof Ks&&null!==e.type&&-1!=ba._textureTypes.indexOf(e.type.name)}_isSamplerVar(e){return e instanceof Ks&&null!==e.type&&-1!=ba._samplerTypes.indexOf(e.type.name)}_getAttribute(e,t){const n=e;if(!n||!n.attributes)return null;const r=n.attributes;for(let i of r)if(i.name==t)return i;return null}_getAttributeNum(e,t,n){if(null===e)return n;for(let r of e)if(r.name==t){let e=null!==r&&null!==r.value?r.value:n;return e instanceof Array&&(e=e[0]),"number"==typeof e?e:"string"==typeof e?parseInt(e):n}return n}_roundUp(e,t){return Math.ceil(t/e)*e}}ba._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}},ba._textureTypes=ra.any_texture_type.map(e=>e.name),ba._samplerTypes=ra.sampler_type.map(e=>e.name);let va=0;class ya{constructor(e,t,n){this.id=va++,this.name=e,this.value=t,this.node=n}clone(){return new ya(this.name,this.value,this.node)}}class wa{constructor(e){this.id=va++,this.name=e.name,this.node=e}clone(){return new wa(this.node)}}class xa{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=va++,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 ya(e,t,null!=n?n:null))}setVariable(e,t,n){const r=this.getVariable(e);null!==r?r.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 xa(this)}}class Ea{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class Ta{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 r=!0;if(n instanceof Zo)return n.data.forEach(e=>{e||(r=!1)}),new qo(r?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 qo(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 qo))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 Oo&&(n=n.right);const r=this.exec.evalExpression(n,t);if(r instanceof ea&&0===r.typeInfo.size){const e=r.typeInfo,t=r.buffer.byteLength/e.stride;return new qo(t,this.getTypeInfo("u32"))}return new qo(r.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 r=n;return new qo(Math.abs(r.value),r.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 r=n;return new qo(Math.acos(r.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 r=n;return new qo(Math.acosh(r.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 r=n;return new qo(Math.asin(r.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 r=n;return new qo(Math.asinh(r.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 r=n;return new qo(Math.atan(r.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 r=n;return new qo(Math.atanh(r.value),n.typeInfo)}Atan2(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof Zo&&r instanceof Zo)return new Zo(n.data.map((e,t)=>Math.atan2(e,r.data[t])),n.typeInfo);const i=n,s=r;return new qo(Math.atan2(i.value,s.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 r=n;return new qo(Math.ceil(r.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),r=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof Zo&&r instanceof Zo&&i instanceof Zo)return new Zo(n.data.map((e,t)=>this._clamp(e,r.data[t],i.data[t])),n.typeInfo);const s=n,o=r,a=i;return new qo(this._clamp(s.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 r=n;return new qo(Math.cos(r.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 r=n;return new qo(Math.cos(r.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 r=n;return new qo(Math.clz32(r.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 r=n;return new qo(this._countOneBits(r.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 r=n;return new qo(this._countTrailingZeros(r.value),n.typeInfo)}Cross(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof Zo&&r instanceof Zo){if(3!==n.data.length||3!==r.data.length)return null;const e=n.data,t=r.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),r=180/Math.PI;return n instanceof Zo?new Zo(n.data.map(e=>e*r),n.typeInfo):new qo(n.value*r,this.getTypeInfo("f32"))}Determinant(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof Jo){const e=n.data,t=n.typeInfo.getTypeName(),r=t.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t)return new qo(e[0]*e[3]-e[1]*e[2],r);if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t)return new qo(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]),r);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 qo(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]),r)}return null}Distance(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof Zo&&r instanceof Zo){let e=0;for(let t=0;t<n.data.length;++t)e+=(n.data[t]-r.data[t])*(n.data[t]-r.data[t]);return new qo(Math.sqrt(e),this.getTypeInfo("f32"))}const i=n,s=r;return new qo(Math.abs(i.value-s.value),n.typeInfo)}_dot(e,t){let n=0;for(let r=0;r<e.length;++r)n+=t[r]*e[r];return n}Dot(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return n instanceof Zo&&r instanceof Zo?new qo(this._dot(n.data,r.data),this.getTypeInfo("f32")):null}Dot4U8Packed(e,t){return null}Dot4I8Packed(e,t){return null}Exp(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof Zo)return new Zo(n.data.map(e=>Math.exp(e)),n.typeInfo);const r=n;return new qo(Math.exp(r.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 r=n;return new qo(Math.pow(2,r.value),n.typeInfo)}ExtractBits(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return null;if("u32"!==i.typeInfo.name&&"x32"!==i.typeInfo.name)return null;const s=r.value,o=i.value;if(n instanceof Zo)return new Zo(n.data.map(e=>e>>s&(1<<o)-1),n.typeInfo);if("i32"!==n.typeInfo.name&&"x32"!==n.typeInfo.name)return null;const a=n.value;return new qo(a>>s&(1<<o)-1,this.getTypeInfo("i32"))}FaceForward(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof Zo&&r instanceof Zo&&i instanceof Zo){const e=this._dot(r.data,i.data);return new Zo(e<0?Array.from(n.data):n.data.map(e=>-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 r=n;return new qo(this._firstLeadingBit(r.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 r=n;return new qo(this._firstTrailingBit(r.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 r=n;return new qo(Math.floor(r.value),n.typeInfo)}Fma(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof Zo&&r instanceof Zo&&i instanceof Zo)return n.data.length!==r.data.length||n.data.length!==i.data.length?null:new Zo(n.data.map((e,t)=>e*r.data[t]+i.data[t]),n.typeInfo);const s=n,o=r,a=i;return new qo(s.value*o.value+a.value,s.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 r=n;return new qo(r.value-Math.floor(r.value),n.typeInfo)}Frexp(e,t){return null}InsertBits(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t),s=this.exec.evalExpression(e.args[3],t);if("u32"!==i.typeInfo.name&&"x32"!==i.typeInfo.name)return null;const o=i.value,a=(1<<s.value)-1<<o,A=~a;if(n instanceof Zo&&r instanceof Zo)return new Zo(n.data.map((e,t)=>e&A|r.data[t]<<o&a),n.typeInfo);const l=n.value,c=r.value;return new qo(l&A|c<<o&a,n.typeInfo)}InverseSqrt(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof Zo)return new Zo(n.data.map(e=>1/Math.sqrt(e)),n.typeInfo);const r=n;return new qo(1/Math.sqrt(r.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 qo(Math.sqrt(e),this.getTypeInfo("f32"))}const r=n;return new qo(Math.abs(r.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 r=n;return new qo(Math.log(r.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 r=n;return new qo(Math.log2(r.value),n.typeInfo)}Max(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof Zo&&r instanceof Zo)return new Zo(n.data.map((e,t)=>Math.max(e,r.data[t])),n.typeInfo);const i=n,s=r;return new qo(Math.max(i.value,s.value),n.typeInfo)}Min(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof Zo&&r instanceof Zo)return new Zo(n.data.map((e,t)=>Math.min(e,r.data[t])),n.typeInfo);const i=n,s=r;return new qo(Math.min(i.value,s.value),n.typeInfo)}Mix(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof Zo&&r instanceof Zo&&i instanceof Zo)return new Zo(n.data.map((e,t)=>n.data[t]*(1-i.data[t])+r.data[t]*i.data[t]),n.typeInfo);const s=r,o=i;return new qo(n.value*(1-o.value)+s.value*o.value,n.typeInfo)}Modf(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof Zo&&r instanceof Zo)return new Zo(n.data.map((e,t)=>e%r.data[t]),n.typeInfo);const i=r;return new qo(n.value%i.value,n.typeInfo)}Normalize(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof Zo){const r=this.Length(e,t).value;return new Zo(n.data.map(e=>e/r),n.typeInfo)}return null}Pow(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof Zo&&r instanceof Zo)return new Zo(n.data.map((e,t)=>Math.pow(e,r.data[t])),n.typeInfo);const i=n,s=r;return new qo(Math.pow(i.value,s.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 qo(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 qo(n.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof Zo&&r instanceof Zo){const e=this._dot(n.data,r.data);return new Zo(n.data.map((t,n)=>t-2*e*r.data[n]),n.typeInfo)}return null}Refract(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof Zo&&r instanceof Zo&&i instanceof qo){const e=this._dot(r.data,n.data);return new Zo(n.data.map((t,n)=>{const s=1-i.value*i.value*(1-e*e);if(s<0)return 0;const o=Math.sqrt(s);return i.value*t-(i.value*e+o)*r.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 r=n;return new qo(Math.round(r.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 r=n;return new qo(Math.min(Math.max(r.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 r=n;return new qo(Math.sign(r.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 r=n;return new qo(Math.sin(r.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 r=n;return new qo(Math.sinh(r.value),n.typeInfo)}_smoothstep(e,t,n){const r=Math.min(Math.max((n-e)/(t-e),0),1);return r*r*(3-2*r)}SmoothStep(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(i instanceof Zo&&n instanceof Zo&&r instanceof Zo)return new Zo(i.data.map((e,t)=>this._smoothstep(n.data[t],r.data[t],e)),i.typeInfo);const s=n,o=r,a=i;return new qo(this._smoothstep(s.value,o.value,a.value),i.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 r=n;return new qo(Math.sqrt(r.value),n.typeInfo)}Step(e,t){const n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(r instanceof Zo&&n instanceof Zo)return new Zo(r.data.map((e,t)=>e<n.data[t]?0:1),r.typeInfo);const i=n;return new qo(r.value<i.value?0:1,i.typeInfo)}Tan(e,t){const n=this.exec.evalExpression(e.args[0],t);if(n instanceof Zo)return new Zo(n.data.map(e=>Math.tan(e)),n.typeInfo);const r=n;return new qo(Math.tan(r.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 r=n;return new qo(Math.tanh(r.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 Jo))return null;const r=this._getTransposeType(n.typeInfo);if("mat2x2"===n.typeInfo.name||"mat2x2f"===n.typeInfo.name||"mat2x2h"===n.typeInfo.name){const e=n.data;return new Jo([e[0],e[2],e[1],e[3]],r)}if("mat2x3"===n.typeInfo.name||"mat2x3f"===n.typeInfo.name||"mat2x3h"===n.typeInfo.name){const e=n.data;return new Jo([e[0],e[3],e[6],e[1],e[4],e[7]],r)}if("mat2x4"===n.typeInfo.name||"mat2x4f"===n.typeInfo.name||"mat2x4h"===n.typeInfo.name){const e=n.data;return new Jo([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13]],r)}if("mat3x2"===n.typeInfo.name||"mat3x2f"===n.typeInfo.name||"mat3x2h"===n.typeInfo.name){const e=n.data;return new Jo([e[0],e[3],e[1],e[4],e[2],e[5]],r)}if("mat3x3"===n.typeInfo.name||"mat3x3f"===n.typeInfo.name||"mat3x3h"===n.typeInfo.name){const e=n.data;return new Jo([e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]],r)}if("mat3x4"===n.typeInfo.name||"mat3x4f"===n.typeInfo.name||"mat3x4h"===n.typeInfo.name){const e=n.data;return new Jo([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14]],r)}if("mat4x2"===n.typeInfo.name||"mat4x2f"===n.typeInfo.name||"mat4x2h"===n.typeInfo.name){const e=n.data;return new Jo([e[0],e[4],e[1],e[5],e[2],e[6]],r)}if("mat4x3"===n.typeInfo.name||"mat4x3f"===n.typeInfo.name||"mat4x3h"===n.typeInfo.name){const e=n.data;return new Jo([e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]],r)}if("mat4x4"===n.typeInfo.name||"mat4x4f"===n.typeInfo.name||"mat4x4h"===n.typeInfo.name){const e=n.data;return new Jo([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]],r)}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 r=n;return new qo(Math.trunc(r.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],r=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(n instanceof Io){const e=n.name,i=t.getVariableValue(e);if(i instanceof ta){if(r<0||r>=i.mipLevelCount)return null;const e=i.getMipLevelSize(r),t=i.dimension;return"1d"===t?new qo(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],r=this.exec.evalExpression(e.args[1],t),i=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(r instanceof Zo)||2!==r.data.length)return null;if(n instanceof Io){const e=n.name,s=t.getVariableValue(e);if(s instanceof ta){const e=Math.floor(r.data[0]),t=Math.floor(r.data[1]);if(e<0||e>=s.width||t<0||t>=s.height)return null;const n=s.getPixel(e,t,0,i);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 Io){const e=n.name,r=t.getVariableValue(e);return r instanceof ta?new qo(r.depthOrArrayLayers,this.getTypeInfo("u32")):null}return null}TextureNumLevels(e,t){const n=e.args[0];if(n instanceof Io){const e=n.name,r=t.getVariableValue(e);return r instanceof ta?new qo(r.mipLevelCount,this.getTypeInfo("u32")):null}return null}TextureNumSamples(e,t){const n=e.args[0];if(n instanceof Io){const e=n.name,r=t.getVariableValue(e);return r instanceof ta?new qo(r.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],r=this.exec.evalExpression(e.args[1],t),i=4===e.args.length?this.exec.evalExpression(e.args[2],t).value:0,s=4===e.args.length?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(4!==s.length)return null;if(!(r instanceof Zo)||2!==r.data.length)return null;if(n instanceof Io){const e=n.name,o=t.getVariableValue(e);if(o instanceof ta){const e=o.getMipLevelSize(0),t=Math.floor(r.data[0]),n=Math.floor(r.data[1]);return t<0||t>=e[0]||n<0||n>=e[1]||o.setPixel(t,n,0,i,Array.from(s)),null}return null}return null}AtomicLoad(e,t){let n=e.args[0];n instanceof Oo&&(n=n.right);const r=this.exec.getVariableName(n,t);return t.getVariable(r).value.getSubData(this.exec,n.postfix,t)}AtomicStore(e,t){let n=e.args[0];n instanceof Oo&&(n=n.right);const r=this.exec.getVariableName(n,t),i=t.getVariable(r);let s=e.args[1];const o=this.exec.evalExpression(s,t),a=i.value.getSubData(this.exec,n.postfix,t);return a instanceof qo&&o instanceof qo&&(a.value=o.value),i.value instanceof ea&&i.value.setDataValue(this.exec,a,n.postfix,t),null}AtomicAdd(e,t){let n=e.args[0];n instanceof Oo&&(n=n.right);const r=this.exec.getVariableName(n,t),i=t.getVariable(r);let s=e.args[1];const o=this.exec.evalExpression(s,t),a=i.value.getSubData(this.exec,n.postfix,t),A=new qo(a.value,a.typeInfo);return a instanceof qo&&o instanceof qo&&(a.value+=o.value),i.value instanceof ea&&i.value.setDataValue(this.exec,a,n.postfix,t),A}AtomicSub(e,t){let n=e.args[0];n instanceof Oo&&(n=n.right);const r=this.exec.getVariableName(n,t),i=t.getVariable(r);let s=e.args[1];const o=this.exec.evalExpression(s,t),a=i.value.getSubData(this.exec,n.postfix,t),A=new qo(a.value,a.typeInfo);return a instanceof qo&&o instanceof qo&&(a.value-=o.value),i.value instanceof ea&&i.value.setDataValue(this.exec,a,n.postfix,t),A}AtomicMax(e,t){let n=e.args[0];n instanceof Oo&&(n=n.right);const r=this.exec.getVariableName(n,t),i=t.getVariable(r);let s=e.args[1];const o=this.exec.evalExpression(s,t),a=i.value.getSubData(this.exec,n.postfix,t),A=new qo(a.value,a.typeInfo);return a instanceof qo&&o instanceof qo&&(a.value=Math.max(a.value,o.value)),i.value instanceof ea&&i.value.setDataValue(this.exec,a,n.postfix,t),A}AtomicMin(e,t){let n=e.args[0];n instanceof Oo&&(n=n.right);const r=this.exec.getVariableName(n,t),i=t.getVariable(r);let s=e.args[1];const o=this.exec.evalExpression(s,t),a=i.value.getSubData(this.exec,n.postfix,t),A=new qo(a.value,a.typeInfo);return a instanceof qo&&o instanceof qo&&(a.value=Math.min(a.value,o.value)),i.value instanceof ea&&i.value.setDataValue(this.exec,a,n.postfix,t),A}AtomicAnd(e,t){let n=e.args[0];n instanceof Oo&&(n=n.right);const r=this.exec.getVariableName(n,t),i=t.getVariable(r);let s=e.args[1];const o=this.exec.evalExpression(s,t),a=i.value.getSubData(this.exec,n.postfix,t),A=new qo(a.value,a.typeInfo);return a instanceof qo&&o instanceof qo&&(a.value=a.value&o.value),i.value instanceof ea&&i.value.setDataValue(this.exec,a,n.postfix,t),A}AtomicOr(e,t){let n=e.args[0];n instanceof Oo&&(n=n.right);const r=this.exec.getVariableName(n,t),i=t.getVariable(r);let s=e.args[1];const o=this.exec.evalExpression(s,t),a=i.value.getSubData(this.exec,n.postfix,t),A=new qo(a.value,a.typeInfo);return a instanceof qo&&o instanceof qo&&(a.value=a.value|o.value),i.value instanceof ea&&i.value.setDataValue(this.exec,a,n.postfix,t),A}AtomicXor(e,t){let n=e.args[0];n instanceof Oo&&(n=n.right);const r=this.exec.getVariableName(n,t),i=t.getVariable(r);let s=e.args[1];const o=this.exec.evalExpression(s,t),a=i.value.getSubData(this.exec,n.postfix,t),A=new qo(a.value,a.typeInfo);return a instanceof qo&&o instanceof qo&&(a.value=a.value^o.value),i.value instanceof ea&&i.value.setDataValue(this.exec,a,n.postfix,t),A}AtomicExchange(e,t){let n=e.args[0];n instanceof Oo&&(n=n.right);const r=this.exec.getVariableName(n,t),i=t.getVariable(r);let s=e.args[1];const o=this.exec.evalExpression(s,t),a=i.value.getSubData(this.exec,n.postfix,t),A=new qo(a.value,a.typeInfo);return a instanceof qo&&o instanceof qo&&(a.value=o.value),i.value instanceof ea&&i.value.setDataValue(this.exec,a,n.postfix,t),A}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 Sa={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},Ca={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 ka extends Ea{constructor(e,t){var n;super(),this.ast=null!=e?e:[],this.reflection=new ba,this.reflection.updateAST(this.ast),this.context=null!==(n=null==t?void 0:t.clone())&&void 0!==n?n:new xa,this.builtins=new Ta(this),this.typeInfo={bool:this.getTypeInfo(vo.bool),i32:this.getTypeInfo(vo.i32),u32:this.getTypeInfo(vo.u32),f32:this.getTypeInfo(vo.f32),f16:this.getTypeInfo(vo.f16),vec2f:this.getTypeInfo(xo.vec2f),vec2u:this.getTypeInfo(xo.vec2u),vec2i:this.getTypeInfo(xo.vec2i),vec2h:this.getTypeInfo(xo.vec2h),vec3f:this.getTypeInfo(xo.vec3f),vec3u:this.getTypeInfo(xo.vec3u),vec3i:this.getTypeInfo(xo.vec3i),vec3h:this.getTypeInfo(xo.vec3h),vec4f:this.getTypeInfo(xo.vec4f),vec4u:this.getTypeInfo(xo.vec4u),vec4i:this.getTypeInfo(xo.vec4i),vec4h:this.getTypeInfo(xo.vec4h),mat2x2f:this.getTypeInfo(xo.mat2x2f),mat2x3f:this.getTypeInfo(xo.mat2x3f),mat2x4f:this.getTypeInfo(xo.mat2x4f),mat3x2f:this.getTypeInfo(xo.mat3x2f),mat3x3f:this.getTypeInfo(xo.mat3x3f),mat3x4f:this.getTypeInfo(xo.mat3x4f),mat4x2f:this.getTypeInfo(xo.mat4x2f),mat4x3f:this.getTypeInfo(xo.mat4x3f),mat4x4f:this.getTypeInfo(xo.mat4x4f)}}getVariableValue(e){var t,n;const r=null!==(n=null===(t=this.context.getVariable(e))||void 0===t?void 0:t.value)&&void 0!==n?n:null;if(null===r)return null;if(r instanceof qo)return r.value;if(r instanceof Zo)return Array.from(r.data);if(r instanceof Jo)return Array.from(r.data);if(r instanceof ea&&r.typeInfo instanceof ms){if("u32"===r.typeInfo.format.name)return Array.from(new Uint32Array(r.buffer,r.offset,r.typeInfo.count));if("i32"===r.typeInfo.format.name)return Array.from(new Int32Array(r.buffer,r.offset,r.typeInfo.count));if("f32"===r.typeInfo.format.name)return Array.from(new Float32Array(r.buffer,r.offset,r.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,r){const i=this.context.clone();(r=null!=r?r:{}).constants&&this._setOverrides(r.constants,i),this._execStatements(this.ast,i);const s=i.getFunction(e);if(!s)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],A=t[2],l=this.getTypeInfo("vec3u");i.setVariable("@num_workgroups",new Zo(t,l));const c=this.reflection.getFunctionInfo(e);for(const u in n)for(const e in n[u]){const t=n[u][e];i.variables.forEach(n=>{var r;const i=n.node;if(null==i?void 0:i.attributes){let s=null,o=null;for(const e of i.attributes)"binding"===e.name?s=e.value:"group"===e.name&&(o=e.value);if(e==s&&u==o){let s=!1;for(const t of c.resources)if(t.name===n.name&&t.group===parseInt(u)&&t.binding===parseInt(e)){s=!0;break}if(s)if(void 0!==t.texture&&void 0!==t.descriptor){const e=new ta(t.texture,this.getTypeInfo(i.type),t.descriptor,null!==(r=t.texture.view)&&void 0!==r?r:null);n.value=e}else void 0!==t.uniform?n.value=new ea(t.uniform,this.getTypeInfo(i.type)):n.value=new ea(t,this.getTypeInfo(i.type))}}})}for(let u=0;u<A;++u)for(let e=0;e<a;++e)for(let t=0;t<o;++t)i.setVariable("@workgroup_id",new Zo([t,e,u],this.getTypeInfo("vec3u"))),this._dispatchWorkgroup(s,[t,e,u],i)}execStatement(e,t){if(e instanceof uo)return this.evalExpression(e.value,t);if(e instanceof _o){if(e.condition){const n=this.evalExpression(e.condition,t);if(!(n instanceof qo))throw new Error("Invalid break-if condition");if(!n.value)return null}return ka._breakObj}if(e instanceof bo)return ka._continueObj;if(e instanceof Js)this._let(e,t);else if(e instanceof Ks)this._var(e,t);else if(e instanceof eo)this._const(e,t);else if(e instanceof $s)this._function(e,t);else{if(e instanceof co)return this._if(e,t);if(e instanceof lo)return this._switch(e,t);if(e instanceof qs)return this._for(e,t);if(e instanceof Qs)return this._while(e,t);if(e instanceof Ao)return this._loop(e,t);if(e instanceof Ys){const n=t.clone();return n.currentFunctionName=t.currentFunctionName,this._execStatements(e.body,n)}if(e instanceof oo)this._assign(e,t);else if(e instanceof so)this._increment(e,t);else{if(e instanceof wo)return null;if(e instanceof Zs){const n=e.name;null===t.getVariable(n)&&t.setVariable(n,new qo(0,this.getTypeInfo("u32")))}else if(e instanceof ao)this._call(e,t);else{if(e instanceof po)return null;if(e instanceof go)return null}}}return null}evalExpression(e,t){return e instanceof Fo?this._evalBinaryOp(e,t):e instanceof Lo?this._evalLiteral(e,t):e instanceof Io?this._evalVariable(e,t):e instanceof Po?this._evalCall(e,t):e instanceof Ro?this._evalCreate(e,t):e instanceof Mo?this._evalConst(e,t):e instanceof No?this._evalBitcast(e,t):e instanceof Oo?this._evalUnaryOp(e,t):null}getTypeInfo(e){var t;if(e instanceof vo){const t=this.reflection.getTypeInfo(e);if(null!==t)return t}let n=null!==(t=this.typeInfo[e])&&void 0!==t?t:null;return null!==n||(n=this.reflection.getTypeInfoByName(e)),n}_setOverrides(e,t){for(const n in e){const r=e[n],i=this.reflection.getOverrideInfo(n);null!==i&&(null===i.type&&(i.type=this.getTypeInfo("u32")),"u32"===i.type.name||"i32"===i.type.name||"f32"===i.type.name||"f16"===i.type.name?t.setVariable(n,new qo(r,i.type)):"bool"===i.type.name?t.setVariable(n,new qo(r?1:0,i.type)):("vec2"===i.type.name||"vec3"===i.type.name||"vec4"===i.type.name||"vec2f"===i.type.name||"vec3f"===i.type.name||"vec4f"===i.type.name||"vec2i"===i.type.name||"vec3i"===i.type.name||"vec4i"===i.type.name||"vec2u"===i.type.name||"vec3u"===i.type.name||"vec4u"===i.type.name||"vec2h"===i.type.name||"vec3h"===i.type.name||"vec4h"===i.type.name)&&t.setVariable(n,new Zo(r,i.type)))}}_dispatchWorkgroup(e,t,n){const r=[1,1,1];for(const l of e.node.attributes)if("workgroup_size"===l.name){if(l.value.length>0){const e=n.getVariableValue(l.value[0]);r[0]=e instanceof qo?e.value:parseInt(l.value[0])}if(l.value.length>1){const e=n.getVariableValue(l.value[1]);r[1]=e instanceof qo?e.value:parseInt(l.value[1])}if(l.value.length>2){const e=n.getVariableValue(l.value[2]);r[2]=e instanceof qo?e.value:parseInt(l.value[2])}}const i=this.getTypeInfo("vec3u"),s=this.getTypeInfo("u32");n.setVariable("@workgroup_size",new Zo(r,i));const o=r[0],a=r[1],A=r[2];for(let l=0,c=0;l<A;++l)for(let A=0;A<a;++A)for(let a=0;a<o;++a,++c){const o=[a,A,l],u=[a+t[0]*r[0],A+t[1]*r[1],l+t[2]*r[2]];n.setVariable("@local_invocation_id",new Zo(o,i)),n.setVariable("@global_invocation_id",new Zo(u,i)),n.setVariable("@local_invocation_index",new qo(c,s)),this._dispatchExec(e,n)}}_dispatchExec(e,t){for(const n of e.node.args)for(const e of n.attributes)if("builtin"===e.name){const r=`@${e.value}`,i=t.getVariable(r);void 0!==i&&t.variables.set(n.name,i)}this._execStatements(e.node.body,t)}getVariableName(e,t){for(;e instanceof Oo;)e=e.right;return e instanceof Io?e.name:null}_execStatements(e,t){for(const n of e){if(n instanceof Array){const e=t.clone(),r=this._execStatements(n,e);if(r)return r;continue}const e=this.execStatement(n,t);if(e)return e}return null}_call(e,t){const n=t.clone();n.currentFunctionName=e.name;const r=t.getFunction(e.name);if(r){for(let t=0;t<r.node.args.length;++t){const i=r.node.args[t],s=this.evalExpression(e.args[t],n);n.setVariable(i.name,s,i)}this._execStatements(r.node.body,n)}else e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)&&this._evalCreate(e,t)}_increment(e,t){const n=this.getVariableName(e.variable,t),r=t.getVariable(n);r&&("++"===e.operator?r.value instanceof qo&&r.value.value++:"--"===e.operator&&r.value instanceof qo&&r.value.value--)}_getVariableData(e,t){if(e instanceof Io){const n=this.getVariableName(e,t),r=t.getVariable(n);return null===r?null:r.value.getSubData(this,e.postfix,t)}if(e instanceof Oo){if("*"===e.operator){const n=this._getVariableData(e.right,t);return n instanceof Yo?n.reference.getSubData(this,e.postfix,t):null}if("&"===e.operator){const n=this._getVariableData(e.right,t);return new Yo(n)}}return null}_assign(e,t){let n=null,r="<var>",i=null;if(e.variable instanceof Oo){const n=this._getVariableData(e.variable,t),r=this.evalExpression(e.value,t),i=e.operator;if("="===i){if(n instanceof qo||n instanceof Zo||n instanceof Jo){if(r instanceof qo||r instanceof Zo||r instanceof Jo&&n.data.length===r.data.length)return void n.data.set(r.data)}else if(n instanceof ea&&r instanceof ea&&n.buffer.byteLength-n.offset>=r.buffer.byteLength-r.offset)return void(n.buffer.byteLength%4==0?new Uint32Array(n.buffer,n.offset,n.typeInfo.size/4).set(new Uint32Array(r.buffer,r.offset,r.typeInfo.size/4)):new Uint8Array(n.buffer,n.offset,n.typeInfo.size).set(new Uint8Array(r.buffer,r.offset,r.typeInfo.size)));return null}if("+="===i)return(n instanceof qo||n instanceof Zo||n instanceof Jo)&&(r instanceof qo||r instanceof Zo||r instanceof Jo)?void n.data.set(r.data.map((e,t)=>n.data[t]+e)):void 0;if("-="===i)return(n instanceof qo||n instanceof Zo||n instanceof Jo)&&(r instanceof qo||r instanceof Zo||r instanceof Jo)?void n.data.set(r.data.map((e,t)=>n.data[t]-e)):void 0}if(e.variable instanceof Oo){if("*"===e.variable.operator){r=this.getVariableName(e.variable.right,t);const i=t.getVariable(r);if(!(i&&i.value instanceof Yo))return;n=i.value.reference;let s=e.variable.postfix;if(!s){let t=e.variable.right;for(;t instanceof Oo;){if(t.postfix){s=t.postfix;break}t=t.right}}s&&(n=n.getSubData(this,s,t))}}else{i=e.variable.postfix,r=this.getVariableName(e.variable,t);const s=t.getVariable(r);if(null===s)return;n=s.value}if(n instanceof Yo&&(n=n.reference),null===n)return;const s=this.evalExpression(e.value,t),o=e.operator;if("="!==o){const e=n.getSubData(this,i,t);if(e instanceof Zo&&s instanceof qo){const t=e.data,n=s.value;if("+="===o)for(let e=0;e<t.length;++e)t[e]+=n;else if("-="===o)for(let e=0;e<t.length;++e)t[e]-=n;else if("*="===o)for(let e=0;e<t.length;++e)t[e]*=n;else if("/="===o)for(let e=0;e<t.length;++e)t[e]/=n;else if("%="===o)for(let e=0;e<t.length;++e)t[e]%=n;else if("&="===o)for(let e=0;e<t.length;++e)t[e]&=n;else if("|="===o)for(let e=0;e<t.length;++e)t[e]|=n;else if("^="===o)for(let e=0;e<t.length;++e)t[e]^=n;else if("<<="===o)for(let e=0;e<t.length;++e)t[e]<<=n;else if(">>="===o)for(let e=0;e<t.length;++e)t[e]>>=n}else if(e instanceof Zo&&s instanceof Zo){const t=e.data,n=s.data;if(t.length!==n.length)return;if("+="===o)for(let e=0;e<t.length;++e)t[e]+=n[e];else if("-="===o)for(let e=0;e<t.length;++e)t[e]-=n[e];else if("*="===o)for(let e=0;e<t.length;++e)t[e]*=n[e];else if("/="===o)for(let e=0;e<t.length;++e)t[e]/=n[e];else if("%="===o)for(let e=0;e<t.length;++e)t[e]%=n[e];else if("&="===o)for(let e=0;e<t.length;++e)t[e]&=n[e];else if("|="===o)for(let e=0;e<t.length;++e)t[e]|=n[e];else if("^="===o)for(let e=0;e<t.length;++e)t[e]^=n[e];else if("<<="===o)for(let e=0;e<t.length;++e)t[e]<<=n[e];else if(">>="===o)for(let e=0;e<t.length;++e)t[e]>>=n[e]}else{if(!(e instanceof qo&&s instanceof qo))return;"+="===o?e.value+=s.value:"-="===o?e.value-=s.value:"*="===o?e.value*=s.value:"/="===o?e.value/=s.value:"%="===o?e.value%=s.value:"&="===o?e.value&=s.value:"|="===o?e.value|=s.value:"^="===o?e.value^=s.value:"<<="===o?e.value<<=s.value:">>="===o&&(e.value>>=s.value)}return void(n instanceof ea&&n.setDataValue(this,e,i,t))}if(n instanceof ea)n.setDataValue(this,s,i,t);else if(i){if(!(n instanceof Zo||n instanceof Jo))return;if(i instanceof Bo){const e=this.evalExpression(i.index,t).value;if(n instanceof Zo){if(!(s instanceof qo))return;n.data[e]=s.value}else{if(!(n instanceof Jo))return;{const e=this.evalExpression(i.index,t).value;if(e<0)return;if(!(s instanceof Zo))return;{const t=n.typeInfo.getTypeName();if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t){if(!(e<2&&2===s.data.length))return;n.data[2*e]=s.data[0],n.data[2*e+1]=s.data[1]}else if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t){if(!(e<2&&3===s.data.length))return;n.data[3*e]=s.data[0],n.data[3*e+1]=s.data[1],n.data[3*e+2]=s.data[2]}else if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t){if(!(e<2&&4===s.data.length))return;n.data[4*e]=s.data[0],n.data[4*e+1]=s.data[1],n.data[4*e+2]=s.data[2],n.data[4*e+3]=s.data[3]}else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t){if(!(e<3&&2===s.data.length))return;n.data[2*e]=s.data[0],n.data[2*e+1]=s.data[1]}else if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t){if(!(e<3&&3===s.data.length))return;n.data[3*e]=s.data[0],n.data[3*e+1]=s.data[1],n.data[3*e+2]=s.data[2]}else if("mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t){if(!(e<3&&4===s.data.length))return;n.data[4*e]=s.data[0],n.data[4*e+1]=s.data[1],n.data[4*e+2]=s.data[2],n.data[4*e+3]=s.data[3]}else if("mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t){if(!(e<4&&2===s.data.length))return;n.data[2*e]=s.data[0],n.data[2*e+1]=s.data[1]}else if("mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t){if(!(e<4&&3===s.data.length))return;n.data[3*e]=s.data[0],n.data[3*e+1]=s.data[1],n.data[3*e+2]=s.data[2]}else{if("mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t)return;if(!(e<4&&4===s.data.length))return;n.data[4*e]=s.data[0],n.data[4*e+1]=s.data[1],n.data[4*e+2]=s.data[2],n.data[4*e+3]=s.data[3]}}}}}else if(i instanceof ko){const e=i.value;if(!(n instanceof Zo))return;if(s instanceof qo){if(e.length>1)return;if("x"===e)n.data[0]=s.value;else if("y"===e){if(n.data.length<2)return;n.data[1]=s.value}else if("z"===e){if(n.data.length<3)return;n.data[2]=s.value}else if("w"===e){if(n.data.length<4)return;n.data[3]=s.value}}else{if(!(s instanceof Zo))return;if(e.length!==s.data.length)return;for(let t=0;t<e.length;++t){const r=e[t];if("x"===r||"r"===r)n.data[0]=s.data[t];else if("y"===r||"g"===r){if(s.data.length<2)return;n.data[1]=s.data[t]}else if("z"===r||"b"===r){if(s.data.length<3)return;n.data[2]=s.data[t]}else{if("w"!==r&&"a"!==r)return;if(s.data.length<4)return;n.data[3]=s.data[t]}}}}}else n instanceof qo&&s instanceof qo?n.value=s.value:(n instanceof Zo&&s instanceof Zo||n instanceof Jo&&s instanceof Jo)&&n.data.set(s.data)}_function(e,t){const n=new wa(e);t.functions.set(e.name,n)}_const(e,t){let n=null;null!==e.value&&(n=this.evalExpression(e.value,t)),t.createVariable(e.name,n,e)}_let(e,t){let n=null;if(null!==e.value){if(n=this.evalExpression(e.value,t),null===n)return;e.value instanceof Oo||(n=n.clone())}else{const r=e.type.name;if("f32"===r||"i32"===r||"u32"===r||"bool"===r||"f16"===r||"vec2"===r||"vec3"===r||"vec4"===r||"vec2f"===r||"vec3f"===r||"vec4f"===r||"vec2i"===r||"vec3i"===r||"vec4i"===r||"vec2u"===r||"vec3u"===r||"vec4u"===r||"vec2h"===r||"vec3h"===r||"vec4h"===r||"vec2b"===r||"vec3b"===r||"vec4b"===r||"mat2x2"===r||"mat2x3"===r||"mat2x4"===r||"mat3x2"===r||"mat3x3"===r||"mat3x4"===r||"mat4x2"===r||"mat4x3"===r||"mat4x4"===r||"mat2x2f"===r||"mat2x3f"===r||"mat2x4f"===r||"mat3x2f"===r||"mat3x3f"===r||"mat3x4f"===r||"mat4x2f"===r||"mat4x3f"===r||"mat4x4f"===r||"mat2x2h"===r||"mat2x3h"===r||"mat2x4h"===r||"mat3x2h"===r||"mat3x3h"===r||"mat3x4h"===r||"mat4x2h"===r||"mat4x3h"===r||"mat4x4h"===r||"array"===r){const r=new Ro(e.type,[]);n=this._evalCreate(r,t)}}t.createVariable(e.name,n,e)}_var(e,t){let n=null;if(null!==e.value){if(n=this.evalExpression(e.value,t),null===n)return;e.value instanceof Oo||(n=n.clone())}else{if(null===e.type)return;const r=e.type.name;if("f32"===r||"i32"===r||"u32"===r||"bool"===r||"f16"===r||"vec2"===r||"vec3"===r||"vec4"===r||"vec2f"===r||"vec3f"===r||"vec4f"===r||"vec2i"===r||"vec3i"===r||"vec4i"===r||"vec2u"===r||"vec3u"===r||"vec4u"===r||"vec2h"===r||"vec3h"===r||"vec4h"===r||"vec2b"===r||"vec3b"===r||"vec4b"===r||"mat2x2"===r||"mat2x3"===r||"mat2x4"===r||"mat3x2"===r||"mat3x3"===r||"mat3x4"===r||"mat4x2"===r||"mat4x3"===r||"mat4x4"===r||"mat2x2f"===r||"mat2x3f"===r||"mat2x4f"===r||"mat3x2f"===r||"mat3x3f"===r||"mat3x4f"===r||"mat4x2f"===r||"mat4x3f"===r||"mat4x4f"===r||"mat2x2h"===r||"mat2x3h"===r||"mat2x4h"===r||"mat3x2h"===r||"mat3x3h"===r||"mat3x4h"===r||"mat4x2h"===r||"mat4x3h"===r||"mat4x4h"===r||e.type instanceof To||e.type instanceof wo||e.type instanceof xo){const r=new Ro(e.type,[]);n=this._evalCreate(r,t)}}t.createVariable(e.name,n,e)}_switch(e,t){t=t.clone();const n=this.evalExpression(e.condition,t);if(!(n instanceof qo))return null;let r=null;for(const i of e.cases)if(i instanceof Go)for(const e of i.selectors){if(e instanceof jo){r=i;continue}const s=this.evalExpression(e,t);if(!(s instanceof qo))return null;if(s.value===n.value)return this._execStatements(i.body,t)}else i instanceof zo&&(r=i);return r?this._execStatements(r.body,t):null}_if(e,t){t=t.clone();const n=this.evalExpression(e.condition,t);if(!(n instanceof qo))return null;if(n.value)return this._execStatements(e.body,t);for(const r of e.elseif){const e=this.evalExpression(r.condition,t);if(!(e instanceof qo))return null;if(e.value)return this._execStatements(r.body,t)}return e.else?this._execStatements(e.else,t):null}_getScalarValue(e){return e instanceof qo?e.value:0}_for(e,t){for(t=t.clone(),this.execStatement(e.init,t);this._getScalarValue(this.evalExpression(e.condition,t));){const n=this._execStatements(e.body,t);if(n===ka._breakObj)break;if(null!==n&&n!==ka._continueObj)return n;this.execStatement(e.increment,t)}return null}_loop(e,t){for(t=t.clone();;){const n=this._execStatements(e.body,t);if(n===ka._breakObj)break;if(n===ka._continueObj){if(e.continuing&&this._execStatements(e.continuing.body,t)===ka._breakObj)break}else if(null!==n)return n}return null}_while(e,t){for(t=t.clone();this._getScalarValue(this.evalExpression(e.condition,t));){const n=this._execStatements(e.body,t);if(n===ka._breakObj)break;if(n!==ka._continueObj&&null!==n)return n}return null}_evalBitcast(e,t){const n=this.evalExpression(e.value,t),r=e.type;if(n instanceof qo){const e=ga(n.value,n.typeInfo.name,r.name);return new qo(e,this.getTypeInfo(r))}if(n instanceof Zo){const e=n.typeInfo.getTypeName();let t="";if(e.endsWith("f"))t="f32";else if(e.endsWith("i"))t="i32";else if(e.endsWith("u"))t="u32";else if(e.endsWith("b"))t="bool";else{if(!e.endsWith("h"))return null;t="f16"}const i=r.getTypeName();let s="";if(i.endsWith("f"))s="f32";else if(i.endsWith("i"))s="i32";else if(i.endsWith("u"))s="u32";else if(i.endsWith("b"))s="bool";else{if(!i.endsWith("h"))return null;s="f16"}const o=function(e,t,n){if(t===n)return e;const r=new Array(e.length);for(let i=0;i<e.length;i++)r[i]=ga(e[i],t,n);return r}(Array.from(n.data),t,s);return new Zo(o,this.getTypeInfo(r))}return null}_evalConst(e,t){return t.getVariableValue(e.name).clone().getSubData(this,e.postfix,t)}_evalCreate(e,t){var n;if(e instanceof Ro){if(null===e.type)return Qo.void;switch(e.type.getTypeName()){case"bool":case"i32":case"u32":case"f32":case"f16":return this._callConstructorValue(e,t);case"vec2":case"vec3":case"vec4":case"vec2f":case"vec3f":case"vec4f":case"vec2h":case"vec3h":case"vec4h":case"vec2i":case"vec3i":case"vec4i":case"vec2u":case"vec3u":case"vec4u":case"vec2b":case"vec3b":case"vec4b":return this._callConstructorVec(e,t);case"mat2x2":case"mat2x2f":case"mat2x2h":case"mat2x3":case"mat2x3f":case"mat2x3h":case"mat2x4":case"mat2x4f":case"mat2x4h":case"mat3x2":case"mat3x2f":case"mat3x2h":case"mat3x3":case"mat3x3f":case"mat3x3h":case"mat3x4":case"mat3x4f":case"mat3x4h":case"mat4x2":case"mat4x2f":case"mat4x2h":case"mat4x3":case"mat4x3f":case"mat4x3h":case"mat4x4":case"mat4x4f":case"mat4x4h":return this._callConstructorMatrix(e,t)}}e instanceof Ro?e.type.name:e.name;const r=e instanceof Ro?this.getTypeInfo(e.type):this.getTypeInfo(e.name);if(null===r)return null;if(0===r.size)return null;const i=new ea(new ArrayBuffer(r.size),r,0);if(r instanceof gs){if(e.args)for(let s=0;s<e.args.length;++s){const n=r.members[s],o=e.args[s],a=this.evalExpression(o,t);i.setData(this,a,n.type,n.offset,t)}}else if(r instanceof ms){let s=0;if(e.args)for(let o=0;o<e.args.length;++o){const a=e.args[o],A=this.evalExpression(a,t);null===r.format&&("x32"===(null===(n=A.typeInfo)||void 0===n?void 0:n.name)?r.format=this.getTypeInfo("i32"):r.format=A.typeInfo),i.setData(this,A,r.format,s,t),s+=r.stride}}return e instanceof Ro?i.getSubData(this,e.postfix,t):i}_evalLiteral(e,t){const n=this.getTypeInfo(e.type),r=n.name;return"x32"===r||"u32"===r||"f32"===r||"f16"===r||"i32"===r||"bool"===r?new qo(e.scalarValue,n):"vec2"===r||"vec3"===r||"vec4"===r||"vec2f"===r||"vec3f"===r||"vec4f"===r||"vec2h"===r||"vec3h"===r||"vec4h"===r||"vec2i"===r||"vec3i"===r||"vec4i"===r||"vec2u"===r||"vec3u"===r||"vec4u"===r?this._callConstructorVec(e,t):"mat2x2"===r||"mat2x3"===r||"mat2x4"===r||"mat3x2"===r||"mat3x3"===r||"mat3x4"===r||"mat4x2"===r||"mat4x3"===r||"mat4x4"===r||"mat2x2f"===r||"mat2x3f"===r||"mat2x4f"===r||"mat3x2f"===r||"mat3x3f"===r||"mat3x4f"===r||"mat4x2f"===r||"mat4x3f"===r||"mat4x4f"===r||"mat2x2h"===r||"mat2x3h"===r||"mat2x4h"===r||"mat3x2h"===r||"mat3x3h"===r||"mat3x4h"===r||"mat4x2h"===r||"mat4x3h"===r||"mat4x4h"===r?this._callConstructorMatrix(e,t):e.value}_evalVariable(e,t){const n=t.getVariableValue(e.name);return null===n?n:n.getSubData(this,e.postfix,t)}_maxFormatTypeInfo(e){let t=e[0];if("f32"===t.name)return t;for(let n=1;n<e.length;++n){const r=ka._priority.get(t.name);ka._priority.get(e[n].name)<r&&(t=e[n])}return"x32"===t.name?this.getTypeInfo("i32"):t}_evalUnaryOp(e,t){const n=this.evalExpression(e.right,t);if("&"===e.operator)return new Yo(n);if("*"===e.operator)return n instanceof Yo?n.reference.getSubData(this,e.postfix,t):null;const r=n instanceof qo?n.value:n instanceof Zo?Array.from(n.data):null;switch(e.operator){case"+":{if(oa(r)){const e=r.map((e,t)=>+e);return new Zo(e,n.typeInfo)}const e=r,t=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new qo(+e,t)}case"-":{if(oa(r)){const e=r.map((e,t)=>-e);return new Zo(e,n.typeInfo)}const e=r,t=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new qo(-e,t)}case"!":{if(oa(r)){const e=r.map((e,t)=>e?0:1);return new Zo(e,n.typeInfo)}const e=r,t=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new qo(e?0:1,t)}case"~":{if(oa(r)){const e=r.map((e,t)=>~e);return new Zo(e,n.typeInfo)}const e=r,t=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new qo(~e,t)}}return null}_evalBinaryOp(e,t){const n=this.evalExpression(e.left,t),r=this.evalExpression(e.right,t),i=n instanceof qo?n.value:n instanceof Zo||n instanceof Jo?Array.from(n.data):null,s=r instanceof qo?r.value:r instanceof Zo||r instanceof Jo?Array.from(r.data):null;switch(e.operator){case"+":{if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e+t[n]);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t+e);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e+t);return new Zo(t,r.typeInfo)}const e=i,t=s,o=this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]);return new qo(e+t,o)}case"-":{if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e-t[n]);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t-e);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e-t);return new Zo(t,r.typeInfo)}const e=i,t=s,o=this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]);return new qo(e-t,o)}case"*":{if(oa(i)&&oa(s)){const e=i,t=s;if(n instanceof Jo&&r instanceof Jo){const i=function(e,t,n,r){if(void 0===Ca[t.name]||void 0===Ca[r.name])return null;const i=Ca[t.name][0],s=Ca[t.name][1],o=Ca[r.name][0];if(i!==Ca[r.name][1])return null;const a=new Array(o*s);for(let A=0;A<s;A++)for(let t=0;t<o;t++){let r=0;for(let o=0;o<i;o++)r+=e[o*s+A]*n[t*i+o];a[A*o+t]=r}return a}(e,n.typeInfo,t,r.typeInfo);if(null===i)return null;const s=Ca[r.typeInfo.name][0],o=Ca[n.typeInfo.name][1],a=this.getTypeInfo(`mat${s}x${o}f`);return new Jo(i,a)}if(n instanceof Jo&&r instanceof Zo){const i=function(e,t,n,r){if(void 0===Ca[t.name]||void 0===Sa[r.name])return null;const i=Ca[t.name][0],s=Ca[t.name][1];if(i!==n.length)return null;const o=new Array(s);for(let a=0;a<s;a++){let t=0;for(let r=0;r<i;r++)t+=e[r*s+a]*n[r];o[a]=t}return o}(e,n.typeInfo,t,r.typeInfo);return null===i?null:new Zo(i,r.typeInfo)}if(n instanceof Zo&&r instanceof Jo){const i=function(e,t,n,r){if(void 0===Sa[t.name]||void 0===Ca[r.name])return null;const i=Ca[r.name][0],s=Ca[r.name][1];if(s!==e.length)return null;const o=[];for(let a=0;a<i;a++){let t=0;for(let r=0;r<s;r++)t+=e[r]*n[r*i+a];o[a]=t}return o}(e,n.typeInfo,t,r.typeInfo);return null===i?null:new Zo(i,n.typeInfo)}{if(e.length!==t.length)return null;const r=e.map((e,n)=>e*t[n]);return new Zo(r,n.typeInfo)}}if(oa(i)){const e=s,t=i.map((t,n)=>t*e);return n instanceof Jo?new Jo(t,n.typeInfo):new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e*t);return r instanceof Jo?new Jo(t,r.typeInfo):new Zo(t,r.typeInfo)}const e=i,t=s,o=this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]);return new qo(e*t,o)}case"%":{if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e%t[n]);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t%e);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e%t);return new Zo(t,r.typeInfo)}const e=i,t=s,o=this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]);return new qo(e%t,o)}case"/":{if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e/t[n]);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t/e);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e/t);return new Zo(t,r.typeInfo)}const e=i,t=s,o=this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]);return new qo(e/t,o)}case"&":{if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e&t[n]);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t&e);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e&t);return new Zo(t,r.typeInfo)}const e=i,t=s,o=this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]);return new qo(e&t,o)}case"|":{if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e|t[n]);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t|e);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e|t);return new Zo(t,r.typeInfo)}const e=i,t=s,o=this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]);return new qo(e|t,o)}case"^":{if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e^t[n]);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t^e);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e^t);return new Zo(t,r.typeInfo)}const e=i,t=s,o=this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]);return new qo(e^t,o)}case"<<":{if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e<<t[n]);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t<<e);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e<<t);return new Zo(t,r.typeInfo)}const e=i,t=s,o=this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]);return new qo(e<<t,o)}case">>":{if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e>>t[n]);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t>>e);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e>>t);return new Zo(t,r.typeInfo)}const e=i,t=s,o=this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]);return new qo(e>>t,o)}case">":if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e>t[n]?1:0);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t>e?1:0);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e>t?1:0);return new Zo(t,r.typeInfo)}return new qo(i>s?1:0,this.getTypeInfo("bool"));case"<":if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e<t[n]?1:0);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t<e?1:0);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e<t?1:0);return new Zo(t,r.typeInfo)}return new qo(i<s?1:0,this.getTypeInfo("bool"));case"==":if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e===t[n]?1:0);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t==e?1:0);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e==t?1:0);return new Zo(t,r.typeInfo)}return new qo(i===s?1:0,this.getTypeInfo("bool"));case"!=":if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e!==t[n]?1:0);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t!==e?1:0);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e!==t?1:0);return new Zo(t,r.typeInfo)}return new qo(i!==s?1:0,this.getTypeInfo("bool"));case">=":if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e>=t[n]?1:0);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t>=e?1:0);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e>=t?1:0);return new Zo(t,r.typeInfo)}return new qo(i>=s?1:0,this.getTypeInfo("bool"));case"<=":if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e<=t[n]?1:0);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t<=e?1:0);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e<=t?1:0);return new Zo(t,r.typeInfo)}return new qo(i<=s?1:0,this.getTypeInfo("bool"));case"&&":if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e&&t[n]?1:0);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t&&e?1:0);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e&&t?1:0);return new Zo(t,r.typeInfo)}return new qo(i&&s?1:0,this.getTypeInfo("bool"));case"||":if(oa(i)&&oa(s)){const e=i,t=s;if(e.length!==t.length)return null;const r=e.map((e,n)=>e||t[n]?1:0);return new Zo(r,n.typeInfo)}if(oa(i)){const e=s,t=i.map((t,n)=>t||e?1:0);return new Zo(t,n.typeInfo)}if(oa(s)){const e=i,t=s.map((t,n)=>e||t?1:0);return new Zo(t,r.typeInfo)}return new qo(i||s?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 r=t.getFunction(e.name);if(!r)return e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)?this._evalCreate(e,t):null;for(let i=0;i<r.node.args.length;++i){const t=r.node.args[i],s=this.evalExpression(e.args[i],n);n.createVariable(t.name,s,t)}return this._execStatements(r.node.body,n)}_callBuiltinFunction(e,t){switch(e.name){case"all":return this.builtins.All(e,t);case"any":return this.builtins.Any(e,t);case"select":return this.builtins.Select(e,t);case"arrayLength":return this.builtins.ArrayLength(e,t);case"abs":return this.builtins.Abs(e,t);case"acos":return this.builtins.Acos(e,t);case"acosh":return this.builtins.Acosh(e,t);case"asin":return this.builtins.Asin(e,t);case"asinh":return this.builtins.Asinh(e,t);case"atan":return this.builtins.Atan(e,t);case"atanh":return this.builtins.Atanh(e,t);case"atan2":return this.builtins.Atan2(e,t);case"ceil":return this.builtins.Ceil(e,t);case"clamp":return this.builtins.Clamp(e,t);case"cos":return this.builtins.Cos(e,t);case"cosh":return this.builtins.Cosh(e,t);case"countLeadingZeros":return this.builtins.CountLeadingZeros(e,t);case"countOneBits":return this.builtins.CountOneBits(e,t);case"countTrailingZeros":return this.builtins.CountTrailingZeros(e,t);case"cross":return this.builtins.Cross(e,t);case"degrees":return this.builtins.Degrees(e,t);case"determinant":return this.builtins.Determinant(e,t);case"distance":return this.builtins.Distance(e,t);case"dot":return this.builtins.Dot(e,t);case"dot4U8Packed":return this.builtins.Dot4U8Packed(e,t);case"dot4I8Packed":return this.builtins.Dot4I8Packed(e,t);case"exp":return this.builtins.Exp(e,t);case"exp2":return this.builtins.Exp2(e,t);case"extractBits":return this.builtins.ExtractBits(e,t);case"faceForward":return this.builtins.FaceForward(e,t);case"firstLeadingBit":return this.builtins.FirstLeadingBit(e,t);case"firstTrailingBit":return this.builtins.FirstTrailingBit(e,t);case"floor":return this.builtins.Floor(e,t);case"fma":return this.builtins.Fma(e,t);case"fract":return this.builtins.Fract(e,t);case"frexp":return this.builtins.Frexp(e,t);case"insertBits":return this.builtins.InsertBits(e,t);case"inverseSqrt":return this.builtins.InverseSqrt(e,t);case"ldexp":return this.builtins.Ldexp(e,t);case"length":return this.builtins.Length(e,t);case"log":return this.builtins.Log(e,t);case"log2":return this.builtins.Log2(e,t);case"max":return this.builtins.Max(e,t);case"min":return this.builtins.Min(e,t);case"mix":return this.builtins.Mix(e,t);case"modf":return this.builtins.Modf(e,t);case"normalize":return this.builtins.Normalize(e,t);case"pow":return this.builtins.Pow(e,t);case"quantizeToF16":return this.builtins.QuantizeToF16(e,t);case"radians":return this.builtins.Radians(e,t);case"reflect":return this.builtins.Reflect(e,t);case"refract":return this.builtins.Refract(e,t);case"reverseBits":return this.builtins.ReverseBits(e,t);case"round":return this.builtins.Round(e,t);case"saturate":return this.builtins.Saturate(e,t);case"sign":return this.builtins.Sign(e,t);case"sin":return this.builtins.Sin(e,t);case"sinh":return this.builtins.Sinh(e,t);case"smoothstep":return this.builtins.SmoothStep(e,t);case"sqrt":return this.builtins.Sqrt(e,t);case"step":return this.builtins.Step(e,t);case"tan":return this.builtins.Tan(e,t);case"tanh":return this.builtins.Tanh(e,t);case"transpose":return this.builtins.Transpose(e,t);case"trunc":return this.builtins.Trunc(e,t);case"dpdx":return this.builtins.Dpdx(e,t);case"dpdxCoarse":return this.builtins.DpdxCoarse(e,t);case"dpdxFine":return this.builtins.DpdxFine(e,t);case"dpdy":return this.builtins.Dpdy(e,t);case"dpdyCoarse":return this.builtins.DpdyCoarse(e,t);case"dpdyFine":return this.builtins.DpdyFine(e,t);case"fwidth":return this.builtins.Fwidth(e,t);case"fwidthCoarse":return this.builtins.FwidthCoarse(e,t);case"fwidthFine":return this.builtins.FwidthFine(e,t);case"textureDimensions":return this.builtins.TextureDimensions(e,t);case"textureGather":return this.builtins.TextureGather(e,t);case"textureGatherCompare":return this.builtins.TextureGatherCompare(e,t);case"textureLoad":return this.builtins.TextureLoad(e,t);case"textureNumLayers":return this.builtins.TextureNumLayers(e,t);case"textureNumLevels":return this.builtins.TextureNumLevels(e,t);case"textureNumSamples":return this.builtins.TextureNumSamples(e,t);case"textureSample":return this.builtins.TextureSample(e,t);case"textureSampleBias":return this.builtins.TextureSampleBias(e,t);case"textureSampleCompare":return this.builtins.TextureSampleCompare(e,t);case"textureSampleCompareLevel":return this.builtins.TextureSampleCompareLevel(e,t);case"textureSampleGrad":return this.builtins.TextureSampleGrad(e,t);case"textureSampleLevel":return this.builtins.TextureSampleLevel(e,t);case"textureSampleBaseClampToEdge":return this.builtins.TextureSampleBaseClampToEdge(e,t);case"textureStore":return this.builtins.TextureStore(e,t);case"atomicLoad":return this.builtins.AtomicLoad(e,t);case"atomicStore":return this.builtins.AtomicStore(e,t);case"atomicAdd":return this.builtins.AtomicAdd(e,t);case"atomicSub":return this.builtins.AtomicSub(e,t);case"atomicMax":return this.builtins.AtomicMax(e,t);case"atomicMin":return this.builtins.AtomicMin(e,t);case"atomicAnd":return this.builtins.AtomicAnd(e,t);case"atomicOr":return this.builtins.AtomicOr(e,t);case"atomicXor":return this.builtins.AtomicXor(e,t);case"atomicExchange":return this.builtins.AtomicExchange(e,t);case"atomicCompareExchangeWeak":return this.builtins.AtomicCompareExchangeWeak(e,t);case"pack4x8snorm":return this.builtins.Pack4x8snorm(e,t);case"pack4x8unorm":return this.builtins.Pack4x8unorm(e,t);case"pack4xI8":return this.builtins.Pack4xI8(e,t);case"pack4xU8":return this.builtins.Pack4xU8(e,t);case"pack4x8Clamp":return this.builtins.Pack4x8Clamp(e,t);case"pack4xU8Clamp":return this.builtins.Pack4xU8Clamp(e,t);case"pack2x16snorm":return this.builtins.Pack2x16snorm(e,t);case"pack2x16unorm":return this.builtins.Pack2x16unorm(e,t);case"pack2x16float":return this.builtins.Pack2x16float(e,t);case"unpack4x8snorm":return this.builtins.Unpack4x8snorm(e,t);case"unpack4x8unorm":return this.builtins.Unpack4x8unorm(e,t);case"unpack4xI8":return this.builtins.Unpack4xI8(e,t);case"unpack4xU8":return this.builtins.Unpack4xU8(e,t);case"unpack2x16snorm":return this.builtins.Unpack2x16snorm(e,t);case"unpack2x16unorm":return this.builtins.Unpack2x16unorm(e,t);case"unpack2x16float":return this.builtins.Unpack2x16float(e,t);case"storageBarrier":return this.builtins.StorageBarrier(e,t);case"textureBarrier":return this.builtins.TextureBarrier(e,t);case"workgroupBarrier":return this.builtins.WorkgroupBarrier(e,t);case"workgroupUniformLoad":return this.builtins.WorkgroupUniformLoad(e,t);case"subgroupAdd":return this.builtins.SubgroupAdd(e,t);case"subgroupExclusiveAdd":return this.builtins.SubgroupExclusiveAdd(e,t);case"subgroupInclusiveAdd":return this.builtins.SubgroupInclusiveAdd(e,t);case"subgroupAll":return this.builtins.SubgroupAll(e,t);case"subgroupAnd":return this.builtins.SubgroupAnd(e,t);case"subgroupAny":return this.builtins.SubgroupAny(e,t);case"subgroupBallot":return this.builtins.SubgroupBallot(e,t);case"subgroupBroadcast":return this.builtins.SubgroupBroadcast(e,t);case"subgroupBroadcastFirst":return this.builtins.SubgroupBroadcastFirst(e,t);case"subgroupElect":return this.builtins.SubgroupElect(e,t);case"subgroupMax":return this.builtins.SubgroupMax(e,t);case"subgroupMin":return this.builtins.SubgroupMin(e,t);case"subgroupMul":return this.builtins.SubgroupMul(e,t);case"subgroupExclusiveMul":return this.builtins.SubgroupExclusiveMul(e,t);case"subgroupInclusiveMul":return this.builtins.SubgroupInclusiveMul(e,t);case"subgroupOr":return this.builtins.SubgroupOr(e,t);case"subgroupShuffle":return this.builtins.SubgroupShuffle(e,t);case"subgroupShuffleDown":return this.builtins.SubgroupShuffleDown(e,t);case"subgroupShuffleUp":return this.builtins.SubgroupShuffleUp(e,t);case"subgroupShuffleXor":return this.builtins.SubgroupShuffleXor(e,t);case"subgroupXor":return this.builtins.SubgroupXor(e,t);case"quadBroadcast":return this.builtins.QuadBroadcast(e,t);case"quadSwapDiagonal":return this.builtins.QuadSwapDiagonal(e,t);case"quadSwapX":return this.builtins.QuadSwapX(e,t);case"quadSwapY":return this.builtins.QuadSwapY(e,t)}const n=t.getFunction(e.name);if(n){const r=t.clone();for(let t=0;t<n.node.args.length;++t){const i=n.node.args[t],s=this.evalExpression(e.args[t],r);r.setVariable(i.name,s,i)}return this._execStatements(n.node.body,r)}return null}_callConstructorValue(e,t){if(!e.args||0===e.args.length)return new qo(0,this.getTypeInfo(e.type));const n=this.evalExpression(e.args[0],t);return n.typeInfo=this.getTypeInfo(e.type),n.getSubData(this,e.postfix,t).clone()}_callConstructorVec(e,t){const n=this.getTypeInfo(e.type),r=e.type.getTypeName(),i=Sa[r];if(void 0===i)return null;const s=[];if(e instanceof Lo)if(e.isVector){const t=e.vectorValue;for(const e of t)s.push(e)}else s.push(e.scalarValue);else if(e.args)for(const o of e.args){const e=this.evalExpression(o,t);if(e instanceof Zo){const t=e.data;for(let e=0;e<t.length;++e){let n=t[e];s.push(n)}}else if(e instanceof qo){let t=e.value;s.push(t)}}if(e.type instanceof xo&&null===e.type.format&&(e.type.format=xo.f32),0===s.length){const r=new Array(i).fill(0);return new Zo(r,n).getSubData(this,e.postfix,t)}if(1===s.length)for(;s.length<i;)s.push(s[0]);return s.length<i?null:new Zo(s.length>i?s.slice(0,i):s,n).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const n=this.getTypeInfo(e.type),r=e.type.getTypeName(),i=Ca[r];if(void 0===i)return null;const s=[];if(e instanceof Lo)if(e.isVector){const t=e.vectorValue;for(const e of t)s.push(e)}else s.push(e.scalarValue);else if(e.args)for(const o of e.args){const e=this.evalExpression(o,t);e instanceof Zo?s.push(...e.data):e instanceof qo?s.push(e.value):e instanceof Jo&&s.push(...e.data)}if(n instanceof bs&&null===n.format&&(n.format=this.getTypeInfo("f32")),0===s.length){const r=new Array(i[2]).fill(0);return new Jo(r,n).getSubData(this,e.postfix,t)}return s.length!==i[2]?null:new Jo(s,n).getSubData(this,e.postfix,t)}}ka._breakObj=new Xo(new fs("BREAK",null),null),ka._continueObj=new Xo(new fs("CONTINUE",null),null),ka._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class Ra{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class Pa{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new Ra,this._exec=new ka,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,r=e.countNode;if(r instanceof Io){const e=r.name,i=this._context.constants.get(e);if(i)try{const e=i.constEvaluate(this._exec);t.count=e}catch(n){}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const r of t)r.search(e=>{e instanceof Ho||e instanceof Eo?e.type=this._forwardType(e.type):e instanceof To?e.format=this._forwardType(e.format):e instanceof Ks||e instanceof Js||e instanceof eo?e.type=this._forwardType(e.type):e instanceof $s?e.returnType=this._forwardType(e.returnType):e instanceof Vo&&(e.type=this._forwardType(e.type))});return t}_forwardType(e){if(e instanceof yo){const t=this._getType(e.name);if(t)return t}else e instanceof Eo?e.type=this._forwardType(e.type):e instanceof To&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if("string"==typeof e){const t=new sa(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==ra.eof}_match(e){if(e instanceof na)return!!this._check(e)&&(this._advance(),!0);for(let t=0,n=e.length;t<n;++t){const n=e[t];if(this._check(n))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),`${t}. Line:${this._currentLine}`)}_check(e){if(this._isAtEnd())return!1;const t=this._peek();if(e instanceof Array){const n=t.type;let r=!1;for(const t of e){if(n===t)return!0;t===ra.tokens.name&&(r=!0)}if(r){const e=ra.tokens.name.rule.exec(t.lexeme);if(e&&0==e.index&&e[0]==t.lexeme)return!0}return!1}if(t.type===e)return!0;if(e===ra.tokens.name){const e=ra.tokens.name.rule.exec(t.lexeme);return e&&0==e.index&&e[0]==t.lexeme}return!1}_advance(){var e,t;return this._currentLine=null!==(t=null===(e=this._peek())||void 0===e?void 0:e.line)&&void 0!==t?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(ra.tokens.semicolon)&&!this._isAtEnd(););if(this._match(ra.keywords.alias)){const e=this._type_alias();return this._consume(ra.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([e]),e}if(this._match(ra.keywords.diagnostic)){const e=this._diagnostic();return this._consume(ra.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([e]),e}if(this._match(ra.keywords.requires)){const e=this._requires_directive();return this._consume(ra.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([e]),e}if(this._match(ra.keywords.enable)){const e=this._enable_directive();return this._consume(ra.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([e]),e}const e=this._attribute();if(this._check(ra.keywords.var)){const t=this._global_variable_decl();return null!=t&&(t.attributes=e),this._consume(ra.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(ra.keywords.override)){const t=this._override_variable_decl();return null!=t&&(t.attributes=e),this._consume(ra.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(ra.keywords.let)){const t=this._global_let_decl();return null!=t&&(t.attributes=e),this._consume(ra.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(ra.keywords.const)){const t=this._global_const_decl();return null!=t&&(t.attributes=e),this._consume(ra.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(ra.keywords.struct)){const t=this._struct_decl();return null!=t&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}if(this._check(ra.keywords.fn)){const t=this._function_decl();return null!=t&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}return null}_function_decl(){if(!this._match(ra.keywords.fn))return null;const e=this._currentLine,t=this._consume(ra.tokens.ident,"Expected function name.").toString();this._consume(ra.tokens.paren_left,"Expected '(' for function arguments.");const n=[];if(!this._check(ra.tokens.paren_right))do{if(this._check(ra.tokens.paren_right))break;const e=this._attribute(),t=this._consume(ra.tokens.name,"Expected argument name.").toString();this._consume(ra.tokens.colon,"Expected ':' for argument type.");const r=this._attribute(),i=this._type_decl();null!=i&&(i.attributes=r,n.push(this._updateNode(new Vo(t,i,e))))}while(this._match(ra.tokens.comma));this._consume(ra.tokens.paren_right,"Expected ')' after function arguments.");let r=null;if(this._match(ra.tokens.arrow)){const e=this._attribute();r=this._type_decl(),null!=r&&(r.attributes=e)}const i=this._compound_statement(),s=this._currentLine;return this._updateNode(new $s(t,n,r,i,e,s),e)}_compound_statement(){const e=[];for(this._consume(ra.tokens.brace_left,"Expected '{' for block.");!this._check(ra.tokens.brace_right);){const t=this._statement();null!==t&&e.push(t)}return this._consume(ra.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(ra.tokens.semicolon)&&!this._isAtEnd(););if(this._check(ra.tokens.attr)&&this._attribute(),this._check(ra.keywords.if))return this._if_statement();if(this._check(ra.keywords.switch))return this._switch_statement();if(this._check(ra.keywords.loop))return this._loop_statement();if(this._check(ra.keywords.for))return this._for_statement();if(this._check(ra.keywords.while))return this._while_statement();if(this._check(ra.keywords.continuing))return this._continuing_statement();if(this._check(ra.keywords.static_assert))return this._static_assert_statement();if(this._check(ra.tokens.brace_left))return this._compound_statement();let e=null;if(this._check(ra.keywords.return))e=this._return_statement();else if(this._check([ra.keywords.var,ra.keywords.let,ra.keywords.const]))e=this._variable_statement();else if(this._match(ra.keywords.discard))e=this._updateNode(new mo);else if(this._match(ra.keywords.break)){const t=this._updateNode(new _o);if(this._currentLoop.length>0){const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t,this._check(ra.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(ra.keywords.continue)){const t=this._updateNode(new bo);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(ra.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(ra.keywords.static_assert))return null;const e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new Xs(t),e)}_while_statement(){if(!this._match(ra.keywords.while))return null;const e=this._updateNode(new Qs(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(ra.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(ra.keywords.continuing))return null;const t=this._currentLine,n=this._compound_statement();return this._updateNode(new Ys(n,e),t)}_for_statement(){if(!this._match(ra.keywords.for))return null;this._consume(ra.tokens.paren_left,"Expected '('.");const e=this._updateNode(new qs(null,null,null,null));return this._currentLoop.push(e),e.init=this._check(ra.tokens.semicolon)?null:this._for_init(),this._consume(ra.tokens.semicolon,"Expected ';'."),e.condition=this._check(ra.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume(ra.tokens.semicolon,"Expected ';'."),e.increment=this._check(ra.tokens.paren_right)?null:this._for_increment(),this._consume(ra.tokens.paren_right,"Expected ')'."),this._check(ra.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(ra.keywords.var)){const e=this._variable_decl();if(null===e)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(ra.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new Ks(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(ra.keywords.let)){const e=this._currentLine,t=this._consume(ra.tokens.name,"Expected name for let.").toString();let n=null;if(this._match(ra.tokens.colon)){const e=this._attribute();n=this._type_decl(),null!=n&&(n.attributes=e)}this._consume(ra.tokens.equal,"Expected '=' for let.");const r=this._short_circuit_or_expression();return this._updateNode(new Js(t,n,null,null,r),e)}if(this._match(ra.keywords.const)){const e=this._currentLine,t=this._consume(ra.tokens.name,"Expected name for const.").toString();let n=null;if(this._match(ra.tokens.colon)){const e=this._attribute();n=this._type_decl(),null!=n&&(n.attributes=e)}this._consume(ra.tokens.equal,"Expected '=' for const.");const r=this._short_circuit_or_expression();return null===n&&r instanceof Lo&&(n=r.type),this._updateNode(new eo(t,n,null,null,r),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(null==t)return null;if(!this._check(ra.increment_operators))return this._current=e,null;const n=this._consume(ra.increment_operators,"Expected increment operator");return this._updateNode(new so(n.type===ra.tokens.plus_plus?to.increment:to.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check(ra.tokens.brace_right))return null;let n=this._match(ra.tokens.underscore);if(n||(e=this._unary_expression()),!n&&null==e)return null;const r=this._consume(ra.assignment_operators,"Expected assignment operator."),i=this._short_circuit_or_expression();return this._updateNode(new oo(no.parse(r.lexeme),e,i),t)}_func_call_statement(){if(!this._check(ra.tokens.ident))return null;const e=this._currentLine,t=this._current,n=this._consume(ra.tokens.ident,"Expected function name."),r=this._argument_expression_list();return null===r?(this._current=t,null):this._updateNode(new ao(n.lexeme,r),e)}_loop_statement(){if(!this._match(ra.keywords.loop))return null;this._check(ra.tokens.attr)&&this._attribute(),this._consume(ra.tokens.brace_left,"Expected '{' for loop.");const e=this._updateNode(new Ao([],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 Ys){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume(ra.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match(ra.keywords.switch))return null;const e=this._updateNode(new lo(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(ra.tokens.attr)&&this._attribute(),this._consume(ra.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(ra.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){const e=[];let t=!1;for(;this._check([ra.keywords.default,ra.keywords.case]);){if(this._match(ra.keywords.case)){const n=this._case_selectors();for(const e of n)if(e instanceof jo){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match(ra.tokens.colon),this._check(ra.tokens.attr)&&this._attribute(),this._consume(ra.tokens.brace_left,"Exected '{' for switch case.");const r=this._case_body();this._consume(ra.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new Go(n,r)))}if(this._match(ra.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match(ra.tokens.colon),this._check(ra.tokens.attr)&&this._attribute(),this._consume(ra.tokens.brace_left,"Exected '{' for switch default.");const n=this._case_body();this._consume(ra.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new zo(n)))}}return e}_case_selectors(){const e=[];for(this._match(ra.keywords.default)?e.push(this._updateNode(new jo)):e.push(this._shift_expression());this._match(ra.tokens.comma);)this._match(ra.keywords.default)?e.push(this._updateNode(new jo)):e.push(this._shift_expression());return e}_case_body(){if(this._match(ra.keywords.fallthrough))return this._consume(ra.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(ra.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check(ra.tokens.attr)&&this._attribute();const n=this._compound_statement();let r=[];this._match_elseif()&&(this._check(ra.tokens.attr)&&this._attribute(),r=this._elseif_statement(r));let i=null;return this._match(ra.keywords.else)&&(this._check(ra.tokens.attr)&&this._attribute(),i=this._compound_statement()),this._updateNode(new co(t,n,r,i),e)}_match_elseif(){return this._tokens[this._current].type===ra.keywords.else&&this._tokens[this._current+1].type===ra.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 Wo(t,n))),this._match_elseif()&&(this._check(ra.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(ra.keywords.return))return null;const e=this._short_circuit_or_expression();return this._updateNode(new uo(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(ra.tokens.or_or);)e=this._updateNode(new Fo(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(ra.tokens.and_and);)e=this._updateNode(new Fo(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(ra.tokens.or);)e=this._updateNode(new Fo(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(ra.tokens.xor);)e=this._updateNode(new Fo(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match(ra.tokens.and);)e=this._updateNode(new Fo(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){const e=this._relational_expression();return this._match([ra.tokens.equal_equal,ra.tokens.not_equal])?this._updateNode(new Fo(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([ra.tokens.less_than,ra.tokens.greater_than,ra.tokens.less_than_equal,ra.tokens.greater_than_equal]);)e=this._updateNode(new Fo(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([ra.tokens.shift_left,ra.tokens.shift_right]);)e=this._updateNode(new Fo(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([ra.tokens.plus,ra.tokens.minus]);)e=this._updateNode(new Fo(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([ra.tokens.star,ra.tokens.forward_slash,ra.tokens.modulo]);)e=this._updateNode(new Fo(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([ra.tokens.minus,ra.tokens.bang,ra.tokens.tilde,ra.tokens.star,ra.tokens.and])?this._updateNode(new Oo(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(ra.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume(ra.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new Bo(e)),n=this._postfix_expression();return n&&(t.postfix=n),t}if(this._match(ra.tokens.period)){const e=this._consume(ra.tokens.name,"Expected member name."),t=this._postfix_expression(),n=this._updateNode(new ko(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 vo.void;case"bool":return vo.bool;case"i32":return vo.i32;case"u32":return vo.u32;case"f32":return vo.f32;case"f16":return vo.f16;case"vec2f":return xo.vec2f;case"vec3f":return xo.vec3f;case"vec4f":return xo.vec4f;case"vec2i":return xo.vec2i;case"vec3i":return xo.vec3i;case"vec4i":return xo.vec4i;case"vec2u":return xo.vec2u;case"vec3u":return xo.vec3u;case"vec4u":return xo.vec4u;case"vec2h":return xo.vec2h;case"vec3h":return xo.vec3h;case"vec4h":return xo.vec4h;case"mat2x2f":return xo.mat2x2f;case"mat2x3f":return xo.mat2x3f;case"mat2x4f":return xo.mat2x4f;case"mat3x2f":return xo.mat3x2f;case"mat3x3f":return xo.mat3x3f;case"mat3x4f":return xo.mat3x4f;case"mat4x2f":return xo.mat4x2f;case"mat4x3f":return xo.mat4x3f;case"mat4x4f":return xo.mat4x4f;case"mat2x2h":return xo.mat2x2h;case"mat2x3h":return xo.mat2x3h;case"mat2x4h":return xo.mat2x4h;case"mat3x2h":return xo.mat3x2h;case"mat3x3h":return xo.mat3x3h;case"mat3x4h":return xo.mat3x4h;case"mat4x2h":return xo.mat4x2h;case"mat4x3h":return xo.mat4x3h;case"mat4x4h":return xo.mat4x4h;case"mat2x2i":return xo.mat2x2i;case"mat2x3i":return xo.mat2x3i;case"mat2x4i":return xo.mat2x4i;case"mat3x2i":return xo.mat3x2i;case"mat3x3i":return xo.mat3x3i;case"mat3x4i":return xo.mat3x4i;case"mat4x2i":return xo.mat4x2i;case"mat4x3i":return xo.mat4x3i;case"mat4x4i":return xo.mat4x4i;case"mat2x2u":return xo.mat2x2u;case"mat2x3u":return xo.mat2x3u;case"mat2x4u":return xo.mat2x4u;case"mat3x2u":return xo.mat3x2u;case"mat3x3u":return xo.mat3x3u;case"mat3x4u":return xo.mat3x4u;case"mat4x2u":return xo.mat4x2u;case"mat4x3u":return xo.mat4x3u;case"mat4x4u":return xo.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(ra.tokens.ident)){const e=this._previous().toString();if(this._check(ra.tokens.paren_left)){const t=this._argument_expression_list(),n=this._getType(e);return null!==n?this._updateNode(new Ro(n,t)):this._updateNode(new Po(e,t))}if(this._context.constants.has(e)){const t=this._context.constants.get(e);return this._updateNode(new Mo(e,t.value))}return this._updateNode(new Io(e))}if(this._match(ra.tokens.int_literal)){const e=this._previous().toString();let t=e.endsWith("i")||e.endsWith("i")?vo.i32:e.endsWith("u")||e.endsWith("U")?vo.u32:vo.x32;const n=parseInt(e);return this._validateTypeRange(n,t),this._updateNode(new Lo(new qo(n,this._exec.getTypeInfo(t)),t))}if(this._match(ra.tokens.uint_literal)){const e=parseInt(this._previous().toString());return this._validateTypeRange(e,vo.u32),this._updateNode(new Lo(new qo(e,this._exec.getTypeInfo(vo.u32)),vo.u32))}if(this._match([ra.tokens.decimal_float_literal,ra.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?vo.f16:vo.f32);const r=t?vo.f16:vo.f32;return this._updateNode(new Lo(new qo(n,this._exec.getTypeInfo(r)),r))}if(this._match([ra.keywords.true,ra.keywords.false])){let e=this._previous().toString()===ra.keywords.true.rule;return this._updateNode(new Lo(new qo(e?1:0,this._exec.getTypeInfo(vo.bool)),vo.bool))}if(this._check(ra.tokens.paren_left))return this._paren_expression();if(this._match(ra.keywords.bitcast)){this._consume(ra.tokens.less_than,"Expected '<'.");const e=this._type_decl();this._consume(ra.tokens.greater_than,"Expected '>'.");const t=this._paren_expression();return this._updateNode(new No(e,t))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new Ro(e,t))}_argument_expression_list(){if(!this._match(ra.tokens.paren_left))return null;const e=[];do{if(this._check(ra.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match(ra.tokens.comma));return this._consume(ra.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(ra.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match(ra.tokens.paren_right),e}_paren_expression(){this._consume(ra.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume(ra.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match(ra.keywords.struct))return null;const e=this._currentLine,t=this._consume(ra.tokens.ident,"Expected name for struct.").toString();this._consume(ra.tokens.brace_left,"Expected '{' for struct body.");const n=[];for(;!this._check(ra.tokens.brace_right);){const e=this._attribute(),t=this._consume(ra.tokens.name,"Expected variable name.").toString();this._consume(ra.tokens.colon,"Expected ':' for struct member type.");const r=this._attribute(),i=this._type_decl();null!=i&&(i.attributes=r),this._check(ra.tokens.brace_right)?this._match(ra.tokens.comma):this._consume(ra.tokens.comma,"Expected ',' for struct member."),n.push(this._updateNode(new Ho(t,i,e)))}this._consume(ra.tokens.brace_right,"Expected '}' after struct body.");const r=this._currentLine,i=this._updateNode(new wo(t,n,e,r),e);return this._context.structs.set(t,i),i}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match(ra.tokens.equal)){const t=this._const_expression();e.value=t}if(null!==e.type&&e.value instanceof Lo){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 Lo&&(e.type="x32"===e.value.type.name?vo.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(ra.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match(ra.keywords.const))return null;const t=this._consume(ra.tokens.name,"Expected variable name"),n=this._currentLine;let r=null;if(this._match(ra.tokens.colon)){const e=this._attribute();r=this._type_decl(),null!=r&&(r.attributes=e)}let i=null;this._consume(ra.tokens.equal,"const declarations require an assignment");const s=this._short_circuit_or_expression();try{let e=[vo.f32],n=s.constEvaluate(this._exec,e);n instanceof qo&&this._validateTypeRange(n.value,e[0]),e[0]instanceof xo&&null===e[0].format&&n.typeInfo instanceof bs&&null!==n.typeInfo.format&&("f16"===n.typeInfo.format.name?e[0].format=vo.f16:"f32"===n.typeInfo.format.name?e[0].format=vo.f32:"i32"===n.typeInfo.format.name?e[0].format=vo.i32:"u32"===n.typeInfo.format.name?e[0].format=vo.u32:"bool"===n.typeInfo.format.name&&(e[0].format=vo.bool)),i=this._updateNode(new Lo(n,e[0])),this._exec.context.setVariable(t.toString(),n)}catch(a){i=s}if(null!==r&&i instanceof Lo){if("x32"!==i.type.name&&r.getTypeName()!==i.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${i.type.name} to ${r.name}. Line:${this._currentLine}`);i.type=r,i.isScalar&&this._validateTypeRange(i.scalarValue,i.type)}else null===r&&i instanceof Lo&&(r=null!==(e=null==i?void 0:i.type)&&void 0!==e?e:vo.f32,r===vo.x32&&(r=vo.i32));const o=this._updateNode(new eo(t.toString(),r,"","",i),n);return this._context.constants.set(o.name,o),o}_global_let_decl(){if(!this._match(ra.keywords.let))return null;const e=this._currentLine,t=this._consume(ra.tokens.name,"Expected variable name");let n=null;if(this._match(ra.tokens.colon)){const e=this._attribute();n=this._type_decl(),null!=n&&(n.attributes=e)}let r=null;if(this._match(ra.tokens.equal)&&(r=this._const_expression()),null!==n&&r instanceof Lo){if("x32"!==r.type.name&&n.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${n.name}. Line:${this._currentLine}`);r.type=n}else null===n&&r instanceof Lo&&(n="x32"===r.type.name?vo.i32:r.type);return r instanceof Lo&&r.isScalar&&this._validateTypeRange(r.scalarValue,n),this._updateNode(new Js(t.toString(),n,"","",r),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(ra.keywords.var))return null;const e=this._currentLine;let t="",n="";this._match(ra.tokens.less_than)&&(t=this._consume(ra.storage_class,"Expected storage_class.").toString(),this._match(ra.tokens.comma)&&(n=this._consume(ra.access_mode,"Expected access_mode.").toString()),this._consume(ra.tokens.greater_than,"Expected '>'."));const r=this._consume(ra.tokens.name,"Expected variable name");let i=null;if(this._match(ra.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}return this._updateNode(new Ks(r.toString(),i,t,n,null),e)}_override_decl(){if(!this._match(ra.keywords.override))return null;const e=this._consume(ra.tokens.name,"Expected variable name");let t=null;if(this._match(ra.tokens.colon)){const e=this._attribute();t=this._type_decl(),null!=t&&(t.attributes=e)}return this._updateNode(new Zs(e.toString(),t,null))}_diagnostic(){this._consume(ra.tokens.paren_left,"Expected '('");const e=this._consume(ra.tokens.ident,"Expected severity control name.");this._consume(ra.tokens.comma,"Expected ','");let t=this._consume(ra.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(ra.tokens.period)&&(t+=`.${this._consume(ra.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(ra.tokens.paren_right,"Expected ')'"),this._updateNode(new po(e.toString(),t))}_enable_directive(){const e=this._consume(ra.tokens.ident,"identity expected.");return this._updateNode(new ho(e.toString()))}_requires_directive(){const e=[this._consume(ra.tokens.ident,"identity expected.").toString()];for(;this._match(ra.tokens.comma);){const t=this._consume(ra.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new fo(e))}_type_alias(){const e=this._consume(ra.tokens.ident,"identity expected.");this._consume(ra.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 go(e.toString(),t));return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([ra.tokens.ident,...ra.texel_format,ra.keywords.bool,ra.keywords.f32,ra.keywords.i32,ra.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 yo(e));return this._forwardTypeCount++,t}return this._updateNode(new vo(e))}let e=this._texture_sampler_types();if(e)return e;if(this._check(ra.template_types)){let e=this._advance().toString(),t=null,n=null;return this._match(ra.tokens.less_than)&&(t=this._type_decl(),n=null,this._match(ra.tokens.comma)&&(n=this._consume(ra.access_mode,"Expected access_mode for pointer").toString()),this._consume(ra.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new xo(e,t,n))}if(this._match(ra.keywords.ptr)){let e=this._previous().toString();this._consume(ra.tokens.less_than,"Expected '<' for pointer.");const t=this._consume(ra.storage_class,"Expected storage_class for pointer");this._consume(ra.tokens.comma,"Expected ',' for pointer.");const n=this._type_decl();let r=null;return this._match(ra.tokens.comma)&&(r=this._consume(ra.access_mode,"Expected access_mode for pointer").toString()),this._consume(ra.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new Eo(e,t.toString(),n,r))}const t=this._attribute();if(this._match(ra.keywords.array)){let e=null,r=-1;const i=this._previous();let s=null;if(this._match(ra.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(ra.tokens.comma)){s=this._shift_expression();try{t=s.constEvaluate(this._exec).toString(),s=null}catch(n){t="1"}}this._consume(ra.tokens.greater_than,"Expected '>' for array."),r=t?parseInt(t):0}const o=this._updateNode(new To(i.toString(),t,e,r));return s&&this._deferArrayCountEval.push({arrayType:o,countNode:s}),o}return null}_texture_sampler_types(){if(this._match(ra.sampler_type))return this._updateNode(new So(this._previous().toString(),null,null));if(this._match(ra.depth_texture_type))return this._updateNode(new So(this._previous().toString(),null,null));if(this._match(ra.sampled_texture_type)||this._match(ra.multisampled_texture_type)){const e=this._previous();this._consume(ra.tokens.less_than,"Expected '<' for sampler type.");const t=this._type_decl();return this._consume(ra.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new So(e.toString(),t,null))}if(this._match(ra.storage_texture_type)){const e=this._previous();this._consume(ra.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume(ra.texel_format,"Invalid texel format.").toString();this._consume(ra.tokens.comma,"Expected ',' after texel format.");const n=this._consume(ra.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(ra.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new So(e.toString(),t,n))}return null}_attribute(){let e=[];for(;this._match(ra.tokens.attr);){const t=this._consume(ra.attribute_name,"Expected attribute name"),n=this._updateNode(new $o(t.toString(),null));if(this._match(ra.tokens.paren_left)){if(n.value=this._consume(ra.literal_or_ident,"Expected attribute value").toString(),this._check(ra.tokens.comma)){this._advance();do{const e=this._consume(ra.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(e)}while(this._match(ra.tokens.comma))}this._consume(ra.tokens.paren_right,"Expected ')'")}e.push(n)}return 0==e.length?null:e}}class Ia extends ba{constructor(e){super(),e&&this.update(e)}update(e){const t=(new Pa).parse(e);this.updateAST(t)}}function Ma(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 La=globalThis.mathgl.config;function Na(e,{precision:t=La.precision}={}){return e=function(e){return Math.round(e/La.EPSILON)*La.EPSILON}(e),`${parseFloat(e.toPrecision(t))}`}function Ba(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Da(e,t,n){return function(e,t,n){if(Ba(e)){const r=e;n=n||function(e){return e.clone?e.clone():new Array(e.length)}(r);for(let i=0;i<n.length&&i<r.length;++i){const r="number"==typeof e?e:e[i];n[i]=t(r)}return n}return t(e)}(e,e=>Math.max(t,Math.min(n,e)))}function Oa(e,t,n){return Ba(e)?e.map((e,r)=>Oa(e,t[r],n)):n*t+(1-n)*e}function Fa(e,t,n){const r=La.EPSILON;try{if(e===t)return!0;if(Ba(e)&&Ba(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!Fa(e[n],t[n]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):"number"==typeof e&&"number"==typeof t&&Math.abs(e-t)<=La.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{La.EPSILON=r}}class Ua extends Array{clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Ba(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(La)}formatString(e){let t="";for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+Na(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<this.ELEMENTS;++t)if(!Fa(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(void 0===n)return this.lerp(this,e,t);for(let r=0;r<this.ELEMENTS;++r){const i=e[r],s="number"==typeof t?t:t[r];this[r]=i+n*(s-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if("number"==typeof e)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(La.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}get elements(){return this}}function ja(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Ga(e,t,n=""){if(La.debug&&!function(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function za(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}class Va extends Ua{get x(){return this[0]}set x(e){this[0]=ja(e)}get y(){return this[1]}set y(e){this[1]=ja(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){const r=this[n]-e[n];t+=r*r}return ja(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return ja(t)}normalize(){const e=this.magnitude();if(0!==e)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return za(e>=0&&e<this.ELEMENTS,"index is out of range"),ja(this[e])}setComponent(e,t){return za(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}const Wa=1e-6;let Ha="undefined"!=typeof Float32Array?Float32Array:Array;function $a(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function Xa(e,t,n,r){const i=t[0],s=t[1];return e[0]=i+r*(n[0]-i),e[1]=s+r*(n[1]-s),e}function Qa(e,t,n){const r=t[0],i=t[1],s=t[2],o=n[3]*r+n[7]*i+n[11]*s||1;return e[0]=(n[0]*r+n[4]*i+n[8]*s)/o,e[1]=(n[1]*r+n[5]*i+n[9]*s)/o,e[2]=(n[2]*r+n[6]*i+n[10]*s)/o,e}function Ya(e,t,n){const r=t[0],i=t[1],s=t[2];let o=n[3]*r+n[7]*i+n[11]*s+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*i+n[8]*s+n[12])/o,e[1]=(n[1]*r+n[5]*i+n[9]*s+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*s+n[14])/o,e}!function(){const e=new Ha(2);Ha!=Float32Array&&(e[0]=0,e[1]=0)}();const qa=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e},Ka=function(e){const t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r};!function(){const e=new Ha(3);Ha!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0)}();const Za=[0,0,0];let Ja;class eA extends Va{static get ZERO(){return Ja||(Ja=new eA(0,0,0),Object.freeze(Ja)),Ja}constructor(e=0,t=0,n=0){super(-0,-0,-0),1===arguments.length&&Ba(e)?this.copy(e):(La.debug&&(ja(e),ja(t),ja(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return La.debug&&(ja(e.x),ja(e.y),ja(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=ja(e)}angle(e){return function(e,t){const n=e[0],r=e[1],i=e[2],s=t[0],o=t[1],a=t[2],A=Math.sqrt((n*n+r*r+i*i)*(s*s+o*o+a*a)),l=A&&function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}(e,t)/A;return Math.acos(Math.min(Math.max(l,-1),1))}(this,e)}cross(e){return function(e,t,n){const r=t[0],i=t[1],s=t[2],o=n[0],a=n[1],A=n[2];e[0]=i*A-s*a,e[1]=s*o-r*A,e[2]=r*a-i*o}(this,this,e),this.check()}rotateX({radians:e,origin:t=Za}){return function(e,t,n,r){const i=[],s=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],s[0]=i[0],s[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),s[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=s[0]+n[0],e[1]=s[1]+n[1],e[2]=s[2]+n[2]}(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Za}){return function(e,t,n,r){const i=[],s=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],s[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),s[1]=i[1],s[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=s[0]+n[0],e[1]=s[1]+n[1],e[2]=s[2]+n[2]}(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Za}){return function(e,t,n,r){const i=[],s=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],s[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),s[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),s[2]=i[2],e[0]=s[0]+n[0],e[1]=s[1]+n[1],e[2]=s[2]+n[2]}(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Ya(this,this,e),this.check()}transformAsVector(e){return Qa(this,this,e),this.check()}transformByMatrix3(e){return function(e,t,n){const r=t[0],i=t[1],s=t[2];e[0]=r*n[0]+i*n[3]+s*n[6],e[1]=r*n[1]+i*n[4]+s*n[7],e[2]=r*n[2]+i*n[5]+s*n[8]}(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,n){const r=t[0],i=t[1];e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e[2]=t[2]}(this,this,e),this.check()}transformByQuaternion(e){return function(e,t,n){const r=n[0],i=n[1],s=n[2],o=n[3],a=t[0],A=t[1],l=t[2];let c=i*l-s*A,u=s*a-r*l,h=r*A-i*a,d=i*h-s*u,f=s*c-r*h,p=r*u-i*c;const g=2*o;c*=g,u*=g,h*=g,d*=2,f*=2,p*=2,e[0]=a+c+d,e[1]=A+u+f,e[2]=l+h+p}(this,this,e),this.check()}}class tA extends Ua{toString(){let e="[";if(La.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=ja(n),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const n=e*this.RANK;for(let r=0;r<this.RANK;++r)t[r]=this[n+r];return t}setColumn(e,t){const n=e*this.RANK;for(let r=0;r<this.RANK;++r)this[n+r]=t[r];return this}}function nA(e,t){const n=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],A=t[6],l=t[7],c=t[8],u=t[9],h=t[10],d=t[11],f=t[12],p=t[13],g=t[14],m=t[15],_=n*a-r*o,b=n*A-i*o,v=n*l-s*o,y=r*A-i*a,w=r*l-s*a,x=i*l-s*A,E=c*p-u*f,T=c*g-h*f,S=c*m-d*f,C=u*g-h*p,k=u*m-d*p,R=h*m-d*g;let P=_*R-b*k+v*C+y*S-w*T+x*E;return P?(P=1/P,e[0]=(a*R-A*k+l*C)*P,e[1]=(i*k-r*R-s*C)*P,e[2]=(p*x-g*w+m*y)*P,e[3]=(h*w-u*x-d*y)*P,e[4]=(A*S-o*R-l*T)*P,e[5]=(n*R-i*S+s*T)*P,e[6]=(g*v-f*x-m*b)*P,e[7]=(c*x-h*v+d*b)*P,e[8]=(o*k-a*S+l*E)*P,e[9]=(r*S-n*k-s*E)*P,e[10]=(f*w-p*v+m*_)*P,e[11]=(u*v-c*w-d*_)*P,e[12]=(a*T-o*C-A*E)*P,e[13]=(n*C-r*T+i*E)*P,e[14]=(p*b-f*y-g*_)*P,e[15]=(c*y-u*b+h*_)*P,e):null}function rA(e,t,n){const r=t[0],i=t[1],s=t[2],o=t[3],a=t[4],A=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],p=t[12],g=t[13],m=t[14],_=t[15];let b=n[0],v=n[1],y=n[2],w=n[3];return e[0]=b*r+v*a+y*u+w*p,e[1]=b*i+v*A+y*h+w*g,e[2]=b*s+v*l+y*d+w*m,e[3]=b*o+v*c+y*f+w*_,b=n[4],v=n[5],y=n[6],w=n[7],e[4]=b*r+v*a+y*u+w*p,e[5]=b*i+v*A+y*h+w*g,e[6]=b*s+v*l+y*d+w*m,e[7]=b*o+v*c+y*f+w*_,b=n[8],v=n[9],y=n[10],w=n[11],e[8]=b*r+v*a+y*u+w*p,e[9]=b*i+v*A+y*h+w*g,e[10]=b*s+v*l+y*d+w*m,e[11]=b*o+v*c+y*f+w*_,b=n[12],v=n[13],y=n[14],w=n[15],e[12]=b*r+v*a+y*u+w*p,e[13]=b*i+v*A+y*h+w*g,e[14]=b*s+v*l+y*d+w*m,e[15]=b*o+v*c+y*f+w*_,e}function iA(e,t,n){const r=n[0],i=n[1],s=n[2];let o,a,A,l,c,u,h,d,f,p,g,m;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*s+t[12],e[13]=t[1]*r+t[5]*i+t[9]*s+t[13],e[14]=t[2]*r+t[6]*i+t[10]*s+t[14],e[15]=t[3]*r+t[7]*i+t[11]*s+t[15]):(o=t[0],a=t[1],A=t[2],l=t[3],c=t[4],u=t[5],h=t[6],d=t[7],f=t[8],p=t[9],g=t[10],m=t[11],e[0]=o,e[1]=a,e[2]=A,e[3]=l,e[4]=c,e[5]=u,e[6]=h,e[7]=d,e[8]=f,e[9]=p,e[10]=g,e[11]=m,e[12]=o*r+c*i+f*s+t[12],e[13]=a*r+u*i+p*s+t[13],e[14]=A*r+h*i+g*s+t[14],e[15]=l*r+d*i+m*s+t[15]),e}function sA(e,t,n){const r=n[0],i=n[1],s=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function oA(e,t,n){const r=Math.sin(n),i=Math.cos(n),s=t[4],o=t[5],a=t[6],A=t[7],l=t[8],c=t[9],u=t[10],h=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*i+l*r,e[5]=o*i+c*r,e[6]=a*i+u*r,e[7]=A*i+h*r,e[8]=l*i-s*r,e[9]=c*i-o*r,e[10]=u*i-a*r,e[11]=h*i-A*r,e}function aA(e,t,n){const r=Math.sin(n),i=Math.cos(n),s=t[0],o=t[1],a=t[2],A=t[3],l=t[4],c=t[5],u=t[6],h=t[7];return t!==e&&(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]),e[0]=s*i+l*r,e[1]=o*i+c*r,e[2]=a*i+u*r,e[3]=A*i+h*r,e[4]=l*i-s*r,e[5]=c*i-o*r,e[6]=u*i-a*r,e[7]=h*i-A*r,e}function AA(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function lA(e,t,n){const r=t[0],i=t[1],s=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*s+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*s+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*s+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*s+n[15]*o,e}var cA,uA;!function(){const e=new Ha(4);Ha!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0)}(),(uA=cA||(cA={}))[uA.COL0ROW0=0]="COL0ROW0",uA[uA.COL0ROW1=1]="COL0ROW1",uA[uA.COL0ROW2=2]="COL0ROW2",uA[uA.COL0ROW3=3]="COL0ROW3",uA[uA.COL1ROW0=4]="COL1ROW0",uA[uA.COL1ROW1=5]="COL1ROW1",uA[uA.COL1ROW2=6]="COL1ROW2",uA[uA.COL1ROW3=7]="COL1ROW3",uA[uA.COL2ROW0=8]="COL2ROW0",uA[uA.COL2ROW1=9]="COL2ROW1",uA[uA.COL2ROW2=10]="COL2ROW2",uA[uA.COL2ROW3=11]="COL2ROW3",uA[uA.COL3ROW0=12]="COL3ROW0",uA[uA.COL3ROW1=13]="COL3ROW1",uA[uA.COL3ROW2=14]="COL3ROW2",uA[uA.COL3ROW3=15]="COL3ROW3";const hA=45*Math.PI/180,dA=1,fA=.1,pA=500,gA=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class mA extends tA{static get IDENTITY(){return bA||(bA=new mA,Object.freeze(bA)),bA}static get ZERO(){return _A||(_A=new mA([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(_A)),_A}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return cA}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,r,i,s,o,a,A,l,c,u,h,d,f,p){return this[0]=e,this[1]=t,this[2]=n,this[3]=r,this[4]=i,this[5]=s,this[6]=o,this[7]=a,this[8]=A,this[9]=l,this[10]=c,this[11]=u,this[12]=h,this[13]=d,this[14]=f,this[15]=p,this.check()}setRowMajor(e,t,n,r,i,s,o,a,A,l,c,u,h,d,f,p){return this[0]=e,this[1]=i,this[2]=A,this[3]=h,this[4]=t,this[5]=s,this[6]=l,this[7]=d,this[8]=n,this[9]=o,this[10]=c,this[11]=f,this[12]=r,this[13]=a,this[14]=u,this[15]=p,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(gA)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const n=t[0],r=t[1],i=t[2],s=t[3],o=n+n,a=r+r,A=i+i,l=n*o,c=r*o,u=r*a,h=i*o,d=i*a,f=i*A,p=s*o,g=s*a,m=s*A;e[0]=1-u-f,e[1]=c+m,e[2]=h-g,e[3]=0,e[4]=c-m,e[5]=1-l-f,e[6]=d+p,e[7]=0,e[8]=h+g,e[9]=d-p,e[10]=1-l-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:n,bottom:r,top:i,near:s=fA,far:o=pA}=e;return o===1/0?function(e,t,n,r,i,s){const o=2*s/(n-t),a=2*s/(i-r),A=(n+t)/(n-t),l=(i+r)/(i-r),c=-2*s;e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=A,e[9]=l,e[10]=-1,e[11]=-1,e[12]=0,e[13]=0,e[14]=c,e[15]=0}(this,t,n,r,i,s):function(e,t,n,r,i,s,o){const a=1/(n-t),A=1/(i-r),l=1/(s-o);e[0]=2*s*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*s*A,e[6]=0,e[7]=0,e[8]=(n+t)*a,e[9]=(i+r)*A,e[10]=(o+s)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*s*2*l,e[15]=0}(this,t,n,r,i,s,o),this.check()}lookAt(e){const{eye:t,center:n=[0,0,0],up:r=[0,1,0]}=e;return function(e,t,n,r){let i,s,o,a,A,l,c,u,h,d;const f=t[0],p=t[1],g=t[2],m=r[0],_=r[1],b=r[2],v=n[0],y=n[1],w=n[2];Math.abs(f-v)<Wa&&Math.abs(p-y)<Wa&&Math.abs(g-w)<Wa?function(e){e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(e):(u=f-v,h=p-y,d=g-w,i=1/Math.sqrt(u*u+h*h+d*d),u*=i,h*=i,d*=i,s=_*d-b*h,o=b*u-m*d,a=m*h-_*u,i=Math.sqrt(s*s+o*o+a*a),i?(i=1/i,s*=i,o*=i,a*=i):(s=0,o=0,a=0),A=h*a-d*o,l=d*s-u*a,c=u*o-h*s,i=Math.sqrt(A*A+l*l+c*c),i?(i=1/i,A*=i,l*=i,c*=i):(A=0,l=0,c=0),e[0]=s,e[1]=A,e[2]=u,e[3]=0,e[4]=o,e[5]=l,e[6]=h,e[7]=0,e[8]=a,e[9]=c,e[10]=d,e[11]=0,e[12]=-(s*f+o*p+a*g),e[13]=-(A*f+l*p+c*g),e[14]=-(u*f+h*p+d*g),e[15]=1)}(this,t,n,r),this.check()}ortho(e){const{left:t,right:n,bottom:r,top:i,near:s=fA,far:o=pA}=e;return function(e,t,n,r,i,s,o){const a=1/(t-n),A=1/(r-i),l=1/(s-o);e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*A,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*a,e[13]=(i+r)*A,e[14]=(o+s)*l,e[15]=1}(this,t,n,r,i,s,o),this.check()}orthographic(e){const{fovy:t=hA,aspect:n=dA,focalDistance:r=1,near:i=fA,far:s=pA}=e;vA(t);const o=t/2,a=r*Math.tan(o),A=a*n;return this.ortho({left:-A,right:A,bottom:-a,top:a,near:i,far:s})}perspective(e){const{fovy:t=45*Math.PI/180,aspect:n=1,near:r=.1,far:i=500}=e;return vA(t),function(e,t,n,r,i){const s=1/Math.tan(t/2);if(e[0]=s/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0){const t=1/(r-i);e[10]=(i+r)*t,e[14]=2*i*r*t}else e[10]=-1,e[14]=-2*r}(this,t,n,r,i),this.check()}determinant(){return function(e){const t=e[0],n=e[1],r=e[2],i=e[3],s=e[4],o=e[5],a=e[6],A=e[7],l=e[8],c=e[9],u=e[10],h=e[11],d=e[12],f=e[13],p=e[14],g=t*o-n*s,m=t*a-r*s,_=n*a-r*o,b=l*f-c*d,v=l*p-u*d,y=c*p-u*f;return A*(t*y-n*v+r*b)-i*(s*y-o*v+a*b)+e[15]*(l*_-c*m+u*g)-h*(d*_-f*m+p*g)}(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const n=this.getScale(t),r=1/n[0],i=1/n[1],s=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*s,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*i,e[6]=this[6]*s,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*i,e[10]=this[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const n=this.getScale(t),r=1/n[0],i=1/n[1],s=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*s,e[3]=this[4]*r,e[4]=this[5]*i,e[5]=this[6]*s,e[6]=this[8]*r,e[7]=this[9]*i,e[8]=this[10]*s,e}transpose(){return function(e,t){if(e===t){const n=t[1],r=t[2],i=t[3],s=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=s,e[11]=t[14],e[12]=i,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15]}(this,this),this.check()}invert(){return nA(this,this),this.check()}multiplyLeft(e){return rA(this,e,this),this.check()}multiplyRight(e){return rA(this,this,e),this.check()}rotateX(e){return oA(this,this,e),this.check()}rotateY(e){return function(e,t,n){const r=Math.sin(n),i=Math.cos(n),s=t[0],o=t[1],a=t[2],A=t[3],l=t[8],c=t[9],u=t[10],h=t[11];t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i-l*r,e[1]=o*i-c*r,e[2]=a*i-u*r,e[3]=A*i-h*r,e[8]=s*r+l*i,e[9]=o*r+c*i,e[10]=a*r+u*i,e[11]=A*r+h*i}(this,this,e),this.check()}rotateZ(e){return aA(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return function(e,t,n,r){let i,s,o,a,A,l,c,u,h,d,f,p,g,m,_,b,v,y,w,x,E,T,S,C,k=r[0],R=r[1],P=r[2],I=Math.sqrt(k*k+R*R+P*P);I<Wa||(I=1/I,k*=I,R*=I,P*=I,s=Math.sin(n),i=Math.cos(n),o=1-i,a=t[0],A=t[1],l=t[2],c=t[3],u=t[4],h=t[5],d=t[6],f=t[7],p=t[8],g=t[9],m=t[10],_=t[11],b=k*k*o+i,v=R*k*o+P*s,y=P*k*o-R*s,w=k*R*o-P*s,x=R*R*o+i,E=P*R*o+k*s,T=k*P*o+R*s,S=R*P*o-k*s,C=P*P*o+i,e[0]=a*b+u*v+p*y,e[1]=A*b+h*v+g*y,e[2]=l*b+d*v+m*y,e[3]=c*b+f*v+_*y,e[4]=a*w+u*x+p*E,e[5]=A*w+h*x+g*E,e[6]=l*w+d*x+m*E,e[7]=c*w+f*x+_*E,e[8]=a*T+u*S+p*C,e[9]=A*T+h*S+g*C,e[10]=l*T+d*S+m*C,e[11]=c*T+f*S+_*C,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}(this,this,e,t),this.check()}scale(e){return sA(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return iA(this,this,e),this.check()}transform(e,t){return 4===e.length?(Ga(t=lA(t||[-0,-0,-0,-0],e,this),4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){const{length:n}=e;let r;switch(n){case 2:r=function(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e}(t||[-0,-0],e,this);break;case 3:r=Ya(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ga(r,e.length),r}transformAsVector(e,t){let n;switch(e.length){case 2:n=function(e,t,n){const r=t[0],i=t[1],s=n[3]*r+n[7]*i||1;return e[0]=(n[0]*r+n[4]*i)/s,e[1]=(n[1]*r+n[5]*i)/s,e}(t||[-0,-0],e,this);break;case 3:n=Qa(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ga(n,e.length),n}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}}let _A,bA;function vA(e){if(e>2*Math.PI)throw Error("expected radians")}function yA(e,t=[],n=0){const r=Math.fround(e),i=e-r;return t[n]=r,t[n+1]=i,t}const wA={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:yA,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 r=0;r<4;++r){const i=4*n+r;yA(e[4*r+n],t,2*i)}return t}},xA={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},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}},EA="precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int lightType;\n\n int directionalLightCount;\n int pointLightCount;\n\n vec3 ambientColor;\n\n vec3 lightColor0;\n vec3 lightPosition0;\n vec3 lightDirection0;\n vec3 lightAttenuation0;\n\n vec3 lightColor1;\n vec3 lightPosition1;\n vec3 lightDirection1;\n vec3 lightAttenuation1;\n\n vec3 lightColor2;\n vec3 lightPosition2;\n vec3 lightDirection2;\n vec3 lightAttenuation2;\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n switch (index) {\n case 0:\n return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);\n case 1:\n return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);\n case 2:\n default: \n return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);\n }\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n switch (index) {\n case 0:\n return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);\n case 1:\n return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);\n case 2:\n default: \n return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);\n }\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";var TA,SA;(SA=TA||(TA={}))[SA.POINT=0]="POINT",SA[SA.DIRECTIONAL=1]="DIRECTIONAL";const CA={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:TA.POINT,directionalLightCount:0,pointLightCount:0,ambientColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0]},source:"// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n color: vec3<f32>,\n};\n\nstruct PointLight {\n color: vec3<f32>,\n position: vec3<f32>,\n attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n color: vec3<f32>,\n direction: vec3<f32>,\n};\n\nstruct lightingUniforms {\n enabled: i32,\n pointLightCount: i32,\n directionalLightCount: i32,\n\n ambientColor: vec3<f32>,\n\n // TODO - support multiple lights by uncommenting arrays below\n lightType: i32,\n lightColor: vec3<f32>,\n lightDirection: vec3<f32>,\n lightPosition: vec3<f32>,\n lightAttenuation: vec3<f32>,\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n};\n\n// Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)\n@binding(1) @group(0) var<uniform> lighting : lightingUniforms;\n\nfn lighting_getPointLight(index: i32) -> PointLight {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nfn lighting_getDirectionalLight(index: i32) -> DirectionalLight {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n",vs:EA,fs:EA,getUniforms:function(e,t={}){if(!(e=e?{...e}:e))return{...CA.defaultUniforms};e.lights&&(e={...e,...RA(e.lights),lights:void 0});const{ambientLight:n,pointLights:r,directionalLights:i}=e||{};if(!(n||r&&r.length>0||i&&i.length>0))return{...CA.defaultUniforms,enabled:0};const s={...CA.defaultUniforms,...t,...kA({ambientLight:n,pointLights:r,directionalLights:i})};return void 0!==e.enabled&&(s.enabled=e.enabled?1:0),s}};function kA({ambientLight:e,pointLights:t=[],directionalLights:n=[]}){const r={};r.ambientColor=PA(e);let i=0;for(const s of t){r.lightType=TA.POINT;const e=i;r[`lightColor${e}`]=PA(s),r[`lightPosition${e}`]=s.position,r[`lightAttenuation${e}`]=s.attenuation||[1,0,0],i++}for(const s of n){r.lightType=TA.DIRECTIONAL;const e=i;r[`lightColor${e}`]=PA(s),r[`lightDirection${e}`]=s.direction,i++}return i>5&&Nr.warn("MAX_LIGHTS exceeded")(),r.directionalLightCount=n.length,r.pointLightCount=t.length,r}function RA(e){var t,n;const r={pointLights:[],directionalLights:[]};for(const i of e||[])switch(i.type){case"ambient":r.ambientLight=i;break;case"directional":null==(t=r.directionalLights)||t.push(i);break;case"point":null==(n=r.pointLights)||n.push(i)}return r}function PA(e={}){const{color:t=[0,0,0],intensity:n=1}=e;return t.map(e=>e*n/255)}const IA="uniform phongMaterialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n",MA="#define MAX_LIGHTS 3\n\nuniform phongMaterialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);\n for (int i = lighting.pointLightCount; i < totalLights; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n",LA="struct phongMaterialUniforms {\n ambient: f32,\n diffuse: f32,\n shininess: f32,\n specularColor: vec3<f32>,\n};\n\n@binding(2) @group(0) var<uniform> phongMaterial : phongMaterialUniforms;\n\nfn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {\n let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);\n var lambertian: f32 = dot(light_direction, normal_worldspace);\n var specular: f32 = 0.0;\n if (lambertian > 0.0) {\n let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, phongMaterial.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * phongMaterial.diffuse * surfaceColor + specular * phongMaterial.specularColor) * color;\n}\n\nfn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {\n var lightColor: vec3<f32> = surfaceColor;\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);\n lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;\n\n if (lighting.lightType == 0) {\n let pointLight: PointLight = lighting_getPointLight(0);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n } else if (lighting.lightType == 1) {\n var directionalLight: DirectionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n /*\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.pointLightCount) {\n break;\n }\n PointLight pointLight = lighting.pointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.directionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting.directionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n */\n}\n\nfn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{\n var lightColor = vec3<f32>(0, 0, 0);\n let surfaceColor = vec3<f32>(0, 0, 0);\n\n if (lighting.enabled == 0) {\n let view_direction = normalize(cameraPosition - position_worldspace);\n\n switch (lighting.lightType) {\n case 0, default: {\n let pointLight: PointLight = lighting_getPointLight(0);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n case 1: {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n }\n return lightColor;\n}\n",NA={props:{},name:"gouraudMaterial",vs:MA.replace("phongMaterial","gouraudMaterial"),fs:IA.replace("phongMaterial","gouraudMaterial"),source:LA.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[CA],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(e){const t={...e};return t.specularColor&&(t.specularColor=t.specularColor.map(e=>e/255)),{...NA.defaultUniforms,...t}}},BA={name:"phongMaterial",dependencies:[CA],source:LA,vs:IA,fs:MA,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(e){const t={...e};return t.specularColor&&(t.specularColor=t.specularColor.map(e=>e/255)),{...BA.defaultUniforms,...t}}},DA="uniform layerUniforms {\n uniform float opacity;\n} layer;\n",OA={name:"layer",vs:DA,fs:DA,getUniforms:e=>({opacity:Math.pow(e.opacity,1/2.2)}),uniformTypes:{opacity:"f32"}},FA="#define SMOOTH_EDGE_RADIUS 0.5",UA={name:"geometry",source:"const SMOOTH_EDGE_RADIUS: f32 = 0.5;\n\nstruct VertexGeometry {\n position: vec4<f32>,\n worldPosition: vec3<f32>,\n worldPositionAlt: vec3<f32>,\n normal: vec3<f32>,\n uv: vec2<f32>,\n pickingColor: vec3<f32>,\n};\n\nvar<private> geometry_: VertexGeometry = VertexGeometry(\n vec4<f32>(0.0, 0.0, 1.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec2<f32>(0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0)\n);\n\nstruct FragmentGeometry {\n uv: vec2<f32>,\n};\n\nvar<private> 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:`${FA}\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:`${FA}\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 jA,GA,zA,VA,WA,HA;(GA=jA||(jA={}))[GA.Start=1]="Start",GA[GA.Move=2]="Move",GA[GA.End=4]="End",GA[GA.Cancel=8]="Cancel",(VA=zA||(zA={}))[VA.None=0]="None",VA[VA.Left=1]="Left",VA[VA.Right=2]="Right",VA[VA.Up=4]="Up",VA[VA.Down=8]="Down",VA[VA.Horizontal=3]="Horizontal",VA[VA.Vertical=12]="Vertical",VA[VA.All=15]="All",(HA=WA||(WA={}))[HA.Possible=1]="Possible",HA[HA.Began=2]="Began",HA[HA.Changed=4]="Changed",HA[HA.Ended=8]="Ended",HA[HA.Recognized=8]="Recognized",HA[HA.Cancelled=16]="Cancelled",HA[HA.Failed=32]="Failed";const $A="manipulation",XA="none",QA="pan-x",YA="pan-y";class qA{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(XA))return XA;const t=e.includes(QA),n=e.includes(YA);return t&&n?XA:t||n?t?QA:YA:e.includes($A)?$A:"auto"}(e.join(" "))}}function KA(e){return e.trim().split(/\s+/g)}function ZA(e,t,n){if(e)for(const r of KA(t))e.addEventListener(r,n,!1)}function JA(e,t,n){if(e)for(const r of KA(t))e.removeEventListener(r,n,!1)}function el(e){return(e.ownerDocument||e).defaultView}function tl(e){const t=e.length;if(1===t)return{x:Math.round(e[0].clientX),y:Math.round(e[0].clientY)};let n=0,r=0,i=0;for(;i<t;)n+=e[i].clientX,r+=e[i].clientY,i++;return{x:Math.round(n/t),y:Math.round(r/t)}}function nl(e){const t=[];let n=0;for(;n<e.pointers.length;)t[n]={clientX:Math.round(e.pointers[n].clientX),clientY:Math.round(e.pointers[n].clientY)},n++;return{timeStamp:Date.now(),pointers:t,center:tl(t),deltaX:e.deltaX,deltaY:e.deltaY}}function rl(e,t){const n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function il(e,t){const n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.sqrt(n*n+r*r)}function sl(e,t){const n=t.clientX-e.clientX,r=t.clientY-e.clientY;return 180*Math.atan2(r,n)/Math.PI}function ol(e,t){return e===t?zA.None:Math.abs(e)>=Math.abs(t)?e<0?zA.Left:zA.Right:t<0?zA.Up:zA.Down}function al(e,t,n){return{x:t/e||0,y:n/e||0}}let Al=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 r=n.pointers.length,i=n.changedPointers.length,s=t&jA.Start&&r-i===0,o=t&(jA.End|jA.Cancel)&&r-i===0;n.isFirst=Boolean(s),n.isFinal=Boolean(o),s&&(e.session={}),n.eventType=t;const a=function(e,t){const{session:n}=e,{pointers:r}=t,{length:i}=r;n.firstInput||(n.firstInput=nl(t)),i>1&&!n.firstMultiple?n.firstMultiple=nl(t):1===i&&(n.firstMultiple=!1);const{firstInput:s,firstMultiple:o}=n,a=o?o.center:s.center,A=t.center=tl(r);t.timeStamp=Date.now(),t.deltaTime=t.timeStamp-s.timeStamp,t.angle=function(e,t){const n=t.x-e.x,r=t.y-e.y;return 180*Math.atan2(r,n)/Math.PI}(a,A),t.distance=rl(a,A);const{deltaX:l,deltaY:c}=function(e,t){const n=t.center;let r=e.offsetDelta,i=e.prevDelta;const s=e.prevInput;return t.eventType!==jA.Start&&(null==s?void 0:s.eventType)!==jA.End||(i=e.prevDelta={x:(null==s?void 0:s.deltaX)||0,y:(null==s?void 0:s.deltaY)||0},r=e.offsetDelta={x:n.x,y:n.y}),{deltaX:i.x+(n.x-r.x),deltaY:i.y+(n.y-r.y)}}(n,t);t.deltaX=l,t.deltaY=c,t.offsetDirection=ol(t.deltaX,t.deltaY);const u=al(t.deltaTime,t.deltaX,t.deltaY);var h,d;t.overallVelocityX=u.x,t.overallVelocityY=u.y,t.overallVelocity=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,t.scale=o?(h=o.pointers,il((d=r)[0],d[1])/il(h[0],h[1])):1,t.rotation=o?function(e,t){return sl(t[1],t[0])-sl(e[1],e[0])}(o.pointers,r):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length;let f=e.element;return function(e,t){let n=e;for(;n;){if(n===t)return!0;n=n.parentNode}return!1}(t.srcEvent.target,f)&&(f=t.srcEvent.target),t.target=f,function(e,t){const n=e.lastInterval||t,r=t.timeStamp-n.timeStamp;let i,s,o,a;if(t.eventType!==jA.Cancel&&(r>25||void 0===n.velocity)){const A=t.deltaX-n.deltaX,l=t.deltaY-n.deltaY,c=al(r,A,l);s=c.x,o=c.y,i=Math.abs(c.x)>Math.abs(c.y)?c.x:c.y,a=ol(A,l),e.lastInterval=t}else i=n.velocity,s=n.velocityX,o=n.velocityY,a=n.direction;t.velocity=i,t.velocityX=s,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(){ZA(this.element,this.evEl,this.domHandler),ZA(this.target,this.evTarget,this.domHandler),ZA(el(this.element),this.evWin,this.domHandler)}destroy(){JA(this.element,this.evEl,this.domHandler),JA(this.target,this.evTarget,this.domHandler),JA(el(this.element),this.evWin,this.domHandler)}};const ll={pointerdown:jA.Start,pointermove:jA.Move,pointerup:jA.End,pointercancel:jA.Cancel,pointerout:jA.Cancel};class cl extends Al{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 r=ll[e.type],i=e.pointerType,s="touch"===i;let o=t.findIndex(t=>t.pointerId===e.pointerId);r&jA.Start&&(e.buttons||s)?o<0&&(t.push(e),o=t.length-1):r&(jA.End|jA.Cancel)&&(n=!0),o<0||(t[o]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:i,srcEvent:e}),n&&t.splice(o,1))}}const ul=["","webkit","Moz","MS","ms","o"];function hl(e,t){const n=t[0].toUpperCase()+t.slice(1);for(const r of ul){const i=r?r+n:t;if(i in e)return i}}const dl={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}};class fl{constructor(e,t){this.options={...dl,...t,cssProps:{...dl.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new cl(this),this.touchAction=new qA(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:r}=this;let{curRecognizer:i}=t;(!i||i&&i.state&WA.Recognized)&&(i=t.curRecognizer=null);let s=0;for(;s<r.length;)n=r[s],2===t.stopped||i&&n!==i&&!n.canRecognizeWith(i)?n.reset():n.recognize(e),!i&&n.state&(WA.Began|WA.Changed|WA.Ended)&&(i=t.curRecognizer=n),s++}get(e){const{recognizers:t}=this;for(let n=0;n<t.length;n++)if(t[n].options.event===e)return t[n];return null}add(e){if(Array.isArray(e)){for(const t of e)this.add(t);return this}const t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(const t of e)this.remove(t);return this}const t="string"==typeof e?this.get(e):e;if(t){const{recognizers:e}=this,n=e.indexOf(t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this}on(e,t){if(!e||!t)return;const{handlers:n}=this;for(const r of KA(e))n[r]=n[r]||[],n[r].push(t)}off(e,t){if(!e)return;const{handlers:n}=this;for(const r of KA(e))t?n[r]&&n[r].splice(n[r].indexOf(t),1):delete n[r]}emit(e,t){const n=this.handlers[e]&&this.handlers[e].slice();if(!n||!n.length)return;const r=t;r.type=e,r.preventDefault=function(){t.srcEvent.preventDefault()};let i=0;for(;i<n.length;)n[i](r),i++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){const{element:t}=this;if(t){for(const[n,r]of Object.entries(this.options.cssProps)){const i=hl(t.style,n);e?(this.oldCssProps[i]=t.style[i],t.style[i]=r):t.style[i]=this.oldCssProps[i]||""}e||(this.oldCssProps={})}}}let pl=1;function gl(e){return e&WA.Cancelled?"cancel":e&WA.Ended?"end":e&WA.Changed?"move":e&WA.Began?"start":""}class ml{constructor(e){this.options=e,this.id=pl++,this.state=WA.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(const t of e)this.recognizeWith(t);return this}let t;if("string"==typeof e){if(t=this.manager.get(e),!t)throw new Error(`Cannot find recognizer ${e}`)}else t=e;const{simultaneous:n}=this;return n[t.id]||(n[t.id]=t,t.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(const t of e)this.dropRecognizeWith(t);return this}let t;return t="string"==typeof e?this.manager.get(e):e,t&&delete this.simultaneous[t.id],this}requireFailure(e){if(Array.isArray(e)){for(const t of e)this.requireFailure(t);return this}let t;if("string"==typeof e){if(t=this.manager.get(e),!t)throw new Error(`Cannot find recognizer ${e}`)}else t=e;const{requireFail:n}=this;return-1===n.indexOf(t)&&(n.push(t),t.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(const t of e)this.dropRequireFailure(t);return this}let t;if(t="string"==typeof e?this.manager.get(e):e,t){const e=this.requireFail.indexOf(t);e>-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<WA.Ended&&this.manager.emit(this.options.event+gl(t),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),t>=WA.Ended&&this.manager.emit(this.options.event+gl(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=WA.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(WA.Failed|WA.Possible)))return!1;e++}return!0}recognize(e){const t={...e};if(!this.options.enable)return this.reset(),void(this.state=WA.Failed);this.state&(WA.Recognized|WA.Cancelled|WA.Failed)&&(this.state=WA.Possible),this.state=this.process(t),this.state&(WA.Began|WA.Changed|WA.Ended|WA.Cancelled)&&this.tryEmit(t)}getEventNames(){return[this.options.event]}reset(){}}class _l extends ml{attrTest(e){const t=this.options.pointers;return 0===t||e.pointers.length===t}process(e){const{state:t}=this,{eventType:n}=e,r=t&(WA.Began|WA.Changed),i=this.attrTest(e);return r&&(n&jA.Cancel||!i)?t|WA.Cancelled:r||i?n&jA.End?t|WA.Ended:t&WA.Began?t|WA.Changed:WA.Began:WA.Failed}}class bl extends ml{constructor(e={}){super({enable:!0,event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[$A]}process(e){const{options:t}=this,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&jA.Start&&0===this.count)return this.failTimeout();if(r&&i&&n){if(e.eventType!==jA.End)return this.failTimeout();const n=!this.pTime||e.timeStamp-this.pTime<t.interval,r=!this.pCenter||rl(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,r&&n?this.count+=1:this.count=1,this._input=e,0===this.count%t.taps)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=WA.Recognized,this.tryEmit(this._input)},t.interval),WA.Began):WA.Recognized}return WA.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=WA.Failed},this.options.interval),WA.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===WA.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}}const vl=["","start","move","end","cancel","up","down","left","right"];class yl extends _l{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:zA.All,...e}),this.pX=null,this.pY=null}getTouchAction(){const{options:{direction:e}}=this,t=[];return e&zA.Horizontal&&t.push(YA),e&zA.Vertical&&t.push(QA),t}getEventNames(){return vl.map(e=>this.options.event+e)}directionTest(e){const{options:t}=this;let n=!0,{distance:r}=e,{direction:i}=e;const s=e.deltaX,o=e.deltaY;return i&t.direction||(t.direction&zA.Horizontal?(i=0===s?zA.None:s<0?zA.Left:zA.Right,n=s!==this.pX,r=Math.abs(e.deltaX)):(i=0===o?zA.None:o<0?zA.Up:zA.Down,n=o!==this.pY,r=Math.abs(e.deltaY))),e.direction=i,n&&r>t.threshold&&Boolean(i&t.direction)}attrTest(e){return super.attrTest(e)&&(Boolean(this.state&WA.Began)||!(this.state&WA.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;const t=zA[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}}const wl=["","start","move","end","cancel","in","out"];class xl{constructor(e,t,n){this.element=e,this.callback=t,this.options=n}}const El=-1!==("undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"").indexOf("firefox"),Tl=4.000244140625;class Sl extends xl{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{if(!this.options.enable)return;let t=e.deltaY;globalThis.WheelEvent&&(El&&e.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(t/=globalThis.devicePixelRatio),e.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(t*=40)),0!==t&&t%Tl===0&&(t=Math.floor(t/Tl)),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 Cl=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"];class kl extends xl{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:r}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,Cl.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){Cl.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 Rl=["keydown","keyup"];class Pl extends xl{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",Rl.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){Rl.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){"keydown"===e&&(this.enableDownEvent=t),"keyup"===e&&(this.enableUpEvent=t)}}class Il extends xl{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 Ml={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4};function Ll(e){const t=Ml[e.srcEvent.type];if(!t)return null;const{buttons:n,button:r}=e.srcEvent;let i=!1,s=!1,o=!1;return 2===t?(i=Boolean(1&n),s=Boolean(4&n),o=Boolean(2&n)):(i=0===r,s=1===r,o=2===r),{leftButton:i,middleButton:s,rightButton:o}}function Nl(e,t){const n=e.center;if(!n)return null;const r=t.getBoundingClientRect(),i=r.width/t.offsetWidth||1,s=r.height/t.offsetHeight||1;return{center:n,offsetCenter:{x:(n.x-r.left-t.clientLeft)/i,y:(n.y-r.top-t.clientTop)/s}}}const Bl={srcElement:"root",priority:0};class Dl{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,r=!1,i=!1){const{handlers:s,handlersByElement:o}=this,a={...Bl,...n};let A=o.get(a.srcElement);A||(A=[],o.set(a.srcElement,A));const l={type:e,handler:t,srcElement:a.srcElement,priority:a.priority};r&&(l.once=!0),i&&(l.passive=!0),s.push(l),this._active=this._active||!l.passive;let c=A.length-1;for(;c>=0&&!(A[c].priority>=l.priority);)c--;A.splice(c+1,0,l)}remove(e,t){const{handlers:n,handlersByElement:r}=this;for(let i=n.length-1;i>=0;i--){const s=n[i];if(s.type===e&&s.handler===t){n.splice(i,1);const e=r.get(s.srcElement);e.splice(e.indexOf(s),1),0===e.length&&r.delete(s.srcElement)}}this._active=n.some(e=>!e.passive)}_emit(e,t){const n=this.handlersByElement.get(t);if(n){let t=!1;const r=()=>{e.handled=!0},i=()=>{e.handled=!0,t=!0},s=[];for(let o=0;o<n.length;o++){const{type:a,handler:A,once:l}=n[o];if(A({...e,type:a,stopPropagation:r,stopImmediatePropagation:i}),l&&s.push(n[o]),t)break}for(let e=0;e<s.length;e++){const{type:t,handler:n}=s[e];this.remove(t,n)}}}_normalizeEvent(e){const t=this.eventManager.getElement();return{...e,...Ll(e),...Nl(e,t),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}}function Ol(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 Fl{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 fl(e,this.options);for(const e of this.options.recognizers){const{recognizer:t,recognizeWith:n,requireFailure:r}=Ol(e);this.manager.add(t),n&&t.recognizeWith(n),r&&t.requireFailure(r)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new Sl(e,this._onOtherEvent,{enable:!1}),this.moveInput=new kl(e,this._onOtherEvent,{enable:!1}),this.keyInput=new Pl(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new Il(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,r,i,s;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==(r=this.moveInput)||r.enableEventType(e,t),null==(i=this.keyInput)||i.enableEventType(e,t),null==(s=this.contextmenuInput)||s.enableEventType(e,t)}_addEventHandler(e,t,n,r,i){if("string"!=typeof e){n=t;for(const[t,s]of Object.entries(e))this._addEventHandler(t,s,n,r,i);return}const{manager:s,events:o}=this;if(!s)return;let a=o.get(e);if(!a){const t=this._getRecognizerName(e)||e;a=new Dl(this,t),o.set(e,a),s&&s.on(e,a.handleEvent)}a.add(e,t,n,r,i),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,r=n.get(e);if(r&&(r.remove(e,t),r.isEmpty())){const{recognizerName:e}=r;let t=!1;for(const r of n.values())if(r.recognizerName===e&&!r.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 Ul={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(Ul,"IDENTITY",{get:()=>(Hn.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const jl={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Gl={common:0,meters:1,pixels:2},zl={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},Vl={multipan:[yl,{threshold:10,direction:zA.Vertical,pointers:2}],pinch:[class extends _l{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[XA]}getEventNames(){return wl.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||Boolean(this.state&WA.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:[yl,{threshold:1},["pinch"],["multipan"]],dblclick:[bl,{event:"dblclick",taps:2}],click:[bl,{event:"click"},null,["dblclick"]]};function Wl(e,t){if(e===t)return!0;if(Array.isArray(e)){const n=e.length;if(!t||t.length!==n)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}return!1}function Hl(e){let t,n={};return r=>{for(const i in r)if(!Wl(r[i],n[i])){t=e(r),n=r;break}return t}}const $l=[0,0,0,0],Xl=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],Ql=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Yl=[0,0,0],ql=[0,0,0],Kl=Hl(function({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:r}){const{projectionCenter:i,viewProjectionMatrix:s,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:A,geospatialOrigin:l}=function(e,t,n){const{viewMatrixUncentered:r,projectionMatrix:i}=e;let{viewMatrix:s,viewProjectionMatrix:o}=e,a=$l,A=$l,l=e.cameraPosition;const{geospatialOrigin:c,shaderCoordinateOrigin:u,offsetMode:h}=Zl(e,t,n);return h&&(A=e.projectPosition(c||u),l=[l[0]-A[0],l[1]-A[1],l[2]-A[2]],A[3]=1,a=lA([],A,o),s=r||s,o=rA([],i,s),o=rA([],o,Xl)),{viewMatrix:s,viewProjectionMatrix:o,projectionCenter:a,originCommon:A,cameraPosCommon:l,shaderCoordinateOrigin:u,geospatialOrigin:c}}(e,n,r),c=e.getDistanceScales(),u=[e.width*t,e.height*t],h=lA([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,d={coordinateSystem:n,projectionMode:e.projectionMode,coordinateOrigin:A,commonOrigin:o.slice(0,3),center:i,pseudoMeters:Boolean(e._pseudoMeters),viewportSize:u,devicePixelRatio:t,focalDistance:h,commonUnitsPerMeter:c.unitsPerMeter,commonUnitsPerWorldUnit:c.unitsPerMeter,commonUnitsPerWorldUnit2:Yl,scale:e.scale,wrapLongitude:!1,viewProjectionMatrix:s,modelMatrix:Ql,cameraPosition:a};if(l){const t=e.getDistanceScales(l);switch(n){case Ul.METER_OFFSETS:d.commonUnitsPerWorldUnit=t.unitsPerMeter,d.commonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case Ul.LNGLAT:case Ul.LNGLAT_OFFSETS:e._pseudoMeters||(d.commonUnitsPerMeter=t.unitsPerMeter),d.commonUnitsPerWorldUnit=t.unitsPerDegree,d.commonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case Ul.CARTESIAN:d.commonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],d.commonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]]}}return d});function Zl(e,t,n=ql){n.length<3&&(n=[n[0],n[1],0]);let r,i=n,s=!0;switch(r=t===Ul.LNGLAT_OFFSETS||t===Ul.METER_OFFSETS?n:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case jl.WEB_MERCATOR:t!==Ul.LNGLAT&&t!==Ul.CARTESIAN||(r=[0,0,0],s=!1);break;case jl.WEB_MERCATOR_AUTO_OFFSET:t===Ul.LNGLAT?i=r:t===Ul.CARTESIAN&&(i=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],r=e.unprojectPosition(i),i[0]-=n[0],i[1]-=n[1],i[2]-=n[2]);break;case jl.IDENTITY:i=e.position.map(Math.fround),i[2]=i[2]||0;break;case jl.GLOBE:s=!1,r=null;break;default:s=!1}return{geospatialOrigin:r,shaderCoordinateOrigin:i,offsetMode:s}}const Jl=`${Object.keys(Ul).map(e=>`const COORDINATE_SYSTEM_${e}: i32 = ${Ul[e]};`).join("")}\n${Object.keys(jl).map(e=>`const PROJECTION_MODE_${e}: i32 = ${jl[e]};`).join("")}\n${Object.keys(Gl).map(e=>`const UNIT_${e.toUpperCase()}: i32 = ${Gl[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<f32> = vec3<f32>(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<f32>,\n projectionMode: i32,\n scale: f32,\n commonUnitsPerWorldUnit: vec3<f32>,\n commonUnitsPerWorldUnit2: vec3<f32>,\n center: vec4<f32>,\n modelMatrix: mat4x4<f32>,\n viewProjectionMatrix: mat4x4<f32>,\n viewportSize: vec2<f32>,\n devicePixelRatio: f32,\n focalDistance: f32,\n cameraPosition: vec3<f32>,\n coordinateOrigin: vec3<f32>,\n commonOrigin: vec3<f32>,\n pseudoMeters: i32,\n};\n\n@group(0) @binding(0)\nvar<uniform> 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<f32>,\n worldPositionAlt: vec3<f32>,\n position: vec4<f32>,\n normal: vec3<f32>,\n uv: vec2<f32>,\n pickingColor: vec3<f32>,\n};\n\n// @group(0) @binding(1)\nvar<private> 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<f32>) -> vec2<f32> {\n return meters * project.commonUnitsPerMeter.xy * project_size();\n}\n\nfn project_size_vec3(meters: vec3<f32>) -> vec3<f32> {\n return meters * project.commonUnitsPerMeter * project_size();\n}\n\nfn project_size_vec4(meters: vec4<f32>) -> vec4<f32> {\n return vec4<f32>(meters.xyz * project.commonUnitsPerMeter, meters.w);\n}\n\n// Returns a rotation matrix aligning the zaxis with the given up vector.\nfn project_get_orientation_matrix(up: vec3<f32>) -> mat3x3<f32> {\n let uz = normalize(up);\n let ux = select(\n vec3<f32>(1.0, 0.0, 0.0),\n normalize(vec3<f32>(uz.y, -uz.x, 0.0)),\n abs(uz.z) == 1.0\n );\n let uy = cross(uz, ux);\n return mat3x3<f32>(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<f32>,\n};\n\nfn project_needs_rotation(commonPosition: vec3<f32>) -> RotationResult {\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n return RotationResult(true, project_get_orientation_matrix(commonPosition));\n } else {\n return RotationResult(false, mat3x3<f32>()); // 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<f32>) -> vec3<f32> {\n let normal_modelspace = project.modelMatrix * vec4<f32>(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<f32>) -> vec4<f32> {\n let dy: f32 = offset.y;\n let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;\n return vec4<f32>(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\n\n// Projects lng/lat coordinates to a unit tile [0,1]\nfn project_mercator_(lnglat: vec2<f32>) -> vec2<f32> {\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<f32>(\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<f32>) -> vec3<f32> {\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<f32>(\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<f32>, position64Low: vec3<f32>) -> vec4<f32> {\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<f32>(\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<f32>(\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<f32>(\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<f32>(position64Low, 0.0));\n}\n\n// Overloaded versions for different input types.\nfn project_position_vec4_f32(position: vec4<f32>) -> vec4<f32> {\n return project_position_vec4_f64(position, ZERO_64_LOW);\n}\n\nfn project_position_vec3_f64(position: vec3<f32>, position64Low: vec3<f32>) -> vec3<f32> {\n let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), position64Low);\n return projected_position.xyz;\n}\n\nfn project_position_vec3_f32(position: vec3<f32>) -> vec3<f32> {\n let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), ZERO_64_LOW);\n return projected_position.xyz;\n}\n\nfn project_position_vec2_f32(position: vec2<f32>) -> vec2<f32> {\n let projected_position = project_position_vec4_f64(vec4<f32>(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<f32>, viewProjectionMatrix: mat4x4<f32>, center: vec4<f32>) -> vec4<f32> {\n return viewProjectionMatrix * position + center;\n}\n\n// Uses the project viewProjectionMatrix and center.\nfn project_common_position_to_clipspace(position: vec4<f32>) -> vec4<f32> {\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<f32>) -> vec2<f32> {\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<f32>) -> vec2<f32> {\n return pixels / project.scale;\n}\n`,ec=Object.keys(Ul).map(e=>`const int COORDINATE_SYSTEM_${e} = ${Ul[e]};`).join(""),tc=Object.keys(jl).map(e=>`const int PROJECTION_MODE_${e} = ${jl[e]};`).join(""),nc=Object.keys(Gl).map(e=>`const int UNIT_${e.toUpperCase()} = ${Gl[e]};`).join(""),rc={},ic={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"},UA],source:Jl,vs:`${ec}\n${tc}\n${nc}\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=rc){return"viewport"in e?function({viewport:e,devicePixelRatio:t=1,modelMatrix:n=null,coordinateSystem:r=Ul.DEFAULT,coordinateOrigin:i=ql,autoWrapLongitude:s=!1}){r===Ul.DEFAULT&&(r=e.isGeospatial?Ul.LNGLAT:Ul.CARTESIAN);const o=Kl({viewport:e,devicePixelRatio:t,coordinateSystem:r,coordinateOrigin:i});return o.wrapLongitude=s,o.modelMatrix=n||Ql,o}(e):{}},uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3<f32>",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3<f32>",commonUnitsPerWorldUnit2:"vec3<f32>",center:"vec4<f32>",modelMatrix:"mat4x4<f32>",viewProjectionMatrix:"mat4x4<f32>",viewportSize:"vec2<f32>",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3<f32>",coordinateOrigin:"vec3<f32>",commonOrigin:"vec3<f32>",pseudoMeters:"f32"}},sc={name:"project32",dependencies:[ic],source:"// Define a structure to hold both the clip-space position and the common position.\nstruct ProjectResult {\n clipPosition: vec4<f32>,\n commonPosition: vec4<f32>,\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<f32>,\n position64Low: vec3<f32>,\n offset: vec3<f32>\n) -> ProjectResult {\n // Compute the projected position.\n let projectedPosition: vec3<f32> = project_position_vec3_f64(position, position64Low);\n\n // Start with the provided offset.\n var finalOffset: vec3<f32> = 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<f32> = vec4<f32>(projectedPosition + finalOffset, 1.0);\n\n // Convert to clip-space.\n let clipPosition: vec4<f32> = 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<f32>,\n position64Low: vec3<f32>,\n offset: vec3<f32>\n) -> vec4<f32> {\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 oc(e,t){const n=lA([],t,e);return AA(n,n,1/n[3]),n}function ac(e,t){const n=e%t;return n<0?t+n:n}function Ac(e,t,n){return e<t?t:e>n?n:e}const lc=Math.log2||function(e){return Math.log(e)*Math.LOG2E};function cc(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}const uc=Math.PI,hc=uc/4,dc=uc/180,fc=180/uc,pc=512,gc=85.051129,mc=1.5;function _c(e){const[t,n]=e;cc(Number.isFinite(t)),cc(Number.isFinite(n)&&n>=-90&&n<=90,"invalid latitude");const r=n*dc;return[pc*(t*dc+uc)/(2*uc),pc*(uc+Math.log(Math.tan(hc+.5*r)))/(2*uc)]}function bc(e){const[t,n]=e,r=t/pc*(2*uc)-uc,i=2*(Math.atan(Math.exp(n/pc*(2*uc)-uc))-hc);return[r*fc,i*fc]}function vc(e){return 12790407194604047e-21/Math.cos(e*dc)}function yc(e){const{latitude:t,longitude:n,highPrecision:r=!1}=e;cc(Number.isFinite(t)&&Number.isFinite(n));const i=Math.cos(t*dc),s=512/360,o=s/i,a=12790407194604047e-21/i,A={unitsPerMeter:[a,a,a],metersPerUnit:[1/a,1/a,1/a],unitsPerDegree:[s,o,a],degreesPerUnit:[.703125,1/o,1/a]};if(r){const e=dc*Math.tan(t*dc)/i,n=s*e/2,r=12790407194604047e-21*e,l=r/o*a;A.unitsPerDegree2=[0,n,r],A.unitsPerMeter2=[l,0,l]}return A}function wc(e,t){const[n,r,i]=e,[s,o,a]=t,{unitsPerMeter:A,unitsPerMeter2:l}=yc({longitude:n,latitude:r,highPrecision:!0}),c=_c(e);c[0]+=s*(A[0]+l[0]*o),c[1]+=o*(A[1]+l[1]*o);const u=bc(c),h=(i||0)+(a||0);return Number.isFinite(i)||Number.isFinite(a)?[u[0],u[1],h]:u}function xc(e){return 2*Math.atan(.5/e)*fc}function Ec(e){return.5/Math.tan(.5*e*dc)}function Tc(e,t){const[n,r,i=0]=e;return cc(Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)),oc(t,[n,r,i,1])}function Sc(e,t,n=0){const[r,i,s]=e;if(cc(Number.isFinite(r)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(s))return oc(t,[r,i,s,1]);const o=oc(t,[r,i,0,1]),a=oc(t,[r,i,1,1]),A=o[2],l=a[2];return Xa([],o,a,A===l?0:((n||0)-A)/(l-A))}const Cc=Math.PI/180;function kc(e,t,n){const{pixelUnprojectionMatrix:r}=e,i=oc(r,[t,0,1,1]),s=oc(r,[t,e.height,1,1]),o=bc(Xa([],i,s,(n*e.distanceScales.unitsPerMeter[2]-i[2])/(s[2]-i[2])));return o.push(n),o}const Rc="\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",Pc=`\n${Rc}\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`,Ic=`\n${Rc}\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`,Mc=Hl(function({viewport:e,center:t}){return new mA(e.viewProjectionMatrix).invert().transform(t)}),Lc=Hl(function({viewport:e,shadowMatrices:t}){const n=[],r=e.pixelUnprojectionMatrix,i=e.isGeospatial?void 0:1,s=[[0,0,i],[e.width,0,i],[0,e.height,i],[e.width,e.height,i],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(e=>function(e,t){const[n,r,i]=e,s=Sc([n,r,i],t);return Number.isFinite(i)?s:[s[0],s[1],0]}(e,r));for(const o of t){const t=o.clone().translate(new eA(e.center).negate()),r=s.map(e=>t.transform(e)),i=(new mA).ortho({left:Math.min(...r.map(e=>e[0])),right:Math.max(...r.map(e=>e[0])),bottom:Math.min(...r.map(e=>e[1])),top:Math.max(...r.map(e=>e[1])),near:Math.min(...r.map(e=>-e[2])),far:Math.max(...r.map(e=>-e[2]))});n.push(i.multiplyRight(o))}return n}),Nc=[0,0,0,1],Bc=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],Dc={name:"shadow",dependencies:[ic],vs:Pc,fs:Ic,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 r=ic.getUniforms(n),i=Mc({viewport:n.viewport,center:r.center}),s=[],o=Lc({shadowMatrices:e.shadowMatrices,viewport:n.viewport}).slice();for(let A=0;A<e.shadowMatrices.length;A++){const e=o[A],t=e.clone().translate(new eA(n.viewport.center).negate());r.coordinateSystem===Ul.LNGLAT&&r.projectionMode===jl.WEB_MERCATOR?(o[A]=t,s[A]=i):(o[A]=e.clone().multiplyRight(Bc),s[A]=t.transform(i))}const a={drawShadowMap:Boolean(e.drawToShadowMap),useShadowMap:!!e.shadowMaps&&e.shadowMaps.length>0,color:e.shadowColor||Nc,lightId:e.shadowLightId||0,lightCount:e.shadowMatrices.length,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};for(let A=0;A<o.length;A++)a[`viewProjectionMatrix${A}`]=o[A],a[`projectCenter${A}`]=s[A];for(let A=0;A<2;A++)a[`shadow_uShadowMap${A}`]=e.shadowMaps&&e.shadowMaps[A]||e.dummyShadowMap;return a},uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4<f32>",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4<f32>",viewProjectionMatrix1:"mat4x4<f32>",projectCenter0:"vec4<f32>",projectCenter1:"vec4<f32>"}},Oc={...xA,defaultUniforms:{...xA.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 "}}},Fc=[UA],Uc=["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)"],jc=[];function Gc(e){const t=Ir.getDefaultShaderAssembler();for(const r of Fc)t.addDefaultModule(r);t._hookFunctions.length=0;const n="glsl"===e?Uc:jc;for(const r of n)t.addShaderHook(r);return t}const zc=[255,255,255],Vc=1;let Wc=0;class Hc{constructor(e={}){this.type="ambient";const{color:t=zc}=e,{intensity:n=Vc}=e;this.id=e.id||"ambient-"+Wc++,this.color=t,this.intensity=n}}const $c=[255,255,255],Xc=1,Qc=[0,0,-1];let Yc=0;class qc{constructor(e={}){this.type="directional";const{color:t=$c}=e,{intensity:n=Xc}=e,{direction:r=Qc}=e,{_shadow:i=!1}=e;this.id=e.id||"directional-"+Yc++,this.color=t,this.intensity=n,this.type="directional",this.direction=new eA(r).normalize().toArray(),this.shadow=i}getProjectedLight(e){return this}}class Kc{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 Zc extends Kc{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){const[t,n]=this.device.canvasContext.getDrawingBufferSize(),r=e.clearCanvas??!0,i=e.clearColor??(!!r&&[0,0,0,0]),s=!!r&&1,o=!!r&&0,a=e.colorMask??15,A={viewport:[0,0,t,n]};e.colorMask&&(A.colorMask=a),e.scissorRect&&(A.scissorRect=e.scissorRect);const l=this.device.beginRenderPass({framebuffer:e.target,parameters:A,clearColor:i,clearDepth:s,clearStencil:o});try{return this._drawLayers(l,e)}finally{l.end(),this.device.submit()}}_drawLayers(e,t){const{target:n,shaderModuleProps:r,viewports:i,views:s,onViewportActive:o,clearStack:a=!0}=t;t.pass=t.pass||"unknown",a&&(this._lastRenderIndex=-1);const A=[];for(const l of i){const i=s&&s[l.id];null==o||o(l);const a=this._getDrawLayerParams(l,t),c=l.subViewports||[l];for(const s of c){const o=this._drawLayersInViewport(e,{target:n,shaderModuleProps:r,viewport:s,view:i,pass:t.pass,layers:t.layers},a);A.push(o)}}return A}_getDrawLayerParams(e,{layers:t,pass:n,isPicking:r=!1,layerFilter:i,cullRect:s,effects:o,shaderModuleProps:a},A=!1){var l;const c=[],u=Jc(this._lastRenderIndex+1),h={layer:t[0],viewport:e,isPicking:r,renderPass:n,cullRect:s},d={};for(let f=0;f<t.length;f++){const r=t[f],s=this._shouldDrawLayer(r,h,i,d),p={shouldDrawLayer:s};s&&!A&&(p.shouldDrawLayer=!0,p.layerRenderIndex=u(r,s),p.shaderModuleProps=this._getShaderModuleProps(r,o,n,a),p.layerParameters={...null==(l=r.context.deck)?void 0:l.props.parameters,...this.getLayerParameters(r,f,e)}),c[f]=p}return c}_drawLayersInViewport(e,{layers:t,shaderModuleProps:n,pass:r,target:i,viewport:s,view:o},a){const A=function(e,{shaderModuleProps:t,target:n,viewport:r}){var i;const s=(null==(i=null==t?void 0:t.project)?void 0:i.devicePixelRatio)??e.canvasContext.cssToDeviceRatio(),[,o]=e.canvasContext.getDrawingBufferSize(),a=n?n.height:o,A=r;return[A.x*s,a-(A.y+A.height)*s,A.width*s,A.height*s]}(this.device,{shaderModuleProps:n,target:i,viewport:s});if(o){const{clear:e,clearColor:t,clearDepth:n,clearStencil:r}=o.props;if(e){let e=[0,0,0,0],s=1,o=0;Array.isArray(t)?e=[...t.slice(0,3),t[3]||255].map(e=>e/255):!1===t&&(e=!1),void 0!==n&&(s=n),void 0!==r&&(o=r),this.device.beginRenderPass({framebuffer:i,parameters:{viewport:A,scissorRect:A},clearColor:e,clearDepth:s,clearStencil:o}).end()}}const l={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:A});for(let u=0;u<t.length;u++){const n=t[u],i=a[u],{shouldDrawLayer:o}=i;if(o&&n.props.pickable&&l.pickableCount++,n.isComposite&&l.compositeCount++,n.isDrawable&&i.shouldDrawLayer){const{layerRenderIndex:t,shaderModuleProps:o,layerParameters:a}=i;l.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,t),o.project&&(o.project.viewport=s),n.context.renderPass=e;try{n._drawLayer({renderPass:e,shaderModuleProps:o,uniforms:{layerIndex:t},parameters:a})}catch(c){n.raiseError(c,`drawing ${n} to ${r}`)}}}return l}shouldDrawLayer(e){return!0}getShaderModuleProps(e,t,n){return null}getLayerParameters(e,t,n){return e.props.parameters}_shouldDrawLayer(e,t,n,r){if(!e.props.visible||!this.shouldDrawLayer(e))return!1;t.layer=e;let i=e.parent;for(;i;){if(!i.props.visible||!i.filterSubLayer(t))return!1;t.layer=i,i=i.parent}if(n){const e=t.layer.id;if(e in r||(r[e]=n(t)),!r[e])return!1}return e.activateViewport(t.viewport),!0}_getShaderModuleProps(e,t,n,r){var i,s;const o=this.device.canvasContext.cssToDeviceRatio(),a=(null==(i=e.internalState)?void 0:i.propsInTransition)||e.props,A={layer:a,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:o,modelMatrix:a.modelMatrix,coordinateSystem:a.coordinateSystem,coordinateOrigin:a.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(t)for(const l of t)eu(A,null==(s=l.getShaderModuleProps)?void 0:s.call(l,e,A));return eu(A,this.getShaderModuleProps(e,t,A),r)}}function Jc(e=0,t={}){const n={},r=(i,s)=>{const o=i.props._offset,a=i.id,A=i.parent&&i.parent.id;let l;if(A&&!(A in t)&&r(i.parent,!1),A in n){const e=n[A]=n[A]||Jc(t[A],t);l=e(i,s),n[a]=e}else Number.isFinite(o)?(l=o+(t[A]||0),n[a]=null):l=e;return s&&l>=e&&(e=l+1),t[a]=l,l};return r}function eu(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 tu extends Zc{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"}}),r=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[n],depthStencilAttachment:r})}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(),r=e.viewports[0],i=r.width*n,s=r.height*n;i===t.width&&s===t.height||t.resize({width:i,height:s}),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 nu={color:[255,255,255],intensity:1},ru=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],iu=[0,0,0,200/255];class su{constructor(e={}){this.id="lighting-effect",this.shadowColor=iu,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(Dc),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:r,views:i}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let s=0;s<this.shadowPasses.length;s++)this.shadowPasses[s].render({layers:e,layerFilter:t,viewports:n,onViewportActive:r,views:i,shaderModuleProps:{shadow:{shadowLightId:s,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,t){const n=this.shadow?{project:t.project,shadowMaps:this.shadowPasses.map(e=>e.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},r={enabled:!0,ambientLight:this.ambientLight,directionalLights:this.directionalLights.map(t=>t.getProjectedLight({layer:e})),pointLights:this.pointLights.map(t=>t.getProjectedLight({layer:e}))},i=e.props.material;return{shadow:n,lighting:r,phongMaterial:i,gouraudMaterial:i}}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(Dc))}_calculateMatrices(){const e=[];for(const t of this.directionalLights){const n=(new mA).lookAt({eye:new eA(t.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let t=0;t<this.directionalLights.length;t++){const n=new tu(e);this.shadowPasses[t]=n}}_applyDefaultLights(){const{ambientLight:e,pointLights:t,directionalLights:n}=this;e||0!==t.length||0!==n.length||(this.ambientLight=new Hc(nu),this.directionalLights.push(new qc(ru[0]),new qc(ru[1])))}}const ou=new class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,t,{size:n=1,type:r,padding:i=0,copy:s=!1,initialize:o=!1,maxCount:a}){const A=r||e&&e.constructor||Float32Array,l=t*n+i;if(ArrayBuffer.isView(e)){if(l<=e.length)return e;if(l*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new A(e.buffer,0,l)}let c=1/0;a&&(c=a*n+i);const u=this._allocate(A,l,o,c);return e&&s?u.set(e):o||u.fill(0,0,4),this._release(e),u}release(e){this._release(e)}_allocate(e,t,n,r){let i=Math.max(Math.ceil(t*this.opts.overAlloc),1);i>r&&(i=r);const s=this._pool,o=e.BYTES_PER_ELEMENT*i,a=s.findIndex(e=>e.byteLength>=o);if(a>=0){const t=new e(s.splice(a,1)[0],0,i);return n&&t.fill(0),t}return new e(i)}_release(e){if(!ArrayBuffer.isView(e))return;const t=this._pool,{buffer:n}=e,{byteLength:r}=n,i=t.findIndex(e=>e.byteLength>=r);i<0?t.push(n):(i>0||t.length<this.opts.poolSize)&&t.splice(i,0,n),t.length>this.opts.poolSize&&t.shift()}},au=new eA;function Au(e,t,n,r){au.set(e,t,n);const i=au.len();return{distance:r/i,normal:new eA(-e/i,-t/i,-n/i)}}function lu(e){return e-Math.fround(e)}let cu;function uu(e,t){const{size:n=1,startIndex:r=0}=t,i=void 0!==t.endIndex?t.endIndex:e.length,s=(i-r)/n;cu=ou.allocate(cu,s,{type:Float32Array,size:2*n});let o=r,a=0;for(;o<i;){for(let t=0;t<n;t++){const r=e[o++];cu[a+t]=r,cu[a+t+n]=lu(r)}a+=2*n}return cu.subarray(0,s*n*2)}function hu(e){let t=null,n=!1;for(const r of e)r&&(t?(n||(t=[[t[0][0],t[0][1]],[t[1][0],t[1][1]]],n=!0),t[0][0]=Math.min(t[0][0],r[0][0]),t[0][1]=Math.min(t[0][1],r[0][1]),t[1][0]=Math.max(t[1][0],r[1][0]),t[1][1]=Math.max(t[1][1],r[1][1])):t=r);return t}const du=Math.PI/180,fu=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],pu=[0,0,0],gu={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};class mu{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||"viewport",this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||gu,this.focalDistance=e.focalDistance||1,this.position=e.position||pu,this.modelMatrix=e.modelMatrix||null;const{longitude:t,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(t),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?jl.WEB_MERCATOR:jl.WEB_MERCATOR_AUTO_OFFSET:jl.IDENTITY}equals(e){return e instanceof mu&&(this===e||e.width===this.width&&e.height===this.height&&e.scale===this.scale&&Fa(e.projectionMatrix,this.projectionMatrix)&&Fa(e.viewMatrix,this.viewMatrix))}project(e,{topLeft:t=!0}={}){const n=Tc(this.projectPosition(e),this.pixelProjectionMatrix),[r,i]=n,s=t?i:this.height-i;return 2===e.length?[r,s]:[r,s,n[2]]}unproject(e,{topLeft:t=!0,targetZ:n}={}){const[r,i,s]=e,o=t?i:this.height-i,a=n&&n*this.distanceScales.unitsPerMeter[2],A=Sc([r,o,s],this.pixelUnprojectionMatrix,a),[l,c,u]=this.unprojectPosition(A);return Number.isFinite(s)?[l,c,u]:Number.isFinite(n)?[l,c,n]:[l,c]}projectPosition(e){const[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(e){const[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(e){if(this.isGeospatial){const t=_c(e);return t[1]=Da(t[1],-318,830),t}return e}unprojectFlat(e){return this.isGeospatial?bc(e):e}getBounds(e={}){const t={targetZ:e.z||0},n=this.unproject([0,0],t),r=this.unproject([this.width,0],t),i=this.unproject([0,this.height],t),s=this.unproject([this.width,this.height],t);return[Math.min(n[0],r[0],i[0],s[0]),Math.min(n[1],r[1],i[1],s[1]),Math.max(n[0],r[0],i[0],s[0]),Math.max(n[1],r[1],i[1],s[1])]}getDistanceScales(e){return e&&this.isGeospatial?yc({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:t,width:n=1,height:r=1}){return e<this.x+this.width&&this.x<e+n&&t<this.y+this.height&&this.y<t+r}getFrustumPlanes(){return this._frustumPlanes.near||Object.assign(this._frustumPlanes,{left:Au((e=this.viewProjectionMatrix)[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:Au(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:Au(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:Au(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:Au(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:Au(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}),this._frustumPlanes;var e}panByPosition(e,t){return null}_initProps(e){const t=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=function(e){const{latitude:t}=e;cc(Number.isFinite(t));const n=Math.cos(t*dc);return lc(4003e4*n)-9}({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||yc({latitude:n,longitude:t}));const r=Math.pow(2,this.zoom);this.scale=r;const{position:i,modelMatrix:s}=e;let o=pu;if(i&&(o=s?new mA(s).transformAsVector(i,[]):i),this.isGeospatial){const e=this.projectPosition([t,n,0]);this.center=new eA(o).scale(this.distanceScales.unitsPerMeter).add(e)}else this.center=this.projectPosition(o)}_initMatrices(e){const{viewMatrix:t=fu,projectionMatrix:n=null,orthographic:r=!1,fovyRadians:i,fovy:s=75,near:o=.1,far:a=1e3,padding:A=null,focalDistance:l=1}=e;this.viewMatrixUncentered=t,this.viewMatrix=(new mA).multiplyRight(t).translate(new eA(this.center).negate()),this.projectionMatrix=n||function({width:e,height:t,orthographic:n,fovyRadians:r,focalDistance:i,padding:s,near:o,far:a}){const A=e/t,l=n?(new mA).orthographic({fovy:r,aspect:A,focalDistance:i,near:o,far:a}):(new mA).perspective({fovy:r,aspect:A,near:o,far:a});if(s){const{left:n=0,right:r=0,top:i=0,bottom:o=0}=s,a=Da((n+e-r)/2,0,e)-e/2,A=Da((i+t-o)/2,0,t)-t/2;l[8]-=2*a/e,l[9]+=2*A/t}return l}({width:this.width,height:this.height,orthographic:r,fovyRadians:i||s*du,focalDistance:l,padding:A,near:o,far:a});const c=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];var u;rA(c,c,this.projectionMatrix),rA(c,c,this.viewMatrix),this.viewProjectionMatrix=c,this.viewMatrixInverse=nA([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=[(u=this.viewMatrixInverse)[12],u[13],u[14]];const h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],d=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];sA(h,h,[this.width/2,-this.height/2,1]),iA(h,h,[1,-1,0]),rA(d,h,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=nA([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||Hn.warn("Pixel project matrix not invertible")()}}mu.displayName="Viewport";class _u extends mu{constructor(e={}){const{latitude:t=0,longitude:n=0,zoom:r=0,pitch:i=0,bearing:s=0,nearZMultiplier:o=.1,farZMultiplier:a=1.01,nearZ:A,farZ:l,orthographic:c=!1,projectionMatrix:u,repeat:h=!1,worldOffset:d=0,position:f,padding:p,legacyMeterSizes:g=!1}=e;let{width:m,height:_,altitude:b=1.5}=e;const v=Math.pow(2,r);let y;m=m||1,_=_||1;let w=null;if(u)b=u[5]/2,y=xc(b);else{let n;if(e.fovy?(y=e.fovy,b=Ec(y)):y=xc(b),p){const{top:e=0,bottom:t=0}=p;n=[0,Da((e+_-t)/2,0,_)-_/2]}w=function(e){const{width:t,height:n,altitude:r,pitch:i=0,offset:s,center:o,scale:a,nearZMultiplier:A=1,farZMultiplier:l=1}=e;let{fovy:c=xc(mc)}=e;void 0!==r&&(c=xc(r));const u=c*dc,h=i*dc,d=Ec(c);let f=d;o&&(f+=o[2]*a/Math.cos(h)/n);const p=u*(.5+(s?s[1]:0)/n),g=Math.sin(p)*f/Math.sin(Ac(Math.PI/2-h-p,.01,Math.PI-.01)),m=Math.sin(h)*g+f,_=10*f;return{fov:u,aspect:t/n,focalDistance:d,near:A,far:Math.min(m*l,_)}}({width:m,height:_,scale:v,center:f&&[0,0,f[2]*vc(t)],offset:n,pitch:i,fovy:y,nearZMultiplier:o,farZMultiplier:a}),Number.isFinite(A)&&(w.near=A),Number.isFinite(l)&&(w.far=l)}let x=function(e){const{height:t,pitch:n,bearing:r,altitude:i,scale:s,center:o}=e,a=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];iA(a,a,[0,0,-i]),oA(a,a,-n*dc),aA(a,a,r*dc);const A=s/t;var l,c;return sA(a,a,[A,A,A]),o&&iA(a,a,((l=[])[0]=-(c=o)[0],l[1]=-c[1],l[2]=-c[2],l)),a}({height:_,pitch:i,bearing:s,scale:v,altitude:b});d&&(x=(new mA).translate([512*d,0,0]).multiplyLeft(x)),super({...e,width:m,height:_,viewMatrix:x,longitude:n,latitude:t,zoom:r,...w,fovy:y,focalDistance:b}),this.latitude=t,this.longitude=n,this.zoom=r,this.pitch=i,this.bearing=s,this.altitude=b,this.fovy=y,this.orthographic=c,this._subViewports=h?[]:null,this._pseudoMeters=g,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){const e=this.getBounds(),t=Math.floor((e[0]+180)/360),n=Math.ceil((e[2]-180)/360);for(let r=t;r<=n;r++){const e=r?new _u({...this,worldOffset:r}):this;this._subViewports.push(e)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);const[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*vc(e[1])]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);const[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)/vc(n)]}addMetersToLngLat(e,t){return wc(e,t)}panByPosition(e,t){const n=Sc(t,this.pixelUnprojectionMatrix),r=$a([],this.projectFlat(e),((i=[])[0]=-(s=n)[0],i[1]=-s[1],i));var i,s;const o=$a([],this.center,r),[a,A]=this.unprojectFlat(o);return{longitude:a,latitude:A}}getBounds(e={}){const t=function(e,t=0){const{width:n,height:r,unproject:i}=e,s={targetZ:t},o=i([0,r],s),a=i([n,r],s);let A,l;return(e.fovy?.5*e.fovy*Cc:Math.atan(.5/e.altitude))>(90-e.pitch)*Cc-.01?(A=kc(e,0,t),l=kc(e,n,t)):(A=i([0,0],s),l=i([n,0],s)),[o,a,l,A]}(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:r}=this,{longitude:i,latitude:s,zoom:o}=function(e){const{width:t,height:n,bounds:r,minExtent:i=0,maxZoom:s=24,offset:o=[0,0]}=e,[[a,A],[l,c]]=r,u=function(e=0){return"number"==typeof e?{top:e,bottom:e,left:e,right:e}:(cc(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}(e.padding),h=_c([a,Ac(c,-85.051129,gc)]),d=_c([l,Ac(A,-85.051129,gc)]),f=[Math.max(Math.abs(d[0]-h[0]),i),Math.max(Math.abs(d[1]-h[1]),i)],p=[t-u.left-u.right-2*Math.abs(o[0]),n-u.top-u.bottom-2*Math.abs(o[1])];cc(p[0]>0&&p[1]>0);const g=p[0]/f[0],m=p[1]/f[1],_=(u.right-u.left)/2/g,b=(u.top-u.bottom)/2/m,v=bc([(d[0]+h[0])/2+_,(d[1]+h[1])/2+b]),y=Math.min(s,lc(Math.abs(Math.min(g,m))));return cc(Number.isFinite(y)),{longitude:v[0],latitude:v[1],zoom:y}}({width:n,height:r,bounds:e,...t});return new _u({width:n,height:r,longitude:i,latitude:s,zoom:o})}}_u.displayName="WebMercatorViewport";const bu=[0,0,0];function vu(e,t,n=!1){const r=t.projectPosition(e);if(n&&t instanceof _u){const[n,i,s=0]=e,o=t.getDistanceScales([n,i]);r[2]=s*o.unitsPerMeter[2]}return r}function yu(e,{viewport:t,modelMatrix:n,coordinateSystem:r,coordinateOrigin:i,offsetMode:s}){let[o,a,A=0]=e;switch(n&&([o,a,A]=lA([],[o,a,A,1],n)),r){case Ul.LNGLAT:return vu([o,a,A],t,s);case Ul.LNGLAT_OFFSETS:return vu([o+i[0],a+i[1],A+(i[2]||0)],t,s);case Ul.METER_OFFSETS:return vu(wc(i,[o,a,A]),t,s);default:return t.isGeospatial?[o+i[0],a+i[1],A+i[2]]:t.projectPosition([o,a,A])}}let wu=1,xu=1;class Eu{constructor(){r(this,"time",0),r(this,"channels",new Map),r(this,"animations",new Map),r(this,"playing",!1),r(this,"lastEngineTime",-1)}addChannel(e){const{delay:t=0,duration:n=Number.POSITIVE_INFINITY,rate:r=1,repeat:i=1}=e,s=wu++,o={time:0,delay:t,duration:n,rate:r,repeat:i};return this._setChannelTime(o,this.time),this.channels.set(s,o),s}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 r of t)this._setChannelTime(r,this.time);const n=this.animations.values();for(const r of n){const{animation:e,channel:t}=r;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=xu++;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 Tu=0;const Su=class e{constructor(t){if(r(this,"device",null),r(this,"canvas",null),r(this,"props"),r(this,"animationProps",null),r(this,"timeline",null),r(this,"stats"),r(this,"cpuTime"),r(this,"gpuTime"),r(this,"frameRate"),r(this,"display"),r(this,"needsRedraw","initialized"),r(this,"_initialized",!1),r(this,"_running",!1),r(this,"_animationFrameId",null),r(this,"_nextFramePromise",null),r(this,"_resolveNextFrame",null),r(this,"_cpuStartTime",0),r(this,"_error",null),this.props={...e.defaultAnimationLoopProps,...t},!(t=this.props).device)throw new Error("No device provided");this.stats=t.stats||new Mt({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,r=t.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:t,canvas:n,useDevicePixels:r,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,r]=(null==(e=this.device)?void 0:e.getDefaultCanvasContext().getDevicePixelSize())||[1,1];let i=1;const s=null==(t=this.device)?void 0:t.getDefaultCanvasContext().canvas;return s&&s.clientHeight?i=s.clientWidth/s.clientHeight:n>0&&r>0&&(i=n/r),{width:n,height:r,aspect:i}}_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}};r(Su,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>{},stats:mi.stats.get("animation-loop-"+Tu++),autoResizeViewport:!1});let Cu=Su;const ku={};function Ru(e="id"){return ku[e]=ku[e]||1,`${e}-${ku[e]++}`}class Pu{constructor(e){if(r(this,"id"),r(this,"userData",{}),r(this,"topology"),r(this,"bufferLayout",[]),r(this,"vertexCount"),r(this,"indices"),r(this,"attributes"),this.id=e.id||Ru("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&Ur.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 Iu=class e{constructor(e){r(this,"device"),r(this,"cachingEnabled"),r(this,"destroyPolicy"),r(this,"debug"),r(this,"_hashCounter",0),r(this,"_hashes",{}),r(this,"_renderPipelineCache",{}),r(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={...Gi.defaultProps,...e},r=this._renderPipelineCache,i=this._hashRenderPipeline(n);let s=null==(t=r[i])?void 0:t.pipeline;return s?(r[i].useCount++,this.debug&&Nr.log(3,`${this}: ${r[i].pipeline} reused, count=${r[i].useCount}, (id=${e.id})`)()):(s=this.device.createRenderPipeline({...n,id:n.id?`${n.id}-cached`:Ru("unnamed-cached")}),s.hash=i,r[i]={pipeline:s,useCount:1},this.debug&&Nr.log(3,`${this}: ${s} created, count=${r[i].useCount}`)()),s}createComputePipeline(e){var t;if(!this.cachingEnabled)return this.device.createComputePipeline(e);const n={...Hi.defaultProps,...e},r=this._computePipelineCache,i=this._hashComputePipeline(n);let s=null==(t=r[i])?void 0:t.pipeline;return s?(r[i].useCount++,this.debug&&Nr.log(3,`${this}: ${r[i].pipeline} reused, count=${r[i].useCount}, (id=${e.id})`)()):(s=this.device.createComputePipeline({...n,id:n.id?`${n.id}-cached`:void 0}),s.hash=i,r[i]={pipeline:s,useCount:1},this.debug&&Nr.log(3,`${this}: ${s} created, count=${r[i].useCount}`)()),s}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&&Nr.log(3,`${this}: ${e} released and destroyed`)()):t[n].useCount<0?(Nr.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[n].useCount=0):this.debug&&Nr.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 Hi&&(t=this._computePipelineCache),e instanceof Gi&&(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,r=this._getHash(JSON.stringify(e.bufferLayout)),{type:i}=this.device;if("webgl"===i)return`${i}/R/${t}/${n}V-BL${r}`;{const s=this._getHash(JSON.stringify(e.parameters));return`${i}/R/${t}/${n}V-T${e.topology}P${s}BL${r}`}}_getHash(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};r(Iu,"defaultProps",{...Gi.defaultProps});let Mu=Iu;const Lu=class e{constructor(e){r(this,"device"),r(this,"cachingEnabled"),r(this,"destroyPolicy"),r(this,"debug"),r(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&&Nr.log(3,`${this}: Reusing shader ${n.shader.id} count=${n.useCount}`)();else{const r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=n={shader:r,useCount:1},this.debug&&Nr.log(3,`${this}: Created new shader ${r.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&&Nr.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&&Nr.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}};r(Lu,"defaultProps",{...Di.defaultProps});let Nu=Lu,Bu=null,Du=null;function Ou(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 r=0;r<e.length;r++)if(!Ou(e[r],t[r],n-1))return!1;return!0}if(Array.isArray(t))return!1;if("object"==typeof e&&"object"==typeof t){const r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(const s of r){if(!t.hasOwnProperty(s))return!1;if(!Ou(e[s],t[s],n-1))return!1}return!0}return!1}class Fu{constructor(e){r(this,"bufferLayouts"),this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.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 r of t){const e=n.findIndex(e=>e.name===r.name);e<0?n.push(r):n[e]=r}return n}getBufferIndex(e){const t=this.bufferLayouts.findIndex(t=>t.name===e);return-1===t&&Nr.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}}function Uu(e){const t={bindings:{},uniforms:{}};return Object.keys(e).forEach(n=>{const r=e[n];var i;!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)}(i=r)&&"number"!=typeof i&&"boolean"!=typeof i?t.bindings[n]=r:t.uniforms[n]=r}),t}class ju{constructor(e,t){r(this,"options",{disableWarnings:!1}),r(this,"modules"),r(this,"moduleUniforms"),r(this,"moduleBindings"),Object.assign(this.options,t);const n=hr(Object.values(e).filter(e=>e.dependencies));for(const r of n)e[r.name]=r;Nr.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[r,i]of Object.entries(e))this._addModule(i),i.name&&r!==i.name&&!this.options.disableWarnings&&Nr.warn(`Module name: ${r} vs ${i.name}`)()}destroy(){}setProps(e){var t;for(const n of Object.keys(e)){const r=n,i=e[r]||{},s=this.modules[r];if(!s){this.options.disableWarnings||Nr.warn(`Module ${n} not found`)();continue}const o=this.moduleUniforms[r],a=this.moduleBindings[r],A=(null==(t=s.getUniforms)?void 0:t.call(s,i,o))||i,{uniforms:l,bindings:c}=Uu(A);this.moduleUniforms[r]={...o,...l},this.moduleBindings[r]={...a,...c}}}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,r]of Object.entries(this.moduleUniforms))for(const[i,s]of Object.entries(r))t[`${n}.${i}`]={type:null==(e=this.modules[n].uniformTypes)?void 0:e[i],value:String(s)};return t}_addModule(e){const t=e.name;this.moduleUniforms[t]=e.defaultUniforms||{},this.moduleBindings[t]={}}}const Gu=["+X","-X","+Y","-Y","+Z","-Z"],zu=["+X","-X","+Y","-Y","+Z","-Z"],Vu=class e{constructor(t,n){r(this,"device"),r(this,"id"),r(this,"props"),r(this,"texture"),r(this,"sampler"),r(this,"view"),r(this,"ready"),r(this,"isReady",!1),r(this,"destroyed",!1),r(this,"resolveReady",()=>{}),r(this,"rejectReady",()=>{}),this.device=t;const i=Ru("async-texture");this.props={...e.defaultProps,id:i,...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 Hu(t).then(void 0,this.rejectReady);if(this.destroyed)return;const r=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(n);if(!r)throw new Error("Texture size could not be determined");const i={...r,...e,data:void 0,mipLevels:1},s=this.device.getMipLevelCount(i.width,i.height);if(i.mipLevels="auto"===this.props.mipLevels?s:Math.min(s,this.props.mipLevels),this.texture=this.device.createTexture(i),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(),Nr.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 Ci?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&&Nr.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let r=0;r<n.length;r++){const e=n[r];this.device.isExternalImage(e)?this.texture.copyExternalImage({image:e,depth:t,mipLevel:r,flipY:!0}):this.texture.copyImageData({data:e.data,mipLevel:r})}}_setTexture3DData(e,t){var n;if("3d"!==(null==(n=this.texture)?void 0:n.props.dimension))throw new Error(this.id);for(let r=0;r<t.length;r++)this._setTexture2DData(t[r],r)}_setTextureCubeData(e,t){var n;if("cube"!==(null==(n=this.texture)?void 0:n.props.dimension))throw new Error(this.id);for(const[r,i]of Object.entries(t)){const e=zu.indexOf(r);this._setTexture2DData(i,e)}}_setTextureArrayData(e,t){var n;if("2d-array"!==(null==(n=this.texture)?void 0:n.props.dimension))throw new Error(this.id);for(let r=0;r<t.length;r++)this._setTexture2DData(t[r],r)}_setTextureCubeArrayData(e,t){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(e,t,n,r=0){Array.isArray(t)&&t.length>1&&!1!==this.props.mipmaps&&Nr.warn(`${this.id} has mipmap and multiple LODs.`)();const i=Gu.indexOf(n);this._setTexture2DData(t,i)}_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}};r(Vu,"defaultProps",{...Pi.defaultProps,data:null,mipmaps:!1});let Wu=Vu;async function Hu(e){if(e=await e,Array.isArray(e))return await Promise.all(e.map(Hu));if(e&&"object"==typeof e&&e.constructor===Object){const t=e,n=await Promise.all(Object.values(t)),r=Object.keys(t),i={};for(let e=0;e<r.length;e++)i[r[e]]=n[e];return i}return e}const $u=class e{constructor(t,n){var i,s,o,a;r(this,"device"),r(this,"id"),r(this,"source"),r(this,"vs"),r(this,"fs"),r(this,"pipelineFactory"),r(this,"shaderFactory"),r(this,"userData",{}),r(this,"parameters"),r(this,"topology"),r(this,"bufferLayout"),r(this,"isInstanced"),r(this,"instanceCount",0),r(this,"vertexCount"),r(this,"indexBuffer",null),r(this,"bufferAttributes",{}),r(this,"constantAttributes",{}),r(this,"bindings",{}),r(this,"vertexArray"),r(this,"transformFeedback",null),r(this,"pipeline"),r(this,"shaderInputs"),r(this,"_uniformStore"),r(this,"_attributeInfos",{}),r(this,"_gpuGeometry",null),r(this,"props"),r(this,"_pipelineNeedsUpdate","newly created"),r(this,"_needsRedraw","initializing"),r(this,"_destroyed",!1),r(this,"_lastDrawTimestamp",-1),r(this,"_lastLogTime",0),r(this,"_logOpen",!1),r(this,"_drawCount",0),this.props={...e.defaultProps,...n},n=this.props,this.id=n.id||Ru("model"),this.device=t,Object.assign(this.userData,n.userData);const A=Object.fromEntries((null==(i=this.props.modules)?void 0:i.map(e=>[e.name,e]))||[]),l=n.shaderInputs||new ju(A,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(l);const c=function(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}(t),u=((null==(s=this.props.modules)?void 0:s.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:c,...this.props,modules:u});this.source=e,this._getModuleUniforms=t,(a=this.props).shaderLayout||(a.shaderLayout=function(e){var t;const n={attributes:[],bindings:[]};let r;try{r=function(e){try{return new Ia(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 Nr.error(o.message)(),n}for(const a of r.uniforms){const e=[];for(const n of(null==(t=a.type)?void 0:t.members)||[])e.push({name:n.name,type:Ma(n.type)});n.bindings.push({type:"uniform",name:a.name,group:a.group,location:a.binding,members:e})}for(const a of r.textures)n.bindings.push({type:"texture",name:a.name,group:a.group,location:a.binding});for(const a of r.samplers)n.bindings.push({type:"sampler",name:a.name,group:a.group,location:a.binding});const i=r.entry.vertex[0],s=(null==i?void 0:i.inputs.length)||0;for(let a=0;a<s;a++){const e=i.inputs[a];if("location"===e.locationType){const t=Ma(e.type);n.attributes.push({name:e.name,location:Number(e.location),type:t})}}return n}(this.source))}else{const{vs:e,fs:t,getUniforms:n}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:c,...this.props,modules:u});this.vs=e,this.fs=t,this._getModuleUniforms=n}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,n.geometry&&this.setGeometry(n.geometry),this.pipelineFactory=n.pipelineFactory||Mu.getDefaultPipelineFactory(this.device),this.shaderFactory=n.shaderFactory||Nu.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in n&&(this.isInstanced=n.isInstanced),n.instanceCount&&this.setInstanceCount(n.instanceCount),n.vertexCount&&this.setVertexCount(n.vertexCount),n.indexBuffer&&this.setIndexBuffer(n.indexBuffer),n.attributes&&this.setAttributes(n.attributes),n.constantAttributes&&this.setConstantAttributes(n.constantAttributes),n.bindings&&this.setBindings(n.bindings),n.transformFeedback&&(this.transformFeedback=n.transformFeedback),Object.seal(this)}get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}destroy(){var e;this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),null==(e=this._gpuGeometry)||e.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._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 Nr.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:r}=this.vertexArray,i=r?r.byteLength/("uint32"===r.indexType?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:i,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 Pu)return t;const n=function(e,t){if(!t.indices)return;const n=t.indices.value;return e.createBuffer({usage:Ur.INDEX,data:n})}(e,t),{attributes:r,bufferLayout:i}=function(e,t){const n=[],r={};for(const[i,s]of Object.entries(t.attributes)){let t=i;switch(i){case"POSITION":t="positions";break;case"NORMAL":t="normals";break;case"TEXCOORD_0":t="texCoords";break;case"COLOR_0":t="colors"}if(s){r[t]=e.createBuffer({data:s.value,id:`${i}-buffer`});const{value:o,size:a,normalized:A}=s;n.push({name:t,format:$r(o,a,A)})}}return{attributes:r,bufferLayout:n,vertexCount:t._calculateVertexCount(t.attributes,t.indices)}}(e,t);return new Pu({topology:t.topology||"triangle-list",bufferLayout:i,vertexCount:t.vertexCount,indices:n,attributes:r})}(this.device,e);if(n){this.setTopology(n.topology||"triangle-list");const e=new Fu(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 Fu(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){Ou(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 ds(this.shaderInputs.modules);for(const[t,n]of Object.entries(this.shaderInputs.modules))if(Qu(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&&Nr.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])),r=t.slice();return r.sort((e,t)=>{const r=e.attributes?e.attributes.map(e=>e.attribute):[e.name],i=t.attributes?t.attributes.map(e=>e.attribute):[t.name];return Math.min(...r.map(e=>n[e]))-Math.min(...i.map(e=>n[e]))}),r}(this.pipeline.shaderLayout,this.bufferLayout);const r=new Fu(this.bufferLayout);for(const[i,s]of Object.entries(e)){const e=r.getBufferLayout(i);if(!e){n||Nr.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}const t=r.getAttributeNamesForBuffer(e);let o=!1;for(const n of t){const e=this._attributeInfos[n];if(e){const t="webgpu"===this.device.type?r.getBufferIndex(e.bufferName):e.location;this.vertexArray.setBuffer(t,s),o=!0}}o||n||Nr.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[n,r]of Object.entries(e)){const e=this._attributeInfos[n];e?this.vertexArray.setConstantWebGL(e.location,r):((null==t?void 0:t.disableWarnings)??this.props.disableWarnings)||Nr.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 Wu&&!e.isReady)return e.id;return!1}_getBindings(){const e={};for(const[t,n]of Object.entries(this.bindings))n instanceof Wu?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 Mi?e=Math.max(e,t.texture.updateTimestamp):t instanceof Ur||t instanceof Pi?e=Math.max(e,t.updateTimestamp):t instanceof Wu?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof Ci||(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&&(Nr.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 r=null;this.source?r=n:this.fs&&(r=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:r}),this._attributeInfos=es(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_logDrawCallStart(){const e=Nr.level>3?0:1e4;Nr.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,Nr.group(2,`>>> DRAWING MODEL ${this.id}`,{collapsed:Nr.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=function(e){var t;const n={},r="Values";if(0===e.attributes.length&&!(null==(t=e.varyings)?void 0:t.length))return{"No attributes or varyings":{[r]:"N/A"}};for(const i of e.attributes)i&&(n[`in ${i.location} ${i.name}: ${i.type}`]={[r]:i.stepMode||"vertex"});for(const i of e.varyings||[])n[`out ${i.location} ${i.name}`]={[r]:JSON.stringify(i)};return n}(this.pipeline.shaderLayout,this.id);Nr.table(2,e)();const t=this.shaderInputs.getDebugTable();Nr.table(2,t)();const n=this._getAttributeDebugTable();Nr.table(2,this._attributeInfos)(),Nr.table(2,n)(),Nr.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:r,top:i="0",left:s="0",rgbaScale:o=1}){Bu||(Bu=document.createElement("canvas"),Bu.id=t,Bu.title=t,Bu.style.zIndex="100",Bu.style.position="absolute",Bu.style.top=i,Bu.style.left=s,Bu.style.border="blue 5px solid",Bu.style.transform="scaleY(-1)",document.body.appendChild(Bu),Du=Bu.getContext("2d")),Bu.width===e.width&&Bu.height===e.height||(Bu.width=e.width/2,Bu.height=e.height/2,Bu.style.width="400px",Bu.style.height="400px");const a=e.device.readPixelsToArrayWebGL(e),A=null==Du?void 0:Du.createImageData(e.width,e.height);if(A){const e=0;for(let t=0;t<a.length;t+=4)A.data[e+t+0]=a[t+0]*o,A.data[e+t+1]=a[t+1]*o,A.data[e+t+2]=a[t+2]*o,A.data[e+t+3]=r?255:a[t+3]*o;null==Du||Du.putImageData(A,0,0)}}(n,{id:n.id,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[t,n]of Object.entries(this._attributeInfos)){const r=this.vertexArray.attributes[n.location];e[n.location]={name:t,type:n.shaderType,values:r?this._getBufferOrConstantValues(r,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:t}=this.vertexArray,n="uint32"===t.indexType?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,t){const n=Vr(t);return(e instanceof Ur?new n(e.debugData):e).toString()}};r($u,"defaultProps",{...Gi.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Ir.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});let Xu=$u;function Qu(e){return Boolean(e.uniformTypes&&!function(e){for(const t in e)return!1;return!0}(e.uniformTypes))}const Yu=class e{constructor(t,n=e.defaultProps){if(r(this,"device"),r(this,"model"),r(this,"transformFeedback"),!e.isSupported(t))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=t,this.model=new Xu(this.device,{id:n.id||"buffer-transform-model",fs:n.fs||Mr(),topology:n.topology||"point-list",varyings:n.outputs||n.varyings,...n}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:n.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}static isSupported(e){var t;return"webgl"===(null==(t=null==e?void 0:e.info)?void 0:t.type)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){(null==e?void 0:e.inputBuffers)&&this.model.setAttributes(e.inputBuffers),(null==e?void 0:e.outputBuffers)&&this.transformFeedback.setBuffers(e.outputBuffers);const t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){const t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof Ur)return t.readAsync();const{buffer:n,byteOffset:r=0,byteLength:i=n.byteLength}=t;return n.readAsync(r,i)}};r(Yu,"defaultProps",{...Xu.defaultProps,outputs:void 0,feedbackBuffers:void 0});let qu=Yu;class Ku{constructor(e){r(this,"id"),r(this,"topology"),r(this,"vertexCount"),r(this,"indices"),r(this,"attributes"),r(this,"userData",{});const{attributes:t={},indices:n=null,vertexCount:i=null}=e;this.id=e.id||Ru("geometry"),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(const[r,s]of Object.entries(t)){const e=ArrayBuffer.isView(s)?{value:s}:s;if(!ArrayBuffer.isView(e.value))throw new Error(`${this._print(r)}: must be typed array or object with value as typed array`);if("POSITION"!==r&&"positions"!==r||e.size||(e.size=3),"indices"===r){if(this.indices)throw new Error("Multiple indices detected");this.indices=e}else this.attributes[r]=e}this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let n=1/0;for(const r of Object.values(e)){const{value:e,size:t,constant:i}=r;!i&&e&&void 0!==t&&t>=1&&(n=Math.min(n,e.length/t))}return n}}const Zu={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"};class Ju extends Zc{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:r,onViewportActive:i,pickingFBO:s,deviceRect:{x:o,y:a,width:A,height:l},cullRect:c,effects:u,pass:h="picking",pickZ:d,shaderModuleProps:f}){this.pickZ=d;const p=this._resetColorEncoder(d),g=[o,a,A,l],m=super.render({target:s,layers:e,layerFilter:t,views:n,viewports:r,onViewportActive:i,cullRect:c,effects:null==u?void 0:u.filter(e=>e.useInPicking),pass:h,isPicking:!0,shaderModuleProps:f,clearColor:[0,0,0,0],colorMask:15,scissorRect:g});return this._colorEncoderState=null,{decodePickingColor:p&&eh.bind(null,p),stats:m}}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 r={...e.props.parameters},{pickable:i,operation:s}=e.props;return!this._colorEncoderState||s.includes("terrain")?r.blend=!1:i&&s.includes("draw")&&(Object.assign(r,Zu),r.blend=!0,r.blendColor=function(e,t,n){const{byLayer:r,byAlpha:i}=e;let s,o=r.get(t);return o?(o.viewports.push(n),s=o.a):(s=r.size+1,s<=255?(o={a:s,layer:t,viewports:[n]},r.set(t,o),i[s]=o):(Hn.warn("Too many pickable layers, only picking the first 255")(),s=0)),[0,0,0,s/255]}(this._colorEncoderState,e,n)),r}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function eh(e,t){const n=e.byAlpha[t[3]];return n&&{pickedLayer:n.layer,pickedViewports:n.viewports,pickedObjectIndex:n.layer.decodePickingColor(t)}}const th=Symbol.for("component"),nh=Symbol.for("propTypes"),rh=Symbol.for("deprecatedProps"),ih=Symbol.for("asyncPropDefaults"),sh=Symbol.for("asyncPropOriginal"),oh=Symbol.for("asyncPropResolved");function ah(e,t=()=>!0){return Array.isArray(e)?Ah(e,t,[]):t(e)?[e]:[]}function Ah(e,t,n){let r=-1;for(;++r<e.length;){const i=e[r];Array.isArray(i)?Ah(i,t,n):t(i)&&n.push(i)}return n}function lh({target:e,source:t,start:n=0,count:r=1}){const i=t.length,s=r*i;let o=0;for(let a=n;o<i;o++)e[a++]=t[o];for(;o<s;)o<s-o?(e.copyWithin(n+o,n,n+o),o*=2):(e.copyWithin(n+o,n,n+s-o),o=s);return e}class ch{constructor(e,t,n){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=n,this.setData(t)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}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 r=e;"string"==typeof e&&(r=Cn(e)),r instanceof Promise?(this.isLoaded=!1,this._loader=r.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 i of this._subscribers)i.onChange(this.getData())}}class uh{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:r=!0}){let i=this._resources[e];i?i.setData(t,n):(i=new ch(e,t,this._context),this._resources[e]=i),i.persistent=r}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],r=this._resources[n.resourceId];r&&r.unsubscribe(n)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:n,requestId:r="default"}){const{_resources:i,protocol:s}=this;e.startsWith(s)&&(i[e=e.replace(s,"")]||this.add({resourceId:e,data:null,persistent:!1}));const o=i[e];if(this._track(n,r,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,r){const i=this._consumers,s=i[e]=i[e]||{};let o=s[t];const a=o&&o.resourceId&&this._resources[o.resourceId];a&&(a.unsubscribe(o),this.prune()),n&&(o?(o.onChange=r,o.resourceId=n.id):o={onChange:r,resourceId:n.id},s[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 hh{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=>{Qn("layerManager.activateViewport",this,e),e&&(this.context.viewport=e)};const{deck:r,stats:i,viewport:s,timeline:o}=t||{};this.layers=[],this.resourceManager=new uh({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:null==e?void 0:e.gl,deck:r,shaderAssembler:Gc((null==(n=null==e?void 0:e.info)?void 0:n.shadingLanguage)||"glsl"),defaultShaderModules:[OA],renderPass:void 0,stats:i||new Mt({id:"deck.gl"}),viewport:s||new mu({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Eu,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 r=n.getNeedsRedraw(e);t=t||r}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){Qn("layerManager.setLayers",this,t,e),this._lastRenderedLayers=e;const n=ah(e,Boolean);for(const r of n)r.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 s of e)n[s.id]?Hn.warn(`Multiple old layers with same id ${s.id}`)():n[s.id]=s;if(this._defaultShaderModulesChanged){for(const t of e)t.setNeedsUpdate(),t.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}const r=[];this._updateSublayersRecursively(t,n,r),this._finalizeOldLayers(n);let i=!1;for(const s of r)if(s.hasUniformTransition()){i=`Uniform transition in ${s}`;break}this._needsUpdate=i,this.layers=r}_updateSublayersRecursively(e,t,n){for(const i of e){i.context=this.context;const e=t[i.id];null===e&&Hn.warn(`Multiple new layers with same id ${i.id}`)(),t[i.id]=null;let s=null;try{this._debug&&e!==i&&i.validateProps(),e?(this._transferLayerState(e,i),this._updateLayer(i)):this._initializeLayer(i),n.push(i),s=i.isComposite?i.getSubLayers():null}catch(r){this._handleError("matching",r,i)}s&&this._updateSublayersRecursively(s,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 dh(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 r=0;r<e.length;r++)if(!dh(e[r],t[r],n-1))return!1;return!0}if(Array.isArray(t))return!1;if("object"==typeof e&&"object"==typeof t){const r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(const s of r){if(!t.hasOwnProperty(s))return!1;if(!dh(e[s],t[s],n-1))return!1}return!0}return!1}class fh{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},Object.seal(this),this.setProps(e)}finalize(){for(const e in this.controllers){const t=this.controllers[e];t&&t.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(const e in this.controllers){const t=this.controllers[e];t&&t.updateTransition()}}getViewports(e){return e?this._viewports.filter(t=>t.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(),r={x:e[0],y:e[1]};for(let i=n.length-1;i>=0;--i){const s=n[i];if(s.containsPixel(r)){const n=e.slice();return n[0]-=s.x,n[1]-=s.y,s.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=ah(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!dh(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):Hn.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,r){const i=e.controller;if(i&&n){const s={...t,...i,id:e.id,x:n.x,y:n.y,width:n.width,height:n.height};return r&&r.constructor===i.type||(r=this._createController(e,s)),r&&r.setProps(s),r}return null}_rebuildViewports(){const{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let n=!1;for(let r=e.length;r--;){const i=e[r],s=this.getViewState(i),o=i.makeViewport({viewState:s,width:this.width,height:this.height});let a=t[i.id];const A=Boolean(i.controller);A&&!a&&(n=!0),!n&&A||!a||(a.finalize(),a=null),this.controllers[i.id]=this._updateController(i,s,o,a),o&&this._viewports.unshift(o)}for(const r in t){const e=t[r];e&&!this.controllers[r]&&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,r)=>!e[r].equals(t[r]))}}const ph=/([0-9]+\.?[0-9]*)(%|px)/;function gh(e){switch(typeof e){case"number":return{position:e,relative:!1};case"string":const t=ph.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 mh(e,t){return e.relative?Math.round(e.position*t):e.position}class _h{constructor(e){const{id:t,x:n=0,y:r=0,width:i="100%",height:s="100%",padding:o=null}=e;this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=gh(n),this._y=gh(r),this._width=gh(i),this._height=gh(s),this._padding=o&&{left:gh(o.left||0),right:gh(o.right||0),top:gh(o.top||0),bottom:gh(o.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e||this.constructor===e.constructor&&dh(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 r=this.getDimensions({width:e,height:t});return r.height&&r.width?new(this.getViewportType(n))({...n,...this.props,...r}):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:mh(this._x,e),y:mh(this._y,t),width:mh(this._width,e),height:mh(this._height,t)};return this._padding&&(n.padding={left:mh(this._padding.left,e),top:mh(this._padding.top,t),right:mh(this._padding.right,e),bottom:mh(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 bh{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 vh=()=>{},yh=e=>e;class wh{constructor(e){this._onTransitionUpdate=e=>{const{time:t,settings:{interpolator:n,startProps:r,endProps:i,duration:s,easing:o}}=e,a=o(t/s),A=n.interpolateProps(r,i,a);this.propsInTransition=this.getControllerState({...this.props,...A}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new bh(e.timeline),this.onViewStateChange=e.onViewStateChange||vh,this.onStateChange=e.onStateChange||vh}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 r=n;if(this.transition.inProgress){const{interruption:e,endProps:t}=this.transition.settings;r={...n,...2===e?t:this.propsInTransition||n}}this._triggerTransition(r,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),r=this.getControllerState(t).shortestPathFrom(n),i=t.transitionInterpolator,s=i.getDuration?i.getDuration(e,t):t.transitionDuration;if(0===s)return;const o=i.initializeProps(e,r);this.propsInTransition={};const a={duration:s,easing:t.transitionEasing||yh,interpolator:i,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 xh(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}class Eh{constructor(e){const{compare:t,extract:n,required:r}=e;this._propsToCompare=t,this._propsToExtract=n||t,this._requiredProps=r}arePropsEqual(e,t){for(const n of this._propsToCompare)if(!(n in e)||!(n in t)||!Fa(e[n],t[n]))return!1;return!0}initializeProps(e,t){const n={},r={};for(const i of this._propsToExtract)(i in e||i in t)&&(n[i]=e[i],r[i]=t[i]);return this._checkRequiredProps(n),this._checkRequiredProps(r),{start:n,end:r}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{const n=e[t];xh(Number.isFinite(n)||Array.isArray(n),`${t} is required for transition`)})}}const Th=["longitude","latitude","zoom","bearing","pitch"],Sh=["longitude","latitude","zoom"];class Ch extends Eh{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:Th,required:Sh},super(n.transitionProps),this.opts=n}initializeProps(e,t){const n=super.initializeProps(e,t),{makeViewport:r,around:i}=this.opts;if(r&&i){const s=r(e),o=r(t),a=s.unproject(i);n.start.around=i,Object.assign(n.end,{around:o.project(a),aroundPosition:a,width:t.width,height:t.height})}return n}interpolateProps(e,t,n){const r={};for(const i of this._propsToExtract)r[i]=Oa(e[i]||0,t[i]||0,n);if(t.aroundPosition&&this.opts.makeViewport){const i=this.opts.makeViewport({...t,...r});Object.assign(r,i.panByPosition(t.aroundPosition,Oa(e.around,t.around,n)))}return r}}const kh={transitionDuration:0},Rh=e=>1-(1-e)*(1-e),Ph=["wheel"],Ih=["panstart","panmove","panend"],Mh=["pinchstart","pinchmove","pinchend"],Lh=["multipanstart","multipanmove","multipanend"],Nh=["dblclick"],Bh=["keydown"],Dh={};class Oh{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 wh({...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:r}=e;return[r.x-t,r.y-n]}isPointInBounds(e,t){const{width:n,height:r}=this.props;if(t&&t.handled)return!1;const i=e[0]>=0&&e[0]<=n&&e[1]>=0&&e[1]<=r;return i&&t&&t.stopPropagation(),i}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:r=!0,dragRotate:i=!0,doubleClickZoom:s=!0,touchZoom:o=!0,touchRotate:a=!1,keyboard:A=!0}=e,l=Boolean(this.onViewStateChange);this.toggleEvents(Ph,l&&n),this.toggleEvents(Ih,l),this.toggleEvents(Mh,l&&(o||a)),this.toggleEvents(Lh,l&&a),this.toggleEvents(Nh,l&&s),this.toggleEvents(Bh,l&&A),this.scrollZoom=n,this.dragPan=r,this.dragRotate=i,this.doubleClickZoom=s,this.touchZoom=o,this.touchRotate=a,this.keyboard=A}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 r={...e.getViewportProps(),...t},i=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(n),i){const e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,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 r=this.controllerState[n?"panStart":"rotateStart"]({pos:t});return this._panMove=n,this.updateViewport(r,kh,{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,kh,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:t}=this;if(this.dragPan&&t&&e.velocity){const n=this.getCenter(e),r=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Rh},{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,kh,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){const n=this.getCenter(e),r=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Rh},{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:r=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:i}=e;let s=2/(1+Math.exp(-Math.abs(i*n)));i<0&&0!==s&&(s=1/s);const o=r?{...this._getTransitionProps({around:t}),transitionDuration:250}:kh,a=this.controllerState.zoom({pos:t,scale:s});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,kh,{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,kh,{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),r=[n[0],n[1]+=e.velocityY*t/2],i=this.controllerState.rotate({pos:r});this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Rh},{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 Dh._startPinchRotation=e.rotation,Dh._lastPinchEvent=e,this.updateViewport(n,kh,{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,r=this.getCenter(e);t=t.zoom({pos:r,scale:n})}if(this.touchRotate){const{rotation:n}=e;t=t.rotate({deltaAngleX:Dh._startPinchRotation-n})}return this.updateViewport(t,kh,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Dh._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this,{_lastPinchEvent:n}=Dh;if(this.touchZoom&&t&&n&&e.scale!==n.scale){const r=this.getCenter(e);let i=this.controllerState.rotateEnd();const s=Math.log2(e.scale),o=(s-Math.log2(n.scale))/(e.deltaTime-n.deltaTime),a=Math.pow(2,s+o*t/2);i=i.zoom({pos:r,scale:a}).zoomEnd(),this.updateViewport(i,{...this._getTransitionProps({around:r}),transitionDuration:t,transitionEasing:Rh},{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 Dh._startPinchRotation=null,Dh._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),r=this.controllerState.zoom({pos:t,scale:n?.5:2});return this.updateViewport(r,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:r,rotateSpeedX:i,rotateSpeedY:s}=!0===this.keyboard?{}:this.keyboard,{controllerState:o}=this;let a;const A={};switch(e.srcEvent.code){case"Minus":a=t?o.zoomOut(n).zoomOut(n):o.zoomOut(n),A.isZooming=!0;break;case"Equal":a=t?o.zoomIn(n).zoomIn(n):o.zoomIn(n),A.isZooming=!0;break;case"ArrowLeft":t?(a=o.rotateLeft(i),A.isRotating=!0):(a=o.moveLeft(r),A.isPanning=!0);break;case"ArrowRight":t?(a=o.rotateRight(i),A.isRotating=!0):(a=o.moveRight(r),A.isPanning=!0);break;case"ArrowUp":t?(a=o.rotateUp(s),A.isRotating=!0):(a=o.moveUp(r),A.isPanning=!0);break;case"ArrowDown":t?(a=o.rotateDown(s),A.isRotating=!0):(a=o.moveDown(r),A.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),A),!0}_getTransitionProps(e){const{transition:t}=this;return t&&t.transitionInterpolator?e?{...t,transitionInterpolator:new Ch({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t:kh}}class Fh{constructor(e,t){this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}}class Uh extends Fh{constructor(e){const{width:t,height:n,latitude:r,longitude:i,zoom:s,bearing:o=0,pitch:a=0,altitude:A=1.5,position:l=[0,0,0],maxZoom:c=20,minZoom:u=0,maxPitch:h=60,minPitch:d=0,startPanLngLat:f,startZoomLngLat:p,startRotatePos:g,startBearing:m,startPitch:_,startZoom:b,normalize:v=!0}=e;xh(Number.isFinite(i)),xh(Number.isFinite(r)),xh(Number.isFinite(s)),super({width:t,height:n,latitude:r,longitude:i,zoom:s,bearing:o,pitch:a,altitude:A,maxZoom:c,minZoom:u,maxPitch:h,minPitch:d,normalize:v,position:l},{startPanLngLat:f,startZoomLngLat:p,startRotatePos:g,startBearing:m,startPitch:_,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 r=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(r)}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:r,startBearing:i,startPitch:s}=this.getState();if(!r||void 0===i||void 0===s)return this;let o;return o=e?this._getNewRotation(e,r,s,i):{bearing:i+t,pitch:s+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:r,startZoomLngLat:i}=this.getState();if(i||(r=this.getViewportProps().zoom,i=this._unproject(t)||this._unproject(e)),!i)return this;const{maxZoom:s,minZoom:o}=this.getViewportProps();let a=r+Math.log2(n);a=Da(a,o,s);const A=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...A.panByPosition(i,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:r,longitude:i}=n;return Math.abs(r-t.bearing)>180&&(n.bearing=r<0?r+360:r-360),Math.abs(i-t.longitude)>180&&(n.longitude=i<0?i+360:i-360),n}applyConstraints(e){const{maxZoom:t,minZoom:n,zoom:r}=e;e.zoom=Da(r,n,t);const{maxPitch:i,minPitch:s,pitch:o}=e;e.pitch=Da(o,s,i);const{normalize:a=!0}=e;return a&&Object.assign(e,function(e){const{width:t,height:n,pitch:r=0}=e;let{longitude:i,latitude:s,zoom:o,bearing:a=0}=e;(i<-180||i>180)&&(i=ac(i+180,360)-180),(a<-180||a>180)&&(a=ac(a+180,360)-180);const A=lc(n/512);if(o<=A)o=A,s=0;else{const e=n/2/Math.pow(2,o),t=bc([0,e])[1];if(s<t)s=t;else{const t=bc([0,512-e])[1];s>t&&(s=t)}}return{width:t,height:n,longitude:i,latitude:s,zoom:o,pitch:r,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,r){const i=e[0]-t[0],s=e[1]-t[1],o=e[1],a=t[1],{width:A,height:l}=this.getViewportProps(),c=i/A;let u=0;s>0?Math.abs(l-a)>5&&(u=s/(a-l)*1.2):s<0&&a>5&&(u=1-o/a),u=Da(u,-1,1);const{minPitch:h,maxPitch:d}=this.getViewportProps();let f=n;return u>0?f=n+u*(d-n):u<0&&(f=n-u*(h-n)),{pitch:f,bearing:r+180*c}}}class jh extends Oh{constructor(){super(...arguments),this.ControllerState=Uh,this.transition={transitionDuration:300,transitionInterpolator:new Ch({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 Gh extends _h{constructor(e={}){super(e)}getViewportType(){return _u}get ControllerType(){return jh}}Gh.displayName="MapView";const zh=new su;class Vh{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&&(dh(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 r of this.effects)t[r.id]=r;const n=[];for(const r of e){const e=t[r.id];let i=r;e&&e!==r?e.setProps?(e.setProps(r.props),i=e):e.cleanup(this._context):e||r.setup(this._context),n.push(i),delete t[r.id]}for(const r in t)t[r].cleanup(this._context);this.effects=n,this._resolvedEffects=n.concat(this._defaultEffects),e.some(e=>e instanceof su)||this._resolvedEffects.push(zh),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 Wh extends Zc{shouldDrawLayer(e){const{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}}class Hh{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Wh(e),this.pickLayersPass=new Ju(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 r=this.lastPostProcessEffect?this.renderBuffers[0]:n.target;this.lastPostProcessEffect&&(n.clearColor=[0,0,0,0],n.clearCanvas=!0);const i=t.render({...n,target:r});n.effects&&(this.lastPostProcessEffect&&(n.clearCanvas=void 0===e.clearCanvas||e.clearCanvas),this._postRender(n.effects,n)),this.renderCount++,Qn("deckRenderer.renderLayers",this,i,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,r]=t;0===e.length&&[0,1].map(t=>{const i=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:n,height:r});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${t}`,colorAttachments:[i]}))});for(const i of e)i.resize(t)}_postRender(e,t){const{renderBuffers:n}=this,r={...t,inputBuffer:n[0],swapBuffer:n[1]};for(const i of e)if(i.postRender){r.target=i.id===this.lastPostProcessEffect?t.target:void 0;const e=i.postRender(r);r.inputBuffer=e,r.swapBuffer=e===n[0]?n[1]:n[0]}}}const $h={pickedColor:null,pickedObjectIndex:-1};function Xh({pickedColors:e,decodePickingColor:t,deviceX:n,deviceY:r,deviceRadius:i,deviceRect:s}){const{x:o,y:a,width:A,height:l}=s;let c=i*i,u=-1,h=0;for(let d=0;d<l;d++){const t=d+a-r,i=t*t;if(i>c)h+=4*A;else for(let r=0;r<A;r++){if(e[h+3]-1>=0){const e=r+o-n,t=e*e+i;t<=c&&(c=t,u=h)}h+=4}}if(u>=0){const n=e.slice(u,u+4),r=t(n);if(r){const e=Math.floor(u/4/A),t=u/4-e*A;return{...r,pickedColor:n,pickedX:o+t,pickedY:a+e}}Hn.error("Picked non-existent layer. Is picking buffer corrupt?")()}return $h}function Qh({pickedColors:e,decodePickingColor:t}){const n=new Map;if(e)for(let r=0;r<e.length;r+=4)if(e[r+3]-1>=0){const i=e.slice(r,r+4),s=i.join(",");if(!n.has(s)){const e=t(i);e?n.set(s,{...e,color:i}):Hn.error("Picked non-existent layer. Is picking buffer corrupt?")()}}return Array.from(n.values())}function Yh({pickInfo:e,viewports:t,pixelRatio:n,x:r,y:i,z:s}){let o,a=t[0];if(t.length>1&&(a=function(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.containsPixel(t))return r}return e[0]}((null==e?void 0:e.pickedViewports)||t,{x:r,y:i})),a){const e=[r-a.x,i-a.y];void 0!==s&&(e[2]=s),o=a.unproject(e)}return{color:null,layer:null,viewport:a,index:-1,picked:!1,x:r,y:i,pixel:[r,i],coordinate:o,devicePixel:e&&"pickedX"in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:n}}function qh(e){const{pickInfo:t,lastPickedInfo:n,mode:r,layers:i}=e,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=t,A=o?[o]:[];if("hover"===r){const e=n.index,t=n.layerId,r=o?o.props.id:null;if(r!==t||a!==e){if(r!==t){const e=i.find(e=>e.props.id===t);e&&A.unshift(e)}n.layerId=r,n.index=a,n.info=null}}const l=Yh(e),c=new Map;return c.set(null,l),A.forEach(e=>{let t={...l};e===o&&(t.color=s,t.index=a,t.picked=!0),t=Kh({layer:e,info:t,mode:r});const i=t.layer;e===o&&"hover"===r&&(n.info=t),c.set(i.id,t),"hover"===r&&i.updateAutoHighlight(t)}),c}function Kh({layer:e,info:t,mode:n}){for(;e&&t;){const r=t.layer||null;t.sourceLayer=r,t.layer=e,t=e.getPickingInfo({info:t,mode:n,sourceLayer:r}),e=e.parent}return t}class Zh{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new Ju(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:r},i=this.lastPickedInfo.info){const s=i&&i.layer&&i.layer.id,o=i&&i.viewport&&i.viewport.id,a=s?n.find(e=>e.id===s):null,A=o&&r.find(e=>e.id===o)||r[0],l=A&&A.unproject([e-A.x,t-A.y]),c={x:e,y:t,viewport:A,coordinate:l,layer:a};return{...i,...c}}_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:r,y:i,radius:s=0,depth:o=1,mode:a="query",unproject3D:A,onViewportActive:l,effects:c}){const u=this.device.canvasContext.cssToDeviceRatio(),h=this._getPickable(e);if(!h||0===n.length)return{result:[],emptyInfo:Yh({viewports:n,x:r,y:i,pixelRatio:u})};this._resizeBuffer();const d=this.device.canvasContext.cssToDevicePixels([r,i],!0),f=[d.x+Math.floor(d.width/2),d.y+Math.floor(d.height/2)],p=Math.round(s*u),{width:g,height:m}=this.pickingFBO,_=this._getPickingRect({deviceX:f[0],deviceY:f[1],deviceRadius:p,deviceWidth:g,deviceHeight:m}),b={x:r-s,y:i-s,width:2*s+1,height:2*s+1};let v;const y=[],w=new Set;for(let x=0;x<o;x++){let e,s;if(e=_?Xh({...this._drawAndSample({layers:h,views:t,viewports:n,onViewportActive:l,deviceRect:_,cullRect:b,effects:c,pass:`picking:${a}`}),deviceX:f[0],deviceY:f[1],deviceRadius:p,deviceRect:_}):{pickedColor:null,pickedObjectIndex:-1},e.pickedLayer&&A&&this.depthFBO){const{pickedColors:r}=this._drawAndSample({layers:[e.pickedLayer],views:t,viewports:n,onViewportActive:l,deviceRect:{x:e.pickedX,y:e.pickedY,width:1,height:1},cullRect:b,effects:c,pass:`picking:${a}:z`},!0);r[3]&&(s=r[0])}e.pickedLayer&&x+1<o&&(w.add(e.pickedLayer),e.pickedLayer.disablePickingIndex(e.pickedObjectIndex)),v=qh({pickInfo:e,lastPickedInfo:this.lastPickedInfo,mode:a,layers:h,viewports:n,x:r,y:i,z:s,pixelRatio:u});for(const t of v.values())t.layer&&y.push(t);if(!e.pickedColor)break}for(const x of w)x.restorePickingColors();return{result:y,emptyInfo:v.get(null)}}_pickClosestObject({layers:e,views:t,viewports:n,x:r,y:i,radius:s=0,depth:o=1,mode:a="query",unproject3D:A,onViewportActive:l,effects:c}){const u=this.device.canvasContext.cssToDeviceRatio(),h=this._getPickable(e);if(!h||0===n.length)return{result:[],emptyInfo:Yh({viewports:n,x:r,y:i,pixelRatio:u})};this._resizeBuffer();const d=this.device.canvasContext.cssToDevicePixels([r,i],!0),f=[d.x+Math.floor(d.width/2),d.y+Math.floor(d.height/2)],p=Math.round(s*u),{width:g,height:m}=this.pickingFBO,_=this._getPickingRect({deviceX:f[0],deviceY:f[1],deviceRadius:p,deviceWidth:g,deviceHeight:m}),b={x:r-s,y:i-s,width:2*s+1,height:2*s+1};let v;const y=[],w=new Set;for(let x=0;x<o;x++){let e,s;if(e=_?Xh({...this._drawAndSample({layers:h,views:t,viewports:n,onViewportActive:l,deviceRect:_,cullRect:b,effects:c,pass:`picking:${a}`}),deviceX:f[0],deviceY:f[1],deviceRadius:p,deviceRect:_}):{pickedColor:null,pickedObjectIndex:-1},e.pickedLayer&&A&&this.depthFBO){const{pickedColors:r}=this._drawAndSample({layers:[e.pickedLayer],views:t,viewports:n,onViewportActive:l,deviceRect:{x:e.pickedX,y:e.pickedY,width:1,height:1},cullRect:b,effects:c,pass:`picking:${a}:z`},!0);r[3]&&(s=r[0])}e.pickedLayer&&x+1<o&&(w.add(e.pickedLayer),e.pickedLayer.disablePickingIndex(e.pickedObjectIndex)),v=qh({pickInfo:e,lastPickedInfo:this.lastPickedInfo,mode:a,layers:h,viewports:n,x:r,y:i,z:s,pixelRatio:u});for(const t of v.values())t.layer&&y.push(t);if(!e.pickedColor)break}for(const x of w)x.restorePickingColors();return{result:y,emptyInfo:v.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:t,viewports:n,x:r,y:i,width:s=1,height:o=1,mode:a="query",maxObjects:A=null,onViewportActive:l,effects:c}){const u=this._getPickable(e);if(!u||0===n.length)return[];this._resizeBuffer();const h=this.device.canvasContext.cssToDeviceRatio(),d=this.device.canvasContext.cssToDevicePixels([r,i],!0),f=d.x,p=d.y+d.height,g=this.device.canvasContext.cssToDevicePixels([r+s,i+o],!0),m=g.x+g.width,_=g.y,b={x:f,y:_,width:m-f,height:p-_},v=Qh(this._drawAndSample({layers:u,views:t,viewports:n,onViewportActive:l,deviceRect:b,cullRect:{x:r,y:i,width:s,height:o},effects:c,pass:`picking:${a}`})),y=new Map,w=[],x=Number.isFinite(A);for(let E=0;E<v.length&&!(x&&w.length>=A);E++){const e=v[E];let t={color:e.pickedColor,layer:null,index:e.pickedObjectIndex,picked:!0,x:r,y:i,pixelRatio:h};t=Kh({layer:e.pickedLayer,info:t,mode:a});const n=t.layer.id;y.has(n)||y.set(n,new Set);const s=y.get(n),o=t.object??t.index;s.has(o)||(s.add(o),w.push(t))}return w}_pickVisibleObjects({layers:e,views:t,viewports:n,x:r,y:i,width:s=1,height:o=1,mode:a="query",maxObjects:A=null,onViewportActive:l,effects:c}){const u=this._getPickable(e);if(!u||0===n.length)return[];this._resizeBuffer();const h=this.device.canvasContext.cssToDeviceRatio(),d=this.device.canvasContext.cssToDevicePixels([r,i],!0),f=d.x,p=d.y+d.height,g=this.device.canvasContext.cssToDevicePixels([r+s,i+o],!0),m=g.x+g.width,_=g.y,b={x:f,y:_,width:m-f,height:p-_},v=Qh(this._drawAndSample({layers:u,views:t,viewports:n,onViewportActive:l,deviceRect:b,cullRect:{x:r,y:i,width:s,height:o},effects:c,pass:`picking:${a}`})),y=new Map,w=[],x=Number.isFinite(A);for(let E=0;E<v.length&&!(x&&w.length>=A);E++){const e=v[E];let t={color:e.pickedColor,layer:null,index:e.pickedObjectIndex,picked:!0,x:r,y:i,pixelRatio:h};t=Kh({layer:e.pickedLayer,info:t,mode:a});const n=t.layer.id;y.has(n)||y.set(n,new Set);const s=y.get(n),o=t.object??t.index;s.has(o)||(s.add(o),w.push(t))}return w}async _drawAndSampleAsync({layers:e,views:t,viewports:n,onViewportActive:r,deviceRect:i,cullRect:s,effects:o,pass:a},A=!1){const l=A?this.depthFBO:this.pickingFBO,c={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:r,pickingFBO:l,deviceRect:i,cullRect:s,effects:o,pass:a,pickZ:A,preRenderStats:{},isPicking:!0};for(const m of o)m.useInPicking&&(c.preRenderStats[m.id]=m.preRender(c));const{decodePickingColor:u}=this.pickLayersPass.render(c),{x:h,y:d,width:f,height:p}=i,g=new(A?Float32Array:Uint8Array)(f*p*4);return this.device.readPixelsToArrayWebGL(l,{sourceX:h,sourceY:d,sourceWidth:f,sourceHeight:p,target:g}),{pickedColors:g,decodePickingColor:u}}_drawAndSample({layers:e,views:t,viewports:n,onViewportActive:r,deviceRect:i,cullRect:s,effects:o,pass:a},A=!1){const l=A?this.depthFBO:this.pickingFBO,c={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:r,pickingFBO:l,deviceRect:i,cullRect:s,effects:o,pass:a,pickZ:A,preRenderStats:{},isPicking:!0};for(const m of o)m.useInPicking&&(c.preRenderStats[m.id]=m.preRender(c));const{decodePickingColor:u}=this.pickLayersPass.render(c),{x:h,y:d,width:f,height:p}=i,g=new(A?Float32Array:Uint8Array)(f*p*4);return this.device.readPixelsToArrayWebGL(l,{sourceX:h,sourceY:d,sourceWidth:f,sourceHeight:p,target:g}),{pickedColors:g,decodePickingColor:u}}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:n,deviceWidth:r,deviceHeight:i}){const s=Math.max(0,e-n),o=Math.max(0,t-n),a=Math.min(r,e+n+1)-s,A=Math.min(i,t+n+1)-o;return a<=0||A<=0?null:{x:s,y:o,width:a,height:A}}}const Jh={"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}},ed="top-left",td="__root";class nd{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&&!dh(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,r;const i=e.reduce((e,t)=>(e[t.id]=t,e),{});for(const s of this.getWidgets()){const{viewId:o}=s;if(o){const e=i[o];e&&(s.onViewportChange&&s.onViewportChange(e),null==(n=s.onRedraw)||n.call(s,{viewports:[e],layers:t}))}else{if(s.onViewportChange)for(const t of e)s.onViewportChange(t);null==(r=s.onRedraw)||r.call(s,{viewports:e,layers:t})}}this.lastViewports=i,this._updateContainers()}onHover(e,t){var n,r;for(const i of this.getWidgets()){const{viewId:s}=i;s&&s!==(null==(n=e.viewport)?void 0:n.id)||null==(r=i.onHover)||r.call(i,e,t)}}onEvent(e,t){var n,r;const i=zl[t.type];if(i)for(const s of this.getWidgets()){const{viewId:o}=s;o&&o!==(null==(n=e.viewport)?void 0:n.id)||null==(r=s[i])||r.call(s,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=ed}=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 r=e||td;let i=this.containers[r];i||(i=document.createElement("div"),i.style.pointerEvents="none",i.style.position="absolute",i.style.overflow="hidden",null==(n=this.parentElement)||n.append(i),this.containers[r]=i);let s=i.querySelector(`.${t}`);return s||(s=globalThis.document.createElement("div"),s.className=t,s.style.position="absolute",s.style.zIndex="2",Object.assign(s.style,Jh[t]),i.append(s)),s}_updateContainers(){const e=this.deck.width,t=this.deck.height;for(const n in this.containers){const r=this.lastViewports[n]||null,i=n===td||r,s=this.containers[n];i?(s.style.display="block",s.style.left=`${r?r.x:0}px`,s.style.top=`${r?r.y:0}px`,s.style.width=`${r?r.width:e}px`,s.style.height=`${r?r.height:t}px`):s.style.display="none"}}}function rd(e,t){t&&Object.entries(t).map(([t,n])=>{t.startsWith("--")?e.style.setProperty(t,n):e.style[t]=n})}class id{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 r,i;n&&t.className!==e.className&&(t.className&&n.classList.remove(t.className),e.className&&n.classList.add(e.className)),n&&!dh(t.style,e.style,1)&&(r=n,(i=t.style)&&Object.keys(i).map(e=>{e.startsWith("--")?r.style.removeProperty(e):r.style[e]=""}),rd(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)),rd(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){}}id.defaultProps={id:"widget",style:{},className:""};const sd={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class od extends id{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,sd),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 r=n(e);this.setTooltip(r,e.x,e.y)}setTooltip(e,t,n){const r=this.rootElement;if(r){if("string"==typeof e)r.innerText=e;else{if(!e)return this.isVisible=!1,void(r.style.display="none");e.text&&(r.innerText=e.text),e.html&&(r.innerHTML=e.html),e.className&&(r.className=e.className)}this.isVisible=!0,r.style.display="block",r.style.transform=`translate(${t}px, ${n}px)`,e&&"object"==typeof e&&"style"in e&&Object.assign(r.style,e.style)}}}var ad,Ad;od.defaultProps={...id.defaultProps},(Ad=ad||(ad={}))[Ad.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",Ad[Ad.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",Ad[Ad.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",Ad[Ad.POINTS=0]="POINTS",Ad[Ad.LINES=1]="LINES",Ad[Ad.LINE_LOOP=2]="LINE_LOOP",Ad[Ad.LINE_STRIP=3]="LINE_STRIP",Ad[Ad.TRIANGLES=4]="TRIANGLES",Ad[Ad.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",Ad[Ad.TRIANGLE_FAN=6]="TRIANGLE_FAN",Ad[Ad.ZERO=0]="ZERO",Ad[Ad.ONE=1]="ONE",Ad[Ad.SRC_COLOR=768]="SRC_COLOR",Ad[Ad.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",Ad[Ad.SRC_ALPHA=770]="SRC_ALPHA",Ad[Ad.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",Ad[Ad.DST_ALPHA=772]="DST_ALPHA",Ad[Ad.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",Ad[Ad.DST_COLOR=774]="DST_COLOR",Ad[Ad.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",Ad[Ad.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",Ad[Ad.CONSTANT_COLOR=32769]="CONSTANT_COLOR",Ad[Ad.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",Ad[Ad.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",Ad[Ad.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",Ad[Ad.FUNC_ADD=32774]="FUNC_ADD",Ad[Ad.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",Ad[Ad.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",Ad[Ad.BLEND_EQUATION=32777]="BLEND_EQUATION",Ad[Ad.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",Ad[Ad.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",Ad[Ad.BLEND_DST_RGB=32968]="BLEND_DST_RGB",Ad[Ad.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",Ad[Ad.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",Ad[Ad.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",Ad[Ad.BLEND_COLOR=32773]="BLEND_COLOR",Ad[Ad.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",Ad[Ad.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",Ad[Ad.LINE_WIDTH=2849]="LINE_WIDTH",Ad[Ad.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",Ad[Ad.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",Ad[Ad.CULL_FACE_MODE=2885]="CULL_FACE_MODE",Ad[Ad.FRONT_FACE=2886]="FRONT_FACE",Ad[Ad.DEPTH_RANGE=2928]="DEPTH_RANGE",Ad[Ad.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",Ad[Ad.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",Ad[Ad.DEPTH_FUNC=2932]="DEPTH_FUNC",Ad[Ad.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",Ad[Ad.STENCIL_FUNC=2962]="STENCIL_FUNC",Ad[Ad.STENCIL_FAIL=2964]="STENCIL_FAIL",Ad[Ad.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",Ad[Ad.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",Ad[Ad.STENCIL_REF=2967]="STENCIL_REF",Ad[Ad.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",Ad[Ad.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",Ad[Ad.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",Ad[Ad.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",Ad[Ad.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",Ad[Ad.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",Ad[Ad.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",Ad[Ad.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",Ad[Ad.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",Ad[Ad.VIEWPORT=2978]="VIEWPORT",Ad[Ad.SCISSOR_BOX=3088]="SCISSOR_BOX",Ad[Ad.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",Ad[Ad.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",Ad[Ad.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",Ad[Ad.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",Ad[Ad.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",Ad[Ad.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",Ad[Ad.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",Ad[Ad.RED_BITS=3410]="RED_BITS",Ad[Ad.GREEN_BITS=3411]="GREEN_BITS",Ad[Ad.BLUE_BITS=3412]="BLUE_BITS",Ad[Ad.ALPHA_BITS=3413]="ALPHA_BITS",Ad[Ad.DEPTH_BITS=3414]="DEPTH_BITS",Ad[Ad.STENCIL_BITS=3415]="STENCIL_BITS",Ad[Ad.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",Ad[Ad.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",Ad[Ad.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",Ad[Ad.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",Ad[Ad.SAMPLES=32937]="SAMPLES",Ad[Ad.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",Ad[Ad.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",Ad[Ad.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",Ad[Ad.VENDOR=7936]="VENDOR",Ad[Ad.RENDERER=7937]="RENDERER",Ad[Ad.VERSION=7938]="VERSION",Ad[Ad.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",Ad[Ad.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",Ad[Ad.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",Ad[Ad.STATIC_DRAW=35044]="STATIC_DRAW",Ad[Ad.STREAM_DRAW=35040]="STREAM_DRAW",Ad[Ad.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",Ad[Ad.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Ad[Ad.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",Ad[Ad.BUFFER_SIZE=34660]="BUFFER_SIZE",Ad[Ad.BUFFER_USAGE=34661]="BUFFER_USAGE",Ad[Ad.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",Ad[Ad.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",Ad[Ad.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",Ad[Ad.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",Ad[Ad.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",Ad[Ad.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",Ad[Ad.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",Ad[Ad.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",Ad[Ad.CULL_FACE=2884]="CULL_FACE",Ad[Ad.FRONT=1028]="FRONT",Ad[Ad.BACK=1029]="BACK",Ad[Ad.FRONT_AND_BACK=1032]="FRONT_AND_BACK",Ad[Ad.BLEND=3042]="BLEND",Ad[Ad.DEPTH_TEST=2929]="DEPTH_TEST",Ad[Ad.DITHER=3024]="DITHER",Ad[Ad.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",Ad[Ad.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",Ad[Ad.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",Ad[Ad.SCISSOR_TEST=3089]="SCISSOR_TEST",Ad[Ad.STENCIL_TEST=2960]="STENCIL_TEST",Ad[Ad.NO_ERROR=0]="NO_ERROR",Ad[Ad.INVALID_ENUM=1280]="INVALID_ENUM",Ad[Ad.INVALID_VALUE=1281]="INVALID_VALUE",Ad[Ad.INVALID_OPERATION=1282]="INVALID_OPERATION",Ad[Ad.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",Ad[Ad.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",Ad[Ad.CW=2304]="CW",Ad[Ad.CCW=2305]="CCW",Ad[Ad.DONT_CARE=4352]="DONT_CARE",Ad[Ad.FASTEST=4353]="FASTEST",Ad[Ad.NICEST=4354]="NICEST",Ad[Ad.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",Ad[Ad.BYTE=5120]="BYTE",Ad[Ad.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",Ad[Ad.SHORT=5122]="SHORT",Ad[Ad.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",Ad[Ad.INT=5124]="INT",Ad[Ad.UNSIGNED_INT=5125]="UNSIGNED_INT",Ad[Ad.FLOAT=5126]="FLOAT",Ad[Ad.DOUBLE=5130]="DOUBLE",Ad[Ad.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",Ad[Ad.ALPHA=6406]="ALPHA",Ad[Ad.RGB=6407]="RGB",Ad[Ad.RGBA=6408]="RGBA",Ad[Ad.LUMINANCE=6409]="LUMINANCE",Ad[Ad.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",Ad[Ad.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",Ad[Ad.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",Ad[Ad.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",Ad[Ad.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",Ad[Ad.VERTEX_SHADER=35633]="VERTEX_SHADER",Ad[Ad.COMPILE_STATUS=35713]="COMPILE_STATUS",Ad[Ad.DELETE_STATUS=35712]="DELETE_STATUS",Ad[Ad.LINK_STATUS=35714]="LINK_STATUS",Ad[Ad.VALIDATE_STATUS=35715]="VALIDATE_STATUS",Ad[Ad.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",Ad[Ad.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",Ad[Ad.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",Ad[Ad.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",Ad[Ad.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",Ad[Ad.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",Ad[Ad.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",Ad[Ad.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",Ad[Ad.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",Ad[Ad.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",Ad[Ad.SHADER_TYPE=35663]="SHADER_TYPE",Ad[Ad.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",Ad[Ad.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",Ad[Ad.NEVER=512]="NEVER",Ad[Ad.LESS=513]="LESS",Ad[Ad.EQUAL=514]="EQUAL",Ad[Ad.LEQUAL=515]="LEQUAL",Ad[Ad.GREATER=516]="GREATER",Ad[Ad.NOTEQUAL=517]="NOTEQUAL",Ad[Ad.GEQUAL=518]="GEQUAL",Ad[Ad.ALWAYS=519]="ALWAYS",Ad[Ad.KEEP=7680]="KEEP",Ad[Ad.REPLACE=7681]="REPLACE",Ad[Ad.INCR=7682]="INCR",Ad[Ad.DECR=7683]="DECR",Ad[Ad.INVERT=5386]="INVERT",Ad[Ad.INCR_WRAP=34055]="INCR_WRAP",Ad[Ad.DECR_WRAP=34056]="DECR_WRAP",Ad[Ad.NEAREST=9728]="NEAREST",Ad[Ad.LINEAR=9729]="LINEAR",Ad[Ad.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",Ad[Ad.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",Ad[Ad.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",Ad[Ad.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",Ad[Ad.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",Ad[Ad.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",Ad[Ad.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",Ad[Ad.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",Ad[Ad.TEXTURE_2D=3553]="TEXTURE_2D",Ad[Ad.TEXTURE=5890]="TEXTURE",Ad[Ad.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",Ad[Ad.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",Ad[Ad.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",Ad[Ad.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",Ad[Ad.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",Ad[Ad.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",Ad[Ad.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",Ad[Ad.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",Ad[Ad.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",Ad[Ad.TEXTURE0=33984]="TEXTURE0",Ad[Ad.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",Ad[Ad.REPEAT=10497]="REPEAT",Ad[Ad.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",Ad[Ad.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",Ad[Ad.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",Ad[Ad.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",Ad[Ad.FLOAT_VEC2=35664]="FLOAT_VEC2",Ad[Ad.FLOAT_VEC3=35665]="FLOAT_VEC3",Ad[Ad.FLOAT_VEC4=35666]="FLOAT_VEC4",Ad[Ad.INT_VEC2=35667]="INT_VEC2",Ad[Ad.INT_VEC3=35668]="INT_VEC3",Ad[Ad.INT_VEC4=35669]="INT_VEC4",Ad[Ad.BOOL=35670]="BOOL",Ad[Ad.BOOL_VEC2=35671]="BOOL_VEC2",Ad[Ad.BOOL_VEC3=35672]="BOOL_VEC3",Ad[Ad.BOOL_VEC4=35673]="BOOL_VEC4",Ad[Ad.FLOAT_MAT2=35674]="FLOAT_MAT2",Ad[Ad.FLOAT_MAT3=35675]="FLOAT_MAT3",Ad[Ad.FLOAT_MAT4=35676]="FLOAT_MAT4",Ad[Ad.SAMPLER_2D=35678]="SAMPLER_2D",Ad[Ad.SAMPLER_CUBE=35680]="SAMPLER_CUBE",Ad[Ad.LOW_FLOAT=36336]="LOW_FLOAT",Ad[Ad.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",Ad[Ad.HIGH_FLOAT=36338]="HIGH_FLOAT",Ad[Ad.LOW_INT=36339]="LOW_INT",Ad[Ad.MEDIUM_INT=36340]="MEDIUM_INT",Ad[Ad.HIGH_INT=36341]="HIGH_INT",Ad[Ad.FRAMEBUFFER=36160]="FRAMEBUFFER",Ad[Ad.RENDERBUFFER=36161]="RENDERBUFFER",Ad[Ad.RGBA4=32854]="RGBA4",Ad[Ad.RGB5_A1=32855]="RGB5_A1",Ad[Ad.RGB565=36194]="RGB565",Ad[Ad.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",Ad[Ad.STENCIL_INDEX=6401]="STENCIL_INDEX",Ad[Ad.STENCIL_INDEX8=36168]="STENCIL_INDEX8",Ad[Ad.DEPTH_STENCIL=34041]="DEPTH_STENCIL",Ad[Ad.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",Ad[Ad.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",Ad[Ad.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",Ad[Ad.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",Ad[Ad.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",Ad[Ad.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",Ad[Ad.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",Ad[Ad.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",Ad[Ad.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",Ad[Ad.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",Ad[Ad.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",Ad[Ad.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",Ad[Ad.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",Ad[Ad.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",Ad[Ad.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",Ad[Ad.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",Ad[Ad.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",Ad[Ad.NONE=0]="NONE",Ad[Ad.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",Ad[Ad.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",Ad[Ad.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",Ad[Ad.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",Ad[Ad.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",Ad[Ad.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",Ad[Ad.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",Ad[Ad.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",Ad[Ad.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",Ad[Ad.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",Ad[Ad.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",Ad[Ad.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",Ad[Ad.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",Ad[Ad.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",Ad[Ad.READ_BUFFER=3074]="READ_BUFFER",Ad[Ad.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",Ad[Ad.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",Ad[Ad.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",Ad[Ad.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",Ad[Ad.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",Ad[Ad.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",Ad[Ad.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",Ad[Ad.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",Ad[Ad.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",Ad[Ad.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",Ad[Ad.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",Ad[Ad.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",Ad[Ad.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",Ad[Ad.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",Ad[Ad.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",Ad[Ad.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",Ad[Ad.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",Ad[Ad.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",Ad[Ad.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",Ad[Ad.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",Ad[Ad.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",Ad[Ad.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",Ad[Ad.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",Ad[Ad.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",Ad[Ad.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",Ad[Ad.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",Ad[Ad.RED=6403]="RED",Ad[Ad.RGB8=32849]="RGB8",Ad[Ad.RGBA8=32856]="RGBA8",Ad[Ad.RGB10_A2=32857]="RGB10_A2",Ad[Ad.TEXTURE_3D=32879]="TEXTURE_3D",Ad[Ad.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",Ad[Ad.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",Ad[Ad.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",Ad[Ad.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",Ad[Ad.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",Ad[Ad.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",Ad[Ad.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",Ad[Ad.SRGB=35904]="SRGB",Ad[Ad.SRGB8=35905]="SRGB8",Ad[Ad.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",Ad[Ad.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",Ad[Ad.RGBA32F=34836]="RGBA32F",Ad[Ad.RGB32F=34837]="RGB32F",Ad[Ad.RGBA16F=34842]="RGBA16F",Ad[Ad.RGB16F=34843]="RGB16F",Ad[Ad.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",Ad[Ad.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",Ad[Ad.R11F_G11F_B10F=35898]="R11F_G11F_B10F",Ad[Ad.RGB9_E5=35901]="RGB9_E5",Ad[Ad.RGBA32UI=36208]="RGBA32UI",Ad[Ad.RGB32UI=36209]="RGB32UI",Ad[Ad.RGBA16UI=36214]="RGBA16UI",Ad[Ad.RGB16UI=36215]="RGB16UI",Ad[Ad.RGBA8UI=36220]="RGBA8UI",Ad[Ad.RGB8UI=36221]="RGB8UI",Ad[Ad.RGBA32I=36226]="RGBA32I",Ad[Ad.RGB32I=36227]="RGB32I",Ad[Ad.RGBA16I=36232]="RGBA16I",Ad[Ad.RGB16I=36233]="RGB16I",Ad[Ad.RGBA8I=36238]="RGBA8I",Ad[Ad.RGB8I=36239]="RGB8I",Ad[Ad.RED_INTEGER=36244]="RED_INTEGER",Ad[Ad.RGB_INTEGER=36248]="RGB_INTEGER",Ad[Ad.RGBA_INTEGER=36249]="RGBA_INTEGER",Ad[Ad.R8=33321]="R8",Ad[Ad.RG8=33323]="RG8",Ad[Ad.R16F=33325]="R16F",Ad[Ad.R32F=33326]="R32F",Ad[Ad.RG16F=33327]="RG16F",Ad[Ad.RG32F=33328]="RG32F",Ad[Ad.R8I=33329]="R8I",Ad[Ad.R8UI=33330]="R8UI",Ad[Ad.R16I=33331]="R16I",Ad[Ad.R16UI=33332]="R16UI",Ad[Ad.R32I=33333]="R32I",Ad[Ad.R32UI=33334]="R32UI",Ad[Ad.RG8I=33335]="RG8I",Ad[Ad.RG8UI=33336]="RG8UI",Ad[Ad.RG16I=33337]="RG16I",Ad[Ad.RG16UI=33338]="RG16UI",Ad[Ad.RG32I=33339]="RG32I",Ad[Ad.RG32UI=33340]="RG32UI",Ad[Ad.R8_SNORM=36756]="R8_SNORM",Ad[Ad.RG8_SNORM=36757]="RG8_SNORM",Ad[Ad.RGB8_SNORM=36758]="RGB8_SNORM",Ad[Ad.RGBA8_SNORM=36759]="RGBA8_SNORM",Ad[Ad.RGB10_A2UI=36975]="RGB10_A2UI",Ad[Ad.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",Ad[Ad.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",Ad[Ad.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",Ad[Ad.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",Ad[Ad.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",Ad[Ad.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",Ad[Ad.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",Ad[Ad.HALF_FLOAT=5131]="HALF_FLOAT",Ad[Ad.RG=33319]="RG",Ad[Ad.RG_INTEGER=33320]="RG_INTEGER",Ad[Ad.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",Ad[Ad.CURRENT_QUERY=34917]="CURRENT_QUERY",Ad[Ad.QUERY_RESULT=34918]="QUERY_RESULT",Ad[Ad.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",Ad[Ad.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",Ad[Ad.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",Ad[Ad.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",Ad[Ad.DRAW_BUFFER0=34853]="DRAW_BUFFER0",Ad[Ad.DRAW_BUFFER1=34854]="DRAW_BUFFER1",Ad[Ad.DRAW_BUFFER2=34855]="DRAW_BUFFER2",Ad[Ad.DRAW_BUFFER3=34856]="DRAW_BUFFER3",Ad[Ad.DRAW_BUFFER4=34857]="DRAW_BUFFER4",Ad[Ad.DRAW_BUFFER5=34858]="DRAW_BUFFER5",Ad[Ad.DRAW_BUFFER6=34859]="DRAW_BUFFER6",Ad[Ad.DRAW_BUFFER7=34860]="DRAW_BUFFER7",Ad[Ad.DRAW_BUFFER8=34861]="DRAW_BUFFER8",Ad[Ad.DRAW_BUFFER9=34862]="DRAW_BUFFER9",Ad[Ad.DRAW_BUFFER10=34863]="DRAW_BUFFER10",Ad[Ad.DRAW_BUFFER11=34864]="DRAW_BUFFER11",Ad[Ad.DRAW_BUFFER12=34865]="DRAW_BUFFER12",Ad[Ad.DRAW_BUFFER13=34866]="DRAW_BUFFER13",Ad[Ad.DRAW_BUFFER14=34867]="DRAW_BUFFER14",Ad[Ad.DRAW_BUFFER15=34868]="DRAW_BUFFER15",Ad[Ad.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",Ad[Ad.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",Ad[Ad.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",Ad[Ad.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",Ad[Ad.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",Ad[Ad.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",Ad[Ad.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",Ad[Ad.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",Ad[Ad.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",Ad[Ad.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",Ad[Ad.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",Ad[Ad.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",Ad[Ad.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",Ad[Ad.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",Ad[Ad.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",Ad[Ad.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",Ad[Ad.SAMPLER_3D=35679]="SAMPLER_3D",Ad[Ad.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",Ad[Ad.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",Ad[Ad.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",Ad[Ad.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",Ad[Ad.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",Ad[Ad.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",Ad[Ad.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",Ad[Ad.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",Ad[Ad.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",Ad[Ad.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",Ad[Ad.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",Ad[Ad.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",Ad[Ad.MAX_SAMPLES=36183]="MAX_SAMPLES",Ad[Ad.SAMPLER_BINDING=35097]="SAMPLER_BINDING",Ad[Ad.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",Ad[Ad.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",Ad[Ad.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",Ad[Ad.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",Ad[Ad.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",Ad[Ad.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",Ad[Ad.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",Ad[Ad.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",Ad[Ad.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",Ad[Ad.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",Ad[Ad.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",Ad[Ad.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",Ad[Ad.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",Ad[Ad.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",Ad[Ad.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",Ad[Ad.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",Ad[Ad.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",Ad[Ad.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",Ad[Ad.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",Ad[Ad.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",Ad[Ad.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",Ad[Ad.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",Ad[Ad.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",Ad[Ad.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",Ad[Ad.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",Ad[Ad.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",Ad[Ad.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",Ad[Ad.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",Ad[Ad.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",Ad[Ad.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",Ad[Ad.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",Ad[Ad.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",Ad[Ad.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",Ad[Ad.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",Ad[Ad.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",Ad[Ad.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",Ad[Ad.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",Ad[Ad.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",Ad[Ad.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",Ad[Ad.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",Ad[Ad.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",Ad[Ad.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",Ad[Ad.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",Ad[Ad.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",Ad[Ad.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",Ad[Ad.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",Ad[Ad.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",Ad[Ad.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",Ad[Ad.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",Ad[Ad.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",Ad[Ad.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",Ad[Ad.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",Ad[Ad.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",Ad[Ad.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",Ad[Ad.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",Ad[Ad.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",Ad[Ad.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",Ad[Ad.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",Ad[Ad.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",Ad[Ad.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",Ad[Ad.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",Ad[Ad.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",Ad[Ad.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",Ad[Ad.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",Ad[Ad.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",Ad[Ad.UNIFORM_TYPE=35383]="UNIFORM_TYPE",Ad[Ad.UNIFORM_SIZE=35384]="UNIFORM_SIZE",Ad[Ad.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",Ad[Ad.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",Ad[Ad.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",Ad[Ad.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",Ad[Ad.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",Ad[Ad.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",Ad[Ad.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",Ad[Ad.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",Ad[Ad.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",Ad[Ad.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",Ad[Ad.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",Ad[Ad.OBJECT_TYPE=37138]="OBJECT_TYPE",Ad[Ad.SYNC_CONDITION=37139]="SYNC_CONDITION",Ad[Ad.SYNC_STATUS=37140]="SYNC_STATUS",Ad[Ad.SYNC_FLAGS=37141]="SYNC_FLAGS",Ad[Ad.SYNC_FENCE=37142]="SYNC_FENCE",Ad[Ad.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",Ad[Ad.UNSIGNALED=37144]="UNSIGNALED",Ad[Ad.SIGNALED=37145]="SIGNALED",Ad[Ad.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",Ad[Ad.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",Ad[Ad.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",Ad[Ad.WAIT_FAILED=37149]="WAIT_FAILED",Ad[Ad.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",Ad[Ad.COLOR=6144]="COLOR",Ad[Ad.DEPTH=6145]="DEPTH",Ad[Ad.STENCIL=6146]="STENCIL",Ad[Ad.MIN=32775]="MIN",Ad[Ad.MAX=32776]="MAX",Ad[Ad.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",Ad[Ad.STREAM_READ=35041]="STREAM_READ",Ad[Ad.STREAM_COPY=35042]="STREAM_COPY",Ad[Ad.STATIC_READ=35045]="STATIC_READ",Ad[Ad.STATIC_COPY=35046]="STATIC_COPY",Ad[Ad.DYNAMIC_READ=35049]="DYNAMIC_READ",Ad[Ad.DYNAMIC_COPY=35050]="DYNAMIC_COPY",Ad[Ad.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",Ad[Ad.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",Ad[Ad.INVALID_INDEX=4294967295]="INVALID_INDEX",Ad[Ad.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",Ad[Ad.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",Ad[Ad.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",Ad[Ad.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",Ad[Ad.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",Ad[Ad.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",Ad[Ad.R16_EXT=33322]="R16_EXT",Ad[Ad.RG16_EXT=33324]="RG16_EXT",Ad[Ad.RGB16_EXT=32852]="RGB16_EXT",Ad[Ad.RGBA16_EXT=32859]="RGBA16_EXT",Ad[Ad.R16_SNORM_EXT=36760]="R16_SNORM_EXT",Ad[Ad.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",Ad[Ad.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",Ad[Ad.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",Ad[Ad.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",Ad[Ad.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",Ad[Ad.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",Ad[Ad.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",Ad[Ad.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",Ad[Ad.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",Ad[Ad.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",Ad[Ad.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",Ad[Ad.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",Ad[Ad.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",Ad[Ad.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",Ad[Ad.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",Ad[Ad.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",Ad[Ad.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",Ad[Ad.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",Ad[Ad.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",Ad[Ad.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",Ad[Ad.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",Ad[Ad.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",Ad[Ad.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",Ad[Ad.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",Ad[Ad.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",Ad[Ad.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",Ad[Ad.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",Ad[Ad.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",Ad[Ad.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",Ad[Ad.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",Ad[Ad.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",Ad[Ad.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",Ad[Ad.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",Ad[Ad.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",Ad[Ad.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",Ad[Ad.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",Ad[Ad.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",Ad[Ad.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",Ad[Ad.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",Ad[Ad.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",Ad[Ad.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",Ad[Ad.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",Ad[Ad.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",Ad[Ad.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",Ad[Ad.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",Ad[Ad.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",Ad[Ad.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",Ad[Ad.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",Ad[Ad.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",Ad[Ad.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",Ad[Ad.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",Ad[Ad.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",Ad[Ad.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",Ad[Ad.LINE_WEBGL=6913]="LINE_WEBGL",Ad[Ad.FILL_WEBGL=6914]="FILL_WEBGL",Ad[Ad.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",Ad[Ad.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",Ad[Ad.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",Ad[Ad.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",Ad[Ad.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",Ad[Ad.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",Ad[Ad.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",Ad[Ad.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",Ad[Ad.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",Ad[Ad.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",Ad[Ad.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",Ad[Ad.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",Ad[Ad.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",Ad[Ad.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",Ad[Ad.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",Ad[Ad.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",Ad[Ad.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",Ad[Ad.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",Ad[Ad.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",Ad[Ad.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",Ad[Ad.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",Ad[Ad.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",Ad[Ad.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",Ad[Ad.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT";const ld={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:{}},cd=e=>({drawBuffersWEBGL:t=>e.drawBuffers(t),COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),ud=e=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES:()=>e.createVertexArray(),deleteVertexArrayOES:t=>e.deleteVertexArray(t),isVertexArrayOES:t=>e.isVertexArray(t),bindVertexArrayOES:t=>e.bindVertexArray(t)}),hd=e=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE:(...t)=>e.drawArraysInstanced(...t),drawElementsInstancedANGLE:(...t)=>e.drawElementsInstanced(...t),vertexAttribDivisorANGLE:(...t)=>e.vertexAttribDivisor(...t)});async function dd(e,t){const n=document.getElementsByTagName("head")[0];if(!n)throw new Error("loadScript");const r=document.createElement("script");return r.setAttribute("type","text/javascript"),r.setAttribute("src",e),new Promise((t,i)=>{r.onload=t,r.onerror=t=>i(new Error(`Unable to load script '${e}': ${t}`)),n.appendChild(r)})}let fd=null,pd=!1;const gd={debugSpectorJS:Nr.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};function md(e){return e.luma=e.luma||{},e.luma}function _d(e,t={}){return t.debugWebGL||t.traceWebGL?function(e,t){if(!globalThis.WebGLDebugUtils)return Nr.warn("webgl-debug not loaded")(),e;const n=md(e);if(n.debugContext)return n.debugContext;globalThis.WebGLDebugUtils.init({...ad,...e});const r=globalThis.WebGLDebugUtils.makeDebugContext(e,vd.bind(null,t),yd.bind(null,t));for(const o in ad)o in r||"number"!=typeof ad[o]||(r[o]=ad[o]);class i{}Object.setPrototypeOf(r,Object.getPrototypeOf(e)),Object.setPrototypeOf(i,r);const s=Object.create(i);return n.realContext=e,n.debugContext=s,s.debug=!0,s}(e,t):function(e){const t=md(e);return t.realContext?t.realContext:e}(e)}function bd(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 vd(e,t,n,r){r=Array.from(r).map(e=>void 0===e?"undefined":e);const i=`${globalThis.WebGLDebugUtils.glEnumToString(t)} in gl.${n}(${globalThis.WebGLDebugUtils.glFunctionArgsToString(n,r)})`;Nr.error(i)()}function yd(e,t,n){let r="";Nr.level>=1&&(r=bd(t,n),e.traceWebGL&&Nr.log(1,r)());for(const i of n)void 0===i&&(r=r||bd(t,n))}const wd=new class extends _i{constructor(){super(),r(this,"type","webgl"),fi.defaultProps={...fi.defaultProps,...gd}}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={...ld,WEBGL_disjoint_timer_query:e.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:cd(e),OES_vertex_array_object:ud(e),ANGLE_instanced_arrays:hd(e)},n=e.getExtension;e.getExtension=function(r){return n.call(e,r)||(r in t?t[r]:null)};const r=e.getSupportedExtensions;e.getSupportedExtensions=function(){const n=r.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&&Nr.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:n}=await l(async()=>{const{WebGLDevice:e}=await Promise.resolve().then(()=>ep);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 r=!0===t.createCanvasContext?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...r}})}async create(e={}){const{WebGLDevice:t}=await l(async()=>{const{WebGLDevice:e}=await Promise.resolve().then(()=>ep);return{WebGLDevice:e}},void 0);Nr.groupCollapsed(1,"WebGLDevice created")();try{const n=[];(e.debugWebGL||e.debug)&&n.push(async function(){Ve()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await dd("https://unpkg.com/webgl-debug@2.0.1/index.js"))}()),e.debugSpectorJS&&n.push(async function(e){if(!globalThis.SPECTOR)try{await dd(e.debugSpectorJSUrl||gd.debugSpectorJSUrl)}catch(t){Nr.warn(String(t))}}(e));const r=await Promise.allSettled(n);for(const e of r)"rejected"===e.status&&Nr.error(`Failed to initialize debug libraries ${e.reason}`)();const i=new t(e),s=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return Nr.probe(1,s)(),Nr.table(1,i.info)(),i}finally{Nr.groupEnd(1)()}}},xd={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},Ed=(e,t,n)=>t?e.enable(n):e.disable(n),Td=(e,t,n)=>e.hint(n,t),Sd=(e,t,n)=>e.pixelStorei(n,t),Cd=(e,t,n)=>{const r=36006===n?36009:36008;return e.bindFramebuffer(r,t)},kd=(e,t,n)=>{const r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[n];e.bindBuffer(r,t)};function Rd(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}const Pd={3042:Ed,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:Ed,2885:(e,t)=>e.cullFace(t),2929:Ed,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:Ed,35723:Td,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:Cd,36010:Cd,34964:kd,36662:kd,36663:kd,35053:kd,35055:kd,2886:(e,t)=>e.frontFace(t),33170:Td,2849:(e,t)=>e.lineWidth(t),32823:Ed,32824:"polygonOffset",10752:"polygonOffset",35977:Ed,32926:Ed,32928:Ed,32938:"sampleCoverage",32939:"sampleCoverage",3089:Ed,3088:(e,t)=>e.scissor(...t),2960:Ed,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:Ed,10754:Ed,12288:Ed,12289:Ed,12290:Ed,12291:Ed,12292:Ed,12293:Ed,12294:Ed,12295:Ed,3333:Sd,3317:Sd,37440:Sd,37441:Sd,37443:Sd,3330:Sd,3332:Sd,3331:Sd,3314:Sd,32878:Sd,3316:Sd,3315:Sd,32877:Sd,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=Rd(t)?t:[t,t];const[n,r]=t;e.stencilMaskSeparate(1028,n),e.stencilMaskSeparate(1029,r)},stencilFunc:(e,t)=>{t=Rd(t)&&3===t.length?[...t,...t]:t;const[n,r,i,s,o,a]=t;e.stencilFuncSeparate(1028,n,r,i),e.stencilFuncSeparate(1029,s,o,a)},stencilOp:(e,t)=>{t=Rd(t)&&3===t.length?[...t,...t]:t;const[n,r,i,s,o,a]=t;e.stencilOpSeparate(1028,n,r,i),e.stencilOpSeparate(1029,s,o,a)},viewport:(e,t)=>e.viewport(...t)};function Id(e,t,n){return void 0!==t[e]?t[e]:n[e]}const Md={blendEquation:(e,t,n)=>e.blendEquationSeparate(Id(32777,t,n),Id(34877,t,n)),blendFunc:(e,t,n)=>e.blendFuncSeparate(Id(32969,t,n),Id(32968,t,n),Id(32971,t,n),Id(32970,t,n)),polygonOffset:(e,t,n)=>e.polygonOffset(Id(32824,t,n),Id(10752,t,n)),sampleCoverage:(e,t,n)=>e.sampleCoverage(Id(32938,t,n),Id(32939,t,n)),stencilFuncFront:(e,t,n)=>e.stencilFuncSeparate(1028,Id(2962,t,n),Id(2967,t,n),Id(2963,t,n)),stencilFuncBack:(e,t,n)=>e.stencilFuncSeparate(1029,Id(34816,t,n),Id(36003,t,n),Id(36004,t,n)),stencilOpFront:(e,t,n)=>e.stencilOpSeparate(1028,Id(2964,t,n),Id(2965,t,n),Id(2966,t,n)),stencilOpBack:(e,t,n)=>e.stencilOpSeparate(1029,Id(34817,t,n),Id(34818,t,n),Id(34819,t,n))},Ld={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 r={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return r?e({[r]:n}):{valueChanged:!0}},blendColor:(e,t,n,r,i)=>e({32773:new Float32Array([t,n,r,i])}),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,r,i)=>e({32969:t,32968:n,32971:r,32970:i}),clearColor:(e,t,n,r,i)=>e({3106:new Float32Array([t,n,r,i])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,n,r,i)=>e({3107:[t,n,r,i]}),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,r,i)=>e({3088:new Int32Array([t,n,r,i])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,n)=>e({[1028===t?2968:36005]:n}),stencilFunc:(e,t,n,r)=>e({2962:t,2967:n,2963:r,34816:t,36003:n,36004:r}),stencilFuncSeparate:(e,t,n,r,i)=>e({[1028===t?2962:34816]:n,[1028===t?2967:36003]:r,[1028===t?2963:36004]:i}),stencilOp:(e,t,n,r)=>e({2964:t,2965:n,2966:r,34817:t,34818:n,34819:r}),stencilOpSeparate:(e,t,n,r,i)=>e({[1028===t?2964:34817]:n,[1028===t?2965:34818]:r,[1028===t?2966:34819]:i}),viewport:(e,t,n,r,i)=>e({2978:[t,n,r,i]})},Nd=(e,t)=>e.isEnabled(t),Bd={3042:Nd,2884:Nd,2929:Nd,3024:Nd,32823:Nd,32926:Nd,32928:Nd,3089:Nd,2960:Nd,35977:Nd},Dd=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 Od(e,t){if(function(e){for(const t in e)return!1;return!0}(t))return;const n={};for(const i in t){const r=Number(i),s=Pd[i];s&&("string"==typeof s?n[s]=!0:s(e,t[i],r))}const r=e.state&&e.state.cache;if(r)for(const i in n)(0,Md[i])(e,t,r)}function Fd(e,t=xd){if("number"==typeof t){const n=t,r=Bd[n];return r?r(e,n):e.getParameter(n)}const n=Array.isArray(t)?t:Object.keys(t),r={};for(const i of n){const t=Bd[i];r[i]=t?t(e,Number(i)):e.getParameter(Number(i))}return r}function Ud(e,t){if(e===t)return!0;if(jd(e)&&jd(t)&&e.length===t.length){for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}return!1}function jd(e){return Array.isArray(e)||ArrayBuffer.isView(e)}class Gd{constructor(e,t){r(this,"gl"),r(this,"program",null),r(this,"stateStack",[]),r(this,"enable",!0),r(this,"cache",null),r(this,"log"),r(this,"initialized",!1),this.gl=e,this.log=(null==t?void 0:t.log)||(()=>{}),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];Od(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=(null==t?void 0:t.copyState)?Fd(e):Object.assign({},xd),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 r=Gd.get(e);r.program!==n&&(t(n),r.program=n)}}(e);for(const n in Ld)Vd(e,n,Ld[n]);zd(e,"getParameter"),zd(e,"isEnabled")}_updateCache(e){let t,n=!1;const r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const i in e){const s=e[i],o=this.cache[i];Ud(s,o)||(n=!0,t=o,r&&!(i in r)&&(r[i]=o),this.cache[i]=s)}return{valueChanged:n,oldValue:t}}}function zd(e,t){const n=e[t].bind(e);e[t]=function(t){if(void 0===t||Dd.has(t))return n(t);const r=Gd.get(e);return t in r.cache||(r.cache[t]=n(t)),r.enable?r.cache[t]:n(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function Vd(e,t,n){if(!e[t])return;const r=e[t].bind(e);e[t]=function(...t){const i=Gd.get(e),{valueChanged:s,oldValue:o}=n(i._updateCache,...t);return s&&r(...t),o},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function Wd(e,t,n){return void 0===n[t]&&(n[t]=e.getExtension(t)||null),n[t]}function Hd(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 $d(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 Xd="WEBGL_compressed_texture_s3tc",Qd="WEBGL_compressed_texture_s3tc_srgb",Yd="EXT_texture_compression_rgtc",qd="EXT_texture_compression_bptc",Kd="EXT_texture_norm16",Zd="EXT_render_snorm",Jd={"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":[Zd],"norm16-renderable-webgl":[Kd],"snorm16-renderable-webgl":[Kd,Zd],"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":[Xd,Qd,Yd,qd],"texture-compression-bc5-webgl":[Yd],"texture-compression-bc7-webgl":[qd],"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"]},ef={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:Xd},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Qd},"bc1-rgba-unorm":{gl:33777,x:Xd},"bc1-rgba-unorm-srgb":{gl:35916,x:Qd},"bc2-rgba-unorm":{gl:33778,x:Xd},"bc2-rgba-unorm-srgb":{gl:35918,x:Qd},"bc3-rgba-unorm":{gl:33779,x:Xd},"bc3-rgba-unorm-srgb":{gl:35919,x:Qd},"bc4-r-unorm":{gl:36283,x:Yd},"bc4-r-snorm":{gl:36284,x:Yd},"bc5-rg-unorm":{gl:36285,x:Yd},"bc5-rg-snorm":{gl:36286,x:Yd},"bc6h-rgb-ufloat":{gl:36495,x:qd},"bc6h-rgb-float":{gl:36494,x:qd},"bc7-rgba-unorm":{gl:36492,x:qd},"bc7-rgba-unorm-srgb":{gl:36493,x:qd},"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 tf(e){var t;const n=ef[e],r=function(e){const t=ef[e],n=null==t?void 0:t.gl;if(void 0===n)throw new Error(`Unsupported texture format ${e}`);return n}(e),i=li.getInfo(e);return i.compressed&&(n.dataFormat=r),{internalFormat:r,format:(null==n?void 0:n.dataFormat)||nf(i.channels,i.integer,i.normalized,r),type:i.dataType?$d(i.dataType):(null==(t=null==n?void 0:n.types)?void 0:t[0])||5121,compressed:i.compressed||!1}}function nf(e,t,n,r){if(6408===r||6407===r)return r;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 rf={"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 sf extends hi{constructor(e,t,n){super([],n),r(this,"gl"),r(this,"extensions"),r(this,"testedFeatures",new Set),this.gl=e,this.extensions=t,Wd(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 Jd}(e)&&function(e,t,n){return(Jd[t]||[]).every(t=>Wd(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(rf),...Object.keys(Jd)]}getWebGLFeature(e){const t=rf[e];return"string"==typeof t?Boolean(Wd(this.gl,t,this.extensions)):Boolean(t)}}class of extends ui{constructor(e){super(),r(this,"gl"),r(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 af extends Ui{constructor(e,t){super(e,t),r(this,"device"),r(this,"gl"),r(this,"handle"),r(this,"colorAttachments",[]),r(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.colorAttachments.length;++t){const e=this.colorAttachments[t];if(e){const n=36064+t;this._attachTextureView(n,e)}}if(this.depthStencilAttachment){const e=function(e){switch(li.getInfo(e).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${e}`)}}(this.depthStencilAttachment.props.format);this._attachTextureView(e,this.depthStencilAttachment)}if(this.device.props.debug){const e=this.gl.checkFramebufferStatus(36160);if(36053!==e)throw new Error(`Framebuffer ${function(e){switch(e){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${e}`}}(e)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,t){const{gl:n}=this.device,{texture:r}=t,i=t.props.baseMipLevel,s=t.props.baseArrayLayer;switch(n.bindTexture(r.glTarget,r.handle),r.glTarget){case 35866:case 32879:n.framebufferTextureLayer(36160,e,r.handle,i,s);break;case 34067:const t=function(e){return e<34069?e+34069:e}(s);n.framebufferTexture2D(36160,e,t,r.handle,i);break;case 3553:n.framebufferTexture2D(36160,e,3553,r.handle,i);break;default:throw new Error("Illegal texture type")}n.bindTexture(r.glTarget,null)}}class Af extends xi{constructor(e,t){super(t),r(this,"device"),r(this,"handle",null),r(this,"_framebuffer",null),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._updateDevice()}get[Symbol.toStringTag](){return"WebGLCanvasContext"}getCurrentFramebuffer(){return this._framebuffer=this._framebuffer||new af(this.device,{handle:null}),this._framebuffer}_updateDevice(){}}const lf={};function cf(e="id"){return lf[e]=lf[e]||1,`${e}-${lf[e]++}`}class uf extends Ur{constructor(e,t={}){super(e,t),r(this,"device"),r(this,"gl"),r(this,"handle"),r(this,"glTarget"),r(this,"glUsage"),r(this,"glIndexType",5123),r(this,"byteLength",0),r(this,"bytesUsed",0),this.device=e,this.gl=this.device.gl;const n="object"==typeof t?t.handle:void 0;var i;this.handle=n||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=(i=this.props.usage)&Ur.INDEX?34963:i&Ur.VERTEX?34962:i&Ur.UNIFORM?35345:34962,this.glUsage=function(e){return e&Ur.INDEX||e&Ur.VERTEX?35044:e&Ur.UNIFORM?35048:35044}(this.props.usage),this.glIndexType="uint32"===this.props.indexType?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,n=e.byteLength+t){const r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,n,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,t,n),this.trackAllocatedMemory(n)}_initWithByteLength(e){let t=e;0===e&&(t=new Float32Array(0));const n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,t,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}write(e,t=0){const n=ArrayBuffer.isView(e)?e:new Uint8Array(e),r=36663;this.gl.bindBuffer(r,this.handle),this.gl.bufferSubData(r,t,n),this.gl.bindBuffer(r,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,n=this.byteLength-t){const r=new ArrayBuffer(n);await e(r,"copied"),this.write(r,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,n){const r=await this.readAsync(t,n);return await e(r.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;const n=new Uint8Array(t);return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,n,0,t),this.gl.bindBuffer(36662,null),this._setDebugData(n,e,t),n}}function hf(e){const t=e.toLowerCase();return["warning","error","info"].includes(t)?t:"info"}class df extends Di{constructor(e,t){switch(super(e,t),r(this,"device"),r(this,"handle"),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(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 r of t){if(r.length<=1)continue;const e=r.split(":");if(2===e.length){const[t,r]=e;n.push({message:r.trim(),type:hf(t),lineNum:0,linePos:0});continue}const[t,i,s,...o]=e;let a=parseInt(s,10);isNaN(a)&&(a=0);let A=parseInt(i,10);isNaN(A)&&(A=0),n.push({message:o.join(":").trim(),type:hf(t),lineNum:a,linePos:A})}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"))Nr.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),Nr.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 ff(e,t){return _f(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function pf(e,t){return _f(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function gf(e,t){return _f(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function mf(e,t,n="color"){return _f(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 _f(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 bf(e){const t={};return e.addressModeU&&(t[10242]=vf(e.addressModeU)),e.addressModeV&&(t[10243]=vf(e.addressModeV)),e.addressModeW&&(t[32882]=vf(e.addressModeW)),e.magFilter&&(t[10240]=yf(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=function(e,t="none"){if(!t)return yf(e);switch(t){case"none":return yf(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]=ff("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function vf(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function yf(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}class wf extends Ci{constructor(e,t){super(e,t),r(this,"device"),r(this,"handle"),r(this,"parameters"),this.device=e,this.parameters=bf(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 xf(e,t,n){if(function(e){for(const t in e)return!1;return!0}(t))return n(e);const{nocatch:r=!0}=t,i=Gd.get(e);let s;if(i.push(),Od(e,t),r)s=n(e),i.pop();else try{s=n(e)}finally{i.pop()}return s}class Ef extends Mi{constructor(e,t){super(e,{...Pi.defaultProps,...t}),r(this,"device"),r(this,"gl"),r(this,"handle"),r(this,"texture"),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}class Tf extends Pi{constructor(e,t){super(e,t),r(this,"device"),r(this,"gl"),r(this,"handle"),r(this,"sampler"),r(this,"view"),r(this,"glTarget"),r(this,"glFormat"),r(this,"glType"),r(this,"glInternalFormat"),r(this,"compressed"),r(this,"_textureUnit",0),this.device=e,this.gl=this.device.gl;const n=tf(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:i,width:s,height:o,depth:a,mipLevels:A,glTarget:l,glInternalFormat:c}=this;switch(i){case"2d":case"cube":this.gl.texStorage2D(l,A,c,s,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,A,c,s,o,a);break;default:throw new Error(i)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data),this.setSampler(this.props.sampler),this.view=new Ef(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 Ef(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);const t=bf(this.sampler.props);this._setSamplerParameters(t)}copyImageData(e){const t=this._normalizeCopyImageDataOptions(e),n=t.data,{width:r,height:i,depth:s}=this,{mipLevel:o=0,byteOffset:a=0,x:A=0,y:l=0,z:c=0}=t,{glFormat:u,glType:h,compressed:d}=this,f=Sf(this.glTarget,this.dimension,c);let p;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}`);p=t.bytesPerRow/e}}const g=this.compressed?{}:{...void 0!==p?{3314:p}:{},32878:t.rowsPerImage};this.gl.bindTexture(f,this.handle),xf(this.gl,g,()=>{switch(this.dimension){case"2d":case"cube":d?this.gl.compressedTexSubImage2D(f,o,A,l,r,i,u,n,a):this.gl.texSubImage2D(f,o,A,l,r,i,u,h,n,a);break;case"2d-array":case"3d":d?this.gl.compressedTexSubImage3D(f,o,A,l,c,r,i,s,u,n,a):this.gl.texSubImage3D(f,o,A,l,c,r,i,s,u,h,n,a)}}),this.gl.bindTexture(f,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:r}=this,{image:i,depth:s,mipLevel:o,x:a,y:A,z:l,width:c,height:u}=t,h=Sf(this.glTarget,this.dimension,s),d=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),xf(this.gl,d,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,o,a,A,c,u,n,r,i);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,o,a,A,l,c,u,s,n,r,i)}}),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)||(Nr.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){Nr.warn(`Error generating mipmap for ${this}: ${t.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){Nr.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),r=n;switch(e){case 33082:case 33083:this.gl.texParameterf(this.glTarget,e,r);break;case 10240:case 10241:case 10242:case 10243:case 32882:case 34892:case 34893:this.gl.texParameteri(this.glTarget,e,r);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,e,r)}}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 Sf(e,t,n){return"cube"===t?34069+n:e}function Cf(e){return Pf[e]}function kf(e){return Boolean(If[e])}function Rf(e){return If[e]}const Pf={5126:"f32",35664:"vec2<f32>",35665:"vec3<f32>",35666:"vec4<f32>",5124:"i32",35667:"vec2<i32>",35668:"vec3<i32>",35669:"vec4<i32>",5125:"u32",36294:"vec2<u32>",36295:"vec3<u32>",36296:"vec4<u32>",35670:"f32",35671:"vec2<f32>",35672:"vec3<f32>",35673:"vec4<f32>",35674:"mat2x2<f32>",35685:"mat2x3<f32>",35686:"mat2x4<f32>",35687:"mat3x2<f32>",35675:"mat3x3<f32>",35688:"mat3x4<f32>",35689:"mat4x2<f32>",35690:"mat4x3<f32>",35676:"mat4x4<f32>"},If={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"}},Mf={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 Lf(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 Nf(e,t,n,r){const i=e;let s=r;!0===s&&(s=1),!1===s&&(s=0);const o="number"==typeof s?[s]:s;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 r)throw new Error("samplers must be set to integers");return e.uniform1i(t,r);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 i.uniform1uiv(t,o,1);case 36294:return i.uniform2uiv(t,o,2);case 36295:return i.uniform3uiv(t,o,3);case 36296:return i.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 i.uniformMatrix2x3fv(t,!1,o);case 35686:return i.uniformMatrix2x4fv(t,!1,o);case 35687:return i.uniformMatrix3x2fv(t,!1,o);case 35688:return i.uniformMatrix3x4fv(t,!1,o);case 35689:return i.uniformMatrix4x2fv(t,!1,o);case 35690:return i.uniformMatrix4x3fv(t,!1,o)}throw new Error("Illegal uniform")}class Bf extends Gi{constructor(e,t){super(e,t),r(this,"device"),r(this,"handle"),r(this,"vs"),r(this,"fs"),r(this,"introspectedLayout"),r(this,"uniforms",{}),r(this,"bindings",{}),r(this,"varyings",null),r(this,"_uniformCount",0),r(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:i=35981}=t;n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,i)),this._linkShaders(),Nr.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=function(e,t){const n={attributes:[],bindings:[]};n.attributes=function(e,t){const n=[],r=e.getProgramParameter(t,35721);for(let i=0;i<r;i++){const r=e.getActiveAttrib(t,i);if(!r)throw new Error("activeInfo");const{name:s,type:o}=r,a=e.getAttribLocation(t,s);if(a>=0){const e=Cf(o),t=/instance/i.test(s)?"instance":"vertex";n.push({name:s,location:a,stepMode:t,type:e})}}return n.sort((e,t)=>e.location-t.location),n}(e,t);const r=function(e,t){const n=(n,r)=>e.getActiveUniformBlockParameter(t,n,r),r=[],i=e.getProgramParameter(t,35382);for(let s=0;s<i;s++){const i={name:e.getActiveUniformBlockName(t,s)||"",location:n(s,35391),byteLength:n(s,35392),vertex:n(s,35396),fragment:n(s,35398),uniformCount:n(s,35394),uniforms:[]},o=n(s,35395)||[],a=e.getActiveUniforms(t,o,35383),A=e.getActiveUniforms(t,o,35384),l=e.getActiveUniforms(t,o,35387),c=e.getActiveUniforms(t,o,35388);for(let n=0;n<i.uniformCount;++n){const r=e.getActiveUniform(t,o[n]);if(!r)throw new Error("activeInfo");const s=Cf(a[n]);i.uniforms.push({name:r.name,format:s,type:a[n],arrayLength:A[n],byteOffset:l[n],byteStride:c[n]})}r.push(i)}return r.sort((e,t)=>e.location-t.location),r}(e,t);for(const a of r){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 i=function(e,t){const n=[],r=e.getProgramParameter(t,35718);for(let i=0;i<r;i++){const r=e.getActiveUniform(t,i);if(!r)throw new Error("activeInfo");const{name:s,size:o,type:a}=r,{name:A,isArray:l}=Lf(s);let c=e.getUniformLocation(t,A);const u={location:c,name:A,size:o,type:a,isArray:l};if(n.push(u),u.size>1)for(let i=0;i<u.size;i++){const r=`${A}[${i}]`;c=e.getUniformLocation(t,r);const s={...u,name:r,location:c};n.push(s)}}return n}(e,t);let s=0;for(const a of i)if(kf(a.type)){const{viewDimension:e,sampleType:t}=Rf(a.type);n.bindings.push({type:"texture",name:a.name,group:0,location:s,viewDimension:e,sampleType:t}),a.textureUnit=s,s+=1}i.length&&(n.uniforms=i);const o=function(e,t){const n=[],r=e.getProgramParameter(t,35971);for(let i=0;i<r;i++){const r=e.getTransformFeedbackVarying(t,i);if(!r)throw new Error("activeInfo");const{name:s,type:o,size:a}=r,A=Cf(o),{type:l,components:c}=qi(A);n.push({location:i,name:s,type:l,size:a*c})}return n.sort((e,t)=>e.location-t.location),n}(e,t);return(null==o?void 0:o.length)&&(n.varyings=o),n}(this.device.gl,this.handle),Nr.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 r of(null==t?void 0:t.attributes)||[]){const e=n.attributes.find(e=>e.name===r.name);e?(e.type=r.type||e.type,e.stepMode=r.stepMode||e.stepMode):Nr.warn(`shader layout attribute ${r.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,r]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)||Nr.warn(`No binding "${n}" in render pipeline "${this.id}", expected one of ${e}`,r)();continue}switch(r||Nr.warn(`Unsetting binding "${n}" in render pipeline "${this.id}"`)(),e.type){case"uniform":if(!(r instanceof uf||r.buffer instanceof uf))throw new Error("buffer value");break;case"texture":if(!(r instanceof Ef||r instanceof Tf||r instanceof af))throw new Error(`${this} Bad texture binding for ${n}`);break;case"sampler":Nr.warn(`Ignoring sampler ${n}`)();break;default:throw new Error(e.type)}this.bindings[n]=r}}draw(e){var t;const{renderPass:n,parameters:r=this.props.parameters,topology:i=this.props.topology,vertexArray:s,vertexCount:o,instanceCount:a,isInstanced:A=!1,firstVertex:l=0,transformFeedback:c}=e,u=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)}}(i),h=Boolean(s.indexBuffer),d=null==(t=s.indexBuffer)?void 0:t.glIndexType;if("success"!==this.linkStatus)return Nr.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return Nr.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),s.bindBeforeRender(n),c&&c.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const f=n;return function(e,t,n,r){if(function(e){let t=!0;for(const n in e){t=!1;break}return t}(t))return r(e);const i=e;i.pushState();try{return function(e,t){const n=e,{gl:r}=n;if(t.cullMode)switch(t.cullMode){case"none":r.disable(2884);break;case"front":r.enable(2884),r.cullFace(1028);break;case"back":r.enable(2884),r.cullFace(1029)}if(t.frontFace&&r.frontFace(_f("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&r.enable(34383),void 0!==t.depthBias&&(r.enable(32823),r.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has("provoking-vertex-webgl")){const e=n.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,r=_f("provokingVertex",t.provokingVertex,{first:36429,last:36430});null==e||e.provokingVertexWEBGL(r)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){const e=n.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,r=_f("polygonMode",t.polygonMode,{fill:6914,line:6913});null==e||e.polygonModeWEBGL(1028,r),null==e||e.polygonModeWEBGL(1029,r)}t.polygonOffsetLine&&r.enable(10754)}if(e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&r.enable(12288),t.clipDistance1&&r.enable(12289),t.clipDistance2&&r.enable(12290),t.clipDistance3&&r.enable(12291),t.clipDistance4&&r.enable(12292),t.clipDistance5&&r.enable(12293),t.clipDistance6&&r.enable(12294),t.clipDistance7&&r.enable(12295)),void 0!==t.depthWriteEnabled&&r.depthMask(t.depthWriteEnabled),t.depthCompare&&("always"!==t.depthCompare?r.enable(2929):r.disable(2929),r.depthFunc(ff("depthCompare",t.depthCompare))),t.stencilWriteMask){const e=t.stencilWriteMask;r.stencilMaskSeparate(1028,e),r.stencilMaskSeparate(1029,e)}if(t.stencilReadMask&&Nr.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){const e=t.stencilReadMask||4294967295,n=ff("depthCompare",t.stencilCompare);"always"!==t.stencilCompare?r.enable(2960):r.disable(2960),r.stencilFuncSeparate(1028,n,0,e),r.stencilFuncSeparate(1029,n,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){const e=pf("stencilPassOperation",t.stencilPassOperation),n=pf("stencilFailOperation",t.stencilFailOperation),i=pf("stencilDepthFailOperation",t.stencilDepthFailOperation);r.stencilOpSeparate(1028,n,i,e),r.stencilOpSeparate(1029,n,i,e)}switch(t.blend){case!0:r.enable(3042);break;case!1:r.disable(3042)}if(t.blendColorOperation||t.blendAlphaOperation){const e=gf("blendColorOperation",t.blendColorOperation||"add"),n=gf("blendAlphaOperation",t.blendAlphaOperation||"add");r.blendEquationSeparate(e,n);const i=mf("blendColorSrcFactor",t.blendColorSrcFactor||"one"),s=mf("blendColorDstFactor",t.blendColorDstFactor||"zero"),o=mf("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),a=mf("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");r.blendFuncSeparate(i,s,o,a)}}(e,t),Od(i.gl,n),r(e)}finally{i.popState()}}(this.device,r,f.glParameters,()=>{h&&A?this.device.gl.drawElementsInstanced(u,o||0,d,l,a||0):h?this.device.gl.drawElements(u,o||0,d,l):A?this.device.gl.drawArraysInstanced(u,l,o||0,a||0):this.device.gl.drawArrays(u,l,o||0),c&&c.end()}),s.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),Nr.time(4,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),Nr.timeEnd(4,`linkProgram for ${this.id}`)(),Nr.level,!this.device.features.has("compilation-status-async-webgl")){const e=this._getLinkStatus();return void this._reportLinkStatus(e)}Nr.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),Nr.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 r=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${n} during ${e}: ${r}`),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$/,"")]||(Nr.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 r of this.shaderLayout.bindings){const i=this.bindings[r.name]||this.bindings[r.name.replace(/Uniforms$/,"")];if(!i)throw new Error(`No value for binding ${r.name} in ${this.id}`);switch(r.type){case"uniform":const{name:s}=r,o=e.getUniformBlockIndex(this.handle,s);if(4294967295===o)throw new Error(`Invalid uniform block name ${s}`);e.uniformBlockBinding(this.handle,n,o),i instanceof uf?e.bindBufferBase(35345,n,i.handle):e.bindBufferRange(35345,n,i.buffer.handle,i.offset||0,i.size||i.buffer.byteLength-i.offset),n+=1;break;case"texture":if(!(i instanceof Ef||i instanceof Tf||i instanceof af))throw new Error("texture");let a;if(i instanceof Ef)a=i.texture;else if(i instanceof Tf)a=i;else{if(!(i instanceof af&&i.colorAttachments[0]instanceof Ef))throw new Error("No texture");Nr.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),a=i.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 '${r.type}' not supported in WebGL`)}}}_applyUniforms(){for(const e of this.shaderLayout.uniforms||[]){const{name:t,location:n,type:r,textureUnit:i}=e,s=this.uniforms[t]??i;void 0!==s&&Nf(this.device.gl,n,r,s)}}}class Df extends Yi{constructor(e){super(e,{}),r(this,"device"),r(this,"handle",null),r(this,"commands",[]),this.device=e}_executeCommands(e=this.commands){for(const t of e)switch(t.name){case"copy-buffer-to-buffer":Of(this.device,t.options);break;case"copy-buffer-to-texture":Ff(this.device,t.options);break;case"copy-texture-to-buffer":Uf(this.device,t.options);break;case"copy-texture-to-texture":jf(this.device,t.options);break;default:throw new Error(t.name)}}}function Of(e,t){const n=t.sourceBuffer,r=t.destinationBuffer;e.gl.bindBuffer(36662,n.handle),e.gl.bindBuffer(36663,r.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 Ff(e,t){throw new Error("Not implemented")}function Uf(e,t){const{sourceTexture:n,mipLevel:r=0,aspect:i="all",width:s=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:a=0,origin:A=[0,0],destinationBuffer:l,byteOffset:c=0,bytesPerRow:u,rowsPerImage:h}=t;if("all"!==i)throw new Error("aspect not supported in WebGL");if(0!==r||0!==a||u||h)throw new Error("not implemented");const{framebuffer:d,destroyFramebuffer:f}=Gf(n);let p;try{const t=l,n=s||d.width,r=o||d.height,i=tf(d.colorAttachments[0].texture.props.format),a=i.format,u=i.type;e.gl.bindBuffer(35051,t.handle),p=e.gl.bindFramebuffer(36160,d.handle),e.gl.readPixels(A[0],A[1],n,r,a,u,c)}finally{e.gl.bindBuffer(35051,null),void 0!==p&&e.gl.bindFramebuffer(36160,p),f&&d.destroy()}}function jf(e,t){const{sourceTexture:n,destinationMipLevel:r=0,origin:i=[0,0],destinationOrigin:s=[0,0],destinationTexture:o}=t;let{width:a=t.destinationTexture.width,height:A=t.destinationTexture.height}=t;const{framebuffer:l,destroyFramebuffer:c}=Gf(n),[u,h]=i,[d,f,p]=s,g=e.gl.bindFramebuffer(36160,l.handle);let m,_;if(!(o instanceof Tf))throw new Error("invalid destination");switch(m=o,a=Number.isFinite(a)?a:m.width,A=Number.isFinite(A)?A:m.height,m._bind(0),_=m.glTarget,_){case 3553:case 34067:e.gl.copyTexSubImage2D(_,r,d,f,u,h,a,A);break;case 35866:case 32879:e.gl.copyTexSubImage3D(_,r,d,f,p,u,h,a,A)}m&&m._unbind(),e.gl.bindFramebuffer(36160,g),c&&l.destroy()}function Gf(e){if(e instanceof Pi){const{width:t,height:n,id:r}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${r}`,width:t,height:n,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}const zf=[1,2,4,8];class Vf extends Vi{constructor(e,t){var n;let i;if(super(e,t),r(this,"device"),r(this,"handle",null),r(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;i=[0,0,e,n]}else{const[t,n]=e.getDefaultCanvasContext().getDrawingBufferSize();i=[0,0,t,n]}this.device.pushState(),this.setParameters({viewport:i,...this.props.parameters});const s=this.props.framebuffer;if(this.props.framebuffer&&(null==s?void 0:s.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=zf.map(t=>Boolean(t&e.colorMask))),this.glParameters=t,Od(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&&xf(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){xf(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 Wf extends Xi{constructor(e,t){super(e,t),r(this,"device"),r(this,"handle",null),r(this,"commandBuffer"),this.device=e,this.commandBuffer=new Df(e)}destroy(){}finish(){return this.commandBuffer}beginRenderPass(e){return new Vf(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 Hf extends rs{constructor(e,t){super(e,t),r(this,"device"),r(this,"handle"),r(this,"buffer",null),r(this,"bufferValue",null),this.device=e,this.handle=this.device.gl.createVertexArray()}get[Symbol.toStringTag](){return"VertexArray"}static isConstantAttributeZeroSupported(e){return"Chrome"==(Ve()?ze()?"Electron":(Ge.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:r,type:i,stride:s,offset:o,normalized:a,integer:A,divisor:l}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),A?this.device.gl.vertexAttribIPointer(e,r,i,s,o):this.device.gl.vertexAttribPointer(e,r,i,a,s,o),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,l||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<this.maxVertexAttributes;++e){const t=this.attributes[e];ArrayBuffer.isView(t)&&this.device.setConstantAttributeWebGL(e,t)}}_getAccessor(e){const t=this.attributeInfos[e];if(!t)throw new Error(`Unknown attribute location ${e}`);const n=$d(t.bufferDataType);return{size:t.bufferComponents,type:n,stride:t.byteStride,offset:t.byteOffset,normalized:t.normalized,integer:t.integer,divisor:"instance"===t.stepMode?1:0}}_enable(e,t=!0){const n=Hf.isConstantAttributeZeroSupported(this.device);(t||n||0!==e)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),t?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,t){const n=(s=t,Array.isArray(s)?new Float32Array(s):s),r=n.byteLength*e,i=n.length*e;var s;if(this.buffer&&r!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${r} !== ${this.buffer.byteLength}.`);let o=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:r}),o||(o=!function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(n,this.bufferValue)),o){const e=function(e,t){return new e(ls(e.BYTES_PER_ELEMENT*t),0,t)}(t.constructor,i);!function(e){const{target:t,source:n,start:r=0,count:i=1}=e,s=n.length,o=i*s;let a=0;for(let A=r;a<s;a++)t[A++]=n[a];for(;a<o;)a<o-a?(t.copyWithin(r+a,r,r+a),a*=2):(t.copyWithin(r+a,r,r+o-a),a=o)}({target:e,source:n,start:0,count:i}),this.buffer.write(e),this.bufferValue=t}return this.buffer}}class $f extends ss{constructor(e,t){super(e,t),r(this,"device"),r(this,"gl"),r(this,"handle"),r(this,"layout"),r(this,"buffers",{}),r(this,"unusedBuffers",{}),r(this,"bindOnUse",!0),r(this,"_bound",!1),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(function(e){switch(e){case"point-list":return 0;case"line-list":case"line-strip":return 1;case"triangle-list":case"triangle-strip":return 4;default:throw new Error(e)}}(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(const t in e)this.setBuffer(t,e[t])})}setBuffer(e,t){const n=this._getVaryingIndex(e),{buffer:r,byteLength:i,byteOffset:s}=this._getBufferRange(t);if(n<0)return this.unusedBuffers[e]=r,void Nr.warn(`${this.id} unusedBuffers varying buffer ${e}`)();this.buffers[n]={buffer:r,byteLength:i,byteOffset:s},this.bindOnUse||this._bindBuffer(n,r,s,i)}getBuffer(e){if(Xf(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 uf)return{buffer:e,byteOffset:0,byteLength:e.byteLength};const{buffer:t,byteOffset:n=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:n,byteLength:r}}_getVaryingIndex(e){if(Xf(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:r}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,r,n)}}_unbindBuffers(){for(const e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,n=0,r){const i=t&&t.handle;i&&void 0!==r?this.gl.bindBufferRange(35982,e,i,n,r):this.gl.bindBufferBase(35982,e,i)}}function Xf(e){return"number"==typeof e?Number.isInteger(e):/^\d+$/.test(e)}class Qf extends As{constructor(e,t){if(super(e,t),r(this,"device"),r(this,"handle"),r(this,"target",null),r(this,"_queryPending",!1),r(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,r)=>{const i=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):t++>e?(r("Timed out"),this._pollingPromise=null):requestAnimationFrame(i)};requestAnimationFrame(i)}),this._pollingPromise}}function Yf(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 qf={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 Kf(e){return e instanceof Ui?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:Zf(e),deleteFramebuffer:!0}}function Zf(e,t){const{device:n,width:r,height:i,id:s}=e;return n.createFramebuffer({...t,id:`framebuffer-for-${s}`,width:r,height:i,colorAttachments:[e]})}class Jf extends fi{constructor(e){var t,n;super({...e,id:e.id||cf("webgl-device")}),r(this,"type","webgl"),r(this,"handle"),r(this,"features"),r(this,"limits"),r(this,"info"),r(this,"canvasContext"),r(this,"preferredColorFormat","rgba8unorm"),r(this,"preferredDepthFormat","depth24plus"),r(this,"commandEncoder"),r(this,"lost"),r(this,"_resolveContextLost"),r(this,"gl"),r(this,"_constants"),r(this,"_extensions",{}),r(this,"_polyfilled",!1),r(this,"spectorJS");const i=fi._getCanvasContextProps(e);if(!i)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let s=null==(n=null==(t=i.canvas)?void 0:t.gl)?void 0:n.device;if(s)throw new Error(`WebGL context already attached to device ${s.id}`);this.canvasContext=new Af(this,i),this.lost=new Promise(e=>{this._resolveContextLost=e});const o={...e.webgl};"premultiplied"===i.alphaMode&&(o.premultipliedAlpha=!0),void 0!==e.powerPreference&&(o.powerPreference=e.powerPreference);const a=this.props._handle||function(e,t,n){let r="";const i={preserveDrawingBuffer:!0,...n};let s=null;if(s||(s=e.getContext("webgl2",i)),i.failIfMajorPerformanceCaveat&&(r||(r="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.")),s||n.failIfMajorPerformanceCaveat||(i.failIfMajorPerformanceCaveat=!1,s=e.getContext("webgl2",i),s.luma||(s.luma={}),s.luma.softwareRenderer=!0),s||(s=e.getContext("webgl",{}),s&&(s=null,r||(r="Your browser only supports WebGL1"))),!s)throw r||(r="Your browser does not support WebGL"),new Error(`Failed to create WebGL context: ${r}`);const{onContextLost:o,onContextRestored:a}=t;return e.addEventListener("webglcontextlost",e=>o(e),!1),e.addEventListener("webglcontextrestored",e=>a(e),!1),s.luma||(s.luma={}),s}(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(s=a.device,s){if(e._reuseDevices)return Nr.log(1,`Not creating a new Device, instead returning a reference to Device ${s.id} already attached to WebGL context`,s)(),s._reused=!0,s;throw new Error(`WebGL context already attached to device ${s.id}`)}this.handle=a,this.gl=a,this.spectorJS=function(e){var t;if(!(e={...gd,...e}).debugSpectorJS)return null;if(!fd&&globalThis.SPECTOR&&!(null==(t=globalThis.luma)?void 0:t.spector)){Nr.probe(1,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:e}=globalThis.SPECTOR;fd=new e,globalThis.luma&&(globalThis.luma.spector=fd)}if(!fd)return null;if(pd||(pd=!0,fd.spyCanvases(),null==fd||fd.onCaptureStarted.add(e=>Nr.info("Spector capture started:",e)()),null==fd||fd.onCapture.add(e=>{Nr.info("Spector capture complete:",e)(),null==fd||fd.getResultUI(),null==fd||fd.resultView.display(),null==fd||fd.resultView.addCapture(e)})),e.gl){const t=e.gl,n=t.device;null==fd||fd.startCapture(e.gl,500),t.device=n,new Promise(e=>setTimeout(e,2e3)).then(e=>{Nr.info("Spector capture stopped after 2 seconds")(),null==fd||fd.stopCapture()})}return fd}({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=function(e,t){const n=e.getParameter(7936),r=e.getParameter(7937);Wd(e,"WEBGL_debug_renderer_info",t);const i=t.WEBGL_debug_renderer_info,s=e.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936)||n,o=e.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937)||r,a=e.getParameter(7938),A=Hd(s,o),l=function(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?"metal":/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?"opengl":"unknown"}(s,o),c=function(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(Hd(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}(s,o);return{type:"webgl",gpu:A,gpuType:c,gpuBackend:l,vendor:s,renderer:o,version:a,shadingLanguage:"glsl",shadingLanguageVersion:300}}(this.gl,this._extensions),this.limits=new of(this.gl),this.features=new sf(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Gd(this.gl,{log:(...e)=>Nr.log(1,...e)()}).trackState(this.gl,{copyState:!1});const A=e.debugWebGL||e.debug,l=e.debugWebGL;A&&(this.gl=_d(this.gl,{debugWebGL:A,traceWebGL:l}),Nr.warn("WebGL debug mode activated. Performance reduced.")(),e.debugWebGL&&(Nr.level=Math.max(Nr.level,1))),this.commandEncoder=new Wf(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 uf(this,t)}createTexture(e){return new Tf(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new wf(this,e)}createShader(e){return new df(this,e)}createFramebuffer(e){return new af(this,e)}createVertexArray(e){return new Hf(this,e)}createTransformFeedback(e){return new $f(this,e)}createQuerySet(e){return new Qf(this,e)}createRenderPipeline(e){return new Bf(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new Wf(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:r=0,sourceY:i=0,sourceAttachment:s=0}=t||{};let{target:o=null,sourceWidth:a,sourceHeight:A,sourceDepth:l,sourceFormat:c,sourceType:u}=t||{};const{framebuffer:h,deleteFramebuffer:d}=Kf(e),{gl:f,handle:p}=h;a||(a=h.width),A||(A=h.height);const g=null==(n=h.colorAttachments[s])?void 0:n.texture;if(!g)throw new Error(`Invalid framebuffer attachment ${s}`);l=(null==g?void 0:g.depth)||1,c||(c=(null==g?void 0:g.glFormat)||6408),u||(u=(null==g?void 0:g.glType)||5121),m=o,_=u,b=c,v=a,y=A,o=m||(_||(_=5121),new(Vr(qf[_]))(v*y*Yf(b)));var m,_,b,v,y;const w=zr(o);u=u||Mf[w];const x=f.bindFramebuffer(36160,p);return f.readBuffer(36064+s),f.readPixels(r,i,a,A,c,u,o),f.readBuffer(36064),f.bindFramebuffer(36160,x||null),d&&h.destroy(),o}(e,t)}readPixelsToBufferWebGL(e,t){return function(e,t){const{target:n,sourceX:r=0,sourceY:i=0,sourceFormat:s=6408,targetByteOffset:o=0}=t||{};let{sourceWidth:a,sourceHeight:A,sourceType:l}=t||{};const{framebuffer:c,deleteFramebuffer:u}=Kf(e);a=a||c.width,A=A||c.height;const h=c;l=l||5121;let d=n;if(!d){const e=o+a*A*Yf(s)*function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}(l);d=h.device.createBuffer({byteLength:e})}const f=e.device.createCommandEncoder();return f.copyTextureToBuffer({sourceTexture:e,width:a,height:A,origin:[r,i],destinationBuffer:d,byteOffset:o}),f.destroy(),u&&c.destroy(),d}(e,t)}setParametersWebGL(e){Od(this.gl,e)}getParametersWebGL(e){return Fd(this.gl,e)}withParametersWebGL(e,t){return xf(this.gl,e,t)}resetWebGL(){Nr.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Od(this.gl,xd)}_getDeviceSpecificTextureFormatCapabilities(e){return function(e,t,n){let r=t.create;const i=ef[t.format];return void 0===(null==i?void 0:i.gl)&&(r=!1),(null==i?void 0:i.x)&&(r=r&&Boolean(Wd(e,i.x,n))),{format:t.format,create:r&&t.create,render:r&&t.render,filter:r&&t.filter,blend:r&&t.blend,store:r&&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(){Gd.get(this.gl).push()}popState(){Gd.get(this.gl).pop()}getGLKey(e,t){const n=Number(e);for(const r in this.gl)if(this.gl[r]===n)return`GL.${r}`;return(null==t?void 0:t.emptyIfUnknown)?"":String(e)}getGLKeys(e){const t={emptyIfUnknown:!0};return Object.entries(e).reduce((e,[n,r])=>(e[`${n}:${this.getGLKey(n,t)}`]=`${r}:${this.getGLKey(r,t)}`,e),{})}setConstantAttributeWebGL(e,t){const n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);const r=this._constants[e];switch(r&&function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(r,t)&&Nr.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:!function(e,t,n){switch(n.length){case 1:e.gl.vertexAttrib1fv(t,n);break;case 2:e.gl.vertexAttrib2fv(t,n);break;case 3:e.gl.vertexAttrib3fv(t,n);break;case 4:e.gl.vertexAttrib4fv(t,n)}}(this,e,t);break;case Int32Array:!function(e,t,n){e.gl.vertexAttribI4iv(t,n)}(this,e,t);break;case Uint32Array:!function(e,t,n){e.gl.vertexAttribI4uiv(t,n)}(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return Wd(this.gl,e,this._extensions),this._extensions}_setWebGLDebugMetadata(e,t,n){e.luma=t;const r={props:n.spector,id:n.spector.id};e.__SPECTOR_Metadata=r}}const ep=Object.freeze(Object.defineProperty({__proto__:null,WebGLDevice:Jf},Symbol.toStringTag,{value:"Module"}));function tp(){}const np={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:tp,onWebGLInitialized:tp,onResize:tp,onViewStateChange:tp,onInteractionStateChange:tp,onBeforeRender:tp,onAfterRender:tp,onLoad:tp,onError:e=>Hn.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 rp{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 Mt({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=zl[e.type],n=e.offsetCenter;if(!t||!n||!this.layerManager)return;const r=this.layerManager.getLayers(),i=this.deckPicker.getLastPickedObject({x:n.x,y:n.y,layers:r,viewports:this.getViewports(n)},this._lastPointerDownInfo),{layer:s}=i,o=s&&(s[t]||s.props[t]),a=this.props[t];let A=!1;o&&(A=o.call(s,i,e)),A||(null==a||a(i,e),this.widgetManager.onEvent(i,e))},this._onPointerDown=e=>{var t;if("webgpu"===(null==(t=this.device)?void 0:t.type))return;const n=e.offsetCenter,r=this._pick("pickObject","pickObject Time",{x:n.x,y:n.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=r.result[0]||r.emptyInfo},this.props={...np,...e},(e=this.props).viewState&&e.initialViewState&&Hn.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&&Hn.error("WebGL1 context not supported.")();const r=null==(t=this.props.deviceProps)?void 0:t.onResize;n=wd.attach(e.gl,{...this.props.deviceProps,onResize:(e,t)=>{const{width:n,height:i}=e.canvas;e.drawingBufferWidth=n,e.drawingBufferHeight=i,this._needsRedraw="Canvas resized",null==r||r(e,t)}})}n||(n=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(n,e),this.setProps(e),e._typedArrayManagerProps&&ou.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){var e,t,n,r,i,s,o,a,A,l;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==(r=this.viewManager)||r.finalize(),this.viewManager=null,null==(i=this.effectManager)||i.finalize(),this.effectManager=null,null==(s=this.deckRenderer)||s.finalize(),this.deckRenderer=null,null==(o=this.deckPicker)||o.finalize(),this.deckPicker=null,null==(a=this.eventManager)||a.destroy(),this.eventManager=null,null==(A=this.widgetManager)||A.finalize(),this.widgetManager=null,this.props.canvas||this.props.device||this.props.gl||!this.canvas||(null==(l=this.canvas.parentElement)||l.removeChild(this.canvas),this.canvas=null)}setProps(e){var t,n,r,i,s,o,a;this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&Hn.removed("onLayerHover","onHover")(),"onLayerClick"in e&&Hn.removed("onLayerClick","onClick")(),e.initialViewState&&!dh(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);const A=Object.create(this.props);Object.assign(A,{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==(r=e.device.canvasContext)?void 0:r.canvas)&&(null==(i=this.canvas)||i.remove(),null==(s=this.eventManager)||s.destroy(),this.canvas=null),Hn.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(A),void 0!==e.useDevicePixels&&(null==(a=this.device)?void 0:a.canvasContext)&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(A),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(A),this.effectManager.setProps(A),this.deckRenderer.setProps(A),this.deckPicker.setProps(A),this.widgetManager.setProps(A)),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),r=this.layerManager.needsRedraw(e),i=this.effectManager.needsRedraw(e),s=this.deckRenderer.needsRedraw(e);return t=t||n||r||i||s,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 xh(this.viewManager),this.viewManager.views}getViewports(e){return xh(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){xh(this.deckPicker);const{stats:r}=this;r.get("Pick Count").incrementCount(),r.get(t).timeStart();const i=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 r.get(t).timeEnd(),i}_createCanvas(e){let t=e.canvas;return"string"==typeof t&&(t=document.getElementById(t),xh(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:r}=e;if(n||0===n){const e=Number.isFinite(n)?`${n}px`:n;this.canvas.style.width=e}if(r||0===r){const n=Number.isFinite(r)?`${r}px`:r;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 r=n.clientWidth??n.width,i=n.clientHeight??n.height;r===this.width&&i===this.height||(this.width=r,this.height=i,null==(e=this.viewManager)||e.setProps({width:r,height:i}),null==(t=this.layerManager)||t.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:i}))}_createAnimationLoop(e,t){const{gl:n,onError:r}=t;return new Cu({device:e,autoResizeDrawingBuffer:!n,autoResizeViewport:!1,onInitialize:e=>this._setDevice(e.device),onRender:this._onRenderFrame.bind(this),onError:r})}_createDevice(e){var t,n,r;const i=null==(t=this.props.deviceProps)?void 0:t.createCanvasContext,s="object"==typeof i?i:void 0,o={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};o.adapters.includes(wd)||o.adapters.push(wd);const a={alphaMode:"webgpu"===(null==(n=this.props.deviceProps)?void 0:n.type)?"premultiplied":void 0},A=null==(r=this.props.deviceProps)?void 0:r.onResize;return mi.createDevice({_reuseDevices:!0,type:"webgl",...o,createCanvasContext:{...a,...s,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(e,t)=>{this._needsRedraw="Canvas resized",null==A||A(e,t)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){const{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new Gh({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,r;if("webgpu"===(null==(e=this.device)?void 0:e.type))return;const{_pickRequest:i}=this;if(i.event){const{result:e,emptyInfo:s}=this._pick("pickObject","pickObject Time",i);this.cursorState.isHovering=e.length>0;let o=s,a=!1;for(const n of e)o=n,a=(null==(t=n.layer)?void 0:t.onHover(n,i.event))||a;a||(null==(r=(n=this.props).onHover)||r.call(n,o,i.event),this.widgetManager.onHover(o,i.event)),i.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 r=new Eu;r.play(),this.animationLoop.attachTimeline(r),this.eventManager=new Fl(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizers:Object.keys(Vl).map(e=>{var t;const[n,r,i,s]=Vl[e];return{recognizer:new n({...r,...null==(t=this.props.eventRecognizerOptions)?void 0:t[e],event:e}),recognizeWith:i,requestFailure:s}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(const s in zl)this.eventManager.on(s,this._onEvent);this.viewManager=new fh({timeline:r,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 i=this.viewManager.getViewports()[0];this.layerManager=new hh(this.device,{deck:this,stats:this.stats,viewport:i,timeline:r}),this.effectManager=new Vh({deck:this,device:this.device}),this.deckRenderer=new Hh(this.device),this.deckPicker=new Zh(this.device),this.widgetManager=new nd({deck:this,parentElement:null==(n=this.canvas)?void 0:n.parentElement}),this.widgetManager.addDefault(new od),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,t){var n;const{device:r,gl:i}=this.layerManager.context;this.props.onBeforeRender({device:r,gl:i});const s={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(s),"screen"===s.pass&&this.widgetManager.onRedraw({viewports:s.viewports,layers:s.layers}),this.props.onAfterRender({device:r,gl:i})}_onRenderFrame(){var e;this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),Hn.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=mi.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}}rp.defaultProps=np,rp.VERSION=qn;const ip=zr;function sp(e,t,n){const r="webgpu"===n&&"uint8"===t.type?"unorm8":t.type;return{attribute:e,format:t.size>1?`${r}x${t.size}`:t.type,byteOffset:t.offset||0}}function op(e){return e.stride||e.size*e.bytesPerElement}function ap(e,t){t.offset&&Hn.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const n=op(e),r=(void 0!==t.vertexOffset?t.vertexOffset:e.vertexOffset||0)*n+(t.elementOffset||0)*e.bytesPerElement+(e.offset||0);return{...t,offset:r,stride:n}}class Ap{constructor(e,t,n){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;const r=t.logicalType||t.type,i="float64"===r;let s,{defaultValue:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0),s=i?"float32":!r&&t.isIndexed?"uint32":r||"float32";let a=function(e){switch(e){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Vr(e)}}(r||s);this.doublePrecision=i,i&&!1===t.fp64&&(a=Float32Array),this.value=null,this.settings={...t,defaultType:a,defaultValue:o,logicalType:r,type:s,normalized:s.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*op(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),ou.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 r=this.value;if(t){const i=ap(this.getAccessor(),t),s=i.offset/r.BYTES_PER_ELEMENT,o=i.size||this.size;n[e]=r.subarray(s,s+o)}else n[e]=r}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(),r=[],i={name:this.id,byteStride:op(n),attributes:r};if(this.doublePrecision){const i=function(e,t){const n=ap(e,t);return{high:n,low:{...n,offset:n.offset+4*e.size}}}(n,t||{});r.push(sp(e,{...n,...i.high},this.device.type),sp(`${e}64Low`,{...n,...i.low},this.device.type))}else if(t){const i=ap(n,t);r.push(sp(e,{...n,...i},this.device.type))}else r.push(sp(e,n,this.device.type));return i}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:r}=this,i=n*r;if(t&&i&&t.length>=i){const n=new Array(r).fill(1/0),s=new Array(r).fill(-1/0);for(let e=0;e<i;)for(let i=0;i<r;i++){const r=t[e++];r<n[i]&&(n[i]=r),r>s[i]&&(s[i]=r)}e=[n,s]}}return this.state.bounds=e,e}setData(e){const{state:t}=this;let n;n=ArrayBuffer.isView(e)?{value:e}:e instanceof Ur?{buffer:e}:e;const r={...this.settings,...n};if(ArrayBuffer.isView(n.value)){if(!n.type)if(this.doublePrecision&&n.value instanceof Float64Array)r.type="float32";else{const e=ip(n.value);r.type=r.normalized?e.replace("int","norm"):e}r.bytesPerElement=n.value.BYTES_PER_ELEMENT,r.stride=op(r)}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:i}=this;const s=op(r),o=(r.vertexOffset||0)*s;if(this.doublePrecision&&e instanceof Float64Array&&(e=uu(e,r)),this.settings.isIndexed){const t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}const a=e.byteLength+o+2*s;(!i||i.byteLength<a)&&(i=this._createBuffer(a)),i.write(e,o)}return this.setAccessor(r),!0}updateSubBuffer(e={}){this.state.bounds=null;const t=this.value,{startOffset:n=0,endOffset:r}=e;this.buffer.write(this.doublePrecision&&t instanceof Float64Array?uu(t,{size:this.size,startIndex:n,endIndex:r}):t.subarray(n,r),n*t.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,t=!1){const{state:n}=this,r=n.allocatedValue,i=ou.allocate(r,e+1,{size:this.size,type:this.settings.defaultType,copy:t});this.value=i;const{byteOffset:s}=this;let{buffer:o}=this;return(!o||o.byteLength<i.byteLength+s)&&(o=this._createBuffer(i.byteLength+s),t&&r&&o.write(r instanceof Float64Array?uu(r,this):r,s)),n.allocatedValue=i,n.constant=!1,n.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){const{value:t}=e;if(!ArrayBuffer.isView(t))throw new Error(`Attribute ${this.id} value is not TypedArray`);const n=this.settings.defaultType;let r=!1;if(this.doublePrecision&&(r=t.BYTES_PER_ELEMENT<4),r)throw new Error(`Attribute ${this.id} does not support ${t.constructor.name}`);t instanceof n||!this.settings.normalized||"normalized"in e||Hn.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(e=>(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:r,size:i}=this.settings;if(Number.isFinite(e))return t[n]=e,t;if(!e){let e=i;for(;--e>=0;)t[n+e]=r[e];return t}switch(i){case 4:t[n+3]=Number.isFinite(e[3])?e[3]:r[3];case 3:t[n+2]=Number.isFinite(e[2])?e[2]:r[2];case 2:t[n+1]=Number.isFinite(e[1])?e[1]:r[1];case 1:t[n+0]=Number.isFinite(e[0])?e[0]:r[0];break;default:let s=i;for(;--s>=0;)t[n+s]=Number.isFinite(e[s])?e[s]:r[s]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;const{size:n}=this;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}_createBuffer(e){var t;this._buffer&&this._buffer.destroy();const{isIndexed:n,type:r}=this.settings;return this._buffer=this.device.createBuffer({...null==(t=this._buffer)?void 0:t.props,id:this.id,usage:(n?Ur.INDEX:Ur.VERTEX)|Ur.COPY_DST,indexType:n?r:void 0,byteLength:e}),this._buffer}}const lp=[],cp=[];function up(e,t=0,n=1/0){let r=lp;const i={index:-1,data:e,target:[]};return e?"function"==typeof e[Symbol.iterator]?r=e:e.length>0&&(cp.length=e.length,r=cp):r=lp,(t>0||Number.isFinite(n))&&(r=(Array.isArray(r)?r:Array.from(r)).slice(t,n),i.index=t-1),{iterable:r,objectInfo:i}}function hp(e){return e&&e[Symbol.asyncIterator]}function dp(e,t){const{size:n,stride:r,offset:i,startIndices:s,nested:o}=t,a=e.BYTES_PER_ELEMENT,A=r?r/a:n,l=i?i/a:0,c=Math.floor((e.length-l)/A);return(t,{index:r,target:i})=>{if(!s){const t=r*A+l;for(let r=0;r<n;r++)i[r]=e[t+r];return i}const a=s[r],u=s[r+1]||c;let h;if(o){h=new Array(u-a);for(let t=a;t<u;t++){const r=t*A+l;i=new Array(n);for(let t=0;t<n;t++)i[t]=e[r+t];h[t-a]=i}}else if(A===n)h=e.subarray(a*n+l,u*n+l);else{h=new e.constructor((u-a)*n);let t=0;for(let r=a;r<u;r++){const i=r*A+l;for(let r=0;r<n;r++)h[t++]=e[i+r]}}return h}}const fp=[],pp=[[0,1/0]],gp={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function mp(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});const n=e.type||"interpolation";return{...gp[n],...t,...e,type:n}}class _p extends Ap{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:pp}),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,r;(t=this.state).layoutChanged||(t.layoutChanged=(n=e,r=this.getAccessor(),!(n.type===r.type&&n.size===r.size&&op(n)===op(r)&&(n.offset||0)===(r.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 mp(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===pp)return e;if(t[0]<0&&(t[0]=0),t[0]>=t[1])return e;const n=[],r=e.length;let i=0;for(let s=0;s<r;s++){const r=e[s];r[1]<t[0]?(n.push(r),i=s+1):r[0]>t[1]?n.push(r):t=[Math.min(r[0],t[0]),Math.max(r[1],t[1])]}return n.splice(i,0,t),n}(this.state.updateRanges,[e,n])}else this.state.updateRanges=pp}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=fp}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!==pp),!0)}updateBuffer({numInstances:e,data:t,props:n,context:r}){if(!this.needsUpdate())return!1;const{state:{updateRanges:i},settings:{update:s,noAlloc:o}}=this;let a=!0;if(s){for(const[o,a]of i)s.call(r,this,{data:t,startRow:o,endRow:a,props:n,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(const[t,n]of i){const r=Number.isFinite(t)?this.getVertexOffset(t):0,i=Number.isFinite(n)?this.getVertexOffset(n):o||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:r,endOffset:i})}this._checkAttributeArray()}else a=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),a}setConstantValue(e,t){const n="webgpu"===this.device.type;if(n||void 0===t||"function"==typeof t){if(n&&"function"!=typeof t){const e=this._normalizeValue(t,[],0);this._areValuesEqual(e,this.value)||this.setNeedsUpdate("WebGPU constant updated")}return!1}const r=this.settings.transform&&e?this.settings.transform.call(e,t):t;return this.setData({constant:!0,value:r})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setExternalBuffer(e){const{state:t}=this;return e?(this.clearNeedsUpdate(),t.lastExternalBuffer===e||(t.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(t.lastExternalBuffer=null,!1)}setBinaryValue(e,t=null){const{state:n,settings:r}=this;if(!e)return n.binaryValue=null,n.binaryAccessor=null,!1;if(r.noAlloc)return!1;if(n.binaryValue===e)return this.clearNeedsUpdate(),!0;if(n.binaryValue=e,this.setNeedsRedraw(),r.transform||t!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});const i=e;xh(ArrayBuffer.isView(i.value),`invalid ${r.accessor}`);const s=Boolean(i.size)&&i.size!==this.size;return n.binaryAccessor=dp(i.value,{size:i.size||this.size,stride:i.stride,offset:i.offset,startIndices:t,nested:s}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){const{startIndices:t}=this;return(t?e<t.length?t[e]:this.numInstances:e)*this.size}getValue(){const e=this.settings.shaderAttributes,t=super.getValue();if(!e)return t;for(const n in e)Object.assign(t,super.getValue(n,e[n]));return t}getBufferLayout(e){this.state.layoutChanged=!1;const t=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:r}=this.settings;if(n.stepMode="dynamic"===r?e?e.isInstanced?"instance":"vertex":"instance":r??"vertex",!t)return n;for(const i in t){const e=super._getBufferLayout(i,t[i]);n.attributes.push(...e.attributes)}return n}_autoUpdater(e,{data:t,startRow:n,endRow:r,props:i,numInstances:s}){if(e.constant&&"webgpu"!==this.context.device.type)return;const{settings:o,state:a,value:A,size:l,startIndices:c}=e,{accessor:u,transform:h}=o;let d=a.binaryAccessor||("function"==typeof u?u:i[u]);"function"!=typeof d&&"string"==typeof u&&(d=()=>i[u]),xh("function"==typeof d,`accessor "${u}" is not a function`);let f=e.getVertexOffset(n);const{iterable:p,objectInfo:g}=up(t,n,r);for(const m of p){g.index++;let t=d(m,g);if(h&&(t=h.call(this,t)),c){const n=(g.index<c.length-1?c[g.index+1]:s)-c[g.index];if(t&&Array.isArray(t[0])){let n=f;for(const r of t)e._normalizeValue(r,A,n),n+=l}else t&&t.length>l?A.set(t,f):(e._normalizeValue(t,g.target,0),lh({target:A,source:g.target,start:f,count:n}));f+=n*l}else e._normalizeValue(t,A,f),f+=l}}_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 bp(e){const{source:t,target:n,start:r=0,size:i,getData:s}=e,o=e.end||n.length,a=t.length,A=o-r;if(a>A)return void n.set(t.subarray(0,A),r);if(n.set(t,r),!s)return;let l=a;for(;l<A;){const e=s(l,t);for(let t=0;t<i;t++)n[r+l]=e[t]||0,l++}}function vp(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${e}"`)}}function yp(e){switch(e){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function wp(e){e.push(e.shift())}function xp({device:e,source:t,target:n}){return(!n||n.byteLength<t.byteLength)&&(null==n||n.destroy(),n=e.createBuffer({byteLength:t.byteLength,usage:t.usage})),n}function Ep({device:e,buffer:t,attribute:n,fromLength:r,toLength:i,fromStartIndices:s,getData:o=e=>e}){const a=n.doublePrecision&&n.value instanceof Float64Array?2:1,A=n.size*a,l=n.byteOffset,c=n.settings.bytesPerElement<4?l/n.settings.bytesPerElement*4:l,u=n.startIndices,h=s&&u,d=n.isConstant;if(!h&&t&&r>=i)return t;const f=n.value instanceof Float64Array?Float32Array:n.value.constructor,p=d?n.value:new f(n.getBuffer().readSyncWebGL(l,i*f.BYTES_PER_ELEMENT).buffer);if(n.settings.normalized&&!d){const e=o;o=(t,r)=>n.normalizeConstant(e(t,r))}const g=d?(e,t)=>o(p,t):(e,t)=>o(p.subarray(e+l,e+l+A),t),m=t?new Float32Array(t.readSyncWebGL(c,4*r).buffer):new Float32Array(0),_=new Float32Array(i);return function({source:e,target:t,size:n,getData:r,sourceStartIndices:i,targetStartIndices:s}){if(!i||!s)return bp({source:e,target:t,size:n,getData:r}),t;let o=0,a=0;const A=r&&((e,t)=>r(e+a,t)),l=Math.min(i.length,s.length);for(let c=1;c<l;c++){const r=i[c]*n,l=s[c]*n;bp({source:e.subarray(o,r),target:t,start:a,end:l,size:n,getData:A}),o=r,a=l}a<t.length&&bp({source:[],target:t,start:a,size:n,getData:A})}({source:m,target:_,sourceStartIndices:s,targetStartIndices:u,size:A,getData:g}),(!t||t.byteLength<_.byteLength+c)&&(null==t||t.destroy(),t=e.createBuffer({byteLength:_.byteLength+c,usage:35050})),t.write(_,c),t}class Tp{constructor({device:e,attribute:t,timeline:n}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new bh(n),this.attribute=t,this.attributeInTransition=function(e){const{device:t,settings:n,value:r}=e,i=new _p(t,n);return i.setData({value:r instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:n.normalized}),i}(t),this.currentStartIndices=t.startIndices}get inProgress(){return this.transition.inProgress}start(e,t,n=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=function(e,t){const{doublePrecision:n,settings:r,value:i,size:s}=e,o=n&&i instanceof Float64Array?2:1;let a=0;const{shaderAttributes:A}=e.settings;if(A)for(const l of Object.values(A))a=Math.max(a,l.vertexOffset??0);return(r.noAlloc?i.length:(t+a)*s)*o}(this.attribute,t),this.transition.start({...e,duration:n})}update(){const e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(const e of this.buffers)e.destroy();this.buffers.length=0}}const Sp={name:"interpolation",vs:"uniform interpolationUniforms {\n float time;\n} interpolation;\n",uniformTypes:{time:"f32"}};function Cp(e){return e.doublePrecision&&e.value instanceof Float64Array}const kp={name:"spring",vs:"uniform springUniforms {\n float damping;\n float stiffness;\n} spring;\n",uniformTypes:{damping:"f32",stiffness:"f32"}},Rp={interpolation:class extends Tp{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="interpolation",this.transform=function(e,t){const n=t.size,r=vp(n),i=yp(n),s=t.getBufferLayout();return Cp(t)?new qu(e,{vs:"#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aFrom64Low;\nin ATTRIBUTE_TYPE aTo;\nin ATTRIBUTE_TYPE aTo64Low;\nout ATTRIBUTE_TYPE vCurrent;\nout ATTRIBUTE_TYPE vCurrent64Low;\n\nvec2 mix_fp64(vec2 a, vec2 b, float x) {\n vec2 range = sub_fp64(b, a);\n return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));\n}\n\nvoid main(void) {\n for (int i=0; i<ATTRIBUTE_SIZE; i++) {\n vec2 value = mix_fp64(vec2(aFrom[i], aFrom64Low[i]), vec2(aTo[i], aTo64Low[i]), interpolation.time);\n vCurrent[i] = value.x;\n vCurrent64Low[i] = value.y;\n }\n gl_Position = vec4(0.0);\n}\n",bufferLayout:[{name:"aFrom",byteStride:8*n,attributes:[{attribute:"aFrom",format:i,byteOffset:0},{attribute:"aFrom64Low",format:i,byteOffset:4*n}]},{name:"aTo",byteStride:8*n,attributes:[{attribute:"aTo",format:i,byteOffset:0},{attribute:"aTo64Low",format:i,byteOffset:4*n}]}],modules:[wA,Sp],defines:{ATTRIBUTE_TYPE:r,ATTRIBUTE_SIZE:n},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new qu(e,{vs:"#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vCurrent;\n\nvoid main(void) {\n vCurrent = mix(aFrom, aTo, interpolation.time);\n gl_Position = vec4(0.0);\n}\n",bufferLayout:[{name:"aFrom",format:i},{name:"aTo",format:s.attributes[0].format}],modules:[Sp],defines:{ATTRIBUTE_TYPE:r},varyings:["vCurrent"],disableWarnings:!0})}(e,t)}start(e,t){const n=this.currentLength,r=this.currentStartIndices;if(super.start(e,t,e.duration),e.duration<=0)return void this.transition.cancel();const{buffers:i,attribute:s}=this;wp(i),i[0]=Ep({device:this.device,buffer:i[0],attribute:s,fromLength:n,toLength:this.currentLength,fromStartIndices:r,getData:e.enter}),i[1]=xp({device:this.device,source:i[0],target:i[1]}),this.setBuffer(i[1]);const{transform:o}=this,a=o.model;let A=Math.floor(this.currentLength/s.size);Cp(s)&&(A/=2),a.setVertexCount(A),s.isConstant?(a.setAttributes({aFrom:i[0]}),a.setConstantAttributes({aTo:s.value})):a.setAttributes({aFrom:i[0],aTo:s.getBuffer()}),o.transformFeedback.setBuffers({vCurrent:i[1]})}onUpdate(){const{duration:e,easing:t}=this.settings,{time:n}=this.transition;let r=n/e;t&&(r=t(r));const{model:i}=this.transform,s={time:r};i.shaderInputs.setProps({interpolation:s}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},spring:class extends Tp{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="spring",this.texture=function(e){return e.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}(e),this.framebuffer=function(e,t){return e.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[t]})}(e,this.texture),this.transform=function(e,t){const n=vp(t.size),r=yp(t.size);return new qu(e,{vs:"#version 300 es\n#define SHADER_NAME spring-transition-vertex-shader\n\n#define EPSILON 0.00001\n\nin ATTRIBUTE_TYPE aPrev;\nin ATTRIBUTE_TYPE aCur;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vNext;\nout float vIsTransitioningFlag;\n\nATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) {\n ATTRIBUTE_TYPE velocity = cur - prev;\n ATTRIBUTE_TYPE delta = dest - cur;\n ATTRIBUTE_TYPE force = delta * spring.stiffness;\n ATTRIBUTE_TYPE resistance = velocity * spring.damping;\n return force - resistance + velocity + cur;\n}\n\nvoid main(void) {\n bool isTransitioning = length(aCur - aPrev) > 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:r},{name:"aCur",format:r},{name:"aTo",format:t.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[kp],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,r=this.currentStartIndices;super.start(e,t);const{buffers:i,attribute:s}=this;for(let a=0;a<2;a++)i[a]=Ep({device:this.device,buffer:i[a],attribute:s,fromLength:n,toLength:this.currentLength,fromStartIndices:r,getData:e.enter});i[2]=xp({device:this.device,source:i[0],target:i[2]}),this.setBuffer(i[1]);const{model:o}=this.transform;o.setVertexCount(Math.floor(this.currentLength/s.size)),s.isConstant?o.setConstantAttributes({aTo:s.value}):o.setAttributes({aTo:s.getBuffer()})}onUpdate(){const{buffers:e,transform:t,framebuffer:n,transition:r}=this,i=this.settings;t.model.setAttributes({aPrev:e[0],aCur:e[1]}),t.transformFeedback.setBuffers({vNext:e[2]});const s={stiffness:i.stiffness,damping:i.damping};t.model.shaderInputs.setProps({spring:s}),t.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),wp(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(n)[0]>0||r.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}};class Pp{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 r in e){const n=e[r],i=n.getTransitionSetting(t);i&&this._updateAttribute(r,n,i)}for(const r in this.transitions){const n=e[r];n&&n.getTransitionSetting(t)||this._removeTransition(r)}}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 r=this.transitions[e];let i=!r||r.type!==n.type;if(i){r&&this._removeTransition(e);const s=Rp[n.type];s?this.transitions[e]=new s({attribute:t,timeline:this.timeline,device:this.device}):(Hn.error(`unsupported transition type '${n.type}'`)(),i=!1)}(i||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}}const Ip="attributeManager.invalidate";class Mp{constructor(e,{id:t="attribute-manager",stats:n,timeline:r}={}){this.mergeBoundsMemoized=Hl(hu),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new Pp(e,{id:`${t}-transitions`,timeline:r}),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);Qn(Ip,this,e,n)}invalidateAll(e){for(const t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);Qn(Ip,this,"all")}update({data:e,numInstances:t,startIndices:n=null,transitions:r,props:i={},buffers:s={},context:o={}}){let a=!1;Qn("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const A in this.attributes){const r=this.attributes[A],l=r.settings.accessor;r.startIndices=n,r.numInstances=t,i[A]&&Hn.removed(`props.${A}`,`data.attributes.${A}`)(),r.setExternalBuffer(s[A])||r.setBinaryValue("string"==typeof l?s[l]:void 0,e.startIndices)||"string"==typeof l&&!s[l]&&r.setConstantValue(o,i[l])||r.needsUpdate()&&(a=!0,this._updateAttribute({attribute:r,numInstances:t,data:e,props:i,context:o})),this.needsRedraw=this.needsRedraw||r.needsRedraw()}a&&Qn("attributeManager.updateEnd",this,t),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:r})}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,r={...n.getAttributes()};for(const i in t){const s=t[i];s.needsRedraw(e)&&!n.hasAttribute(i)&&(r[i]=s)}return r}getBufferLayouts(e){return Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_add(e,t){for(const n in e){const r=e[n],i={...r,id:n,size:(r.isIndexed?1:r.size)||1,...t};this.attributes[n]=new _p(this.device,i)}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:r}=this,i=r[e];return i&&i.forEach(e=>{const r=n[e];r&&r.setNeedsUpdate(r.id,t)}),i}_updateAttribute(e){const{attribute:t,numInstances:n}=e;Qn("attribute.updateStart",t),t.constant?t.setConstantValue(e.context,t.value):(t.allocate(n)&&Qn("attribute.allocate",t,n),t.updateBuffer(e)&&(this.needsRedraw=!0,Qn("attribute.updateEnd",t,n)))}}const Lp=1e-5;function Np(e,t,n,r,i){const s=t-e;return(n-t)*i+-s*r+s+t}function Bp(e,t){if(Array.isArray(e)){let n=0;for(let r=0;r<e.length;r++){const i=e[r]-t[r];n+=i*i}return Math.sqrt(n)}return Math.abs(e-t)}const Dp={interpolation:class extends bh{get value(){return this._value}_onUpdate(){const{time:e,settings:{fromValue:t,toValue:n,duration:r,easing:i}}=this,s=i(e/r);this._value=Oa(t,n,s)}},spring:class extends bh{get value(){return this._currValue}_onUpdate(){const{fromValue:e,toValue:t,damping:n,stiffness:r}=this.settings,{_prevValue:i=e,_currValue:s=e}=this;let o=function(e,t,n,r,i){if(Array.isArray(n)){const s=[];for(let o=0;o<n.length;o++)s[o]=Np(e[o],t[o],n[o],r,i);return s}return Np(e,t,n,r,i)}(i,s,t,n,r);const a=Bp(o,t),A=Bp(o,s);a<Lp&&A<Lp&&(o=t,this.end()),this._prevValue=s,this._currValue=o}}};class Op{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,t,n,r){const{transitions:i}=this;if(i.has(e)){const n=i.get(e),{value:r=n.settings.fromValue}=n;t=r,this.remove(e)}if(!(r=mp(r)))return;const s=Dp[r.type];if(!s)return void Hn.error(`unsupported transition type '${r.type}'`)();const o=new s(this.timeline);o.start({...r,fromValue:t,toValue:n}),i.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 Fp(e,t){if(!e.transitions)return!1;const n={},r=e[nh];let i=!1;for(const s in e.transitions){const o=r[s],a=o&&o.type;("number"===a||"color"===a||"array"===a)&&jp(e[s],t[s],o)&&(n[s]=!0,i=!0)}return!!i&&n}function Up({newProps:e,oldProps:t,ignoreProps:n={},propTypes:r={},triggerName:i="props"}){if(t===e)return!1;if("object"!=typeof e||null===e)return`${i} changed shallowly`;if("object"!=typeof t||null===t)return`${i} changed shallowly`;for(const s of Object.keys(e))if(!(s in n)){if(!(s in t))return`${i}.${s} added`;const n=jp(e[s],t[s],r[s]);if(n)return`${i}.${s} ${n}`}for(const s of Object.keys(t))if(!(s in n)){if(!(s in e))return`${i}.${s} dropped`;if(!Object.hasOwnProperty.call(e,s)){const n=jp(e[s],t[s],r[s]);if(n)return`${i}.${s} ${n}`}}return!1}function jp(e,t,n){let r=n&&n.equal;return r&&!r(e,t,n)?"changed deeply":r||(r=e&&t&&e.equals,!r||r.call(e,t))?r||t===e?null:"changed shallowly":"changed deeply"}function Gp(e,t){if(null===t)return!0;const n=t.extensions,{extensions:r}=e;if(r===n)return!1;if(!n||!r)return!0;if(r.length!==n.length)return!0;for(let i=0;i<r.length;i++)if(!r[i].equals(n[i]))return!0;return!1}function zp(e,t,n){let r=e.updateTriggers[n];r=null==r?{}:r;let i=t.updateTriggers[n];return i=null==i?{}:i,Up({oldProps:i,newProps:r,triggerName:n})}function Vp(e,t){if(!t)return e;const n={...e,...t};if("defines"in t&&(n.defines={...e.defines,...t.defines}),"modules"in t&&(n.modules=(e.modules||[]).concat(t.modules),t.modules.some(e=>"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 r={...e.inject};for(const e in t.inject)r[e]=(r[e]||"")+t.inject[e];n.inject=r}else n.inject=t.inject;return n}const Wp={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Hp={},$p={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||Yp(e)&&(3===e.length||4===e.length),equal:(e,t,n)=>dh(e,t,1)},accessor:{validate(e,t){const n=qp(e);return"function"===n||n===qp(t.value)},equal:(e,t,n)=>"function"==typeof t||dh(e,t,1)},array:{validate:(e,t)=>t.optional&&!e||Yp(e),equal(e,t,n){const{compare:r}=n,i=Number.isInteger(r)?r:r?1:0;return r?dh(e,t,i):e===t}},object:{equal(e,t,n){if(n.ignore)return!0;const{compare:r}=n,i=Number.isInteger(r)?r:r?1:0;return r?dh(e,t,i):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:r}=n.props;return r?r(e):"string"==typeof e.shape&&e.shape.endsWith("-table")&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,n)=>{const r=n.context;return r&&r.device?function(e,t,n,r){if(n instanceof Pi)return n;n.constructor&&"Object"!==n.constructor.name&&(n={data:n});let i=null;n.compressed&&(i={minFilter:"linear",mipmapFilter:n.data.length>1?"nearest":"linear"});const{width:s,height:o}=n.data,a=t.createTexture({...n,sampler:{...Wp,...i,...r},mipLevels:t.getMipLevelCount(s,o)});return a.generateMipmapsWebGL(),Hp[a.id]=e,a}(n.id,r.device,e,{...t.parameters,...n.props.textureParameters}):null},release:(e,t,n)=>{var r,i;r=n.id,(i=e)&&i instanceof Pi&&Hp[i.id]===r&&(i.delete(),delete Hp[i.id])}}};function Xp(e,t){switch(qp(t)){case"object":return Qp(e,t);case"array":return Qp(e,{type:"array",value:t,compare:!1});case"boolean":return Qp(e,{type:"boolean",value:t});case"number":return Qp(e,{type:"number",value:t});case"function":return Qp(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function Qp(e,t){return"type"in t?{name:e,...$p[t.type],...t}:"value"in t?{name:e,type:qp(t.value),...t}:{name:e,type:"object",value:t}}function Yp(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function qp(e){return Yp(e)?"array":null===e?"null":typeof e}function Kp(e,t){if(!(e instanceof ng.constructor))return{};let n="_mergedDefaultProps";if(t)for(const r of t){const e=r.constructor;e&&(n+=`:${e.extensionName||e.name}`)}return eg(e,n)||(e[n]=function(e,t){if(!e.prototype)return null;const n=Kp(Object.getPrototypeOf(e)),r=function(e){const t={},n={},r={};for(const[i,s]of Object.entries(e)){const e=null==s?void 0:s.deprecatedFor;if(e)r[i]=Array.isArray(e)?e:[e];else{const e=Xp(i,s);t[i]=e,n[i]=e.value}}return{propTypes:t,defaultProps:n,deprecatedProps:r}}(eg(e,"defaultProps")||{}),i=Object.assign(Object.create(null),n,r.defaultProps),s=Object.assign(Object.create(null),null==n?void 0:n[nh],r.propTypes),o=Object.assign(Object.create(null),null==n?void 0:n[rh],r.deprecatedProps);for(const a of t){const e=Kp(a.constructor);e&&(Object.assign(i,e),Object.assign(s,e[nh]),Object.assign(o,e[rh]))}return function(e,t){const n=function(e){const t=e.componentName;return t||Hn.warn(`${e.name}.componentName not specified`)(),t||e.name}(t);Object.defineProperties(e,{id:{writable:!0,value:n}})}(i,e),function(e,t){const n={},r={};for(const i in t){const e=t[i],{name:s,value:o}=e;e.async&&(n[s]=o,r[s]=Zp(s))}e[ih]=n,e[sh]={},Object.defineProperties(e,r)}(i,s),function(e,t){for(const n in t)Object.defineProperty(e,n,{enumerable:!1,set(e){const r=`${this.id}: ${n}`;for(const i of t[n])Jp(this,i)||(this[i]=e);Hn.deprecated(r,t[n].join("/"))()}})}(i,o),i[nh]=s,i[rh]=o,0!==t.length||Jp(e,"_propTypes")||(e._propTypes=s),i}(e,t||[]))}function Zp(e){return{enumerable:!0,set(t){"string"==typeof t||t instanceof Promise||hp(t)?this[sh][e]=t:this[oh][e]=t},get(){if(this[oh]){if(e in this[oh])return this[oh][e]||this[ih][e];if(e in this[sh]){const t=this[th]&&this[th].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[ih][e]}}return this[ih][e]}}}function Jp(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function eg(e,t){return Jp(e,t)&&e[t]}let tg=0;class ng{constructor(...e){this.props=function(e,t){let n;for(let s=t.length-1;s>=0;s--){const e=t[s];"extensions"in e&&(n=e.extensions)}const r=Kp(e.constructor,n),i=Object.create(r);i[th]=e,i[sh]={},i[oh]={};for(let s=0;s<t.length;++s){const e=t[s];for(const t in e)i[t]=e[t]}return Object.freeze(i),i}(this,e),this.id=this.props.id,this.count=tg++}clone(e){const{props:t}=this,n={};for(const r in t[ih])r in t[oh]?n[r]=t[oh][r]:r in t[sh]&&(n[r]=t[sh][r]);return new this.constructor({...t,...n,...e})}}ng.componentName="Component",ng.defaultProps={};const rg=Object.freeze({});class ig{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},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||rg}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[th]||this.component;const t=e[oh]||{},n=e[sh]||e,r=e[ih]||{};for(const i in t){const e=t[i];this._createAsyncPropData(i,r[i]),this._updateAsyncProp(i,e),t[i]=this.getAsyncProp(i)}for(const i in n){const e=n[i];this._createAsyncPropData(i,r[i]),this._updateAsyncProp(i,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):hp(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 r=this.asyncProps[e];r&&n>=r.resolvedLoadCount&&void 0!==t&&(this._freezeAsyncOldProps(),r.resolvedValue=t,r.resolvedLoadCount=n,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){const n=this.asyncProps[e];if(n){n.pendingLoadCount++;const r=n.pendingLoadCount;t.then(t=>{this.component&&(t=this._postProcessValue(n,t),this._setAsyncPropValue(e,t,r),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 r=n.pendingLoadCount;let i=[],s=0;for await(const o of t){if(!this.component)return;const{dataTransform:t}=this.component.props;i=t?t(o,i):i.concat(o),Object.defineProperty(i,"__diff",{enumerable:!1,value:[{startRow:s,endRow:i.length}]}),s=i.length,this._setAsyncPropValue(e,i,r)}this._onResolve(e,i)}_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[nh];this.asyncProps[e]={type:n&&n[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}}class sg extends ig{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,r=null==n?void 0:n.props.fetch;return r?r(t,{propName:e,layer:n}):super._fetch(e,t)}_onResolve(e,t){const n=this.layer;if(n){const r=n.props.onDataLoad;"data"===e&&r&&r(t,{propName:e,layer:n})}}_onError(e,t){const n=this.layer;n&&n.raiseError(t,`loading ${e} of ${this.layer}`)}}const og=2**24-1,ag=Object.freeze([]),Ag=Hl(({oldViewport:e,viewport:t})=>e.equals(t));let lg=new Uint8ClampedArray(0);const cg={data:{type:"data",value:ag,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:r,loadOptions:i,signal:s})=>{const{resourceManager:o}=n.context;i=i||n.getLoadOptions(),r=r||n.props.loaders,s&&(i={...i,fetch:{...null==i?void 0:i.fetch,signal:s}});let a=o.contains(e);return a||i||(o.add({resourceId:e,data:Cn(e,r),persistent:!1}),a=!0),a?o.subscribe({resourceId:e,onChange:e=>{var r;return null==(r=n.internalState)?void 0:r.reloadAsyncProp(t,e)},consumerId:n.id,requestId:t}):Cn(e,r,i)}},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:Ul.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 ug extends ng{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){xh(this.internalState);const t=this.internalState.viewport||this.context.viewport,n=yu(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[r,i,s]=Tc(n,t.pixelProjectionMatrix);return 2===e.length?[r,i]:[r,i,s]}unproject(e){return xh(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){return xh(this.internalState),function(e,t){const{viewport:n,coordinateSystem:r,coordinateOrigin:i,modelMatrix:s,fromCoordinateSystem:o,fromCoordinateOrigin:a}=function(e){const{viewport:t,modelMatrix:n,coordinateOrigin:r}=e;let{coordinateSystem:i,fromCoordinateSystem:s,fromCoordinateOrigin:o}=e;return i===Ul.DEFAULT&&(i=t.isGeospatial?Ul.LNGLAT:Ul.CARTESIAN),void 0===s&&(s=i),void 0===o&&(o=r),{viewport:t,coordinateSystem:i,coordinateOrigin:r,modelMatrix:n,fromCoordinateSystem:s,fromCoordinateOrigin:o}}(t),{autoOffset:A=!0}=t,{geospatialOrigin:l=bu,shaderCoordinateOrigin:c=bu,offsetMode:u=!1}=A?Zl(n,r,i):{},h=yu(e,{viewport:n,modelMatrix:s,coordinateSystem:o,coordinateOrigin:a,offsetMode:u});if(u){const e=n.projectPosition(l||c);qa(h,h,e)}return h}(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===Ul.DEFAULT||e===Ul.LNGLAT||e===Ul.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){xh(e instanceof Uint8Array);const[t,n,r]=e;return t+256*n+65536*r-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=Vp(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const t of this.props.extensions)e=Vp(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 r of n)t.invalidateAll(r);else t.invalidateAll();if(t){const{props:n}=e,r=this.internalState.hasPickingBuffer,i=Number.isInteger(n.highlightedObjectIndex)||n.pickable||n.extensions.some(e=>e.getNeedsPickingBuffer.call(this,e));if(r!==i){this.internalState.hasPickingBuffer=i;const{pickingColors:e,instancePickingColors:n}=t.attributes,r=e||n;r&&(i&&r.constant&&(r.constant=!1,t.invalidate(r.id)),r.value||i||(r.constant=!0,r.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:r}=e;return r>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[r]),e}raiseError(e,t){var n,r,i,s;t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),(null==(r=(n=this.props).onError)?void 0:r.call(n,e))||null==(s=null==(i=this.context)?void 0:i.onError)||s.call(i,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&&Ag({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(),r=this.getStartIndices();e.update({data:t.data,numInstances:n,startIndices:r,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});const i=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(i)}_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(lg.length/4);if(this.internalState.usesPickingColorCache=!0,n<t){t>og&&Hn.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),lg=ou.allocate(lg,t,{size:4,copy:!0,maxCount:Math.max(t,og)});const e=Math.floor(lg.length/4),r=[0,0,0];for(let t=n;t<e;t++)this.encodePickingColor(t,r),lg[4*t+0]=r[0],lg[4*t+1]=r[1],lg[4*t+2]=r[2],lg[4*t+3]=0}e.value=lg.subarray(0,4*t)}_setModelAttributes(e,t,n=!1){var r;if(!Object.keys(t).length)return;if(n){const n=this.getAttributeManager();e.setBufferLayout(n.getBufferLayouts(e)),t=n.getAttributes()}const i=(null==(r=e.userData)?void 0:r.excludeAttributes)||{},s={},o={};for(const a in t){if(i[a])continue;const n=t[a].getValue();for(const r in n){const i=n[r];i instanceof Ur?t[a].settings.isIndexed?e.setIndexBuffer(i):s[r]=i:i&&(o[r]=i)}}e.setAttributes(s),e.setConstantAttributes(o)}disablePickingIndex(e){const t=this.props.data;if(!("attributes"in t))return void this._disablePickingIndex(e);const{pickingColors:n,instancePickingColors:r}=this.getAttributeManager().attributes,i=n||r,s=i&&t.attributes&&t.attributes[i.id];if(s&&s.value){const n=s.value,r=this.encodePickingColor(e);for(let e=0;e<t.length;e++){const t=i.getVertexOffset(e);n[t]===r[0]&&n[t+1]===r[1]&&n[t+2]===r[2]&&this._disablePickingIndex(e)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){const{pickingColors:t,instancePickingColors:n}=this.getAttributeManager().attributes,r=t||n;if(!r)return;const i=r.getVertexOffset(e),s=r.getVertexOffset(e+1);r.buffer.write(new Uint8Array(s-i),i)}restorePickingColors(){const{pickingColors:e,instancePickingColors:t}=this.getAttributeManager().attributes,n=e||t;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==lg.buffer&&(n.value=lg.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){xh(!this.internalState),xh(Number.isFinite(this.props.coordinateSystem)),Qn("layer.initialize",this);const e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new sg({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(Hn.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Op(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){Qn("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(Qn("layer.update",this,e),!e)return;const t=this.props,n=this.context,r=this.internalState,i=n.viewport,s=this._updateUniformTransition();r.propsInTransition=s,n.viewport=r.viewport||i,this.props=s;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 r=this.getModels()[0]!==t[0];this._postUpdate(e,r)}finally{n.viewport=i,this.props=t,this._clearChangeFlags(),r.needsUpdate=!1,r.resetOldProps()}}_finalize(){Qn("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:r={}}){this._updateAttributeTransition();const i=this.props,s=this.context;this.props=this.internalState.propsInTransition||i;try{t&&this.setShaderModuleProps(t);const{getPolygonOffset:i}=this.props,o=i&&i(n)||[0,0];s.device instanceof Jf&&s.device.setParametersWebGL({polygonOffset:o});for(const e of this.getModels())"webgpu"===e.device.type?e.setParameters({...e.parameters,...r}):e.setParameters(r);if(s.device instanceof Jf)s.device.withParametersWebGL(r,()=>{const i={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:r,context:s};for(const e of this.props.extensions)e.draw.call(this,i,e);this.draw(i)});else{const i={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:r,context:s};for(const e of this.props.extensions)e.draw.call(this,i,e);this.draw(i)}}finally{this.props=i}}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 r in e)if(e[r]){let n=!1;if("dataChanged"===r){const i=e[r],s=t[r];i&&Array.isArray(s)&&(t.dataChanged=Array.isArray(i)?s.concat(i):i,n=!0)}t[r]||(t[r]=e[r],n=!0),n&&Qn("layer.changeFlag",this,r,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 r=function(e,t){const n=Up({newProps:e,oldProps:t,propTypes:e[nh],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),r=function(e,t){if(null===t)return"oldProps is null, initial diff";let n=!1;const{dataComparator:r,_dataDiff:i}=e;return r?r(e.data,t.data)||(n="Data comparator detected a change"):e.data!==t.data&&(n="A new data container was supplied"),n&&i&&(n=i(e.data,t.data)||n),n}(e,t);let i=!1;return r||(i=function(e,t){if(null===t)return{all:!0};if("all"in e.updateTriggers&&zp(e,t,"all"))return{all:!0};const n={};let r=!1;for(const i in e.updateTriggers)"all"!==i&&zp(e,t,i)&&(n[i]=!0,r=!0);return!!r&&n}(e,t)),{dataChanged:r,propsChanged:n,updateTriggersChanged:i,extensionsChanged:Gp(e,t),transitionsChanged:Fp(e,t)}}(e,t);if(r.updateTriggersChanged)for(const i in r.updateTriggersChanged)r.updateTriggersChanged[i]&&this.invalidateAttribute(i);if(r.transitionsChanged)for(const i in r.transitionsChanged)this.internalState.uniformTransitions.add(i,t[i],e[i],null==(n=e.transitions)?void 0:n[i]);return this.setChangeFlags(r)}validateProps(){!function(e){const t=e[nh];for(const n in t){const r=t[n],{validate:i}=r;if(i&&!i(e[n],r))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 Mp(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){const{props:n,oldProps:r}=e,i=this.state.model;(null==i?void 0:i.isInstanced)&&i.setInstanceCount(this.getNumInstances());const{autoHighlight:s,highlightedObjectIndex:o,highlightColor:a}=n;if(t||r.autoHighlight!==s||r.highlightedObjectIndex!==o||r.highlightColor!==a){const e={};Array.isArray(a)&&(e.highlightColor=a),(t||r.autoHighlight!==s||o!==r.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(),r=!!n&&n.getNeedsRedraw(e);if(t=t||r,t)for(const i of this.props.extensions)i.onNeedsRedraw.call(this,i);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}ug.defaultProps=cg,ug.layerName="Layer";class hg extends ug{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){const{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id?(e.object=t.__source.object,e.index=t.__source.index,e):e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){const{_subLayerProps:n}=this.props;return n&&n[e]&&n[e].type||t}getSubLayerRow(e,t,n){return e.__source={parent:this,object:t,index:n},e}getSubLayerAccessor(e){if("function"==typeof e){const t={index:-1,data:this.props.data,target:[]};return(n,r)=>n&&n.__source?(t.index=n.__source.index,e(n.__source.object,t)):e(n,r)}return e}getSubLayerProps(e={}){var t;const{opacity:n,pickable:r,visible:i,parameters:s,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:A,highlightColor:l,coordinateSystem:c,coordinateOrigin:u,wrapLongitude:h,positionFormat:d,modelMatrix:f,extensions:p,fetch:g,operation:m,_subLayerProps:_}=this.props,b={id:"",updateTriggers:{},opacity:n,pickable:r,visible:i,parameters:s,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:A,highlightColor:l,coordinateSystem:c,coordinateOrigin:u,wrapLongitude:h,positionFormat:d,modelMatrix:f,extensions:p,fetch:g,operation:m},v=_&&e.id&&_[e.id],y=v&&v.updateTriggers,w=e.id||"sublayer";if(v){const t=this.props[nh],n=e.type?e.type._propTypes:{};for(const e in v){const r=n[e]||t[e];r&&"accessor"===r.type&&(v[e]=this.getSubLayerAccessor(v[e]))}}Object.assign(b,e,v),b.id=`${this.props.id}-${w}`,b.updateTriggers={all:null==(t=this.props.updateTriggers)?void 0:t.all,...e.updateTriggers,...y};for(const x of p){const e=x.getSubLayerProps.call(this,x);e&&Object.assign(b,e,{updateTriggers:Object.assign(b.updateTriggers,e.updateTriggers)})}return b}_updateAutoHighlight(e){for(const t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let n=this.internalState.subLayers;const r=!n||this.needsUpdate();r&&(n=ah(this.renderLayers(),Boolean),this.internalState.subLayers=n),Qn("compositeLayer.renderLayers",this,r,n);for(const i of n)i.parent=this}}hg.layerName="CompositeLayer";const dg=Math.PI/180,fg=180/Math.PI,pg=6370972,gg=256;function mg(){const e=4018225162502676e-20,t=Math.PI/180*gg;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 _g extends mu{constructor(e={}){const{longitude:t=0,zoom:n=0,nearZMultiplier:r=.5,farZMultiplier:i=1,resolution:s=10}=e;let{latitude:o=0,height:a,altitude:A=1.5,fovy:l}=e;o=Math.max(Math.min(o,gc),-85.051129),a=a||1,l?A=Ec(l):l=xc(A);const c=1/Math.PI/Math.cos(o*Math.PI/180),u=Math.pow(2,n)*c,h=e.nearZ??r,d=e.farZ??(A+512*u/a)*i,f=(new mA).lookAt({eye:[0,-A,0],up:[0,0,1]});f.rotateX(o*dg),f.rotateZ(-t*dg),f.scale(u/a),super({...e,height:a,viewMatrix:f,longitude:t,latitude:o,zoom:n,distanceScales:mg(),fovy:l,focalDistance:A,near:h,far:d}),this.scale=u,this.latitude=o,this.longitude=t,this.resolution=s}get projectionMode(){return jl.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){const t={targetZ:e.z||0},n=this.unproject([0,this.height/2],t),r=this.unproject([this.width/2,0],t),i=this.unproject([this.width,this.height/2],t),s=this.unproject([this.width/2,this.height],t);return i[0]<this.longitude&&(i[0]+=360),n[0]>this.longitude&&(n[0]-=360),[Math.min(n[0],i[0],r[0],s[0]),Math.min(n[1],i[1],r[1],s[1]),Math.max(n[0],i[0],r[0],s[0]),Math.max(n[1],i[1],r[1],s[1])]}unproject(e,{topLeft:t=!0,targetZ:n}={}){const[r,i,s]=e,o=t?i:this.height-i,{pixelUnprojectionMatrix:a}=this;let A;if(Number.isFinite(s))A=bg(a,[r,o,s,1]);else{const e=bg(a,[r,o,-1,1]),t=bg(a,[r,o,1,1]),i=((n||0)/pg+1)*gg,s=Ka(qa([],e,t)),l=Ka(e),c=Ka(t),u=(4*l*c-(s-l-c)**2)/16*4/s;A=function(e,t,n,r){const i=t[0],s=t[1],o=t[2];return e[0]=i+r*(n[0]-i),e[1]=s+r*(n[1]-s),e[2]=o+r*(n[2]-o),e}([],e,t,(Math.sqrt(l-u)-Math.sqrt(Math.max(0,i*i-u)))/Math.sqrt(s))}const[l,c,u]=this.unprojectPosition(A);return Number.isFinite(s)?[l,c,u]:Number.isFinite(n)?[l,c,n]:[l,c]}projectPosition(e){const[t,n,r=0]=e,i=t*dg,s=n*dg,o=Math.cos(s),a=(r/pg+1)*gg;return[Math.sin(i)*o*a,-Math.cos(i)*o*a,Math.sin(s)*a]}unprojectPosition(e){const[t,n,r]=e,i=function(e){const t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}(e),s=Math.asin(r/i);return[Math.atan2(t,-n)*fg,s*fg,(i/gg-1)*pg]}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 bg(e,t){const n=lA([],t,e);return AA(n,n,1/n[3]),n}class vg extends Uh{applyConstraints(e){const{maxZoom:t,minZoom:n,zoom:r}=e;e.zoom=Da(r,n,t);const{longitude:i,latitude:s}=e;return(i<-180||i>180)&&(e.longitude=function(e){const t=e%360;return t<0?360+t:t}(i+180)-180),e.latitude=Da(s,-85.051129,gc),e}}class yg extends Oh{constructor(){super(...arguments),this.ControllerState=vg,this.transition={transitionDuration:300,transitionInterpolator:new Ch(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}}class wg extends _h{constructor(e={}){super(e)}getViewportType(e){return e.zoom>12?_u:_g}get ControllerType(){return yg}}wg.displayName="GlobeView";class xg{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;const{attributes:t={}}=e;this.typedArrayManager=ou,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);const{data:t,buffers:n={},getGeometry:r,geometryBuffer:i,positionFormat:s,dataChanged:o,normalize:a=!0}=this.opts;if(this.data=t,this.getGeometry=r,this.positionSize=i&&i.size||("XY"===s?2:3),this.buffers=n,this.normalize=a,i&&(xh(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(i),a||(n.vertexPositions=i)),this.geometryBuffer=n.vertexPositions,Array.isArray(o))for(const A of o)this._rebuildGeometry(A);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)?dp(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){const{attributes:n,buffers:r,_attributeDefs:i,typedArrayManager:s}=this;for(const o in i)if(o in r)s.release(n[o]),n[o]=null;else{const r=i[o];r.copy=t,n[o]=s.allocate(n[o],e,r)}}_forEachGeometry(e,t,n){const{data:r,getGeometry:i}=this,{iterable:s,objectInfo:o}=up(r,t,n);for(const a of s)o.index++,e(i?i(a,o):null,o.index)}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:n,instanceCount:r}=this;const{data:i,geometryBuffer:s}=this,{startRow:o=0,endRow:a=1/0}=e||{},A={};if(e||(t=[0],n=[0]),this.normalize||!s)this._forEachGeometry((e,t)=>{const r=e&&this.normalizeGeometry(e);A[t]=r,n[t+1]=n[t]+(r?this.getGeometrySize(r):0)},o,a),r=n[n.length-1];else if(n=i.startIndices,r=n[i.length]||0,ArrayBuffer.isView(s))r=r||s.length/this.positionSize;else if(s instanceof Ur){const e=4*this.positionSize;r=r||s.byteLength/e}else if(s.buffer){const e=s.stride||4*this.positionSize;r=r||s.buffer.byteLength/e}else if(s.value){const e=s.value,t=s.stride/e.BYTES_PER_ELEMENT||this.positionSize;r=r||e.length/t}this._allocate(r,Boolean(e)),this.indexStarts=t,this.vertexStarts=n,this.instanceCount=r;const l={};this._forEachGeometry((e,i)=>{const s=A[i]||e;l.vertexStart=n[i],l.indexStart=t[i];const o=i<n.length-1?n[i+1]:r;l.geometrySize=o-n[i],l.geometryIndex=i,this.updateGeometryAttributes(s,l)},o,a),this.vertexCount=t[t.length-1]}}function Eg(e,t,n={}){const r=function(e,t={}){return Math.sign(function(e,t={}){const{start:n=0,end:r=e.length,plane:i="xy"}=t,s=t.size||2;let o=0;const a=Tg[i[0]],A=Tg[i[1]];for(let l=n,c=r-s;l<r;l+=s)o+=(e[l+a]-e[c+a])*(e[l+A]+e[c+A]),c=l;return o/2}(e,t))}(e,n);return r!==t&&(function(e,t){const{start:n=0,end:r=e.length,size:i=2}=t,s=(r-n)/i,o=Math.floor(s/2);for(let a=0;a<o;++a){const t=n+a*i,r=n+(s-1-a)*i;for(let n=0;n<i;++n){const i=e[t+n];e[t+n]=e[r+n],e[r+n]=i}}}(e,n),!0)}const Tg={x:0,y:1,z:2};function Sg(e,t){const n=t.length,r=e.length;if(r>0){let i=!0;for(let s=0;s<n;s++)if(e[r-n+s]!==t[s]){i=!1;break}if(i)return!1}for(let i=0;i<n;i++)e[r+i]=t[i];return!0}function Cg(e,t){const n=t.length;for(let r=0;r<n;r++)e[r]=t[r]}function kg(e,t,n,r,i=[]){const s=r+t*n;for(let o=0;o<n;o++)i[o]=e[s+o];return i}function Rg(e,t,n,r,i=[]){let s,o;if(8&n)s=(r[3]-e[1])/(t[1]-e[1]),o=3;else if(4&n)s=(r[1]-e[1])/(t[1]-e[1]),o=1;else if(2&n)s=(r[2]-e[0])/(t[0]-e[0]),o=2;else{if(!(1&n))return null;s=(r[0]-e[0])/(t[0]-e[0]),o=0}for(let a=0;a<e.length;a++)i[a]=(1&o)===a?r[o]:s*(t[a]-e[a])+e[a];return i}function Pg(e,t){let n=0;return e[0]<t[0]?n|=1:e[0]>t[2]&&(n|=2),e[1]<t[1]?n|=4:e[1]>t[3]&&(n|=8),n}function Ig(e,t){const{size:n=2,broken:r=!1,gridResolution:i=10,gridOffset:s=[0,0],startIndex:o=0,endIndex:a=e.length}=t||{},A=(a-o)/n;let l=[];const c=[l],u=kg(e,0,n,o);let h,d;const f=Ng(u,i,s,[]),p=[];Sg(l,u);for(let g=1;g<A;g++){for(h=kg(e,g,n,o,h),d=Pg(h,f);d;){Rg(u,h,d,f,p);const e=Pg(p,f);e&&(Rg(u,p,e,f,p),d=e),Sg(l,p),Cg(u,p),Bg(f,i,d),r&&l.length>n&&(l=[],c.push(l),Sg(l,u)),d=Pg(h,f)}Sg(l,h),Cg(u,h)}return r?c:c[0]}function Mg(e,t=null,n){if(!e.length)return[];const{size:r=2,gridResolution:i=10,gridOffset:s=[0,0],edgeTypes:o=!1}=n||{},a=[],A=[{pos:e,types:o?new Array(e.length/r).fill(1):null,holes:t||[]}],l=[[],[]];let c=[];for(;A.length;){const{pos:e,types:t,holes:n}=A.shift();Dg(e,r,n[0]||e.length,l),c=Ng(l[0],i,s,c);const u=Pg(l[1],c);if(u){let i=Lg(e,t,r,0,n[0]||e.length,c,u);const s={pos:i[0].pos,types:i[0].types,holes:[]},a={pos:i[1].pos,types:i[1].types,holes:[]};A.push(s,a);for(let A=0;A<n.length;A++)i=Lg(e,t,r,n[A],n[A+1]||e.length,c,u),i[0]&&(s.holes.push(s.pos.length),s.pos=Og(s.pos,i[0].pos),o&&(s.types=Og(s.types,i[0].types))),i[1]&&(a.holes.push(a.pos.length),a.pos=Og(a.pos,i[1].pos),o&&(a.types=Og(a.types,i[1].types)))}else{const r={positions:e};o&&(r.edgeTypes=t),n.length&&(r.holeIndices=n),a.push(r)}}return a}function Lg(e,t,n,r,i,s,o){const a=(i-r)/n,A=[],l=[],c=[],u=[],h=[];let d,f,p;const g=kg(e,a-1,n,r);let m=Math.sign(8&o?g[1]-s[3]:g[0]-s[2]),_=t&&t[a-1],b=0,v=0;for(let y=0;y<a;y++)d=kg(e,y,n,r,d),f=Math.sign(8&o?d[1]-s[3]:d[0]-s[2]),p=t&&t[r/n+y],f&&m&&m!==f&&(Rg(g,d,o,s,h),Sg(A,h)&&c.push(_),Sg(l,h)&&u.push(_)),f<=0?(Sg(A,d)&&c.push(p),b-=f):c.length&&(c[c.length-1]=0),f>=0?(Sg(l,d)&&u.push(p),v+=f):u.length&&(u[u.length-1]=0),Cg(g,d),m=f,_=p;return[b?{pos:A,types:t&&c}:null,v?{pos:l,types:t&&u}:null]}function Ng(e,t,n,r){const i=Math.floor((e[0]-n[0])/t)*t+n[0],s=Math.floor((e[1]-n[1])/t)*t+n[1];return r[0]=i,r[1]=s,r[2]=i+t,r[3]=s+t,r}function Bg(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 Dg(e,t,n,r){let i=1/0,s=-1/0,o=1/0,a=-1/0;for(let A=0;A<n;A+=t){const t=e[A],n=e[A+1];i=t<i?t:i,s=t>s?t:s,o=n<o?n:o,a=n>a?n:a}return r[0][0]=i,r[0][1]=o,r[1][0]=s,r[1][1]=a,r}function Og(e,t){for(let n=0;n<t.length;n++)e.push(t[n]);return e}function Fg(e,t,n,r){let i=-1,s=-1;for(let o=n+1;o<r;o+=t){const t=Math.abs(e[o]);t>i&&(i=t,s=o-1)}return s}function Ug(e,t,n,r,i=85.051129){const s=e[n],o=e[r-t];if(Math.abs(s-o)>180){const r=kg(e,0,t,n);r[0]+=360*Math.round((o-s)/360),Sg(e,r),r[1]=Math.sign(r[1])*i,Sg(e,r),r[0]=s,Sg(e,r)}}function jg(e,t,n,r){let i,s=e[0];for(let o=n;o<r;o+=t){i=e[o];const t=i-s;(t>180||t<-180)&&(i-=360*Math.round(t/360)),e[o]=s=i}}function Gg(e,t){let n;const r=e.length/t;for(let s=0;s<r&&(n=e[s*t],(n+180)%360==0);s++);const i=360*-Math.round(n/360);if(0!==i)for(let s=0;s<r;s++)e[s*t]+=i}class zg extends Ku{constructor(e){const{indices:t,attributes:n}=function(e){const{radius:t,height:n=1,nradial:r=10}=e;let{vertices:i}=e;i&&(Hn.assert(i.length>=r),i=i.flatMap(e=>[e[0],e[1]]),Eg(i,-1));const s=n>0,o=r+1,a=s?3*o+1:r,A=2*Math.PI/r,l=new Uint16Array(s?3*r*2:0),c=new Float32Array(3*a),u=new Float32Array(3*a);let h=0;if(s){for(let e=0;e<o;e++){const s=e*A,o=e%r,a=Math.sin(s),l=Math.cos(s);for(let e=0;e<2;e++)c[h+0]=i?i[2*o]:l*t,c[h+1]=i?i[2*o+1]:a*t,c[h+2]=(.5-e)*n,u[h+0]=i?i[2*o]:l,u[h+1]=i?i[2*o+1]:a,h+=3}c[h+0]=c[h-3],c[h+1]=c[h-2],c[h+2]=c[h-1],h+=3}for(let d=s?0:1;d<o;d++){const e=Math.floor(d/2)*Math.sign(.5-d%2),s=e*A,o=(e+r)%r,a=Math.sin(s),l=Math.cos(s);c[h+0]=i?i[2*o]:l*t,c[h+1]=i?i[2*o+1]:a*t,c[h+2]=n/2,u[h+2]=1,h+=3}if(s){let e=0;for(let t=0;t<r;t++)l[e++]=2*t+0,l[e++]=2*t+2,l[e++]=2*t+0,l[e++]=2*t+1,l[e++]=2*t+1,l[e++]=2*t+3}return{indices:l,attributes:{POSITION:{size:3,value:c},NORMAL:{size:3,value:u}}}}(e);super({...e,indices:t,attributes:n})}}const Vg="uniform columnUniforms {\n float radius;\n float angle;\n vec2 offset;\n bool extruded;\n bool stroked;\n bool isStroke;\n float coverage;\n float elevationScale;\n float edgeDistance;\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n highp int radiusUnits;\n highp int widthUnits;\n} column;\n",Wg={name:"column",vs:Vg,fs:Vg,uniformTypes:{radius:"f32",angle:"f32",offset:"vec2<f32>",extruded:"f32",stroked:"f32",isStroke:"f32",coverage:"f32",elevationScale:"f32",edgeDistance:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",radiusUnits:"i32",widthUnits:"i32"}},Hg=[0,0,0,255],$g={diskResolution:{type:"number",min:4,value:20},vertices:null,radius:{type:"number",min:0,value:1e3},angle:{type:"number",value:0},offset:{type:"array",value:[0,0]},coverage:{type:"number",min:0,max:1,value:1},elevationScale:{type:"number",min:0,value:1},radiusUnits:"meters",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,extruded:!0,wireframe:!1,filled:!0,stroked:!1,flatShading:!1,getPosition:{type:"accessor",value:e=>e.position},getFillColor:{type:"accessor",value:Hg},getLineColor:{type:"accessor",value:Hg},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class Xg extends ug{getShaders(){const e={},{flatShading:t}=this.props;return t&&(e.FLAT_SHADING=1),super.getShaders({vs:"#version 300 es\n#define SHADER_NAME column-layer-vertex-shader\nin vec3 positions;\nin vec3 normals;\nin vec3 instancePositions;\nin float instanceElevations;\nin vec3 instancePositions64Low;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin float instanceStrokeWidths;\nin vec3 instancePickingColors;\nout vec4 vColor;\n#ifdef FLAT_SHADING\nout vec3 cameraPosition;\nout vec4 position_commonspace;\n#endif\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nvec4 color = column.isStroke ? instanceLineColors : instanceFillColors;\nmat2 rotationMatrix = mat2(cos(column.angle), sin(column.angle), -sin(column.angle), cos(column.angle));\nfloat elevation = 0.0;\nfloat strokeOffsetRatio = 1.0;\nif (column.extruded) {\nelevation = instanceElevations * (positions.z + 1.0) / 2.0 * column.elevationScale;\n} else if (column.stroked) {\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceStrokeWidths * column.widthScale, column.widthUnits),\ncolumn.widthMinPixels, column.widthMaxPixels) / 2.0;\nfloat halfOffset = project_pixel_size(widthPixels) / project_size(column.edgeDistance * column.coverage * column.radius);\nif (column.isStroke) {\nstrokeOffsetRatio -= sign(positions.z) * halfOffset;\n} else {\nstrokeOffsetRatio -= halfOffset;\n}\n}\nfloat shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);\nfloat dotRadius = column.radius * column.coverage * shouldRender;\ngeometry.pickingColor = instancePickingColors;\nvec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation);\nvec3 centroidPosition64Low = instancePositions64Low;\nvec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + column.offset) * dotRadius;\nif (column.radiusUnits == UNIT_METERS) {\noffset = project_size(offset);\n}\nvec3 pos = vec3(offset, 0.);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);\ngeometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z));\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (column.extruded && !column.isStroke) {\n#ifdef FLAT_SHADING\ncameraPosition = project.cameraPosition;\nposition_commonspace = geometry.position;\nvColor = vec4(color.rgb, color.a * layer.opacity);\n#else\nvec3 lightColor = lighting_getLightColor(color.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, color.a * layer.opacity);\n#endif\n} else {\nvColor = vec4(color.rgb, color.a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME column-layer-fragment-shader\nprecision highp float;\nout vec4 fragColor;\nin vec4 vColor;\n#ifdef FLAT_SHADING\nin vec3 cameraPosition;\nin vec4 position_commonspace;\n#endif\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\n#ifdef FLAT_SHADING\nif (column.extruded && !column.isStroke && !bool(picking.isActive)) {\nvec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\nfragColor.rgb = lighting_getLightColor(vColor.rgb, cameraPosition, position_commonspace.xyz, normal);\n}\n#endif\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:e,modules:[sc,t?BA:NA,Oc,Wg]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:Hg},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:Hg},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(e){var t;super.updateState(e);const{props:n,oldProps:r,changeFlags:i}=e,s=i.extensionsChanged||n.flatShading!==r.flatShading;s&&(null==(t=this.state.models)||t.forEach(e=>e.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());const o=this.getNumInstances();this.state.fillModel.setInstanceCount(o),this.state.wireframeModel.setInstanceCount(o),(s||n.diskResolution!==r.diskResolution||n.vertices!==r.vertices||(n.extruded||n.stroked)!==(r.extruded||r.stroked))&&this._updateGeometry(n)}getGeometry(e,t,n){const r=new zg({radius:1,height:n?2:0,vertices:t,nradial:e});let i=0;if(t)for(let s=0;s<e;s++){const n=t[s];i+=Math.sqrt(n[0]*n[0]+n[1]*n[1])/e}else i=1;return this.setState({edgeDistance:Math.cos(Math.PI/e)*i}),r}_getModels(){const e=this.getShaders(),t=this.getAttributeManager().getBufferLayouts(),n=new Xu(this.context.device,{...e,id:`${this.props.id}-fill`,bufferLayout:t,isInstanced:!0}),r=new Xu(this.context.device,{...e,id:`${this.props.id}-wireframe`,bufferLayout:t,isInstanced:!0});return{fillModel:n,wireframeModel:r,models:[r,n]}}_updateGeometry({diskResolution:e,vertices:t,extruded:n,stroked:r}){const i=this.getGeometry(e,t,n||r);this.setState({fillVertexCount:i.attributes.POSITION.value.length/3});const s=this.state.fillModel,o=this.state.wireframeModel;s.setGeometry(i),s.setTopology("triangle-strip"),s.setIndexBuffer(null),o.setGeometry(i),o.setTopology("line-list")}draw({uniforms:e}){const{lineWidthUnits:t,lineWidthScale:n,lineWidthMinPixels:r,lineWidthMaxPixels:i,radiusUnits:s,elevationScale:o,extruded:a,filled:A,stroked:l,wireframe:c,offset:u,coverage:h,radius:d,angle:f}=this.props,p=this.state.fillModel,g=this.state.wireframeModel,{fillVertexCount:m,edgeDistance:_}=this.state,b={radius:d,angle:f/180*Math.PI,offset:u,extruded:a,stroked:l,coverage:h,elevationScale:o,edgeDistance:_,radiusUnits:Gl[s],widthUnits:Gl[t],widthScale:n,widthMinPixels:r,widthMaxPixels:i};a&&c&&(g.shaderInputs.setProps({column:{...b,isStroke:!0}}),g.draw(this.context.renderPass)),A&&(p.setVertexCount(m),p.shaderInputs.setProps({column:{...b,isStroke:!1}}),p.draw(this.context.renderPass)),!a&&l&&(p.setVertexCount(2*m/3),p.shaderInputs.setProps({column:{...b,isStroke:!0}}),p.draw(this.context.renderPass))}}Xg.layerName="ColumnLayer",Xg.defaultProps=$g;class Qg extends xg{constructor(e){super({...e,attributes:{positions:{size:3,padding:18,initialize:!0,type:e.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(e){return this.attributes[e]}getGeometryFromBuffer(e){return this.normalize?super.getGeometryFromBuffer(e):null}normalizeGeometry(e){return this.normalize?function(e,t,n,r){let i;if(Array.isArray(e[0])){const n=e.length*t;i=new Array(n);for(let r=0;r<e.length;r++)for(let n=0;n<t;n++)i[r*t+n]=e[r][n]||0}else i=e;return n?Ig(i,{size:t,gridResolution:n}):r?function(e,t){const{size:n=2,startIndex:r=0,endIndex:i=e.length,normalize:s=!0}=t||{},o=e.slice(r,i);jg(o,n,0,i-r);const a=Ig(o,{size:n,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(s)for(const A of a)Gg(A,n);return a}(i,{size:t}):i}(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(Yg(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&&Yg(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,r=!!e&&this.isClosed(e),{vertexStart:i,geometrySize:s}=t;n.fill(0,i,i+s),r?(n[i]=4,n[i+s-2]=4):(n[i]+=1,n[i+s-2]+=2),n[i+s-1]=4}_updatePositions(e,t){const{positions:n}=this.attributes;if(!n||!e)return;const{vertexStart:r,geometrySize:i}=t,s=new Array(3);for(let o=r,a=0;a<i;o++,a++)this.getPointOnPath(e,a,s),n[3*o]=s[0],n[3*o+1]=s[1],n[3*o+2]=s[2]}getPathLength(e){return e.length/this.positionSize}getPointOnPath(e,t,n=[]){const{positionSize:r}=this;t*r>=e.length&&(t+=1-e.length/r);const i=t*r;return n[0]=e[i],n[1]=e[i+1],n[2]=3===r&&e[i+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 Yg(e){return Array.isArray(e[0])}const qg="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",Kg={name:"path",vs:qg,fs:qg,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}},Zg=[0,0,0,255],Jg={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:Zg},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},em={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class tm extends ug{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:[sc,Oc,Kg]})}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:em,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:em,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:em,defaultValue:Zg},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 Qg({fp64:this.use64bitPositions()})})}updateState(e){var t;super.updateState(e);const{props:n,changeFlags:r}=e,i=this.getAttributeManager();if(r.dataChanged||r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.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:r.dataChanged}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts}),r.dataChanged||i.invalidateAll()}r.extensionsChanged&&(null==(t=this.state.model)||t.destroy(),this.state.model=this._getModel(),i.invalidateAll())}getPickingInfo(e){const t=super.getPickingInfo(e),{index:n}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.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<t.length;n++)t[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){const{jointRounded:t,capRounded:n,billboard:r,miterLimit:i,widthUnits:s,widthScale:o,widthMinPixels:a,widthMaxPixels:A}=this.props,l=this.state.model,c={jointType:Number(t),capType:Number(n),billboard:r,widthUnits:Gl[s],widthScale:o,miterLimit:i,widthMinPixels:a,widthMaxPixels:A};l.shaderInputs.setProps({path:c}),l.draw(this.context.renderPass)}_getModel(){return new Xu(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ku({topology:"triangle-list",attributes:{indices:new Uint16Array([0,1,2,1,4,2,1,3,4,3,5,4]),positions:{value:new Float32Array([0,0,0,-1,0,1,1,-1,1,1,1,0]),size:2}}}),isInstanced:!0})}calculatePositions(e){const{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("positions")}calculateSegmentTypes(e){const{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("segmentTypes")}}tm.defaultProps=Jg,tm.layerName="PathLayer";var nm,rm={exports:{}},im=function(){if(nm)return rm.exports;function e(e,n,i){i=i||2;var s,o,a,c,u,d,f,p=n&&n.length,g=p?n[0]*i:e.length,m=t(e,0,g,i,!0),_=[];if(!m||m.next===m.prev)return _;if(p&&(m=function(e,n,r,i){var s,o,a,c=[];for(s=0,o=n.length;s<o;s++)(a=t(e,n[s]*i,s<o-1?n[s+1]*i:e.length,i,!1))===a.next&&(a.steiner=!0),c.push(h(a));for(c.sort(A),s=0;s<c.length;s++)r=l(c[s],r);return r}(e,n,m,i)),e.length>80*i){s=a=e[0],o=c=e[1];for(var b=i;b<g;b+=i)(u=e[b])<s&&(s=u),(d=e[b+1])<o&&(o=d),u>a&&(a=u),d>c&&(c=d);f=0!==(f=Math.max(a-s,c-o))?32767/f:0}return r(m,_,i,s,o,f,0),_}function t(e,t,n,r,i){var s,o;if(i===T(e,t,n,r)>0)for(s=t;s<n;s+=r)o=w(s,e[s],e[s+1],o);else for(s=n-r;s>=t;s-=r)o=w(s,e[s],e[s+1],o);return o&&g(o,o.next)&&(x(o),o=o.next),o}function n(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!g(r,r.next)&&0!==p(r.prev,r,r.next))r=r.next;else{if(x(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function r(e,t,A,l,c,h,d){if(e){!d&&h&&function(e,t,n,r){var i=e;do{0===i.z&&(i.z=u(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,s,o,a,A,l=1;do{for(n=e,e=null,s=null,o=0;n;){for(o++,r=n,a=0,t=0;t<l&&(a++,r=r.nextZ);t++);for(A=l;a>0||A>0&&r;)0!==a&&(0===A||!r||n.z<=r.z)?(i=n,n=n.nextZ,a--):(i=r,r=r.nextZ,A--),s?s.nextZ=i:e=i,i.prevZ=s,s=i;n=r}s.nextZ=null,l*=2}while(o>1)}(i)}(e,l,c,h);for(var f,p,g=e;e.prev!==e.next;)if(f=e.prev,p=e.next,h?s(e,l,c,h):i(e))t.push(f.i/A|0),t.push(e.i/A|0),t.push(p.i/A|0),x(e),e=p.next,g=p.next;else if((e=p)===g){d?1===d?r(e=o(n(e),t,A),t,A,l,c,h,2):2===d&&a(e,t,A,l,c,h):r(n(e),t,A,l,c,h,1);break}}}function i(e){var t=e.prev,n=e,r=e.next;if(p(t,n,r)>=0)return!1;for(var i=t.x,s=n.x,o=r.x,a=t.y,A=n.y,l=r.y,c=i<s?i<o?i:o:s<o?s:o,u=a<A?a<l?a:l:A<l?A:l,h=i>s?i>o?i:o:s>o?s:o,f=a>A?a>l?a:l:A>l?A:l,g=r.next;g!==t;){if(g.x>=c&&g.x<=h&&g.y>=u&&g.y<=f&&d(i,a,s,A,o,l,g.x,g.y)&&p(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function s(e,t,n,r){var i=e.prev,s=e,o=e.next;if(p(i,s,o)>=0)return!1;for(var a=i.x,A=s.x,l=o.x,c=i.y,h=s.y,f=o.y,g=a<A?a<l?a:l:A<l?A:l,m=c<h?c<f?c:f:h<f?h:f,_=a>A?a>l?a:l:A>l?A:l,b=c>h?c>f?c:f:h>f?h:f,v=u(g,m,t,n,r),y=u(_,b,t,n,r),w=e.prevZ,x=e.nextZ;w&&w.z>=v&&x&&x.z<=y;){if(w.x>=g&&w.x<=_&&w.y>=m&&w.y<=b&&w!==i&&w!==o&&d(a,c,A,h,l,f,w.x,w.y)&&p(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,x.x>=g&&x.x<=_&&x.y>=m&&x.y<=b&&x!==i&&x!==o&&d(a,c,A,h,l,f,x.x,x.y)&&p(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;w&&w.z>=v;){if(w.x>=g&&w.x<=_&&w.y>=m&&w.y<=b&&w!==i&&w!==o&&d(a,c,A,h,l,f,w.x,w.y)&&p(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;x&&x.z<=y;){if(x.x>=g&&x.x<=_&&x.y>=m&&x.y<=b&&x!==i&&x!==o&&d(a,c,A,h,l,f,x.x,x.y)&&p(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function o(e,t,r){var i=e;do{var s=i.prev,o=i.next.next;!g(s,o)&&m(s,i,i.next,o)&&v(s,o)&&v(o,s)&&(t.push(s.i/r|0),t.push(i.i/r|0),t.push(o.i/r|0),x(i),x(i.next),i=e=o),i=i.next}while(i!==e);return n(i)}function a(e,t,i,s,o,a){var A=e;do{for(var l=A.next.next;l!==A.prev;){if(A.i!==l.i&&f(A,l)){var c=y(A,l);return A=n(A,A.next),c=n(c,c.next),r(A,t,i,s,o,a,0),void r(c,t,i,s,o,a,0)}l=l.next}A=A.next}while(A!==e)}function A(e,t){return e.x-t.x}function l(e,t){var r=function(e,t){var n,r=t,i=e.x,s=e.y,o=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>o&&(o=a,n=r.x<r.next.x?r:r.next,a===i))return n}r=r.next}while(r!==t);if(!n)return null;var A,l=n,u=n.x,h=n.y,f=1/0;r=n;do{i>=r.x&&r.x>=u&&i!==r.x&&d(s<h?i:o,s,u,h,s<h?o:i,s,r.x,r.y)&&(A=Math.abs(s-r.y)/(i-r.x),v(r,e)&&(A<f||A===f&&(r.x>n.x||r.x===n.x&&c(n,r)))&&(n=r,f=A)),r=r.next}while(r!==l);return n}(e,t);if(!r)return t;var i=y(r,e);return n(i,i.next),n(r,r.next)}function c(e,t){return p(e.prev,e,t.prev)<0&&p(t.next,e,e.next)<0}function u(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function h(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function d(e,t,n,r,i,s,o,a){return(i-o)*(t-a)>=(e-o)*(s-a)&&(e-o)*(r-a)>=(n-o)*(t-a)&&(n-o)*(s-a)>=(i-o)*(r-a)}function f(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&m(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(v(e,t)&&v(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&i<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(p(e.prev,e,t.prev)||p(e,t.prev,t))||g(e,t)&&p(e.prev,e,e.next)>0&&p(t.prev,t,t.next)>0)}function p(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function g(e,t){return e.x===t.x&&e.y===t.y}function m(e,t,n,r){var i=b(p(e,t,n)),s=b(p(e,t,r)),o=b(p(n,r,e)),a=b(p(n,r,t));return i!==s&&o!==a||!(0!==i||!_(e,n,t))||!(0!==s||!_(e,r,t))||!(0!==o||!_(n,e,r))||!(0!==a||!_(n,t,r))}function _(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function b(e){return e>0?1:e<0?-1:0}function v(e,t){return p(e.prev,e,e.next)<0?p(e,t,e.next)>=0&&p(e,e.prev,t)>=0:p(e,t,e.prev)<0||p(e,e.next,t)<0}function y(e,t){var n=new E(e.i,e.x,e.y),r=new E(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,s.next=r,r.prev=s,r}function w(e,t,n,r){var i=new E(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function x(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function E(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function T(e,t,n,r){for(var i=0,s=t,o=n-r;s<n;s+=r)i+=(e[o]-e[s])*(e[s+1]+e[o+1]),o=s;return i}return nm=1,rm.exports=e,rm.exports.default=e,e.deviation=function(e,t,n,r){var i=t&&t.length,s=i?t[0]*n:e.length,o=Math.abs(T(e,0,s,n));if(i)for(var a=0,A=t.length;a<A;a++){var l=t[a]*n,c=a<A-1?t[a+1]*n:e.length;o-=Math.abs(T(e,l,c,n))}var u=0;for(a=0;a<r.length;a+=3){var h=r[a]*n,d=r[a+1]*n,f=r[a+2]*n;u+=Math.abs((e[h]-e[f])*(e[d+1]-e[h+1])-(e[h]-e[d])*(e[f+1]-e[h+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},e.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var s=0;s<e[i].length;s++)for(var o=0;o<t;o++)n.vertices.push(e[i][s][o]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n},rm.exports}();const sm=j(im),om={};function am(e){return"positions"in e?e.positions:e}function Am(e){return"holeIndices"in e?e.holeIndices:null}function lm(e,t,n,r,i){let s=t;const o=n.length;for(let a=0;a<o;a++)for(let t=0;t<r;t++)e[s++]=n[a][t]||0;if(!function(e){const t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]}(n))for(let a=0;a<r;a++)e[s++]=n[0][a]||0;return om.start=t,om.end=s,om.size=r,Eg(e,i,om),s}function cm(e,t,n,r,i=0,s,o){const a=(s=s||n.length)-i;if(a<=0)return t;let A=t;for(let l=0;l<a;l++)e[A++]=n[i+l];if(!function(e,t,n,r){for(let i=0;i<t;i++)if(e[n+i]!==e[r-t+i])return!1;return!0}(n,r,i,s))for(let l=0;l<r;l++)e[A++]=n[i+l];return om.start=t,om.end=A,om.size=r,Eg(e,o,om),A}function um(e,t){!function(e){if(e=e&&e.positions||e,!Array.isArray(e)&&!ArrayBuffer.isView(e))throw new Error("invalid polygon")}(e);const n=[],r=[];if("positions"in e){const{positions:i,holeIndices:s}=e;if(s){let e=0;for(let o=0;o<=s.length;o++)e=cm(n,e,i,t,s[o-1],s[o],0===o?1:-1),r.push(e);return r.pop(),{positions:n,holeIndices:r}}e=i}if(!function(e){return Array.isArray(e[0])}(e))return cm(n,0,e,t,0,n.length,1),n;if(!function(e){return e.length>=1&&e[0].length>=2&&Number.isFinite(e[0][0])}(e)){let i=0;for(const[s,o]of e.entries())i=lm(n,i,o,t,0===s?1:-1),r.push(i);return r.pop(),{positions:n,holeIndices:r}}return lm(n,0,e,t,1),n}function hm(e,t,n){const r=e.length/3;let i=0;for(let s=0;s<r;s++){const o=(s+1)%r;i+=e[3*s+t]*e[3*o+n],i-=e[3*o+t]*e[3*s+n]}return Math.abs(i/2)}function dm(e,t,n,r){const i=e.length/3;for(let s=0;s<i;s++){const i=3*s,o=e[i+0],a=e[i+1],A=e[i+2];e[i+t]=o,e[i+n]=a,e[i+r]=A}}class fm extends xg{constructor(e){const{fp64:t,IndexType:n=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:t?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:n,size:1}}})}get(e){const{attributes:t}=this;return"indices"===e?t.indices&&t.indices.subarray(0,this.vertexCount):t[e]}updateGeometry(e){super.updateGeometry(e);const t=this.buffers.indices;if(t)this.vertexCount=(t.value||t).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){const t=um(e,this.positionSize);return this.opts.resolution?Mg(am(t),Am(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?function(e,t=null,n){const{size:r=2,normalize:i=!0,edgeTypes:s=!1}=n||{};t=t||[];const o=[],a=[];let A=0,l=0;for(let u=0;u<=t.length;u++){const i=t[u]||e.length,s=l,c=Fg(e,r,A,i);for(let t=c;t<i;t++)o[l++]=e[t];for(let t=A;t<c;t++)o[l++]=e[t];jg(o,r,s,l),Ug(o,r,s,l,null==n?void 0:n.maxLatitude),A=i,a[u]=l}a.pop();const c=Mg(o,a,{size:r,gridResolution:360,gridOffset:[-180,-180],edgeTypes:s});if(i)for(const u of c)Gg(u.positions,r);return c}(am(t),Am(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(pm(e)){let t=0;for(const n of e)t+=this.getGeometrySize(n);return t}return am(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&pm(e))for(const n of e){const e=this.getGeometrySize(n);t.geometrySize=e,this.updateGeometryAttributes(n,t),t.vertexStart+=e,t.indexStart=this.indexStarts[t.geometryIndex+1]}else{const n=e;this._updateIndices(n,t),this._updatePositions(n,t),this._updateVertexValid(n,t)}}_updateIndices(e,{geometryIndex:t,vertexStart:n,indexStart:r}){const{attributes:i,indexStarts:s,typedArrayManager:o}=this;let a=i.indices;if(!a||!e)return;let A=r;const l=function(e,t,n,r){let i=Am(e);i&&(i=i.map(e=>e/t));let s=am(e);const o=r&&3===t;if(n){const e=s.length;s=s.slice();const r=[];for(let i=0;i<e;i+=t){r[0]=s[i],r[1]=s[i+1],o&&(r[2]=s[i+2]);const e=n(r);s[i]=e[0],s[i+1]=e[1],o&&(s[i+2]=e[2])}}if(o){const e=hm(s,0,1),t=hm(s,0,2),r=hm(s,1,2);if(!e&&!t&&!r)return[];e>t&&e>r||(t>r?(n||(s=s.slice()),dm(s,0,2,1)):(n||(s=s.slice()),dm(s,2,0,1)))}return sm(s,i,t)}(e,this.positionSize,this.opts.preproject,this.opts.full3d);a=o.allocate(a,r+l.length,{copy:!0});for(let c=0;c<l.length;c++)a[A++]=l[c]+n;s[t+1]=r+l.length,i.indices=a}_updatePositions(e,{vertexStart:t,geometrySize:n}){const{attributes:{positions:r},positionSize:i}=this;if(!r||!e)return;const s=am(e);for(let o=t,a=0;a<n;o++,a++){const e=s[a*i],t=s[a*i+1],n=i>2?s[a*i+2]:0;r[3*o]=e,r[3*o+1]=t,r[3*o+2]=n}}_updateVertexValid(e,{vertexStart:t,geometrySize:n}){const{positionSize:r}=this,i=this.attributes.vertexValid,s=e&&Am(e);if(e&&e.edgeTypes?i.set(e.edgeTypes,t):i.fill(1,t,t+n),s)for(let o=0;o<s.length;o++)i[t+s[o]/r-1]=0;i[t+n-1]=0}}function pm(e){return Array.isArray(e)&&e.length>0&&!Number.isFinite(e[0])}const gm="uniform solidPolygonUniforms {\n bool extruded;\n bool isWireframe;\n float elevationScale;\n} solidPolygon;\n",mm={name:"solidPolygon",vs:gm,fs:gm,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}},_m="in vec4 fillColors;\nin vec4 lineColors;\nin vec3 pickingColors;\nout vec4 vColor;\nstruct PolygonProps {\nvec3 positions;\nvec3 positions64Low;\nvec3 normal;\nfloat elevations;\n};\nvec3 project_offset_normal(vec3 vector) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {\nreturn normalize(vector * project.commonUnitsPerWorldUnit);\n}\nreturn project_normal(vector);\n}\nvoid calculatePosition(PolygonProps props) {\nvec3 pos = props.positions;\nvec3 pos64Low = props.positions64Low;\nvec3 normal = props.normal;\nvec4 colors = solidPolygon.isWireframe ? lineColors : fillColors;\ngeometry.worldPosition = props.positions;\ngeometry.pickingColor = pickingColors;\nif (solidPolygon.extruded) {\npos.z += props.elevations * solidPolygon.elevationScale;\n}\ngl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (solidPolygon.extruded) {\n#ifdef IS_SIDE_VERTEX\nnormal = project_offset_normal(normal);\n#else\nnormal = project_normal(normal);\n#endif\ngeometry.normal = normal;\nvec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, colors.a * layer.opacity);\n} else {\nvColor = vec4(colors.rgb, colors.a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",bm=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader\nin vec3 vertexPositions;\nin vec3 vertexPositions64Low;\nin float elevations;\n${_m}\nvoid main(void) {\nPolygonProps props;\nprops.positions = vertexPositions;\nprops.positions64Low = vertexPositions64Low;\nprops.elevations = elevations;\nprops.normal = vec3(0.0, 0.0, 1.0);\ncalculatePosition(props);\n}\n`,vm=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader-side\n#define IS_SIDE_VERTEX\nin vec2 positions;\nin vec3 vertexPositions;\nin vec3 nextVertexPositions;\nin vec3 vertexPositions64Low;\nin vec3 nextVertexPositions64Low;\nin float elevations;\nin float instanceVertexValid;\n${_m}\nvoid main(void) {\nif(instanceVertexValid < 0.5){\ngl_Position = vec4(0.);\nreturn;\n}\nPolygonProps props;\nvec3 pos;\nvec3 pos64Low;\nvec3 nextPos;\nvec3 nextPos64Low;\n#if RING_WINDING_ORDER_CW == 1\npos = vertexPositions;\npos64Low = vertexPositions64Low;\nnextPos = nextVertexPositions;\nnextPos64Low = nextVertexPositions64Low;\n#else\npos = nextVertexPositions;\npos64Low = nextVertexPositions64Low;\nnextPos = vertexPositions;\nnextPos64Low = vertexPositions64Low;\n#endif\nprops.positions = mix(pos, nextPos, positions.x);\nprops.positions64Low = mix(pos64Low, nextPos64Low, positions.x);\nprops.normal = vec3(\npos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),\nnextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),\n0.0);\nprops.elevations = elevations * positions.y;\ncalculatePosition(props);\n}\n`,ym=[0,0,0,255],wm={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:e=>e.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:ym},getLineColor:{type:"accessor",value:ym},material:!0},xm={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class Em extends ug{getShaders(e){return super.getShaders({vs:"top"===e?bm:vm,fs:"#version 300 es\n#define SHADER_NAME solid-polygon-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:{RING_WINDING_ORDER_CW:this.props._normalize||"CCW"!==this.props._windingOrder?1:0},modules:[sc,NA,Oc,mm]})}get wrapLongitude(){return!1}getBounds(){var e;return null==(e=this.getAttributeManager())?void 0:e.getBounds(["vertexPositions"])}initializeState(){const{viewport:e}=this.context;let{coordinateSystem:t}=this.props;const{_full3d:n}=this.props;let r;e.isGeospatial&&t===Ul.DEFAULT&&(t=Ul.LNGLAT),t===Ul.LNGLAT&&(r=n?e.projectPosition.bind(e):e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new fm({preproject:r,fp64:this.use64bitPositions(),IndexType:Uint32Array})});const i=this.getAttributeManager(),s=!0;i.remove(["instancePickingColors"]),i.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:s},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:xm,accessor:"getPolygon",update:this.calculatePositions,noAlloc:s,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:s},elevations:{size:1,stepMode:"dynamic",transition:xm,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:xm,accessor:"getFillColor",defaultValue:ym},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:xm,accessor:"getLineColor",defaultValue:ym},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(e,{index:t,target:n})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,n)}})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:n}=t,r=this.props.data;return r[0]&&r[0].__source&&(t.object=r.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<t.length;n++)t[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){const{extruded:t,filled:n,wireframe:r,elevationScale:i}=this.props,{topModel:s,sideModel:o,wireframeModel:a,polygonTesselator:A}=this.state,l={extruded:Boolean(t),elevationScale:i,isWireframe:!1};a&&r&&(a.setInstanceCount(A.instanceCount-1),a.shaderInputs.setProps({solidPolygon:{...l,isWireframe:!0}}),a.draw(this.context.renderPass)),o&&n&&(o.setInstanceCount(A.instanceCount-1),o.shaderInputs.setProps({solidPolygon:l}),o.draw(this.context.renderPass)),s&&n&&(s.setVertexCount(A.vertexCount),s.shaderInputs.setProps({solidPolygon:l}),s.draw(this.context.renderPass))}updateState(e){var t;super.updateState(e),this.updateGeometry(e);const{props:n,oldProps:r,changeFlags:i}=e,s=this.getAttributeManager();(i.extensionsChanged||n.filled!==r.filled||n.extruded!==r.extruded)&&(null==(t=this.state.models)||t.forEach(e=>e.destroy()),this.setState(this._getModels()),s.invalidateAll())}updateGeometry({props:e,oldProps:t,changeFlags:n}){if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPolygon)){const{polygonTesselator:t}=this.state,r=e.data.attributes||{};t.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:r.getPolygon,buffers:r,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:n.dataChanged,full3d:e._full3d}),this.setState({numInstances:t.instanceCount,startIndices:t.vertexStarts}),n.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){const{id:e,filled:t,extruded:n}=this.props;let r,i,s;if(t){const t=this.getShaders("top");t.defines.NON_INSTANCED_MODEL=1;const n=this.getAttributeManager().getBufferLayouts({isInstanced:!1});r=new Xu(this.context.device,{...t,id:`${e}-top`,topology:"triangle-list",bufferLayout:n,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(n){const t=this.getAttributeManager().getBufferLayouts({isInstanced:!0});i=new Xu(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:t,geometry:new Ku({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),s=new Xu(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:t,geometry:new Ku({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[i,s,r].filter(Boolean),topModel:r,sideModel:i,wireframeModel:s}}calculateIndices(e){const{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get("indices")}calculatePositions(e){const{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}}Em.defaultProps=wm,Em.layerName="SolidPolygonLayer";const Tm=[0,0,0,255],Sm={stroked:!0,filled:!0,extruded:!1,elevationScale:1,wireframe:!1,_normalize:!0,_windingOrder:"CW",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,lineJointRounded:!1,lineMiterLimit:4,getPolygon:{type:"accessor",value:e=>e.polygon},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:Tm},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0};class Cm extends hg{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&Hn.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:e}){const t=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon);if(t&&Array.isArray(e.dataChanged)){const t=this.state.paths.slice(),n=e.dataChanged.map(e=>function({data:e,getIndex:t,dataRange:n,replace:r}){const{startRow:i=0,endRow:s=1/0}=n,o=e.length;let a=o,A=o;for(let u=0;u<o;u++){const n=t(e[u]);if(a>u&&n>=i&&(a=u),n>=s){A=u;break}}let l=a;const c=A-a!==r.length?e.slice(A):void 0;for(let u=0;u<r.length;u++)e[l++]=r[u];if(c){for(let t=0;t<c.length;t++)e[l++]=c[t];e.length=l}return{startRow:a,endRow:a+r.length}}({data:t,getIndex:e=>e.__source.index,dataRange:e,replace:this._getPaths(e)}));this.setState({paths:t,pathsDiff:n})}else t&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(e={}){const{data:t,getPolygon:n,positionFormat:r,_normalize:i}=this.props,s=[],o="XY"===r?2:3,{startRow:a,endRow:A}=e,{iterable:l,objectInfo:c}=up(t,a,A);for(const u of l){c.index++;let e=n(u,c);i&&(e=um(e,o));const{holeIndices:t}=e,r=e.positions||e;if(t)for(let n=0;n<=t.length;n++){const e=r.slice(t[n-1]||0,t[n]||r.length);s.push(this.getSubLayerRow({path:e},u,c.index))}else s.push(this.getSubLayerRow({path:r},u,c.index))}return s}renderLayers(){const{data:e,_dataDiff:t,stroked:n,filled:r,extruded:i,wireframe:s,_normalize:o,_windingOrder:a,elevationScale:A,transitions:l,positionFormat:c}=this.props,{lineWidthUnits:u,lineWidthScale:h,lineWidthMinPixels:d,lineWidthMaxPixels:f,lineJointRounded:p,lineMiterLimit:g,lineDashJustified:m}=this.props,{getFillColor:_,getLineColor:b,getLineWidth:v,getLineDashArray:y,getElevation:w,getPolygon:x,updateTriggers:E,material:T}=this.props,{paths:S,pathsDiff:C}=this.state,k=this.getSubLayerClass("fill",Em),R=this.getSubLayerClass("stroke",tm),P=this.shouldRenderSubLayer("fill",S)&&new k({_dataDiff:t,extruded:i,elevationScale:A,filled:r,wireframe:s,_normalize:o,_windingOrder:a,getElevation:w,getFillColor:_,getLineColor:i&&s?b:Tm,material:T,transitions:l},this.getSubLayerProps({id:"fill",updateTriggers:E&&{getPolygon:E.getPolygon,getElevation:E.getElevation,getFillColor:E.getFillColor,lineColors:i&&s,getLineColor:E.getLineColor}}),{data:e,positionFormat:c,getPolygon:x});return[!i&&P,!i&&n&&this.shouldRenderSubLayer("stroke",S)&&new R({_dataDiff:C&&(()=>C),widthUnits:u,widthScale:h,widthMinPixels:d,widthMaxPixels:f,jointRounded:p,miterLimit:g,dashJustified:m,_pathType:"loop",transitions:l&&{getWidth:l.getLineWidth,getColor:l.getLineColor,getPath:l.getPolygon},getColor:this.getSubLayerAccessor(b),getWidth:this.getSubLayerAccessor(v),getDashArray:this.getSubLayerAccessor(y)},this.getSubLayerProps({id:"stroke",updateTriggers:E&&{getWidth:E.getLineWidth,getColor:E.getLineColor,getDashArray:E.getLineDashArray}}),{data:S,positionFormat:c,getPath:e=>e.path}),i&&P]}}Cm.layerName="PolygonLayer",Cm.defaultProps=Sm;var km=function(e){var t,n=void 0!==(e=e||{})?e:{},r={};for(t in n)n.hasOwnProperty(t)&&(r[t]=n[t]);var i,s="";"undefined"!=typeof document&&document.currentScript&&(s=document.currentScript.src),s=0!==s.indexOf("blob:")?s.substr(0,s.lastIndexOf("/")+1):"",i=function(e,t,n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=function(){if(200==r.status||0==r.status&&r.response)t(r.response);else{var i=V(e);i?t(i.buffer):n()}},r.onerror=n,r.send(null)};var o=n.print||function(){}.bind(),a=n.printErr||function(){}.bind();for(t in r)r.hasOwnProperty(t)&&(n[t]=r[t]);r=null,n.arguments&&n.arguments;var A=0,l=!1;function c(e){var t=n["_"+e];return t||ne("Assertion failed: "+("Cannot call unknown function "+e+", make sure it is exported")),t}var u,h,d,f,p,g,m,_="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function b(e,t){return e?function(e,t,n){for(var r=t+n,i=t;e[i]&&!(i>=r);)++i;if(i-t>16&&e.subarray&&_)return _.decode(e.subarray(t,i));for(var s="";t<i;){var o=e[t++];if(128&o){var a=63&e[t++];if(192!=(224&o)){var A=63&e[t++];if((o=224==(240&o)?(15&o)<<12|a<<6|A:(7&o)<<18|a<<12|A<<6|63&e[t++])<65536)s+=String.fromCharCode(o);else{var l=o-65536;s+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else s+=String.fromCharCode((31&o)<<6|a)}else s+=String.fromCharCode(o)}return s}(d,e,t):""}function v(e,t){return e%t>0&&(e+=t-e%t),e}function y(e){u=e,n.HEAP8=h=new Int8Array(e),n.HEAP16=f=new Int16Array(e),n.HEAP32=p=new Int32Array(e),n.HEAPU8=d=new Uint8Array(e),n.HEAPU16=new Uint16Array(e),n.HEAPU32=new Uint32Array(e),n.HEAPF32=g=new Float32Array(e),n.HEAPF64=m=new Float64Array(e)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var w=n.TOTAL_MEMORY||33554432;function x(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var r=t.func;"number"==typeof r?void 0===t.arg?n.dynCall_v(r):n.dynCall_vi(r,t.arg):r(void 0===t.arg?null:t.arg)}else t()}}w=(u=n.buffer?n.buffer:new ArrayBuffer(w)).byteLength,y(u),p[7156]=5271536;var E=[],T=[],S=[],C=[];function k(e){E.unshift(e)}function R(e){C.unshift(e)}var P=Math.abs,I=Math.ceil,M=Math.floor,L=Math.min,N=0,B=null;n.preloadedImages={},n.preloadedAudios={};var D,O,F=null,U="data:application/octet-stream;base64,";function j(e){return String.prototype.startsWith?e.startsWith(U):0===e.indexOf(U)}function G(){return h.length}F="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var z="function"==typeof atob?atob:function(e){var t,n,r,i,s,o,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",A="",l=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{t=a.indexOf(e.charAt(l++))<<2|(i=a.indexOf(e.charAt(l++)))>>4,n=(15&i)<<4|(s=a.indexOf(e.charAt(l++)))>>2,r=(3&s)<<6|(o=a.indexOf(e.charAt(l++))),A+=String.fromCharCode(t),64!==s&&(A+=String.fromCharCode(n)),64!==o&&(A+=String.fromCharCode(r))}while(l<e.length);return A};function V(e){if(j(e))return function(e){try{for(var t=z(e),n=new Uint8Array(t.length),r=0;r<t.length;++r)n[r]=t.charCodeAt(r);return n}catch(i){throw new Error("Converting base64 string to bytes failed.")}}(e.slice(U.length))}var W=function(e,t,n){var r=new e.Int8Array(n),i=new e.Int32Array(n);new e.Uint8Array(n),new e.Float32Array(n);var s=new e.Float64Array(n),o=0|t.o,a=0|t.p,A=e.Math.floor,l=e.Math.abs,c=e.Math.sqrt,u=e.Math.pow,h=e.Math.cos,d=e.Math.sin,f=e.Math.tan,p=e.Math.acos,g=e.Math.asin,m=e.Math.atan,_=e.Math.atan2,b=e.Math.ceil,v=e.Math.imul,y=e.Math.min,w=e.Math.max,x=e.Math.clz32,E=t.b,T=t.c,S=t.d,C=t.e,k=t.f,R=t.g,P=t.h,I=t.i,M=28656;function L(e,t,n,r){return 0|N(e|=0,t|=0,n|=0,r|=0,0)}function N(e,t,n,r,s){var o,a=0,A=0,l=0,c=0;if(o=M,M=M+16|0,A=o,!(0|B(e|=0,t|=0,n|=0,r|=0,s|=0)))return M=o,0;do{if((0|n)>=0){if((0|n)>13780509){if(0|(a=0|lt(15,A)))break;A=0|i[(l=A)>>2],l=0|i[l+4>>2]}else c=0|Zt(0|n,0|(a=((0|n)<0)<<31>>31),3,0),l=0|T(),a=0|Xt(0|n,0|a,1,0),a=0|Xt(0|(a=0|Zt(0|c,0|l,0|a,0|T())),0|T(),1,0),l=0|T(),i[A>>2]=a,i[A+4>>2]=l,A=a;if(cn(0|r,0,A<<3),0|s){cn(0|s,0,A<<2),a=0|D(e,t,n,r,s,A,l,0);break}(a=0|$t(A,4))?(c=0|D(e,t,n,r,a,A,l,0),Ht(a),a=c):a=13}else a=2}while(0);return M=o,0|a}function B(e,t,n,r,s){e|=0,t|=0,n|=0,r|=0,s|=0;var o,a,A=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0;if(a=M,M=M+16|0,g=a+8|0,i[(p=o=a)>>2]=e,i[p+4>>2]=t,(0|n)<0)return M=a,2;if(i[(A=r)>>2]=e,i[A+4>>2]=t,(A=!!(0|s))&&(i[s>>2]=0),0|je(e,t))return M=a,9;i[g>>2]=0;e:do{if((0|n)>=1)if(A)for(d=1,h=0,f=0,p=1,A=e;;){if(!(h|f)){if(0|(A=0|O(A,t,4,g,o)))break e;if(0|je(A=0|i[(t=o)>>2],t=0|i[t+4>>2])){A=9;break e}}if(0|(A=0|O(A,t,0|i[26800+(f<<2)>>2],g,o)))break e;if(A=0|i[(t=o)>>2],t=0|i[t+4>>2],i[(e=r+(d<<3)|0)>>2]=A,i[e+4>>2]=t,i[s+(d<<2)>>2]=p,l=(0|(e=h+1|0))==(0|p),u=6==(0|(c=f+1|0)),0|je(A,t)){A=9;break e}if((0|(p=p+(u&l&1)|0))>(0|n)){A=0;break}d=d+1|0,h=l?0:e,f=l?u?0:c:f}else for(d=1,h=0,f=0,p=1,A=e;;){if(!(h|f)){if(0|(A=0|O(A,t,4,g,o)))break e;if(0|je(A=0|i[(t=o)>>2],t=0|i[t+4>>2])){A=9;break e}}if(0|(A=0|O(A,t,0|i[26800+(f<<2)>>2],g,o)))break e;if(A=0|i[(t=o)>>2],t=0|i[t+4>>2],i[(e=r+(d<<3)|0)>>2]=A,i[e+4>>2]=t,l=(0|(e=h+1|0))==(0|p),u=6==(0|(c=f+1|0)),0|je(A,t)){A=9;break e}if((0|(p=p+(u&l&1)|0))>(0|n)){A=0;break}d=d+1|0,h=l?0:e,f=l?u?0:c:f}else A=0}while(0);return M=a,0|A}function D(e,t,n,r,s,o,a,A){n|=0,r|=0,s|=0,A|=0;var l,c,u,h=0,d=0,f=0,p=0,g=0,m=0,_=0;if(u=M,M=M+16|0,l=u+8|0,c=u,h=0|en(0|(e|=0),0|(t|=0),0|(o|=0),0|(a|=0)),f=0|T(),!(!(0|(_=0|i[(m=p=r+(h<<3)|0)>>2]))&!(0|(m=0|i[m+4>>2]))|(d=(0|_)==(0|e)&(0|m)==(0|t))))do{h=0|Jt(0|(h=0|Xt(0|h,0|f,1,0)),0|T(),0|o,0|a),f=0|T(),d=(0|(m=0|i[(_=p=r+(h<<3)|0)>>2]))==(0|e)&(0|(_=0|i[_+4>>2]))==(0|t)}while(!(!(0|m)&!(0|_)|d));if(h=s+(h<<2)|0,d&&(0|i[h>>2])<=(0|A))return M=u,0;if(i[(_=p)>>2]=e,i[_+4>>2]=t,i[h>>2]=A,(0|A)>=(0|n))return M=u,0;switch(d=A+1|0,i[l>>2]=0,0|(h=0|O(e,t,2,l,c))){case 9:g=9;break;case 0:(h=0|D(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,o,a,d))||(g=9)}e:do{if(9==(0|g)){switch(i[l>>2]=0,0|(h=0|O(e,t,3,l,c))){case 9:break;case 0:if(0|(h=0|D(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,o,a,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(h=0|O(e,t,1,l,c))){case 9:break;case 0:if(0|(h=0|D(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,o,a,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(h=0|O(e,t,5,l,c))){case 9:break;case 0:if(0|(h=0|D(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,o,a,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(h=0|O(e,t,4,l,c))){case 9:break;case 0:if(0|(h=0|D(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,o,a,d)))break e;break;default:break e}switch(i[l>>2]=0,0|(h=0|O(e,t,6,l,c))){case 9:break;case 0:if(0|(h=0|D(0|i[(h=c)>>2],0|i[h+4>>2],n,r,s,o,a,d)))break e;break;default:break e}return M=u,0}}while(0);return M=u,0|h}function O(e,t,n,r,s){e|=0,t|=0,s|=0;var o,a,A=0,l=0,c=0,u=0,h=0,d=0,f=0;if((n|=0)>>>0>6)return 1;if(h=(0|i[(r|=0)>>2])%6|0,i[r>>2]=h,(0|h)>0){A=0;do{n=0|be(n),A=A+1|0}while((0|A)<(0|i[r>>2]))}if(h=0|nn(0|e,0|t,45),T(),(a=127&h)>>>0>121)return 5;o=0|Ve(e,t),A=0|nn(0|e,0|t,52),T(),A&=15;e:do{if(A){for(;;){if(c=0|nn(0|e,0|t,0|(l=3*(15-A|0)|0)),T(),7==(0|(c&=7))){t=5;break}if(f=!(0|Qe(A)),A=A+-1|0,d=0|rn(7,0,0|l),t&=~T(),e=0|rn(0|i[(f?432:16)+(28*c|0)+(n<<2)>>2],0,0|l)|e&~d,t|=l=0|T(),!(n=0|i[(f?640:224)+(28*c|0)+(n<<2)>>2])){n=0;break e}if(!A){u=8;break e}}return 0|t}u=8}while(0);8==(0|u)&&(e|=0|rn(0|(f=0|i[848+(28*a|0)+(n<<2)>>2]),0,45),t=T()|-1040385&t,n=0|i[4272+(28*a|0)+(n<<2)>>2],127&~f||(f=0|rn(0|i[848+(28*a|0)+20>>2],0,45),t=T()|-1040385&t,n=0|i[4272+(28*a|0)+20>>2],e=0|He(f|e,t),t=0|T(),i[r>>2]=1+(0|i[r>>2]))),c=0|nn(0|e,0|t,45),T(),c&=127;e:do{if(0|G(c)){t:do{if(1==(0|Ve(e,t))){if((0|a)!=(0|c)){if(0|H(c,0|i[7696+(28*a|0)>>2])){e=0|Xe(e,t),l=1,t=0|T();break}S(27795,26864,533,26872)}switch(0|o){case 3:e=0|He(e,t),t=0|T(),i[r>>2]=1+(0|i[r>>2]),l=0;break t;case 5:e=0|Xe(e,t),t=0|T(),i[r>>2]=5+(0|i[r>>2]),l=0;break t;case 0:return 9;default:return 1}}else l=0}while(0);if((0|n)>0){A=0;do{e=0|We(e,t),t=0|T(),A=A+1|0}while((0|A)!=(0|n))}if((0|a)!=(0|c)){if(!(0|z(c))){if(!!(0|l)|5!=(0|Ve(e,t)))break;i[r>>2]=1+(0|i[r>>2]);break}switch(127&h){case 8:case 118:break e}3!=(0|Ve(e,t))&&(i[r>>2]=1+(0|i[r>>2]))}}else if((0|n)>0){A=0;do{e=0|He(e,t),t=0|T(),A=A+1|0}while((0|A)!=(0|n))}}while(0);return i[r>>2]=((0|i[r>>2])+n|0)%6|0,i[(f=s)>>2]=e,i[f+4>>2]=t,0}function F(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var s,o,a=0,A=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0;if(o=M,M=M+16|0,p=o+8|0,i[(f=s=o)>>2]=e,i[f+4>>2]=t,(0|n)<0)return M=o,2;if(!n)return i[(p=r)>>2]=e,i[p+4>>2]=t,M=o,0;i[p>>2]=0;e:do{if(0|je(e,t))e=9;else{a=0,f=e;do{if(0|(e=0|O(f,t,4,p,s)))break e;if(a=a+1|0,0|je(f=0|i[(t=s)>>2],t=0|i[t+4>>2])){e=9;break e}}while((0|a)<(0|n));i[(d=r)>>2]=f,i[d+4>>2]=t,d=n+-1|0,h=0,e=1;do{if(a=26800+(h<<2)|0,5==(0|h))for(l=0|i[a>>2],A=0,a=e;;){if(0|(e=0|O(0|i[(e=s)>>2],0|i[e+4>>2],l,p,s)))break e;if((0|A)!=(0|d)){if(c=0|i[(u=s)>>2],u=0|i[u+4>>2],i[(e=r+(a<<3)|0)>>2]=c,i[e+4>>2]=u,0|je(c,u)){e=9;break e}e=a+1|0}else e=a;if((0|(A=A+1|0))>=(0|n))break;a=e}else for(l=s,u=0|i[a>>2],c=0,a=e,A=0|i[l>>2],l=0|i[l+4>>2];;){if(0|(e=0|O(A,l,u,p,s)))break e;if(A=0|i[(l=s)>>2],l=0|i[l+4>>2],i[(e=r+(a<<3)|0)>>2]=A,i[e+4>>2]=l,e=a+1|0,0|je(A,l)){e=9;break e}if((0|(c=c+1|0))>=(0|n))break;a=e}h=h+1|0}while(h>>>0<6);e=(0|f)==(0|i[(e=s)>>2])&&(0|t)==(0|i[e+4>>2])?0:9}}while(0);return M=o,0|e}function U(e,t,n,r){n|=0,r|=0;var s,o,a,A=0,l=0;for(a=M,M=M+16|0,s=a,o=a+8|0,A=(A=!(0|je(e|=0,t|=0)))?1:2;;){if(i[o>>2]=0,!(0|O(e,t,A,o,s))&((0|i[(l=s)>>2])==(0|n)?(0|i[l+4>>2])==(0|r):0)){e=4;break}if((A=A+1|0)>>>0>=7){A=7,e=4;break}}return 4==(0|e)?(M=a,0|A):0}function j(e,t,n,r,o,a,A){t|=0,n|=0,r|=0,o|=0,a|=0,A|=0;var l,c,u,h,d,f,p,g,m,_,b=0,v=0,y=0,w=0,x=0,E=0,S=0,C=0,k=0,R=0,P=0,I=0,L=0,N=0,B=0,D=0,O=0,F=0,U=0;if(_=M,M=M+64|0,p=_+48|0,g=_+32|0,m=_+24|0,l=_+8|0,c=_,(0|(v=0|i[(e|=0)>>2]))<=0)return M=_,0;for(u=e+4|0,h=p+8|0,d=g+8|0,f=l+8|0,b=0,L=0;;){I=(y=0|i[u>>2])+(L<<4)|0,i[p>>2]=i[I>>2],i[p+4>>2]=i[I+4>>2],i[p+8>>2]=i[I+8>>2],i[p+12>>2]=i[I+12>>2],(0|L)==(v+-1|0)?(i[g>>2]=i[y>>2],i[g+4>>2]=i[y+4>>2],i[g+8>>2]=i[y+8>>2],i[g+12>>2]=i[y+12>>2]):(I=y+(L+1<<4)|0,i[g>>2]=i[I>>2],i[g+4>>2]=i[I+4>>2],i[g+8>>2]=i[I+8>>2],i[g+12>>2]=i[I+12>>2]),v=0|ne(p,g,r,m);e:do{if(v)y=0,b=v;else if(y=0|i[(v=m)>>2],(0|(v=0|i[v+4>>2]))>0|!(0|v)&y>>>0>0){P=0,I=0;t:for(;;){if(O=1/(+(y>>>0)+4294967296*+(0|v)),U=+s[p>>3],F=+((v=0|Qt(0|y,0|v,0|P,0|I))>>>0)+4294967296*+(0|T()),D=+(P>>>0)+4294967296*+(0|I),s[l>>3]=O*(U*F)+O*(+s[g>>3]*D),s[f>>3]=O*(+s[h>>3]*F)+O*(+s[d>>3]*D),0|(v=0|Ye(l,r,c))){b=v;break}E=0|en(0|(k=0|i[(R=c)>>2]),0|(R=0|i[R+4>>2]),0|t,0|n),w=0|T(),y=0|i[(x=v=A+(E<<3)|0)>>2],x=0|i[x+4>>2];n:do{if(!(0|y)&!(0|x))N=v,B=16;else for(S=0,C=0;;){if((0|S)>(0|n)|(0|S)==(0|n)&C>>>0>t>>>0){b=1;break t}if((0|y)==(0|k)&(0|x)==(0|R))break n;if(E=0|Jt(0|(v=0|Xt(0|E,0|w,1,0)),0|T(),0|t,0|n),w=0|T(),C=0|Xt(0|C,0|S,1,0),S=0|T(),!(0|(y=0|i[(x=v=A+(E<<3)|0)>>2]))&!(0|(x=0|i[x+4>>2]))){N=v,B=16;break}}}while(0);if(16!=(0|B)||(B=0,!(0|k)&!(0|R))||(i[(C=N)>>2]=k,i[C+4>>2]=R,C=a+(i[o>>2]<<3)|0,i[C>>2]=k,i[C+4>>2]=R,C=0|Xt(0|i[(C=o)>>2],0|i[C+4>>2],1,0),k=0|T(),i[(R=o)>>2]=C,i[R+4>>2]=k),P=0|Xt(0|P,0|I,1,0),I=0|T(),y=0|i[(v=m)>>2],!((0|(v=0|i[v+4>>2]))>(0|I)|(0|v)==(0|I)&y>>>0>P>>>0)){y=1;break e}}y=0}else y=1}while(0);if(L=L+1|0,!y){B=21;break}if((0|L)>=(0|(v=0|i[e>>2]))){b=0,B=21;break}}return 21==(0|B)?(M=_,0|b):0}function G(e){return(e|=0)>>>0>121?0|(e=0):0|(e=0|i[7696+(28*e|0)+16>>2])}function z(e){return 4==(0|(e|=0))|117==(0|e)|0}function V(e){return 0|i[11120+(216*(0|i[(e|=0)>>2])|0)+(72*(0|i[e+4>>2])|0)+(24*(0|i[e+8>>2])|0)+(i[e+12>>2]<<3)>>2]}function W(e){return 0|i[11120+(216*(0|i[(e|=0)>>2])|0)+(72*(0|i[e+4>>2])|0)+(24*(0|i[e+8>>2])|0)+(i[e+12>>2]<<3)+4>>2]}function H(e,t){return t|=0,(0|i[7696+(28*(e|=0)|0)+20>>2])==(0|t)?0|(t=1):0|(t=(0|i[7696+(28*e|0)+24>>2])==(0|t))}function $(e,t){return 0|i[848+(28*(e|=0)|0)+((t|=0)<<2)>>2]}function X(e,t){return t|=0,(0|i[848+(28*(e|=0)|0)>>2])==(0|t)?0|(t=0):(0|i[848+(28*e|0)+4>>2])==(0|t)?0|(t=1):(0|i[848+(28*e|0)+8>>2])==(0|t)?0|(t=2):(0|i[848+(28*e|0)+12>>2])==(0|t)?0|(t=3):(0|i[848+(28*e|0)+16>>2])==(0|t)?0|(t=4):(0|i[848+(28*e|0)+20>>2])==(0|t)?0|(t=5):0|((0|i[848+(28*e|0)+24>>2])==(0|t)?6:7)}function Q(e){var t,n,r;return t=(r=+s[16+(e|=0)>>3])-(n=+s[e+24>>3]),+(r<n?t+6.283185307179586:t)}function Y(e){return+s[16+(e|=0)>>3]<+s[e+24>>3]|0}function q(e){return+(+s[(e|=0)>>3]-+s[e+8>>3])}function K(e,t){e|=0;var n,r,i=0;return(i=+s[(t|=0)>>3])>=+s[e+8>>3]&&i<=+s[e>>3]?(n=+s[e+16>>3],i=+s[e+24>>3],t=(r=+s[t+8>>3])>=i,e=r<=n&1,n<i?t&&(e=1):t||(e=0),0|(t=!!(0|e))):0|(t=0)}function Z(e,t){t|=0;var n,r,i,o,a,A=0,l=0,c=0,u=0;return+s[(e|=0)>>3]<+s[t+8>>3]||+s[e+8>>3]>+s[t>>3]?0|(A=0):(i=(l=+s[e+16>>3])<(u=+s[(n=e+24|0)>>3]),c=(a=+s[(A=t+16|0)>>3])<(o=+s[(r=t+24|0)>>3]),t=u-a<o-l,e=i?c|t?1:2:0,t=c?i?1:t?2:1:0,(l=+ot(l,e))<+ot(+s[r>>3],t)||(u=+ot(+s[n>>3],e))>+ot(+s[A>>3],t)?0|(c=0):0|(c=1))}function J(e,t){t|=0;var n,r,i,o,a,A=0,l=0,c=0,u=0;return+s[(e|=0)>>3]<+s[t>>3]||+s[e+8>>3]>+s[t+8>>3]?0|(A=0):(i=(o=+s[(A=e+16|0)>>3])<(l=+s[e+24>>3]),c=(u=+s[(n=t+16|0)>>3])<(a=+s[(r=t+24|0)>>3]),t=l-u<a-o,e=i?c|t?1:2:0,t=c?i?1:t?2:1:0,(l=+ot(l,e))<=+ot(+s[r>>3],t)?0|(c=(u=+ot(+s[A>>3],e))>=+ot(+s[n>>3],t)):0|(c=0))}function ee(e,t){e|=0,t|=0;var n,r,o,a,A,l=0;o=M,M=M+176|0,i[(r=o)>>2]=4,l=+s[t>>3],s[r+8>>3]=l,a=+s[t+16>>3],s[r+16>>3]=a,s[r+24>>3]=l,l=+s[t+24>>3],s[r+32>>3]=l,A=+s[t+8>>3],s[r+40>>3]=A,s[r+48>>3]=l,s[r+56>>3]=A,s[r+64>>3]=a,n=96+(t=r+72|0)|0;do{i[t>>2]=0,t=t+4|0}while((0|t)<(0|n));ln(0|e,0|r,168),M=o}function te(e,t,n){e|=0,t|=0,n|=0;var r,a,c,u,h,d,f,p=0,g=0,m=0,_=0,v=0,w=0,x=0;d=M,M=M+288|0,h=d+264|0,_=d+96|0,g=(p=m=d)+96|0;do{i[p>>2]=0,p=p+4|0}while((0|p)<(0|g));return 0|(t=0|et(t,m))?(M=d,0|(w=t)):(Ze(m=0|i[(g=m)>>2],g=0|i[g+4>>2],h),Je(m,g,_),u=+at(h,_+8|0),s[h>>3]=+s[e>>3],s[(g=h+8|0)>>3]=+s[e+16>>3],s[_>>3]=+s[e+8>>3],s[(m=_+8|0)>>3]=+s[e+24>>3],a=+at(h,_),x=+s[g>>3]-+s[m>>3],c=+l(+x),f=+s[h>>3]-+s[_>>3],r=+l(+f),!(0==x|0==f)&&(x=+on(+c,+r),x=+b(+a*a/+an(+x/+an(+c,+r),3)/(u*(2.59807621135*u)*.8)),s[o>>3]=x,v=~~x>>>0,w=+l(x)>=1?x>0?~~+y(+A(x/4294967296),4294967295)>>>0:~~+b((x-+(~~x>>>0))/4294967296)>>>0:0,2146435072&~i[o+4>>2])?(_=!(0|v)&!(0|w),i[(t=n)>>2]=_?1:v,i[t+4>>2]=_?0:w,t=0):t=1,M=d,0|(w=t))}function ne(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a,c,u,h,d=0,f=0,p=0;h=M,M=M+288|0,c=h+264|0,u=h+96|0,a=(d=f=h)+96|0;do{i[d>>2]=0,d=d+4|0}while((0|d)<(0|a));return 0|(n=0|et(n,f))?(M=h,0|(r=n)):(Ze(d=0|i[(n=f)>>2],n=0|i[n+4>>2],c),Je(d,n,u),p=+at(c,u+8|0),p=+b(+ +at(e,t)/(2*p)),s[o>>3]=p,n=~~p>>>0,d=+l(p)>=1?p>0?~~+y(+A(p/4294967296),4294967295)>>>0:~~+b((p-+(~~p>>>0))/4294967296)>>>0:0,2146435072&~i[o+4>>2]?(f=!(0|n)&!(0|d),i[r>>2]=f?1:n,i[r+4>>2]=f?0:d,M=h,0|(r=0)):(M=h,0|(r=1)))}function re(e,t,n,r){t|=0,n|=0,r|=0,i[(e|=0)>>2]=t,i[e+4>>2]=n,i[e+8>>2]=r}function ie(e){var t,n=0,r=0,s=0,o=0,a=0;n=0|i[(e|=0)>>2],r=0|i[(t=e+4|0)>>2],(0|n)<0&&(r=r-n|0,i[t>>2]=r,i[(a=e+8|0)>>2]=(0|i[a>>2])-n,i[e>>2]=0,n=0),(0|r)<0?(n=n-r|0,i[e>>2]=n,o=(0|i[(a=e+8|0)>>2])-r|0,i[a>>2]=o,i[t>>2]=0,r=0):(a=o=e+8|0,o=0|i[o>>2]),(0|o)<0&&(n=n-o|0,i[e>>2]=n,r=r-o|0,i[t>>2]=r,i[a>>2]=0,o=0),(0|(s=(0|o)<(0|(s=(0|r)<(0|n)?r:n))?o:s))<=0||(i[e>>2]=n-s,i[t>>2]=r-s,i[a>>2]=o-s)}function se(e,t){var n,r;t|=0,r=0|i[8+(e|=0)>>2],n=+((0|i[e+4>>2])-r|0),s[t>>3]=+((0|i[e>>2])-r|0)-.5*n,s[t+8>>3]=.8660254037844386*n}function oe(e,t,n){e|=0,t|=0,i[(n|=0)>>2]=(0|i[t>>2])+(0|i[e>>2]),i[n+4>>2]=(0|i[t+4>>2])+(0|i[e+4>>2]),i[n+8>>2]=(0|i[t+8>>2])+(0|i[e+8>>2])}function ae(e,t,n){e|=0,t|=0,i[(n|=0)>>2]=(0|i[e>>2])-(0|i[t>>2]),i[n+4>>2]=(0|i[e+4>>2])-(0|i[t+4>>2]),i[n+8>>2]=(0|i[e+8>>2])-(0|i[t+8>>2])}function Ae(e,t){t|=0;var n,r=0;r=0|v(0|i[(e|=0)>>2],t),i[e>>2]=r,n=0|v(0|i[(r=e+4|0)>>2],t),i[r>>2]=n,t=0|v(0|i[(e=e+8|0)>>2],t),i[e>>2]=t}function le(e){var t,n,r=0,s=0,o=0,a=0,A=0;A=(0|(n=0|i[(e|=0)>>2]))<0,e=(e=(s=(0|(a=((t=(0|(o=(0|i[e+4>>2])-(A?n:0)|0))<0)?0-o|0:0)+((0|i[e+8>>2])-(A?n:0))|0))<0)?0:a)-((o=(0|(s=(0|e)<(0|(s=(0|(r=(t?0:o)-(s?a:0)|0))<(0|(a=(A?0:n)-(t?o:0)-(s?a:0)|0))?r:a))?e:s))>0)?s:0)|0,r=r-(o?s:0)|0;e:do{switch(a-(o?s:0)|0){case 0:switch(0|r){case 0:return 0|(0|e?1==(0|e)?1:7:0);case 1:return 0|(0|e?1==(0|e)?3:7:2);default:break e}case 1:switch(0|r){case 0:return 0|(0|e?1==(0|e)?5:7:4);case 1:if(e)break e;return 6;default:break e}}}while(0);return 7}function ce(e){var t,n,r=0,s=0,o=0,a=0,A=0,l=0,c=0;if(l=0|i[(n=8+(e|=0)|0)>>2],(t=(0|i[e>>2])-l|0)>>>0>715827881|(l=(0|i[(c=e+4|0)>>2])-l|0)>>>0>715827881){if(a=2147483647-t|0,A=-2147483648-t|0,(o=(0|t)>0)?(0|a)<(0|t):(0|A)>(0|t))return 1;if(s=t<<1,o?(2147483647-s|0)<(0|t):(-2147483648-s|0)>(0|t))return 1;if((0|l)>0?(2147483647-l|0)<(0|l):(-2147483648-l|0)>(0|l))return 1;if(r=3*t|0,s=l<<1,(o?(0|a)<(0|s):(0|A)>(0|s))||((0|t)>-1?(-2147483648|r)>=(0|l):(-2147483648^r)<(0|l)))return 1}else s=l<<1,r=3*t|0;return o=0|Vt(.14285714285714285*+(r-l|0)),i[e>>2]=o,a=0|Vt(.14285714285714285*+(s+t|0)),i[c>>2]=a,i[n>>2]=0,r=(s=(0|a)<(0|o))?o:a,(0|(s=s?a:o))<0&&((-2147483648==(0|s)||((0|r)>0?(2147483647-r|0)<(0|s):(-2147483648-r|0)>(0|s)))&&S(27795,26892,354,26903),((0|r)>-1?(-2147483648|r)>=(0|s):(-2147483648^r)<(0|s))&&S(27795,26892,354,26903)),r=a-o|0,(0|o)<0?(s=0-o|0,i[c>>2]=r,i[n>>2]=s,i[e>>2]=0,o=0):(r=a,s=0),(0|r)<0&&(o=o-r|0,i[e>>2]=o,s=s-r|0,i[n>>2]=s,i[c>>2]=0,r=0),A=o-s|0,a=r-s|0,(0|s)<0?(i[e>>2]=A,i[c>>2]=a,i[n>>2]=0,r=a,a=A,s=0):a=o,(0|(o=(0|s)<(0|(o=(0|r)<(0|a)?r:a))?s:o))<=0||(i[e>>2]=a-o,i[c>>2]=r-o,i[n>>2]=s-o),0}function ue(e){var t,n=0,r=0,s=0,o=0,a=0,A=0,l=0;if(o=0|i[(t=8+(e|=0)|0)>>2],(a=(0|i[e>>2])-o|0)>>>0>715827881|(o=(0|i[(A=e+4|0)>>2])-o|0)>>>0>715827881){if((r=(0|a)>0)?(2147483647-a|0)<(0|a):(-2147483648-a|0)>(0|a))return 1;if(n=a<<1,(s=(0|o)>0)?(2147483647-o|0)<(0|o):(-2147483648-o|0)>(0|o))return 1;if(l=o<<1,s?(2147483647-l|0)<(0|o):(-2147483648-l|0)>(0|o))return 1;if(r?(2147483647-n|0)<(0|o):(-2147483648-n|0)>(0|o))return 1;if(r=3*o|0,(0|o)>-1?(-2147483648|r)>=(0|a):(-2147483648^r)<(0|a))return 1}else r=3*o|0,n=a<<1;return s=0|Vt(.14285714285714285*+(n+o|0)),i[e>>2]=s,o=0|Vt(.14285714285714285*+(r-a|0)),i[A>>2]=o,i[t>>2]=0,n=(r=(0|o)<(0|s))?s:o,(0|(r=r?o:s))<0&&((-2147483648==(0|r)||((0|n)>0?(2147483647-n|0)<(0|r):(-2147483648-n|0)>(0|r)))&&S(27795,26892,402,26917),((0|n)>-1?(-2147483648|n)>=(0|r):(-2147483648^n)<(0|r))&&S(27795,26892,402,26917)),n=o-s|0,(0|s)<0?(r=0-s|0,i[A>>2]=n,i[t>>2]=r,i[e>>2]=0,s=0):(n=o,r=0),(0|n)<0&&(s=s-n|0,i[e>>2]=s,r=r-n|0,i[t>>2]=r,i[A>>2]=0,n=0),a=s-r|0,o=n-r|0,(0|r)<0?(i[e>>2]=a,i[A>>2]=o,i[t>>2]=0,n=o,o=a,r=0):o=s,(0|(s=(0|r)<(0|(s=(0|n)<(0|o)?n:o))?r:s))<=0||(i[e>>2]=o-s,i[A>>2]=n-s,i[t>>2]=r-s),0}function he(e){var t,n,r=0,s=0,o=0,a=0,A=0;s=0|i[(t=8+(e|=0)|0)>>2],o=0|Vt(.14285714285714285*+((3*(r=(0|i[e>>2])-s|0)|0)-(s=(0|i[(n=e+4|0)>>2])-s|0)|0)),i[e>>2]=o,r=0|Vt(.14285714285714285*+((s<<1)+r|0)),i[n>>2]=r,i[t>>2]=0,s=r-o|0,(0|o)<0?(A=0-o|0,i[n>>2]=s,i[t>>2]=A,i[e>>2]=0,r=s,o=0,s=A):s=0,(0|r)<0&&(o=o-r|0,i[e>>2]=o,s=s-r|0,i[t>>2]=s,i[n>>2]=0,r=0),A=o-s|0,a=r-s|0,(0|s)<0?(i[e>>2]=A,i[n>>2]=a,i[t>>2]=0,r=a,a=A,s=0):a=o,(0|(o=(0|s)<(0|(o=(0|r)<(0|a)?r:a))?s:o))<=0||(i[e>>2]=a-o,i[n>>2]=r-o,i[t>>2]=s-o)}function de(e){var t,n,r=0,s=0,o=0,a=0,A=0;s=0|i[(t=8+(e|=0)|0)>>2],o=0|Vt(.14285714285714285*+(((r=(0|i[e>>2])-s|0)<<1)+(s=(0|i[(n=e+4|0)>>2])-s|0)|0)),i[e>>2]=o,r=0|Vt(.14285714285714285*+((3*s|0)-r|0)),i[n>>2]=r,i[t>>2]=0,s=r-o|0,(0|o)<0?(A=0-o|0,i[n>>2]=s,i[t>>2]=A,i[e>>2]=0,r=s,o=0,s=A):s=0,(0|r)<0&&(o=o-r|0,i[e>>2]=o,s=s-r|0,i[t>>2]=s,i[n>>2]=0,r=0),A=o-s|0,a=r-s|0,(0|s)<0?(i[e>>2]=A,i[n>>2]=a,i[t>>2]=0,r=a,a=A,s=0):a=o,(0|(o=(0|s)<(0|(o=(0|r)<(0|a)?r:a))?s:o))<=0||(i[e>>2]=a-o,i[n>>2]=r-o,i[t>>2]=s-o)}function fe(e){var t,n,r,s=0,o=0,a=0,A=0;s=0|i[(e|=0)>>2],o=0|i[(n=e+4|0)>>2],a=0|i[(r=e+8|0)>>2],A=o+(3*s|0)|0,i[e>>2]=A,o=a+(3*o|0)|0,i[n>>2]=o,s=(3*a|0)+s|0,i[r>>2]=s,a=o-A|0,(0|A)<0?(s=s-A|0,i[n>>2]=a,i[r>>2]=s,i[e>>2]=0,o=a,a=0):a=A,(0|o)<0&&(a=a-o|0,i[e>>2]=a,s=s-o|0,i[r>>2]=s,i[n>>2]=0,o=0),t=a-s|0,A=o-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=A,i[r>>2]=0,a=t,s=0):A=o,(0|(o=(0|s)<(0|(o=(0|A)<(0|a)?A:a))?s:o))<=0||(i[e>>2]=a-o,i[n>>2]=A-o,i[r>>2]=s-o)}function pe(e){var t,n,r,s=0,o=0,a=0,A=0;A=0|i[(e|=0)>>2],a=(3*(s=0|i[(n=e+4|0)>>2])|0)+A|0,A=(o=0|i[(r=e+8|0)>>2])+(3*A|0)|0,i[e>>2]=A,i[n>>2]=a,s=(3*o|0)+s|0,i[r>>2]=s,o=a-A|0,(0|A)<0?(s=s-A|0,i[n>>2]=o,i[r>>2]=s,i[e>>2]=0,A=0):o=a,(0|o)<0&&(A=A-o|0,i[e>>2]=A,s=s-o|0,i[r>>2]=s,i[n>>2]=0,o=0),t=A-s|0,a=o-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=a,i[r>>2]=0,A=t,s=0):a=o,(0|(o=(0|s)<(0|(o=(0|a)<(0|A)?a:A))?s:o))<=0||(i[e>>2]=A-o,i[n>>2]=a-o,i[r>>2]=s-o)}function ge(e,t){e|=0;var n,r,s,o=0,a=0,A=0;((t|=0)-1|0)>>>0>=6||(A=(0|i[15440+(12*t|0)>>2])+(0|i[e>>2])|0,i[e>>2]=A,s=e+4|0,a=(0|i[15440+(12*t|0)+4>>2])+(0|i[s>>2])|0,i[s>>2]=a,r=e+8|0,t=(0|i[15440+(12*t|0)+8>>2])+(0|i[r>>2])|0,i[r>>2]=t,o=a-A|0,(0|A)<0?(t=t-A|0,i[s>>2]=o,i[r>>2]=t,i[e>>2]=0,a=0):(o=a,a=A),(0|o)<0&&(a=a-o|0,i[e>>2]=a,t=t-o|0,i[r>>2]=t,i[s>>2]=0,o=0),n=a-t|0,A=o-t|0,(0|t)<0?(i[e>>2]=n,i[s>>2]=A,i[r>>2]=0,a=n,t=0):A=o,(0|(o=(0|t)<(0|(o=(0|A)<(0|a)?A:a))?t:o))<=0||(i[e>>2]=a-o,i[s>>2]=A-o,i[r>>2]=t-o))}function me(e){var t,n,r,s=0,o=0,a=0,A=0;A=0|i[(e|=0)>>2],a=(s=0|i[(n=e+4|0)>>2])+A|0,A=(o=0|i[(r=e+8|0)>>2])+A|0,i[e>>2]=A,i[n>>2]=a,s=o+s|0,i[r>>2]=s,o=a-A|0,(0|A)<0?(s=s-A|0,i[n>>2]=o,i[r>>2]=s,i[e>>2]=0,a=0):(o=a,a=A),(0|o)<0&&(a=a-o|0,i[e>>2]=a,s=s-o|0,i[r>>2]=s,i[n>>2]=0,o=0),t=a-s|0,A=o-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=A,i[r>>2]=0,a=t,s=0):A=o,(0|(o=(0|s)<(0|(o=(0|A)<(0|a)?A:a))?s:o))<=0||(i[e>>2]=a-o,i[n>>2]=A-o,i[r>>2]=s-o)}function _e(e){var t,n,r,s=0,o=0,a=0,A=0;s=0|i[(e|=0)>>2],a=0|i[(n=e+4|0)>>2],o=0|i[(r=e+8|0)>>2],A=a+s|0,i[e>>2]=A,a=o+a|0,i[n>>2]=a,s=o+s|0,i[r>>2]=s,o=a-A|0,(0|A)<0?(s=s-A|0,i[n>>2]=o,i[r>>2]=s,i[e>>2]=0,a=0):(o=a,a=A),(0|o)<0&&(a=a-o|0,i[e>>2]=a,s=s-o|0,i[r>>2]=s,i[n>>2]=0,o=0),t=a-s|0,A=o-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=A,i[r>>2]=0,a=t,s=0):A=o,(0|(o=(0|s)<(0|(o=(0|A)<(0|a)?A:a))?s:o))<=0||(i[e>>2]=a-o,i[n>>2]=A-o,i[r>>2]=s-o)}function be(e){switch(0|(e|=0)){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1}return 0|e}function ve(e){switch(0|(e|=0)){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1}return 0|e}function ye(e){var t,n,r,s=0,o=0,a=0,A=0;s=0|i[(e|=0)>>2],o=0|i[(n=e+4|0)>>2],a=0|i[(r=e+8|0)>>2],A=o+(s<<1)|0,i[e>>2]=A,o=a+(o<<1)|0,i[n>>2]=o,s=(a<<1)+s|0,i[r>>2]=s,a=o-A|0,(0|A)<0?(s=s-A|0,i[n>>2]=a,i[r>>2]=s,i[e>>2]=0,o=a,a=0):a=A,(0|o)<0&&(a=a-o|0,i[e>>2]=a,s=s-o|0,i[r>>2]=s,i[n>>2]=0,o=0),t=a-s|0,A=o-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=A,i[r>>2]=0,a=t,s=0):A=o,(0|(o=(0|s)<(0|(o=(0|A)<(0|a)?A:a))?s:o))<=0||(i[e>>2]=a-o,i[n>>2]=A-o,i[r>>2]=s-o)}function we(e){var t,n,r,s=0,o=0,a=0,A=0;A=0|i[(e|=0)>>2],a=((s=0|i[(n=e+4|0)>>2])<<1)+A|0,A=(o=0|i[(r=e+8|0)>>2])+(A<<1)|0,i[e>>2]=A,i[n>>2]=a,s=(o<<1)+s|0,i[r>>2]=s,o=a-A|0,(0|A)<0?(s=s-A|0,i[n>>2]=o,i[r>>2]=s,i[e>>2]=0,A=0):o=a,(0|o)<0&&(A=A-o|0,i[e>>2]=A,s=s-o|0,i[r>>2]=s,i[n>>2]=0,o=0),t=A-s|0,a=o-s|0,(0|s)<0?(i[e>>2]=t,i[n>>2]=a,i[r>>2]=0,A=t,s=0):a=o,(0|(o=(0|s)<(0|(o=(0|a)<(0|A)?a:A))?s:o))<=0||(i[e>>2]=A-o,i[n>>2]=a-o,i[r>>2]=s-o)}function xe(e,t){t|=0;var n,r,s,o=0,a=0,A=0;return s=(0|(r=(0|i[(e|=0)>>2])-(0|i[t>>2])|0))<0,n=(0|(a=(0|i[e+4>>2])-(0|i[t+4>>2])-(s?r:0)|0))<0,t=(t=(e=(0|(A=(s?0-r|0:0)+(0|i[e+8>>2])-(0|i[t+8>>2])+(n?0-a|0:0)|0))<0)?0:A)-((a=(0|(e=(0|t)<(0|(e=(0|(o=(n?0:a)-(e?A:0)|0))<(0|(A=(s?0:r)-(n?a:0)-(e?A:0)|0))?o:A))?t:e))>0)?e:0)|0,o=o-(a?e:0)|0,0|((0|(e=(0|(e=A-(a?e:0)|0))>-1?e:0-e|0))>(0|(t=(0|(o=(0|o)>-1?o:0-o|0))>(0|(t=(0|t)>-1?t:0-t|0))?o:t))?e:t)}function Ee(e){var t,n,r,s;n=(s=0|i[(t=8+(e|=0)|0)>>2])-(0|i[e>>2])|0,i[e>>2]=n,e=(0|i[(r=e+4|0)>>2])-s|0,i[r>>2]=e,i[t>>2]=0-(e+n)}function Te(e){var t,n,r=0,s=0,o=0,a=0,A=0;r=0-(s=0|i[(e|=0)>>2])|0,i[e>>2]=r,i[(t=e+8|0)>>2]=0,a=(o=0|i[(n=e+4|0)>>2])+s|0,(0|s)>0?(i[n>>2]=a,i[t>>2]=s,i[e>>2]=0,r=0,o=a):s=0,(0|o)<0?(A=r-o|0,i[e>>2]=A,s=s-o|0,i[t>>2]=s,i[n>>2]=0,a=A-s|0,r=0-s|0,(0|s)<0?(i[e>>2]=a,i[n>>2]=r,i[t>>2]=0,o=r,s=0):(o=0,a=A)):a=r,(0|(r=(0|s)<(0|(r=(0|o)<(0|a)?o:a))?s:r))<=0||(i[e>>2]=a-r,i[n>>2]=o-r,i[t>>2]=s-r)}function Se(e,t){var n=0;switch(n=0|nn(0|(e|=0),0|(t|=0),56),T(),7&n){case 0:case 7:return 0}return n=-2130706433&t|134217728,!0&268435456==(2013265920&t)?!0&16777216==(117440512&t)&!!(0|je(e,n))?0|(n=0):0|(n=0|De(e,n)):0|(n=0)}function Ce(e,t,n){n|=0;var r,s,o=0,a=0;return s=M,M=M+16|0,r=s,a=-2130706433&(t|=0)|134217728,!0&268435456==(2013265920&t)?(o=0|nn(0|(e|=0),0|t,56),T(),o=0|function(e,t,n){n|=0;var r,s=0,o=0;if(r=M,M=M+16|0,o=r,s=0|je(e|=0,t|=0),(n+-1|0)>>>0>5)return M=r,-1;if(1==(0|n)&(s=!!(0|s)))return M=r,-1;do{if(!(0|Lt(e,t,o))){if(s){s=(5+(0|i[26352+(n<<2)>>2])-(0|i[o>>2])|0)%5|0;break}s=(6+(0|i[26384+(n<<2)>>2])-(0|i[o>>2])|0)%6|0;break}s=-1}while(0);return M=r,0|(o=s)}(e,a,7&o),-1==(0|o)?(i[n>>2]=0,M=s,0|(a=6)):(0|Ke(e,a,r)&&S(27795,26932,282,26947),t=0|nn(0|e,0|t,52),T(),t&=15,0|je(e,a)?Re(r,t,o,2,n):Le(r,t,o,2,n),M=s,0|(a=0))):(M=s,0|(a=6))}function ke(e,t,n,r,o){t|=0,n|=0,r|=0,o|=0;var a,A=0,u=0;if(A=+function(e){var t,n;return n=+s[(e|=0)>>3],t=+s[e+8>>3],+ +c(+(n*n+t*t))}(e|=0),A<1e-16)return t=15600+(t<<4)|0,i[o>>2]=i[t>>2],i[o+4>>2]=i[t+4>>2],i[o+8>>2]=i[t+8>>2],void(i[o+12>>2]=i[t+12>>2]);if(u=+_(+ +s[e+8>>3],+ +s[e>>3]),(0|n)>0){e=0;do{A*=.37796447300922725,e=e+1|0}while((0|e)!=(0|n))}a=.3333333333333333*A,r?(n=!(0|Qe(n)),A=+m(.381966011250105*(n?a:.37796447300922725*a))):(A=+m(.381966011250105*A),0|Qe(n)&&(u=+it(u+.3334731722518321))),function(e,t,n,r){e|=0,t=+t,r|=0;var o=0,a=0,A=0,c=0;if((n=+n)<1e-16)return i[r>>2]=i[e>>2],i[r+4>>2]=i[e+4>>2],i[r+8>>2]=i[e+8>>2],void(i[r+12>>2]=i[e+12>>2]);a=t<0?t+6.283185307179586:t,a=t>=6.283185307179586?a+-6.283185307179586:a;do{if(!(a<1e-16)){if(o=+l(+(a+-3.141592653589793))<1e-16,t=+s[e>>3],o){t-=n,s[r>>3]=t,o=r;break}if(A=+h(+n),n=+d(+n),t=A*+d(+t)+ +h(+a)*(n*+h(+t)),t=+g(+((t=t>1?1:t)<-1?-1:t)),s[r>>3]=t,+l(+(t+-1.5707963267948966))<1e-16)return s[r>>3]=1.5707963267948966,void(s[r+8>>3]=0);if(+l(+(t+1.5707963267948966))<1e-16)return s[r>>3]=-1.5707963267948966,void(s[r+8>>3]=0);if(c=1/+h(+t),a=n*+d(+a)*c,n=+s[e>>3],t=c*((A-+d(+t)*+d(+n))/+h(+n)),A=a>1?1:a,t=t>1?1:t,(t=+s[e+8>>3]+ +_(+(A<-1?-1:A),+(t<-1?-1:t)))>3.141592653589793)do{t+=-6.283185307179586}while(t>3.141592653589793);if(t<-3.141592653589793)do{t+=6.283185307179586}while(t<-3.141592653589793);return void(s[r+8>>3]=t)}t=+s[e>>3]+n,s[r>>3]=t,o=r}while(0);if(+l(+(t+-1.5707963267948966))<1e-16)return s[o>>3]=1.5707963267948966,void(s[r+8>>3]=0);if(+l(+(t+1.5707963267948966))<1e-16)return s[o>>3]=-1.5707963267948966,void(s[r+8>>3]=0);if((t=+s[e+8>>3])>3.141592653589793)do{t+=-6.283185307179586}while(t>3.141592653589793);if(t<-3.141592653589793)do{t+=6.283185307179586}while(t<-3.141592653589793);s[r+8>>3]=t}(15600+(t<<4)|0,+it(+s[15920+(24*t|0)>>3]-u),A,o)}function Re(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var a,A,l,c,u,h,d,f,p,g,m,_,b,v,y,w,x,E,T,C,k,R,P=0,I=0,L=0,N=0,B=0,D=0;if(R=M,M=M+272|0,N=R+240|0,T=R,C=R+224|0,k=R+208|0,m=R+176|0,_=R+160|0,b=R+192|0,v=R+144|0,y=R+128|0,w=R+112|0,x=R+96|0,E=R+80|0,i[(P=R+256|0)>>2]=t,i[N>>2]=i[e>>2],i[N+4>>2]=i[e+4>>2],i[N+8>>2]=i[e+8>>2],i[N+12>>2]=i[e+12>>2],Pe(N,P,T),i[o>>2]=0,(0|(N=r+n+(5==(0|r)&1)|0))<=(0|n))M=R;else{A=C+4|0,l=m+4|0,c=n+5|0,u=16880+((a=0|i[P>>2])<<2)|0,h=16960+(a<<2)|0,d=y+8|0,f=w+8|0,p=x+8|0,g=k+4|0,L=n;e:for(;;){I=T+((0|L)%5<<4)|0,i[k>>2]=i[I>>2],i[k+4>>2]=i[I+4>>2],i[k+8>>2]=i[I+8>>2],i[k+12>>2]=i[I+12>>2];do{}while(2==(0|Ie(k,a,0,1)));if((0|L)>(0|n)&!!(0|Qe(t))){if(i[m>>2]=i[k>>2],i[m+4>>2]=i[k+4>>2],i[m+8>>2]=i[k+8>>2],i[m+12>>2]=i[k+12>>2],se(A,_),r=0|i[m>>2],P=0|i[17040+(80*r|0)+(i[C>>2]<<2)>>2],i[m>>2]=i[18640+(80*r|0)+(20*P|0)>>2],(0|(I=0|i[18640+(80*r|0)+(20*P|0)+16>>2]))>0){e=0;do{me(l),e=e+1|0}while((0|e)<(0|I))}switch(I=18640+(80*r|0)+(20*P|0)+4|0,i[b>>2]=i[I>>2],i[b+4>>2]=i[I+4>>2],i[b+8>>2]=i[I+8>>2],Ae(b,3*(0|i[u>>2])|0),oe(l,b,l),ie(l),se(l,v),B=+(0|i[h>>2]),s[y>>3]=3*B,s[d>>3]=0,D=-1.5*B,s[w>>3]=D,s[f>>3]=2.598076211353316*B,s[x>>3]=D,s[p>>3]=-2.598076211353316*B,0|i[17040+(80*(0|i[m>>2])|0)+(i[k>>2]<<2)>>2]){case 1:e=w,r=y;break;case 3:e=x,r=w;break;case 2:e=y,r=x;break;default:e=12;break e}Pt(_,v,r,e,E),ke(E,0|i[m>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])}if((0|L)<(0|c)&&(se(g,m),ke(m,0|i[k>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])),i[C>>2]=i[k>>2],i[C+4>>2]=i[k+4>>2],i[C+8>>2]=i[k+8>>2],i[C+12>>2]=i[k+12>>2],(0|(L=L+1|0))>=(0|N)){e=3;break}}3!=(0|e)?12==(0|e)&&S(26970,27017,572,27027):M=R}}function Pe(e,t,n){e|=0,t|=0,n|=0;var r,s=0,o=0,a=0,A=0,l=0;r=M,M=M+128|0,o=r,A=20240,l=60+(a=s=r+64|0)|0;do{i[a>>2]=i[A>>2],a=a+4|0,A=A+4|0}while((0|a)<(0|l));A=20304,l=(a=o)+60|0;do{i[a>>2]=i[A>>2],a=a+4|0,A=A+4|0}while((0|a)<(0|l));s=(l=!(0|Qe(0|i[t>>2])))?s:o,ye(o=e+4|0),we(o),0|Qe(0|i[t>>2])&&(pe(o),i[t>>2]=1+(0|i[t>>2])),i[n>>2]=i[e>>2],oe(o,s,t=n+4|0),ie(t),i[n+16>>2]=i[e>>2],oe(o,s+12|0,t=n+20|0),ie(t),i[n+32>>2]=i[e>>2],oe(o,s+24|0,t=n+36|0),ie(t),i[n+48>>2]=i[e>>2],oe(o,s+36|0,t=n+52|0),ie(t),i[n+64>>2]=i[e>>2],oe(o,s+48|0,n=n+68|0),ie(n),M=r}function Ie(e,t,n,r){n|=0,r|=0;var s,o,a,A,l,c,u=0,h=0,d=0,f=0,p=0;if(c=M,M=M+32|0,l=c+12|0,o=c,p=4+(e|=0)|0,f=0|i[16960+((t|=0)<<2)>>2],f=(A=!!(0|r))?3*f|0:f,u=0|i[p>>2],s=0|i[(a=e+8|0)>>2],A){if((0|(u=s+u+(r=0|i[(h=e+12|0)>>2])|0))==(0|f))return M=c,1;d=h}else u=s+u+(r=0|i[(d=e+12|0)>>2])|0;if((0|u)<=(0|f))return M=c,0;do{if((0|r)>0){if(r=0|i[e>>2],(0|s)>0){h=18640+(80*r|0)+60|0,r=e;break}r=18640+(80*r|0)+40|0,n?(re(l,f,0,0),ae(p,l,o),_e(o),oe(o,l,p),h=r,r=e):(h=r,r=e)}else h=18640+(80*(0|i[e>>2])|0)+20|0,r=e}while(0);if(i[r>>2]=i[h>>2],(0|i[(u=h+16|0)>>2])>0){r=0;do{me(p),r=r+1|0}while((0|r)<(0|i[u>>2]))}return e=h+4|0,i[l>>2]=i[e>>2],i[l+4>>2]=i[e+4>>2],i[l+8>>2]=i[e+8>>2],t=0|i[16880+(t<<2)>>2],Ae(l,A?3*t|0:t),oe(p,l,p),ie(p),r=A&&((0|i[a>>2])+(0|i[p>>2])+(0|i[d>>2])|0)==(0|f)?1:2,M=c,0|r}function Me(e,t){e|=0,t|=0;var n=0;do{n=0|Ie(e,t,0,1)}while(2==(0|n));return 0|n}function Le(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var a,A,l,c,u,h,d,f,p,g,m,_,b,v,y,w,x,E,T=0,C=0,k=0,R=0,P=0;if(E=M,M=M+240|0,v=E+208|0,y=E,w=E+192|0,x=E+176|0,p=E+160|0,g=E+144|0,m=E+128|0,_=E+112|0,b=E+96|0,i[(T=E+224|0)>>2]=t,i[v>>2]=i[e>>2],i[v+4>>2]=i[e+4>>2],i[v+8>>2]=i[e+8>>2],i[v+12>>2]=i[e+12>>2],Ne(v,T,y),i[o>>2]=0,(0|(f=r+n+(6==(0|r)&1)|0))<=(0|n))M=E;else{A=n+6|0,l=16960+((a=0|i[T>>2])<<2)|0,c=g+8|0,u=m+8|0,h=_+8|0,d=w+4|0,C=0,k=n,r=-1;e:for(;;){if(e=y+((T=(0|k)%6|0)<<4)|0,i[w>>2]=i[e>>2],i[w+4>>2]=i[e+4>>2],i[w+8>>2]=i[e+8>>2],i[w+12>>2]=i[e+12>>2],e=C,C=0|Ie(w,a,0,1),(0|k)>(0|n)&!!(0|Qe(t))&&1!=(0|e)&&(0|i[w>>2])!=(0|r)){switch(se(y+((T+5|0)%6<<4)+4|0,x),se(y+(T<<4)+4|0,p),R=+(0|i[l>>2]),s[g>>3]=3*R,s[c>>3]=0,P=-1.5*R,s[m>>3]=P,s[u>>3]=2.598076211353316*R,s[_>>3]=P,s[h>>3]=-2.598076211353316*R,T=0|i[v>>2],0|i[17040+(80*T|0)+(((0|r)==(0|T)?i[w>>2]:r)<<2)>>2]){case 1:e=m,r=g;break;case 3:e=_,r=m;break;case 2:e=g,r=_;break;default:e=8;break e}Pt(x,p,r,e,b),0|It(x,b)||0|It(p,b)||(ke(b,0|i[v>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2]))}if((0|k)<(0|A)&&(se(d,x),ke(x,0|i[w>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])),(0|(k=k+1|0))>=(0|f)){e=3;break}r=0|i[w>>2]}3!=(0|e)?8==(0|e)&&S(27054,27017,737,27099):M=E}}function Ne(e,t,n){e|=0,t|=0,n|=0;var r,s=0,o=0,a=0,A=0,l=0;r=M,M=M+160|0,o=r,A=20368,l=72+(a=s=r+80|0)|0;do{i[a>>2]=i[A>>2],a=a+4|0,A=A+4|0}while((0|a)<(0|l));A=20448,l=(a=o)+72|0;do{i[a>>2]=i[A>>2],a=a+4|0,A=A+4|0}while((0|a)<(0|l));s=(l=!(0|Qe(0|i[t>>2])))?s:o,ye(o=e+4|0),we(o),0|Qe(0|i[t>>2])&&(pe(o),i[t>>2]=1+(0|i[t>>2])),i[n>>2]=i[e>>2],oe(o,s,t=n+4|0),ie(t),i[n+16>>2]=i[e>>2],oe(o,s+12|0,t=n+20|0),ie(t),i[n+32>>2]=i[e>>2],oe(o,s+24|0,t=n+36|0),ie(t),i[n+48>>2]=i[e>>2],oe(o,s+36|0,t=n+52|0),ie(t),i[n+64>>2]=i[e>>2],oe(o,s+48|0,t=n+68|0),ie(t),i[n+80>>2]=i[e>>2],oe(o,s+60|0,n=n+84|0),ie(n),M=r}function Be(e,t){return t=0|nn(0|(e|=0),0|(t|=0),45),T(),127&t}function De(e,t){e|=0;var n=0,i=0,s=0,o=0;return!0&134217728==(-16777216&(t|=0))?(i=0|nn(0|e,0|t,52),T(),i&=15,n=0|nn(0|e,0|t,45),T(),(n&=127)>>>0>121?0|(e=0):!(613566756&(o=0|rn(0|(s=0|nn(0|e,0|t,0|(o=3*(15^i)|0))),0|T(),0|o))&Qt(-1227133514,-1171,0|o,0|(s=0|T())))&!(4681&s&T())&&15==(0|i)|!(0|(o=0|nn(0|rn(0|~e,0|~t,0|(o=19+(3*i|0)|0)),0|T(),0|o)))&!(0|T())?0|r[20528+n|0]?!(0|e)&!(0|(t&=8191))?0|(o=1):(o=0|sn(0|e,0|t),T(),0|!!((63-o|0)%3|0)):0|(o=1):0|(o=0)):0|(e=0)}function Oe(e,t,n,r){e|=0,n|=0,r|=0;var s=0,o=0,a=0,A=0;if(s=0|rn(0|(t|=0),0,52),o=0|T(),n=0|rn(0|n,0,45),n=0|o|T()|134225919,(0|t)<1)return o=-1,r=n,i[(t=e)>>2]=o,void(i[(e=e+4|0)>>2]=r);for(o=1,s=-1;A=0|rn(7,0,0|(a=3*(15-o|0)|0)),n&=~T(),s=s&~A|(a=0|rn(0|r,0,0|a)),n=0|n|T(),(0|o)!=(0|t);)o=o+1|0;i[(a=A=e)>>2]=s,i[(A=A+4|0)>>2]=n}function Fe(e,t,n,r){n|=0,r|=0;var s=0,o=0;if(o=0|nn(0|(e|=0),0|(t|=0),52),T(),n>>>0>15)return 4;if((0|(o&=15))<(0|n))return 12;if((0|o)==(0|n))return i[r>>2]=e,i[r+4>>2]=t,0;if(s=0|rn(0|n,0,52),s|=e,e=T()|-15728641&t,(0|o)>(0|n))do{t=0|rn(7,0,3*(14-n|0)|0),n=n+1|0,s|=t,e=0|T()|e}while((0|n)<(0|o));return i[r>>2]=s,i[r+4>>2]=e,0}function Ue(e,t,n,r){n|=0,r|=0;var s=0,o=0,a=0;if(o=0|nn(0|(e|=0),0|(t|=0),52),T(),!((0|n)<16&(0|(o&=15))<=(0|n)))return 4;s=n-o|0,n=0|nn(0|e,0|t,45),T();e:do{if(0|G(127&n)){t:do{if(0|o){for(n=1;!((a=0|rn(7,0,3*(15-n|0)|0))&e)&!((0|T())&t);){if(!(n>>>0<o>>>0))break t;n=n+1|0}n=0|_t(7,0,s,((0|s)<0)<<31>>31),s=0|T();break e}}while(0);n=0|Xt(0|(n=0|Zt(0|(n=0|_t(7,0,s,((0|s)<0)<<31>>31)),0|T(),5,0)),0|T(),-5,-1),n=0|Xt(0|(n=0|Kt(0|n,0|T(),6,0)),0|T(),1,0),s=0|T()}else n=0|_t(7,0,s,((0|s)<0)<<31>>31),s=0|T()}while(0);return i[(a=r)>>2]=n,i[a+4>>2]=s,0}function je(e,t){var n=0,r=0,i=0;if(i=0|nn(0|(e|=0),0|(t|=0),45),T(),!(0|G(127&i)))return 0;i=0|nn(0|e,0|t,52),T(),i&=15;e:do{if(i)for(r=1;;){if(n=0|nn(0|e,0|t,3*(15-r|0)|0),T(),0|(n&=7))break e;if(!(r>>>0<i>>>0)){n=0;break}r=r+1|0}else n=0}while(0);return 1&!(0|n)}function Ge(e,t,n,r){return e|=0,t|=0,(0|(r|=0))<(0|(n|=0))?(r=e,E(0|(n=t)),0|r):(n=0|rn(-1,-1,3+(3*(r-n|0)|0)|0),r=0|rn(0|~n,0|~T(),3*(15-r|0)|0),n=~T()&t,r=~r&e,E(0|n),0|r)}function ze(e,t,n,r){n|=0,r|=0;var s=0;return s=0|nn(0|(e|=0),0|(t|=0),52),T(),(0|n)<16&(0|(s&=15))<=(0|n)?((0|s)<(0|n)&&(s=0|rn(-1,-1,3+(3*(n+-1-s|0)|0)|0),s=0|rn(0|~s,0|~T(),3*(15-n|0)|0),t=~T()&t,e&=~s),s=0|rn(0|n,0,52),n=-15728641&t|T(),i[r>>2]=e|s,i[r+4>>2]=n,0|(r=0)):0|(r=4)}function Ve(e,t){var n=0,r=0,i=0;if(i=0|nn(0|(e|=0),0|(t|=0),52),T(),!(i&=15))return 0;for(r=1;;){if(n=0|nn(0|e,0|t,3*(15-r|0)|0),T(),0|(n&=7)){r=5;break}if(!(r>>>0<i>>>0)){n=0,r=5;break}r=r+1|0}return 5==(0|r)?0|n:0}function We(e,t){var n=0,r=0,i=0,s=0,o=0,a=0,A=0;if(A=0|nn(0|(e|=0),0|(t|=0),52),T(),!(A&=15))return A=e,E(0|(a=t)),0|A;for(a=1,n=0;;){r=0|rn(7,0,0|(s=3*(15-a|0)|0)),i=0|T(),o=0|nn(0|e,0|t,0|s),T(),e=(s=0|rn(0|be(7&o),0,0|s))|e&~r,t=(o=0|T())|t&~i;e:do{if(!n)if(!(s&r|0)&!(o&i|0))n=0;else if(r=0|nn(0|e,0|t,52),T(),r&=15){n=1;t:for(;;){switch(o=0|nn(0|e,0|t,3*(15-n|0)|0),T(),7&o){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0<r>>>0)){n=1;break e}n=n+1|0}for(n=1;;){if(i=0|nn(0|e,0|t,0|(o=3*(15-n|0)|0)),T(),s=0|rn(7,0,0|o),t&=~T(),e=e&~s|(o=0|rn(0|be(7&i),0,0|o)),t=0|t|T(),!(n>>>0<r>>>0)){n=1;break}n=n+1|0}}else n=1}while(0);if(!(a>>>0<A>>>0))break;a=a+1|0}return E(0|t),0|e}function He(e,t){var n=0,r=0,i=0,s=0,o=0;if(r=0|nn(0|(e|=0),0|(t|=0),52),T(),!(r&=15))return r=e,E(0|(n=t)),0|r;for(n=1;o=0|nn(0|e,0|t,0|(s=3*(15-n|0)|0)),T(),i=0|rn(7,0,0|s),t&=~T(),e=(s=0|rn(0|be(7&o),0,0|s))|e&~i,t=0|T()|t,n>>>0<r>>>0;)n=n+1|0;return E(0|t),0|e}function $e(e,t){var n=0,r=0,i=0,s=0,o=0,a=0,A=0;if(A=0|nn(0|(e|=0),0|(t|=0),52),T(),!(A&=15))return A=e,E(0|(a=t)),0|A;for(a=1,n=0;;){r=0|rn(7,0,0|(s=3*(15-a|0)|0)),i=0|T(),o=0|nn(0|e,0|t,0|s),T(),e=(s=0|rn(0|ve(7&o),0,0|s))|e&~r,t=(o=0|T())|t&~i;e:do{if(!n)if(!(s&r|0)&!(o&i|0))n=0;else if(r=0|nn(0|e,0|t,52),T(),r&=15){n=1;t:for(;;){switch(o=0|nn(0|e,0|t,3*(15-n|0)|0),T(),7&o){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0<r>>>0)){n=1;break e}n=n+1|0}for(n=1;;){if(s=0|rn(7,0,0|(i=3*(15-n|0)|0)),o=t&~T(),t=0|nn(0|e,0|t,0|i),T(),e=e&~s|(t=0|rn(0|ve(7&t),0,0|i)),t=0|o|T(),!(n>>>0<r>>>0)){n=1;break}n=n+1|0}}else n=1}while(0);if(!(a>>>0<A>>>0))break;a=a+1|0}return E(0|t),0|e}function Xe(e,t){var n=0,r=0,i=0,s=0,o=0;if(r=0|nn(0|(e|=0),0|(t|=0),52),T(),!(r&=15))return r=e,E(0|(n=t)),0|r;for(n=1;s=0|rn(7,0,0|(o=3*(15-n|0)|0)),i=t&~T(),t=0|nn(0|e,0|t,0|o),T(),e=(t=0|rn(0|ve(7&t),0,0|o))|e&~s,t=0|T()|i,n>>>0<r>>>0;)n=n+1|0;return E(0|t),0|e}function Qe(e){return(0|(e|=0))%2|0}function Ye(e,t,n){n|=0;var r,o=0;return r=M,M=M+16|0,o=r,(t|=0)>>>0>15?(M=r,0|(o=4)):2146435072&~i[4+(e|=0)>>2]&&2146435072&~i[e+8+4>>2]?(function(e,t,n){var r,o;r=M,M=M+16|0,function(e,t,n,r){t|=0,r|=0;var o,a=0,A=0,l=0,c=0;if(o=M,M=M+16|0,function(e,t,n){t|=0,n|=0;var r,o,a=0;o=M,M=M+32|0,function(e,t){t|=0;var n,r,i=0;i=+s[(e|=0)>>3],n=+h(+i),i=+d(+i),s[t+16>>3]=i,i=+s[e+8>>3],r=n*+h(+i),s[t>>3]=r,i=n*+d(+i),s[t+8>>3]=i}(e|=0,r=o),i[t>>2]=0,s[n>>3]=5,(a=+Mt(16400,r))<+s[n>>3]&&(i[t>>2]=0,s[n>>3]=a),(a=+Mt(16424,r))<+s[n>>3]&&(i[t>>2]=1,s[n>>3]=a),(a=+Mt(16448,r))<+s[n>>3]&&(i[t>>2]=2,s[n>>3]=a),(a=+Mt(16472,r))<+s[n>>3]&&(i[t>>2]=3,s[n>>3]=a),(a=+Mt(16496,r))<+s[n>>3]&&(i[t>>2]=4,s[n>>3]=a),(a=+Mt(16520,r))<+s[n>>3]&&(i[t>>2]=5,s[n>>3]=a),(a=+Mt(16544,r))<+s[n>>3]&&(i[t>>2]=6,s[n>>3]=a),(a=+Mt(16568,r))<+s[n>>3]&&(i[t>>2]=7,s[n>>3]=a),(a=+Mt(16592,r))<+s[n>>3]&&(i[t>>2]=8,s[n>>3]=a),(a=+Mt(16616,r))<+s[n>>3]&&(i[t>>2]=9,s[n>>3]=a),(a=+Mt(16640,r))<+s[n>>3]&&(i[t>>2]=10,s[n>>3]=a),(a=+Mt(16664,r))<+s[n>>3]&&(i[t>>2]=11,s[n>>3]=a),(a=+Mt(16688,r))<+s[n>>3]&&(i[t>>2]=12,s[n>>3]=a),(a=+Mt(16712,r))<+s[n>>3]&&(i[t>>2]=13,s[n>>3]=a),(a=+Mt(16736,r))<+s[n>>3]&&(i[t>>2]=14,s[n>>3]=a),(a=+Mt(16760,r))<+s[n>>3]&&(i[t>>2]=15,s[n>>3]=a),(a=+Mt(16784,r))<+s[n>>3]&&(i[t>>2]=16,s[n>>3]=a),(a=+Mt(16808,r))<+s[n>>3]&&(i[t>>2]=17,s[n>>3]=a),(a=+Mt(16832,r))<+s[n>>3]&&(i[t>>2]=18,s[n>>3]=a),(a=+Mt(16856,r))<+s[n>>3]?(i[t>>2]=19,s[n>>3]=a,M=o):M=o}(e|=0,n|=0,c=o),(A=+p(+(1-.5*+s[c>>3])))<1e-16)return i[r>>2]=0,i[r+4>>2]=0,i[r+8>>2]=0,i[r+12>>2]=0,void(M=o);if(c=0|i[n>>2],a=+it((a=+s[15920+(24*c|0)>>3])-+it(+function(e,t){var n,r,i,o,a;return e|=0,o=+s[(t|=0)>>3],r=+h(+o),i=+s[t+8>>3]-+s[e+8>>3],a=r*+d(+i),n=+s[e>>3],+ +_(+a,+(+d(+o)*+h(+n)-+h(+i)*(r*+d(+n))))}(15600+(c<<4)|0,e))),l=0|Qe(t)?+it(a+-.3334731722518321):a,a=2.618033988749896*+f(+A),(0|t)>0){e=0;do{a*=2.6457513110645907,e=e+1|0}while((0|e)!=(0|t))}A=+h(+l)*a,s[r>>3]=A,l=+d(+l)*a,s[r+8>>3]=l,M=o}(e|=0,t|=0,n|=0,o=r),function(e,t){e|=0;var n,r,o,a,A=0,c=0,u=0,h=0,d=0,f=0,p=0;i[(a=8+(t|=0)|0)>>2]=0,r=+s[e>>3],h=+l(+r),o=+s[e+8>>3],h+=.5*(d=1.1547005383792515*+l(+o)),h-=+(0|(A=~~h)),d-=+(0|(e=~~d));do{if(h<.5){if(h<.3333333333333333){if(i[t>>2]=A,d<.5*(h+1)){i[t+4>>2]=e;break}e=e+1|0,i[t+4>>2]=e;break}if(e=(1&!(d<(p=1-h)))+e|0,i[t+4>>2]=e,p<=d&d<2*h){A=A+1|0,i[t>>2]=A;break}i[t>>2]=A;break}if(!(h<.6666666666666666)){if(A=A+1|0,i[t>>2]=A,d<.5*h){i[t+4>>2]=e;break}e=e+1|0,i[t+4>>2]=e;break}if(d<1-h){if(i[t+4>>2]=e,2*h-1<d){i[t>>2]=A;break}}else e=e+1|0,i[t+4>>2]=e;A=A+1|0,i[t>>2]=A}while(0);do{if(r<0){if(1&e){A=~~(+(0|A)-(2*(+((f=0|Qt(0|A,((0|A)<0)<<31>>31,0|(f=(e+1|0)/2|0),((0|f)<0)<<31>>31))>>>0)+4294967296*+(0|T()))+1)),i[t>>2]=A;break}A=~~(+(0|A)-2*(+((f=0|Qt(0|A,((0|A)<0)<<31>>31,0|(f=(0|e)/2|0),((0|f)<0)<<31>>31))>>>0)+4294967296*+(0|T()))),i[t>>2]=A;break}}while(0);f=t+4|0,o<0&&(A=A-((1|e<<1)/2|0)|0,i[t>>2]=A,e=0-e|0,i[f>>2]=e),c=e-A|0,(0|A)<0?(u=0-A|0,i[f>>2]=c,i[a>>2]=u,i[t>>2]=0,e=c,A=0):u=0,(0|e)<0&&(A=A-e|0,i[t>>2]=A,u=u-e|0,i[a>>2]=u,i[f>>2]=0,e=0),n=A-u|0,c=e-u|0,(0|u)<0&&(i[t>>2]=n,i[f>>2]=c,i[a>>2]=0,e=c,A=n,u=0),(0|(c=(0|u)<(0|(c=(0|e)<(0|A)?e:A))?u:c))<=0||(i[t>>2]=A-c,i[f>>2]=e-c,i[a>>2]=u-c)}(o,n+4|0),M=r}(e,t,o),t=0|function(e,t){e|=0;var n,r=0,s=0,o=0,a=0,A=0,l=0,c=0,u=0;if(n=M,M=M+64|0,l=n+40|0,s=n+24|0,o=n+12|0,a=n,rn(0|(t|=0),0,52),r=134225919|T(),!t)return(0|i[e+4>>2])>2||(0|i[e+8>>2])>2||(0|i[e+12>>2])>2?(l=0,E(0|(A=0)),M=n,0|l):(rn(0|V(e),0,45),A=0|T()|r,l=-1,E(0|A),M=n,0|l);if(i[l>>2]=i[e>>2],i[l+4>>2]=i[e+4>>2],i[l+8>>2]=i[e+8>>2],i[l+12>>2]=i[e+12>>2],A=l+4|0,(0|t)>0)for(e=-1;i[s>>2]=i[A>>2],i[s+4>>2]=i[A+4>>2],i[s+8>>2]=i[A+8>>2],1&t?(he(A),i[o>>2]=i[A>>2],i[o+4>>2]=i[A+4>>2],i[o+8>>2]=i[A+8>>2],fe(o)):(de(A),i[o>>2]=i[A>>2],i[o+4>>2]=i[A+4>>2],i[o+8>>2]=i[A+8>>2],pe(o)),ae(s,o,a),ie(a),c=0|rn(7,0,0|(u=3*(15-t|0)|0)),r&=~T(),e=(u=0|rn(0|le(a),0,0|u))|e&~c,r=0|T()|r,(0|t)>1;)t=t+-1|0;else e=-1;e:do{if((0|i[A>>2])<=2&&(0|i[l+8>>2])<=2&&(0|i[l+12>>2])<=2){if(t=0|rn(0|(s=0|V(l)),0,45),t|=e,e=T()|-1040385&r,a=0|W(l),!(0|G(s))){if((0|a)<=0)break;for(o=0;;){if(s=0|nn(0|t,0|e,52),T(),s&=15)for(r=1;l=0|nn(0|t,0|e,0|(u=3*(15-r|0)|0)),T(),c=0|rn(7,0,0|u),e&=~T(),t=t&~c|(u=0|rn(0|be(7&l),0,0|u)),e=0|e|T(),r>>>0<s>>>0;)r=r+1|0;if((0|(o=o+1|0))==(0|a))break e}}o=0|nn(0|t,0|e,52),T(),o&=15;t:do{if(o){r=1;n:for(;;){switch(u=0|nn(0|t,0|e,3*(15-r|0)|0),T(),7&u){case 1:break n;case 0:break;default:break t}if(!(r>>>0<o>>>0))break t;r=r+1|0}if(0|H(s,0|i[l>>2]))for(r=1;c=0|rn(7,0,0|(l=3*(15-r|0)|0)),u=e&~T(),e=0|nn(0|t,0|e,0|l),T(),t=t&~c|(e=0|rn(0|ve(7&e),0,0|l)),e=0|u|T(),r>>>0<o>>>0;)r=r+1|0;else for(r=1;l=0|nn(0|t,0|e,0|(u=3*(15-r|0)|0)),T(),c=0|rn(7,0,0|u),e&=~T(),t=t&~c|(u=0|rn(0|be(7&l),0,0|u)),e=0|e|T(),r>>>0<o>>>0;)r=r+1|0}}while(0);if((0|a)>0){r=0;do{t=0|We(t,e),e=0|T(),r=r+1|0}while((0|r)!=(0|a))}}else t=0,e=0}while(0);return u=t,E(0|(c=e)),M=n,0|u}(o,t),o=0|T(),i[n>>2]=t,i[n+4>>2]=o,!(0|t)&!(0|o)&&S(27795,27122,1050,27145),M=r,0|(o=0)):(M=r,0|(o=3))}function qe(e,t,n){var r,s=0,o=0,a=0;if(r=4+(n|=0)|0,o=0|nn(0|(e|=0),0|(t|=0),52),T(),o&=15,a=0|nn(0|e,0|t,45),T(),s=!(0|o),0|G(127&a)){if(s)return 1;s=1}else{if(s)return 0;s=0|i[r>>2]||0|i[n+8>>2]?1:1&!!(0|i[n+12>>2])}for(n=1;1&n?fe(r):pe(r),a=0|nn(0|e,0|t,3*(15-n|0)|0),T(),ge(r,7&a),n>>>0<o>>>0;)n=n+1|0;return 0|s}function Ke(e,t,n){n|=0;var r,s,o=0,a=0,A=0,l=0,c=0,u=0;if(s=M,M=M+16|0,r=s,u=0|nn(0|(e|=0),0|(t|=0),45),T(),(u&=127)>>>0>121)return i[n>>2]=0,i[n+4>>2]=0,i[n+8>>2]=0,i[n+12>>2]=0,M=s,5;e:do{if(0|G(u)&&(A=0|nn(0|e,0|t,52),T(),0|(A&=15))){o=1;t:for(;;){switch(c=0|nn(0|e,0|t,3*(15-o|0)|0),T(),7&c){case 5:break t;case 0:break;default:o=t;break e}if(!(o>>>0<A>>>0)){o=t;break e}o=o+1|0}for(a=1,o=t;l=0|rn(7,0,0|(t=3*(15-a|0)|0)),c=o&~T(),o=0|nn(0|e,0|o,0|t),T(),e=e&~l|(o=0|rn(0|ve(7&o),0,0|t)),o=0|c|T(),a>>>0<A>>>0;)a=a+1|0}else o=t}while(0);if(c=7696+(28*u|0)|0,i[n>>2]=i[c>>2],i[n+4>>2]=i[c+4>>2],i[n+8>>2]=i[c+8>>2],i[n+12>>2]=i[c+12>>2],!(0|qe(e,o,n)))return M=s,0;if(l=n+4|0,i[r>>2]=i[l>>2],i[r+4>>2]=i[l+4>>2],i[r+8>>2]=i[l+8>>2],A=0|nn(0|e,0|o,52),T(),c=15&A,1&A?(pe(l),A=c+1|0):A=c,0|G(u)){e:do{if(c)for(t=1;;){if(a=0|nn(0|e,0|o,3*(15-t|0)|0),T(),0|(a&=7)){o=a;break e}if(!(t>>>0<c>>>0)){o=0;break}t=t+1|0}else o=0}while(0);o=4==(0|o)&1}else o=0;if(0|Ie(n,A,o,0)){if(0|G(u))do{}while(0|Ie(n,A,0,0));(0|A)!=(0|c)&&de(l)}else(0|A)!=(0|c)&&(i[l>>2]=i[r>>2],i[l+4>>2]=i[r+4>>2],i[l+8>>2]=i[r+8>>2]);return M=s,0}function Ze(e,t,n){n|=0;var r,s,o=0;return s=M,M=M+16|0,0|(o=0|Ke(e|=0,t|=0,r=s))?(M=s,0|o):(o=0|nn(0|e,0|t,52),T(),function(e,t,n){var r,s;t|=0,n|=0,r=M,M=M+16|0,se(4+(e|=0)|0,s=r),ke(s,0|i[e>>2],t,0,n),M=r}(r,15&o,n),M=s,0|(o=0))}function Je(e,t,n){n|=0;var r,i=0,s=0,o=0;if(r=M,M=M+16|0,0|(i=0|Ke(e|=0,t|=0,o=r)))return M=r,0|i;i=0|nn(0|e,0|t,45),T(),i=!(0|G(127&i)),s=0|nn(0|e,0|t,52),T(),s&=15;e:do{if(!i){if(0|s)for(i=1;;){if(!(!((0|rn(7,0,3*(15-i|0)|0))&e)&!((0|T())&t)))break e;if(!(i>>>0<s>>>0))break;i=i+1|0}return Re(o,s,0,5,n),M=r,0}}while(0);return Le(o,s,0,6,n),M=r,0}function et(e,t){t|=0;var n=0,r=0,s=0,o=0,a=0,A=0,l=0;if((e|=0)>>>0>15)return 4;if(rn(0|e,0,52),A=134225919|T(),!e){n=0,r=0;do{0|G(r)&&(rn(0|r,0,45),a=0|A|T(),i[(e=t+(n<<3)|0)>>2]=-1,i[e+4>>2]=a,n=n+1|0),r=r+1|0}while(122!=(0|r));return 0}n=0,a=0;do{if(0|G(a)){for(rn(0|a,0,45),r=1,s=-1,o=0|A|T();s&=~(l=0|rn(7,0,3*(15-r|0)|0)),o&=~T(),(0|r)!=(0|e);)r=r+1|0;i[(l=t+(n<<3)|0)>>2]=s,i[l+4>>2]=o,n=n+1|0}a=a+1|0}while(122!=(0|a));return 0}function tt(e,t,n,r){e|=0,r|=0;var s=0,o=0,a=0;s=0|nn(0|(t|=0),0|(n|=0),52),T(),!(0|t)&!(0|n)|(0|r)>15|(0|(s&=15))>(0|r)?(o=-1,t=-1,n=0,s=0):(t=0|Ge(t,n,s+1|0,r),a=-15728641&T(),n=0|rn(0|r,0,52),o=s,t=(t=!(0|je(n|=t,a=0|a|T())))?-1:r,s=a),i[(a=e)>>2]=n,i[a+4>>2]=s,i[e+8>>2]=o,i[e+12>>2]=t}function nt(e,t,n,r){n|=0,r|=0;var s=0,o=0;return s=0|nn(0|(e|=0),0|(t|=0),52),T(),s&=15,i[(o=r+8|0)>>2]=s,!(0|e)&!(0|t)|(0|n)>15|(0|s)>(0|n)?(i[(n=r)>>2]=0,i[n+4>>2]=0,i[o>>2]=-1,void(i[r+12>>2]=-1)):(e=0|Ge(e,t,s+1|0,n),o=-15728641&T(),s=0|rn(0|n,0,52),s|=e,o=0|o|T(),i[(e=r)>>2]=s,i[e+4>>2]=o,e=r+12|0,0|je(s,o)?void(i[e>>2]=n):void(i[e>>2]=-1))}function rt(e){var t,n=0,r=0,s=0,o=0,a=0,A=0,l=0,c=0;if(!(!(0|(n=0|i[(r=e|=0)>>2]))&!(0|(r=0|i[r+4>>2]))||(s=0|nn(0|n,0|r,52),T(),n=0|Xt(0|(l=0|rn(1,0,3*(15^(s&=15))|0)),0|T(),0|n,0|r),r=0|T(),i[(l=e)>>2]=n,i[l+4>>2]=r,(0|s)<(0|(A=0|i[(l=e+8|0)>>2]))))){for(t=e+12|0,a=s;;){if((0|a)==(0|A)){s=5;break}if(c=(0|a)==(0|i[t>>2]),s=0|nn(0|n,0|r,0|(o=3*(15-a|0)|0)),T(),c&1==(0|(s&=7))&!0){s=7;break}if(!(7==(0|s)&!0)){s=10;break}if(n=0|Xt(0|n,0|r,0|(c=0|rn(1,0,0|o)),0|T()),r=0|T(),i[(c=e)>>2]=n,i[c+4>>2]=r,!((0|a)>(0|A))){s=10;break}a=a+-1|0}if(5==(0|s))return i[(c=e)>>2]=0,i[c+4>>2]=0,i[l>>2]=-1,void(i[t>>2]=-1);if(7==(0|s))return A=0|Xt(0|n,0|r,0|(A=0|rn(1,0,0|o)),0|T()),l=0|T(),i[(c=e)>>2]=A,i[c+4>>2]=l,void(i[t>>2]=a+-1)}}function it(e){var t;return t=(e=+e)<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function st(e,t){return t|=0,+l(+(+s[(e|=0)>>3]-+s[t>>3]))<17453292519943298e-27?0|(t=+l(+(+s[e+8>>3]-+s[t+8>>3]))<17453292519943298e-27):0|(t=0)}function ot(e,t){switch(e=+e,0|(t|=0)){case 1:e=e<0?e+6.283185307179586:e;break;case 2:e=e>0?e+-6.283185307179586:e}return+e}function at(e,t){e|=0;var n,r,i,o=0;return r=+s[(t|=0)>>3],n=+s[e>>3],o=(i=+d(.5*(r-n)))*i+(o=+d(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+h(+r)*+h(+n)*o),2*+_(+ +c(+o),+ +c(+(1-o)))*6371.007180918475}function At(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20656+(e<<3)>>3],0|(t=0))}function lt(e,t){t|=0;var n=0;return(e|=0)>>>0>15?0|(t=4):(n=0|Zt(0|(n=0|_t(7,0,e,((0|e)<0)<<31>>31)),0|T(),120,0),e=0|T(),i[t>>2]=2|n,i[t+4>>2]=e,0|(t=0))}function ct(e,t,n){e|=0,n|=0;var r,i,o,a,A=0,l=0,u=0,p=0,g=0,b=0;return b=+s[(t|=0)>>3],o=+s[e>>3],g=+d(.5*(b-o)),u=+s[t+8>>3],i=+s[e+8>>3],p=+d(.5*(u-i)),r=+h(+o),a=+h(+b),p=2*+_(+ +c(+(p=g*g+p*(a*r*p))),+ +c(+(1-p))),g=+s[n>>3],b=+d(.5*(g-b)),A=+s[n+8>>3],u=+d(.5*(A-u)),l=+h(+g),u=2*+_(+ +c(+(u=b*b+u*(a*l*u))),+ +c(+(1-u))),g=+d(.5*(o-g)),A=+d(.5*(i-A)),A=2*+_(+ +c(+(A=g*g+A*(r*l*A))),+ +c(+(1-A))),4*+m(+ +c(+ +f(.5*(l=.5*(p+u+A)))*+f(.5*(l-p))*+f(.5*(l-u))*+f(.5*(l-A))))}function ut(e,t,n){n|=0;var r,o,a,A=0,l=0;if(a=M,M=M+192|0,o=a,0|(l=0|Ze(e|=0,t|=0,r=a+168|0)))return M=a,0|l;if(0|Je(e,t,o)&&S(27795,27190,415,27199),(0|(t=0|i[o>>2]))>0){if(A=+ct(o+8|0,o+8+((1!=(0|t)&1)<<4)|0,r)+0,1!=(0|t)){e=1;do{A+=+ct(o+8+((l=e)<<4)|0,o+8+((0|(e=e+1|0))%(0|t)<<4)|0,r)}while((0|e)<(0|t))}}else A=0;return s[n>>3]=A,M=a,0}function ht(e){e|=0;var t,n,r=0;return(t=0|$t(1,12))||S(27280,27235,49,27293),0|(r=0|i[(n=e+4|0)>>2])?(i[(r=r+8|0)>>2]=t,i[n>>2]=t,0|t):(0|i[e>>2]&&S(27310,27235,61,27333),i[(r=e)>>2]=t,i[n>>2]=t,0|t)}function dt(e,t){var n,r;return e|=0,t|=0,(r=0|Wt(24))||S(27347,27235,78,27361),i[r>>2]=i[t>>2],i[r+4>>2]=i[t+4>>2],i[r+8>>2]=i[t+8>>2],i[r+12>>2]=i[t+12>>2],i[r+16>>2]=0,0|(n=0|i[(t=e+4|0)>>2])?(i[n+16>>2]=r,i[t>>2]=r,0|r):(0|i[e>>2]&&S(27376,27235,82,27361),i[e>>2]=r,i[t>>2]=r,0|r)}function ft(e){var t=0,n=0,r=0,s=0;if(e|=0)for(r=1;;){if(0|(t=0|i[e>>2]))do{if(0|(n=0|i[t>>2]))do{s=n,n=0|i[n+16>>2],Ht(s)}while(0|n);s=t,t=0|i[t+8>>2],Ht(s)}while(0|t);if(t=e,e=0|i[e+8>>2],r||Ht(t),!e)break;r=0}}function pt(e,t,n){e|=0;var r=0,o=0,a=0,A=0,l=0,c=0,u=0,h=0;if(!(0|K(t|=0,n|=0)))return 0;if(t=0|Y(t),r=+s[n>>3],o=t&(o=+s[n+8>>3])<0?o+6.283185307179586:o,!(e=0|i[e>>2]))return 0;if(t){t=0,u=o,n=e;e:for(;;){for(;A=+s[n>>3],o=+s[n+8>>3],h=0|i[(n=n+16|0)>>2],a=+s[(h=0|h?h:e)>>3],l=+s[h+8>>3],A>a?(c=A,A=l):(c=a,a=A,A=o,o=l),(r=r==a|r==c?r+2220446049250313e-31:r)<a|r>c;)if(!(n=0|i[n>>2])){n=22;break e}if(((c=(l=A<0?A+6.283185307179586:A)+(r-a)/(c-a)*((A=o<0?o+6.283185307179586:o)-l))<0?c+6.283185307179586:c)>(u=l==u|A==u?u+-2220446049250313e-31:u)&&(t^=1),!(n=0|i[n>>2])){n=22;break}}if(22==(0|n))return 0|t}else{t=0,u=o,n=e;e:for(;;){for(;A=+s[n>>3],o=+s[n+8>>3],h=0|i[(n=n+16|0)>>2],a=+s[(h=0|h?h:e)>>3],l=+s[h+8>>3],A>a?(c=A,A=l):(c=a,a=A,A=o,o=l),(r=r==a|r==c?r+2220446049250313e-31:r)<a|r>c;)if(!(n=0|i[n>>2])){n=22;break e}if(A+(r-a)/(c-a)*(o-A)>(u=A==u|o==u?u+-2220446049250313e-31:u)&&(t^=1),!(n=0|i[n>>2])){n=22;break}}if(22==(0|n))return 0|t}return 0}function gt(e,t,n,s,o){n|=0,s|=0,o|=0;var a,A,l,c,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0;if(c=M,M=M+32|0,v=c+16|0,l=c,u=0|nn(0|(e|=0),0|(t|=0),52),T(),u&=15,m=0|nn(0|n,0|s,52),T(),(0|u)!=(15&m))return M=c,12;if(p=0|nn(0|e,0|t,45),T(),p&=127,g=0|nn(0|n,0|s,45),T(),p>>>0>121|(g&=127)>>>0>121)return M=c,5;if(m=(0|p)!=(0|g)){if(7==(0|(d=0|X(p,g))))return M=c,1;7==(0|(f=0|X(g,p)))?S(27514,27538,161,27548):(_=d,h=f)}else _=0,h=0;a=0|G(p),A=0|G(g),i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0;do{if(_){if(d=(0|(g=0|i[4272+(28*p|0)+(_<<2)>>2]))>0,A)if(d){p=0,f=n,d=s;do{f=0|$e(f,d),d=0|T(),1==(0|(h=0|ve(h)))&&(h=0|ve(1)),p=p+1|0}while((0|p)!=(0|g));g=h,p=f,f=d}else g=h,p=n,f=s;else if(d){p=0,f=n,d=s;do{f=0|Xe(f,d),d=0|T(),h=0|ve(h),p=p+1|0}while((0|p)!=(0|g));g=h,p=f,f=d}else g=h,p=n,f=s;if(qe(p,f,v),m||S(27563,27538,191,27548),(d=!!(0|a))&(h=!!(0|A))&&S(27590,27538,192,27548),d){if(7==(0|(h=0|Ve(e,t)))){u=5;break}if(0|r[22e3+(7*h|0)+_|0]){u=1;break}p=f=0|i[21168+(28*h|0)+(_<<2)>>2]}else if(h){if(7==(0|(h=0|Ve(p,f)))){u=5;break}if(0|r[22e3+(7*h|0)+g|0]){u=1;break}p=0,f=0|i[21168+(28*g|0)+(h<<2)>>2]}else p=0,f=0;if((p|f|0)<0)u=5;else{if((0|f)>0){d=v+4|0,h=0;do{_e(d),h=h+1|0}while((0|h)!=(0|f))}if(i[l>>2]=0,i[l+4>>2]=0,i[l+8>>2]=0,ge(l,_),0|u)for(;0|Qe(u)?fe(l):pe(l),(0|u)>1;)u=u+-1|0;if((0|p)>0){u=0;do{_e(l),u=u+1|0}while((0|u)!=(0|p))}oe(b=v+4|0,l,b),ie(b),b=51}}else if(qe(n,s,v),!!(0|a)&!!(0|A))if((0|g)!=(0|p)&&S(27621,27538,261,27548),7==(0|(h=0|Ve(e,t)))|7==(0|(u=0|Ve(n,s))))u=5;else if(0|r[22e3+(7*h|0)+u|0])u=1;else if((0|(h=0|i[21168+(28*h|0)+(u<<2)>>2]))>0){d=v+4|0,u=0;do{_e(d),u=u+1|0}while((0|u)!=(0|h));b=51}else b=51;else b=51}while(0);return 51==(0|b)&&(u=v+4|0,i[o>>2]=i[u>>2],i[o+4>>2]=i[u+4>>2],i[o+8>>2]=i[u+8>>2],u=0),M=c,0|u}function mt(e,t,n,r){n|=0,r|=0;var s,o,a,A=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0;if(a=M,M=M+48|0,s=a+36|0,c=a+24|0,u=a+12|0,h=a,A=0|nn(0|(e|=0),0|(t|=0),52),T(),A&=15,f=0|nn(0|e,0|t,45),T(),(f&=127)>>>0>121)return M=a,5;if(o=0|G(f),rn(0|A,0,52),m=134225919|T(),i[(l=r)>>2]=-1,i[l+4>>2]=m,!A)return 7==(0|(A=0|le(n)))||127==(0|(A=0|$(f,A)))?(M=a,0|(m=1)):(p=0|rn(0|A,0,45),g=0|T(),g=-1040385&i[(f=r)+4>>2]|g,i[(m=r)>>2]=i[f>>2]|p,i[m+4>>2]=g,M=a,0|(m=0));for(i[s>>2]=i[n>>2],i[s+4>>2]=i[n+4>>2],i[s+8>>2]=i[n+8>>2],n=A;;){if(l=n,n=n+-1|0,i[c>>2]=i[s>>2],i[c+4>>2]=i[s+4>>2],i[c+8>>2]=i[s+8>>2],0|Qe(l)){if(0|(A=0|ce(s))){n=13;break}i[u>>2]=i[s>>2],i[u+4>>2]=i[s+4>>2],i[u+8>>2]=i[s+8>>2],fe(u)}else{if(0|(A=0|ue(s))){n=13;break}i[u>>2]=i[s>>2],i[u+4>>2]=i[s+4>>2],i[u+8>>2]=i[s+8>>2],pe(u)}if(ae(c,u,h),ie(h),b=0|i[(A=r)>>2],A=0|i[A+4>>2],_=0|rn(7,0,0|(v=3*(15-l|0)|0)),A&=~T(),v=0|rn(0|le(h),0,0|v),A=0|T()|A,i[(m=r)>>2]=v|b&~_,i[m+4>>2]=A,(0|l)<=1){n=14;break}}e:do{if(13!=(0|n)&&14==(0|n))if((0|i[s>>2])<=1&&(0|i[s+4>>2])<=1&&(0|i[s+8>>2])<=1){h=127==(0|(A=0|$(f,n=0|le(s))))?0:0|G(A);t:do{if(n){if(o){if(7==(0|(A=0|Ve(e,t)))){A=5;break e}if((0|(l=0|i[21376+(28*A|0)+(n<<2)>>2]))>0){A=n,n=0;do{A=0|be(A),n=n+1|0}while((0|n)!=(0|l))}else A=n;if(1==(0|A)){A=9;break e}127==(0|(n=0|$(f,A)))&&S(27648,27538,411,27678),0|G(n)?S(27693,27538,412,27678):(g=n,p=l,d=A)}else g=A,p=0,d=n;if((0|(u=0|i[4272+(28*f|0)+(d<<2)>>2]))<=-1&&S(27724,27538,419,27678),!h){if((0|p)<0){A=5;break e}if(0|p){A=0,n=0|i[(l=r)>>2],l=0|i[l+4>>2];do{n=0|He(n,l),l=0|T(),i[(v=r)>>2]=n,i[v+4>>2]=l,A=A+1|0}while((0|A)<(0|p))}if((0|u)<=0){A=g,n=58;break}for(A=0,n=0|i[(l=r)>>2],l=0|i[l+4>>2];;)if(n=0|He(n,l),l=0|T(),i[(v=r)>>2]=n,i[v+4>>2]=l,(0|(A=A+1|0))==(0|u)){A=g,n=58;break t}}if(7==(0|(c=0|X(g,f)))&&S(27514,27538,428,27678),n=0|i[(A=r)>>2],A=0|i[A+4>>2],(0|u)>0){l=0;do{n=0|He(n,A),A=0|T(),i[(v=r)>>2]=n,i[v+4>>2]=A,l=l+1|0}while((0|l)!=(0|u))}if(7==(0|(A=0|Ve(n,A)))&&S(27795,27538,440,27678),n=0|z(g),(0|(n=0|i[(n?21792:21584)+(28*c|0)+(A<<2)>>2]))<0&&S(27795,27538,454,27678),n){A=0,l=0|i[(c=r)>>2],c=0|i[c+4>>2];do{l=0|We(l,c),c=0|T(),i[(v=r)>>2]=l,i[v+4>>2]=c,A=A+1|0}while((0|A)<(0|n));A=g,n=58}else A=g,n=58}else if(!!(0|o)&!!(0|h)){if(7==(0|(n=0|Ve(e,t)))|7==(0|(l=0|Ve(0|i[(l=r)>>2],0|i[l+4>>2])))){A=5;break e}if((0|(l=0|i[21376+(28*n|0)+(l<<2)>>2]))<0){A=5;break e}if(l){n=0,c=0|i[(u=r)>>2],u=0|i[u+4>>2];do{c=0|He(c,u),u=0|T(),i[(v=r)>>2]=c,i[v+4>>2]=u,n=n+1|0}while((0|n)<(0|l));n=58}else n=59}else n=58}while(0);if(58==(0|n)&&h&&(n=59),59==(0|n)&&1==(0|Ve(0|i[(v=r)>>2],0|i[v+4>>2]))){A=9;break}_=0|i[(v=r)>>2],v=-1040385&i[v+4>>2],b=0|rn(0|A,0,45),v=0|v|T(),i[(A=r)>>2]=_|b,i[A+4>>2]=v,A=0}else A=1}while(0);return M=a,0|A}function _t(e,t,n,r){e|=0,t|=0;var i=0,s=0,o=0;if(!(0|(n|=0))&!(0|(r|=0)))return s=1,E(0|(i=0)),0|s;s=e,i=t,e=1,t=0;do{e=0|Zt(0|((o=!0&!(1&n))?1:s),0|(o?0:i),0|e,0|t),t=0|T(),n=0|tn(0|n,0|r,1),r=0|T(),s=0|Zt(0|s,0|i,0|s,0|i),i=0|T()}while(!(!(0|n)&!(0|r)));return E(0|t),0|e}function bt(e,t,n,r){n|=0,r|=0;var o,a=0,A=0,l=0,c=0,u=0,d=0;o=M,M=M+16|0,A=o,l=0|nn(0|(e|=0),0|(t|=0),52),T(),l&=15;do{if(l){if(!(a=0|Ze(e,t,A))){u=+s[A>>3],c=1/+h(+u),d=+s[25968+(l<<3)>>3],s[n>>3]=u+d,s[n+8>>3]=u-d,u=+s[A+8>>3],c*=d,s[n+16>>3]=c+u,s[n+24>>3]=u-c;break}return M=o,0|a}if(a=0|nn(0|e,0|t,45),T(),(a&=127)>>>0>121)return M=o,5;A=22064+(a<<5)|0,i[n>>2]=i[A>>2],i[n+4>>2]=i[A+4>>2],i[n+8>>2]=i[A+8>>2],i[n+12>>2]=i[A+12>>2],i[n+16>>2]=i[A+16>>2],i[n+20>>2]=i[A+20>>2],i[n+24>>2]=i[A+24>>2],i[n+28>>2]=i[A+28>>2];break}while(0);return function(e,t){t=+t;var n,r,i,o,a,A,l,c=0,u=0;c=(o=+s[(i=16+(e|=0)|0)>>3])-(r=+s[(n=e+24|0)>>3]),c=o<r?c+6.283185307179586:c,u=+s[e>>3],c=.5*(c*t-c),u+=t=.5*((l=u-(A=+s[(a=e+8|0)>>3]))*t-l),s[e>>3]=u>1.5707963267948966?1.5707963267948966:u,t=A-t,s[a>>3]=t<-1.5707963267948966?-1.5707963267948966:t,t=(t=o+c)>3.141592653589793?t+-6.283185307179586:t,s[i>>3]=t<-3.141592653589793?t+6.283185307179586:t,t=(t=r-c)>3.141592653589793?t+-6.283185307179586:t,s[n>>3]=t<-3.141592653589793?t+6.283185307179586:t}(n,r?1.4:1.1),(0|i[(r=26096+(l<<3)|0)>>2])==(0|e)&&(0|i[r+4>>2])==(0|t)&&(s[n>>3]=1.5707963267948966),(0|i[(l=26224+(l<<3)|0)>>2])==(0|e)&&(0|i[l+4>>2])==(0|t)&&(s[n+8>>3]=-1.5707963267948966),1.5707963267948966!=+s[n>>3]&&-1.5707963267948966!=+s[n+8>>3]?(M=o,0|(l=0)):(s[n+16>>3]=3.141592653589793,s[n+24>>3]=-3.141592653589793,M=o,0|(l=0))}function vt(e){var t,n,s,o,a=0,A=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0,y=0,w=0;if(o=M,M=M+336|0,t=o+168|0,n=o,!(0|(A=0|i[(l=e|=0)>>2]))&!(0|(l=0|i[l+4>>2])))M=o;else{if(0|r[0|(a=e+28|0)]?(A=0|yt(A,l),l=0|T()):r[0|a]=1,!(0|i[i[(s=e+20|0)>>2]>>2]))return 0|(A=0|i[(a=e+24|0)>>2])&&Ht(A),i[(w=e)>>2]=0,i[w+4>>2]=0,i[e+8>>2]=0,i[s>>2]=0,i[e+12>>2]=-1,i[e+16>>2]=0,i[a>>2]=0,void(M=o);c=15&(a=0|i[(w=e+16|0)>>2]);e:do{if(!(0|A)&!(0|l))y=e+24|0;else{b=e+12|0,m=3==(0|c),g=255&a,f=3==(1|c),_=e+24|0,p=(c+-1|0)>>>0<3,h=3==(2|c),d=n+8|0;t:for(;;){if(u=0|nn(0|A,0|l,52),T(),(0|(u&=15))==(0|i[b>>2])){switch(15&g){case 0:case 2:case 3:if(0|(c=0|Ze(A,l,t))){v=15;break t}if(0|St(0|i[s>>2],0|i[_>>2],t)){v=19;break t}}if(f&&(c=0|i[4+(0|i[s>>2])>>2],i[t>>2]=i[c>>2],i[t+4>>2]=i[c+4>>2],i[t+8>>2]=i[c+8>>2],i[t+12>>2]=i[c+12>>2],0|K(26832,t))){if(0|Ye(0|i[4+(0|i[s>>2])>>2],u,n)){v=25;break}if((0|i[(c=n)>>2])==(0|A)&&(0|i[c+4>>2])==(0|l)){v=29;break}}if(p){if(0|(c=0|Je(A,l,t))){v=32;break}if(0|bt(A,l,n,0)){v=36;break}if(h&&0|Ct(0|i[s>>2],0|i[_>>2],t,n)){v=42;break}if(f&&0|Rt(0|i[s>>2],0|i[_>>2],t,n)){v=42;break}}if(m){if(a=0|bt(A,l,t,1),c=0|i[_>>2],0|a){v=45;break}if(0|Z(c,t)){if(ee(n,t),0|J(t,0|i[_>>2])){v=53;break}if(0|St(0|i[s>>2],0|i[_>>2],d)){v=53;break}if(0|Rt(0|i[s>>2],0|i[_>>2],n,t)){v=53;break}}}}do{if((0|u)<(0|i[b>>2])){if(a=0|bt(A,l,t,1),c=0|i[_>>2],0|a){v=58;break t}if(!(0|Z(c,t))){v=73;break}if(0|J(0|i[_>>2],t)&&(ee(n,t),0|Ct(0|i[s>>2],0|i[_>>2],n,t))){v=65;break t}if(0|(A=0|ze(A,l,u+1|0,n))){v=67;break t}A=0|i[(l=n)>>2],l=0|i[l+4>>2]}else v=73}while(0);if(73==(0|v)&&(v=0,A=0|yt(A,l),l=0|T()),!(0|A)&!(0|l)){y=_;break e}}switch(0|v){case 15:0|(a=0|i[_>>2])&&Ht(a),i[(v=e)>>2]=0,i[v+4>>2]=0,i[s>>2]=0,i[b>>2]=-1,i[w>>2]=0,i[_>>2]=0,i[e+8>>2]=c,v=20;break;case 19:i[e>>2]=A,i[e+4>>2]=l,v=20;break;case 25:S(27795,27761,470,27772);break;case 29:case 42:return i[e>>2]=A,i[e+4>>2]=l,void(M=o);case 32:return 0|(a=0|i[_>>2])&&Ht(a),i[(y=e)>>2]=0,i[y+4>>2]=0,i[s>>2]=0,i[b>>2]=-1,i[w>>2]=0,i[_>>2]=0,i[e+8>>2]=c,void(M=o);case 36:S(27795,27761,493,27772);break;case 45:0|c&&Ht(c),i[(v=e)>>2]=0,i[v+4>>2]=0,i[s>>2]=0,i[b>>2]=-1,i[w>>2]=0,i[_>>2]=0,i[e+8>>2]=a,v=55;break;case 53:i[e>>2]=A,i[e+4>>2]=l,v=55;break;case 58:0|c&&Ht(c),i[(v=e)>>2]=0,i[v+4>>2]=0,i[s>>2]=0,i[b>>2]=-1,i[w>>2]=0,i[_>>2]=0,i[e+8>>2]=a,v=71;break;case 65:i[e>>2]=A,i[e+4>>2]=l,v=71;break;case 67:return 0|(a=0|i[_>>2])&&Ht(a),i[(y=e)>>2]=0,i[y+4>>2]=0,i[s>>2]=0,i[b>>2]=-1,i[w>>2]=0,i[_>>2]=0,i[e+8>>2]=A,void(M=o)}if(20==(0|v))return void(M=o);if(55==(0|v))return void(M=o);if(71==(0|v))return void(M=o)}}while(0);0|(a=0|i[y>>2])&&Ht(a),i[(v=e)>>2]=0,i[v+4>>2]=0,i[e+8>>2]=0,i[s>>2]=0,i[e+12>>2]=-1,i[w>>2]=0,i[y>>2]=0,M=o}}function yt(e,t){var n,r=0,s=0,o=0,a=0,A=0,l=0,c=0,u=0,h=0;n=M,M=M+16|0,h=n,s=0|nn(0|(e|=0),0|(t|=0),52),T(),s&=15,r=0|nn(0|e,0|t,45),T();do{if(s){for(;r=0|rn(s+4095|0,0,52),o=T()|-15728641&t,r=r|e|(A=0|rn(7,0,0|(a=3*(15-s|0)|0))),o|=l=0|T(),c=0|nn(0|e,0|t,0|a),T(),s=s+-1|0,!((c&=7)>>>0<6);){if(!s){u=4;break}t=o,e=r}if(4==(0|u)){r=0|nn(0|r,0|o,45),T();break}return h=0|rn(((h=!(0|c)&!!(0|je(r,o)))?2:1)+c|0,0,0|a),u=0|T()|t&~l,h|=e&~A,E(0|u),M=n,0|h}}while(0);return(r&=127)>>>0>120?(h=0,E(0|(u=0)),M=n,0|h):(Oe(h,0,r+1|0,0),u=0|i[h+4>>2],h=0|i[h>>2],E(0|u),M=n,0|h)}function wt(e,t,n){e|=0;var r,o=0,a=0,A=0,l=0,c=0,u=0,h=0,d=0,f=0;if(!(0|K(t|=0,n|=0)))return 0;if(t=0|Y(t),o=+s[n>>3],a=t&(a=+s[n+8>>3])<0?a+6.283185307179586:a,(0|(f=0|i[e>>2]))<=0)return 0;if(r=0|i[e+4>>2],t){t=0,d=a,n=-1,e=0;e:for(;;){for(h=e;l=+s[r+(h<<4)>>3],a=+s[r+(h<<4)+8>>3],A=+s[r+((e=(n+2|0)%(0|f)|0)<<4)>>3],c=+s[r+(e<<4)+8>>3],l>A?(u=l,l=c):(u=A,A=l,l=a,a=c),(o=o==A|o==u?o+2220446049250313e-31:o)<A|o>u;){if((0|(n=h+1|0))>=(0|f)){n=22;break e}e=h,h=n,n=e}if(((u=(c=l<0?l+6.283185307179586:l)+(o-A)/(u-A)*((l=a<0?a+6.283185307179586:a)-c))<0?u+6.283185307179586:u)>(d=c==d|l==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=h+1|0))>=(0|f)){n=22;break}n=h}if(22==(0|n))return 0|t}else{t=0,d=a,n=-1,e=0;e:for(;;){for(h=e;l=+s[r+(h<<4)>>3],a=+s[r+(h<<4)+8>>3],A=+s[r+((e=(n+2|0)%(0|f)|0)<<4)>>3],c=+s[r+(e<<4)+8>>3],l>A?(u=l,l=c):(u=A,A=l,l=a,a=c),(o=o==A|o==u?o+2220446049250313e-31:o)<A|o>u;){if((0|(n=h+1|0))>=(0|f)){n=22;break e}e=h,h=n,n=e}if(l+(o-A)/(u-A)*(a-l)>(d=l==d|a==d?d+-2220446049250313e-31:d)&&(t^=1),(0|(e=h+1|0))>=(0|f)){n=22;break}n=h}if(22==(0|n))return 0|t}return 0}function xt(e,t){t|=0;var n,r,o,a,A,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0,y=0;if(!(r=0|i[(e|=0)>>2]))return i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,void(i[t+28>>2]=0);if(s[(o=t+8|0)>>3]=17976931348623157e292,s[(a=t+24|0)>>3]=17976931348623157e292,s[t>>3]=-17976931348623157e292,s[(A=t+16|0)>>3]=-17976931348623157e292,!((0|r)<=0)){for(n=0|i[e+4>>2],m=17976931348623157e292,_=-17976931348623157e292,b=0,e=-1,d=17976931348623157e292,f=17976931348623157e292,g=-17976931348623157e292,u=-17976931348623157e292,v=0;c=+s[n+(v<<4)>>3],p=+s[n+(v<<4)+8>>3],h=+s[n+(((0|(e=e+2|0))==(0|r)?0:e)<<4)+8>>3],c<d&&(s[o>>3]=c,d=c),p<f&&(s[a>>3]=p,f=p),c>g?s[t>>3]=c:c=g,p>u&&(s[A>>3]=p,u=p),m=p>0&p<m?p:m,_=p<0&p>_?p:_,b|=+l(+(p-h))>3.141592653589793,(0|(e=v+1|0))!=(0|r);)y=v,g=c,v=e,e=y;b&&(s[A>>3]=_,s[a>>3]=m)}}function Et(e){return 0|((e|=0)>>>0<4?0:15)}function Tt(e,t){t|=0;var n,r=0,o=0,a=0,A=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0,y=0,w=0,x=0,E=0,T=0,S=0;if(_=0|i[(e|=0)>>2]){if(s[(b=t+8|0)>>3]=17976931348623157e292,s[(v=t+24|0)>>3]=17976931348623157e292,s[t>>3]=-17976931348623157e292,s[(y=t+16|0)>>3]=-17976931348623157e292,(0|_)>0){for(a=0|i[e+4>>2],g=17976931348623157e292,m=-17976931348623157e292,o=0,r=-1,h=17976931348623157e292,d=17976931348623157e292,p=-17976931348623157e292,c=-17976931348623157e292,w=0;A=+s[a+(w<<4)>>3],f=+s[a+(w<<4)+8>>3],u=+s[a+(((0|(T=r+2|0))==(0|_)?0:T)<<4)+8>>3],A<h&&(s[b>>3]=A,h=A),f<d&&(s[v>>3]=f,d=f),A>p?s[t>>3]=A:A=p,f>c&&(s[y>>3]=f,c=f),g=f>0&f<g?f:g,m=f<0&f>m?f:m,o|=+l(+(f-u))>3.141592653589793,(0|(r=w+1|0))!=(0|_);)T=w,p=A,w=r,r=T;o&&(s[y>>3]=m,s[v>>3]=g)}}else i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,i[t+28>>2]=0;if(!((0|(r=0|i[(T=e+8|0)>>2]))<=0)){n=e+12|0,E=0;do{if(a=0|i[n>>2],o=E,v=t+((E=E+1|0)<<5)|0,y=0|i[a+(o<<3)>>2]){if(s[(w=t+(E<<5)+8|0)>>3]=17976931348623157e292,s[(e=t+(E<<5)+24|0)>>3]=17976931348623157e292,s[v>>3]=-17976931348623157e292,s[(x=t+(E<<5)+16|0)>>3]=-17976931348623157e292,(0|y)>0){for(_=0|i[a+(o<<3)+4>>2],g=17976931348623157e292,m=-17976931348623157e292,a=0,o=-1,b=0,h=17976931348623157e292,d=17976931348623157e292,f=-17976931348623157e292,c=-17976931348623157e292;A=+s[_+(b<<4)>>3],p=+s[_+(b<<4)+8>>3],u=+s[_+(((0|(o=o+2|0))==(0|y)?0:o)<<4)+8>>3],A<h&&(s[w>>3]=A,h=A),p<d&&(s[e>>3]=p,d=p),A>f?s[v>>3]=A:A=f,p>c&&(s[x>>3]=p,c=p),g=p>0&p<g?p:g,m=p<0&p>m?p:m,a|=+l(+(p-u))>3.141592653589793,(0|(o=b+1|0))!=(0|y);)S=b,b=o,f=A,o=S;a&&(s[x>>3]=m,s[e>>3]=g)}}else i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0,i[v+16>>2]=0,i[v+20>>2]=0,i[v+24>>2]=0,i[v+28>>2]=0,r=0|i[T>>2]}while((0|E)<(0|r))}}function St(e,t,n){var r=0,s=0,o=0;if(!(0|wt(e|=0,t|=0,n|=0)))return 0;if((0|i[(s=e+8|0)>>2])<=0)return 1;for(r=e+12|0,e=0;;){if(o=e,e=e+1|0,0|wt((0|i[r>>2])+(o<<3)|0,t+(e<<5)|0,n)){e=0,r=6;break}if((0|e)>=(0|i[s>>2])){e=1,r=6;break}}return 6==(0|r)?0|e:0}function Ct(e,t,n,r){r|=0;var s,o,a=0,A=0,l=0,c=0,u=0;if(o=M,M=M+16|0,s=o,!(0|wt(e|=0,t|=0,l=8+(n|=0)|0)))return M=o,0;c=e+8|0;e:do{if((0|i[c>>2])>0){for(A=e+12|0,a=0;;){if(u=a,a=a+1|0,0|wt((0|i[A>>2])+(u<<3)|0,t+(a<<5)|0,l)){a=0;break}if((0|a)>=(0|i[c>>2]))break e}return M=o,0|a}}while(0);if(0|kt(e,t,n,r))return M=o,0;i[s>>2]=i[n>>2],i[s+4>>2]=l,a=0|i[c>>2];e:do{if((0|a)>0)for(e=e+12|0,l=0,A=a;;){if(a=0|i[e>>2],(0|i[a+(l<<3)>>2])>0){if(0|wt(s,r,0|i[a+(l<<3)+4>>2])){a=0;break e}if(a=l+1|0,0|kt((0|i[e>>2])+(l<<3)|0,t+(a<<5)|0,n,r)){a=0;break e}A=0|i[c>>2]}else a=l+1|0;if(!((0|a)<(0|A))){a=1;break}l=a}else a=1}while(0);return M=o,0|a}function kt(e,t,n,r){e|=0,n|=0;var o,a,A,l,c,u,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0,y=0,w=0,x=0,E=0,T=0,S=0;if(u=M,M=M+176|0,l=u+172|0,h=u+168|0,c=u,!(0|Z(t|=0,r|=0)))return M=u,0;if(function(e,t,n,r){var o,a,A,l,c;t|=0,n|=0,r|=0,e=(a=+s[16+(e|=0)>>3])<(c=+s[e+24>>3]),o=(l=+s[t+16>>3])<(A=+s[t+24>>3]),t=c-l<A-a,i[n>>2]=e?o|t?1:2:0,i[r>>2]=o?e?1:t?2:1:0}(t,r,l,h),ln(0|c,0|n,168),(0|i[n>>2])>0){t=0;do{w=+ot(+s[(T=c+8+(t<<4)+8|0)>>3],0|i[h>>2]),s[T>>3]=w,t=t+1|0}while((0|t)<(0|i[n>>2]))}a=+s[r>>3],A=+s[r+8>>3],w=+ot(+s[r+16>>3],0|i[h>>2]),o=+ot(+s[r+24>>3],0|i[h>>2]);e:do{if((0|i[e>>2])>0){if(r=e+4|0,(0|(h=0|i[c>>2]))<=0)for(t=0;;)if((0|(t=t+1|0))>=(0|i[e>>2])){t=0;break e}for(n=0;;){if(t=0|i[r>>2],v=+s[t+(n<<4)>>3],y=+ot(+s[t+(n<<4)+8>>3],0|i[l>>2]),t=0|i[r>>2],T=(0|(n=n+1|0))%(0|i[e>>2])|0,d=+s[t+(T<<4)>>3],f=+ot(+s[t+(T<<4)+8>>3],0|i[l>>2]),!(v>=a)|!(d>=a)&&!(v<=A)|!(d<=A)&&!(y<=o)|!(f<=o)&&!(y>=w)|!(f>=w)){b=d-v,m=f-y,t=0;do{if(S=t,T=(0|(t=t+1|0))==(0|h)?0:t,d=+s[c+8+(S<<4)+8>>3],f=+s[c+8+(T<<4)+8>>3]-d,p=+s[c+8+(S<<4)>>3],!(0==(_=b*f-m*(g=+s[c+8+(T<<4)>>3]-p))||(x=y-d,E=v-p,g=(x*g-f*E)/_,g<0|g>1))&&(_=(b*x-m*E)/_)>=0&_<=1){t=1;break e}}while((0|t)<(0|h))}if((0|n)>=(0|i[e>>2])){t=0;break}}}else t=0}while(0);return M=u,0|t}function Rt(e,t,n,r){var s=0,o=0,a=0;if(0|kt(e|=0,t|=0,n|=0,r|=0))return 1;if((0|i[(o=e+8|0)>>2])<=0)return 0;for(s=e+12|0,e=0;;){if(a=e,e=e+1|0,0|kt((0|i[s>>2])+(a<<3)|0,t+(e<<5)|0,n,r)){e=1,s=6;break}if((0|e)>=(0|i[o>>2])){e=0,s=6;break}}return 6==(0|s)?0|e:0}function Pt(e,t,n,r,i){t|=0,n|=0,r|=0,i|=0;var o,a,A,l,c,u,h,d=0;l=+s[(e|=0)>>3],A=+s[t>>3]-l,a=+s[e+8>>3],o=+s[t+8>>3]-a,u=+s[n>>3],d=((d=+s[r>>3]-u)*(a-(h=+s[n+8>>3]))-(l-u)*(c=+s[r+8>>3]-h))/(A*c-o*d),s[i>>3]=l+A*d,s[i+8>>3]=a+o*d}function It(e,t){return t|=0,+l(+(+s[(e|=0)>>3]-+s[t>>3]))<1.1920928955078125e-7?0|(t=+l(+(+s[e+8>>3]-+s[t+8>>3]))<1.1920928955078125e-7):0|(t=0)}function Mt(e,t){var n,r,i;return t|=0,+((i=+s[(e|=0)>>3]-+s[t>>3])*i+(r=+s[e+8>>3]-+s[t+8>>3])*r+(n=+s[e+16>>3]-+s[t+16>>3])*n)}function Lt(e,t,n){n|=0;var r,s,o,a,A=0,l=0,c=0,u=0;if(a=M,M=M+32|0,u=a,0|(A=0|Ke(e|=0,t|=0,s=a+16|0)))return M=a,0|A;r=0|Be(e,t),o=0|Ve(e,t),function(e,t){e=7696+(28*(e|=0)|0)|0,i[(t|=0)>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2]}(r,u),A=0|function(e,t){e|=0;var n=0,r=0;if((t|=0)>>>0>20)return-1;do{if((0|i[11120+(216*t|0)>>2])!=(0|e))if((0|i[11120+(216*t|0)+8>>2])!=(0|e))if((0|i[11120+(216*t|0)+16>>2])!=(0|e))if((0|i[11120+(216*t|0)+24>>2])!=(0|e))if((0|i[11120+(216*t|0)+32>>2])!=(0|e))if((0|i[11120+(216*t|0)+40>>2])!=(0|e))if((0|i[11120+(216*t|0)+48>>2])!=(0|e))if((0|i[11120+(216*t|0)+56>>2])!=(0|e))if((0|i[11120+(216*t|0)+64>>2])!=(0|e))if((0|i[11120+(216*t|0)+72>>2])!=(0|e))if((0|i[11120+(216*t|0)+80>>2])!=(0|e))if((0|i[11120+(216*t|0)+88>>2])!=(0|e))if((0|i[11120+(216*t|0)+96>>2])!=(0|e))if((0|i[11120+(216*t|0)+104>>2])!=(0|e))if((0|i[11120+(216*t|0)+112>>2])!=(0|e))if((0|i[11120+(216*t|0)+120>>2])!=(0|e))if((0|i[11120+(216*t|0)+128>>2])!=(0|e)){if((0|i[11120+(216*t|0)+136>>2])!=(0|e)){if((0|i[11120+(216*t|0)+144>>2])==(0|e)){e=0,n=2,r=0;break}if((0|i[11120+(216*t|0)+152>>2])==(0|e)){e=0,n=2,r=1;break}if((0|i[11120+(216*t|0)+160>>2])==(0|e)){e=0,n=2,r=2;break}if((0|i[11120+(216*t|0)+168>>2])==(0|e)){e=1,n=2,r=0;break}if((0|i[11120+(216*t|0)+176>>2])==(0|e)){e=1,n=2,r=1;break}if((0|i[11120+(216*t|0)+184>>2])==(0|e)){e=1,n=2,r=2;break}if((0|i[11120+(216*t|0)+192>>2])==(0|e)){e=2,n=2,r=0;break}if((0|i[11120+(216*t|0)+200>>2])==(0|e)){e=2,n=2,r=1;break}if((0|i[11120+(216*t|0)+208>>2])==(0|e)){e=2,n=2,r=2;break}return-1}e=2,n=1,r=2}else e=2,n=1,r=1;else e=2,n=1,r=0;else e=1,n=1,r=2;else e=1,n=1,r=1;else e=1,n=1,r=0;else e=0,n=1,r=2;else e=0,n=1,r=1;else e=0,n=1,r=0;else e=2,n=0,r=2;else e=2,n=0,r=1;else e=2,n=0,r=0;else e=1,n=0,r=2;else e=1,n=0,r=1;else e=1,n=0,r=0;else e=0,n=0,r=2;else e=0,n=0,r=1;else e=0,n=0,r=0}while(0);return 0|i[11120+(216*t|0)+(72*n|0)+(24*e|0)+(r<<3)+4>>2]}(r,0|i[s>>2]);do{if(0|G(r)){switch(0|r){case 4:l=0;break;case 14:l=1;break;case 24:l=2;break;case 38:l=3;break;case 49:l=4;break;case 58:l=5;break;case 63:l=6;break;case 72:l=7;break;case 83:l=8;break;case 97:l=9;break;case 107:l=10;break;case 117:l=11;break;default:S(27795,27797,75,27806)}if(c=0|i[26416+(24*l|0)+8>>2],t=0|i[26416+(24*l|0)+16>>2],(0|(e=0|i[s>>2]))!=(0|i[u>>2])&&(u=0|z(r))|(0|(e=0|i[s>>2]))==(0|t)&&(A=(A+1|0)%6|0),3==(0|o)&(0|e)==(0|t)){A=(A+5|0)%6|0;break}5==(0|o)&(0|e)==(0|c)&&(A=(A+1|0)%6|0)}}while(0);return i[n>>2]=A,M=a,0}function Nt(e,t,n,r){n|=0,r|=0;var s,o,a,A,l,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0;if(l=M,M=M+32|0,v=l+24|0,A=l+20|0,a=l+8|0,o=l+16|0,s=l,f=(f=!(0|je(e|=0,t|=0)))?6:5,g=0|nn(0|e,0|t,52),T(),f>>>0<=n>>>0)return M=l,2;!(m=!(0|(g&=15)))&&!((_=0|rn(7,0,3*(15^g)|0))&e)&!((0|T())&t)?c=n:u=4;e:do{if(4==(0|u)){if((0|((c=!!(0|je(e,t)))?4:5))<(0|n))return M=l,1;if(0|Lt(e,t,v))return M=l,1;if(u=(0|i[v>>2])+n|0,7==(0|(_=0|i[(c=c?26704+((0|u)%5<<2)|0:26736+((0|u)%6<<2)|0)>>2])))return M=l,1;i[A>>2]=0,c=0|O(e,t,_,A,a);do{if(!c){if(p=0|i[(d=a)>>2],u=(h=(d=0|i[d+4>>2])>>>0<t>>>0|(0|d)==(0|t)&p>>>0<e>>>0)?p:e,h=h?d:t,!m&&!(p&(m=0|rn(7,0,3*(15^g)|0)))&!(d&(0|T())))c=n;else{if(d=(n+-1+f|0)%(0|f)|0,c=0|je(e,t),(0|d)<0&&S(27795,27797,248,27822),(0|((f=!!(0|c))?4:5))<(0|d)&&S(27795,27797,248,27822),0|Lt(e,t,v)&&S(27795,27797,248,27822),c=(0|i[v>>2])+d|0,7==(0|(d=0|i[(c=f?26704+((0|c)%5<<2)|0:26736+((0|c)%6<<2)|0)>>2]))&&S(27795,27797,248,27822),i[o>>2]=0,0|(c=0|O(e,t,d,o,s)))break;f=0|i[(p=s)>>2],p=0|i[p+4>>2];do{if(p>>>0<h>>>0|(0|p)==(0|h)&f>>>0<u>>>0){if(u=0|je(f,p)?0|U(f,p,e,t):0|i[26800+(((0|i[o>>2])+(0|i[26768+(d<<2)>>2])|0)%6<<2)>>2],c=0|je(f,p),(u+-1|0)>>>0>5){c=-1,u=f,h=p;break}if(1==(0|u)&(c=!!(0|c))){c=-1,u=f,h=p;break}do{if(!(0|Lt(f,p,v))){if(c){c=(5+(0|i[26352+(u<<2)>>2])-(0|i[v>>2])|0)%5|0;break}c=(6+(0|i[26384+(u<<2)>>2])-(0|i[v>>2])|0)%6|0;break}c=-1}while(0);u=f,h=p}else c=n}while(0);p=0|i[(d=a)>>2],d=0|i[d+4>>2]}if((0|u)==(0|p)&(0|h)==(0|d)){if(e=(f=!!(0|je(p,d)))?0|U(p,d,e,t):0|i[26800+(((0|i[A>>2])+(0|i[26768+(_<<2)>>2])|0)%6<<2)>>2],c=0|je(p,d),(e+-1|0)>>>0<=5&&!(1==(0|e)&(b=!!(0|c))))do{if(!(0|Lt(p,d,v))){if(b){c=(5+(0|i[26352+(e<<2)>>2])-(0|i[v>>2])|0)%5|0;break}c=(6+(0|i[26384+(e<<2)>>2])-(0|i[v>>2])|0)%6|0;break}c=-1}while(0);else c=-1;c=6==(0|(c=c+1|0))|f&5==(0|c)?0:c}t=h,e=u;break e}}while(0);return M=l,0|c}}while(0);return b=0|rn(0|c,0,56),v=T()|-2130706433&t|536870912,i[r>>2]=b|e,i[r+4>>2]=v,M=l,0}function Bt(e,t){e|=0;var n,r,s=0,o=0;return r=M,M=M+16|0,n=r,!0&536870912==(2013265920&(t|=0))&&0|De(e,s=-2130706433&t|134217728)?(o=0|nn(0|e,0|t,56),T(),s=(o=!(0|Nt(e,s,7&o,n)))&((0|i[(s=n)>>2])==(0|e)?(0|i[s+4>>2])==(0|t):0)&1,M=r,0|s):(M=r,0|(s=0))}function Dt(e,t,n){e|=0,n|=0;var r=0;(0|(t|=0))>0?(r=0|$t(t,4),i[e>>2]=r,r||S(27835,27858,40,27872)):i[e>>2]=0,i[e+4>>2]=t,i[e+8>>2]=0,i[e+12>>2]=n}function Ot(e){var t,n,r,o=0,a=0,A=0,c=0;t=4+(e|=0)|0,n=e+12|0,r=e+8|0;e:for(;;){for(a=0|i[t>>2],o=0;;){if((0|o)>=(0|a))break e;if(A=0|i[e>>2],c=0|i[A+(o<<2)>>2])break;o=o+1|0}o=A+(~~(+l(+ +u(10,+ +(15-(0|i[n>>2])|0))*(+s[c>>3]+ +s[c+8>>3]))%+(0|a))>>>0<<2)|0,a=0|i[o>>2];t:do{if(0|a){if(A=c+32|0,(0|a)==(0|c))i[o>>2]=i[A>>2];else{if(!(o=0|i[(a=a+32|0)>>2]))break;for(;(0|o)!=(0|c);)if(!(o=0|i[(a=o+32|0)>>2]))break t;i[a>>2]=i[A>>2]}Ht(c),i[r>>2]=(0|i[r>>2])-1}}while(0)}Ht(0|i[e>>2])}function Ft(e){var t,n=0,r=0;for(t=0|i[4+(e|=0)>>2],r=0;;){if((0|r)>=(0|t)){n=0,r=4;break}if(n=0|i[(0|i[e>>2])+(r<<2)>>2]){r=4;break}r=r+1|0}return 4==(0|r)?0|n:0}function Ut(e,t){t|=0;var n=0,r=0,o=0,a=0;if(n=~~(+l(+ +u(10,+ +(15-(0|i[12+(e|=0)>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|i[e+4>>2]))>>>0,n=(0|i[e>>2])+(n<<2)|0,!(r=0|i[n>>2]))return 1;a=t+32|0;do{if((0|r)!=(0|t)){if(!(n=0|i[r+32>>2]))return 1;for(o=n;;){if((0|o)==(0|t)){o=8;break}if(!(n=0|i[o+32>>2])){n=1,o=10;break}r=o,o=n}if(8==(0|o)){i[r+32>>2]=i[a>>2];break}if(10==(0|o))return 0|n}else i[n>>2]=i[a>>2]}while(0);return Ht(t),i[(a=e+8|0)>>2]=(0|i[a>>2])-1,0}function jt(e,t,n){e|=0,t|=0,n|=0;var r,o=0,a=0,A=0;(r=0|Wt(40))||S(27888,27858,98,27901),i[r>>2]=i[t>>2],i[r+4>>2]=i[t+4>>2],i[r+8>>2]=i[t+8>>2],i[r+12>>2]=i[t+12>>2],i[(a=r+16|0)>>2]=i[n>>2],i[a+4>>2]=i[n+4>>2],i[a+8>>2]=i[n+8>>2],i[a+12>>2]=i[n+12>>2],i[r+32>>2]=0,a=~~(+l(+ +u(10,+ +(15-(0|i[e+12>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|i[e+4>>2]))>>>0,a=(0|i[e>>2])+(a<<2)|0,o=0|i[a>>2];do{if(o){for(;!(0|st(o,t)&&0|st(o+16|0,n));)if(a=0|i[o+32>>2],!(0|i[(o=0|a?a:o)+32>>2])){A=10;break}if(10==(0|A)){i[o+32>>2]=r;break}return Ht(r),0|o}i[a>>2]=r}while(0);return i[(A=e+8|0)>>2]=1+(0|i[A>>2]),0|r}function Gt(e,t,n){t|=0,n|=0;var r=0,o=0;if(o=~~(+l(+ +u(10,+ +(15-(0|i[12+(e|=0)>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|i[e+4>>2]))>>>0,!(o=0|i[(0|i[e>>2])+(o<<2)>>2]))return 0;if(!n){for(e=o;;){if(0|st(e,t)){r=10;break}if(!(e=0|i[e+32>>2])){e=0,r=10;break}}if(10==(0|r))return 0|e}for(e=o;;){if(0|st(e,t)&&0|st(e+16|0,n)){r=10;break}if(!(e=0|i[e+32>>2])){e=0,r=10;break}}return 10==(0|r)?0|e:0}function zt(e,t){t|=0;var n=0;if(n=~~(+l(+ +u(10,+ +(15-(0|i[12+(e|=0)>>2])|0))*(+s[t>>3]+ +s[t+8>>3]))%+(0|i[e+4>>2]))>>>0,!(e=0|i[(0|i[e>>2])+(n<<2)>>2]))return 0;for(;;){if(0|st(e,t)){t=5;break}if(!(e=0|i[e+32>>2])){e=0,t=5;break}}return 5==(0|t)?0|e:0}function Vt(e){return 0|+un(+(e=+e))}function Wt(e){e|=0;var t,n=0,r=0,s=0,o=0,a=0,A=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0,y=0,w=0;t=M,M=M+16|0,f=t;do{if(e>>>0<245){if(e=(u=e>>>0<11?16:e+11&-8)>>>3,3&(r=(d=0|i[6981])>>>e))return s=0|i[(r=8+(e=27964+((n=(1&r^1)+e|0)<<1<<2)|0)|0)>>2],(0|(a=0|i[(o=s+8|0)>>2]))==(0|e)?i[6981]=d&~(1<<n):(i[a+12>>2]=e,i[r>>2]=a),w=n<<3,i[s+4>>2]=3|w,i[(w=s+w+4|0)>>2]=1|i[w>>2],M=t,0|o;if(u>>>0>(h=0|i[6983])>>>0){if(0|r)return n=((n=r<<e&((n=2<<e)|0-n))&0-n)-1|0,a=0|i[(e=8+(n=27964+((s=((r=(n>>>=l=n>>>12&16)>>>5&8)|l|(a=(n>>>=r)>>>2&4)|(e=(n>>>=a)>>>1&2)|(s=(n>>>=e)>>>1&1))+(n>>>s)|0)<<1<<2)|0)|0)>>2],(0|(r=0|i[(l=a+8|0)>>2]))==(0|n)?(e=d&~(1<<s),i[6981]=e):(i[r+12>>2]=n,i[e>>2]=r,e=d),A=(w=s<<3)-u|0,i[a+4>>2]=3|u,i[4+(o=a+u|0)>>2]=1|A,i[a+w>>2]=A,0|h&&(s=0|i[6986],r=27964+((n=h>>>3)<<1<<2)|0,e&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6981]=e|n,n=r,e=r+8|0),i[e>>2]=s,i[n+12>>2]=s,i[s+8>>2]=n,i[s+12>>2]=r),i[6983]=A,i[6986]=o,M=t,0|l;if(a=0|i[6982]){for(r=(a&0-a)-1|0,r=c=0|i[28228+(((s=(r>>>=o=r>>>12&16)>>>5&8)|o|(A=(r>>>=s)>>>2&4)|(l=(r>>>=A)>>>1&2)|(c=(r>>>=l)>>>1&1))+(r>>>c)<<2)>>2],l=c,c=(-8&i[c+4>>2])-u|0;(e=0|i[r+16>>2])||(e=0|i[r+20>>2]);)r=e,l=(o=(A=(-8&i[e+4>>2])-u|0)>>>0<c>>>0)?e:l,c=o?A:c;if((A=l+u|0)>>>0>l>>>0){o=0|i[l+24>>2],n=0|i[l+12>>2];do{if((0|n)==(0|l)){if(!(n=0|i[(e=l+20|0)>>2])&&!(n=0|i[(e=l+16|0)>>2])){r=0;break}for(;;)if(r=0|i[(s=n+20|0)>>2])n=r,e=s;else{if(!(r=0|i[(s=n+16|0)>>2]))break;n=r,e=s}i[e>>2]=0,r=n}else r=0|i[l+8>>2],i[r+12>>2]=n,i[n+8>>2]=r,r=n}while(0);do{if(0|o){if(n=0|i[l+28>>2],(0|l)==(0|i[(e=28228+(n<<2)|0)>>2])){if(i[e>>2]=r,!r){i[6982]=a&~(1<<n);break}}else if(i[((0|i[(w=o+16|0)>>2])==(0|l)?w:o+20)>>2]=r,!r)break;i[r+24>>2]=o,0|(n=0|i[l+16>>2])&&(i[r+16>>2]=n,i[n+24>>2]=r),0|(n=0|i[l+20>>2])&&(i[r+20>>2]=n,i[n+24>>2]=r)}}while(0);return c>>>0<16?(w=c+u|0,i[l+4>>2]=3|w,i[(w=l+w+4|0)>>2]=1|i[w>>2]):(i[l+4>>2]=3|u,i[A+4>>2]=1|c,i[A+c>>2]=c,0|h&&(s=0|i[6986],r=27964+((n=h>>>3)<<1<<2)|0,(n=1<<n)&d?n=0|i[(e=r+8|0)>>2]:(i[6981]=n|d,n=r,e=r+8|0),i[e>>2]=s,i[n+12>>2]=s,i[s+8>>2]=n,i[s+12>>2]=r),i[6983]=c,i[6986]=A),M=t,0|l+8}d=u}else d=u}else d=u}else if(e>>>0<=4294967231)if(u=-8&(e=e+11|0),s=0|i[6982]){o=0-u|0,c=(e>>>=8)?u>>>0>16777215?31:u>>>(7+(c=14-((l=(520192+(m=e<<(d=(e+1048320|0)>>>16&8))|0)>>>16&4)|d|(c=(245760+(m<<=l)|0)>>>16&2))+(m<<c>>>15)|0)|0)&1|c<<1:0,r=0|i[28228+(c<<2)>>2];e:do{if(r)for(e=0,l=u<<(31==(0|c)?0:25-(c>>>1)|0),a=0;;){if((A=(-8&i[r+4>>2])-u|0)>>>0<o>>>0){if(!A){e=r,o=0,m=65;break e}e=r,o=A}if(a=!(0|(m=0|i[r+20>>2]))|(0|m)==(0|(r=0|i[r+16+(l>>>31<<2)>>2]))?a:m,!r){r=a,m=61;break}l<<=1}else r=0,e=0,m=61}while(0);if(61==(0|m)){if(!(0|r)&!(0|e)){if(!(e=((e=2<<c)|0-e)&s)){d=u;break}d=(e&0-e)-1|0,e=0,r=0|i[28228+(((a=(d>>>=A=d>>>12&16)>>>5&8)|A|(l=(d>>>=a)>>>2&4)|(c=(d>>>=l)>>>1&2)|(r=(d>>>=c)>>>1&1))+(d>>>r)<<2)>>2]}r?m=65:(l=e,A=o)}if(65==(0|m))for(a=r;;){if(o=(r=(d=(-8&i[a+4>>2])-u|0)>>>0<o>>>0)?d:o,e=r?a:e,(r=0|i[a+16>>2])||(r=0|i[a+20>>2]),!r){l=e,A=o;break}a=r}if(0|l&&A>>>0<((0|i[6983])-u|0)>>>0&&(h=l+u|0)>>>0>l>>>0){a=0|i[l+24>>2],n=0|i[l+12>>2];do{if((0|n)==(0|l)){if(!(n=0|i[(e=l+20|0)>>2])&&!(n=0|i[(e=l+16|0)>>2])){n=0;break}for(;;)if(r=0|i[(o=n+20|0)>>2])n=r,e=o;else{if(!(r=0|i[(o=n+16|0)>>2]))break;n=r,e=o}i[e>>2]=0}else w=0|i[l+8>>2],i[w+12>>2]=n,i[n+8>>2]=w}while(0);do{if(a){if(e=0|i[l+28>>2],(0|l)==(0|i[(r=28228+(e<<2)|0)>>2])){if(i[r>>2]=n,!n){s&=~(1<<e),i[6982]=s;break}}else if(i[((0|i[(w=a+16|0)>>2])==(0|l)?w:a+20)>>2]=n,!n)break;i[n+24>>2]=a,0|(e=0|i[l+16>>2])&&(i[n+16>>2]=e,i[e+24>>2]=n),(e=0|i[l+20>>2])&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);e:do{if(A>>>0<16)w=A+u|0,i[l+4>>2]=3|w,i[(w=l+w+4|0)>>2]=1|i[w>>2];else{if(i[l+4>>2]=3|u,i[h+4>>2]=1|A,i[h+A>>2]=A,n=A>>>3,A>>>0<256){r=27964+(n<<1<<2)|0,(e=0|i[6981])&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6981]=e|n,n=r,e=r+8|0),i[e>>2]=h,i[n+12>>2]=h,i[h+8>>2]=n,i[h+12>>2]=r;break}if(n=28228+((r=(n=A>>>8)?A>>>0>16777215?31:A>>>(7+(r=14-((v=(520192+(w=n<<(y=(n+1048320|0)>>>16&8))|0)>>>16&4)|y|(r=(245760+(w<<=v)|0)>>>16&2))+(w<<r>>>15)|0)|0)&1|r<<1:0)<<2)|0,i[h+28>>2]=r,i[4+(e=h+16|0)>>2]=0,i[e>>2]=0,!(s&(e=1<<r))){i[6982]=s|e,i[n>>2]=h,i[h+24>>2]=n,i[h+12>>2]=h,i[h+8>>2]=h;break}n=0|i[n>>2];t:do{if((-8&i[n+4>>2])!=(0|A)){for(s=A<<(31==(0|r)?0:25-(r>>>1)|0);e=0|i[(r=n+16+(s>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|A)){n=e;break t}s<<=1,n=e}i[r>>2]=h,i[h+24>>2]=n,i[h+12>>2]=h,i[h+8>>2]=h;break e}}while(0);w=0|i[(y=n+8|0)>>2],i[w+12>>2]=h,i[y>>2]=h,i[h+8>>2]=w,i[h+12>>2]=n,i[h+24>>2]=0}}while(0);return M=t,0|l+8}d=u}else d=u;else d=-1}while(0);if((r=0|i[6983])>>>0>=d>>>0)return n=r-d|0,e=0|i[6986],n>>>0>15?(w=e+d|0,i[6986]=w,i[6983]=n,i[w+4>>2]=1|n,i[e+r>>2]=n,i[e+4>>2]=3|d):(i[6983]=0,i[6986]=0,i[e+4>>2]=3|r,i[(w=e+r+4|0)>>2]=1|i[w>>2]),M=t,0|e+8;if((A=0|i[6984])>>>0>d>>>0)return v=A-d|0,i[6984]=v,y=(w=0|i[6987])+d|0,i[6987]=y,i[y+4>>2]=1|v,i[w+4>>2]=3|d,M=t,0|w+8;if(0|i[7099]?e=0|i[7101]:(i[7101]=4096,i[7100]=4096,i[7102]=-1,i[7103]=-1,i[7104]=0,i[7092]=0,i[7099]=-16&f^1431655768,e=4096),l=d+48|0,(u=(a=e+(c=d+47|0)|0)&(o=0-e|0))>>>0<=d>>>0)return M=t,0;if(0|(e=0|i[7091])&&(f=(h=0|i[7089])+u|0)>>>0<=h>>>0|f>>>0>e>>>0)return M=t,0;e:do{if(4&i[7092])n=0,m=143;else{r=0|i[6987];t:do{if(r){for(s=28372;!((f=0|i[s>>2])>>>0<=r>>>0&&(f+(0|i[s+4>>2])|0)>>>0>r>>>0);){if(!(e=0|i[s+8>>2])){m=128;break t}s=e}if((n=a-A&o)>>>0<2147483647)if((0|(e=0|hn(0|n)))==((0|i[s>>2])+(0|i[s+4>>2])|0)){if(-1!=(0|e)){A=n,a=e,m=145;break e}}else s=e,m=136;else n=0}else m=128}while(0);do{if(128==(0|m))if(-1!=(0|(r=0|hn(0)))&&(n=r,g=(n=((g=(p=0|i[7100])-1|0)&n?(g+n&0-p)-n|0:0)+u|0)+(p=0|i[7089])|0,n>>>0>d>>>0&n>>>0<2147483647)){if(0|(f=0|i[7091])&&g>>>0<=p>>>0|g>>>0>f>>>0){n=0;break}if((0|(e=0|hn(0|n)))==(0|r)){A=n,a=r,m=145;break e}s=e,m=136}else n=0}while(0);do{if(136==(0|m)){if(r=0-n|0,!(l>>>0>n>>>0&n>>>0<2147483647&-1!=(0|s))){if(-1==(0|s)){n=0;break}A=n,a=s,m=145;break e}if((e=c-n+(e=0|i[7101])&0-e)>>>0>=2147483647){A=n,a=s,m=145;break e}if(-1==(0|hn(0|e))){hn(0|r),n=0;break}A=e+n|0,a=s,m=145;break e}}while(0);i[7092]=4|i[7092],m=143}}while(0);if(143==(0|m)&&u>>>0<2147483647&&!(-1==(0|(v=0|hn(0|u)))|1^(b=(_=(g=0|hn(0))-v|0)>>>0>(d+40|0)>>>0)|v>>>0<g>>>0&-1!=(0|v)&-1!=(0|g)^1)&&(A=b?_:n,a=v,m=145),145==(0|m)){n=(0|i[7089])+A|0,i[7089]=n,n>>>0>(0|i[7090])>>>0&&(i[7090]=n),c=0|i[6987];e:do{if(c){for(n=28372;;){if((0|a)==((e=0|i[n>>2])+(r=0|i[n+4>>2])|0)){m=154;break}if(!(s=0|i[n+8>>2]))break;n=s}if(!(154!=(0|m)||(y=n+4|0,8&i[n+12>>2]))&&a>>>0>c>>>0&e>>>0<=c>>>0){i[y>>2]=r+A,y=c+(v=7&(v=c+8|0)?0-v&7:0)|0,v=(w=(0|i[6984])+A|0)-v|0,i[6987]=y,i[6984]=v,i[y+4>>2]=1|v,i[c+w+4>>2]=40,i[6988]=i[7103];break}for(a>>>0<(0|i[6985])>>>0&&(i[6985]=a),r=a+A|0,n=28372;;){if((0|i[n>>2])==(0|r)){m=162;break}if(!(e=0|i[n+8>>2]))break;n=e}if(162==(0|m)&&!(8&i[n+12>>2])){i[n>>2]=a,i[(h=n+4|0)>>2]=(0|i[h>>2])+A,u=(h=a+(7&(h=a+8|0)?0-h&7:0)|0)+d|0,l=(n=r+(7&(n=r+8|0)?0-n&7:0)|0)-h-d|0,i[h+4>>2]=3|d;t:do{if((0|c)==(0|n))w=(0|i[6984])+l|0,i[6984]=w,i[6987]=u,i[u+4>>2]=1|w;else{if((0|i[6986])==(0|n)){w=(0|i[6983])+l|0,i[6983]=w,i[6986]=u,i[u+4>>2]=1|w,i[u+w>>2]=w;break}if(1==(3&(e=0|i[n+4>>2]))){A=-8&e,s=e>>>3;n:do{if(e>>>0<256){if(e=0|i[n+8>>2],(0|(r=0|i[n+12>>2]))==(0|e)){i[6981]=i[6981]&~(1<<s);break}i[e+12>>2]=r,i[r+8>>2]=e;break}a=0|i[n+24>>2],e=0|i[n+12>>2];do{if((0|e)==(0|n)){if(e=0|i[(s=4+(r=n+16|0)|0)>>2])r=s;else if(!(e=0|i[r>>2])){e=0;break}for(;;)if(s=0|i[(o=e+20|0)>>2])e=s,r=o;else{if(!(s=0|i[(o=e+16|0)>>2]))break;e=s,r=o}i[r>>2]=0}else w=0|i[n+8>>2],i[w+12>>2]=e,i[e+8>>2]=w}while(0);if(!a)break;s=28228+((r=0|i[n+28>>2])<<2)|0;do{if((0|i[s>>2])==(0|n)){if(i[s>>2]=e,0|e)break;i[6982]=i[6982]&~(1<<r);break n}if(i[((0|i[(w=a+16|0)>>2])==(0|n)?w:a+20)>>2]=e,!e)break n}while(0);if(i[e+24>>2]=a,0|(s=0|i[(r=n+16|0)>>2])&&(i[e+16>>2]=s,i[s+24>>2]=e),!(r=0|i[r+4>>2]))break;i[e+20>>2]=r,i[r+24>>2]=e}while(0);n=n+A|0,o=A+l|0}else o=l;if(i[(n=n+4|0)>>2]=-2&i[n>>2],i[u+4>>2]=1|o,i[u+o>>2]=o,n=o>>>3,o>>>0<256){r=27964+(n<<1<<2)|0,(e=0|i[6981])&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6981]=e|n,n=r,e=r+8|0),i[e>>2]=u,i[n+12>>2]=u,i[u+8>>2]=n,i[u+12>>2]=r;break}n=o>>>8;do{if(n){if(o>>>0>16777215){s=31;break}s=o>>>(7+(s=14-((v=(520192+(w=n<<(y=(n+1048320|0)>>>16&8))|0)>>>16&4)|y|(s=(245760+(w<<=v)|0)>>>16&2))+(w<<s>>>15)|0)|0)&1|s<<1}else s=0}while(0);if(n=28228+(s<<2)|0,i[u+28>>2]=s,i[4+(e=u+16|0)>>2]=0,i[e>>2]=0,!((e=0|i[6982])&(r=1<<s))){i[6982]=e|r,i[n>>2]=u,i[u+24>>2]=n,i[u+12>>2]=u,i[u+8>>2]=u;break}n=0|i[n>>2];n:do{if((-8&i[n+4>>2])!=(0|o)){for(s=o<<(31==(0|s)?0:25-(s>>>1)|0);e=0|i[(r=n+16+(s>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|o)){n=e;break n}s<<=1,n=e}i[r>>2]=u,i[u+24>>2]=n,i[u+12>>2]=u,i[u+8>>2]=u;break t}}while(0);w=0|i[(y=n+8|0)>>2],i[w+12>>2]=u,i[y>>2]=u,i[u+8>>2]=w,i[u+12>>2]=n,i[u+24>>2]=0}}while(0);return M=t,0|h+8}for(n=28372;!((e=0|i[n>>2])>>>0<=c>>>0&&(w=e+(0|i[n+4>>2])|0)>>>0>c>>>0);)n=0|i[n+8>>2];n=(e=(e=(o=w+-47|0)+(7&(e=o+8|0)?0-e&7:0)|0)>>>0<(o=c+16|0)>>>0?c:e)+8|0,y=a+(v=7&(v=a+8|0)?0-v&7:0)|0,v=(r=A+-40|0)-v|0,i[6987]=y,i[6984]=v,i[y+4>>2]=1|v,i[a+r+4>>2]=40,i[6988]=i[7103],i[(r=e+4|0)>>2]=27,i[n>>2]=i[7093],i[n+4>>2]=i[7094],i[n+8>>2]=i[7095],i[n+12>>2]=i[7096],i[7093]=a,i[7094]=A,i[7096]=0,i[7095]=n,n=e+24|0;do{y=n,i[(n=n+4|0)>>2]=7}while((y+8|0)>>>0<w>>>0);if((0|e)!=(0|c)){if(a=e-c|0,i[r>>2]=-2&i[r>>2],i[c+4>>2]=1|a,i[e>>2]=a,n=a>>>3,a>>>0<256){r=27964+(n<<1<<2)|0,(e=0|i[6981])&(n=1<<n)?n=0|i[(e=r+8|0)>>2]:(i[6981]=e|n,n=r,e=r+8|0),i[e>>2]=c,i[n+12>>2]=c,i[c+8>>2]=n,i[c+12>>2]=r;break}if(r=28228+((s=(n=a>>>8)?a>>>0>16777215?31:a>>>(7+(s=14-((v=(520192+(w=n<<(y=(n+1048320|0)>>>16&8))|0)>>>16&4)|y|(s=(245760+(w<<=v)|0)>>>16&2))+(w<<s>>>15)|0)|0)&1|s<<1:0)<<2)|0,i[c+28>>2]=s,i[c+20>>2]=0,i[o>>2]=0,!((n=0|i[6982])&(e=1<<s))){i[6982]=n|e,i[r>>2]=c,i[c+24>>2]=r,i[c+12>>2]=c,i[c+8>>2]=c;break}n=0|i[r>>2];t:do{if((-8&i[n+4>>2])!=(0|a)){for(s=a<<(31==(0|s)?0:25-(s>>>1)|0);e=0|i[(r=n+16+(s>>>31<<2)|0)>>2];){if((-8&i[e+4>>2])==(0|a)){n=e;break t}s<<=1,n=e}i[r>>2]=c,i[c+24>>2]=n,i[c+12>>2]=c,i[c+8>>2]=c;break e}}while(0);w=0|i[(y=n+8|0)>>2],i[w+12>>2]=c,i[y>>2]=c,i[c+8>>2]=w,i[c+12>>2]=n,i[c+24>>2]=0}}else!(0|(w=0|i[6985]))|a>>>0<w>>>0&&(i[6985]=a),i[7093]=a,i[7094]=A,i[7096]=0,i[6990]=i[7099],i[6989]=-1,i[6994]=27964,i[6993]=27964,i[6996]=27972,i[6995]=27972,i[6998]=27980,i[6997]=27980,i[7e3]=27988,i[6999]=27988,i[7002]=27996,i[7001]=27996,i[7004]=28004,i[7003]=28004,i[7006]=28012,i[7005]=28012,i[7008]=28020,i[7007]=28020,i[7010]=28028,i[7009]=28028,i[7012]=28036,i[7011]=28036,i[7014]=28044,i[7013]=28044,i[7016]=28052,i[7015]=28052,i[7018]=28060,i[7017]=28060,i[7020]=28068,i[7019]=28068,i[7022]=28076,i[7021]=28076,i[7024]=28084,i[7023]=28084,i[7026]=28092,i[7025]=28092,i[7028]=28100,i[7027]=28100,i[7030]=28108,i[7029]=28108,i[7032]=28116,i[7031]=28116,i[7034]=28124,i[7033]=28124,i[7036]=28132,i[7035]=28132,i[7038]=28140,i[7037]=28140,i[7040]=28148,i[7039]=28148,i[7042]=28156,i[7041]=28156,i[7044]=28164,i[7043]=28164,i[7046]=28172,i[7045]=28172,i[7048]=28180,i[7047]=28180,i[7050]=28188,i[7049]=28188,i[7052]=28196,i[7051]=28196,i[7054]=28204,i[7053]=28204,i[7056]=28212,i[7055]=28212,y=a+(v=7&(v=a+8|0)?0-v&7:0)|0,v=(w=A+-40|0)-v|0,i[6987]=y,i[6984]=v,i[y+4>>2]=1|v,i[a+w+4>>2]=40,i[6988]=i[7103]}while(0);if((n=0|i[6984])>>>0>d>>>0)return v=n-d|0,i[6984]=v,y=(w=0|i[6987])+d|0,i[6987]=y,i[y+4>>2]=1|v,i[w+4>>2]=3|d,M=t,0|w+8}return i[(w=27920)>>2]=12,M=t,0}function Ht(e){var t=0,n=0,r=0,s=0,o=0,a=0,A=0,l=0;if(e|=0){n=e+-8|0,s=0|i[6985],l=n+(t=-8&(e=0|i[e+-4>>2]))|0;do{if(1&e)A=n,a=n;else{if(r=0|i[n>>2],!(3&e))return;if(o=r+t|0,(a=n+(0-r)|0)>>>0<s>>>0)return;if((0|i[6986])==(0|a)){if(3&~(t=0|i[(e=l+4|0)>>2])){A=a,t=o;break}return i[6983]=o,i[e>>2]=-2&t,i[a+4>>2]=1|o,void(i[a+o>>2]=o)}if(n=r>>>3,r>>>0<256){if(e=0|i[a+8>>2],(0|(t=0|i[a+12>>2]))==(0|e)){i[6981]=i[6981]&~(1<<n),A=a,t=o;break}i[e+12>>2]=t,i[t+8>>2]=e,A=a,t=o;break}s=0|i[a+24>>2],e=0|i[a+12>>2];do{if((0|e)==(0|a)){if(e=0|i[(n=4+(t=a+16|0)|0)>>2])t=n;else if(!(e=0|i[t>>2])){e=0;break}for(;;)if(n=0|i[(r=e+20|0)>>2])e=n,t=r;else{if(!(n=0|i[(r=e+16|0)>>2]))break;e=n,t=r}i[t>>2]=0}else A=0|i[a+8>>2],i[A+12>>2]=e,i[e+8>>2]=A}while(0);if(s){if(t=0|i[a+28>>2],(0|i[(n=28228+(t<<2)|0)>>2])==(0|a)){if(i[n>>2]=e,!e){i[6982]=i[6982]&~(1<<t),A=a,t=o;break}}else if(i[((0|i[(A=s+16|0)>>2])==(0|a)?A:s+20)>>2]=e,!e){A=a,t=o;break}i[e+24>>2]=s,0|(n=0|i[(t=a+16|0)>>2])&&(i[e+16>>2]=n,i[n+24>>2]=e),(t=0|i[t+4>>2])?(i[e+20>>2]=t,i[t+24>>2]=e,A=a,t=o):(A=a,t=o)}else A=a,t=o}}while(0);if(!(a>>>0>=l>>>0)&&1&(r=0|i[(e=l+4|0)>>2])){if(2&r)i[e>>2]=-2&r,i[A+4>>2]=1|t,i[a+t>>2]=t,s=t;else{if((0|i[6987])==(0|l)){if(l=(0|i[6984])+t|0,i[6984]=l,i[6987]=A,i[A+4>>2]=1|l,(0|A)!=(0|i[6986]))return;return i[6986]=0,void(i[6983]=0)}if((0|i[6986])==(0|l))return l=(0|i[6983])+t|0,i[6983]=l,i[6986]=a,i[A+4>>2]=1|l,void(i[a+l>>2]=l);s=(-8&r)+t|0,n=r>>>3;do{if(r>>>0<256){if(t=0|i[l+8>>2],(0|(e=0|i[l+12>>2]))==(0|t)){i[6981]=i[6981]&~(1<<n);break}i[t+12>>2]=e,i[e+8>>2]=t;break}o=0|i[l+24>>2],e=0|i[l+12>>2];do{if((0|e)==(0|l)){if(e=0|i[(n=4+(t=l+16|0)|0)>>2])t=n;else if(!(e=0|i[t>>2])){n=0;break}for(;;)if(n=0|i[(r=e+20|0)>>2])e=n,t=r;else{if(!(n=0|i[(r=e+16|0)>>2]))break;e=n,t=r}i[t>>2]=0,n=e}else n=0|i[l+8>>2],i[n+12>>2]=e,i[e+8>>2]=n,n=e}while(0);if(0|o){if(e=0|i[l+28>>2],(0|i[(t=28228+(e<<2)|0)>>2])==(0|l)){if(i[t>>2]=n,!n){i[6982]=i[6982]&~(1<<e);break}}else if(i[((0|i[(r=o+16|0)>>2])==(0|l)?r:o+20)>>2]=n,!n)break;i[n+24>>2]=o,0|(t=0|i[(e=l+16|0)>>2])&&(i[n+16>>2]=t,i[t+24>>2]=n),0|(e=0|i[e+4>>2])&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);if(i[A+4>>2]=1|s,i[a+s>>2]=s,(0|A)==(0|i[6986]))return void(i[6983]=s)}if(e=s>>>3,s>>>0<256)return n=27964+(e<<1<<2)|0,(t=0|i[6981])&(e=1<<e)?e=0|i[(t=n+8|0)>>2]:(i[6981]=t|e,e=n,t=n+8|0),i[t>>2]=A,i[e+12>>2]=A,i[A+8>>2]=e,void(i[A+12>>2]=n);e=28228+((r=(e=s>>>8)?s>>>0>16777215?31:s>>>(7+(r=14-((o=(520192+(l=e<<(a=(e+1048320|0)>>>16&8))|0)>>>16&4)|a|(r=(245760+(l<<=o)|0)>>>16&2))+(l<<r>>>15)|0)|0)&1|r<<1:0)<<2)|0,i[A+28>>2]=r,i[A+20>>2]=0,i[A+16>>2]=0,t=0|i[6982],n=1<<r;e:do{if(t&n){e=0|i[e>>2];t:do{if((-8&i[e+4>>2])!=(0|s)){for(r=s<<(31==(0|r)?0:25-(r>>>1)|0);t=0|i[(n=e+16+(r>>>31<<2)|0)>>2];){if((-8&i[t+4>>2])==(0|s)){e=t;break t}r<<=1,e=t}i[n>>2]=A,i[A+24>>2]=e,i[A+12>>2]=A,i[A+8>>2]=A;break e}}while(0);l=0|i[(a=e+8|0)>>2],i[l+12>>2]=A,i[a>>2]=A,i[A+8>>2]=l,i[A+12>>2]=e,i[A+24>>2]=0}else i[6982]=t|n,i[e>>2]=A,i[A+24>>2]=e,i[A+12>>2]=A,i[A+8>>2]=A}while(0);if(l=(0|i[6989])-1|0,i[6989]=l,!(0|l)){for(e=28380;e=0|i[e>>2];)e=e+8|0;i[6989]=-1}}}}function $t(e,t){t|=0;var n=0;return(e|=0)?(n=0|v(t,e),(t|e)>>>0>65535&&(n=((n>>>0)/(e>>>0)|0)==(0|t)?n:-1)):n=0,(e=0|Wt(n))&&3&i[e+-4>>2]?(cn(0|e,0,0|n),0|e):0|e}function Xt(e,t,n,r){return 0|(E((t|=0)+(r|=0)+((n=(e|=0)+(n|=0)>>>0)>>>0<e>>>0|0)>>>0|0),n)}function Qt(e,t,n,r){return 0|(E(0|(r=(t|=0)-(r|=0)-((n|=0)>>>0>(e|=0)>>>0|0)>>>0)),e-n>>>0)}function Yt(e){return 0|((e|=0)?31-(0|x(e^e-1)):32)}function qt(e,t,n,r,s){s|=0;var o=0,a=0,A=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0;if(u=e|=0,a=n|=0,A=d=r|=0,!(c=l=t|=0))return o=!!(0|s),A?o?(i[s>>2]=0|e,i[s+4>>2]=0&t,s=0,0|(E(0|(d=0)),s)):(s=0,0|(E(0|(d=0)),s)):(o&&(i[s>>2]=(u>>>0)%(a>>>0),i[s+4>>2]=0),s=(u>>>0)/(a>>>0)>>>0,0|(E(0|(d=0)),s));o=!(0|A);do{if(a){if(!o){if((o=(0|x(0|A))-(0|x(0|c))|0)>>>0<=31){a=h=o+1|0,e=u>>>(h>>>0)&(t=o-31>>31)|c<<(A=31-o|0),t&=c>>>(h>>>0),o=0,A=u<<A;break}return s?(i[s>>2]=0|e,i[s+4>>2]=l|0&t,s=0,0|(E(0|(d=0)),s)):(s=0,0|(E(0|(d=0)),s))}if((o=a-1|0)&a){a=A=33+(0|x(0|a))-(0|x(0|c))|0,e=(h=32-A|0)-1>>31&c>>>((f=A-32|0)>>>0)|(c<<h|u>>>(A>>>0))&(t=f>>31),t&=c>>>(A>>>0),o=u<<(p=64-A|0)&(l=h>>31),A=(c<<p|u>>>(f>>>0))&l|u<<h&A-33>>31;break}return 0|s&&(i[s>>2]=o&u,i[s+4>>2]=0),1==(0|a)?(p=0|e,0|(E(0|(f=l|0&t)),p)):(f=c>>>((p=0|Yt(0|a))>>>0)|0,p=c<<32-p|u>>>(p>>>0),0|(E(0|f),p))}if(o)return 0|s&&(i[s>>2]=(c>>>0)%(a>>>0),i[s+4>>2]=0),p=(c>>>0)/(a>>>0)>>>0,0|(E(0|(f=0)),p);if(!u)return 0|s&&(i[s>>2]=0,i[s+4>>2]=(c>>>0)%(A>>>0)),p=(c>>>0)/(A>>>0)>>>0,0|(E(0|(f=0)),p);if(!((o=A-1|0)&A))return 0|s&&(i[s>>2]=0|e,i[s+4>>2]=o&c|0&t),f=0,p=c>>>((0|Yt(0|A))>>>0),0|(E(0|f),p);if((o=(0|x(0|A))-(0|x(0|c))|0)>>>0<=30){a=t=o+1|0,e=c<<(A=31-o|0)|u>>>(t>>>0),t=c>>>(t>>>0),o=0,A=u<<A;break}return s?(i[s>>2]=0|e,i[s+4>>2]=l|0&t,p=0,0|(E(0|(f=0)),p)):(p=0,0|(E(0|(f=0)),p))}while(0);if(a){c=0|Xt(0|(h=0|n),0|(u=d|0&r),-1,-1),n=0|T(),l=A,A=0;do{r=l,l=o>>>31|l<<1,o=A|o<<1,Qt(0|c,0|n,0|(r=e<<1|r>>>31),0|(d=e>>>31|t<<1)),A=1&(f=(p=0|T())>>31|((0|p)<0?-1:0)<<1),e=0|Qt(0|r,0|d,f&h|0,(((0|p)<0?-1:0)>>31|((0|p)<0?-1:0)<<1)&u),t=0|T(),a=a-1|0}while(0|a);c=l,l=0}else c=A,l=0,A=0;return a=0,0|s&&(i[s>>2]=e,i[s+4>>2]=t),p=o<<1&-2|A,0|(E(0|(f=(0|o)>>>31|(c|a)<<1|l)),p)}function Kt(e,t,n,r){var i,s,o,a,A;return n|=0,s=(r|=0)>>31|((0|r)<0?-1:0)<<1,i=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,o=0|Qt((A=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0),(a=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t,0|A,0|a),e=s^A,t=i^a,0|Qt((0|qt(o,0|T(),0|Qt(s^n|0,i^r|0,0|s,0|i),0|T(),0))^e,(0|T())^t,0|e,0|t)}function Zt(e,t,n,r){var i,s;return t|=0,r|=0,n=0|function(e,t){var n,r,i,s=0;return e=((n=0|v(s=65535&(t|=0),i=65535&(e|=0)))>>>16)+(0|v(s,r=e>>>16))|0,t=0|v(s=t>>>16,i),0|(E((e>>>16)+(0|v(s,r))+(((65535&e)+t|0)>>>16)|0),e+t<<16|65535&n)}(i=e|=0,s=n|=0),e=0|T(),0|(E((0|v(t,s))+(0|v(r,i))+e|0&e),n)}function Jt(e,t,n,r){var s,o,a,A,l,c;return n|=0,s=M,M=M+16|0,A=0|s,c=(r|=0)>>31|((0|r)<0?-1:0)<<1,l=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,qt(e=0|Qt((a=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0),(o=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t,0|a,0|o),t=0|T(),0|Qt(c^n|0,l^r|0,0|c,0|l),0|T(),A),r=0|Qt(i[A>>2]^a|0,i[A+4>>2]^o|0,0|a,0|o),n=0|T(),M=s,0|(E(0|n),r)}function en(e,t,n,r){var s,o;return o=M,M=M+16|0,qt(e|=0,t|=0,n|=0,r|=0,s=0|o),M=o,0|(E(0|i[s+4>>2]),i[s>>2])}function tn(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(E(t>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(E(0|((0|t)<0?-1:0)),t>>n-32)}function nn(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(E(t>>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(E(0),t>>>n-32|0)}function rn(e,t,n){return e|=0,(0|(n|=0))<32?(E((t|=0)<<n|(e&(1<<n)-1<<32-n)>>>32-n),e<<n):(E(e<<n-32),0)}function sn(e,t,n){return e|=0,32==(0|(t=0|x(t|=0)))&&(t=t+(0|x(e))|0),E(0),0|t}function on(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+w(+e,+t)}function an(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+y(+e,+t)}function An(e){return(e=+e)>=0?+A(e+.5):+b(e-.5)}function ln(e,t,n){e|=0,t|=0;var s,o,a=0;if((0|(n|=0))>=8192)return R(0|e,0|t,0|n),0|e;if(o=0|e,s=e+n|0,(3&e)==(3&t)){for(;3&e;){if(!n)return 0|o;r[0|e]=0|r[0|t],e=e+1|0,t=t+1|0,n=n-1|0}for(a=(n=-4&s)-64|0;(0|e)<=(0|a);)i[e>>2]=i[t>>2],i[e+4>>2]=i[t+4>>2],i[e+8>>2]=i[t+8>>2],i[e+12>>2]=i[t+12>>2],i[e+16>>2]=i[t+16>>2],i[e+20>>2]=i[t+20>>2],i[e+24>>2]=i[t+24>>2],i[e+28>>2]=i[t+28>>2],i[e+32>>2]=i[t+32>>2],i[e+36>>2]=i[t+36>>2],i[e+40>>2]=i[t+40>>2],i[e+44>>2]=i[t+44>>2],i[e+48>>2]=i[t+48>>2],i[e+52>>2]=i[t+52>>2],i[e+56>>2]=i[t+56>>2],i[e+60>>2]=i[t+60>>2],e=e+64|0,t=t+64|0;for(;(0|e)<(0|n);)i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0}else for(n=s-4|0;(0|e)<(0|n);)r[0|e]=0|r[0|t],r[e+1|0]=0|r[t+1|0],r[e+2|0]=0|r[t+2|0],r[e+3|0]=0|r[t+3|0],e=e+4|0,t=t+4|0;for(;(0|e)<(0|s);)r[0|e]=0|r[0|t],e=e+1|0,t=t+1|0;return 0|o}function cn(e,t,n){t|=0;var s,o=0,a=0,A=0;if(s=(e|=0)+(n|=0)|0,t&=255,(0|n)>=67){for(;3&e;)r[0|e]=t,e=e+1|0;for(A=t|t<<8|t<<16|t<<24,a=(o=-4&s)-64|0;(0|e)<=(0|a);)i[e>>2]=A,i[e+4>>2]=A,i[e+8>>2]=A,i[e+12>>2]=A,i[e+16>>2]=A,i[e+20>>2]=A,i[e+24>>2]=A,i[e+28>>2]=A,i[e+32>>2]=A,i[e+36>>2]=A,i[e+40>>2]=A,i[e+44>>2]=A,i[e+48>>2]=A,i[e+52>>2]=A,i[e+56>>2]=A,i[e+60>>2]=A,e=e+64|0;for(;(0|e)<(0|o);)i[e>>2]=A,e=e+4|0}for(;(0|e)<(0|s);)r[0|e]=t,e=e+1|0;return s-n|0}function un(e){return(e=+e)>=0?+A(e+.5):+b(e-.5)}function hn(e){var t,n,r;return e|=0,r=0|k(),(0|e)>0&(0|(t=(n=0|i[a>>2])+e|0))<(0|n)|(0|t)<0?(I(0|t),C(12),-1):(0|t)>(0|r)&&!(0|P(0|t))?(C(12),-1):(i[a>>2]=t,0|n)}return{___divdi3:Kt,___muldi3:Zt,___remdi3:Jt,___uremdi3:en,_areNeighborCells:function(e,t,n,r,s){s|=0;var o,a,A,l=0,c=0,u=0,h=0;if(A=M,M=M+64|0,a=A,o=A+56|0,!(!0&134217728==(2013265920&(t|=0))&!0&134217728==(2013265920&(r|=0))))return M=A,5;if((0|(e|=0))==(0|(n|=0))&(0|t)==(0|r))return i[s>>2]=0,M=A,0;if(c=0|nn(0|e,0|t,52),T(),c&=15,h=0|nn(0|n,0|r,52),T(),(0|c)!=(15&h))return M=A,12;if(l=c+-1|0,c>>>0>1){Fe(e,t,l,a),Fe(n,r,l,o),u=0|i[(h=a)>>2],h=0|i[h+4>>2];e:do{if((0|u)==(0|i[o>>2])&&(0|h)==(0|i[o+4>>2])){l=0|nn(0|e,0|t,0|(c=3*(15^c)|0)),T(),l&=7,c=0|nn(0|n,0|r,0|c),T(),c&=7;do{if(!(0|l)|!(0|c))i[s>>2]=1,l=0;else if(7==(0|l))l=5;else{if(1==(0|l)|1==(0|c)&&0|je(u,h)){l=5;break}if((0|i[15536+(l<<2)>>2])!=(0|c)&&(0|i[15568+(l<<2)>>2])!=(0|c))break e;i[s>>2]=1,l=0}}while(0);return M=A,0|l}}while(0)}c=(l=a)+56|0;do{i[l>>2]=0,l=l+4|0}while((0|l)<(0|c));return L(e,t,1,a),l=(0|i[(t=a)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=a+8|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=a+16|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=a+24|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=a+32|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)||(0|i[(t=a+40|0)>>2])==(0|n)&&(0|i[t+4>>2])==(0|r)?1:1&((0|i[(l=a+48|0)>>2])==(0|n)?(0|i[l+4>>2])==(0|r):0),i[s>>2]=l,M=A,0},_bitshift64Ashr:tn,_bitshift64Lshr:nn,_bitshift64Shl:rn,_calloc:$t,_cellAreaKm2:function(e,t,n){return 0|(e=0|ut(e|=0,t|=0,n|=0))||(s[n>>3]=6371.007180918475*+s[n>>3]*6371.007180918475),0|e},_cellAreaM2:function(e,t,n){return 0|(e=0|ut(e|=0,t|=0,n|=0))||(s[n>>3]=6371.007180918475*+s[n>>3]*6371.007180918475*1e3*1e3),0|e},_cellAreaRads2:ut,_cellToBoundary:Je,_cellToCenterChild:ze,_cellToChildPos:function(e,t,n,r){n|=0,r|=0;var s,o=0,a=0,A=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0;if(s=M,M=M+16|0,_=s,b=0|nn(0|(e|=0),0|(t|=0),52),T(),n>>>0>15)return M=s,4;if((0|(b&=15))<(0|n))return M=s,12;if((0|b)!=(0|n))if(a=0|rn(0|n,0,52),a|=e,l=T()|-15728641&t,(0|b)>(0|n)){c=n;do{m=0|rn(7,0,3*(14-c|0)|0),c=c+1|0,a|=m,l=0|T()|l}while((0|c)<(0|b));m=a}else m=a;else m=e,l=t;g=0|nn(0|m,0|l,45),T();e:do{if(0|G(127&g)){if(c=0|nn(0|m,0|l,52),T(),0|(c&=15))for(a=1;;){if(!(!((g=0|rn(7,0,3*(15-a|0)|0))&m)&!((0|T())&l))){u=33;break e}if(!(a>>>0<c>>>0))break;a=a+1|0}if(i[(g=r)>>2]=0,i[g+4>>2]=0,(0|b)>(0|n)){for(g=-15728641&t,p=b;;){if(f=p,(p=p+-1|0)>>>0>15|(0|b)<(0|p)){u=19;break}if((0|b)!=(0|p))if(a=0|rn(0|p,0,52),a|=e,c=0|T()|g,(0|b)<(0|f))d=a;else{u=p;do{d=0|rn(7,0,3*(14-u|0)|0),u=u+1|0,a|=d,c=0|T()|c}while((0|u)<(0|b));d=a}else d=e,c=t;if(h=0|nn(0|d,0|c,45),T(),0|G(127&h)){h=0|nn(0|d,0|c,52),T(),h&=15;t:do{if(h)for(u=1;;){if(a=0|nn(0|d,0|c,3*(15-u|0)|0),T(),0|(a&=7))break t;if(!(u>>>0<h>>>0)){a=0;break}u=u+1|0}else a=0}while(0);a=1&!(0|a)}else a=0;if(c=0|nn(0|e,0|t,3*(15-f|0)|0),T(),7==(0|(c&=7))){o=5,u=42;break}if(1==(0|c)&(a=!!(0|a))){o=5,u=42;break}if(0|(d=c+((!!(0|c)&a)<<31>>31)|0)&&(u=0|_t(7,0,u=b-f|0,((0|u)<0)<<31>>31),h=0|T(),a?(a=0|Xt(0|(a=0|Zt(0|u,0|h,5,0)),0|T(),-5,-1),a=0|Xt(0|(a=0|Kt(0|a,0|T(),6,0)),0|T(),1,0),c=0|T()):(a=u,c=h),f=0|Xt(0|a,0|c,0|(f=0|Zt(0|u,0|h,0|(f=d+-1|0),((0|f)<0)<<31>>31)),0|T()),h=0|Xt(0|f,0|(d=0|T()),0|i[(h=r)>>2],0|i[h+4>>2]),d=0|T(),i[(f=r)>>2]=h,i[f+4>>2]=d),(0|p)<=(0|n)){u=37;break}}if(19==(0|u))S(27795,27122,1367,27158);else{if(37==(0|u)){o=0|i[(A=r)+4>>2],A=0|i[A>>2];break}if(42==(0|u))return M=s,0|o}}else o=0,A=0}else u=33}while(0);e:do{if(33==(0|u)){if(i[(g=r)>>2]=0,i[g+4>>2]=0,(0|b)>(0|n)){for(a=b;;){if(o=0|nn(0|e,0|t,3*(15-a|0)|0),T(),7==(0|(o&=7))){o=5;break}if(o=0|Zt(0|(A=0|_t(7,0,A=b-a|0,((0|A)<0)<<31>>31)),0|T(),0|o,0),A=0|T(),A=0|Xt(0|i[(g=r)>>2],0|i[g+4>>2],0|o,0|A),o=0|T(),i[(g=r)>>2]=A,i[g+4>>2]=o,(0|(a=a+-1|0))<=(0|n))break e}return M=s,0|o}o=0,A=0}}while(0);return 0|Ue(m,l,b,_)&&S(27795,27122,1327,27173),((0|o)>-1|-1==(0|o)&A>>>0>4294967295)&((0|(_=0|i[(b=_)+4>>2]))>(0|o)|((0|_)==(0|o)?(0|i[b>>2])>>>0>A>>>0:0))?(M=s,0|(b=0)):(S(27795,27122,1407,27158),0)},_cellToChildren:function(e,t,n,r){r|=0;var s,o,a=0,A=0;if(o=M,M=M+16|0,tt(s=o,e|=0,t|=0,n|=0),!(0|(e=0|i[(t=s)>>2]))&!(0|(t=0|i[t+4>>2])))return M=o,0;a=0,n=0;do{i[(A=r+(a<<3)|0)>>2]=e,i[A+4>>2]=t,a=0|Xt(0|a,0|n,1,0),n=0|T(),rt(s),e=0|i[(A=s)>>2],t=0|i[A+4>>2]}while(!(!(0|e)&!(0|t)));return M=o,0},_cellToChildrenSize:Ue,_cellToLatLng:Ze,_cellToLocalIj:function(e,t,n,r,s,o){var a,A;return e|=0,o|=0,A=M,M=M+16|0,a=A,(s|=0)?e=15:(e=0|gt(e,t|=0,n|=0,r|=0,a))||(function(e,t){var n;t|=0,n=0|i[8+(e|=0)>>2],i[t>>2]=(0|i[e>>2])-n,i[t+4>>2]=(0|i[e+4>>2])-n}(a,o),e=0),M=A,0|e},_cellToParent:Fe,_cellToVertex:Nt,_cellToVertexes:function(e,t,n){n|=0;var r,s=0,o=0;return o=!(0|je(e|=0,t|=0)),r=!(0|(s=0|Nt(e,t,0,n))),o?r?0|(s=0|Nt(e,t,1,n+8|0))||0|(s=0|Nt(e,t,2,n+16|0))||0|(s=0|Nt(e,t,3,n+24|0))||(s=0|Nt(e,t,4,n+32|0))?0|(o=s):0|Nt(e,t,5,n+40|0):0|(o=s):r?0|(s=0|Nt(e,t,1,n+8|0))||0|(s=0|Nt(e,t,2,n+16|0))||0|(s=0|Nt(e,t,3,n+24|0))||0|(s=0|Nt(e,t,4,n+32|0))?0|(o=s):(i[(o=n+40|0)>>2]=0,i[o+4>>2]=0,0|(o=0)):0|(o=s)},_cellsToDirectedEdge:function(e,t,n,r,s){return s|=0,7==(0|(n=0|U(e|=0,t|=0,n|=0,r|=0)))?0|(s=11):(r=0|rn(0|n,0,56),t=-2130706433&t|T()|268435456,i[s>>2]=e|r,i[s+4>>2]=t,0|(s=0))},_cellsToLinkedMultiPolygon:function(e,t,n){n|=0;var r,o,a,A=0;if(a=M,M=M+32|0,r=a,0|(e=0|function(e,t,n){e|=0,n|=0;var r,s,o=0,a=0,A=0,l=0,c=0,u=0;if(s=M,M=M+176|0,r=s,(0|(t|=0))<1)return Dt(n,0,0),M=s,0;for(c=0|nn(0|i[(c=e)>>2],0|i[c+4>>2],52),T(),Dt(n,(0|t)>6?t:6,15&c),c=0;!(0|(o=0|Je(0|i[(o=e+(c<<3)|0)>>2],0|i[o+4>>2],r)));){if((0|(o=0|i[r>>2]))>0){l=0;do{A=r+8+(l<<4)|0,(a=0|Gt(n,o=r+8+((0|(l=l+1|0))%(0|o)<<4)|0,A))?Ut(n,a):jt(n,A,o),o=0|i[r>>2]}while((0|l)<(0|o))}if((0|(c=c+1|0))>=(0|t)){o=0,u=13;break}}return 13==(0|u)?(M=s,0|o):(Ot(n),M=s,0|(u=o))}(e|=0,t|=0,o=a+16|0)))return M=a,0|e;if(i[n>>2]=0,i[n+4>>2]=0,i[n+8>>2]=0,0|(e=0|Ft(o)))do{t=0|ht(n);do{dt(t,e),A=e+16|0,i[r>>2]=i[A>>2],i[r+4>>2]=i[A+4>>2],i[r+8>>2]=i[A+8>>2],i[r+12>>2]=i[A+12>>2],Ut(o,e),e=0|zt(o,r)}while(0|e);e=0|Ft(o)}while(0|e);return Ot(o),(e=0|function(e){var t,n,r=0,o=0,a=0,A=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0,y=0,w=0,x=0,E=0,T=0,C=0,k=0,R=0,P=0,I=0,M=0,L=0,N=0,B=0,D=0;if(0|i[(A=(e|=0)+8|0)>>2])return 1;if(!(a=0|i[e>>2]))return 0;r=a,o=0;do{o=o+1|0,r=0|i[r+8>>2]}while(0|r);if(o>>>0<2)return 0;(n=0|Wt(o<<2))||S(27396,27235,317,27415),(t=0|Wt(o<<5))||S(27437,27235,321,27415),i[e>>2]=0,i[(k=e+4|0)>>2]=0,i[A>>2]=0,o=0,N=0,C=0,g=0;e:for(;;){if(p=0|i[a>>2]){c=0,u=p;do{if(d=+s[u+8>>3],r=u,u=0|i[u+16>>2],h=+s[(A=(f=!(0|u))?p:u)+8>>3],+l(+(d-h))>3.141592653589793){D=14;break}c+=(h-d)*(+s[r>>3]+ +s[A>>3])}while(!f);if(14==(0|D)){D=0,c=0,r=p;do{T=+s[r+8>>3],M=0|i[(L=r+16|0)>>2],E=+s[(M=0|M?M:p)+8>>3],c+=(+s[r>>3]+ +s[M>>3])*((E<0?E+6.283185307179586:E)-(T<0?T+6.283185307179586:T)),r=0|i[(0|r?L:a)>>2]}while(0|r)}c>0?(i[n+(N<<2)>>2]=a,N=N+1|0,A=C,r=g):D=19}else D=19;if(19==(0|D)){D=0;do{if(!o){if(g){A=k,u=g+8|0,r=a,o=e;break}if(0|i[e>>2]){D=27;break e}A=k,u=e,r=a,o=e;break}if(0|i[(r=o+8|0)>>2]){D=21;break e}if(!(o=0|$t(1,12))){D=23;break e}i[r>>2]=o,A=o+4|0,u=o,r=g}while(0);if(i[u>>2]=a,i[A>>2]=a,u=t+(C<<5)|0,f=0|i[a>>2]){for(s[(p=t+(C<<5)+8|0)>>3]=17976931348623157e292,s[(g=t+(C<<5)+24|0)>>3]=17976931348623157e292,s[u>>3]=-17976931348623157e292,s[(m=t+(C<<5)+16|0)>>3]=-17976931348623157e292,w=17976931348623157e292,x=-17976931348623157e292,A=0,_=f,d=17976931348623157e292,v=17976931348623157e292,y=-17976931348623157e292,h=-17976931348623157e292;c=+s[_>>3],T=+s[_+8>>3],_=0|i[_+16>>2],E=+s[((b=!(0|_))?f:_)+8>>3],c<d&&(s[p>>3]=c,d=c),T<v&&(s[g>>3]=T,v=T),c>y?s[u>>3]=c:c=y,T>h&&(s[m>>3]=T,h=T),w=T>0&T<w?T:w,x=T<0&T>x?T:x,A|=+l(+(T-E))>3.141592653589793,!b;)y=c;A&&(s[m>>3]=x,s[g>>3]=w)}else i[u>>2]=0,i[u+4>>2]=0,i[u+8>>2]=0,i[u+12>>2]=0,i[u+16>>2]=0,i[u+20>>2]=0,i[u+24>>2]=0,i[u+28>>2]=0;A=C+1|0}if(a=0|i[(L=a+8|0)>>2],i[L>>2]=0,!a){D=45;break}C=A,g=r}if(21==(0|D))S(27213,27235,35,27247);else if(23==(0|D))S(27267,27235,37,27247);else if(27==(0|D))S(27310,27235,61,27333);else if(45==(0|D)){e:do{if((0|N)>0){for(L=!(0|A),I=A<<2,M=!(0|e),P=0,r=0;;){if(R=0|i[n+(P<<2)>>2],L)D=73;else{if(!(C=0|Wt(I))){D=50;break}if(!(k=0|Wt(I))){D=52;break}t:do{if(M)o=0;else{for(A=0,o=0,u=e;a=t+(A<<5)|0,0|pt(0|i[u>>2],a,0|i[R>>2])?(i[C+(o<<2)>>2]=u,i[k+(o<<2)>>2]=a,b=o+1|0):b=o,u=0|i[u+8>>2];)A=A+1|0,o=b;if((0|b)>0)if(a=0|i[C>>2],1==(0|b))o=a;else for(m=0,_=-1,o=a,g=a;;){for(f=0|i[g>>2],a=0,u=0;p=(0|(A=0|i[i[C+(u<<2)>>2]>>2]))==(0|f)?a:a+(1&pt(A,0|i[k+(u<<2)>>2],0|i[f>>2]))|0,(0|(u=u+1|0))!=(0|b);)a=p;if(o=(A=(0|p)>(0|_))?g:o,(0|(a=m+1|0))==(0|b))break t;m=a,_=A?p:_,g=0|i[C+(a<<2)>>2]}else o=0}}while(0);if(Ht(C),Ht(k),o){if(a=0|i[(A=o+4|0)>>2])o=a+8|0;else if(0|i[o>>2]){D=70;break}i[o>>2]=R,i[A>>2]=R}else D=73}if(73==(0|D)){if(D=0,0|(r=0|i[R>>2]))do{k=r,r=0|i[r+16>>2],Ht(k)}while(0|r);Ht(R),r=1}if((0|(P=P+1|0))>=(0|N)){B=r;break e}}50==(0|D)?S(27452,27235,249,27471):52==(0|D)?S(27490,27235,252,27471):70==(0|D)&&S(27310,27235,61,27333)}else B=0}while(0);return Ht(n),Ht(t),0|B}return 0}(n))?(ft(n),M=a,0|(A=e)):(M=a,0|(A=0))},_childPosToCell:function(e,t,n,r,s,o){e|=0,t|=0,o|=0;var a,A=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0;if(a=M,M=M+16|0,A=a,(s|=0)>>>0>15)return M=a,4;if(l=0|nn(0|(n|=0),0|(r|=0),52),T(),(0|(l&=15))>(0|s))return M=a,12;if(0|Ue(n,r,s,A)&&S(27795,27122,1327,27173),!(((0|t)>-1|-1==(0|t)&e>>>0>4294967295)&((0|(u=0|i[(h=A)+4>>2]))>(0|t)|((0|u)==(0|t)?(0|i[h>>2])>>>0>e>>>0:0))))return M=a,2;h=s-l|0,s=0|rn(0|s,0,52),c=T()|-15728641&r,i[(u=o)>>2]=s|n,i[u+4>>2]=c,u=0|nn(0|n,0|r,45),T();e:do{if(0|G(127&u)){if(0|l)for(A=1;;){if(!(!((u=0|rn(7,0,3*(15-A|0)|0))&n)&!((0|T())&r)))break e;if(!(A>>>0<l>>>0))break;A=A+1|0}if((0|h)<1)return M=a,0;for(u=15^l,r=-1,c=1,A=1;;){l=0|_t(7,0,l=h-c|0,((0|l)<0)<<31>>31),n=0|T();do{if(A){if(A=0|Kt(0|(A=0|Xt(0|(A=0|Zt(0|l,0|n,5,0)),0|T(),-5,-1)),0|T(),6,0),(0|t)>(0|(s=0|T()))|(0|t)==(0|s)&e>>>0>A>>>0){t=0|Qt(0|(t=0|Xt(0|e,0|t,-1,-1)),0|T(),0|A,0|s),A=0|T(),p=0|i[(d=o)>>2],d=0|i[d+4>>2],f=0|rn(7,0,0|(g=3*(u+r|0)|0)),d&=~T(),g=0|rn(0|(s=0|Xt(0|(r=0|Kt(0|t,0|A,0|l,0|n)),0|(e=0|T()),2,0)),0|T(),0|g),d=0|T()|d,i[(s=o)>>2]=g|p&~f,i[s+4>>2]=d,e=0|Qt(0|t,0|A,0|(e=0|Zt(0|r,0|e,0|l,0|n)),0|T()),A=0,t=0|T();break}f=0|i[(g=o)>>2],g=0|i[g+4>>2],p=0|rn(7,0,3*(u+r|0)|0),g&=~T(),i[(A=o)>>2]=f&~p,i[A+4>>2]=g,A=1;break}s=0|i[(f=o)>>2],f=0|i[f+4>>2],d=0|rn(7,0,0|(r=3*(u+r|0)|0)),f&=~T(),r=0|rn(0|(g=0|Kt(0|e,0|t,0|l,0|n)),0|(A=0|T()),0|r),f=0|T()|f,i[(p=o)>>2]=r|s&~d,i[p+4>>2]=f,e=0|Qt(0|e,0|t,0|(A=0|Zt(0|g,0|A,0|l,0|n)),0|T()),A=0,t=0|T()}while(0);if(!((0|h)>(0|c))){t=0;break}r=~c,c=c+1|0}return M=a,0|t}}while(0);if((0|h)<1)return M=a,0;for(s=15^l,A=1;;){if(p=0|_t(7,0,p=h-A|0,((0|p)<0)<<31>>31),g=0|T(),n=0|i[(c=o)>>2],c=0|i[c+4>>2],r=0|rn(7,0,0|(l=3*(s-A|0)|0)),c&=~T(),l=0|rn(0|(d=0|Kt(0|e,0|t,0|p,0|g)),0|(f=0|T()),0|l),c=0|T()|c,i[(u=o)>>2]=l|n&~r,i[u+4>>2]=c,e=0|Qt(0|e,0|t,0|(g=0|Zt(0|d,0|f,0|p,0|g)),0|T()),t=0|T(),(0|h)<=(0|A)){t=0;break}A=A+1|0}return M=a,0|t},_compactCells:function(e,t,n,r){t|=0;var s,o=0,a=0,A=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0,y=0,w=0,x=0,E=0,C=0,k=0,R=0,P=0,I=0,M=0;if(!(0|(n|=0))&!(0|(r|=0)))return 0;if(a=0|i[(o=e|=0)>>2],!0&!(15728640&(o=0|i[o+4>>2]))){if(!((0|r)>0|!(0|r)&n>>>0>0))return 0;if(i[(M=t)>>2]=a,i[M+4>>2]=o,1==(0|n)&!(0|r))return 0;o=1,a=0;do{I=0|i[4+(P=e+(o<<3)|0)>>2],i[(M=t+(o<<3)|0)>>2]=i[P>>2],i[M+4>>2]=I,o=0|Xt(0|o,0|a,1,0),a=0|T()}while((0|a)<(0|r)|(0|a)==(0|r)&o>>>0<n>>>0);return 0}if(!(I=0|Wt(s=n<<3)))return 13;if(ln(0|I,0|e,0|s),!(P=0|$t(n,8)))return Ht(I),13;e:for(;;){k=0|nn(0|(u=0|i[(o=I)>>2]),0|(o=0|i[o+4>>2]),52),T(),R=(k&=15)-1|0,C=!!(0|k),E=(0|r)>0|!(0|r)&n>>>0>0;t:do{if(C&E){if(v=0|rn(0|R,0,52),y=0|T(),R>>>0>15){if(!(!(0|u)&!(0|o))){M=16;break e}for(a=0,e=0;;){if(a=0|Xt(0|a,0|e,1,0),!((0|(e=0|T()))<(0|r)|(0|e)==(0|r)&a>>>0<n>>>0))break t;if(!(!(0|(x=0|i[(A=I+(a<<3)|0)>>2]))&!(0|(A=0|i[A+4>>2])))){o=A,M=16;break e}}}for(l=u,e=o,a=0,A=0;;){if(!(!(0|l)&!(0|e))){if(!(!0&!(117440512&e))){M=21;break e}if(h=0|nn(0|l,0|e,52),T(),(0|(h&=15))<(0|R)){o=12,M=27;break e}if((0|h)!=(0|R)&&(l|=v,e=-15728641&e|y,h>>>0>=k>>>0)){c=R;do{x=0|rn(7,0,3*(14-c|0)|0),c=c+1|0,l|=x,e=0|T()|e}while(c>>>0<h>>>0)}if(f=0|en(0|l,0|e,0|n,0|r),p=0|T(),!(!(0|(d=0|i[(h=c=P+(f<<3)|0)>>2]))&!(0|(h=0|i[h+4>>2])))){_=0,b=0;do{if((0|_)>(0|r)|(0|_)==(0|r)&b>>>0>n>>>0){M=31;break e}if((0|d)==(0|l)&(-117440513&h)==(0|e)){g=0|nn(0|d,0|h,56),T(),m=1+(g&=7)|0,x=0|nn(0|d,0|h,45),T();n:do{if(0|G(127&x)){if(d=0|nn(0|d,0|h,52),T(),!(d&=15)){h=6;break}for(h=1;;){if(!(!((x=0|rn(7,0,3*(15-h|0)|0))&l)&!((0|T())&e))){h=7;break n}if(!(h>>>0<d>>>0)){h=6;break}h=h+1|0}}else h=7}while(0);if((g+2|0)>>>0>h>>>0){M=41;break e}x=0|rn(0|m,0,56),e=T()|-117440513&e,i[(w=c)>>2]=0,i[w+4>>2]=0,l|=x}else f=0|Jt(0|(f=0|Xt(0|f,0|p,1,0)),0|T(),0|n,0|r),p=0|T();b=0|Xt(0|b,0|_,1,0),_=0|T(),d=0|i[(h=c=P+(f<<3)|0)>>2],h=0|i[h+4>>2]}while(!(!(0|d)&!(0|h)))}i[(x=c)>>2]=l,i[x+4>>2]=e}if(a=0|Xt(0|a,0|A,1,0),!((0|(A=0|T()))<(0|r)|(0|A)==(0|r)&a>>>0<n>>>0))break t;l=0|i[(e=I+(a<<3)|0)>>2],e=0|i[e+4>>2]}}}while(0);if(x=0|Xt(0|n,0|r,5,0),(w=0|T())>>>0<0|!(0|w)&x>>>0<11){M=85;break}if(x=0|Kt(0|n,0|r,6,0),T(),!(x=0|$t(x,8))){M=48;break}do{if(E){for(m=0,e=0,g=0,_=0;;){if(!(0|(a=0|i[(A=h=P+(m<<3)|0)>>2]))&!(0|(A=0|i[A+4>>2])))w=g;else{d=0|nn(0|a,0|A,56),T(),l=1+(d&=7)|0,f=-117440513&A,w=0|nn(0|a,0|A,45),T();t:do{if(0|G(127&w)){if(p=0|nn(0|a,0|A,52),T(),0|(p&=15))for(c=1;;){if(!(!(a&(w=0|rn(7,0,3*(15-c|0)|0)))&!(f&(0|T()))))break t;if(!(c>>>0<p>>>0))break;c=c+1|0}a|=A=0|rn(0|l,0,56),A=0|T()|f,i[(l=h)>>2]=a,i[l+4>>2]=A,l=d+2|0}}while(0);7==(0|l)?(i[(w=x+(e<<3)|0)>>2]=a,i[w+4>>2]=-117440513&A,e=0|Xt(0|e,0|g,1,0),w=0|T()):w=g}if(m=0|Xt(0|m,0|_,1,0),!((0|(_=0|T()))<(0|r)|(0|_)==(0|r)&m>>>0<n>>>0))break;g=w}if(E){if(b=R>>>0>15,v=0|rn(0|R,0,52),y=0|T(),!C){for(a=0,c=0,l=0,A=0;!(0|u)&!(0|o)||(i[(R=t+(a<<3)|0)>>2]=u,i[R+4>>2]=o,a=0|Xt(0|a,0|c,1,0),c=0|T()),l=0|Xt(0|l,0|A,1,0),(0|(A=0|T()))<(0|r)|(0|A)==(0|r)&l>>>0<n>>>0;)u=0|i[(o=I+(l<<3)|0)>>2],o=0|i[o+4>>2];o=w;break}for(a=0,c=0,A=0,l=0;;){do{if(!(!(0|u)&!(0|o))){if(p=0|nn(0|u,0|o,52),T(),b|(0|(p&=15))<(0|R)){M=80;break e}if((0|p)!=(0|R)){if(h=u|v,d=-15728641&o|y,p>>>0>=k>>>0){f=R;do{C=0|rn(7,0,3*(14-f|0)|0),f=f+1|0,h|=C,d=0|T()|d}while(f>>>0<p>>>0)}}else h=u,d=o;g=0|en(0|h,0|d,0|n,0|r),f=0,p=0,_=0|T();do{if((0|f)>(0|r)|(0|f)==(0|r)&p>>>0>n>>>0){M=81;break e}if((-117440513&(m=0|i[4+(C=P+(g<<3)|0)>>2]))==(0|d)&&(0|i[C>>2])==(0|h)){M=65;break}g=0|Jt(0|(C=0|Xt(0|g,0|_,1,0)),0|T(),0|n,0|r),_=0|T(),p=0|Xt(0|p,0|f,1,0),f=0|T(),C=P+(g<<3)|0}while((0|i[C>>2])!=(0|h)||(0|i[C+4>>2])!=(0|d));if(65==(0|M)&&(M=0,!0&100663296==(117440512&m)))break;i[(C=t+(a<<3)|0)>>2]=u,i[C+4>>2]=o,a=0|Xt(0|a,0|c,1,0),c=0|T()}}while(0);if(A=0|Xt(0|A,0|l,1,0),!((0|(l=0|T()))<(0|r)|(0|l)==(0|r)&A>>>0<n>>>0))break;u=0|i[(o=I+(A<<3)|0)>>2],o=0|i[o+4>>2]}o=w}else a=0,o=w}else a=0,e=0,o=0}while(0);if(cn(0|P,0,0|s),ln(0|I,0|x,e<<3),Ht(x),!(0|e)&!(0|o)){M=89;break}t=t+(a<<3)|0,r=o,n=e}if(16==(0|M))!0&!(117440512&o)?(o=4,M=27):M=21;else if(31==(0|M))S(27795,27122,620,27132);else{if(41==(0|M))return Ht(I),Ht(P),10;if(48==(0|M))return Ht(I),Ht(P),13;80==(0|M)?S(27795,27122,711,27132):81==(0|M)?S(27795,27122,723,27132):85==(0|M)&&(ln(0|t,0|I,n<<3),M=89)}return 21==(0|M)?(Ht(I),Ht(P),0|(M=5)):27==(0|M)?(Ht(I),Ht(P),0|(M=o)):89==(0|M)?(Ht(I),Ht(P),0|(M=0)):0},_constructCell:function(e,t,n,s){n|=0,s|=0;var o=0,a=0,A=0,l=0,c=0,u=0;if((e|=0)>>>0>15)return 4;if((t|=0)>>>0>121)return 17;A=0|rn(0|e,0,52),o=0|T(),l=0|rn(0|t,0,45),o=0|o|T()|134225919;e:do{if((0|e)>=1){for(l=1,A=!!(0|r[20528+t|0]),a=-1;;){if((t=0|i[n+(l+-1<<2)>>2])>>>0>6){o=18,t=10;break}if(!(!(0|t)|1^A)){if(1==(0|t)){o=19,t=10;break}A=0}if(c=0|rn(7,0,0|(u=3*(15-l|0)|0)),o&=~T(),a=(t=0|rn(0|t,((0|t)<0)<<31>>31,0|u))|a&~c,o=0|T()|o,!((0|l)<(0|e)))break e;l=l+1|0}if(10==(0|t))return 0|o}else a=-1}while(0);return i[(u=s)>>2]=a,i[u+4>>2]=o,0},_destroyLinkedMultiPolygon:ft,_directedEdgeToBoundary:Ce,_directedEdgeToCells:function(e,t,n){e|=0;var r,s,o,a=0;return r=M,M=M+16|0,a=r,!0&268435456==(2013265920&(t|=0))?(s=-2130706433&t|134217728,i[(o=n|=0)>>2]=e,i[o+4>>2]=s,i[a>>2]=0,t=0|nn(0|e,0|t,56),T(),a=0|O(e,s,7&t,a,n+8|0),M=r,0|a):(M=r,0|(a=6))},_edgeLengthKm:function(e,t,n){n|=0;var r,o=0,a=0,A=0,l=0,u=0,f=0,p=0;if(r=M,M=M+176|0,0|(e=0|Ce(e|=0,t|=0,l=r)))return l=e,A=+s[n>>3],A*=6371.007180918475,s[n>>3]=A,M=r,0|l;if(s[n>>3]=0,(0|(e=0|i[l>>2]))<=1)return l=0,A=0,A*=6371.007180918475,s[n>>3]=A,M=r,0|l;t=e+-1|0,e=0,o=+s[l+8>>3],a=+s[l+16>>3],A=0;do{f=o,o=+s[l+8+((e=e+1|0)<<4)>>3],p=+d(.5*(o-f)),u=a,a=+s[l+8+(e<<4)+8>>3],u=p*p+(u=+d(.5*(a-u)))*(+h(+f)*+h(+o)*u),A+=2*+_(+ +c(+u),+ +c(+(1-u)))}while((0|e)!=(0|t));return s[n>>3]=A,l=0,p=A,p*=6371.007180918475,s[n>>3]=p,M=r,0|l},_edgeLengthM:function(e,t,n){n|=0;var r,o=0,a=0,A=0,l=0,u=0,f=0,p=0;if(r=M,M=M+176|0,0|(e=0|Ce(e|=0,t|=0,l=r)))return l=e,A=+s[n>>3],A*=6371.007180918475,A*=1e3,s[n>>3]=A,M=r,0|l;if(s[n>>3]=0,(0|(e=0|i[l>>2]))<=1)return l=0,A=0,A*=6371.007180918475,A*=1e3,s[n>>3]=A,M=r,0|l;t=e+-1|0,e=0,o=+s[l+8>>3],a=+s[l+16>>3],A=0;do{f=o,o=+s[l+8+((e=e+1|0)<<4)>>3],p=+d(.5*(o-f)),u=a,a=+s[l+8+(e<<4)+8>>3],u=p*p+(u=+d(.5*(a-u)))*(+h(+f)*+h(+o)*u),A+=2*+_(+ +c(+u),+ +c(+(1-u)))}while((0|e)!=(0|t));return s[n>>3]=A,l=0,p=A,p*=6371.007180918475,p*=1e3,s[n>>3]=p,M=r,0|l},_edgeLengthRads:function(e,t,n){n|=0;var r,o=0,a=0,A=0,l=0,u=0,f=0,p=0;if(r=M,M=M+176|0,0|(e=0|Ce(e|=0,t|=0,l=r)))return M=r,0|e;if(s[n>>3]=0,(0|(e=0|i[l>>2]))<=1)return M=r,0;t=e+-1|0,e=0,o=+s[l+8>>3],a=+s[l+16>>3],A=0;do{f=o,o=+s[l+8+((e=e+1|0)<<4)>>3],p=+d(.5*(o-f)),u=a,a=+s[l+8+(e<<4)+8>>3],u=p*p+(u=+d(.5*(a-u)))*(+h(+o)*+h(+f)*u),A+=2*+_(+ +c(+u),+ +c(+(1-u)))}while((0|e)<(0|t));return s[n>>3]=A,M=r,0},_emscripten_replace_memory:function(e){return r=new Int8Array(e),i=new Int32Array(e),s=new Float64Array(e),n=e,!0},_free:Ht,_getBaseCellNumber:Be,_getDirectedEdgeDestination:function(e,t,n){e|=0,t|=0,n|=0;var r,s,o=0;return r=M,M=M+16|0,i[(o=r)>>2]=0,!0&268435456==(2013265920&t)?(s=0|nn(0|e,0|t,56),T(),o=0|O(e,-2130706433&t|134217728,7&s,o,n),M=r,0|o):(M=r,0|(o=6))},_getDirectedEdgeOrigin:function(e,t,n){return e|=0,n|=0,!0&268435456==(2013265920&(t|=0))?(i[n>>2]=e,i[n+4>>2]=-2130706433&t|134217728,0|(n=0)):0|(n=6)},_getHexagonAreaAvgKm2:At,_getHexagonAreaAvgM2:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20784+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgKm:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[20912+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgM:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(s[t>>3]=+s[21040+(e<<3)>>3],0|(t=0))},_getIcosahedronFaces:function e(t,n,r){r|=0;var s,o=0,a=0,A=0,l=0,c=0,u=0,h=0,d=0;s=M,M=M+128|0,h=s+112|0,A=s+96|0,d=s,a=0|nn(0|(t|=0),0|(n|=0),52),T(),c=15&a,i[h>>2]=c,l=0|nn(0|t,0|n,45),T(),l&=127;e:do{if(0|G(l)){if(0|c)for(o=1;;){if(!(!((u=0|rn(7,0,3*(15-o|0)|0))&t)&!((0|T())&n))){a=0;break e}if(!(o>>>0<c>>>0))break;o=o+1|0}if(!(1&a))return u=0|rn(c+1|0,0,52),d=T()|-15728641&n,d=0|e((u|t)&~(h=0|rn(7,0,3*(14-c|0)|0)),d&~T(),r),M=s,0|d;a=1}else a=0}while(0);if(!(o=0|Ke(t,n,A))){a?(Pe(A,h,d),u=5):(Ne(A,h,d),u=6);e:do{if(0|G(l))if(c)for(o=1;;){if(!(!((l=0|rn(7,0,3*(15-o|0)|0))&t)&!((0|T())&n))){t=2;break e}if(!(o>>>0<c>>>0)){t=5;break}o=o+1|0}else t=5;else t=2}while(0);cn(0|r,-1,t<<2);e:do{if(a)for(A=0;;){if(Me(l=d+(A<<4)|0,0|i[h>>2]),l=0|i[l>>2],-1==(0|(c=0|i[r>>2]))|(0|c)==(0|l))o=r;else{a=0;do{if((a=a+1|0)>>>0>=t>>>0){o=1;break e}c=0|i[(o=r+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(i[o>>2]=l,(A=A+1|0)>>>0>=u>>>0){o=0;break}}else for(A=0;;){if(Ie(l=d+(A<<4)|0,0|i[h>>2],0,1),l=0|i[l>>2],-1==(0|(c=0|i[r>>2]))|(0|c)==(0|l))o=r;else{a=0;do{if((a=a+1|0)>>>0>=t>>>0){o=1;break e}c=0|i[(o=r+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(i[o>>2]=l,(A=A+1|0)>>>0>=u>>>0){o=0;break}}}while(0)}return M=s,0|o},_getIndexDigit:function(e,t,n,r){return r|=0,((n|=0)-1|0)>>>0>14?0|(r=4):(n=0|nn(0|(e|=0),0|(t|=0),3*(15-n|0)|0),T(),i[r>>2]=7&n,0|(r=0))},_getNumCells:lt,_getPentagons:et,_getRes0Cells:function(e){e|=0;var t=0,n=0,r=0;t=0;do{rn(0|t,0,45),r=134225919|T(),i[(n=e+(t<<3)|0)>>2]=-1,i[n+4>>2]=r,t=t+1|0}while(122!=(0|t));return 0},_getResolution:function(e,t){return t=0|nn(0|(e|=0),0|(t|=0),52),T(),15&t},_greatCircleDistanceKm:at,_greatCircleDistanceM:function(e,t){e|=0;var n,r,i,o=0;return r=+s[(t|=0)>>3],n=+s[e>>3],o=(i=+d(.5*(r-n)))*i+(o=+d(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+h(+r)*+h(+n)*o),2*+_(+ +c(+o),+ +c(+(1-o)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(e,t){e|=0;var n,r,i,o=0;return r=+s[(t|=0)>>3],n=+s[e>>3],o=(i=+d(.5*(r-n)))*i+(o=+d(.5*(+s[t+8>>3]-+s[e+8>>3])))*(+h(+r)*+h(+n)*o),2*+_(+ +c(+o),+ +c(+(1-o)))},_gridDisk:L,_gridDiskDistances:N,_gridDistance:function(e,t,n,r,s){n|=0,r|=0,s|=0;var o,a,A=0,l=0;return a=M,M=M+32|0,l=a,0|(o=0|gt(e|=0,t|=0,e,t,A=a+12|0))?(M=a,0|(l=o)):0|(e=0|gt(e,t,n,r,l))?(M=a,0|(l=e)):(A=0|xe(A,l),i[(l=s)>>2]=A,i[l+4>>2]=((0|A)<0)<<31>>31,M=a,0|(l=0))},_gridPathCells:function(e,t,n,r,s){n|=0,r|=0,s|=0;var o,a,A=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0,y=0,w=0,x=0,E=0,C=0,k=0;if(a=M,M=M+48|0,c=a+12|0,C=a,!(A=0|gt(e|=0,t|=0,e,t,o=a+24|0))&&!(A=0|gt(e,t,n,r,c))){E=((0|(x=0|xe(o,c)))<0)<<31>>31,i[o>>2]=0,i[o+4>>2]=0,i[o+8>>2]=0,i[c>>2]=0,i[c+4>>2]=0,i[c+8>>2]=0,0|gt(e,t,e,t,o)&&S(27795,27538,692,27747),0|gt(e,t,n,r,c)&&S(27795,27538,697,27747),Ee(o),Ee(c),f=0|x?1/+(0|x):0,n=0|i[o>>2],b=f*+((0|i[c>>2])-n|0),r=0|i[(v=o+4|0)>>2],y=f*+((0|i[c+4>>2])-r|0),A=0|i[(w=o+8|0)>>2],f*=+((0|i[c+8>>2])-A|0),i[C>>2]=n,i[(p=C+4|0)>>2]=r,i[(g=C+8|0)>>2]=A;e:do{if((0|x)<0)A=0;else for(m=0,_=0;;){k=b*(h=+(_>>>0)+4294967296*+(0|m))+ +(0|n),u=y*h+ +(0|r),h=f*h+ +(0|A),n=~~+An(+k),c=~~+An(+u),A=~~+An(+h),k=+l(+(+(0|n)-k)),u=+l(+(+(0|c)-u)),h=+l(+(+(0|A)-h));do{if(!(k>u&k>h)){if(d=0-n|0,u>h){r=d-A|0;break}r=c,A=d-c|0;break}n=0-(c+A)|0,r=c}while(0);if(i[C>>2]=n,i[p>>2]=r,i[g>>2]=A,Te(C),0|(A=0|mt(e,t,C,s+(_<<3)|0)))break e;if(!((0|m)<(0|E)|(0|m)==(0|E)&_>>>0<x>>>0)){A=0;break e}n=0|Xt(0|_,0|m,1,0),m=r=0|T(),_=n,n=0|i[o>>2],r=0|i[v>>2],A=0|i[w>>2]}}while(0);return M=a,0|A}return M=a,0|A},_gridPathCellsSize:function(e,t,n,r,s){n|=0,r|=0,s|=0;var o,a=0,A=0,l=0;return o=M,M=M+32|0,l=o,(a=0|gt(e|=0,t|=0,e,t,A=o+12|0))||(a=0|gt(e,t,n,r,l))?(M=o,0|(l=a)):(r=0|Xt(0|(r=0|xe(A,l)),((0|r)<0)<<31>>31,1,0),A=0|T(),i[(l=s)>>2]=r,i[l+4>>2]=A,M=o,0|(l=0))},_gridRing:function(e,t,n,r){return 0|F(e|=0,t|=0,n|=0,r|=0)?(cn(0|r,0,48*n|0),0|(r=0|function(e,t,n,r){e|=0,t|=0,r|=0;var s,o=0,a=0,A=0,l=0,c=0,u=0,h=0,d=0;if(s=M,M=M+16|0,A=s,!(n|=0))return i[r>>2]=e,i[r+4>>2]=t,M=s,0;do{if((0|n)>=0){if((0|n)>13780509){if(0|(o=0|lt(15,A)))break;o=0|i[(a=A)>>2],a=0|i[a+4>>2]}else h=0|Zt(0|n,0|(o=((0|n)<0)<<31>>31),3,0),a=0|T(),o=0|Xt(0|n,0|o,1,0),o=0|Xt(0|(o=0|Zt(0|h,0|a,0|o,0|T())),0|T(),1,0),a=0|T(),i[(h=A)>>2]=o,i[h+4>>2]=a;if(u=0|$t(o,8)){if(!(h=0|$t(o,4))){Ht(u),o=13;break}if(0|(o=0|D(e,t,n,u,h,o,a,0))){Ht(u),Ht(h);break}if(t=0|i[A>>2],(0|(A=0|i[A+4>>2]))>0|!(0|A)&t>>>0>0){o=0,l=0,c=0;do{!(0|(a=0|i[(e=u+(l<<3)|0)>>2]))&!(0|(e=0|i[e+4>>2]))||(0|i[h+(l<<2)>>2])!=(0|n)||(i[(d=r+(o<<3)|0)>>2]=a,i[d+4>>2]=e,o=o+1|0),l=0|Xt(0|l,0|c,1,0),c=0|T()}while((0|c)<(0|A)|(0|c)==(0|A)&l>>>0<t>>>0)}Ht(u),Ht(h),o=0}else o=13}else o=2}while(0);return M=s,0|o}(e,t,n,r))):0|(r=0)},_gridRingUnsafe:F,_i64Add:Xt,_i64Subtract:Qt,_isPentagon:je,_isResClassIII:function(e,t){return t=0|nn(0|(e|=0),0|(t|=0),52),T(),1&t},_isValidCell:De,_isValidDirectedEdge:Se,_isValidIndex:function(e,t){e|=0;var n=0,i=0,s=0,o=0;if(!0&134217728==(-16777216&(t|=0))&&(i=0|nn(0|e,0|t,52),T(),i&=15,n=0|nn(0|e,0|t,45),T(),(n&=127)>>>0<=121)&&!(613566756&(o=0|rn(0|(s=0|nn(0|e,0|t,0|(o=3*(15^i)|0))),0|T(),0|o))&Qt(-1227133514,-1171,0|o,0|(s=0|T())))&!(4681&s&T())&&15==(0|i)|!(0|(o=0|nn(0|rn(0|~e,0|~t,0|(o=19+(3*i|0)|0)),0|T(),0|o)))&!(0|T())){if(!(0|r[20528+n|0]))return 1;if(!(0|e)&!(0|(n=8191&t)))return 1;if(o=0|sn(0|e,0|n),T(),(63-o|0)%3|0)return 1}return 0|Se(e,t)?0|(o=1):0|(o=1&!!(0|Bt(e,t)))},_isValidVertex:Bt,_latLngToCell:Ye,_llvm_ctlz_i64:sn,_llvm_maxnum_f64:on,_llvm_minnum_f64:an,_llvm_round_f64:An,_localIjToCell:function(e,t,n,r,s){var o,a;return e|=0,t|=0,n|=0,s|=0,a=M,M=M+16|0,o=a,(r|=0)?n=15:(n=0|function(e,t){t|=0;var n,r,s,o=0,a=0,A=0;if(a=0|i[(e|=0)>>2],i[t>>2]=a,A=0|i[e+4>>2],i[(r=t+4|0)>>2]=A,i[(s=t+8|0)>>2]=0,e=(o=(0|A)<(0|a))?a:A,(0|(o=o?A:a))<0){if(-2147483648==(0|o)||((0|e)>0?(2147483647-e|0)<(0|o):(-2147483648-e|0)>(0|o)))return 1;if((0|e)>-1?(-2147483648|e)>=(0|o):(-2147483648^e)<(0|o))return 1}return e=A-a|0,(0|a)<0?(o=0-a|0,i[r>>2]=e,i[s>>2]=o,i[t>>2]=0,a=0):(e=A,o=0),(0|e)<0&&(a=a-e|0,i[t>>2]=a,o=o-e|0,i[s>>2]=o,i[r>>2]=0,e=0),n=a-o|0,A=e-o|0,(0|o)<0?(i[t>>2]=n,i[r>>2]=A,i[s>>2]=0,e=A,A=n,o=0):A=a,(0|(a=(0|o)<(0|(a=(0|e)<(0|A)?e:A))?o:a))<=0||(i[t>>2]=A-a,i[r>>2]=e-a,i[s>>2]=o-a),0}(n,o))||(n=0|mt(e,t,o,s)),M=a,0|n},_malloc:Wt,_maxFaceCount:function(e,t,n){n|=0;var r=0,s=0;if(s=0|nn(0|(e|=0),0|(t|=0),45),T(),!(0|G(127&s)))return s=2,i[n>>2]=s,0;if(s=0|nn(0|e,0|t,52),T(),!(s&=15))return s=5,i[n>>2]=s,0;for(r=1;;){if(!(!((0|rn(7,0,3*(15-r|0)|0))&e)&!((0|T())&t))){r=2,e=6;break}if(!(r>>>0<s>>>0)){r=5,e=6;break}r=r+1|0}return 6==(0|e)?(i[n>>2]=r,0):0},_maxGridDiskSize:function(e,t){t|=0;var n=0,r=0,s=0;return(0|(e|=0))<0?0|(t=2):(0|e)>13780509?0|(t=0|lt(15,t)):(s=0|Zt(0|e,0|(n=((0|e)<0)<<31>>31),3,0),r=0|T(),n=0|Xt(0|e,0|n,1,0),n=0|Xt(0|(n=0|Zt(0|s,0|r,0|n,0|T())),0|T(),1,0),e=0|T(),i[t>>2]=n,i[t+4>>2]=e,0|(t=0))},_maxPolygonToCellsSize:function(e,t,n,r){e|=0,t|=0,r|=0;var s,o=0,a=0,A=0,l=0,c=0;if(s=M,M=M+48|0,o=s+16|0,a=s+8|0,A=s,0|(n=0|Et(n|=0)))return M=s,0|n;if(l=0|i[(c=e)+4>>2],i[(n=a)>>2]=i[c>>2],i[n+4>>2]=l,xt(a,o),!(n=0|te(o,t,A))){if(t=0|i[a>>2],(0|(a=0|i[e+8>>2]))>0){o=0|i[e+12>>2],n=0;do{t=(0|i[o+(n<<3)>>2])+t|0,n=n+1|0}while((0|n)<(0|a))}o=0|i[(n=A)>>2],(0|(n=0|i[n+4>>2]))<(0|(a=((0|t)<0)<<31>>31))|(0|n)==(0|a)&o>>>0<t>>>0?(i[(n=A)>>2]=t,i[n+4>>2]=a,n=a):t=o,l=0|Xt(0|t,0|n,12,0),c=0|T(),i[(n=A)>>2]=l,i[n+4>>2]=c,i[(n=r)>>2]=l,i[n+4>>2]=c,n=0}return M=s,0|n},_maxPolygonToCellsSizeExperimental:function(e,t,n,o){t|=0,n|=0,o|=0;var a,A,c=0,u=0,d=0,f=0,p=0,g=0,m=0,_=0;if(A=M,M=M+48|0,p=A+32|0,f=A+40|0,a=A,!(0|i[(e|=0)>>2]))return i[(g=o)>>2]=0,i[g+4>>2]=0,M=A,0;Oe(p,0,0,0),c=0|i[(d=p)>>2],d=0|i[d+4>>2];do{if(t>>>0>15)i[(g=a)>>2]=0,i[g+4>>2]=0,i[a+8>>2]=4,i[a+12>>2]=-1,n=a+29|0,i[(g=a+16|0)>>2]=0,i[g+4>>2]=0,i[g+8>>2]=0,r[g+12|0]=0,r[0|n]=0|r[0|f],r[n+1|0]=0|r[f+1|0],r[n+2|0]=0|r[f+2|0],n=4,g=9;else{if(0|(n=0|Et(n))){i[(p=a)>>2]=0,i[p+4>>2]=0,i[a+8>>2]=n,i[a+12>>2]=-1,g=a+29|0,i[(p=a+16|0)>>2]=0,i[p+4>>2]=0,i[p+8>>2]=0,r[p+12|0]=0,r[0|g]=0|r[0|f],r[g+1|0]=0|r[f+1|0],r[g+2|0]=0|r[f+2|0],g=9;break}if(!(n=0|$t(1+(0|i[e+8>>2])|0,32))){i[(g=a)>>2]=0,i[g+4>>2]=0,i[a+8>>2]=13,i[a+12>>2]=-1,n=a+29|0,i[(g=a+16|0)>>2]=0,i[g+4>>2]=0,i[g+8>>2]=0,r[g+12|0]=0,r[0|n]=0|r[0|f],r[n+1|0]=0|r[f+1|0],r[n+2|0]=0|r[f+2|0],n=13,g=9;break}Tt(e,n),i[(_=a)>>2]=c,i[_+4>>2]=d,i[(d=a+8|0)>>2]=0,i[a+12>>2]=t,i[a+20>>2]=e,i[a+24>>2]=n,r[a+28|0]=0,r[0|(c=a+29|0)]=0|r[0|f],r[c+1|0]=0|r[f+1|0],r[c+2|0]=0|r[f+2|0],i[a+16>>2]=3,m=+q(n),m*=+Q(n),u=+l(+ +s[n>>3]),u=m/+h(+ +an(+u,+ +l(+ +s[n+8>>3])))*6371.007180918475*6371.007180918475,n=0|i[(c=a+12|0)>>2];e:do{if((0|n)>0)do{if(At(n+-1|0,p),!(u/+s[p>>3]>10))break e;n=(_=0|i[c>>2])-1|0,i[c>>2]=n}while((0|_)>1)}while(0);if(vt(a),i[(c=o)>>2]=0,i[c+4>>2]=0,!(!(0|(n=0|i[(c=a)>>2]))&!(0|(c=0|i[c+4>>2]))))do{Ue(n,c,t,p),f=p,f=0|Xt(0|i[(e=o)>>2],0|i[e+4>>2],0|i[f>>2],0|i[f+4>>2]),e=0|T(),i[(_=o)>>2]=f,i[_+4>>2]=e,vt(a),n=0|i[(_=a)>>2],c=0|i[_+4>>2]}while(!(!(0|n)&!(0|c)));n=0|i[d>>2]}}while(0);return M=A,0|n},_memcpy:ln,_memset:cn,_originToDirectedEdges:function(e,t,n){n|=0;var r,s=0;return r=!(0|je(e|=0,t|=0)),t&=-2130706433,i[(s=n)>>2]=r?e:0,i[s+4>>2]=r?285212672|t:0,i[(s=n+8|0)>>2]=e,i[s+4>>2]=301989888|t,i[(s=n+16|0)>>2]=e,i[s+4>>2]=318767104|t,i[(s=n+24|0)>>2]=e,i[s+4>>2]=335544320|t,i[(s=n+32|0)>>2]=e,i[s+4>>2]=352321536|t,i[(n=n+40|0)>>2]=e,i[n+4>>2]=369098752|t,0},_pentagonCount:function(){return 12},_polygonToCells:function(e,t,n,r){e|=0,t|=0,r|=0;var s,o,a,A,l=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0,b=0,v=0,y=0,w=0,x=0,E=0,S=0,C=0,k=0,R=0,P=0,I=0,L=0,N=0,O=0,F=0,U=0;if(A=M,M=M+112|0,s=A+80|0,d=A+72|0,o=A,a=A+56|0,0|(l=0|Et(n|=0)))return M=A,0|l;if(!(U=0|Wt(32+(i[(f=e+8|0)>>2]<<5)|0)))return M=A,13;if(Tt(e,U),!(l=0|Et(n))){if(F=0|i[(O=e)+4>>2],i[(l=d)>>2]=i[O>>2],i[l+4>>2]=F,xt(d,s),l=0|te(s,t,o))O=0,F=0;else{if(l=0|i[d>>2],(0|(c=0|i[f>>2]))>0){u=0|i[e+12>>2],n=0;do{l=(0|i[u+(n<<3)>>2])+l|0,n=n+1|0}while((0|n)!=(0|c));n=l}else n=l;c=0|i[(l=o)>>2],(0|(l=0|i[l+4>>2]))<(0|(u=((0|n)<0)<<31>>31))|(0|l)==(0|u)&c>>>0<n>>>0?(i[(l=o)>>2]=n,i[l+4>>2]=u,l=u):n=c,O=0|Xt(0|n,0|l,12,0),F=0|T(),i[(l=o)>>2]=O,i[l+4>>2]=F,l=0}if(!l){if(!(n=0|$t(O,8)))return Ht(U),M=A,13;if(!(h=0|$t(O,8)))return Ht(U),Ht(n),M=A,13;i[(L=s)>>2]=0,i[L+4>>2]=0,N=0|i[(L=e)+4>>2],i[(l=d)>>2]=i[L>>2],i[l+4>>2]=N,l=0|j(d,O,F,t,s,n,h);e:do{if(l)Ht(n),Ht(h),Ht(U);else{t:do{if((0|i[f>>2])>0){for(u=e+12|0,c=0;l=0|j((0|i[u>>2])+(c<<3)|0,O,F,t,s,n,h),c=c+1|0,!(0|l);)if((0|c)>=(0|i[f>>2]))break t;Ht(n),Ht(h),Ht(U);break e}}while(0);(0|F)>0|!(0|F)&O>>>0>0&&cn(0|h,0,O<<3),L=0|i[(N=s)+4>>2];t:do{if((0|L)>0|!(0|L)&(0|i[N>>2])>>>0>0){R=n,P=h,I=n,L=h,N=n,l=n,S=n,C=h,k=h,n=h;n:for(;;){for(y=0,w=0,x=0,E=0,c=0,u=0;;){d=(h=o)+56|0;do{i[h>>2]=0,h=h+4|0}while((0|h)<(0|d));if(0|B(f=0|i[(t=R+(y<<3)|0)>>2],t=0|i[t+4>>2],1,o,0)){d=(h=o)+56|0;do{i[h>>2]=0,h=h+4|0}while((0|h)<(0|d));0|(h=0|$t(7,4))&&(D(f,t,1,o,h,7,0,0),Ht(h))}for(v=0;;){_=0|i[(b=o+(v<<3)|0)>>2],b=0|i[b+4>>2];r:do{if(!(0|_)&!(0|b))h=c,d=u;else{if(p=0|en(0|_,0|b,0|O,0|F),f=0|T(),!(!(0|(d=0|i[(t=h=r+(p<<3)|0)>>2]))&!(0|(t=0|i[t+4>>2])))){g=0,m=0;do{if((0|g)>(0|F)|(0|g)==(0|F)&m>>>0>O>>>0)break n;if((0|d)==(0|_)&(0|t)==(0|b)){h=c,d=u;break r}p=0|Jt(0|(h=0|Xt(0|p,0|f,1,0)),0|T(),0|O,0|F),f=0|T(),m=0|Xt(0|m,0|g,1,0),g=0|T(),d=0|i[(t=h=r+(p<<3)|0)>>2],t=0|i[t+4>>2]}while(!(!(0|d)&!(0|t)))}if(!(0|_)&!(0|b)){h=c,d=u;break}Ze(_,b,a),0|St(e,U,a)&&(m=0|Xt(0|c,0|u,1,0),u=0|T(),i[(g=h)>>2]=_,i[g+4>>2]=b,i[(c=P+(c<<3)|0)>>2]=_,i[c+4>>2]=b,c=m),h=c,d=u}}while(0);if((v=v+1|0)>>>0>=7)break;c=h,u=d}if(y=0|Xt(0|y,0|w,1,0),w=0|T(),x=0|Xt(0|x,0|E,1,0),E=0|T(),c=0|i[(u=s)>>2],!((0|E)<(0|(u=0|i[u+4>>2]))|(0|E)==(0|u)&x>>>0<c>>>0))break;c=h,u=d}if((0|u)>0|!(0|u)&c>>>0>0){c=0,u=0;do{i[(E=R+(c<<3)|0)>>2]=0,i[E+4>>2]=0,c=0|Xt(0|c,0|u,1,0),u=0|T(),x=0|i[(E=s)+4>>2]}while((0|u)<(0|x)|((0|u)==(0|x)?c>>>0<(0|i[E>>2])>>>0:0))}if(i[(E=s)>>2]=h,i[E+4>>2]=d,!((0|d)>0|!(0|d)&h>>>0>0))break t;v=n,y=k,w=N,x=C,E=P,n=S,k=l,C=I,S=v,l=y,N=L,L=w,I=x,P=R,R=E}Ht(I),Ht(L),Ht(U),l=1;break e}l=h}while(0);Ht(U),Ht(n),Ht(l),l=0}}while(0);return M=A,0|l}}return Ht(U),M=A,0|l},_polygonToCellsExperimental:function(e,t,n,s,o,a){s|=0,o|=0,a|=0;var A,l,c,u=0,h=0,d=0,f=0,p=0,g=0,m=0,_=0;c=M,M=M+160|0,h=c+64|0,p=c+112|0,_=c,function(e,t,n,s){e|=0,t|=0,n|=0,s|=0;var o,a,A,l=0,c=0,u=0,h=0;A=M,M=M+48|0,o=A+40|0,a=A,Oe(c=A+32|0,0,0,0),u=0|i[c>>2],c=0|i[c+4>>2];do{if(n>>>0<=15){if(0|(l=0|Et(s))){i[(s=a)>>2]=0,i[s+4>>2]=0,i[a+8>>2]=l,i[a+12>>2]=-1,u=a+29|0,i[(s=a+16|0)>>2]=0,i[s+4>>2]=0,i[s+8>>2]=0,r[s+12|0]=0,r[0|u]=0|r[0|o],r[u+1|0]=0|r[o+1|0],r[u+2|0]=0|r[o+2|0];break}if(l=0|$t(1+(0|i[t+8>>2])|0,32)){Tt(t,l),i[(h=a)>>2]=u,i[h+4>>2]=c,i[a+8>>2]=0,i[a+12>>2]=n,i[a+16>>2]=s,i[a+20>>2]=t,i[a+24>>2]=l,r[a+28|0]=0,r[0|(u=a+29|0)]=0|r[0|o],r[u+1|0]=0|r[o+1|0],r[u+2|0]=0|r[o+2|0];break}i[(s=a)>>2]=0,i[s+4>>2]=0,i[a+8>>2]=13,i[a+12>>2]=-1,u=a+29|0,i[(s=a+16|0)>>2]=0,i[s+4>>2]=0,i[s+8>>2]=0,r[s+12|0]=0,r[0|u]=0|r[0|o],r[u+1|0]=0|r[o+1|0],r[u+2|0]=0|r[o+2|0];break}i[(u=a)>>2]=0,i[u+4>>2]=0,i[a+8>>2]=4,i[a+12>>2]=-1,h=a+29|0,i[(u=a+16|0)>>2]=0,i[u+4>>2]=0,i[u+8>>2]=0,r[u+12|0]=0,r[0|h]=0|r[0|o],r[h+1|0]=0|r[o+1|0],r[h+2|0]=0|r[o+2|0]}while(0);vt(a),i[e>>2]=i[a>>2],i[e+4>>2]=i[a+4>>2],i[e+8>>2]=i[a+8>>2],i[e+12>>2]=i[a+12>>2],i[e+16>>2]=i[a+16>>2],i[e+20>>2]=i[a+20>>2],i[e+24>>2]=i[a+24>>2],i[e+28>>2]=i[a+28>>2],M=A}(f=c+80|0,e|=0,t|=0,n|=0),tt(h,0|i[(d=f)>>2],0|i[d+4>>2],t),A=0|i[(d=h)>>2],d=0|i[d+4>>2],u=0|i[f+8>>2],i[(g=p+4|0)>>2]=i[f>>2],i[g+4>>2]=i[f+4>>2],i[g+8>>2]=i[f+8>>2],i[g+12>>2]=i[f+12>>2],i[g+16>>2]=i[f+16>>2],i[g+20>>2]=i[f+20>>2],i[g+24>>2]=i[f+24>>2],i[g+28>>2]=i[f+28>>2],i[(g=_)>>2]=A,i[g+4>>2]=d,i[(g=_+8|0)>>2]=u,t=p,n=36+(e=_+12|0)|0;do{i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0}while((0|e)<(0|n));if(i[(p=_+48|0)>>2]=i[h>>2],i[p+4>>2]=i[h+4>>2],i[p+8>>2]=i[h+8>>2],i[p+12>>2]=i[h+12>>2],!(0|A)&!(0|d))return M=c,0|u;n=_+16|0,l=_+24|0,f=_+28|0,u=0,h=0,t=A,e=d;do{if(!((0|u)<(0|o)|(0|u)==(0|o)&h>>>0<s>>>0)){m=4;break}if(d=h,h=0|Xt(0|h,0|u,1,0),u=0|T(),i[(d=a+(d<<3)|0)>>2]=t,i[d+4>>2]=e,rt(p),!(0|(t=0|i[(e=p)>>2]))&!(0|(e=0|i[e+4>>2]))){if(vt(n),!(0|(e=0|i[(t=n)>>2]))&!(0|(t=0|i[t+4>>2]))){m=10;break}nt(e,t,0|i[f>>2],p),t=0|i[(e=p)>>2],e=0|i[e+4>>2]}i[(d=_)>>2]=t,i[d+4>>2]=e}while(!(!(0|t)&!(0|e)));return 4==(0|m)?(0|(t=0|i[(e=_+40|0)>>2])&&Ht(t),i[(m=_+16|0)>>2]=0,i[m+4>>2]=0,i[l>>2]=0,i[_+36>>2]=0,i[f>>2]=-1,i[_+32>>2]=0,i[e>>2]=0,nt(0,0,0,p),i[_>>2]=0,i[_+4>>2]=0,i[g>>2]=0,M=c,0|(_=14)):(10==(0|m)&&(i[_>>2]=0,i[_+4>>2]=0,i[g>>2]=i[l>>2]),_=0|i[g>>2],M=c,0|_)},_readInt64AsDoubleFromPointer:function(e){return+(+((0|i[(e|=0)>>2])>>>0)+4294967296*+(0|i[e+4>>2]))},_res0CellCount:function(){return 122},_round:un,_sbrk:hn,_sizeOfCellBoundary:function(){return 168},_sizeOfCoordIJ:function(){return 8},_sizeOfGeoLoop:function(){return 8},_sizeOfGeoPolygon:function(){return 16},_sizeOfH3Index:function(){return 8},_sizeOfLatLng:function(){return 16},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompactCells:function(e,t,n,r,s,o,a){e|=0,r|=0,s|=0,o|=0;var A,l=0,c=0,u=0,h=0,d=0,f=0,p=0,g=0;if(A=M,M=M+16|0,g=A,!((0|(n|=0))>0|!(0|n)&(t|=0)>>>0>0))return M=A,0;if((0|(a|=0))>=16)return M=A,12;f=0,p=0,d=0,l=0;e:for(;;){if(h=0|nn(0|(c=0|i[(u=e+(f<<3)|0)>>2]),0|(u=0|i[u+4>>2]),52),T(),(15&h)>(0|a)){l=12,c=11;break}if(tt(g,c,u,a),!(0|(u=0|i[(h=g)>>2]))&!(0|(h=0|i[h+4>>2])))c=d;else{c=d;do{if(!((0|l)<(0|o)|(0|l)==(0|o)&c>>>0<s>>>0)){c=10;break e}i[(d=r+(c<<3)|0)>>2]=u,i[d+4>>2]=h,c=0|Xt(0|c,0|l,1,0),l=0|T(),rt(g),u=0|i[(d=g)>>2],h=0|i[d+4>>2]}while(!(!(0|u)&!(0|h)))}if(f=0|Xt(0|f,0|p,1,0),!((0|(p=0|T()))<(0|n)|(0|p)==(0|n)&f>>>0<t>>>0)){l=0,c=11;break}d=c}return 10==(0|c)?(M=A,0|(g=14)):11==(0|c)?(M=A,0|l):0},_uncompactCellsSize:function(e,t,n,r,s){e|=0,t|=0,n|=0,r|=0,s|=0;var o,a,A=0,l=0,c=0,u=0,h=0,d=0;a=M,M=M+16|0,o=a;e:do{if((0|n)>0|!(0|n)&t>>>0>0){for(h=0,l=0,A=0,d=0;;){if(!(!(0|(c=0|i[(u=e+(h<<3)|0)>>2]))&!(0|(u=0|i[u+4>>2]))||(u=!(0|Ue(c,u,r,o)),l=0|Xt(0|i[(c=o)>>2],0|i[c+4>>2],0|l,0|A),A=0|T(),u))){A=12;break}if(h=0|Xt(0|h,0|d,1,0),!((0|(d=0|T()))<(0|n)|(0|d)==(0|n)&h>>>0<t>>>0))break e}return M=a,0|A}l=0,A=0}while(0);return i[s>>2]=l,i[s+4>>2]=A,M=a,0},_vertexToLatLng:function(e,t,n){n|=0;var r,s,o,a,A=0,l=0;return a=M,M=M+192|0,s=a,o=a+168|0,A=0|nn(0|(e|=0),0|(t|=0),56),T(),A&=7,0|(r=0|Ke(e,l=-2130706433&t|134217728,o))?(M=a,0|(l=r)):(t=0|nn(0|e,0|t,52),T(),t&=15,0|je(e,l)?Re(o,t,A,1,s):Le(o,t,A,1,s),l=s+8|0,i[n>>2]=i[l>>2],i[n+4>>2]=i[l+4>>2],i[n+8>>2]=i[l+8>>2],i[n+12>>2]=i[l+12>>2],M=a,0|(l=0))},establishStackSpace:function(e,t){M=e|=0},stackAlloc:function(e){var t;return t=M,M=15+(M=M+(e|=0)|0)&-16,0|t},stackRestore:function(e){M=e|=0},stackSave:function(){return 0|M}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{b:function(e){A=e},c:function(){return A},d:function(e,t,n,r){ne("Assertion failed: "+b(e)+", at: "+[t?b(t):"unknown filename",n,r?b(r):"unknown function"])},e:function(e){return n.___errno_location&&(p[n.___errno_location()>>2]=e),e},f:G,g:function(e,t,n){d.set(d.subarray(t,t+n),e)},h:function(e){var t=G(),n=16777216,r=2130706432;if(e>r)return!1;for(var i=Math.max(t,16777216);i<e;)i=i<=536870912?v(2*i,n):Math.min(v((3*i+2147483648)/4,n),r);return!!function(e){try{var t=new ArrayBuffer(e);if(t.byteLength!=e)return;return new Int8Array(t).set(h),H(t),y(t),1}catch(ys){}}(i)},i:function(e){ne("OOM")},o:28640,p:28624},u);n.___divdi3=W.___divdi3,n.___muldi3=W.___muldi3,n.___remdi3=W.___remdi3,n.___uremdi3=W.___uremdi3,n._areNeighborCells=W._areNeighborCells,n._bitshift64Ashr=W._bitshift64Ashr,n._bitshift64Lshr=W._bitshift64Lshr,n._bitshift64Shl=W._bitshift64Shl,n._calloc=W._calloc,n._cellAreaKm2=W._cellAreaKm2,n._cellAreaM2=W._cellAreaM2,n._cellAreaRads2=W._cellAreaRads2,n._cellToBoundary=W._cellToBoundary,n._cellToCenterChild=W._cellToCenterChild,n._cellToChildPos=W._cellToChildPos,n._cellToChildren=W._cellToChildren,n._cellToChildrenSize=W._cellToChildrenSize,n._cellToLatLng=W._cellToLatLng,n._cellToLocalIj=W._cellToLocalIj,n._cellToParent=W._cellToParent,n._cellToVertex=W._cellToVertex,n._cellToVertexes=W._cellToVertexes,n._cellsToDirectedEdge=W._cellsToDirectedEdge,n._cellsToLinkedMultiPolygon=W._cellsToLinkedMultiPolygon,n._childPosToCell=W._childPosToCell,n._compactCells=W._compactCells,n._constructCell=W._constructCell,n._destroyLinkedMultiPolygon=W._destroyLinkedMultiPolygon,n._directedEdgeToBoundary=W._directedEdgeToBoundary,n._directedEdgeToCells=W._directedEdgeToCells,n._edgeLengthKm=W._edgeLengthKm,n._edgeLengthM=W._edgeLengthM,n._edgeLengthRads=W._edgeLengthRads;var H=n._emscripten_replace_memory=W._emscripten_replace_memory;n._free=W._free,n._getBaseCellNumber=W._getBaseCellNumber,n._getDirectedEdgeDestination=W._getDirectedEdgeDestination,n._getDirectedEdgeOrigin=W._getDirectedEdgeOrigin,n._getHexagonAreaAvgKm2=W._getHexagonAreaAvgKm2,n._getHexagonAreaAvgM2=W._getHexagonAreaAvgM2,n._getHexagonEdgeLengthAvgKm=W._getHexagonEdgeLengthAvgKm,n._getHexagonEdgeLengthAvgM=W._getHexagonEdgeLengthAvgM,n._getIcosahedronFaces=W._getIcosahedronFaces,n._getIndexDigit=W._getIndexDigit,n._getNumCells=W._getNumCells,n._getPentagons=W._getPentagons,n._getRes0Cells=W._getRes0Cells,n._getResolution=W._getResolution,n._greatCircleDistanceKm=W._greatCircleDistanceKm,n._greatCircleDistanceM=W._greatCircleDistanceM,n._greatCircleDistanceRads=W._greatCircleDistanceRads,n._gridDisk=W._gridDisk,n._gridDiskDistances=W._gridDiskDistances,n._gridDistance=W._gridDistance,n._gridPathCells=W._gridPathCells,n._gridPathCellsSize=W._gridPathCellsSize,n._gridRing=W._gridRing,n._gridRingUnsafe=W._gridRingUnsafe,n._i64Add=W._i64Add,n._i64Subtract=W._i64Subtract,n._isPentagon=W._isPentagon,n._isResClassIII=W._isResClassIII,n._isValidCell=W._isValidCell,n._isValidDirectedEdge=W._isValidDirectedEdge,n._isValidIndex=W._isValidIndex,n._isValidVertex=W._isValidVertex,n._latLngToCell=W._latLngToCell,n._llvm_ctlz_i64=W._llvm_ctlz_i64,n._llvm_maxnum_f64=W._llvm_maxnum_f64,n._llvm_minnum_f64=W._llvm_minnum_f64,n._llvm_round_f64=W._llvm_round_f64,n._localIjToCell=W._localIjToCell,n._malloc=W._malloc,n._maxFaceCount=W._maxFaceCount,n._maxGridDiskSize=W._maxGridDiskSize,n._maxPolygonToCellsSize=W._maxPolygonToCellsSize,n._maxPolygonToCellsSizeExperimental=W._maxPolygonToCellsSizeExperimental,n._memcpy=W._memcpy,n._memset=W._memset,n._originToDirectedEdges=W._originToDirectedEdges,n._pentagonCount=W._pentagonCount,n._polygonToCells=W._polygonToCells,n._polygonToCellsExperimental=W._polygonToCellsExperimental,n._readInt64AsDoubleFromPointer=W._readInt64AsDoubleFromPointer,n._res0CellCount=W._res0CellCount,n._round=W._round,n._sbrk=W._sbrk,n._sizeOfCellBoundary=W._sizeOfCellBoundary,n._sizeOfCoordIJ=W._sizeOfCoordIJ,n._sizeOfGeoLoop=W._sizeOfGeoLoop,n._sizeOfGeoPolygon=W._sizeOfGeoPolygon,n._sizeOfH3Index=W._sizeOfH3Index,n._sizeOfLatLng=W._sizeOfLatLng,n._sizeOfLinkedGeoPolygon=W._sizeOfLinkedGeoPolygon,n._uncompactCells=W._uncompactCells,n._uncompactCellsSize=W._uncompactCellsSize,n._vertexToLatLng=W._vertexToLatLng,n.establishStackSpace=W.establishStackSpace;var $,X,Q=n.stackAlloc=W.stackAlloc,Y=n.stackRestore=W.stackRestore,q=n.stackSave=W.stackSave;if(n.asm=W,n.cwrap=function(e,t,n,r){var i=(n=n||[]).every(function(e){return"number"===e});return"string"!==t&&i&&!r?c(e):function(){return function(e,t,n,r){var i={string:function(e){var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);!function(e,t,n){!function(e,t,n,r){if(!(r>0))return 0;for(var i=n+r-1,s=0;s<e.length;++s){var o=e.charCodeAt(s);if(o>=55296&&o<=57343&&(o=65536+((1023&o)<<10)|1023&e.charCodeAt(++s)),o<=127){if(n>=i)break;t[n++]=o}else if(o<=2047){if(n+1>=i)break;t[n++]=192|o>>6,t[n++]=128|63&o}else if(o<=65535){if(n+2>=i)break;t[n++]=224|o>>12,t[n++]=128|o>>6&63,t[n++]=128|63&o}else{if(n+3>=i)break;t[n++]=240|o>>18,t[n++]=128|o>>12&63,t[n++]=128|o>>6&63,t[n++]=128|63&o}}t[n]=0}(e,d,t,n)}(e,t=Q(n),n)}return t},array:function(e){var t,n,r=Q(e.length);return t=e,n=r,h.set(t,n),r}},s=c(e),o=[],a=0;if(r)for(var A=0;A<r.length;A++){var l=i[n[A]];l?(0===a&&(a=q()),o[A]=l(r[A])):o[A]=r[A]}var u,f=s.apply(null,o);return u=f,f="string"===t?b(u):"boolean"===t?Boolean(u):u,0!==a&&Y(a),f}(e,t,n,arguments)}},n.setValue=function(e,t,n,r){switch("*"===(n=n||"i8").charAt(n.length-1)&&(n="i32"),n){case"i1":case"i8":h[0|e]=t;break;case"i16":f[e>>1]=t;break;case"i32":p[e>>2]=t;break;case"i64":O=[t>>>0,(D=t,+P(D)>=1?D>0?(0|L(+M(D/4294967296),4294967295))>>>0:~~+I((D-+(~~D>>>0))/4294967296)>>>0:0)],p[e>>2]=O[0],p[e+4>>2]=O[1];break;case"float":g[e>>2]=t;break;case"double":m[e>>3]=t;break;default:ne("invalid type for setValue: "+n)}},n.getValue=function(e,t,n){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return h[0|e];case"i16":return f[e>>1];case"i32":case"i64":return p[e>>2];case"float":return g[e>>2];case"double":return m[e>>3];default:ne("invalid type for getValue: "+t)}return null},F){j(F)||($=F,F=n.locateFile?n.locateFile($,s):s+$),N++,n.monitorRunDependencies&&n.monitorRunDependencies(N);var K=function(e){e.byteLength&&(e=new Uint8Array(e)),d.set(e,8),n.memoryInitializerRequest&&delete n.memoryInitializerRequest.response,function(){if(N--,n.monitorRunDependencies&&n.monitorRunDependencies(N),0==N&&B){var e=B;B=null,e()}}()},Z=function(){i(F,K,function(){throw"could not load memory initializer "+F})},J=V(F);if(J)K(J.buffer);else if(n.memoryInitializerRequest){var ee=function(){var e=n.memoryInitializerRequest,t=e.response;if(200!==e.status&&0!==e.status){var r=V(n.memoryInitializerRequestURL);if(!r)return void Z();t=r.buffer}K(t)};n.memoryInitializerRequest.response?setTimeout(ee,0):n.memoryInitializerRequest.addEventListener("load",ee)}else Z()}function te(e){function t(){X||(X=!0,l||(x(T),x(S),n.onRuntimeInitialized&&n.onRuntimeInitialized(),function(){if(n.postRun)for("function"==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)R(n.postRun.shift());x(C)}()))}N>0||(function(){if(n.preRun)for("function"==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)k(n.preRun.shift());x(E)}(),N>0||(n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),t()},1)):t()))}function ne(e){throw n.onAbort&&n.onAbort(e),o(e+=""),a(e),l=!0,"abort("+e+"). Build with -s ASSERTIONS=1 for more info."}if(B=function e(){X||te(),X||(B=e)},n.run=te,n.abort=ne,n.preInit)for("function"==typeof n.preInit&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return te(),e}("object"==typeof km?km:{}),Rm="number",Pm={0:"Success",1:"The operation failed but a more specific error is not available",2:"Argument was outside of acceptable range",3:"Latitude or longitude arguments were outside of acceptable range",4:"Resolution argument was outside of acceptable range",5:"Cell argument was not valid",6:"Directed edge argument was not valid",7:"Undirected edge argument was not valid",8:"Vertex argument was not valid",9:"Pentagon distortion was encountered",10:"Duplicate input",11:"Cell arguments were not neighbors",12:"Cell arguments had incompatible resolutions",13:"Memory allocation failed",14:"Bounds of provided memory were insufficient",15:"Mode or flags argument was not valid",16:"Index argument was not valid",17:"Base cell number was outside of acceptable range",18:"Child indexing digits invalid",19:"Child indexing digits refer to a deleted subsequence"},Im={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function Mm(e,t,n){var r=n&&"value"in n,i=new Error((e[t]||"Unknown error")+" (code: "+t+(r?", value: "+n.value:"")+")");return i.code=t,i}function Lm(e,t){return Mm(Pm,e,2===arguments.length?{value:t}:{})}function Nm(e,t){return Mm(Im,e,2===arguments.length?{value:t}:{})}function Bm(e){if(0!==e)throw Lm(e)}var Dm={};[["sizeOfH3Index",Rm],["sizeOfLatLng",Rm],["sizeOfCellBoundary",Rm],["sizeOfGeoLoop",Rm],["sizeOfGeoPolygon",Rm],["sizeOfLinkedGeoPolygon",Rm],["sizeOfCoordIJ",Rm],["readInt64AsDoubleFromPointer",Rm],["isValidCell",Rm,[Rm,Rm]],["isValidIndex",Rm,[Rm,Rm]],["latLngToCell",Rm,[Rm,Rm,Rm,Rm]],["cellToLatLng",Rm,[Rm,Rm,Rm]],["cellToBoundary",Rm,[Rm,Rm,Rm]],["maxGridDiskSize",Rm,[Rm,Rm]],["gridDisk",Rm,[Rm,Rm,Rm,Rm]],["gridDiskDistances",Rm,[Rm,Rm,Rm,Rm,Rm]],["gridRing",Rm,[Rm,Rm,Rm,Rm]],["gridRingUnsafe",Rm,[Rm,Rm,Rm,Rm]],["maxPolygonToCellsSize",Rm,[Rm,Rm,Rm,Rm]],["polygonToCells",Rm,[Rm,Rm,Rm,Rm]],["maxPolygonToCellsSizeExperimental",Rm,[Rm,Rm,Rm,Rm]],["polygonToCellsExperimental",Rm,[Rm,Rm,Rm,Rm,Rm,Rm]],["cellsToLinkedMultiPolygon",Rm,[Rm,Rm,Rm]],["destroyLinkedMultiPolygon",null,[Rm]],["compactCells",Rm,[Rm,Rm,Rm,Rm]],["uncompactCells",Rm,[Rm,Rm,Rm,Rm,Rm,Rm]],["uncompactCellsSize",Rm,[Rm,Rm,Rm,Rm,Rm]],["isPentagon",Rm,[Rm,Rm]],["isResClassIII",Rm,[Rm,Rm]],["getBaseCellNumber",Rm,[Rm,Rm]],["getResolution",Rm,[Rm,Rm]],["getIndexDigit",Rm,[Rm,Rm,Rm]],["constructCell",Rm,[Rm,Rm,Rm,Rm]],["maxFaceCount",Rm,[Rm,Rm,Rm]],["getIcosahedronFaces",Rm,[Rm,Rm,Rm]],["cellToParent",Rm,[Rm,Rm,Rm,Rm]],["cellToChildren",Rm,[Rm,Rm,Rm,Rm]],["cellToCenterChild",Rm,[Rm,Rm,Rm,Rm]],["cellToChildrenSize",Rm,[Rm,Rm,Rm,Rm]],["cellToChildPos",Rm,[Rm,Rm,Rm,Rm]],["childPosToCell",Rm,[Rm,Rm,Rm,Rm,Rm,Rm]],["areNeighborCells",Rm,[Rm,Rm,Rm,Rm,Rm]],["cellsToDirectedEdge",Rm,[Rm,Rm,Rm,Rm,Rm]],["getDirectedEdgeOrigin",Rm,[Rm,Rm,Rm]],["getDirectedEdgeDestination",Rm,[Rm,Rm,Rm]],["isValidDirectedEdge",Rm,[Rm,Rm]],["directedEdgeToCells",Rm,[Rm,Rm,Rm]],["originToDirectedEdges",Rm,[Rm,Rm,Rm]],["directedEdgeToBoundary",Rm,[Rm,Rm,Rm]],["gridDistance",Rm,[Rm,Rm,Rm,Rm,Rm]],["gridPathCells",Rm,[Rm,Rm,Rm,Rm,Rm]],["gridPathCellsSize",Rm,[Rm,Rm,Rm,Rm,Rm]],["cellToLocalIj",Rm,[Rm,Rm,Rm,Rm,Rm,Rm]],["localIjToCell",Rm,[Rm,Rm,Rm,Rm,Rm]],["getHexagonAreaAvgM2",Rm,[Rm,Rm]],["getHexagonAreaAvgKm2",Rm,[Rm,Rm]],["getHexagonEdgeLengthAvgM",Rm,[Rm,Rm]],["getHexagonEdgeLengthAvgKm",Rm,[Rm,Rm]],["greatCircleDistanceM",Rm,[Rm,Rm]],["greatCircleDistanceKm",Rm,[Rm,Rm]],["greatCircleDistanceRads",Rm,[Rm,Rm]],["cellAreaM2",Rm,[Rm,Rm,Rm]],["cellAreaKm2",Rm,[Rm,Rm,Rm]],["cellAreaRads2",Rm,[Rm,Rm,Rm]],["edgeLengthM",Rm,[Rm,Rm,Rm]],["edgeLengthKm",Rm,[Rm,Rm,Rm]],["edgeLengthRads",Rm,[Rm,Rm,Rm]],["getNumCells",Rm,[Rm,Rm]],["getRes0Cells",Rm,[Rm]],["res0CellCount",Rm],["getPentagons",Rm,[Rm,Rm]],["pentagonCount",Rm],["cellToVertex",Rm,[Rm,Rm,Rm,Rm]],["cellToVertexes",Rm,[Rm,Rm,Rm]],["vertexToLatLng",Rm,[Rm,Rm,Rm]],["isValidVertex",Rm,[Rm,Rm]]].forEach(function(e){Dm[e[0]]=km.cwrap.apply(km,e)});var Om=16,Fm=Dm.sizeOfH3Index(),Um=Dm.sizeOfLatLng(),jm=Dm.sizeOfCellBoundary();Dm.sizeOfGeoPolygon(),Dm.sizeOfGeoLoop(),Dm.sizeOfLinkedGeoPolygon(),Dm.sizeOfCoordIJ();var Gm=/[^0-9a-fA-F]/;function zm(e){if(Array.isArray(e)&&2===e.length&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if("string"!=typeof e||Gm.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),Om);return[parseInt(e.substring(e.length-8),Om),t]}function Vm(e){if(e>=0)return e.toString(Om);var t=Wm(8,(e&=2147483647).toString(Om));return(parseInt(t[0],Om)+8).toString(Om)+t.substring(1)}function Wm(e,t){for(var n=e-t.length,r="",i=0;i<n;i++)r+="0";return r+t}function Hm(e){return 180*km.getValue(e,"double")/Math.PI}function $m(e){return[Hm(e+8),Hm(e)]}function Xm(e){var t=zm(e),n=t[0],r=t[1];return Boolean(Dm.isPentagon(n,r))}function Qm(e){var t=zm(e),n=t[0],r=t[1];return Dm.isValidCell(n,r)?Dm.getResolution(n,r):-1}function Ym(e,t,n){var r=km._malloc(Um);km.HEAPF64.set([e,t].map(Zm),r/8);var i=km._malloc(Fm);try{return Bm(Dm.latLngToCell(r,n,i)),function(e){if(!e)throw Nm(1002);return e}(function(e,t){void 0===t&&(t=0);var n=km.getValue(e+Fm*t,"i32"),r=km.getValue(e+Fm*t+4,"i32");return r?function(e,t){return Vm(t)+Wm(8,Vm(e))}(n,r):null}(i))}finally{km._free(i),km._free(r)}}function qm(e){var t,n=km._malloc(Um),r=zm(e),i=r[0],s=r[1];try{return Bm(Dm.cellToLatLng(i,s,n)),[Hm(t=n),Hm(t+8)]}finally{km._free(n)}}function Km(e,t){!function(e){if("number"!=typeof e||e<0||e>15||Math.floor(e)!==e)throw Lm(4,e)}(e);var n,r,i=km._malloc(8);try{switch(t){case"m":Bm(Dm.getHexagonEdgeLengthAvgM(e,i));break;case"km":Bm(Dm.getHexagonEdgeLengthAvgKm(e,i));break;default:throw Nm(1e3,t)}return n=i,void 0===r&&(r=0),km.getValue(n+8*r,"double")}finally{km._free(i)}}function Zm(e){return e*Math.PI/180}function Jm(e,t){t=void 0===t?e[0][0]:t;for(const n of e){const e=n[0]-t;e>180?n[0]-=360:e<-180&&(n[0]+=360)}}function e_(e,t,n){const r=e(t,n),[i,s]=qm(r);return[s,i]}function t_(e,t=1){const n=function(e){var t=km._malloc(jm),n=zm(e),r=n[0],i=n[1];try{return Bm(Dm.cellToBoundary(r,i,t)),function(e){for(var t=km.getValue(e,"i32"),n=e+8,r=[],i=$m,s=0;s<2*t;s+=2)r.push(i(n+8*s));return r.push(r[0]),r}(t)}finally{km._free(t)}}(e);return 1!==t?function(e,t,n){const[r,i]=qm(e),s=t.length;Jm(t,i);const o=t[0]===t[s-1]?s-1:s;for(let a=0;a<o;a++)t[a][0]=Oa(i,t[a][0],n),t[a][1]=Oa(r,t[a][1],n)}(e,n,t):Jm(n),n}const n_={...Cm.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:e=>e.hexagon},extruded:!0};class r_ extends hg{initializeState(){r_._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:t}){if(!0!==e.highPrecision&&(t.dataChanged||t.updateTriggersChanged&&t.updateTriggersChanged.getHexagon)){const e=this._calculateH3DataProps();this.setState(e)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,t=!1,n=!1;const{iterable:r,objectInfo:i}=up(this.props.data);for(const s of r){i.index++;const r=this.props.getHexagon(s,i),o=Qm(r);if(e<0){if(e=o,!this.props.highPrecision)break}else if(e!==o){n=!0;break}if(Xm(r)){t=!0;break}}return{resolution:e,edgeLengthKM:e>=0?Km(e,"km"):0,hasMultipleRes:n,hasPentagon:t}}_shouldUseHighPrecision(){if("auto"===this.props.highPrecision){const{resolution:e,hasPentagon:t,hasMultipleRes:n}=this.state,{viewport:r}=this.context;return Boolean(null==r?void 0:r.resolution)||n||t||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;const{resolution:t,edgeLengthKM:n,centerHex:r}=this.state;if(t<0)return;const i=this.props.centerHexagon||Ym(e.latitude,e.longitude,t);if(r===i)return;if(r)try{if(function(e,t){var n,r=zm(e),i=r[0],s=r[1],o=zm(t),a=o[0],A=o[1],l=km._malloc(8);try{return Bm(Dm.gridDistance(i,s,a,A,l)),n=l,Dm.readInt64AsDoubleFromPointer(n)}finally{km._free(l)}}(r,i)*n<10)return}catch{}const{unitsPerMeter:s}=e.distanceScales;let o=t_(i);const[a,A]=qm(i),[l,c]=e.projectFlat([A,a]);o=o.map(t=>{const n=e.projectFlat(t);return[(n[0]-l)/s[0],(n[1]-c)/s[1]]}),this.setState({centerHex:i,vertices:o})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){const{elevationScale:e,material:t,coverage:n,extruded:r,wireframe:i,stroked:s,filled:o,lineWidthUnits:a,lineWidthScale:A,lineWidthMinPixels:l,lineWidthMaxPixels:c,getFillColor:u,getElevation:h,getLineColor:d,getLineWidth:f,transitions:p,updateTriggers:g}=this.props;return{elevationScale:e,extruded:r,coverage:n,wireframe:i,stroked:s,filled:o,lineWidthUnits:a,lineWidthScale:A,lineWidthMinPixels:l,lineWidthMaxPixels:c,material:t,getElevation:h,getFillColor:u,getLineColor:d,getLineWidth:f,transitions:p,updateTriggers:{getFillColor:g.getFillColor,getElevation:g.getElevation,getLineColor:g.getLineColor,getLineWidth:g.getLineWidth}}}_renderPolygonLayer(){const{data:e,getHexagon:t,updateTriggers:n,coverage:r}=this.props,i=this.getSubLayerClass("hexagon-cell-hifi",Cm),s=this._getForwardProps();return s.updateTriggers.getPolygon=function(e,t){let n;return n=null==e?t:"object"==typeof e?{...e,coverage:t}:{getHexagon:e,coverage:t},n}(n.getHexagon,r),new i(s,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:s.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(e,n)=>function(e){const t=new Float64Array(2*e.length);let n=0;for(const r of e)t[n++]=r[0],t[n++]=r[1];return t}(t_(t(e,n),r))})}_renderColumnLayer(){const{data:e,getHexagon:t,updateTriggers:n}=this.props,r=this.getSubLayerClass("hexagon-cell",Xg),i=this._getForwardProps();return i.updateTriggers.getPosition=n.getHexagon,new r(i,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:i.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:e_.bind(null,t)})}}r_.defaultProps=n_,r_.layerName="H3HexagonLayer",r_._checkH3Lib=()=>{};const i_="mapbox",s_=Math.PI/180;function o_({map:e,gl:t,deck:n}){if(e.__deck)return e.__deck;const r=null==n?void 0:n.props._customRender,i=null==n?void 0:n.props.onLoad,s={...null==n?void 0:n.props,_customRender:()=>{e.triggerRepaint(),null==r||r("")}};let o;return s.parameters={...l_(e,!0),...s.parameters},s.views||(s.views=u_(e)),n&&n.props.gl!==t||(Object.assign(s,{gl:t,width:null,height:null,touchAction:"unset",viewState:h_(e)}),(null==n?void 0:n.isInitialized)?a_(n,e):s.onLoad=()=>{null==i||i(),a_(o,e)}),n?(o=n,n.setProps(s),n.userData.isExternal=!0):(o=new rp(s),e.on("remove",()=>{A_(e)})),o.userData.mapboxLayers=new Set,e.__deck=o,e.on("render",()=>{o.isInitialized&&function(e,t){const{mapboxLayers:n,isExternal:r}=e.userData;if(r){const r=Array.from(n,e=>e.id),i=ah(e.props.layers,Boolean).some(e=>e&&!r.includes(e.id));let s=e.getViewports();const o=s.findIndex(e=>e.id===i_),a=s.length>1||o<0;(i||a)&&(o>=0&&(s=s.slice(),s[o]=d_(e,t)),e._drawLayers("mapbox-repaint",{viewports:s,layerFilter:t=>(!e.props.layerFilter||e.props.layerFilter(t))&&(t.viewport.id!==i_||!r.includes(t.layer.id)),clearCanvas:!1}))}e.userData.currentViewport=null}(o,e)}),o}function a_(e,t){const n=()=>{e.isInitialized?function(e,t){e.setProps({viewState:h_(t)}),e.needsRedraw({clearRedrawFlags:!0})}(e,t):t.off("move",n)};t.on("move",n)}function A_(e){var t;null==(t=e.__deck)||t.finalize(),e.__deck=null}function l_(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"===c_(e)&&(n.cullMode="back"),n}function c_(e){var t;const n=null==(t=e.getProjection)?void 0:t.call(e),r=(null==n?void 0:n.type)||(null==n?void 0:n.name);if("globe"===r)return"globe";if(r&&"mercator"!==r)throw new Error("Unsupported projection");return"mercator"}function u_(e){return"globe"===c_(e)?new wg({id:i_}):new Gh({id:i_})}function h_(e){var t;const{lng:n,lat:r}=e.getCenter(),i={longitude:(n+540)%360-180,latitude:r,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 r=e.transform.height,{longitude:i,latitude:s,pitch:o}=t,a=512*n.x,A=512*(1-n.y),l=512*n.z,c=_c([i,s]),u=a-c[0],h=A-c[1],d=Math.sqrt(u*u+h*h),f=o*s_,p=1.5*r,g=f<.001?p*Math.cos(f)/l:p*Math.sin(f)/d;t.zoom=Math.log2(g);const m=l-p*Math.cos(f)/g;t.position=[0,0,m/vc(s)]}else"number"==typeof e.transform.elevation&&(t.position=[0,0,e.transform.elevation])}(e,i),i}function d_(e,t,n){const r=h_(t),{views:i}=e.props,s=i&&ah(i).find(e=>e.id===i_)||u_(t);n&&(s.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)&&(r.nearZ=o/t.transform.height,r.farZ=a/t.transform.height),s.makeViewport({width:e.width,height:e.height,viewState:r})}function f_(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 p_{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=o_({map:e,gl:t,deck:this.props.deck}),(n=this.deck).userData.mapboxLayers.add(this),f_(n)}onRemove(){var e;this.deck&&((e=this.deck).userData.mapboxLayers.delete(this),f_(e))}setProps(e){Object.assign(this.props,e,{id:this.id}),this.deck&&f_(this.deck)}render(e,t){!function(e,t,n,r){let{currentViewport:i}=e.userData,s=!1;i||(i=d_(e,t,r),e.userData.currentViewport=i,s=!0),e.isInitialized&&e._drawLayers("mapbox-repaint",{viewports:[i],layerFilter:t=>(!e.props.layerFilter||e.props.layerFilter(t))&&(n.id===t.layer.id||t.layer.props.operation.includes("terrain")),clearStack:s,clearCanvas:!1})}(this.deck,this.map,this,t)}}const g_="__UNDEFINED__";function m_(e,t,n,r){if(!(e&&t&&e.style&&e.style._loaded))return;const i=ah(r,Boolean);if(n!==r){const t=ah(n,Boolean),r=new Set(t.map(e=>e.id));for(const e of i)r.delete(e.id);for(const n of r)e.getLayer(n)&&e.removeLayer(n)}for(const a of i){const n=e.getLayer(a.id);n?(n.implementation||n).setProps(a.props):e.addLayer(new p_({id:a.id,deck:t,slot:a.props.slot}),a.props.beforeId)}const s=e.style._order,o={};for(const a of i){let{beforeId:e}=a.props;e&&s.includes(e)||(e=g_),o[e]=o[e]||[],o[e].push(a.id)}for(const a in o){const t=o[a];let n=a===g_?s.length:s.indexOf(a),r=a===g_?void 0:a;for(let i=t.length-1;i>=0;i--){const o=t[i],a=s.indexOf(o);a!==n-1&&(e.moveLayer(o,r),a>n&&n++),n--,r=o}}}class __{constructor(e){this._handleStyleChange=()=>{var e;m_(this._map,this._deck,this._props.layers,this._props.layers),this._map&&c_(this._map)&&!this._props.views&&(null==(e=this._deck)||e.setProps({views:u_(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||u_(t),viewState:h_(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},r=this._lastMouseDownPoint;switch(!e.point&&r&&(n.deltaX=e.originalEvent.clientX-r.clientX,n.deltaY=e.originalEvent.clientY-r.clientY,n.offsetCenter={x:r.x+n.deltaX,y:r.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,...r}=e;return t||void 0===n||(r.useDevicePixels=n),r}setProps(e){this._interleaved&&e.layers&&m_(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:{...l_(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 rp({...this._props,parent:t,parameters:{...l_(e,!1),...this._props.parameters},views:this._props.views||u_(e),viewState:h_(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&&Hn.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=o_({map:e,gl:t,deck:new rp({...this._props,gl:t,parameters:{...l_(e,!0),...this._props.parameters}})}),e.on("styledata",this._handleStyleChange),m_(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),m_(e,this._deck,this._props.layers,[]),A_(e)}getDefaultPosition(){return"top-left"}pickObject(e){return xh(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return xh(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return xh(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 b_=f.createContext(null);function v_({children:e}){const{current:t}=_(),n=f.useRef(null),r=f.useRef(new Map),[i,o]=f.useState(!1);f.useEffect(()=>{const e=null==t?void 0:t.getMap();if(e)return n.current||(n.current=new __({interleaved:!0,useDevicePixels:!0,layers:[]}),e.addControl(n.current),o(!0)),()=>{if(n.current&&e){try{e.removeControl(n.current)}catch{}n.current=null,o(!1)}}},[t]);const a=f.useCallback(()=>{if(!n.current)return;const e=[],t=Array.from(r.current.keys()).sort();for(const n of t){const t=r.current.get(n);t&&t.length>0&&e.push(...t)}n.current.setProps({layers:e})},[]),A=f.useCallback((e,t)=>{0===t.length?r.current.delete(e):r.current.set(e,t),a()},[a]);return s.jsx(b_.Provider,{value:{setLayers:A,isReady:i},children:e})}function y_(){const e=f.useContext(b_);if(!e)throw new Error("useDeckOverlay must be used within a DeckOverlayProvider");return e}const w_=[[0,0,4,200],[16,11,45,200],[34,17,80,200],[50,15,106,200],[64,15,116,200],[79,18,123,200],[94,23,127,200],[109,29,129,200],[124,35,130,200],[140,41,129,200],[155,47,127,200],[171,53,124,200],[187,59,119,200],[203,65,111,200],[219,72,103,200],[234,82,96,200],[249,93,91,200],[253,111,92,200],[254,130,94,200],[254,150,98,200],[254,170,102,200],[254,192,106,200],[254,214,118,200],[254,234,158,200]];function x_({coveragePoints:e,visible:t,opacity:n=.7}){const{setLayers:r,isReady:i}=y_(),{h3Cells:o,minQuality:a,maxQuality:A}=f.useMemo(()=>{if(!e||!Array.isArray(e)||0===e.length)return{h3Cells:[],minQuality:0,maxQuality:0};const t=function(e){const t=new Map;for(const r of e){if("number"!=typeof r.lat||"number"!=typeof r.lon||isNaN(r.lat)||isNaN(r.lon))continue;const e=Ym(r.lat,r.lon,8),n=t.get(e),i=r.weight;n?(n.count++,n.qualitySum+=i):t.set(e,{count:1,qualitySum:i})}const n=[];for(const[r,i]of t.entries())n.push({hexId:r,count:i.count,avgQuality:i.qualitySum/i.count});return n}(e),n=t.map(e=>e.avgQuality);return{h3Cells:t,minQuality:Math.min(...n),maxQuality:Math.max(...n)}},[e]);return f.useEffect(()=>{if(!i)return;if(!t||0===o.length)return void r("wardriving",[]);const e=new r_({id:"wardriving-coverage",data:o,getHexagon:e=>e.hexId,getFillColor:e=>function(e,t,n){const r=n-t;if(r<.001)return w_[12];const i=(o=Math.max(0,Math.min(1,(e-t)/r)))<.15?o/.15*.1:o>.85?.9+(o-.85)/.15*.1:.1+(o-.15)/.7*.8,s=Math.min(23,Math.floor(24*i));var o;return w_[s]}(e.avgQuality,a,A),opacity:n,filled:!0,stroked:!1,pickable:!1,extruded:!1});return r("wardriving",[e]),()=>{r("wardriving",[])}},[o,a,A,t,n,i,r]),o.length>0&&t?s.jsx("div",{"data-testid":"wardriving-hexlayer-active","data-point-count":(null==e?void 0:e.length)||0,"data-cell-count":o.length,"data-is-ready":i,style:{display:"none"}}):null}function E_(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}function T_(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}var S_,C_={},k_={};var R_,P_,I_={};var M_,L_,N_=(P_||(P_=1,M_=function(){if(S_)return k_;S_=1;var e=m();function t(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var n=Object.prototype.hasOwnProperty,r=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,i={},s={};function o(e){return!!n.call(s,e)||!n.call(i,e)&&(r.test(e)?s[e]=!0:(i[e]=!0,!1))}function a(e,t,n,r,i,s,o){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var A={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){A[e]=new a(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];A[t]=new a(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){A[e]=new a(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){A[e]=new a(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){A[e]=new a(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){A[e]=new a(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){A[e]=new a(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){A[e]=new a(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){A[e]=new a(e,5,!1,e.toLowerCase(),null,!1,!1)});var l=/[\-:]([a-z])/g;function c(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(l,c);A[t]=new a(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(l,c);A[t]=new a(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(l,c);A[t]=new a(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){A[e]=new a(e,1,!1,e.toLowerCase(),null,!1,!1)}),A.xlinkHref=new a("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){A[e]=new a(e,1,!1,e.toLowerCase(),null,!0,!0)});var u={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},h=["Webkit","ms","Moz","O"];Object.keys(u).forEach(function(e){h.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),u[t]=u[e]})});var d=/["'&<>]/;function f(e){if("boolean"==typeof e||"number"==typeof e)return""+e;e=""+e;var t=d.exec(e);if(t){var n,r="",i=0;for(n=t.index;n<e.length;n++){switch(e.charCodeAt(n)){case 34:t="&quot;";break;case 38:t="&amp;";break;case 39:t="&#x27;";break;case 60:t="&lt;";break;case 62:t="&gt;";break;default:continue}i!==n&&(r+=e.substring(i,n)),i=n+1,r+=t}e=i!==n?r+e.substring(i,n):r}return e}var p=/([A-Z])/g,g=/^ms-/,_=Array.isArray;function b(e,t){return{insertionMode:e,selectedValue:t}}var v=new Map;function y(e,r,i){if("object"!=typeof i)throw Error(t(62));for(var s in r=!0,i)if(n.call(i,s)){var o=i[s];if(null!=o&&"boolean"!=typeof o&&""!==o){if(0===s.indexOf("--")){var a=f(s);o=f((""+o).trim())}else{a=s;var A=v.get(a);void 0!==A||(A=f(a.replace(p,"-$1").toLowerCase().replace(g,"-ms-")),v.set(a,A)),a=A,o="number"==typeof o?0===o||n.call(u,s)?""+o:o+"px":f((""+o).trim())}r?(r=!1,e.push(' style="',a,":",o)):e.push(";",a,":",o)}}r||e.push('"')}function w(e,t,n,r){switch(n){case"style":return void y(e,t,r);case"defaultValue":case"defaultChecked":case"innerHTML":case"suppressContentEditableWarning":case"suppressHydrationWarning":return}if(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])if(null!==(t=A.hasOwnProperty(n)?A[n]:null)){switch(typeof r){case"function":case"symbol":return;case"boolean":if(!t.acceptsBooleans)return}switch(n=t.attributeName,t.type){case 3:r&&e.push(" ",n,'=""');break;case 4:!0===r?e.push(" ",n,'=""'):!1!==r&&e.push(" ",n,'="',f(r),'"');break;case 5:isNaN(r)||e.push(" ",n,'="',f(r),'"');break;case 6:!isNaN(r)&&1<=r&&e.push(" ",n,'="',f(r),'"');break;default:t.sanitizeURL&&(r=""+r),e.push(" ",n,'="',f(r),'"')}}else if(o(n)){switch(typeof r){case"function":case"symbol":return;case"boolean":if("data-"!==(t=n.toLowerCase().slice(0,5))&&"aria-"!==t)return}e.push(" ",n,'="',f(r),'"')}}function x(e,n,r){if(null!=n){if(null!=r)throw Error(t(60));if("object"!=typeof n||!("__html"in n))throw Error(t(61));null!=(n=n.__html)&&e.push(""+n)}}function E(e,t,r,i){e.push(C(r));var s,o=r=null;for(s in t)if(n.call(t,s)){var a=t[s];if(null!=a)switch(s){case"children":r=a;break;case"dangerouslySetInnerHTML":o=a;break;default:w(e,i,s,a)}}return e.push(">"),x(e,o,r),"string"==typeof r?(e.push(f(r)),null):r}var T=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,S=new Map;function C(e){var n=S.get(e);if(void 0===n){if(!T.test(e))throw Error(t(65,e));n="<"+e,S.set(e,n)}return n}function k(e,n,r){if(e.push('\x3c!--$?--\x3e<template id="'),null===r)throw Error(t(395));return e.push(r),e.push('"></template>')}var R=/[<\u2028\u2029]/g;function P(e){return JSON.stringify(e).replace(R,function(e){switch(e){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React")}})}function I(e,t,n,r){return n.generateStaticMarkup?(e.push(f(t)),!1):(""===t?e=r:(r&&e.push("\x3c!-- --\x3e"),e.push(f(t)),e=!0),e)}var M=Object.assign,L=Symbol.for("react.element"),N=Symbol.for("react.portal"),B=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),U=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),H=Symbol.for("react.scope"),$=Symbol.for("react.debug_trace_mode"),X=Symbol.for("react.legacy_hidden"),Q=Symbol.for("react.default_value"),Y=Symbol.iterator;function q(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case B:return"Fragment";case N:return"Portal";case O:return"Profiler";case D:return"StrictMode";case G:return"Suspense";case z:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case U:return(e.displayName||"Context")+".Consumer";case F:return(e._context.displayName||"Context")+".Provider";case j:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case V:return null!==(t=e.displayName||null)?t:q(e.type)||"Memo";case W:t=e._payload,e=e._init;try{return q(e(t))}catch(n){}}return null}var K={};function Z(e,t){if(!(e=e.contextTypes))return K;var n,r={};for(n in e)r[n]=t[n];return r}var J=null;function ee(e,n){if(e!==n){e.context._currentValue2=e.parentValue,e=e.parent;var r=n.parent;if(null===e){if(null!==r)throw Error(t(401))}else{if(null===r)throw Error(t(401));ee(e,r)}n.context._currentValue2=n.value}}function te(e){e.context._currentValue2=e.parentValue,null!==(e=e.parent)&&te(e)}function ne(e){var t=e.parent;null!==t&&ne(t),e.context._currentValue2=e.value}function re(e,n){if(e.context._currentValue2=e.parentValue,null===(e=e.parent))throw Error(t(402));e.depth===n.depth?ee(e,n):re(e,n)}function ie(e,n){var r=n.parent;if(null===r)throw Error(t(402));e.depth===r.depth?ee(e,r):ie(e,r),n.context._currentValue2=n.value}function se(e){var t=J;t!==e&&(null===t?ne(e):null===e?te(t):t.depth===e.depth?ee(t,e):t.depth>e.depth?re(t,e):ie(t,e),J=e)}var oe={isMounted:function(){return!1},enqueueSetState:function(e,t){null!==(e=e._reactInternals).queue&&e.queue.push(t)},enqueueReplaceState:function(e,t){(e=e._reactInternals).replace=!0,e.queue=[t]},enqueueForceUpdate:function(){}};function ae(e,t,n,r){var i=void 0!==e.state?e.state:null;e.updater=oe,e.props=n,e.state=i;var s={queue:[],replace:!1};e._reactInternals=s;var o=t.contextType;if(e.context="object"==typeof o&&null!==o?o._currentValue2:r,"function"==typeof(o=t.getDerivedStateFromProps)&&(i=null==(o=o(n,i))?i:M({},i,o),e.state=i),"function"!=typeof t.getDerivedStateFromProps&&"function"!=typeof e.getSnapshotBeforeUpdate&&("function"==typeof e.UNSAFE_componentWillMount||"function"==typeof e.componentWillMount))if(t=e.state,"function"==typeof e.componentWillMount&&e.componentWillMount(),"function"==typeof e.UNSAFE_componentWillMount&&e.UNSAFE_componentWillMount(),t!==e.state&&oe.enqueueReplaceState(e,e.state,null),null!==s.queue&&0<s.queue.length)if(t=s.queue,o=s.replace,s.queue=null,s.replace=!1,o&&1===t.length)e.state=t[0];else{for(s=o?t[0]:e.state,i=!0,o=o?1:0;o<t.length;o++){var a=t[o];null!=(a="function"==typeof a?a.call(e,s,n,r):a)&&(i?(i=!1,s=M({},s,a)):M(s,a))}e.state=s}else s.queue=null}var Ae={id:1,overflow:""};function le(e,t,n){var r=e.id;e=e.overflow;var i=32-ce(r)-1;r&=~(1<<i),n+=1;var s=32-ce(t)+i;if(30<s){var o=i-i%5;return s=(r&(1<<o)-1).toString(32),r>>=o,i-=o,{id:1<<32-ce(t)+i|n<<i|r,overflow:s+e}}return{id:1<<s|n<<i|r,overflow:e}}var ce=Math.clz32?Math.clz32:function(e){return 0==(e>>>=0)?32:31-(ue(e)/he|0)|0},ue=Math.log,he=Math.LN2,de="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},fe=null,pe=null,ge=null,me=null,_e=!1,be=!1,ve=0,ye=null,we=0;function xe(){if(null===fe)throw Error(t(321));return fe}function Ee(){if(0<we)throw Error(t(312));return{memoizedState:null,queue:null,next:null}}function Te(){return null===me?null===ge?(_e=!1,ge=me=Ee()):(_e=!0,me=ge):null===me.next?(_e=!1,me=me.next=Ee()):(_e=!0,me=me.next),me}function Se(){pe=fe=null,be=!1,ge=null,we=0,me=ye=null}function Ce(e,t){return"function"==typeof t?t(e):t}function ke(e,t,n){if(fe=xe(),me=Te(),_e){var r=me.queue;if(t=r.dispatch,null!==ye&&void 0!==(n=ye.get(r))){ye.delete(r),r=me.memoizedState;do{r=e(r,n.action),n=n.next}while(null!==n);return me.memoizedState=r,[r,t]}return[me.memoizedState,t]}return e=e===Ce?"function"==typeof t?t():t:void 0!==n?n(t):t,me.memoizedState=e,e=(e=me.queue={last:null,dispatch:null}).dispatch=Pe.bind(null,fe,e),[me.memoizedState,e]}function Re(e,t){if(fe=xe(),t=void 0===t?null:t,null!==(me=Te())){var n=me.memoizedState;if(null!==n&&null!==t){var r=n[1];e:if(null===r)r=!1;else{for(var i=0;i<r.length&&i<t.length;i++)if(!de(t[i],r[i])){r=!1;break e}r=!0}if(r)return n[0]}}return e=e(),me.memoizedState=[e,t],e}function Pe(e,n,r){if(25<=we)throw Error(t(301));if(e===fe)if(be=!0,e={action:r,next:null},null===ye&&(ye=new Map),void 0===(r=ye.get(n)))ye.set(n,e);else{for(n=r;null!==n.next;)n=n.next;n.next=e}}function Ie(){throw Error(t(394))}function Me(){}var Le={readContext:function(e){return e._currentValue2},useContext:function(e){return xe(),e._currentValue2},useMemo:Re,useReducer:ke,useRef:function(e){fe=xe();var t=(me=Te()).memoizedState;return null===t?(e={current:e},me.memoizedState=e):t},useState:function(e){return ke(Ce,e)},useInsertionEffect:Me,useLayoutEffect:function(){},useCallback:function(e,t){return Re(function(){return e},t)},useImperativeHandle:Me,useEffect:Me,useDebugValue:Me,useDeferredValue:function(e){return xe(),e},useTransition:function(){return xe(),[!1,Ie]},useId:function(){var e=pe.treeContext,n=e.overflow;e=((e=e.id)&~(1<<32-ce(e)-1)).toString(32)+n;var r=Ne;if(null===r)throw Error(t(404));return n=ve++,e=":"+r.idPrefix+"R"+e,0<n&&(e+="H"+n.toString(32)),e+":"},useMutableSource:function(e,t){return xe(),t(e._source)},useSyncExternalStore:function(e,n,r){if(void 0===r)throw Error(t(407));return r()}},Ne=null,Be=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function De(e){return null}function Oe(){}function Fe(e,t,n,r,i,s,o,a){e.allPendingTasks++,null===n?e.pendingRootTasks++:n.pendingTasks++;var A={node:t,ping:function(){var t=e.pingedTasks;t.push(A),1===t.length&&Je(e)},blockedBoundary:n,blockedSegment:r,abortSet:i,legacyContext:s,context:o,treeContext:a};return i.add(A),A}function Ue(e,t,n,r,i,s){return{status:0,id:-1,index:t,parentFlushed:!1,chunks:[],children:[],formatContext:r,boundary:n,lastPushedText:i,textEmbedded:s}}function je(e,t){if(null!=(e=e.onError(t))&&"string"!=typeof e)throw Error('onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "'+typeof e+'" instead');return e}function Ge(e,t){var n=e.onShellError;n(t),(n=e.onFatalError)(t),null!==e.destination?(e.status=2,e.destination.destroy(t)):(e.status=1,e.fatalError=t)}function ze(e,t,n,r,i){for(fe={},pe=t,ve=0,e=n(r,i);be;)be=!1,ve=0,we+=1,me=null,e=n(r,i);return Se(),e}function Ve(e,n,r,i){var s=r.render(),o=i.childContextTypes;if(null!=o){var a=n.legacyContext;if("function"!=typeof r.getChildContext)i=a;else{for(var A in r=r.getChildContext())if(!(A in o))throw Error(t(108,q(i)||"Unknown",A));i=M({},a,r)}n.legacyContext=i,$e(e,n,s),n.legacyContext=a}else $e(e,n,s)}function We(e,t){if(e&&e.defaultProps){for(var n in t=M({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}function He(r,i,s,a,A){if("function"==typeof s)if(s.prototype&&s.prototype.isReactComponent){A=Z(s,i.legacyContext);var l=s.contextType;ae(l=new s(a,"object"==typeof l&&null!==l?l._currentValue2:A),s,a,A),Ve(r,i,l,s)}else{A=ze(r,i,s,a,l=Z(s,i.legacyContext));var c=0!==ve;if("object"==typeof A&&null!==A&&"function"==typeof A.render&&void 0===A.$$typeof)ae(A,s,a,l),Ve(r,i,A,s);else if(c){a=i.treeContext,i.treeContext=le(a,1,0);try{$e(r,i,A)}finally{i.treeContext=a}}else $e(r,i,A)}else{if("string"!=typeof s){switch(s){case X:case $:case D:case O:case B:case z:return void $e(r,i,a.children);case H:throw Error(t(343));case G:e:{s=i.blockedBoundary,A=i.blockedSegment,l=a.fallback,a=a.children;var u={id:null,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,forceClientRender:!1,completedSegments:[],byteSize:0,fallbackAbortableTasks:c=new Set,errorDigest:null},h=Ue(0,A.chunks.length,u,A.formatContext,!1,!1);A.children.push(h),A.lastPushedText=!1;var d=Ue(0,0,null,A.formatContext,!1,!1);d.parentFlushed=!0,i.blockedBoundary=u,i.blockedSegment=d;try{if(Qe(r,i,a),r.responseState.generateStaticMarkup||d.lastPushedText&&d.textEmbedded&&d.chunks.push("\x3c!-- --\x3e"),d.status=1,Ke(u,d),0===u.pendingTasks)break e}catch(p){d.status=4,u.forceClientRender=!0,u.errorDigest=je(r,p)}finally{i.blockedBoundary=s,i.blockedSegment=A}i=Fe(r,l,s,h,c,i.legacyContext,i.context,i.treeContext),r.pingedTasks.push(i)}return}if("object"==typeof s&&null!==s)switch(s.$$typeof){case j:if(a=ze(r,i,s.render,a,A),0!==ve){s=i.treeContext,i.treeContext=le(s,1,0);try{$e(r,i,a)}finally{i.treeContext=s}}else $e(r,i,a);return;case V:return void He(r,i,s=s.type,a=We(s,a),A);case F:if(A=a.children,s=s._context,a=a.value,l=s._currentValue2,s._currentValue2=a,J=a={parent:c=J,depth:null===c?0:c.depth+1,context:s,parentValue:l,value:a},i.context=a,$e(r,i,A),null===(r=J))throw Error(t(403));return a=r.parentValue,r.context._currentValue2=a===Q?r.context._defaultValue:a,r=J=r.parent,void(i.context=r);case U:return void $e(r,i,a=(a=a.children)(s._currentValue2));case W:return void He(r,i,s=(A=s._init)(s._payload),a=We(s,a),void 0)}throw Error(t(130,null==s?s:typeof s,""))}switch(l=function(r,i,s,a,A){switch(i){case"select":r.push(C("select"));var l=null,c=null;for(p in s)if(n.call(s,p)){var u=s[p];if(null!=u)switch(p){case"children":l=u;break;case"dangerouslySetInnerHTML":c=u;break;case"defaultValue":case"value":break;default:w(r,a,p,u)}}return r.push(">"),x(r,c,l),l;case"option":c=A.selectedValue,r.push(C("option"));var h=u=null,d=null,p=null;for(l in s)if(n.call(s,l)){var g=s[l];if(null!=g)switch(l){case"children":u=g;break;case"selected":d=g;break;case"dangerouslySetInnerHTML":p=g;break;case"value":h=g;default:w(r,a,l,g)}}if(null!=c)if(s=null!==h?""+h:function(t){var n="";return e.Children.forEach(t,function(e){null!=e&&(n+=e)}),n}(u),_(c)){for(a=0;a<c.length;a++)if(""+c[a]===s){r.push(' selected=""');break}}else""+c===s&&r.push(' selected=""');else d&&r.push(' selected=""');return r.push(">"),x(r,p,u),u;case"textarea":for(u in r.push(C("textarea")),p=c=l=null,s)if(n.call(s,u)&&null!=(h=s[u]))switch(u){case"children":p=h;break;case"value":l=h;break;case"defaultValue":c=h;break;case"dangerouslySetInnerHTML":throw Error(t(91));default:w(r,a,u,h)}if(null===l&&null!==c&&(l=c),r.push(">"),null!=p){if(null!=l)throw Error(t(92));if(_(p)&&1<p.length)throw Error(t(93));l=""+p}return"string"==typeof l&&"\n"===l[0]&&r.push("\n"),null!==l&&r.push(f(""+l)),null;case"input":for(c in r.push(C("input")),h=p=u=l=null,s)if(n.call(s,c)&&null!=(d=s[c]))switch(c){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,"input"));case"defaultChecked":h=d;break;case"defaultValue":u=d;break;case"checked":p=d;break;case"value":l=d;break;default:w(r,a,c,d)}return null!==p?w(r,a,"checked",p):null!==h&&w(r,a,"checked",h),null!==l?w(r,a,"value",l):null!==u&&w(r,a,"value",u),r.push("/>"),null;case"menuitem":for(var m in r.push(C("menuitem")),s)if(n.call(s,m)&&null!=(l=s[m]))switch(m){case"children":case"dangerouslySetInnerHTML":throw Error(t(400));default:w(r,a,m,l)}return r.push(">"),null;case"title":for(g in r.push(C("title")),l=null,s)if(n.call(s,g)&&null!=(c=s[g]))switch(g){case"children":l=c;break;case"dangerouslySetInnerHTML":throw Error(t(434));default:w(r,a,g,c)}return r.push(">"),l;case"listing":case"pre":for(h in r.push(C(i)),c=l=null,s)if(n.call(s,h)&&null!=(u=s[h]))switch(h){case"children":l=u;break;case"dangerouslySetInnerHTML":c=u;break;default:w(r,a,h,u)}if(r.push(">"),null!=c){if(null!=l)throw Error(t(60));if("object"!=typeof c||!("__html"in c))throw Error(t(61));null!=(s=c.__html)&&("string"==typeof s&&0<s.length&&"\n"===s[0]?r.push("\n",s):r.push(""+s))}return"string"==typeof l&&"\n"===l[0]&&r.push("\n"),l;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":for(var b in r.push(C(i)),s)if(n.call(s,b)&&null!=(l=s[b]))switch(b){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,i));default:w(r,a,b,l)}return r.push("/>"),null;case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return E(r,s,i,a);case"html":return 0===A.insertionMode&&r.push("<!DOCTYPE html>"),E(r,s,i,a);default:if(-1===i.indexOf("-")&&"string"!=typeof s.is)return E(r,s,i,a);for(d in r.push(C(i)),c=l=null,s)if(n.call(s,d)&&null!=(u=s[d]))switch(d){case"children":l=u;break;case"dangerouslySetInnerHTML":c=u;break;case"style":y(r,a,u);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:o(d)&&"function"!=typeof u&&"symbol"!=typeof u&&r.push(" ",d,'="',f(u),'"')}return r.push(">"),x(r,c,l),l}}((A=i.blockedSegment).chunks,s,a,r.responseState,A.formatContext),A.lastPushedText=!1,c=A.formatContext,A.formatContext=function(e,t,n){switch(t){case"select":return b(1,null!=n.value?n.value:n.defaultValue);case"svg":return b(2,null);case"math":return b(3,null);case"foreignObject":return b(1,null);case"table":return b(4,null);case"thead":case"tbody":case"tfoot":return b(5,null);case"colgroup":return b(7,null);case"tr":return b(6,null)}return 4<=e.insertionMode||0===e.insertionMode?b(1,null):e}(c,s,a),Qe(r,i,l),A.formatContext=c,s){case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":break;default:A.chunks.push("</",s,">")}A.lastPushedText=!1}}function $e(e,n,r){if(n.node=r,"object"==typeof r&&null!==r){switch(r.$$typeof){case L:return void He(e,n,r.type,r.props,r.ref);case N:throw Error(t(257));case W:var i=r._init;return void $e(e,n,r=i(r._payload))}if(_(r))return void Xe(e,n,r);if((i=null===r||"object"!=typeof r?null:"function"==typeof(i=Y&&r[Y]||r["@@iterator"])?i:null)&&(i=i.call(r))){if(!(r=i.next()).done){var s=[];do{s.push(r.value),r=i.next()}while(!r.done);Xe(e,n,s)}return}throw e=Object.prototype.toString.call(r),Error(t(31,"[object Object]"===e?"object with keys {"+Object.keys(r).join(", ")+"}":e))}"string"==typeof r?(i=n.blockedSegment).lastPushedText=I(n.blockedSegment.chunks,r,e.responseState,i.lastPushedText):"number"==typeof r&&((i=n.blockedSegment).lastPushedText=I(n.blockedSegment.chunks,""+r,e.responseState,i.lastPushedText))}function Xe(e,t,n){for(var r=n.length,i=0;i<r;i++){var s=t.treeContext;t.treeContext=le(s,r,i);try{Qe(e,t,n[i])}finally{t.treeContext=s}}}function Qe(e,t,n){var r=t.blockedSegment.formatContext,i=t.legacyContext,s=t.context;try{return $e(e,t,n)}catch(A){if(Se(),"object"!=typeof A||null===A||"function"!=typeof A.then)throw t.blockedSegment.formatContext=r,t.legacyContext=i,t.context=s,se(s),A;n=A;var o=t.blockedSegment,a=Ue(0,o.chunks.length,null,o.formatContext,o.lastPushedText,!0);o.children.push(a),o.lastPushedText=!1,e=Fe(e,t.node,t.blockedBoundary,a,t.abortSet,t.legacyContext,t.context,t.treeContext).ping,n.then(e,e),t.blockedSegment.formatContext=r,t.legacyContext=i,t.context=s,se(s)}}function Ye(e){var t=e.blockedBoundary;(e=e.blockedSegment).status=3,Ze(this,t,e)}function qe(e,n,r){var i=e.blockedBoundary;e.blockedSegment.status=3,null===i?(n.allPendingTasks--,2!==n.status&&(n.status=2,null!==n.destination&&n.destination.push(null))):(i.pendingTasks--,i.forceClientRender||(i.forceClientRender=!0,e=void 0===r?Error(t(432)):r,i.errorDigest=n.onError(e),i.parentFlushed&&n.clientRenderedBoundaries.push(i)),i.fallbackAbortableTasks.forEach(function(e){return qe(e,n,r)}),i.fallbackAbortableTasks.clear(),n.allPendingTasks--,0===n.allPendingTasks&&(i=n.onAllReady)())}function Ke(e,t){if(0===t.chunks.length&&1===t.children.length&&null===t.children[0].boundary){var n=t.children[0];n.id=t.id,n.parentFlushed=!0,1===n.status&&Ke(e,n)}else e.completedSegments.push(t)}function Ze(e,n,r){if(null===n){if(r.parentFlushed){if(null!==e.completedRootSegment)throw Error(t(389));e.completedRootSegment=r}e.pendingRootTasks--,0===e.pendingRootTasks&&(e.onShellError=Oe,(n=e.onShellReady)())}else n.pendingTasks--,n.forceClientRender||(0===n.pendingTasks?(r.parentFlushed&&1===r.status&&Ke(n,r),n.parentFlushed&&e.completedBoundaries.push(n),n.fallbackAbortableTasks.forEach(Ye,e),n.fallbackAbortableTasks.clear()):r.parentFlushed&&1===r.status&&(Ke(n,r),1===n.completedSegments.length&&n.parentFlushed&&e.partialBoundaries.push(n)));e.allPendingTasks--,0===e.allPendingTasks&&(e=e.onAllReady)()}function Je(e){if(2!==e.status){var t=J,n=Be.current;Be.current=Le;var r=Ne;Ne=e.responseState;try{var i,s=e.pingedTasks;for(i=0;i<s.length;i++){var o=s[i],a=e,A=o.blockedSegment;if(0===A.status){se(o.context);try{$e(a,o,o.node),a.responseState.generateStaticMarkup||A.lastPushedText&&A.textEmbedded&&A.chunks.push("\x3c!-- --\x3e"),o.abortSet.delete(o),A.status=1,Ze(a,o.blockedBoundary,A)}catch(d){if(Se(),"object"==typeof d&&null!==d&&"function"==typeof d.then){var l=o.ping;d.then(l,l)}else{o.abortSet.delete(o),A.status=4;var c=o.blockedBoundary,u=d,h=je(a,u);null===c?Ge(a,u):(c.pendingTasks--,c.forceClientRender||(c.forceClientRender=!0,c.errorDigest=h,c.parentFlushed&&a.clientRenderedBoundaries.push(c))),a.allPendingTasks--,0===a.allPendingTasks&&(0,a.onAllReady)()}}}}s.splice(0,i),null!==e.destination&&st(e,e.destination)}catch(d){je(e,d),Ge(e,d)}finally{Ne=r,Be.current=n,n===Le&&se(t)}}}function et(e,n,r){switch(r.parentFlushed=!0,r.status){case 0:var i=r.id=e.nextSegmentId++;return r.lastPushedText=!1,r.textEmbedded=!1,e=e.responseState,n.push('<template id="'),n.push(e.placeholderPrefix),e=i.toString(16),n.push(e),n.push('"></template>');case 1:r.status=2;var s=!0;i=r.chunks;var o=0;r=r.children;for(var a=0;a<r.length;a++){for(s=r[a];o<s.index;o++)n.push(i[o]);s=tt(e,n,s)}for(;o<i.length-1;o++)n.push(i[o]);return o<i.length&&(s=n.push(i[o])),s;default:throw Error(t(390))}}function tt(e,n,r){var i=r.boundary;if(null===i)return et(e,n,r);if(i.parentFlushed=!0,i.forceClientRender)return e.responseState.generateStaticMarkup||(i=i.errorDigest,n.push("\x3c!--$!--\x3e"),n.push("<template"),i&&(n.push(' data-dgst="'),i=f(i),n.push(i),n.push('"')),n.push("></template>")),et(e,n,r),!!e.responseState.generateStaticMarkup||n.push("\x3c!--/$--\x3e");if(0<i.pendingTasks){i.rootSegmentID=e.nextSegmentId++,0<i.completedSegments.length&&e.partialBoundaries.push(i);var s=e.responseState,o=s.nextSuspenseID++;return s=s.boundaryPrefix+o.toString(16),i=i.id=s,k(n,e.responseState,i),et(e,n,r),n.push("\x3c!--/$--\x3e")}if(i.byteSize>e.progressiveChunkSize)return i.rootSegmentID=e.nextSegmentId++,e.completedBoundaries.push(i),k(n,e.responseState,i.id),et(e,n,r),n.push("\x3c!--/$--\x3e");if(e.responseState.generateStaticMarkup||n.push("\x3c!--$--\x3e"),1!==(r=i.completedSegments).length)throw Error(t(391));return tt(e,n,r[0]),!!e.responseState.generateStaticMarkup||n.push("\x3c!--/$--\x3e")}function nt(e,n,r){return function(e,n,r,i){switch(r.insertionMode){case 0:case 1:return e.push('<div hidden id="'),e.push(n.segmentPrefix),n=i.toString(16),e.push(n),e.push('">');case 2:return e.push('<svg aria-hidden="true" style="display:none" id="'),e.push(n.segmentPrefix),n=i.toString(16),e.push(n),e.push('">');case 3:return e.push('<math aria-hidden="true" style="display:none" id="'),e.push(n.segmentPrefix),n=i.toString(16),e.push(n),e.push('">');case 4:return e.push('<table hidden id="'),e.push(n.segmentPrefix),n=i.toString(16),e.push(n),e.push('">');case 5:return e.push('<table hidden><tbody id="'),e.push(n.segmentPrefix),n=i.toString(16),e.push(n),e.push('">');case 6:return e.push('<table hidden><tr id="'),e.push(n.segmentPrefix),n=i.toString(16),e.push(n),e.push('">');case 7:return e.push('<table hidden><colgroup id="'),e.push(n.segmentPrefix),n=i.toString(16),e.push(n),e.push('">');default:throw Error(t(397))}}(n,e.responseState,r.formatContext,r.id),tt(e,n,r),function(e,n){switch(n.insertionMode){case 0:case 1:return e.push("</div>");case 2:return e.push("</svg>");case 3:return e.push("</math>");case 4:return e.push("</table>");case 5:return e.push("</tbody></table>");case 6:return e.push("</tr></table>");case 7:return e.push("</colgroup></table>");default:throw Error(t(397))}}(n,r.formatContext)}function rt(e,n,r){for(var i=r.completedSegments,s=0;s<i.length;s++)it(e,n,r,i[s]);if(i.length=0,e=e.responseState,i=r.id,r=r.rootSegmentID,n.push(e.startInlineScript),e.sentCompleteBoundaryFunction?n.push('$RC("'):(e.sentCompleteBoundaryFunction=!0,n.push('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("')),null===i)throw Error(t(395));return r=r.toString(16),n.push(i),n.push('","'),n.push(e.segmentPrefix),n.push(r),n.push('")<\/script>')}function it(e,n,r,i){if(2===i.status)return!0;var s=i.id;if(-1===s){if(-1===(i.id=r.rootSegmentID))throw Error(t(392));return nt(e,n,i)}return nt(e,n,i),e=e.responseState,n.push(e.startInlineScript),e.sentCompleteSegmentFunction?n.push('$RS("'):(e.sentCompleteSegmentFunction=!0,n.push('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("')),n.push(e.segmentPrefix),s=s.toString(16),n.push(s),n.push('","'),n.push(e.placeholderPrefix),n.push(s),n.push('")<\/script>')}function st(e,n){try{var r=e.completedRootSegment;if(null!==r&&0===e.pendingRootTasks){tt(e,n,r),e.completedRootSegment=null;var i=e.responseState.bootstrapChunks;for(r=0;r<i.length-1;r++)n.push(i[r]);r<i.length&&n.push(i[r])}var s,o=e.clientRenderedBoundaries;for(s=0;s<o.length;s++){var a=o[s];i=n;var A=e.responseState,l=a.id,c=a.errorDigest,u=a.errorMessage,h=a.errorComponentStack;if(i.push(A.startInlineScript),A.sentClientRenderFunction?i.push('$RX("'):(A.sentClientRenderFunction=!0,i.push('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("')),null===l)throw Error(t(395));if(i.push(l),i.push('"'),c||u||h){i.push(",");var d=P(c||"");i.push(d)}if(u||h){i.push(",");var f=P(u||"");i.push(f)}if(h){i.push(",");var p=P(h);i.push(p)}if(!i.push(")<\/script>"))return e.destination=null,s++,void o.splice(0,s)}o.splice(0,s);var g=e.completedBoundaries;for(s=0;s<g.length;s++)if(!rt(e,n,g[s]))return e.destination=null,s++,void g.splice(0,s);g.splice(0,s);var m=e.partialBoundaries;for(s=0;s<m.length;s++){var _=m[s];e:{o=e,a=n;var b=_.completedSegments;for(A=0;A<b.length;A++)if(!it(o,a,_,b[A])){A++,b.splice(0,A);var v=!1;break e}b.splice(0,A),v=!0}if(!v)return e.destination=null,s++,void m.splice(0,s)}m.splice(0,s);var y=e.completedBoundaries;for(s=0;s<y.length;s++)if(!rt(e,n,y[s]))return e.destination=null,s++,void y.splice(0,s);y.splice(0,s)}finally{0===e.allPendingTasks&&0===e.pingedTasks.length&&0===e.clientRenderedBoundaries.length&&0===e.completedBoundaries.length&&n.push(null)}}function ot(e,t){try{var n=e.abortableTasks;n.forEach(function(n){return qe(n,e,t)}),n.clear(),null!==e.destination&&st(e,e.destination)}catch(r){je(e,r),Ge(e,r)}}function at(){}function At(e,n,r,i){var s=!1,o=null,a="",A={push:function(e){return null!==e&&(a+=e),!0},destroy:function(e){s=!0,o=e}},l=!1;if(e=function(e,t,n,r,i,s,o){var a=[],A=new Set;return(n=Ue(t={destination:null,responseState:t,progressiveChunkSize:r,status:0,fatalError:null,nextSegmentId:0,allPendingTasks:0,pendingRootTasks:0,completedRootSegment:null,abortableTasks:A,pingedTasks:a,clientRenderedBoundaries:[],completedBoundaries:[],partialBoundaries:[],onError:void 0===i?De:i,onAllReady:Oe,onShellReady:void 0===o?Oe:o,onShellError:Oe,onFatalError:Oe},0,null,n,!1,!1)).parentFlushed=!0,e=Fe(t,e,null,n,A,K,null,Ae),a.push(e),t}(e,function(e,t){return{bootstrapChunks:[],startInlineScript:"<script>",placeholderPrefix:(t=void 0===t?"":t)+"P:",segmentPrefix:t+"S:",boundaryPrefix:t+"B:",idPrefix:t,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1,generateStaticMarkup:e}}(r,n?n.identifierPrefix:void 0),{insertionMode:1,selectedValue:null},1/0,at,0,function(){l=!0}),Je(e),ot(e,i),1===e.status)e.status=2,A.destroy(e.fatalError);else if(2!==e.status&&null===e.destination){e.destination=A;try{st(e,A)}catch(c){je(e,c),Ge(e,c)}}if(s)throw o;if(!l)throw Error(t(426));return a}return k_.renderToNodeStream=function(){throw Error(t(207))},k_.renderToStaticMarkup=function(e,t){return At(e,t,!0,'The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server')},k_.renderToStaticNodeStream=function(){throw Error(t(208))},k_.renderToString=function(e,t){return At(e,t,!1,'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server')},k_.version="18.3.1",k_}(),L_=function(){if(R_)return I_;R_=1;var e=m();function t(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var n=null,r=0;function i(e,t){if(0!==t.length)if(512<t.length)0<r&&(e.enqueue(new Uint8Array(n.buffer,0,r)),n=new Uint8Array(512),r=0),e.enqueue(t);else{var i=n.length-r;i<t.length&&(0===i?e.enqueue(n):(n.set(t.subarray(0,i),r),e.enqueue(n),t=t.subarray(i)),n=new Uint8Array(512),r=0),n.set(t,r),r+=t.length}}function s(e,t){return i(e,t),!0}function o(e){n&&0<r&&(e.enqueue(new Uint8Array(n.buffer,0,r)),n=null,r=0)}var a=new TextEncoder;function A(e){return a.encode(e)}function l(e){return a.encode(e)}function c(e,t){"function"==typeof e.error?e.error(t):e.close()}var u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,d={},f={};function p(e){return!!u.call(f,e)||!u.call(d,e)&&(h.test(e)?f[e]=!0:(d[e]=!0,!1))}function g(e,t,n,r,i,s,o){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var _={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){_[e]=new g(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];_[t]=new g(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){_[e]=new g(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){_[e]=new g(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){_[e]=new g(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){_[e]=new g(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){_[e]=new g(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){_[e]=new g(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){_[e]=new g(e,5,!1,e.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function v(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(b,v);_[t]=new g(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(b,v);_[t]=new g(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(b,v);_[t]=new g(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){_[e]=new g(e,1,!1,e.toLowerCase(),null,!1,!1)}),_.xlinkHref=new g("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){_[e]=new g(e,1,!1,e.toLowerCase(),null,!0,!0)});var y={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},w=["Webkit","ms","Moz","O"];Object.keys(y).forEach(function(e){w.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),y[t]=y[e]})});var x=/["'&<>]/;function E(e){if("boolean"==typeof e||"number"==typeof e)return""+e;e=""+e;var t=x.exec(e);if(t){var n,r="",i=0;for(n=t.index;n<e.length;n++){switch(e.charCodeAt(n)){case 34:t="&quot;";break;case 38:t="&amp;";break;case 39:t="&#x27;";break;case 60:t="&lt;";break;case 62:t="&gt;";break;default:continue}i!==n&&(r+=e.substring(i,n)),i=n+1,r+=t}e=i!==n?r+e.substring(i,n):r}return e}var T=/([A-Z])/g,S=/^ms-/,C=Array.isArray,k=l("<script>"),R=l("<\/script>"),P=l('<script src="'),I=l('<script type="module" src="'),M=l('" async=""><\/script>'),L=/(<\/|<)(s)(cript)/gi;function N(e,t,n,r){return t+("s"===n?"\\u0073":"\\u0053")+r}function B(e,t){return{insertionMode:e,selectedValue:t}}var D=l("\x3c!-- --\x3e");function O(e,t,n,r){return""===t?r:(r&&e.push(D),e.push(A(E(t))),!0)}var F=new Map,U=l(' style="'),j=l(":"),G=l(";");function z(e,n,r){if("object"!=typeof r)throw Error(t(62));for(var i in n=!0,r)if(u.call(r,i)){var s=r[i];if(null!=s&&"boolean"!=typeof s&&""!==s){if(0===i.indexOf("--")){var o=A(E(i));s=A(E((""+s).trim()))}else{o=i;var a=F.get(o);void 0!==a||(a=l(E(o.replace(T,"-$1").toLowerCase().replace(S,"-ms-"))),F.set(o,a)),o=a,s="number"==typeof s?0===s||u.call(y,i)?A(""+s):A(s+"px"):A(E((""+s).trim()))}n?(n=!1,e.push(U,o,j,s)):e.push(G,o,j,s)}}n||e.push(H)}var V=l(" "),W=l('="'),H=l('"'),$=l('=""');function X(e,t,n,r){switch(n){case"style":return void z(e,t,r);case"defaultValue":case"defaultChecked":case"innerHTML":case"suppressContentEditableWarning":case"suppressHydrationWarning":return}if(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])if(null!==(t=_.hasOwnProperty(n)?_[n]:null)){switch(typeof r){case"function":case"symbol":return;case"boolean":if(!t.acceptsBooleans)return}switch(n=A(t.attributeName),t.type){case 3:r&&e.push(V,n,$);break;case 4:!0===r?e.push(V,n,$):!1!==r&&e.push(V,n,W,A(E(r)),H);break;case 5:isNaN(r)||e.push(V,n,W,A(E(r)),H);break;case 6:!isNaN(r)&&1<=r&&e.push(V,n,W,A(E(r)),H);break;default:t.sanitizeURL&&(r=""+r),e.push(V,n,W,A(E(r)),H)}}else if(p(n)){switch(typeof r){case"function":case"symbol":return;case"boolean":if("data-"!==(t=n.toLowerCase().slice(0,5))&&"aria-"!==t)return}e.push(V,A(n),W,A(E(r)),H)}}var Q=l(">"),Y=l("/>");function q(e,n,r){if(null!=n){if(null!=r)throw Error(t(60));if("object"!=typeof n||!("__html"in n))throw Error(t(61));null!=(n=n.__html)&&e.push(A(""+n))}}var K=l(' selected=""');function Z(e,t,n,r){e.push(ne(n));var i,s=n=null;for(i in t)if(u.call(t,i)){var o=t[i];if(null!=o)switch(i){case"children":n=o;break;case"dangerouslySetInnerHTML":s=o;break;default:X(e,r,i,o)}}return e.push(Q),q(e,s,n),"string"==typeof n?(e.push(A(E(n))),null):n}var J=l("\n"),ee=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,te=new Map;function ne(e){var n=te.get(e);if(void 0===n){if(!ee.test(e))throw Error(t(65,e));n=l("<"+e),te.set(e,n)}return n}var re=l("<!DOCTYPE html>"),ie=l("</"),se=l(">"),oe=l('<template id="'),ae=l('"></template>'),Ae=l("\x3c!--$--\x3e"),le=l('\x3c!--$?--\x3e<template id="'),ce=l('"></template>'),ue=l("\x3c!--$!--\x3e"),he=l("\x3c!--/$--\x3e"),de=l("<template"),fe=l('"'),pe=l(' data-dgst="');l(' data-msg="'),l(' data-stck="');var ge=l("></template>");function me(e,n,r){if(i(e,le),null===r)throw Error(t(395));return i(e,r),s(e,ce)}var _e=l('<div hidden id="'),be=l('">'),ve=l("</div>"),ye=l('<svg aria-hidden="true" style="display:none" id="'),we=l('">'),xe=l("</svg>"),Ee=l('<math aria-hidden="true" style="display:none" id="'),Te=l('">'),Se=l("</math>"),Ce=l('<table hidden id="'),ke=l('">'),Re=l("</table>"),Pe=l('<table hidden><tbody id="'),Ie=l('">'),Me=l("</tbody></table>"),Le=l('<table hidden><tr id="'),Ne=l('">'),Be=l("</tr></table>"),De=l('<table hidden><colgroup id="'),Oe=l('">'),Fe=l("</colgroup></table>"),Ue=l('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'),je=l('$RS("'),Ge=l('","'),ze=l('")<\/script>'),Ve=l('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("'),We=l('$RC("'),He=l('","'),$e=l('")<\/script>'),Xe=l('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("'),Qe=l('$RX("'),Ye=l('"'),qe=l(")<\/script>"),Ke=l(","),Ze=/[<\u2028\u2029]/g;function Je(e){return JSON.stringify(e).replace(Ze,function(e){switch(e){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React")}})}var et=Object.assign,tt=Symbol.for("react.element"),nt=Symbol.for("react.portal"),rt=Symbol.for("react.fragment"),it=Symbol.for("react.strict_mode"),st=Symbol.for("react.profiler"),ot=Symbol.for("react.provider"),at=Symbol.for("react.context"),At=Symbol.for("react.forward_ref"),lt=Symbol.for("react.suspense"),ct=Symbol.for("react.suspense_list"),ut=Symbol.for("react.memo"),ht=Symbol.for("react.lazy"),dt=Symbol.for("react.scope"),ft=Symbol.for("react.debug_trace_mode"),pt=Symbol.for("react.legacy_hidden"),gt=Symbol.for("react.default_value"),mt=Symbol.iterator;function _t(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case rt:return"Fragment";case nt:return"Portal";case st:return"Profiler";case it:return"StrictMode";case lt:return"Suspense";case ct:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case at:return(e.displayName||"Context")+".Consumer";case ot:return(e._context.displayName||"Context")+".Provider";case At:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case ut:return null!==(t=e.displayName||null)?t:_t(e.type)||"Memo";case ht:t=e._payload,e=e._init;try{return _t(e(t))}catch(n){}}return null}var bt={};function vt(e,t){if(!(e=e.contextTypes))return bt;var n,r={};for(n in e)r[n]=t[n];return r}var yt=null;function wt(e,n){if(e!==n){e.context._currentValue=e.parentValue,e=e.parent;var r=n.parent;if(null===e){if(null!==r)throw Error(t(401))}else{if(null===r)throw Error(t(401));wt(e,r)}n.context._currentValue=n.value}}function xt(e){e.context._currentValue=e.parentValue,null!==(e=e.parent)&&xt(e)}function Et(e){var t=e.parent;null!==t&&Et(t),e.context._currentValue=e.value}function Tt(e,n){if(e.context._currentValue=e.parentValue,null===(e=e.parent))throw Error(t(402));e.depth===n.depth?wt(e,n):Tt(e,n)}function St(e,n){var r=n.parent;if(null===r)throw Error(t(402));e.depth===r.depth?wt(e,r):St(e,r),n.context._currentValue=n.value}function Ct(e){var t=yt;t!==e&&(null===t?Et(e):null===e?xt(t):t.depth===e.depth?wt(t,e):t.depth>e.depth?Tt(t,e):St(t,e),yt=e)}var kt={isMounted:function(){return!1},enqueueSetState:function(e,t){null!==(e=e._reactInternals).queue&&e.queue.push(t)},enqueueReplaceState:function(e,t){(e=e._reactInternals).replace=!0,e.queue=[t]},enqueueForceUpdate:function(){}};function Rt(e,t,n,r){var i=void 0!==e.state?e.state:null;e.updater=kt,e.props=n,e.state=i;var s={queue:[],replace:!1};e._reactInternals=s;var o=t.contextType;if(e.context="object"==typeof o&&null!==o?o._currentValue:r,"function"==typeof(o=t.getDerivedStateFromProps)&&(i=null==(o=o(n,i))?i:et({},i,o),e.state=i),"function"!=typeof t.getDerivedStateFromProps&&"function"!=typeof e.getSnapshotBeforeUpdate&&("function"==typeof e.UNSAFE_componentWillMount||"function"==typeof e.componentWillMount))if(t=e.state,"function"==typeof e.componentWillMount&&e.componentWillMount(),"function"==typeof e.UNSAFE_componentWillMount&&e.UNSAFE_componentWillMount(),t!==e.state&&kt.enqueueReplaceState(e,e.state,null),null!==s.queue&&0<s.queue.length)if(t=s.queue,o=s.replace,s.queue=null,s.replace=!1,o&&1===t.length)e.state=t[0];else{for(s=o?t[0]:e.state,i=!0,o=o?1:0;o<t.length;o++){var a=t[o];null!=(a="function"==typeof a?a.call(e,s,n,r):a)&&(i?(i=!1,s=et({},s,a)):et(s,a))}e.state=s}else s.queue=null}var Pt={id:1,overflow:""};function It(e,t,n){var r=e.id;e=e.overflow;var i=32-Mt(r)-1;r&=~(1<<i),n+=1;var s=32-Mt(t)+i;if(30<s){var o=i-i%5;return s=(r&(1<<o)-1).toString(32),r>>=o,i-=o,{id:1<<32-Mt(t)+i|n<<i|r,overflow:s+e}}return{id:1<<s|n<<i|r,overflow:e}}var Mt=Math.clz32?Math.clz32:function(e){return 0==(e>>>=0)?32:31-(Lt(e)/Nt|0)|0},Lt=Math.log,Nt=Math.LN2,Bt="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},Dt=null,Ot=null,Ft=null,Ut=null,jt=!1,Gt=!1,zt=0,Vt=null,Wt=0;function Ht(){if(null===Dt)throw Error(t(321));return Dt}function $t(){if(0<Wt)throw Error(t(312));return{memoizedState:null,queue:null,next:null}}function Xt(){return null===Ut?null===Ft?(jt=!1,Ft=Ut=$t()):(jt=!0,Ut=Ft):null===Ut.next?(jt=!1,Ut=Ut.next=$t()):(jt=!0,Ut=Ut.next),Ut}function Qt(){Ot=Dt=null,Gt=!1,Ft=null,Wt=0,Ut=Vt=null}function Yt(e,t){return"function"==typeof t?t(e):t}function qt(e,t,n){if(Dt=Ht(),Ut=Xt(),jt){var r=Ut.queue;if(t=r.dispatch,null!==Vt&&void 0!==(n=Vt.get(r))){Vt.delete(r),r=Ut.memoizedState;do{r=e(r,n.action),n=n.next}while(null!==n);return Ut.memoizedState=r,[r,t]}return[Ut.memoizedState,t]}return e=e===Yt?"function"==typeof t?t():t:void 0!==n?n(t):t,Ut.memoizedState=e,e=(e=Ut.queue={last:null,dispatch:null}).dispatch=Zt.bind(null,Dt,e),[Ut.memoizedState,e]}function Kt(e,t){if(Dt=Ht(),t=void 0===t?null:t,null!==(Ut=Xt())){var n=Ut.memoizedState;if(null!==n&&null!==t){var r=n[1];e:if(null===r)r=!1;else{for(var i=0;i<r.length&&i<t.length;i++)if(!Bt(t[i],r[i])){r=!1;break e}r=!0}if(r)return n[0]}}return e=e(),Ut.memoizedState=[e,t],e}function Zt(e,n,r){if(25<=Wt)throw Error(t(301));if(e===Dt)if(Gt=!0,e={action:r,next:null},null===Vt&&(Vt=new Map),void 0===(r=Vt.get(n)))Vt.set(n,e);else{for(n=r;null!==n.next;)n=n.next;n.next=e}}function Jt(){throw Error(t(394))}function en(){}var tn={readContext:function(e){return e._currentValue},useContext:function(e){return Ht(),e._currentValue},useMemo:Kt,useReducer:qt,useRef:function(e){Dt=Ht();var t=(Ut=Xt()).memoizedState;return null===t?(e={current:e},Ut.memoizedState=e):t},useState:function(e){return qt(Yt,e)},useInsertionEffect:en,useLayoutEffect:function(){},useCallback:function(e,t){return Kt(function(){return e},t)},useImperativeHandle:en,useEffect:en,useDebugValue:en,useDeferredValue:function(e){return Ht(),e},useTransition:function(){return Ht(),[!1,Jt]},useId:function(){var e=Ot.treeContext,n=e.overflow;e=((e=e.id)&~(1<<32-Mt(e)-1)).toString(32)+n;var r=nn;if(null===r)throw Error(t(404));return n=zt++,e=":"+r.idPrefix+"R"+e,0<n&&(e+="H"+n.toString(32)),e+":"},useMutableSource:function(e,t){return Ht(),t(e._source)},useSyncExternalStore:function(e,n,r){if(void 0===r)throw Error(t(407));return r()}},nn=null,rn=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function sn(e){return null}function on(){}function an(e,t,n,r,i,s,o,a){e.allPendingTasks++,null===n?e.pendingRootTasks++:n.pendingTasks++;var A={node:t,ping:function(){var t=e.pingedTasks;t.push(A),1===t.length&&wn(e)},blockedBoundary:n,blockedSegment:r,abortSet:i,legacyContext:s,context:o,treeContext:a};return i.add(A),A}function An(e,t,n,r,i,s){return{status:0,id:-1,index:t,parentFlushed:!1,chunks:[],children:[],formatContext:r,boundary:n,lastPushedText:i,textEmbedded:s}}function ln(e,t){if(null!=(e=e.onError(t))&&"string"!=typeof e)throw Error('onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "'+typeof e+'" instead');return e}function cn(e,t){var n=e.onShellError;n(t),(n=e.onFatalError)(t),null!==e.destination?(e.status=2,c(e.destination,t)):(e.status=1,e.fatalError=t)}function un(e,t,n,r,i){for(Dt={},Ot=t,zt=0,e=n(r,i);Gt;)Gt=!1,zt=0,Wt+=1,Ut=null,e=n(r,i);return Qt(),e}function hn(e,n,r,i){var s=r.render(),o=i.childContextTypes;if(null!=o){var a=n.legacyContext;if("function"!=typeof r.getChildContext)i=a;else{for(var A in r=r.getChildContext())if(!(A in o))throw Error(t(108,_t(i)||"Unknown",A));i=et({},a,r)}n.legacyContext=i,pn(e,n,s),n.legacyContext=a}else pn(e,n,s)}function dn(e,t){if(e&&e.defaultProps){for(var n in t=et({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}function fn(n,r,i,s,o){if("function"==typeof i)if(i.prototype&&i.prototype.isReactComponent){o=vt(i,r.legacyContext);var a=i.contextType;Rt(a=new i(s,"object"==typeof a&&null!==a?a._currentValue:o),i,s,o),hn(n,r,a,i)}else{o=un(n,r,i,s,a=vt(i,r.legacyContext));var l=0!==zt;if("object"==typeof o&&null!==o&&"function"==typeof o.render&&void 0===o.$$typeof)Rt(o,i,s,a),hn(n,r,o,i);else if(l){s=r.treeContext,r.treeContext=It(s,1,0);try{pn(n,r,o)}finally{r.treeContext=s}}else pn(n,r,o)}else{if("string"!=typeof i){switch(i){case pt:case ft:case it:case st:case rt:case ct:return void pn(n,r,s.children);case dt:throw Error(t(343));case lt:e:{i=r.blockedBoundary,o=r.blockedSegment,a=s.fallback,s=s.children;var c={id:null,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,forceClientRender:!1,completedSegments:[],byteSize:0,fallbackAbortableTasks:l=new Set,errorDigest:null},h=An(0,o.chunks.length,c,o.formatContext,!1,!1);o.children.push(h),o.lastPushedText=!1;var d=An(0,0,null,o.formatContext,!1,!1);d.parentFlushed=!0,r.blockedBoundary=c,r.blockedSegment=d;try{if(mn(n,r,s),d.lastPushedText&&d.textEmbedded&&d.chunks.push(D),d.status=1,vn(c,d),0===c.pendingTasks)break e}catch(f){d.status=4,c.forceClientRender=!0,c.errorDigest=ln(n,f)}finally{r.blockedBoundary=i,r.blockedSegment=o}r=an(n,a,i,h,l,r.legacyContext,r.context,r.treeContext),n.pingedTasks.push(r)}return}if("object"==typeof i&&null!==i)switch(i.$$typeof){case At:if(s=un(n,r,i.render,s,o),0!==zt){i=r.treeContext,r.treeContext=It(i,1,0);try{pn(n,r,s)}finally{r.treeContext=i}}else pn(n,r,s);return;case ut:return void fn(n,r,i=i.type,s=dn(i,s),o);case ot:if(o=s.children,i=i._context,s=s.value,a=i._currentValue,i._currentValue=s,yt=s={parent:l=yt,depth:null===l?0:l.depth+1,context:i,parentValue:a,value:s},r.context=s,pn(n,r,o),null===(n=yt))throw Error(t(403));return s=n.parentValue,n.context._currentValue=s===gt?n.context._defaultValue:s,n=yt=n.parent,void(r.context=n);case at:return void pn(n,r,s=(s=s.children)(i._currentValue));case ht:return void fn(n,r,i=(o=i._init)(i._payload),s=dn(i,s),void 0)}throw Error(t(130,null==i?i:typeof i,""))}switch(a=function(n,r,i,s,o){switch(r){case"select":n.push(ne("select"));var a=null,l=null;for(f in i)if(u.call(i,f)){var c=i[f];if(null!=c)switch(f){case"children":a=c;break;case"dangerouslySetInnerHTML":l=c;break;case"defaultValue":case"value":break;default:X(n,s,f,c)}}return n.push(Q),q(n,l,a),a;case"option":l=o.selectedValue,n.push(ne("option"));var h=c=null,d=null,f=null;for(a in i)if(u.call(i,a)){var g=i[a];if(null!=g)switch(a){case"children":c=g;break;case"selected":d=g;break;case"dangerouslySetInnerHTML":f=g;break;case"value":h=g;default:X(n,s,a,g)}}if(null!=l)if(i=null!==h?""+h:function(t){var n="";return e.Children.forEach(t,function(e){null!=e&&(n+=e)}),n}(c),C(l)){for(s=0;s<l.length;s++)if(""+l[s]===i){n.push(K);break}}else""+l===i&&n.push(K);else d&&n.push(K);return n.push(Q),q(n,f,c),c;case"textarea":for(c in n.push(ne("textarea")),f=l=a=null,i)if(u.call(i,c)&&null!=(h=i[c]))switch(c){case"children":f=h;break;case"value":a=h;break;case"defaultValue":l=h;break;case"dangerouslySetInnerHTML":throw Error(t(91));default:X(n,s,c,h)}if(null===a&&null!==l&&(a=l),n.push(Q),null!=f){if(null!=a)throw Error(t(92));if(C(f)&&1<f.length)throw Error(t(93));a=""+f}return"string"==typeof a&&"\n"===a[0]&&n.push(J),null!==a&&n.push(A(E(""+a))),null;case"input":for(l in n.push(ne("input")),h=f=c=a=null,i)if(u.call(i,l)&&null!=(d=i[l]))switch(l){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,"input"));case"defaultChecked":h=d;break;case"defaultValue":c=d;break;case"checked":f=d;break;case"value":a=d;break;default:X(n,s,l,d)}return null!==f?X(n,s,"checked",f):null!==h&&X(n,s,"checked",h),null!==a?X(n,s,"value",a):null!==c&&X(n,s,"value",c),n.push(Y),null;case"menuitem":for(var m in n.push(ne("menuitem")),i)if(u.call(i,m)&&null!=(a=i[m]))switch(m){case"children":case"dangerouslySetInnerHTML":throw Error(t(400));default:X(n,s,m,a)}return n.push(Q),null;case"title":for(g in n.push(ne("title")),a=null,i)if(u.call(i,g)&&null!=(l=i[g]))switch(g){case"children":a=l;break;case"dangerouslySetInnerHTML":throw Error(t(434));default:X(n,s,g,l)}return n.push(Q),a;case"listing":case"pre":for(h in n.push(ne(r)),l=a=null,i)if(u.call(i,h)&&null!=(c=i[h]))switch(h){case"children":a=c;break;case"dangerouslySetInnerHTML":l=c;break;default:X(n,s,h,c)}if(n.push(Q),null!=l){if(null!=a)throw Error(t(60));if("object"!=typeof l||!("__html"in l))throw Error(t(61));null!=(i=l.__html)&&("string"==typeof i&&0<i.length&&"\n"===i[0]?n.push(J,A(i)):n.push(A(""+i)))}return"string"==typeof a&&"\n"===a[0]&&n.push(J),a;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":for(var _ in n.push(ne(r)),i)if(u.call(i,_)&&null!=(a=i[_]))switch(_){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,r));default:X(n,s,_,a)}return n.push(Y),null;case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return Z(n,i,r,s);case"html":return 0===o.insertionMode&&n.push(re),Z(n,i,r,s);default:if(-1===r.indexOf("-")&&"string"!=typeof i.is)return Z(n,i,r,s);for(d in n.push(ne(r)),l=a=null,i)if(u.call(i,d)&&null!=(c=i[d]))switch(d){case"children":a=c;break;case"dangerouslySetInnerHTML":l=c;break;case"style":z(n,s,c);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:p(d)&&"function"!=typeof c&&"symbol"!=typeof c&&n.push(V,A(d),W,A(E(c)),H)}return n.push(Q),q(n,l,a),a}}((o=r.blockedSegment).chunks,i,s,n.responseState,o.formatContext),o.lastPushedText=!1,l=o.formatContext,o.formatContext=function(e,t,n){switch(t){case"select":return B(1,null!=n.value?n.value:n.defaultValue);case"svg":return B(2,null);case"math":return B(3,null);case"foreignObject":return B(1,null);case"table":return B(4,null);case"thead":case"tbody":case"tfoot":return B(5,null);case"colgroup":return B(7,null);case"tr":return B(6,null)}return 4<=e.insertionMode||0===e.insertionMode?B(1,null):e}(l,i,s),mn(n,r,a),o.formatContext=l,i){case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":break;default:o.chunks.push(ie,A(i),se)}o.lastPushedText=!1}}function pn(e,n,r){if(n.node=r,"object"==typeof r&&null!==r){switch(r.$$typeof){case tt:return void fn(e,n,r.type,r.props,r.ref);case nt:throw Error(t(257));case ht:var i=r._init;return void pn(e,n,r=i(r._payload))}if(C(r))return void gn(e,n,r);if((i=null===r||"object"!=typeof r?null:"function"==typeof(i=mt&&r[mt]||r["@@iterator"])?i:null)&&(i=i.call(r))){if(!(r=i.next()).done){var s=[];do{s.push(r.value),r=i.next()}while(!r.done);gn(e,n,s)}return}throw e=Object.prototype.toString.call(r),Error(t(31,"[object Object]"===e?"object with keys {"+Object.keys(r).join(", ")+"}":e))}"string"==typeof r?(i=n.blockedSegment).lastPushedText=O(n.blockedSegment.chunks,r,e.responseState,i.lastPushedText):"number"==typeof r&&((i=n.blockedSegment).lastPushedText=O(n.blockedSegment.chunks,""+r,e.responseState,i.lastPushedText))}function gn(e,t,n){for(var r=n.length,i=0;i<r;i++){var s=t.treeContext;t.treeContext=It(s,r,i);try{mn(e,t,n[i])}finally{t.treeContext=s}}}function mn(e,t,n){var r=t.blockedSegment.formatContext,i=t.legacyContext,s=t.context;try{return pn(e,t,n)}catch(A){if(Qt(),"object"!=typeof A||null===A||"function"!=typeof A.then)throw t.blockedSegment.formatContext=r,t.legacyContext=i,t.context=s,Ct(s),A;n=A;var o=t.blockedSegment,a=An(0,o.chunks.length,null,o.formatContext,o.lastPushedText,!0);o.children.push(a),o.lastPushedText=!1,e=an(e,t.node,t.blockedBoundary,a,t.abortSet,t.legacyContext,t.context,t.treeContext).ping,n.then(e,e),t.blockedSegment.formatContext=r,t.legacyContext=i,t.context=s,Ct(s)}}function _n(e){var t=e.blockedBoundary;(e=e.blockedSegment).status=3,yn(this,t,e)}function bn(e,n,r){var i=e.blockedBoundary;e.blockedSegment.status=3,null===i?(n.allPendingTasks--,2!==n.status&&(n.status=2,null!==n.destination&&n.destination.close())):(i.pendingTasks--,i.forceClientRender||(i.forceClientRender=!0,e=void 0===r?Error(t(432)):r,i.errorDigest=n.onError(e),i.parentFlushed&&n.clientRenderedBoundaries.push(i)),i.fallbackAbortableTasks.forEach(function(e){return bn(e,n,r)}),i.fallbackAbortableTasks.clear(),n.allPendingTasks--,0===n.allPendingTasks&&(i=n.onAllReady)())}function vn(e,t){if(0===t.chunks.length&&1===t.children.length&&null===t.children[0].boundary){var n=t.children[0];n.id=t.id,n.parentFlushed=!0,1===n.status&&vn(e,n)}else e.completedSegments.push(t)}function yn(e,n,r){if(null===n){if(r.parentFlushed){if(null!==e.completedRootSegment)throw Error(t(389));e.completedRootSegment=r}e.pendingRootTasks--,0===e.pendingRootTasks&&(e.onShellError=on,(n=e.onShellReady)())}else n.pendingTasks--,n.forceClientRender||(0===n.pendingTasks?(r.parentFlushed&&1===r.status&&vn(n,r),n.parentFlushed&&e.completedBoundaries.push(n),n.fallbackAbortableTasks.forEach(_n,e),n.fallbackAbortableTasks.clear()):r.parentFlushed&&1===r.status&&(vn(n,r),1===n.completedSegments.length&&n.parentFlushed&&e.partialBoundaries.push(n)));e.allPendingTasks--,0===e.allPendingTasks&&(e=e.onAllReady)()}function wn(e){if(2!==e.status){var t=yt,n=rn.current;rn.current=tn;var r=nn;nn=e.responseState;try{var i,s=e.pingedTasks;for(i=0;i<s.length;i++){var o=s[i],a=e,A=o.blockedSegment;if(0===A.status){Ct(o.context);try{pn(a,o,o.node),A.lastPushedText&&A.textEmbedded&&A.chunks.push(D),o.abortSet.delete(o),A.status=1,yn(a,o.blockedBoundary,A)}catch(d){if(Qt(),"object"==typeof d&&null!==d&&"function"==typeof d.then){var l=o.ping;d.then(l,l)}else{o.abortSet.delete(o),A.status=4;var c=o.blockedBoundary,u=d,h=ln(a,u);null===c?cn(a,u):(c.pendingTasks--,c.forceClientRender||(c.forceClientRender=!0,c.errorDigest=h,c.parentFlushed&&a.clientRenderedBoundaries.push(c))),a.allPendingTasks--,0===a.allPendingTasks&&(0,a.onAllReady)()}}}}s.splice(0,i),null!==e.destination&&kn(e,e.destination)}catch(d){ln(e,d),cn(e,d)}finally{nn=r,rn.current=n,n===tn&&Ct(t)}}}function xn(e,n,r){switch(r.parentFlushed=!0,r.status){case 0:var o=r.id=e.nextSegmentId++;return r.lastPushedText=!1,r.textEmbedded=!1,e=e.responseState,i(n,oe),i(n,e.placeholderPrefix),i(n,e=A(o.toString(16))),s(n,ae);case 1:r.status=2;var a=!0;o=r.chunks;var l=0;r=r.children;for(var c=0;c<r.length;c++){for(a=r[c];l<a.index;l++)i(n,o[l]);a=En(e,n,a)}for(;l<o.length-1;l++)i(n,o[l]);return l<o.length&&(a=s(n,o[l])),a;default:throw Error(t(390))}}function En(e,n,r){var o=r.boundary;if(null===o)return xn(e,n,r);if(o.parentFlushed=!0,o.forceClientRender)o=o.errorDigest,s(n,ue),i(n,de),o&&(i(n,pe),i(n,A(E(o))),i(n,fe)),s(n,ge),xn(e,n,r);else if(0<o.pendingTasks){o.rootSegmentID=e.nextSegmentId++,0<o.completedSegments.length&&e.partialBoundaries.push(o);var a=e.responseState,c=a.nextSuspenseID++;a=l(a.boundaryPrefix+c.toString(16)),o=o.id=a,me(n,e.responseState,o),xn(e,n,r)}else if(o.byteSize>e.progressiveChunkSize)o.rootSegmentID=e.nextSegmentId++,e.completedBoundaries.push(o),me(n,e.responseState,o.id),xn(e,n,r);else{if(s(n,Ae),1!==(r=o.completedSegments).length)throw Error(t(391));En(e,n,r[0])}return s(n,he)}function Tn(e,n,r){return function(e,n,r,o){switch(r.insertionMode){case 0:case 1:return i(e,_e),i(e,n.segmentPrefix),i(e,A(o.toString(16))),s(e,be);case 2:return i(e,ye),i(e,n.segmentPrefix),i(e,A(o.toString(16))),s(e,we);case 3:return i(e,Ee),i(e,n.segmentPrefix),i(e,A(o.toString(16))),s(e,Te);case 4:return i(e,Ce),i(e,n.segmentPrefix),i(e,A(o.toString(16))),s(e,ke);case 5:return i(e,Pe),i(e,n.segmentPrefix),i(e,A(o.toString(16))),s(e,Ie);case 6:return i(e,Le),i(e,n.segmentPrefix),i(e,A(o.toString(16))),s(e,Ne);case 7:return i(e,De),i(e,n.segmentPrefix),i(e,A(o.toString(16))),s(e,Oe);default:throw Error(t(397))}}(n,e.responseState,r.formatContext,r.id),En(e,n,r),function(e,n){switch(n.insertionMode){case 0:case 1:return s(e,ve);case 2:return s(e,xe);case 3:return s(e,Se);case 4:return s(e,Re);case 5:return s(e,Me);case 6:return s(e,Be);case 7:return s(e,Fe);default:throw Error(t(397))}}(n,r.formatContext)}function Sn(e,n,r){for(var o=r.completedSegments,a=0;a<o.length;a++)Cn(e,n,r,o[a]);if(o.length=0,e=e.responseState,o=r.id,r=r.rootSegmentID,i(n,e.startInlineScript),e.sentCompleteBoundaryFunction?i(n,We):(e.sentCompleteBoundaryFunction=!0,i(n,Ve)),null===o)throw Error(t(395));return r=A(r.toString(16)),i(n,o),i(n,He),i(n,e.segmentPrefix),i(n,r),s(n,$e)}function Cn(e,n,r,o){if(2===o.status)return!0;var a=o.id;if(-1===a){if(-1===(o.id=r.rootSegmentID))throw Error(t(392));return Tn(e,n,o)}return Tn(e,n,o),i(n,(e=e.responseState).startInlineScript),e.sentCompleteSegmentFunction?i(n,je):(e.sentCompleteSegmentFunction=!0,i(n,Ue)),i(n,e.segmentPrefix),i(n,a=A(a.toString(16))),i(n,Ge),i(n,e.placeholderPrefix),i(n,a),s(n,ze)}function kn(e,a){n=new Uint8Array(512),r=0;try{var l=e.completedRootSegment;if(null!==l&&0===e.pendingRootTasks){En(e,a,l),e.completedRootSegment=null;var c=e.responseState.bootstrapChunks;for(l=0;l<c.length-1;l++)i(a,c[l]);l<c.length&&s(a,c[l])}var u,h=e.clientRenderedBoundaries;for(u=0;u<h.length;u++){var d=h[u];c=a;var f=e.responseState,p=d.id,g=d.errorDigest,m=d.errorMessage,_=d.errorComponentStack;if(i(c,f.startInlineScript),f.sentClientRenderFunction?i(c,Qe):(f.sentClientRenderFunction=!0,i(c,Xe)),null===p)throw Error(t(395));i(c,p),i(c,Ye),(g||m||_)&&(i(c,Ke),i(c,A(Je(g||"")))),(m||_)&&(i(c,Ke),i(c,A(Je(m||"")))),_&&(i(c,Ke),i(c,A(Je(_)))),s(c,qe)}h.splice(0,u);var b=e.completedBoundaries;for(u=0;u<b.length;u++)Sn(e,a,b[u]);b.splice(0,u),o(a),n=new Uint8Array(512),r=0;var v=e.partialBoundaries;for(u=0;u<v.length;u++){var y=v[u];e:{h=e,d=a;var w=y.completedSegments;for(f=0;f<w.length;f++)if(!Cn(h,d,y,w[f])){f++,w.splice(0,f);var x=!1;break e}w.splice(0,f),x=!0}if(!x)return e.destination=null,u++,void v.splice(0,u)}v.splice(0,u);var E=e.completedBoundaries;for(u=0;u<E.length;u++)Sn(e,a,E[u]);E.splice(0,u)}finally{o(a),0===e.allPendingTasks&&0===e.pingedTasks.length&&0===e.clientRenderedBoundaries.length&&0===e.completedBoundaries.length&&a.close()}}function Rn(e,t){try{var n=e.abortableTasks;n.forEach(function(n){return bn(n,e,t)}),n.clear(),null!==e.destination&&kn(e,e.destination)}catch(r){ln(e,r),cn(e,r)}}return I_.renderToReadableStream=function(e,t){return new Promise(function(n,r){var i,s,o=new Promise(function(e,t){s=e,i=t}),a=function(e,t,n,r,i,s,o,a,A){var l=[],c=new Set;return(n=An(t={destination:null,responseState:t,progressiveChunkSize:void 0===r?12800:r,status:0,fatalError:null,nextSegmentId:0,allPendingTasks:0,pendingRootTasks:0,completedRootSegment:null,abortableTasks:c,pingedTasks:l,clientRenderedBoundaries:[],completedBoundaries:[],partialBoundaries:[],onError:void 0===i?sn:i,onAllReady:void 0===s?on:s,onShellReady:void 0===o?on:o,onShellError:void 0===a?on:a,onFatalError:void 0===A?on:A},0,null,n,!1,!1)).parentFlushed=!0,e=an(t,e,null,n,c,bt,null,Pt),l.push(e),t}(e,function(e,t,n,r,i){e=void 0===e?"":e,t=void 0===t?k:l('<script nonce="'+E(t)+'">');var s=[];if(void 0!==n&&s.push(t,A((""+n).replace(L,N)),R),void 0!==r)for(n=0;n<r.length;n++)s.push(P,A(E(r[n])),M);if(void 0!==i)for(r=0;r<i.length;r++)s.push(I,A(E(i[r])),M);return{bootstrapChunks:s,startInlineScript:t,placeholderPrefix:l(e+"P:"),segmentPrefix:l(e+"S:"),boundaryPrefix:e+"B:",idPrefix:e,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1}}(t?t.identifierPrefix:void 0,t?t.nonce:void 0,t?t.bootstrapScriptContent:void 0,t?t.bootstrapScripts:void 0,t?t.bootstrapModules:void 0),function(e){return B("http://www.w3.org/2000/svg"===e?2:"http://www.w3.org/1998/Math/MathML"===e?3:0,null)}(t?t.namespaceURI:void 0),t?t.progressiveChunkSize:void 0,t?t.onError:void 0,s,function(){var e=new ReadableStream({type:"bytes",pull:function(e){if(1===a.status)a.status=2,c(e,a.fatalError);else if(2!==a.status&&null===a.destination){a.destination=e;try{kn(a,e)}catch(t){ln(a,t),cn(a,t)}}},cancel:function(){Rn(a)}},{highWaterMark:0});e.allReady=o,n(e)},function(e){o.catch(function(){}),r(e)},i);if(t&&t.signal){var u=t.signal,h=function(){Rn(a,u.reason),u.removeEventListener("abort",h)};u.addEventListener("abort",h)}wn(a)})},I_.version="18.3.1",I_}(),C_.version=M_.version,C_.renderToString=M_.renderToString,C_.renderToStaticMarkup=M_.renderToStaticMarkup,C_.renderToNodeStream=M_.renderToNodeStream,C_.renderToStaticNodeStream=M_.renderToStaticNodeStream,C_.renderToReadableStream=L_.renderToReadableStream),C_);const B_=new Map;function D_(e,t){const n=B_.get(e);if(n)return n;if(B_.size>=200){const e=B_.keys().next().value;e&&B_.delete(e)}const r=t();return B_.set(e,r),r}const O_=N_.renderToStaticMarkup(s.jsx(D,{size:16,color:ie,strokeWidth:2.5,fill:"none"})),F_=N_.renderToStaticMarkup(s.jsx(R,{size:16,color:ae,strokeWidth:2.5,fill:"none"}));function U_(e=se,t=1,n=!1,r=!1){return D_(`filled:${e}:${t}:${n}:${r}`,()=>{const i=n?1.25:1;if(r){const n=18,r=n+2,s=(r-14)/2,o=(r-n)/2;return`<div style="\n position: relative;\n width: ${r}px;\n height: ${r}px;\n opacity: ${t};\n filter: brightness(${i});\n transition: filter 0s ease-in, filter 150ms ease-out;\n ">\n \x3c!-- Yellow inner stroke ring --\x3e\n <div style="\n position: absolute;\n top: ${o}px;\n left: ${o}px;\n width: ${n}px;\n height: ${n}px;\n background: transparent;\n border-radius: 50%;\n border: 2px solid ${Ae};\n box-sizing: border-box;\n opacity: 0.85;\n "></div>\n \x3c!-- Inner filled dot --\x3e\n <div style="\n position: absolute;\n top: ${s}px;\n left: ${s}px;\n width: 14px;\n height: 14px;\n background-color: ${e};\n border-radius: 50%;\n box-sizing: border-box;\n "></div>\n </div>`}return`<div style="\n width: 14px;\n height: 14px;\n background-color: ${e};\n border-radius: 50%;\n box-sizing: border-box;\n opacity: ${t};\n filter: brightness(${i});\n transition: filter 0s ease-in, filter 150ms ease-out;\n "></div>`})}function j_(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}function G_(e){return e.startsWith("0x")?e.slice(2,4).toUpperCase():e.slice(0,2).toUpperCase()}function z_({hash:e,neighbor:t,isZeroHop:n,isHub:r,isGateway:i,isMobile:o,isRoomServer:a,centrality:A,lastHopData:l,affinity:c,txDelayRec:u,nodeOpacity:h,isHovered:d,onHover:p,onRequestRemove:g,isPopupOpen:m,onOpenPopup:_,onClosePopup:y,pulseIntensity:w=0}){const x=t.node_name||t.name||"Unknown",E=G_(e),T=(null==l?void 0:l.avgSnr)??void 0,S=(null==l?void 0:l.avgRssi)??void 0,C="stale"===(null==l?void 0:l.status),k=(null==l?void 0:l.lastSeen)??void 0,R=C?Math.min(h,.5):h,P=Math.round(20*R)/20,I=f.useMemo(()=>a?function(e=1,t=!1,n=!1){return D_(`roomserver:${e}:${t}:${n}`,()=>{const r=t?1.25:1;if(n){const t=16,n=t+4,i=n+2,s=(i-t)/2,o=(i-n)/2;return`<div style="\n position: relative;\n width: ${i}px;\n height: ${i}px;\n opacity: ${e};\n filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)) brightness(${r});\n transition: filter 0s ease-in, filter 150ms ease-out;\n ">\n \x3c!-- Yellow inner stroke ring --\x3e\n <div style="\n position: absolute;\n top: ${o}px;\n left: ${o}px;\n width: ${n}px;\n height: ${n}px;\n background: transparent;\n border-radius: 50%;\n border: 2px solid ${Ae};\n box-sizing: border-box;\n opacity: 0.85;\n "></div>\n \x3c!-- Icon --\x3e\n <div style="\n position: absolute;\n top: ${s}px;\n left: ${s}px;\n width: ${t}px;\n height: ${t}px;\n display: flex;\n align-items: center;\n justify-content: center;\n ">${F_}</div>\n </div>`}return`<div style="\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: ${e};\n filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)) brightness(${r});\n transition: filter 0s ease-in, filter 150ms ease-out;\n ">${F_}</div>`})}(P,d,n):r?U_(se,P,d,n):i?U_(re,P,d,n):function(e=re,t=1,n=!1,r=!1){return D_(`ring:${e}:${t}:${n}:${r}`,()=>{const i=n?1.25:1;if(r){const n=18,r=n+2,s=(r-14)/2,o=(r-n)/2;return`<div style="\n position: relative;\n width: ${r}px;\n height: ${r}px;\n opacity: ${t};\n filter: brightness(${i});\n transition: filter 0s ease-in, filter 150ms ease-out;\n ">\n \x3c!-- Yellow inner stroke ring --\x3e\n <div style="\n position: absolute;\n top: ${o}px;\n left: ${o}px;\n width: ${n}px;\n height: ${n}px;\n background: transparent;\n border-radius: 50%;\n border: 2px solid ${Ae};\n box-sizing: border-box;\n opacity: 0.85;\n "></div>\n \x3c!-- Inner colored ring --\x3e\n <div style="\n position: absolute;\n top: ${s}px;\n left: ${s}px;\n width: 14px;\n height: 14px;\n background: transparent;\n border-radius: 50%;\n border: 5px solid ${e};\n box-sizing: border-box;\n "></div>\n </div>`}return`<div style="\n width: 14px;\n height: 14px;\n background: transparent;\n border-radius: 50%;\n border: 5px solid ${e};\n box-sizing: border-box;\n opacity: ${t};\n filter: brightness(${i});\n transition: filter 0s ease-in, filter 150ms ease-out;\n "></div>`})}(o?oe:re,P,d,n),[a,r,i,o,n,P,d]),M=n?20:14,L=f.useCallback(()=>p(e),[e,p]),N=f.useCallback(()=>p(null),[p]),B=f.useCallback(t=>{t.stopPropagation(),_(e)},[e,_]);return t.latitude&&t.longitude?s.jsxs(s.Fragment,{children:[s.jsx(b,{longitude:t.longitude,latitude:t.latitude,anchor:"center",children:s.jsx("div",{role:"button",tabIndex:0,"aria-label":`Node ${x}`,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",touchAction:"manipulation",WebkitTapHighlightColor:"transparent"},onClick:B,onTouchEnd:B,onMouseEnter:L,onMouseLeave:N,onKeyDown:t=>"Enter"===t.key&&_(e),children:s.jsx("div",{style:{pointerEvents:"none",filter:w>0?"brightness(1.5)":void 0,transition:"filter 1000ms ease-out"},dangerouslySetInnerHTML:{__html:I}})})}),m&&s.jsx(v,{longitude:t.longitude,latitude:t.latitude,anchor:"bottom",offset:[0,-M/2],closeOnClick:!0,onClose:y,className:"maplibre-popup",children:s.jsx(ve,{hash:e,hashPrefix:E,name:x,isHub:r,isZeroHop:n,isMobile:o,isRoomServer:a,isStale:C,lastSeenTimestamp:k,centrality:A,affinity:c,meanSnr:T,meanRssi:S,neighbor:t,txDelayRec:u,onRemove:g?()=>g(e,x):void 0})})]}):null}function V_({localNode:e,localHash:t,isHovered:n,onHover:r,isPopupOpen:i,onOpenPopup:o,onClosePopup:a,pulseIntensity:A=0}){const l=f.useMemo(()=>function(e=!1){return D_(`local:${e}`,()=>`<div style="\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)) brightness(${e?1.25:1});\n transition: filter 0s ease-in, filter 150ms ease-out;\n ">${O_}</div>`)}(n),[n]),c=f.useCallback(()=>r("local"),[r]),u=f.useCallback(()=>r(null),[r]),h=f.useCallback(e=>{e.stopPropagation(),o()},[o]);return e.latitude&&e.longitude?s.jsxs(s.Fragment,{children:[s.jsx(b,{longitude:e.longitude,latitude:e.latitude,anchor:"center",children:s.jsx("div",{role:"button",tabIndex:0,"aria-label":`Local node ${e.name}`,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",touchAction:"manipulation",WebkitTapHighlightColor:"transparent"},onClick:h,onTouchEnd:h,onMouseEnter:c,onMouseLeave:u,onKeyDown:e=>"Enter"===e.key&&o(),children:s.jsx("div",{style:{pointerEvents:"none",filter:A>0?"brightness(1.5)":void 0,transition:"filter 1000ms ease-out"},dangerouslySetInnerHTML:{__html:l}})})}),i&&s.jsx(v,{longitude:e.longitude,latitude:e.latitude,anchor:"bottom",offset:[0,-8],closeOnClick:!0,onClose:a,className:"maplibre-popup",children:s.jsxs("div",{className:"text-sm",children:[s.jsx("strong",{className:"text-base",children:e.name}),t&&s.jsx("span",{className:"ml-2 font-mono text-xs text-text-muted bg-surface-elevated px-1.5 py-0.5 rounded",children:G_(t)}),s.jsx("br",{}),s.jsx("span",{style:{color:ie},className:"font-medium",children:"This Node (Local)"}),s.jsx("br",{}),s.jsxs("span",{className:"text-xs text-text-muted",children:[e.latitude.toFixed(5),", ",e.longitude.toFixed(5)]})]})})]}):null}function W_({neighborsWithLocation:e,localNode:t,localHash:n,zeroHopNeighbors:r,lastHopNeighborMap:i,meshTopology:o,hoveredMarker:a,onMarkerHover:A,getNodeOpacity:l,shouldShowNode:c,onRequestRemove:u,localPulseIntensity:h=0,neighborPulseHashes:d,neighborPulseIntensity:p=0}){const[g,m]=f.useState(null),_=f.useCallback(e=>{m(e)},[]),b=f.useCallback(()=>{m(null)},[]),v=f.useMemo(()=>[...e].sort(([e,t],[n,i])=>{const s=(e,t)=>j_(t)?5e3:r.has(e)?3e3:o.hubNodes.includes(e)?2e3:o.gatewayNodes.includes(e)?1e3:0;return s(e,t)-s(n,i)}),[e,r,o.hubNodes,o.gatewayNodes]);return s.jsxs(s.Fragment,{children:[v.map(([e,t])=>{if(!t.latitude||!t.longitude)return null;const n=c(e),h=l(e,n);if(h<=.01)return null;const f=r.has(e),m=o.hubNodes.includes(e),v=o.gatewayNodes.includes(e),y=o.mobileNodes.includes(e),w=j_(t),x=o.centrality.get(e)||0,E=i.get(e)??null,T=o.fullAffinity.get(e),S=o.txDelayRecommendations.get(e),C=(null==d?void 0:d.has(e))?p:0;return s.jsx(z_,{hash:e,neighbor:t,isZeroHop:f,isHub:m,isGateway:v,isMobile:y,isRoomServer:w,centrality:x,lastHopData:E,affinity:T,txDelayRec:S,nodeOpacity:h,isHovered:a===e,onHover:A,onRequestRemove:u,isPopupOpen:g===e,onOpenPopup:_,onClosePopup:b,pulseIntensity:C},e)}),t&&t.latitude&&t.longitude&&s.jsx(V_,{localNode:t,localHash:n,isHovered:"local"===a,onHover:A,isPopupOpen:"local"===g,onOpenPopup:()=>_("local"),onClosePopup:b,pulseIntensity:h})]})}function H_(e,t=!1,n=!1,r=!1,i=.7){return e?t?he:n?de:fe:r?i>=.75?ce:le:i>=.85?le:i>=.7?ue:"#1F2937"}function $_(e,t,n){const r=t[1]-e[1],i=t[0]-e[0],s=Math.sqrt(r*r+i*i);if(0===s)return{line1:[e,t],line2:[e,t]};const o=2e-5*n,a=-i/s*o,A=r/s*o;return{line1:[[e[0]+a,e[1]+A],[t[0]+a,t[1]+A]],line2:[[e[0]-a,e[1]-A],[t[0]-a,t[1]-A]]}}function X_(e){return[e[1],e[0]]}const Q_={id:"topology-weak-edges",type:"line",paint:{"line-color":["get","color"],"line-width":["get","width"],"line-opacity":["get","opacity"]},layout:{"line-cap":"round","line-join":"round"}},Y_={id:"topology-validated-edges",type:"line",paint:{"line-color":["get","color"],"line-width":["get","width"],"line-opacity":["get","opacity"]},layout:{"line-cap":"round","line-join":"round"}},q_={id:"topology-validated-edges-hitarea",type:"line",paint:{"line-color":"transparent","line-width":16,"line-opacity":0},layout:{"line-cap":"round","line-join":"round"}};function K_({showTopology:e,isExiting:t,validatedPolylines:n,weakPolylines:r,edgeAnimProgress:i,weightAnimProgress:o,animStartWeights:a,animTargetWeights:A,maxCertainCount:l,loopEdgeKeys:c,backboneEdgeKeys:u,hoveredEdgeKey:h,onEdgeHover:d,highlightedEdgeKey:p,neighbors:g}){const m=e||t,_=f.useMemo(()=>m?function(e,t){const n=[];for(const{from:r,to:i,edge:s}of e){const e=t.get(s.key)??0;if(e<=0)continue;const o=[r[0]+(i[0]-r[0])*e,r[1]+(i[1]-r[1])*e];n.push({type:"Feature",properties:{key:s.key,color:ue,width:1.5,opacity:.5*e,isLoopEdge:!1,isBackbone:!1,isDirectPath:!1,isHubConnection:!1,certainCount:s.certainCount,confidence:s.avgConfidence??.7,symmetryRatio:s.symmetryRatio??1,dominantDirection:s.dominantDirection??"balanced",fromName:"",toName:""},geometry:{type:"LineString",coordinates:[X_(r),X_(o)]}})}return{type:"FeatureCollection",features:n}}(r,i):{type:"FeatureCollection",features:[]},[r,i,m]),b=f.useMemo(()=>m?function(e,t,n,r,i,s,o,a,A,l,c){const u=[];for(const{from:h,to:d,edge:f}of e){const e=t.get(f.key)??0;if(e<=0)continue;const s=i.get(f.key)??J(f.certainCount),p=r.get(f.key)??s,g=p+(s-p)*n,m=o.has(f.key),_=a.has(f.key),b=f.avgConfidence??.7,v=A===f.key,y=null!==A,w=l===f.key,x=c[f.fromHash],E=c[f.toHash],T=(null==x?void 0:x.node_name)||(null==x?void 0:x.name)||f.fromHash.slice(0,8),S=(null==E?void 0:E.node_name)||(null==E?void 0:E.name)||f.toHash.slice(0,8),C=[h[0]+(d[0]-h[0])*e,h[1]+(d[1]-h[1])*e],k=.82*Math.min(1.5*e,1),R=y?v?1.25:.4:1;if(m){const{line1:e,line2:t}=$_(h,C,1.5*g),n=v?de:le,r=1.1*k*R,i=v?Math.max(2.5,.8*g):Math.max(1.5,.6*g);u.push({type:"Feature",properties:{key:`${f.key}-loop1`,color:n,width:i,opacity:r,isLoopEdge:!0,isBackbone:!1,isDirectPath:f.isDirectPathEdge??!1,isHubConnection:f.isHubConnection??!1,certainCount:f.certainCount,confidence:b,symmetryRatio:f.symmetryRatio??1,dominantDirection:f.dominantDirection??"balanced",fromName:T,toName:S},geometry:{type:"LineString",coordinates:[X_(e[0]),X_(e[1])]}}),u.push({type:"Feature",properties:{key:`${f.key}-loop2`,color:n,width:i,opacity:r,isLoopEdge:!0,isBackbone:!1,isDirectPath:f.isDirectPathEdge??!1,isHubConnection:f.isHubConnection??!1,certainCount:f.certainCount,confidence:b,symmetryRatio:f.symmetryRatio??1,dominantDirection:f.dominantDirection??"balanced",fromName:T,toName:S},geometry:{type:"LineString",coordinates:[X_(t[0]),X_(t[1])]}});continue}const P=w?"#FFD700":H_(v,f.isDirectPathEdge??!1,!1,_,b);let I=w?Math.max(1.6*g,4.5):_?1.3*g:g;v&&!w&&(I=Math.max(1.2*I,3));let M=w?.95:_?1.15*k:k;M*=R,u.push({type:"Feature",properties:{key:f.key,color:P,width:I,opacity:M,isLoopEdge:!1,isBackbone:_,isDirectPath:f.isDirectPathEdge??!1,isHubConnection:f.isHubConnection??!1,certainCount:f.certainCount,confidence:b,symmetryRatio:f.symmetryRatio??1,dominantDirection:f.dominantDirection??"balanced",fromName:T,toName:S},geometry:{type:"LineString",coordinates:[X_(h),X_(C)]}})}return{type:"FeatureCollection",features:u}}(n,i,o,a,A,0,c,u,h,p,g):{type:"FeatureCollection",features:[]},[n,i,o,a,A,l,c,u,h,p,g,m]);return m?s.jsxs(s.Fragment,{children:[s.jsx(y,{id:"weak-edges",type:"geojson",data:_,children:s.jsx(w,{...Q_})}),s.jsxs(y,{id:"validated-edges",type:"geojson",data:b,children:[s.jsx(w,{...q_}),s.jsx(w,{...Y_})]})]}):null}const Z_=["topology-validated-edges-hitarea","topology-validated-edges"];function J_(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:[128,128,128]}const eb=J_(pe),tb=J_(ge),nb=J_(ge),rb=[...eb,153],ib=[...tb,255],sb=[0,0,0,0];function ob(e,t,n,r,i){return[t+(r-t)*i,e+(n-e)*i,2e4*i*(1-i)]}function ab(e,t){const[n,r]=e,[i,s]=t,o=function(e,t,n,r){const i=(n-e)*Math.PI/180,s=(r-t)*Math.PI/180,o=Math.sin(i/2)*Math.sin(i/2)+Math.cos(e*Math.PI/180)*Math.cos(n*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o))*6371}(n,r,i,s),a=Math.min(1.5/o,.5),A=a+Math.min(1.5/o,.5),l=[];let c=0;for(;c<1;){const e=Math.min(c+a,1),t=[],o=Math.max(2,Math.ceil(32*(e-c)));for(let a=0;a<=o;a++){const A=c+a/o*(e-c);t.push(ob(n,r,i,s,A))}l.push(t),c+=A}return{segments:l,totalSegments:l.length}}function Ab({neighborPolylines:e,hoveredEdgeKey:t,onEdgeHover:n,visible:r=!0}){const{setLayers:i,isReady:s}=y_(),o=f.useRef(null),a=f.useRef(-1),A=f.useRef([]),l=f.useRef(null);f.useEffect(()=>{l.current=t},[t]),f.useEffect(()=>{const t=[];for(const{from:n,to:r,hash:i,neighbor:s,lastHopData:o}of e){const e=s.node_name||s.name||i.slice(0,8),a=(null==o?void 0:o.avgSnr)??s.snr,A=(null==o?void 0:o.avgRssi)??s.rssi,l=`neighbor-${i}`,{segments:c,totalSegments:u}=ab(n,r);c.forEach((n,r)=>{t.push({path:n,parentKey:l,segmentIndex:r,totalSegments:u,hash:i,name:e,prefix:null==o?void 0:o.prefix,rssi:A,snr:a,packetCount:null==o?void 0:o.count,confidence:null==o?void 0:o.confidence,hasAvgRssi:void 0!==(null==o?void 0:o.avgRssi),hasAvgSnr:void 0!==(null==o?void 0:o.avgSnr)})})}A.current=t},[e]);const c=f.useCallback((e,t,n)=>{if(e.parentKey===n)return ib;if(t<0)return rb;const r=(e.segmentIndex+.5)/e.totalSegments,i=Math.abs(r-t),s=Math.max(0,1-i/.15);return 0===s?rb:(sb[0]=eb[0]+(nb[0]-eb[0])*s|0,sb[1]=eb[1]+(nb[1]-eb[1])*s|0,sb[2]=eb[2]+(nb[2]-eb[2])*s|0,sb[3]=153+102*s|0,sb)},[]),u=f.useCallback((e,t)=>new tm({id:"neighbor-arcs",data:A.current,pickable:!0,getPath:e=>e.path,getColor:n=>c(n,e,t),getWidth:e=>e.parentKey===t?3:1.875,widthUnits:"pixels",widthMinPixels:1,capRounded:!0,jointRounded:!0,onHover:e=>{e.object?n(e.object.parentKey):n(null)},updateTriggers:{getColor:[t,e],getWidth:[t]}}),[c,n]),h=f.useRef(i);return f.useEffect(()=>{h.current=i},[i]),f.useEffect(()=>{if(!s||0===e.length||!r)return void h.current("neighbor-arcs",[]);let t=!0,n=performance.now(),i=null;const A=()=>{t&&(n=performance.now(),a.current=0,o.current=requestAnimationFrame(c))},c=e=>{if(!t)return;const r=e-n;if(r<1500){const e=1.15*(s=r/1500,1-Math.pow(1-s,3));a.current=e;const t=u(e,l.current);h.current("neighbor-arcs",[t]),o.current=requestAnimationFrame(c)}else{a.current=-1;const e=u(-1,l.current);h.current("neighbor-arcs",[e]),i=setTimeout(A,7e3)}var s};return A(),()=>{t=!1,null!==o.current&&cancelAnimationFrame(o.current),null!==i&&clearTimeout(i),h.current("neighbor-arcs",[])}},[s,e,u,r]),f.useEffect(()=>{if(!s||0===e.length||!r)return;const n=u(a.current,t);h.current("neighbor-arcs",[n])},[t,u,e.length,s]),null}const lb=["neighbor-arcs"];function cb({positions:e}){const{current:t}=_(),n=f.useRef(!1);return f.useEffect(()=>{if(t&&0!==e.length&&!n.current)if(n.current=!0,1===e.length)t.flyTo({center:[e[0][1],e[0][0]],zoom:14,duration:1e3});else{const n=e.map(([e,t])=>[t,e]);let r=1/0,i=-1/0,s=1/0,o=-1/0;for(const[e,t]of n)r=Math.min(r,e),i=Math.max(i,e),s=Math.min(s,t),o=Math.max(o,t);const a=[[r,s],[i,o]];t.fitBounds(a,{padding:{top:15,bottom:15,left:15,right:15},maxZoom:16,duration:1e3})}},[t,e]),null}function ub({targetHash:e,nodeCoordinates:t,onComplete:n}){const{current:r}=_(),i=f.useRef(null);return f.useEffect(()=>{if(!r||!e||e===i.current)return;const s=t.get(e);if(!s)return;i.current=e;const[o,a]=s;r.flyTo({center:[a,o],zoom:15,duration:2500,essential:!0}),setTimeout(()=>{null==n||n()},2600)},[e,t,r,n]),null}function hb({highlightedEdgeKey:e,validatedPolylines:t,weakPolylines:n,onEnsureTopology:r}){const{current:i}=_();return f.useEffect(()=>{if(!i||!e)return;r();const s=t.find(t=>t.edge.key===e)||n.find(t=>t.edge.key===e);if(!s)return;const o=(s.from[0]+s.to[0])/2,a=(s.from[1]+s.to[1])/2,A=i.getZoom(),l=Math.max(A,11);i.flyTo({center:[a,o],zoom:l,duration:500,essential:!0})},[e,t,n,i,r]),null}const db={longitude:0,latitude:0,zoom:2};function fb({type:e,properties:t,maxCertainCount:n}){if("neighbor"===e){const e=t;return s.jsxs("div",{className:"text-xs",children:[s.jsxs("div",{className:"font-medium text-text-primary",children:[s.jsx("span",{className:"text-amber-400",children:"●"})," ",e.name,e.prefix&&s.jsxs("span",{className:"ml-1 text-text-muted font-mono text-[10px]",children:["(",e.prefix,")"]})]}),s.jsxs("div",{className:"text-text-secondary flex gap-2",children:[void 0!==e.rssi&&null!==e.rssi&&s.jsxs("span",{children:["RSSI: ",Math.round(e.rssi)," dBm",e.hasAvgRssi&&" avg"]}),void 0!==e.snr&&null!==e.snr&&s.jsxs("span",{children:["SNR: ",Number(e.snr).toFixed(1)," dB",e.hasAvgSnr&&" avg"]})]}),void 0!==e.packetCount&&s.jsxs("div",{className:"text-text-muted text-[10px]",children:[Number(e.packetCount).toLocaleString()," packets",void 0!==e.confidence&&` • ${Math.round(100*Number(e.confidence))}% conf`]}),s.jsx("div",{className:"text-amber-400 text-[10px] mt-0.5",children:"Direct RF neighbor"})]})}const r=t,i=n>0?Number(r.certainCount)/n:0;return s.jsxs("div",{className:"text-xs",children:[s.jsxs("div",{className:"font-medium text-text-primary",children:[r.fromName," ↔ ",r.toName]}),s.jsxs("div",{className:"text-text-secondary",children:[r.certainCount," validations (",Math.round(100*i),"%) • ",Math.round(100*Number(r.confidence)),"% conf"]}),r.isBackbone&&s.jsx("div",{className:"text-gray-300 font-semibold",children:"Backbone"}),r.isLoopEdge&&s.jsx("div",{className:"text-indigo-400 text-[10px] mt-0.5",children:"Redundant path"}),r.isDirectPath&&s.jsx("div",{className:"text-teal-400 text-[10px]",children:"Direct path"})]})}function pb({neighbors:e,localNode:t,localHash:n,onRemoveNode:r,selectedNodeHash:i,onNodeSelected:o,highlightedEdgeKey:a}){const A=f.useRef(null),l=c(),p=u(),g=h(),m=d(),[_,b]=f.useState(db),[y,w]=f.useState(!1),[S,C]=f.useState(!1),[k,R]=f.useState(!0),[I,M]=f.useState(!0),[L,N]=f.useState(!1),[B,D]=f.useState(!1),[O,F]=f.useState(null),[U,j]=f.useState(null),[G,z]=f.useState(null),[V,W]=f.useState(""),[H,$]=f.useState(!1),[X,Q]=f.useState("fetching"),[Y,q]=f.useState(!1),[K,Z]=f.useState(0),ee=Le(e=>e.coveragePoints),te=Le(e=>e.isVisible),re=Le(e=>e.openModal),ie=f.useRef(!1);f.useEffect(()=>{ee.length>0&&te&&!ie.current&&(R(!1),ie.current=!0)},[ee.length,te]);const[se,oe]=f.useState(null),ae=f.useMemo(()=>Object.entries(e).filter(([,e])=>e.latitude&&e.longitude),[e]),Ae=f.useMemo(()=>{const e=[];(null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&e.push([t.latitude,t.longitude]);for(const[,t]of ae)t.latitude&&t.longitude&&e.push([t.latitude,t.longitude]);return e},[t,ae]),le=f.useMemo(()=>{const e=new Map;n&&(null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&e.set(n,[t.latitude,t.longitude]);for(const[t,n]of ae)n.latitude&&n.longitude&&e.set(t,[n.latitude,n.longitude]);return e},[n,t,ae]),ce=f.useMemo(()=>{const e=new Map;for(const t of g)"expired"!==t.status&&e.set(t.hash,{hash:t.hash,prefix:t.prefix,count:t.count,avgRssi:t.avgRssi,avgSnr:t.avgSnr,lastSeen:t.lastSeen,confidence:1,status:t.status});return e},[g]),ue=f.useMemo(()=>{var t,n;const r=new Set;for(const i of ce.keys())(null==(t=e[i])?void 0:t.latitude)&&(null==(n=e[i])?void 0:n.longitude)&&r.add(i);return r},[ce,e]),he=f.useMemo(()=>{const e=[];for(const t of l.validatedEdges){const n=le.get(t.fromHash),r=le.get(t.toHash);n&&r&&e.push({from:n,to:r,edge:t})}return e},[l.validatedEdges,le]),de=f.useMemo(()=>{const e=[];for(const t of l.weakEdges){const n=le.get(t.fromHash),r=le.get(t.toHash);n&&r&&e.push({from:n,to:r,edge:t})}return e},[l.weakEdges,le]),fe=f.useMemo(()=>{if(!(null==t?void 0:t.latitude)||!(null==t?void 0:t.longitude))return[];const n=[],r=[t.latitude,t.longitude];for(const t of ue){const i=e[t];(null==i?void 0:i.latitude)&&(null==i?void 0:i.longitude)&&n.push({from:r,to:[i.latitude,i.longitude],hash:t,neighbor:i,lastHopData:ce.get(t)??null})}return n},[t,ue,e,ce]),pe=f.useMemo(()=>new Set(l.loopEdgeKeys),[l.loopEdgeKeys]),ge=f.useMemo(()=>new Set(l.backboneEdges),[l.backboneEdges]),_e=f.useMemo(()=>{let e=0;for(const t of l.validatedEdges)t.certainCount>e&&(e=t.certainCount);return e||1},[l.validatedEdges]),{edgeAnimProgress:be,weightAnimProgress:ve,animStartWeights:we,animTargetWeights:xe,isExiting:Se,resetAnimationState:Ce}=function({showTopology:e,polylines:t,weakPolylines:n,maxCertainCount:r,getWeight:i}){const[s,o]=f.useState(new Map),[a,A]=f.useState(1),[l,c]=f.useState(!1),u=f.useRef(e),h=f.useRef(new Set),d=f.useRef(""),[p,g]=f.useState(new Map),[m,_]=f.useState(new Map),b=f.useRef(new Map),v=f.useRef(new Map);f.useEffect(()=>{v.current=s},[s]);const y=f.useCallback(()=>{o(new Map),h.current=new Set,d.current="",g(new Map),_(new Map)},[]);return f.useEffect(()=>{const t=u.current,n=e;if(u.current=e,t&&!n&&!l){c(!0);const e=new Map(v.current);let t=null;const n=r=>{t||(t=r);const i=r-t,s=Math.min(i/500,1),a=(A=s,1-Math.pow(1-A,3));var A;o(()=>{const t=new Map;for(const[n,r]of e)t.set(n,r*(1-a));return t}),s<1?requestAnimationFrame(n):(c(!1),o(new Map),h.current=new Set,d.current="",g(new Map),_(new Map))};requestAnimationFrame(n)}!t&&n&&(o(new Map),h.current=new Set,d.current="")},[e,l]),f.useEffect(()=>{if(!e||l)return;const s=[...t,...n],a=s.map(e=>`${e.edge.key}:${e.edge.certainCount}`).sort().join(","),c=0===h.current.size,u=""!==d.current&&d.current!==a;if(c||u){const e=[],n=[];for(const{edge:t}of s)h.current.has(t.key)?n.push(t.key):e.push(t.key);if(u&&n.length>0){const e=new Map;for(const t of n){const n=b.current.get(t);void 0!==n&&e.set(t,n)}g(e),A(0)}const a=new Map;for(const{edge:s}of t){const e=i(s.certainCount,r);a.set(s.key,e)}if(_(a),o(t=>{const r=new Map(t);for(const n of e)r.set(n,0);for(const e of n)r.has(e)||r.set(e,1);return r}),e.length>0){let t=null;const n=Math.min(100,me/e.length/2),r=i=>{t||(t=i);const s=i-t;o(t=>{const r=new Map(t);return e.forEach((e,t)=>{const i=t*n,o=Math.max(0,s-i),a=E_(Math.min(o/me,1));r.set(e,a)}),r});const a=me+(e.length-1)*n;s<a&&requestAnimationFrame(r)};requestAnimationFrame(r)}if(u&&n.length>0){let e=null;const t=n=>{e||(e=n);const r=n-e,i=Math.min(r/me,1),s=E_(i);A(s),i<1&&requestAnimationFrame(t)};requestAnimationFrame(t)}for(const t of e)h.current.add(t)}for(const{edge:e}of t){const t=i(e.certainCount,r);b.current.set(e.key,t)}d.current=a},[e,l,t,n,r,i]),{edgeAnimProgress:s,weightAnimProgress:a,isExiting:l,animStartWeights:p,animTargetWeights:m,resetAnimationState:y}}({showTopology:S,polylines:he,weakPolylines:de,maxCertainCount:_e,getWeight:J}),ke=f.useMemo(()=>{const e=new Set;for(const t of l.hubNodes){e.add(t);for(const n of l.validatedEdges)n.fromHash===t&&e.add(n.toHash),n.toHash===t&&e.add(n.fromHash)}return e},[l.hubNodes,l.validatedEdges]),Re=f.useMemo(()=>{const e=new Set;if(!n)return e;for(const t of l.validatedEdges)t.fromHash===n&&e.add(t.toHash),t.toHash===n&&e.add(t.fromHash);return e},[n,l.validatedEdges]),{getNodeOpacity:Pe}=function({soloDirect:e,soloHubs:t,neighborHashes:n,hubConnectedNodes:r,directNodeSet:i,localConnectedNodes:s,showTopology:o}){const[a,A]=f.useState(new Map),l=f.useRef(e),c=f.useRef(t),u=f.useRef(new Map),h=f.useRef(null),d=f.useRef(r),p=f.useRef(i),g=f.useRef(s),m=f.useRef(o);return f.useEffect(()=>{d.current=r,p.current=i,g.current=s,m.current=o},[r,i,s,o]),f.useEffect(()=>{const r=l.current,i=c.current,s=e,o=t;if(l.current=e,c.current=t,r===s&&i===o)return;h.current&&(cancelAnimationFrame(h.current),h.current=null);const a=d.current,f=p.current,_=g.current,b=m.current;for(const e of n)u.current.has(e)||u.current.set(e,Math.random());const v=(e,t,n)=>{const r=a.has(e),i=f.has(e),s=b&&_.has(e);return!t&&!n||(t&&n?r||i||s:n?r:!t||i||s)},y=[];for(const e of n){const t=v(e,r,i),n=v(e,s,o);t!==n&&y.push({hash:e,startOpacity:t?1:0,targetOpacity:n?1:0})}if(0===y.length)return;A(e=>{const t=new Map(e);for(const{hash:n,startOpacity:r}of y)t.set(n,r);return t});const w=y;let x=null;const E=e=>{x||(x=e);const t=e-x;let n=!0;A(()=>{const e=new Map;for(const{hash:r,startOpacity:i,targetOpacity:s}of w){const o=250*(u.current.get(r)??0),a=Math.max(0,t-o),A=Math.min(a/500,1),l=i+(s-i)*T_(A);e.set(r,l),A<1&&(n=!1)}return e}),t<750&&!n?h.current=requestAnimationFrame(E):(h.current=null,A(new Map))};return h.current=requestAnimationFrame(E),()=>{h.current&&(cancelAnimationFrame(h.current),h.current=null)}},[e,t,n]),{nodeOpacities:a,getNodeOpacity:(e,t)=>a.has(e)?a.get(e):t?1:0}}({soloDirect:L,soloHubs:B,neighborHashes:ae.map(([e])=>e),hubConnectedNodes:ke,directNodeSet:ue,localConnectedNodes:Re,showTopology:S}),Ie=f.useCallback(e=>{if(!L&&!B)return!0;if(L)return ue.has(e);if(B){if(l.hubNodes.includes(e))return!0;for(const t of l.validatedEdges){if(t.fromHash===e&&l.hubNodes.includes(t.toHash))return!0;if(t.toHash===e&&l.hubNodes.includes(t.fromHash))return!0}return!1}return!0},[L,B,ue,l.hubNodes,l.validatedEdges]),Me=f.useCallback(async()=>{q(!0),$(!0),Q("fetching"),Z(0),await p(),Z(m.packetCount),Q("analyzing"),await new Promise(e=>setTimeout(e,200)),Q("building");const e=Date.now(),t=Date.now()-e;t<1700&&await new Promise(e=>setTimeout(e,1700-t)),Q("complete"),await new Promise(e=>setTimeout(e,1e3)),$(!1),q(!1),Ce(),setTimeout(()=>{C(!0)},150)},[p,Ce,m.packetCount]),Ne=f.useCallback(e=>{b(e.viewState)},[]),De=f.useCallback(()=>{w(e=>!e)},[]),Oe=f.useCallback(()=>{C(e=>!e)},[]),Fe=f.useCallback(()=>{N(e=>!e)},[]),Ue=f.useCallback(()=>{D(e=>!e)},[]),je=f.useCallback(()=>{R(e=>!e)},[]),Ge=f.useCallback(()=>{M(e=>!e)},[]),ze=f.useCallback(()=>{S||C(!0)},[S]),Ve=f.useCallback((e,t)=>{z(e),W(t)},[]),We=f.useCallback(()=>{G&&r&&r(G),z(null),W("")},[G,r]),He=f.useMemo(()=>[...Z_,...lb],[]),$e=f.useCallback(e=>{var t;if(!e.features||0===e.features.length)return;const n=e.features[0],r=null==(t=n.layer)?void 0:t.id,i=n.properties;if(!(null==i?void 0:i.key))return;const s=null==r?void 0:r.startsWith("topology-"),o=null==r?void 0:r.startsWith("neighbor-");if(s||o){const t=i.key.replace(/-loop[12]$/,"");j(t),e.lngLat&&oe({longitude:e.lngLat.lng,latitude:e.lngLat.lat,type:s?"topology":"neighbor",properties:i})}A.current&&(A.current.getCanvas().style.cursor="pointer")},[]),Xe=f.useCallback(()=>{j(null),oe(null),A.current&&(A.current.getCanvas().style.cursor="")},[]),Qe=y?"h-screen":"h-[500px]";return s.jsxs("div",{className:`relative ${Qe} ${y?"fixed inset-0 z-50":""}`,children:[s.jsx("div",{className:"relative w-full h-full "+(y?"":"rounded-[1.125rem] overflow-hidden"),children:s.jsxs(x,{ref:A,..._,onMove:Ne,mapStyle:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:He,onMouseMove:$e,onMouseLeave:Xe,onLoad:e=>{const t=e.target,n=t.getStyle();if(null==n?void 0:n.layers)for(const r of n.layers)"symbol"===r.type&&(t.setPaintProperty(r.id,"text-color","rgba(50, 52, 58, 1)"),t.setPaintProperty(r.id,"text-halo-color","rgba(8, 9, 11, 0.9)"),t.setPaintProperty(r.id,"text-halo-width",1),t.setLayoutProperty(r.id,"text-font",["Inter","Open Sans Regular","Arial Unicode MS Regular"]))},children:[s.jsx(E,{position:"top-left",style:{marginTop:"1rem",marginLeft:"1rem"}}),s.jsx(T,{position:"bottom-right"}),s.jsx(cb,{positions:Ae}),s.jsxs(v_,{children:[s.jsx(x_,{coveragePoints:ee,visible:ee.length>0&&te}),s.jsx(Ab,{neighborPolylines:fe,hoveredEdgeKey:U,onEdgeHover:j,visible:k})]}),i&&s.jsx(ub,{targetHash:i,nodeCoordinates:le,onComplete:o}),a&&s.jsx(hb,{highlightedEdgeKey:a,validatedPolylines:he,weakPolylines:de,onEnsureTopology:ze}),s.jsx(K_,{showTopology:S,isExiting:Se,validatedPolylines:he,weakPolylines:de,edgeAnimProgress:be,weightAnimProgress:ve,animStartWeights:we,animTargetWeights:xe,maxCertainCount:_e,loopEdgeKeys:pe,backboneEdgeKeys:ge,hoveredEdgeKey:U,onEdgeHover:j,highlightedEdgeKey:a,neighbors:e}),I&&s.jsx(W_,{neighborsWithLocation:ae,localNode:t,localHash:n,zeroHopNeighbors:ue,lastHopNeighborMap:ce,meshTopology:l,hoveredMarker:O,onMarkerHover:F,getNodeOpacity:Pe,shouldShowNode:Ie,onRequestRemove:r?Ve:void 0}),se&&s.jsx(v,{longitude:se.longitude,latitude:se.latitude,anchor:"bottom",offset:[0,-20],closeButton:!1,closeOnClick:!1,className:"maplibre-popup",children:s.jsx(fb,{type:se.type,properties:se.properties,maxCertainCount:_e})})]})}),s.jsx(Ee,{isDeepLoading:Y,showDeepAnalysisModal:H,onDeepAnalysis:Me,showTopology:S,onToggleTopology:Oe,hasValidatedPolylines:he.length>0,showNeighborLines:k,onToggleNeighborLines:je,hasNeighborPolylines:fe.length>0,showNodes:I,onToggleNodes:Ge,soloHubs:B,onToggleSoloHubs:Ue,hasHubNodes:l.hubNodes.length>0,soloDirect:L,onToggleSoloDirect:Fe,hasZeroHopNeighbors:ue.size>0,isFullscreen:y,onToggleFullscreen:De}),s.jsxs("div",{className:"absolute bottom-4 left-4 z-[600] flex flex-col gap-2",style:{maxWidth:"150px"},children:[s.jsx(Te,{isActive:ee.length>0&&te,onClick:re}),s.jsx(ye,{showTopology:S,validatedPolylineCount:he.length,filteredNeighborCount:ae.length,hasLocalNode:!(!(null==t?void 0:t.latitude)||!(null==t?void 0:t.longitude)),meshTopology:l,zeroHopNeighbors:ue,neighborsWithLocation:ae})]}),!y&&s.jsx("div",{className:"glass-card-frame absolute inset-0 pointer-events-none rounded-[1.125rem]","aria-hidden":"true"}),s.jsx(P,{isOpen:null!==G,onCancel:()=>z(null),onConfirm:We,title:"Remove Node?",message:`Remove "${V}" from the contacts list? This will hide the node until it sends a new packet.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),s.jsx(ne,{isOpen:H,currentStep:X,packetCount:K}),s.jsx(Be,{})]})}export{pb as default};