var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(let c of r(i))!a.call(e,c)&&c!==o&&(s=n(i,c),t(e,c,{get:s&&s.get&&!s.configurable?s.get:()=>i[c],enumerable:!s||s.enumerable}));return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function P(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;for(e.push(t);0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break t}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break e}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=f(),n=u(),r=m();function i(e){var t=`https://react.dev/errors/`+e;if(1pe||(e.current=fe[pe],fe[pe]=null,pe--)}function ge(e,t){pe++,fe[pe]=e.current,e.current=t}var _e=me(null),ve=me(null),ye=me(null),be=me(null);function xe(e,t){switch(ge(ye,t),ge(ve,e),ge(_e,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?xp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=xp(t),e=Sp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}he(_e),ge(_e,e)}function Se(){he(_e),he(ve),he(ye)}function Ce(e){var t=e.memoizedState;t!==null&&(_h._currentValue=t.memoizedState,ge(be,e)),t=_e.current;var n=Sp(t,e.type);t!==n&&(ge(ve,e),ge(_e,n))}function we(e){ve.current===e&&(he(_e),he(ve)),be.current===e&&(he(be),_h._currentValue=de)}var Te,Ee;function De(e){if(Te===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Te=t&&t[1]||``,Ee=-1)`:-1i||c[r]!==l[i]){var u=` `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Oe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?De(n):``}function Ae(e,t){switch(e.tag){case 26:case 27:case 5:return De(e.type);case 16:return De(`Lazy`);case 13:return e.child!==t&&t!==null?De(`Suspense Fallback`):De(`Suspense`);case 19:return De(`SuspenseList`);case 0:case 15:return ke(e.type,!1);case 11:return ke(e.type.render,!1);case 1:return ke(e.type,!0);case 31:return De(`Activity`);case 30:return De(`ViewTransition`);default:return``}}function je(e){try{var t=``,n=null;do t+=Ae(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}var Me=Object.prototype.hasOwnProperty,Ne=t.unstable_scheduleCallback,Pe=t.unstable_cancelCallback,Fe=t.unstable_shouldYield,Ie=t.unstable_requestPaint,Le=t.unstable_now,Re=t.unstable_getCurrentPriorityLevel,ze=t.unstable_ImmediatePriority,Be=t.unstable_UserBlockingPriority,Ve=t.unstable_NormalPriority,He=t.unstable_LowPriority,Ue=t.unstable_IdlePriority,We=t.log,Ge=t.unstable_setDisableYieldValue,Ke=null,qe=null;function Je(e){if(typeof We==`function`&&Ge(e),qe&&typeof qe.setStrictMode==`function`)try{qe.setStrictMode(Ke,e)}catch{}}var Ye=Math.clz32?Math.clz32:Qe,Xe=Math.log,Ze=Math.LN2;function Qe(e){return e>>>=0,e===0?32:31-(Xe(e)/Ze|0)|0}var $e=256,et=262144,tt=4194304;function nt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 0x8000000:return 0x8000000;case 268435456:return 268435456;case 536870912:return 536870912;case 0x40000000:return 0;default:return e}}function rt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&0x7ffffff;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=nt(n))):i=nt(o):i=nt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=nt(n))):i=nt(o)):i=nt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function it(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function at(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function lt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ut(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=ur),pr=` `,mr=!1;function hr(e,t){switch(e){case`keyup`:return cr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function gr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var _r=!1;function vr(e,t){switch(e){case`compositionend`:return gr(t);case`keypress`:return t.which===32?(mr=!0,pr):null;case`textInput`:return e=t.data,e===pr&&mr?null:e;default:return null}}function yr(e,t){if(_r)return e===`compositionend`||!lr&&hr(e,t)?(e=jn(),An=kn=On=null,_r=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Hr(n)}}function Wr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Wr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Gr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Vr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Vr(e.document)}return t}function Kr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var qr=Tn&&`documentMode`in document&&11>=document.documentMode,Jr=null,Yr=null,Xr=null,Zr=!1;function Qr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Zr||Jr==null||Jr!==Vr(r)||(r=Jr,`selectionStart`in r&&Kr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Xr&&Br(Xr,r)||(Xr=r,r=ip(Yr,`onSelect`),0>=o,i-=o,Ji=1<<32-Ye(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),ra&&Xi(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),ra&&Xi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return ra&&Xi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),ra&&Xi(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===j&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case k:e:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===j){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),so(c,o),c.return=e,e=c;break e}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===z&&eo(l)===r.type){n(e,r.sibling),c=a(r,o.props),so(c,o),c.return=e,e=c;break e}n(e,r);break}t(e,r),r=r.sibling}o.type===j?(c=Fi(o.props.children,e.mode,c,o.key),so(c,o),c.return=e,e=c):(c=Pi(o.type,o.key,o.props,null,e.mode,c),so(c,o),c.return=e,e=c)}return s(e);case A:e:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break e}n(e,r);break}t(e,r),r=r.sibling}c=Ri(o,e.mode,c),c.return=e,e=c}return s(e);case z:return o=eo(o),_(e,r,o,c)}if(le(o))return h(e,r,o,c);if(oe(o)){if(l=oe(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,oo(o),c);if(o.$$typeof===F)return _(e,r,Ta(e,o),c);co(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Ii(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ao=0;var i=_(e,t,n,r);return io=null,i}catch(t){if(t===Ja||t===Xa)throw t;var a=Ai(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var uo=lo(!0),fo=lo(!1),po=!1;function mo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ho(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function go(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function _o(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,id&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Di(e),Ei(e,null,n),t}return Ci(e,r,t,n),Di(e)}function vo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ft(e,n)}}function yo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var bo=!1;function xo(){if(bo){var e=za;if(e!==null)throw e}}function So(e,t,n,r){bo=!1;var i=e.updateQueue;po=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(sd&f)===f:(r&f)===f){f!==0&&f===Ra&&(bo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break e}d=m;break e;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break e;d=D({},d,f);break e;case 2:po=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),hd|=o,e.lanes=o,e.memoizedState=d}}function Co(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function wo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=V.T,s={};s.types=o===null?null:o.types,V.T=s,fc(e,!1,t,n);try{var c=i(),l=V.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?dc(e,t,Ha(c,r),Bd(e)):dc(e,t,r,Bd(e))}catch(n){dc(e,t,{then:function(){},status:`rejected`,reason:n},Bd())}finally{ue.p=a,o!==null&&s.types!==null&&(o.types=s.types),V.T=o}}function tc(){}function nc(e,t,n,r){if(e.tag!==5)throw Error(i(476));ec(e,rc(e).queue,t,de,n===null?tc:function(){return ic(e),n(r)})}function rc(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:de,baseState:de,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:de},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ic(e){var t=rc(e);t.next===null&&(t=e.alternate.memoizedState),dc(e,t.next.queue,{},Bd())}function ac(){return wa(_h)}function oc(){return cs().memoizedState}function sc(){return cs().memoizedState}function cc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Bd();e=go(n);var r=_o(t,e,n);r!==null&&(Ud(r,t,n),vo(r,t,n)),t={cache:ja()},e.payload=t;return}t=t.return}}function lc(e,t,n){var r=Bd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},pc(e)?mc(t,n):(n=wi(e,t,n,r),n!==null&&(Ud(n,e,r),hc(n,t,r)))}function uc(e,t,n){dc(e,t,n,Bd())}function dc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(pc(e))mc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,zr(s,o))return Ci(e,t,i,0),ad===null&&Si(),!1}catch{}if(n=wi(e,t,i,r),n!==null)return Ud(n,e,r),hc(n,t,r),!0}return!1}function fc(e,t,n,r){if(r={lane:2,revertLane:Uf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},pc(e)){if(t)throw Error(i(479))}else t=wi(e,n,r,2),t!==null&&Ud(t,e,2)}function pc(e){var t=e.alternate;return e===Ho||t!==null&&t===Ho}function mc(e,t){Ko=Go=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ft(e,n)}}var gc={readContext:wa,use:ds,useCallback:Qo,useContext:Qo,useEffect:Qo,useImperativeHandle:Qo,useLayoutEffect:Qo,useInsertionEffect:Qo,useMemo:Qo,useReducer:Qo,useRef:Qo,useState:Qo,useDebugValue:Qo,useDeferredValue:Qo,useTransition:Qo,useSyncExternalStore:Qo,useId:Qo,useHostTransitionStatus:Qo,useFormState:Qo,useActionState:Qo,useOptimistic:Qo,useMemoCache:Qo,useCacheRefresh:Qo,useEffectEvent:Qo},_c={readContext:wa,use:ds,useCallback:function(e,t){return ss().memoizedState=[e,t===void 0?null:t],e},useContext:wa,useEffect:Vs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),zs(4194308,4,qs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return zs(4194308,4,e,t)},useInsertionEffect:function(e,t){zs(4,2,e,t)},useMemo:function(e,t){var n=ss();t=t===void 0?null:t;var r=e();if(qo){Je(!0);try{e()}finally{Je(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ss();if(n!==void 0){var i=n(t);if(qo){Je(!0);try{n(t)}finally{Je(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=lc.bind(null,Ho,e),[r.memoizedState,e]},useRef:function(e){var t=ss();return e={current:e},t.memoizedState=e},useState:function(e){e=Cs(e);var t=e.queue,n=uc.bind(null,Ho,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ys,useDeferredValue:function(e,t){return Qs(ss(),e,t)},useTransition:function(){var e=Cs(!1);return e=ec.bind(null,Ho,e.queue,!0,!1),ss().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ho,a=ss();if(ra){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),ad===null)throw Error(i(349));sd&127||vs(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Vs(bs.bind(null,r,o,e),[e]),r.flags|=2048,Ls(9,{destroy:void 0},ys.bind(null,r,o,n,t),null),n},useId:function(){var e=ss(),t=ad.identifierPrefix;if(ra){var n=Yi,r=Ji;n=(r&~(1<<32-Ye(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Jo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[yt]=t,o[bt]=r;e:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(t.stateNode=o,pp(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break;case`img`:r=!0;break;default:r=!1}r&&hl(t)}}return bl(t),t.subtreeFlags&=-33554433,gl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&hl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ye.current,ua(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ta,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[yt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||up(e.nodeValue,n)),e||sa(t,!0)}else e=bp(e).createTextNode(r),e[yt]=t,t.stateNode=e}return bl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ua(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[yt]=t}else da(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;bl(t),e=!1}else n=fa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Io(t),t):(Io(t),null);if(t.flags&128)throw Error(i(558))}return bl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ua(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[yt]=t}else da(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;bl(t),a=!1}else a=fa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Io(t),t):(Io(t),null)}return Io(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),vl(t,t.updateQueue),bl(t),null);case 4:return Se(),e===null&&ep(t.stateNode.containerInfo),t.flags|=67108864,bl(t),null;case 10:return va(t.type),bl(t),null;case 19:if(zo(t),r=t.memoizedState,r===null)return bl(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)yl(r,!1);else{if(md!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Bo(e),o!==null){for(t.flags|=128,yl(r,!1),e=o.updateQueue,t.updateQueue=e,vl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Ni(n,e),n=n.sibling;return Ro(t,Lo.current&1|2),ra&&Xi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Le()>Td&&(t.flags|=128,a=!0,yl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Bo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,vl(t,e),yl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!ra)return bl(t),null}else 2*Le()-r.renderingStartTime>Td&&n!==536870912&&(t.flags|=128,a=!0,yl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;e:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break e}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Le(),e.sibling=null,o=Lo.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||ra?Ro(t,o):(n=o,ge(Ao,t),ge(Lo,n),jo===null&&(jo=t)),ra&&Xi(t,r.treeForkCount),e}return bl(t),null;case 22:case 23:return Io(t),ko(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(bl(t),t.subtreeFlags&6&&(t.flags|=8192)):bl(t),n=t.updateQueue,n!==null&&vl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&he(Wa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),va(Aa),bl(t),null;case 25:return null;case 30:return t.flags|=33554432,bl(t),null}throw Error(i(156,t.tag))}function Sl(e,t){switch($i(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return va(Aa),Se(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return we(t),null;case 31:if(t.memoizedState!==null){if(Io(t),t.alternate===null)throw Error(i(340));da()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));da()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return zo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Se(),null;case 10:return va(t.type),null;case 22:case 23:return Io(t),ko(),e!==null&&he(Wa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return va(Aa),null;default:return null}}function Cl(e,t){switch($i(t),t.tag){case 3:va(Aa),Se();break;case 26:case 27:case 5:we(t);break;case 4:Se();break;case 31:t.memoizedState!==null&&Io(t);break;case 13:Io(t);break;case 19:zo(t);break;case 10:va(t.type);break;case 22:case 23:Io(t),ko(),e!==null&&he(Wa);break;case 24:va(Aa)}}function wl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Sf(t,t.return,e)}}function Tl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Sf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Sf(t,t.return,e)}}function El(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{wo(t,n)}catch(t){Sf(e,e.return,t)}}}function Dl(e,t,n){n.props=wc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Sf(e,t,n)}}function Ol(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=hi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Gp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Kp(e);h(e.child,!1,cm,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Sf(e,t,n)}}function kl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Sf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Sf(e,t,n)}else n.current=null}}function Al(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),pp(r,t,n),r[yt]=e,Nt(r),t=r;break e;case`link`:if(o=th(`link`,`href`,a).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Ur(s,h),v=Ur(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,V.T=null,n=Nd,Nd=null;var o=kd,s=jd;if(Od=0,Ad=kd=null,jd=0,id&6)throw Error(i(331));var c=id;if(id|=4,$u(o.current),Gu(o,o.current,s,n),id=c,If(0,!1),qe&&typeof qe.onPostCommitFiberRoot==`function`)try{qe.onPostCommitFiberRoot(Ke,o)}catch{}return!0}finally{ue.p=a,V.T=r,vf(e,t)}}function xf(e,t,n){t=Bi(n,t),t=Ac(e.stateNode,t,2),e=_o(e,t,2),e!==null&&(lt(e,2),Ff(e))}function Sf(e,t,n){if(e.tag===3)xf(e,e,n);else for(;t!==null;){if(t.tag===3){xf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(Dd===null||!Dd.has(r))){e=Bi(n,e),n=jc(2),r=_o(t,n,2),r!==null&&(Mc(n,r,t,e),lt(r,2),Ff(r));break}}t=t.return}}function Cf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new rd;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(fd=!0,i.add(n),e=wf.bind(null,e,t,n),t.then(e,e))}function wf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,ad===e&&(sd&n)===n&&(md===4||md===3&&(sd&62914560)===sd&&300>Le()-Cd?id&2?_d|=n:Yd(e,0):_d|=n,yd===sd&&(yd=0)),Ff(e)}function Tf(e,t){t===0&&(t=st()),e=Ti(e,t),e!==null&&(lt(e,t),Ff(e))}function Ef(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Tf(e,n)}function Df(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Tf(e,n)}function Of(e,t){return Ne(e,t)}var kf=null,Af=null,jf=!1,Mf=!1,Nf=!1,Pf=0;function Ff(e){e!==Af&&e.next===null&&(Af===null?kf=Af=e:Af=Af.next=e),Mf=!0,jf||(jf=!0,Hf())}function If(e,t){if(!Nf&&Mf){Nf=!0;do for(var n=!1,r=kf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ye(42|e)+1)-1,a&=i&~(o&~s),a=a&0xc000095?a&0xc000095|1:a?a|2:0}a!==0&&(n=!0,Vf(r,a))}else a=sd,a=rt(r,r===ad?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||it(r,a)||(n=!0,Vf(r,a))}r=r.next}while(n);Nf=!1}}function Lf(){Rf()}function Rf(){Mf=jf=!1;var e=0;Pf!==0&&Ep()&&(e=Pf);for(var t=Le(),n=null,r=kf;r!==null;){var i=r.next,a=zf(r,t);a===0?(r.next=null,n===null?kf=i:n.next=i,i===null&&(Af=n)):(n=r,(e!==0||a&3)&&(Mf=!0)),r=i}Od!==0&&Od!==5||If(e,!1),Pf!==0&&(Pf=0)}function zf(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&gp(d)&&(c=c.responseEnd,o+=u*(clh){s.length=o;break}f=new Promise(Hp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Fm(e,t,n){var r=Pm;if(r&&typeof t==`string`&&t){var i=en(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),km.has(i)||(km.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),pp(t,`link`,e),Nt(t),r.head.appendChild(t)))}}function Im(e){jm.D(e),Fm(`dns-prefetch`,e,null)}function Lm(e,t){jm.C(e,t),Fm(`preconnect`,e,t)}function Rm(e,t,n){jm.L(e,t,n);var r=Pm;if(r&&e&&t){var i=`link[rel="preload"][as="`+en(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+en(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+en(n.imageSizes)+`"]`)):i+=`[href="`+en(e)+`"]`;var a=i;switch(t){case`style`:a=Wm(e);break;case`script`:a=Jm(e)}if(!(Om.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Om.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Gm(a))||t===`script`&&r.querySelector(Ym(a))))){var o=r.createElement(`link`);pp(o,`link`,e),t===`style`&&(o[Dt]=!0,o.onload=o.onerror=function(){Pt(o)}),Nt(o),r.head.appendChild(o)}}}function zm(e,t){jm.m(e,t);var n=Pm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+en(r)+`"][href="`+en(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Jm(e)}if(!Om.has(a)&&(e=D({rel:`modulepreload`,href:e},t),Om.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ym(a)))return}r=n.createElement(`link`),pp(r,`link`,e),Nt(r),n.head.appendChild(r)}}}function Bm(e,t,n){jm.S(e,t,n);var r=Pm;if(r&&e){var i=Mt(r).hoistableStyles,a=Wm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Gm(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Om.get(a))&&Qm(e,n);var c=o=r.createElement(`link`);Nt(c),pp(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Zm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Vm(e,t){jm.X(e,t);var n=Pm;if(n&&e){var r=Mt(n).hoistableScripts,i=Jm(e),a=r.get(i);a||(a=n.querySelector(Ym(i)),a||(e=D({src:e,async:!0},t),(t=Om.get(i))&&$m(e,t),a=n.createElement(`script`),Nt(a),pp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Hm(e,t){jm.M(e,t);var n=Pm;if(n&&e){var r=Mt(n).hoistableScripts,i=Jm(e),a=r.get(i);a||(a=n.querySelector(Ym(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=Om.get(i))&&$m(e,t),a=n.createElement(`script`),Nt(a),pp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Um(e,t,n,r){var a=(a=ye.current)?Am(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Wm(n.href),t=Mt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Wm(n.href);var o=Mt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Gm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=Om.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Om.set(e,o)),qm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Jm(n),t=Mt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Wm(e){return`href="`+en(e)+`"`}function Gm(e){return`link[rel="stylesheet"][`+e+`]`}function Km(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function qm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Dt]){r.loading=1;return}}else t=e.createElement(`link`),t[Dt]=!0,t.onload=t.onerror=Pt.bind(null,t),pp(t,`link`,n),Nt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Jm(e){return`[src="`+en(e)+`"]`}function Ym(e){return`script[async]`+e}function Xm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+en(n.href)+`"]`);if(r)return t.instance=r,Nt(r),r;var a=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Nt(r),pp(r,`style`,a),Zm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Wm(n.href);var o=e.querySelector(Gm(a));if(o)return t.state.loading|=4,t.instance=o,Nt(o),o;r=Km(n),(a=Om.get(a))&&Qm(r,a),o=(e.ownerDocument||e).createElement(`link`),Nt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),pp(o,`link`,r),t.state.loading|=4,Zm(o,n.precedence,e),t.instance=o;case`script`:return o=Jm(n.src),(a=e.querySelector(Ym(o)))?(t.instance=a,Nt(a),a):(r=n,(a=Om.get(o))&&(r=D({},n),$m(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Nt(a),pp(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Zm(r,n.precedence,e));return t.instance}function Zm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function rh(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;return t.rel!==`stylesheet`||(e=t.disabled,typeof t.precedence==`string`&&e==null);case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function ih(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function ah(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function oh(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function sh(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=oh(t),e.suspenseyImages.push(t)),e=ph.bind(e),t.decode().then(e,e))}function ch(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Wm(r.href),a=t.querySelector(Gm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=fh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Nt(a);return}a=t.ownerDocument||t,r=Km(r),(i=Om.get(i))&&Qm(r,i),a=a.createElement(`link`),Nt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),pp(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=fh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var lh=0;function uh(e,t){return e.stylesheets&&e.count===0&&hh(e,e.stylesheets),0lh?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function dh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)hh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function fh(){this.count--,dh(this)}function ph(){this.imgCount--,dh(this)}var mh=null;function hh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,mh=new Map,t.forEach(gh,e),mh=null,fh.call(e))}function gh(e,t){if(!(t.state.loading&4)){var n=mh.get(e);if(n)var r=n.get(null);else{n=new Map,mh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=c(u(),1),v=g(),y=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),b=o(((e,t)=>{t.exports=y()})),x=(0,_.createContext)({});function S(e){let t=(0,_.useRef)(null);return t.current===null&&(t.current=e()),t.current}var C=typeof window<`u`?_.useLayoutEffect:_.useEffect,w=(0,_.createContext)(null);function T(e,t){e.indexOf(t)===-1&&e.push(t)}function E(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var D=(e,t,n)=>n>t?t:n/^-?(?:\d+(?:\.\d+)?|\.\d+)(?:e[-+]?\d+)?$/iu.test(e),A=e=>typeof e==`object`&&!!e,j=e=>/^0[^.\s]+$/u.test(e);function M(e){let t;return()=>(t===void 0&&(t=e()),t)}var N=e=>e,P=(...e)=>e.reduce((e,t)=>n=>t(e(n))),F=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},I=class{constructor(){this.subscriptions=[]}add(e){return T(this.subscriptions,e),()=>this.remove(e)}remove(e){E(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r){if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;ie*1e3,ee=e=>e/1e3,R=(e,t)=>t?1e3/t*e:0,z=(e,t,n)=>e*(3*(1-e)*((1-e)*t+e*n)+e*e);function B(e,t,n,r){return e===t&&n===r?N:i=>{let a=0,o=1,s=i;for(let t=0;;t++){s>=a&&s<=o||(s=(a+o)/2);let r=z(s,e,n)-i;if(r*r<1e-28||t===40)break;r>0?o=s:a=s,s-=r*1e-7/(z(s+1e-7,e,n)-i-r)}return z(s,t,r)}}var te=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ne=e=>t=>1-e(1-t),re=B(.33,1.53,.69,.99),ie=ne(re),ae=te(ie),oe=e=>e>=1?1:(e*=2)<1?.5*ie(e):.5*(2-2**(-10*(e-1))),se=e=>1-Math.sin(Math.acos(e)),ce=ne(se),le=te(se),V=B(.42,0,1,1),ue=B(0,0,.58,1),de=B(.42,0,.58,1),fe=e=>Array.isArray(e)&&typeof e[0]!=`number`,pe=e=>Array.isArray(e)&&typeof e[0]==`number`,me={linear:N,easeIn:V,easeInOut:de,easeOut:ue,circIn:se,circInOut:le,circOut:ce,backIn:ie,backInOut:ae,backOut:re,anticipate:oe},he=e=>typeof e==`string`,ge=e=>{if(pe(e)){let[t,n,r,i]=e;return B(t,n,r,i)}return he(e)?me[e]:e},_e={delta:0,timestamp:0,isProcessing:!1},ve;function ye(){ve=void 0}var be={now:()=>(ve===void 0&&be.set(_e.isProcessing||O.useManualTiming?_e.timestamp:performance.now()),ve),set:e=>{ve=e,queueMicrotask(ye)}},xe=e=>e.startsWith(`--`);function Se(e,t,n){xe(t)?e.style.setProperty(t,n):e.style[t]=n}var Ce=(e,t,n)=>e.animate(t,n),we=(e,t,n)=>new Animation(new KeyframeEffect(e,t,n));function Te(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a,o,s=0;for(let t=0;t{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t=n?1/0:i}function ke(e,t=100,n){let{keyframes:r,velocity:i}=e,a=r&&r[r.length-1]-r[0],o=n({...e,velocity:i&&a?i*t/a:i,keyframes:[0,t]}),s=Math.min(Oe(o),De);return{type:`keyframes`,ease:e=>o.next(s*e).value/t,duration:ee(s)}}var Ae=100,je=10,Me=1,Ne=800,Pe=.3,Fe=.3,Ie=.01,Le=2,Re=.005,ze=.5,Be=.01,Ve=10,He=.05,Ue=e=>e<0?1/Math.max(1+e,He):Math.max(1-e,He);function We(e,t){if(!(e>1))return 1;let n=Math.sqrt(e*e-1),r=e-n,i=e+n,a=2*n*Math.exp(-t)*(1+t);return qe(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function Ge(e,t){return e*Math.sqrt(1-t*t)}var Ke=12;function qe(e,t,n){let r=n;for(let n=1;n{let n=t*i,r=n*e,a=Ge(t,i),o=Math.exp(-r);return Je-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=Ge(t*t,i);return(-n(t)+Je>0?-1:1)*-a*o/s}):(n=t=>-.001+Math.exp(-t*e)*(t*e+1),r=t=>Math.exp(-t*e)*(-t*(e*e)));let a=5/e,o=qe(n,r,a),s=o*We(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:L(e)}}var Xe=(e,t)=>(t?e>=0:e>0)&&e<1/0;function Ze(e,t){if(Xe(e,t))return e}function Qe(e){let t=Ze(e.stiffness),n=Ze(e.damping,!0),r=Ze(e.mass),i={...e,stiffness:t??Ae,damping:n??je,mass:r??Me,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){let t=Ue(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*We(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,Ye(i)),i.isResolvedFromDuration=!0;Xe(i.stiffness)&&Xe(i.damping,!0)||(i.stiffness=Ae,i.damping=je)}return i}function $e(e=Fe,t=Pe){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:o,damping:s,mass:c,duration:l,isResolvedFromDuration:u,isTimeDefined:d}=Qe(n),f=e=>u?0:-ee(e),p=s/(2*Math.sqrt(o*c)),m=ee(Math.sqrt(o/c)),h=p*m,g={target:i,delta:i-r,velocity:f(n.velocity)||0,restSpeed:0,restDelta:0},_=()=>{let e=Math.abs(g.delta)<5;g.restSpeed=n.restSpeed||(e?Ie:Le),g.restDelta=n.restDelta||(e?Re:ze)};_();let v,y,b;if(p<1){let e=Ge(m,p),t={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};b=()=>{t.A=(g.velocity+h*g.delta)/e,t.sinC=h*t.A+g.delta*e,t.cosC=h*g.delta-t.A*e};let n=n=>{n!==t.t&&(t.t=n,t.env=Math.exp(-h*n),t.sin=Math.sin(e*n),t.cos=Math.cos(e*n))};v=e=>(n(e),g.target-t.env*(t.A*t.sin+g.delta*t.cos)),y=e=>(n(e),t.env*(t.sinC*t.sin+t.cosC*t.cos))}else if(p===1){let e={C:0};b=()=>{e.C=g.velocity+m*g.delta},v=t=>g.target-Math.exp(-m*t)*(g.delta+e.C*t),y=t=>Math.exp(-m*t)*(m*e.C*t-g.velocity)}else{let e=m*Math.sqrt(p*p-1),t=h-e,n=h+e,r=e<1||d?1/0:300/e,i=(e,t)=>Math.exp(t>r?(h-e)*r-h*t:-e*t),a={S:0,F:0};b=()=>{let t=(g.velocity+h*g.delta)/e;a.S=(g.delta+t)/2,a.F=(g.delta-t)/2},v=e=>g.target-a.S*i(t,e)-a.F*i(n,e),y=e=>t*a.S*i(t,e)+n*a.F*i(n,e)}b();let x=u&&l||null,S={calculatedDuration:x,retarget:(e,t)=>{g.target=e[e.length-1],g.delta=g.target-e[0],g.velocity=f(t),n.restSpeed&&n.restDelta||_(),S.calculatedDuration=x,a.done=!1,b()},velocity:e=>L(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=L(y(e));a.done=Math.abs(n)<=g.restSpeed&&Math.abs(g.target-t)<=g.restDelta}return a.value=a.done?g.target:t,a},toString:()=>{let e=Math.min(Oe(S),De),t=Ee(t=>S.next(e*t).value,e,30);return e+`ms `+t}};return S}var et=Object.assign($e,{applyToOptions:e=>{let t=ke(e,100,$e);return e.ease=t.ease,e.duration=L(t.duration),e.type=`keyframes`,e}});function tt({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>ec,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)-h*Math.exp(-e/r),y=e=>{let t=v(e);f.done=Math.abs(t)<=l,f.value=f.done?_:e?_+t:d},b,x,S=e=>{p(f.value)&&(b=e,x=et({keyframes:[f.value,m(f.value)],velocity:-v(e)/r*1e3,damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return!x&&b===void 0&&(t=!0,y(e),S(e)),b!==void 0&&e>=b?x.next(e-b):(!t&&y(e),f)}}}var nt=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function rt(e){let t=new Set,n=new Set,r=!1,i=!1,a,o=new Set,s;function c(t){o.has(t)&&(n.add(t),e()),(a=t)(s)}let l={schedule:(e,i=!1,s=!1)=>{let c=s&&r,l=c?t:n;return i&&o.add(e),c&&e!==a&&l.delete(e),l.add(e),e},cancel:e=>{n.delete(e),o.delete(e)},process:e=>{if(s=e,r){i=!0;return}r=!0;let o=t;t=n,n=o,t.forEach(c),t.clear(),a=void 0,r=!1,i&&(i=!1,l.process(e))}};return l}var it=40;function at(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o={},s={};for(let e of nt){let t=o[e]=rt(a);s[e]=(e,n=!1,i=!1)=>(r||_(),t.schedule(e,n,i))}let{setup:c,read:l,resolveKeyframes:u,preUpdate:d,update:f,preRender:p,render:m,postRender:h}=o,g=()=>{let a=O.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,it),1)),n.timestamp=o,n.isProcessing=!0,c.process(n),l.process(n),u.process(n),d.process(n),f.process(n),p.process(n),m.process(n),h.process(n),n.isProcessing=!1,r&&t&&(i=!1,e(g))},_=()=>{r=!0,i=!0,n.isProcessing||e(g)};return{schedule:s,cancel:e=>{for(let t=0;t{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>st.update(t,e),stop:()=>ct(t),now:()=>_e.isProcessing?_e.timestamp:be.now()}},dt=e=>Math.round(e*1e5)/1e5,ft=e=>t=>typeof t==`string`&&t.startsWith(e),pt=ft(`--`),mt=ft(`var(--`),ht=e=>mt(e)?gt.test(e.split(`/*`)[0].trim()):!1,gt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function _t(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var vt=e=>typeof e==`number`,yt={test:vt,parse:parseFloat,transform:e=>e},bt={test:vt,parse:parseFloat,transform:e=>D(0,1,e)},xt={test:vt,parse:parseFloat,transform:e=>e,default:1},St=/-?(?:\d+(?:\.\d+)?|\.\d+)(?:e[-+]?\d+)?/giu,Ct=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+(?:e[-+]?\d+)?%?[,\s]+){2}-?[\d.]+(?:e[-+]?\d+)?%?\s*(?:[,/]\s*)?(?:(?:\b\d+(?:\.\d+)?|\.\d+)(?:e[-+]?\d+)?)?%?\))$/iu,wt=(e,t)=>n=>!!(typeof n==`string`&&Ct.test(n)&&n.startsWith(e)||t&&n!=null&&Object.prototype.hasOwnProperty.call(n,t)),Tt=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(St);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Et={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>Math.round(D(0,255,e))},Dt=({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Et.transform(e)+`, `+Et.transform(t)+`, `+Et.transform(n)+`, `+dt(bt.transform(r))+`)`,Ot={test:wt(`rgb`,`red`),parse:Tt(`red`,`green`,`blue`),transform:Dt},kt=(e,t,n)=>{let r=e.substring(1+t*n,1+(t+1)*n);return n>1?r:r+r};function At(e){let t=e.length>5?2:1,n=kt(e,3,t);return{red:parseInt(kt(e,0,t),16),green:parseInt(kt(e,1,t),16),blue:parseInt(kt(e,2,t),16),alpha:n?parseInt(n,16)/255:1}}var jt={test:wt(`#`),parse:At,transform:Dt},Mt=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Nt=Mt(`deg`),Pt=Mt(`%`),Ft=Mt(`px`),It=Mt(`vh`),Lt=Mt(`vw`),Rt={...Pt,parse:e=>Pt.parse(e)/100,transform:e=>Pt.transform(e*100)},zt={test:wt(`hsl`,`hue`),parse:Tt(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Pt.transform(dt(t))+`, `+Pt.transform(dt(n))+`, `+dt(bt.transform(r))+`)`},Bt={test:e=>Ot.test(e)||jt.test(e)||zt.test(e),parse:e=>Ot.test(e)?Ot.parse(e):zt.test(e)?zt.parse(e):jt.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Ot.transform(e):zt.transform(e),getAnimatableNone:e=>{let t=Bt.parse(e);return t.alpha=0,Bt.transform(t)}},Vt=/-?(?:\d+(?:\.\d+)?|\.\d+)(?:e[-+]?\d+)?/,Ht=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+(?:e[-+]?\d+)?%?[,\s]+){2}-?[\d.]+(?:e[-+]?\d+)?%?\s*(?:[,/]\s*)?(?:(?:\b\d+(?:\.\d+)?|\.\d+)(?:e[-+]?\d+)?)?%?\))/i;function Ut(e){return isNaN(e)&&typeof e==`string`&&Xt(e)}var Wt=`number`,Gt=`color`,Kt=`var`,qt=`var(`,Jt="${}",Yt=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+(?:e[-+]?\d+)?%?[,\s]+){2}-?[\d.]+(?:e[-+]?\d+)?%?\s*(?:[,/]\s*)?(?:(?:\b\d+(?:\.\d+)?|\.\d+)(?:e[-+]?\d+)?)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)(?:e[-+]?\d+)?(?![a-z]*\()/giu;function Xt(e){let t=e.toString();return Vt.test(t)||Ht.test(t)}function Zt(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(Yt,e=>(Bt.test(e)?(r.color.push(a),i.push(Gt),n.push(Bt.parse(e))):e.startsWith(qt)?(r.var.push(a),i.push(Kt),n.push(e)):(r.number.push(a),i.push(Wt),n.push(parseFloat(e))),++a,Jt)).split(Jt),indexes:r,types:i}}function Qt(e){return Zt(e).values}function $t({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;atypeof e==`number`?t?.trim().endsWith(`/`)?e:0:Bt.test(e)?Bt.getAnimatableNone(e):e;function nn(e){let t=Zt(e);return $t(t)(t.values.map((e,n)=>tn(e,t.split[n])))}var rn={test:Ut,parse:Qt,createTransformer:en,getAnimatableNone:nn};function an(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function on({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=an(s,r,e+1/3),a=an(s,r,e),o=an(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function sn(e,t){return n=>n>0?t:e}var cn=(e,t,n)=>e+(t-e)*n,ln=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},un=[jt,Ot,zt],dn=e=>un.find(t=>t.test(e));function fn(e){let t=dn(e);if(!t)return!1;let n=t.parse(e);return t===zt&&(n=on(n)),n}var pn=(e,t)=>{let n=fn(e),r=fn(t);if(!n||!r)return sn(e,t);let i={...n};return e=>(i.red=ln(n.red,r.red,e),i.green=ln(n.green,r.green,e),i.blue=ln(n.blue,r.blue,e),i.alpha=cn(n.alpha,r.alpha,e),Ot.transform(i))},mn=new Set([`none`,`hidden`]);function hn(e,t){return mn.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function gn(e,t){return n=>cn(e,t,n)}function _n(e){return typeof e==`number`?gn:typeof e==`string`?ht(e)?sn:Bt.test(e)?pn:xn:Array.isArray(e)?vn:typeof e==`object`?Bt.test(e)?pn:yn:sn}function vn(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>_n(e)(e,t[n]));return e=>{for(let t=0;t{for(let t in r)n[t]=r[t](e);return n}}function bn(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i{let n=Zt(e),r=Zt(t);return n.indexes.var.length===r.indexes.var.length&&n.indexes.color.length===r.indexes.color.length&&n.indexes.number.length>=r.indexes.number.length?mn.has(e)&&!r.values.length||mn.has(t)&&!n.values.length?hn(e,t):P(vn(bn(n,r),r.values),$t(r)):sn(e,t)},Sn=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function Cn(e,t){let n=Sn.exec(e);if(!n)return;let r=Sn.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>dt(cn(a,o,e))+i}function wn(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return cn(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=Cn(e,t);if(n)return n}return _n(e)(e,t)}function Tn(e,t,n){let r=[],i=O.mix||wn,a=e.length-1;for(let o=0;ot[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=Tn(t,r,i),c=s.length,l=n=>{if(o&&n1)for(;rl(D(e[0],e[a-1],t)):l}function Dn(e){let t=[0],n=e.length-1;for(let e=1;e<=n;e++)t.push(e/n);return t}function On(e,t){return e.map(e=>e*t)}function kn(e,t){return e.map(()=>t||de).splice(0,e.length-1)}function An({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`,mixer:i}){let a=typeof t[0]==`number`?void 0:i,o=fe(r)?r.map(ge):ge(r)||de,s={done:!1,value:t[0]},c=-1;if(!a){for(let e=1;e=0){c=-2;break}c=e-1}}let l=n&&n.length===t.length?n:Dn(t);if(c>=0){let n=l[c]*e,r=l[c+1]*e,i=t[c],a=t[c+1],u=Array.isArray(o)?o[c]:o,d=(O.mix||wn)(i,a),f=t.length-2;return{calculatedDuration:e,next:t=>(s.value=c&&t=r||!e)?typeof a==`number`?a:d(1):d(u(t>=r||!e?1:t<=n?0:(t-n)/(r-n))),s.done=t>=e,s)}}let u=En(On(l,e),t,{ease:Array.isArray(o)?o:kn(t,o),mixer:a});return{calculatedDuration:e,next:t=>(s.value=u(t),s.done=t>=e,s)}}var jn={decay:tt,inertia:tt,tween:An,keyframes:An,spring:et};function Mn(e){typeof e.type==`string`&&(e.type=jn[e.type])}function Nn(e){let{options:t}=e;Mn(t);let{type:n,repeat:r=0,repeatDelay:i=0,repeatType:a,velocity:o=0}=t,{keyframes:s}=t,c=n||An;if(e.mixKeyframes=void 0,c!==An&&typeof s[0]!=`number`){let n=t.mixer?.(s[0],s[1])||wn(s[0],s[1]);e.mixKeyframes=e=>n(e/100),s=[0,100]}let l=c(s===t.keyframes?t:{...t,keyframes:s});a===`mirror`&&(e.mirroredGenerator=c({...t,keyframes:[...s].reverse(),velocity:-o})),l.calculatedDuration===null&&(l.calculatedDuration=Oe(l));let{calculatedDuration:u}=l;e.calculatedDuration=u,e.resolvedDuration=u+i,e.totalDuration=e.resolvedDuration*(r+1)-i,e.generator=l}function Pn(e,t,n){let{generator:r,totalDuration:i,mixKeyframes:a,mirroredGenerator:o,resolvedDuration:s}=e,{keyframes:c,repeat:l,repeatType:u,repeatDelay:d}=e.options;if(n){let t=e.delayState||={done:!1,value:void 0};return t.value=c[0],t}let f=t,p=r;if(l){let e=Math.min(t,i)/s,n=Math.floor(e),r=e%1;!r&&e>=1&&(r=1),r===1&&n--,n=Math.min(n,l+1),n%2&&(u===`reverse`?(r=1-r,d&&(r-=d/s)):u===`mirror`&&(p=o)),f=D(0,1,r)*s}let m=p.next(f);return a&&(m.value=a(m.value)),m}var Fn=40,In=(e,t)=>t-e>Fn&&!O.useManualTiming?t:e;function Ln(e,t){return{kind:e,animation:t,timestamp:be.now(),frameTimestamp:_e.timestamp,frameIsProcessing:_e.isProcessing}}function Rn(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...Ln(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function zn(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...Ln(`layout-animation-start`,e),node:t})}catch{}}var Bn=class{constructor(){this.isResolved=!1}get finished(){return this._finished||=this.isResolved?Promise.resolve():new Promise(e=>{this._resolve=e})}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(e,t){return this.finished.then(e,t)}},Vn=(e,t)=>t&&typeof e==`number`?t.transform(e):e,Hn={test:e=>typeof e==`number`,parse:parseFloat,transform:Math.round},Un={rotate:Nt,pathRotation:Nt,rotateX:Nt,rotateY:Nt,rotateZ:Nt,scale:xt,scaleX:xt,scaleY:xt,scaleZ:xt,skew:Nt,skewX:Nt,skewY:Nt,distance:Ft,translateX:Ft,translateY:Ft,translateZ:Ft,x:Ft,y:Ft,z:Ft,perspective:Ft,transformPerspective:Ft,opacity:bt,originX:Rt,originY:Rt,originZ:Ft},Wn=Object.assign({borderWidth:Ft,borderTopWidth:Ft,borderRightWidth:Ft,borderBottomWidth:Ft,borderLeftWidth:Ft,borderRadius:Ft,borderTopLeftRadius:Ft,borderTopRightRadius:Ft,borderBottomRightRadius:Ft,borderBottomLeftRadius:Ft,width:Ft,maxWidth:Ft,height:Ft,maxHeight:Ft,top:Ft,right:Ft,bottom:Ft,left:Ft,inset:Ft,insetBlock:Ft,insetBlockStart:Ft,insetBlockEnd:Ft,insetInline:Ft,insetInlineStart:Ft,insetInlineEnd:Ft,padding:Ft,paddingTop:Ft,paddingRight:Ft,paddingBottom:Ft,paddingLeft:Ft,paddingBlock:Ft,paddingBlockStart:Ft,paddingBlockEnd:Ft,paddingInline:Ft,paddingInlineStart:Ft,paddingInlineEnd:Ft,margin:Ft,marginTop:Ft,marginRight:Ft,marginBottom:Ft,marginLeft:Ft,marginBlock:Ft,marginBlockStart:Ft,marginBlockEnd:Ft,marginInline:Ft,marginInlineStart:Ft,marginInlineEnd:Ft,fontSize:Ft,backgroundPositionX:Ft,backgroundPositionY:Ft},Un,{zIndex:Hn,fillOpacity:bt,strokeOpacity:bt,numOctaves:Hn}),Gn=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Kn=new Set([...Gn,`pathRotation`]),qn={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},Jn={},Yn=(e,t,n=Vn(t,Un[e]))=>(Jn[e]||(Jn[e]=(qn[e]||e)+`(`))+n+`)`,Xn=(e,t)=>(typeof t==`number`?t:parseFloat(t))===+!!e.startsWith(`scale`);function Zn(e,t,n,r=Gn){let i=``;for(let a=0;a`cubic-bezier(${e}, ${t}, ${n}, ${r})`,$n={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Qn([0,.65,.55,1]),circOut:Qn([.55,0,1,.45]),backIn:Qn([.31,.01,.66,-.59]),backOut:Qn([.33,1.53,.69,.99])},er=new Set([`opacity`,`clipPath`,`filter`,`transform`]),tr=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/,nr=e=>e.some(e=>typeof e==`string`&&tr.test(e)),rr=({mixer:e,keyframes:t})=>e&&typeof t[0]!=`number`&&t.some((n,r)=>r&&e(t[r-1],n)),ir=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),ar=()=>!O.useManualTiming&&Object.hasOwnProperty.call(Element.prototype,`animate`);function or(e,t){let{onUpdate:n,transformTemplate:r}=e.motionValue.owner.getProps();return!n&&!e.hasOnUpdate&&(!t||!r)&&e.type!==`inertia`&&!rr(e)}function sr(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,keyframes:o}=e,s=!!(n&&er.has(n));if(!s&&!(n&&ir.has(n)))return!1;let c=t?.owner?.current;return!(c instanceof HTMLElement)&&!(c instanceof SVGElement)?!1:ar()&&(s||nr(o))&&!r&&i!==`mirror`&&a!==0&&or(e,n===`transform`)}var cr={};function lr(e,t){let n=M(e);return()=>cr[t]??n()}var ur=lr(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),dr=new WeakMap,fr={},pr=new Set,mr=0,hr=(e,t)=>{t?pr.add(e):pr.delete(e),mr=pr.size},gr=new Map,_r=new Map,vr=e=>e.size>=6,yr=()=>vr(_r)||vr(gr),br=e=>vr(_r)&&_r.has(e)||vr(gr)&&gr.has(e),xr=new Set,Sr=1e3/60,Cr=Sr,wr=0,Tr=0,Er=0,Dr=0,Or=0,kr=0,Ar=0,jr,Mr=()=>Dr=performance.now(),Nr=4,Pr=()=>{let e=performance.now();if(!Er||e-Dr>500)return Ar=0;kr+=Math.max(e-Ar-Nr-1,0),Ar=e,setTimeout(Pr,Nr)},Fr={computer:2e3,touch:100,max:500},Ir,Lr=()=>typeof matchMedia<`u`&&(Ir||=matchMedia(`(pointer:coarse)`)).matches,Rr=e=>Math.max(_r.size,gr.size)>e,zr=()=>Rr(Lr()?Fr.touch:Fr.computer),Br=e=>Cr>Sr*e&&wr>(Rr(Fr.max)&&Lr()?Rr(Fr.max*2)?1/0:Sr:Math.max(Sr,Tr)/4),Vr=!1,Hr=0,Ur=0,Wr=30,Gr=e=>e.schedule(!0),Kr=e=>{Vr=e,Hr=12,Ur=0,e?(xr.forEach(Gr),xr.clear()):pr.forEach(Yr)},qr=()=>{let{timestamp:e}=_e;if(Er&&e-Er<500&&(Cr+=(Math.min(e-Er,100)-Cr)*.1,wr+=(Math.max(kr-Or,0)-wr)*.1,Tr+=(Or-Tr)*.1,Sr=Math.max(4,Math.min(Sr,Cr))),Er=e,kr=0,Or=(Dr=performance.now())-e,!jr&&typeof MessageChannel<`u`&&typeof requestAnimationFrame<`u`){let e=new MessageChannel;jr=e.port2,e.port1.onmessage=()=>{Or+=performance.now()-Dr,requestAnimationFrame(Mr)}}Ar||(Ar=Dr,setTimeout(Pr,Nr)),jr?.postMessage(0),Hr&&--Hr||(Vr?Br(1.1)?Ur=0:++Ur>=Wr&&(Wr*=2,Kr(!1)):Br(1.25)?Kr(!0):pr.forEach(Yr))},Jr=e=>!!(fr.mark=Qr)&&yr()&&!Vr&&zr()&&!!xr.add(e),Yr=e=>e.isScrolling||Jr(e)&&e.demote(!0),Xr=e=>xr.delete(e),Zr=()=>{gr=_r,_r=new Map,gr.forEach((e,t)=>e?.animation?.state===`running`&&_r.set(t,e)),yr()&&zr()?qr():(Kr(!0),Vr=!1,Hr=Er=wr=Tr=0,Cr=Sr=1e3/60,Wr=30),gr.size?st.postRender(Zr):Er=0},Qr=(e,t)=>{_r.has(e)?t&&_r.set(e,t):(_r.size||st.postRender(Zr),_r.set(e,t))},$r={},ei=50,ti=16,ni=100,ri=new WeakMap,ii=(e,t)=>{let n=ri.get(e);return n?.[0]!==t&&ri.set(e,n=[t,Ee(e,t+1,1)]),n[1]},ai=(e,t)=>{if(pe(e))return Qn(e);let n=typeof e==`string`&&$n[e];return n&&n[0]!==`c`?n:ii(ge(e),t)},oi=(e,t)=>e-t,si=e=>e.motionValue.owner,ci=e=>dr.get(e),li=({state:e})=>e===`idle`||e===`finished`,ui=e=>!e.scrollTimeline&&(e.parent.holdTime!==null||!e.speed),di=e=>e.startTime+((e.options.delay||0)+e.totalDuration)/e.speed,fi=(e,t)=>{let n=e.getValue(t);return n?n.get():e.latestValues?.[t]},pi=e=>{let t=``;for(let n in e)t+=Yn(n,e[n])+` `;return t||`none`},mi=(e,t,n)=>!!((e!==`pathRotation`&&Kn.has(e)||n&&e!==`transform`&&er.has(e))&&t?.owner?.current instanceof HTMLElement&&ar()&&ur());function hi(e){let t=si(e);return(fi(t,`transform`)||`none`)===`none`&&!fi(t,`pathRotation`)&&!t.projection?.isProjecting()&&or(e,!0)}function gi(e,t){let{startTime:n,calculatedDuration:r,resolvedDuration:i,totalDuration:a,options:o}=e,{speed:s}=e,{keyframes:c,repeat:l,repeatType:u,repeatDelay:d,type:f,delay:p}=o,m=D(2,ei,Math.ceil(r/10)),{ease:h,times:g}=o,_=g||Dn(c),v;if(!(i<1/0)||!s||u===`mirror`||t&&l||_.length!==c.length||_[0]||_[_.length-1]!==1||_.some((e,t)=>t&&e<=_[t-1]))return;if(f===An)h??=`easeInOut`,v=_.slice(1).map((e,t)=>ai(fe(h)?h[t]||`linear`:h,m));else{let t=parseFloat(c[0]),n=parseFloat(c[1])-t;if(!(Math.abs(n)>0))return;_=[0,1],v=[Ee(i=>(parseFloat(e.sampleTime(p+i*r,!0))-t)/n,m+1,1)]}let y=c,b=n+p/s,x=l?i:a,S=l+1,C=u===`reverse`,w=()=>{_.unshift(0),y=[y[0],...y],v.unshift(`linear`)};if(t){if(p){let e=a/(p+a);_=_.map(t=>1-e+t*e),w()}b=x=0,S=s=1}else if(l&&d){let e=r/i,t=C?(1-e)/2:0;_=[..._.map(n=>t+n*e),1],y=[...y,y[y.length-1]],v.push(`linear`),C&&(w(),b-=t*i/s),S-=1-e-t}return[b,x,S,l&&C?`alternate`:`normal`,s,_,y,v]}var _i,vi=100,yi=e=>{_i||queueMicrotask(()=>{let e=_i;_i=void 0,e.forEach(e=>e())}),(_i||=[]).push(e)};function bi(e){let t=si(e.options),n=ci(t.current)||xi(t);return n.tracks.add(e),n}function xi(e){let t=e.current,n=new Set,r={},i=[],a=[],o=new Set,s=new Map,c,l=()=>N(!0),u=e=>{clearTimeout(c),e===void 0||(c=setTimeout(l,e))},d,f,p,m=0,h=0,g=!1,_=!1,v=!1,y=!1,b=-1/0,x=e=>{for(let t of n)if(t.name===e)return!0},S=()=>{let n={},r;for(let t of Gn){let i=fi(e,t);i!==void 0&&(r=n[t]=i)}o.forEach(n=>{let r=fi(e,n);r!==void 0&&Se(t,n,r)}),r!==void 0&&Se(t,`transform`,Zn(n,{}))},C=(e=!0)=>{e&&S(),clearTimeout(c),d=void 0,f&&(f.onfinish=f.oncancel=null,f.cancel(),f=p=void 0,F.isScrolling=!1,hr(F,!1))},w=t=>{let s={};r={},a=[];for(let e of n){let{name:n}=e;s[n]=e,Kn.has(n)||(a.push(n),o.add(n),ui(e)&&(r[n]=e.sampleAt(t)))}return i=Gn.filter(n=>{let i=s[n];if(i&&!ui(i))return!0;let a=r[n]=i?i.sampleAt(t):fi(e,n);return a!==void 0&&!Xn(n,a)}),s},T=()=>{let e=i.length?{transform:[]}:{};for(let t of a)e[t]=[];return e},E=(e,n)=>{let r=we(t,e,n);return r.oncancel=()=>f===r&&P(),f||hr(F,!0),f=r},D=(e,t)=>{let n={},o,s=[],c=i.concat(a),l={};for(let r of c){let i=e[r];if(!i||ui(i))continue;let a=gi(i,t);if(!a)return;n[r]=a;let{curve:o}=i.options;o&&!(l[o]?.[1]>=a[1])&&(l[o]=a)}for(let t in n){let r=n[t],i=l[e[t].options.curve];if(i&&(r[1]=i[1],r[7]=i[7]),o&&(Math.abs(r[0]-o[0])>1||Math.abs(r[1]-o[1])>1||r[2]!==o[2]||r[3]!==o[3]||r[4]!==o[4]))return;o||=r;for(let e of r[5])s.includes(e)||s.push(e)}if(!o)return null;s.sort(oi);let u=[],d=T();for(let e=0;e=0;a||(r=t.findIndex(t=>t>s[e])-1),c=n[r];let l=c!==n[r+1];if(!a&&l)return;if(a&&l&&e{let o=1/0,s=[],c=[];for(let e of n){if(e.speed<0)return;ui(e)||(c.push(e),o=Math.min(o,di(e)))}if(!(o<1/0))return;let l=o-t,u=Math.max(ti,l/ei);for(let e=t;et&&s.push(e,e+.01)}s.sort(oi);let d=(t,n)=>{let i=e[t];return i&&!ui(i)?i.sampleAt(n):r[t]},f=T();for(let e of s){let t={};for(let n of i)t[n]=d(n,e);f.transform?.push(pi(t));for(let t of a)f[t].push(d(t,e))}return[t,l,1,`normal`,1,s.map(e=>(e-t)/l),f]},k=e=>{s.clear();for(let t of n)s.set(t,[t.at(e),t.speed,ui(t)]);let t=w(e),r=D(t);if(r===void 0&&(r=O(t,e)),C(!1),r===null)return S(),!0;if(!r)return;let[i,a,o,c,f,p,g,_]=r,v=0;if(o===1&&f>0){let t=Object.values(g),r=e=>t.map(t=>t[e])+``,o=0,s=p.length-1;for(;oo&&r(s-1)===r(s);)s--;if(o(e-t)/r);for(let e in g)g[e]=g[e].slice(o,s+1);_&&=_.slice(o,s);let c=Math.floor((i-vi)/vi)*vi-e;if(c>0)return n.forEach(e=>e.sync()),u(d=c),!0}}let y=null,b=!1;for(let e in g){let t=g[e];t.some(e=>e!==t[0])?(y||={})[e]=t:b=!0}b&&S(),y&&p.length>2&&(y.offset=p,_?.some(e=>e!==`linear`)&&(y.easing=_)),m=i-e,h=a*o+v;let x=E(y,{duration:a,iterations:o,direction:c,endDelay:v,easing:p.length>2?`linear`:_?.[0]||`linear`,fill:`both`});return f!==1&&(x.playbackRate=f),x.startTime=be.now()+m,o<1/0&&(x.onfinish=l),!0},A=e=>{s.clear();let t=D(w(be.now()),!0);if(C(!1),!t)return t===null?S():P(!0);let n=t[6];n.offset=t[5],n.easing=t[7];let r=E(n,{duration:1e3,fill:`both`});r.timeline=e.timeline,e.onAttach?e.onAttach(r):r.play(),p=r,F.isScrolling=!0,Xr(F)},j=()=>!n.size&&(v=!0,Xr(F),ci(t)===F&&dr.delete(t),F.isJS||C(),!0),M=()=>{let t=be.now();if(F.isJS||(F.isFinishing=!0,n.forEach(n=>{if(n.state!==`running`||n.scrollTimeline)return;let{speed:i}=n;(i>0?di(n)<=t+1:i<0&&n.at(t)<=1)&&(n.complete(),r[n.name]=fi(e,n.name),s.has(n)||(g=!0))}),F.isFinishing=!1),_=!1,v||(n.forEach(e=>li(e)&&n.delete(e)),j()))return;let i=!1;for(let e of n){let{scrollTimeline:t}=e;if(!e.canAccelerate||i!==!1&&t!==i)return P(!0);i=t}if(!i&&Jr(F))return P(!0);F.isJS&&(F.isJS=!1,g=!0);let a=g,o=y;if(g=y=!1,i)return A(i);if(a||!$r.retime?.(n,s,f,d,m,h,u,t,o)){if(o){if(t-bui(e)&&e.sync())},N=(e,t)=>{v||(g||=e,y||=!!t,_||(_=!0,_e.isProcessing?st.render(M,!1,!0):yi(M)))},P=e=>{if(!(F.isJS||v))return n.forEach(t=>{t.isAccelerated()&&t.sync(),e||(t.canAccelerate=!1)}),F.isJS=!0,s.clear(),C(),n.forEach(e=>li(e)||e.parent.js?.start()),n.forEach(e=>e.scrollTimeline&&e.observe()),!0},F={tracks:n,isJS:!1,isFinishing:!1,schedule:N,demote:P,scrollTime(e){let t=!F.isJS&&p?.effect?.getComputedTiming().progress;return typeof t==`number`?t*e.iterationDuration*1e3:void 0},release(e){li(e)&&n.delete(e),j()||N(!0)},check(){if(!F.isJS){for(let t in r)if(fi(e,t)!==r[t]&&!x(t))return N(!0,!0)}}};return dr.set(t,F),F}var Si=class extends Bn{constructor(e,t,n,r,i){super(),this.parent=e,this.options=t,this.value=n,this.plan=r,this.onDone=i,this.name=t.name,this.calculatedDuration=this.resolvedDuration=this.totalDuration=0,this.stop=()=>Ei(this)}update(e){this.value.set(e),this.plan.transition.onUpdate?.(e)}init(){this.resolver=void 0,this.isStopped||(this.isReady=!0,this.isTransform&&(this.canAccelerate=hi(this.options)),Nn(this),this.parent.onTrackReady(this),this.isTransform&&this.parent.state===`running`&&Ci(this))}at(e){return(this.scrollTimeline&&this.group?.scrollTime(this))??Fi(this.parent,this,Oi(this.parent,e))}sampleAt(e,t){return this.sampleTime(this.at(e),t)}sampleTime(e,t,n){this.generator||Nn(this);let{options:r,totalDuration:i}=this;return e-=r.delay||0,!n&&e>=i&&r.type!==tt?Te(r.keyframes,r,t?void 0:r.finalKeyframe):Pn(this,Math.max(e,0),e<0).value}isAccelerated(){let{group:e}=this;return e&&!e.isJS&&this.canAccelerate&&!this.isDone&&e.tracks.has(this)}demote(){let{parent:e}=this;this.native&&(Li(e,this),this.generator||Nn(this),e.state===`running`&&e.driver?.start())}schedule(){let{parent:e,pooled:t}=this;if(!(this.native||this.isDone||this.isStopped||e.isStopped||e.isCancelled||e.unfollow||!t))try{let n=Ai(this,...t);n.playbackRate=e.playbackSpeed,ji(e,n)}catch{}}sync(){let e=be.now(),t=this.sampleAt(e,!0);this.value.setWithVelocity(this.parent.holdTime===null?this.sampleAt(e-10,!0):t,t,10)}get grouped(){return this.parent}liveValue(){return this.native&&!this.isDone||this.isAccelerated()?this.sampleAt(be.now()):void 0}get state(){return this.isDone?`finished`:this.isStopped?`idle`:this.parent.state}get startTime(){return this.parent.startTime}get speed(){return this.parent.playbackSpeed}set speed(e){this.parent.speed=e}complete(){this.isDone||(this.update(this.options.type===tt?this.sampleAt(be.now()):Ti(this)),wi(this))}};function Ci(e){Mi(e.parent,be.now());let t=e.group=bi(e);t.isJS||t.schedule(!1)}function wi(e){let{parent:t,group:n}=e;e.isDone||t.numDone++,e.isDone=!0,e.notifyFinished(),e.onDone(),e.pooled&&Xr(e),e.plan.transition.onComplete?.(),n&&!n.isFinishing&&n.release(e),(e.native||n)&&Ri(t)}function Ti(e){let{options:t}=e;return Te(t.keyframes,t,t.finalKeyframe,e.parent.playbackSpeed)}function Ei(e){e.isStopped||(e.parent.state===`idle`||e.options.onStop?.(),e.isStopped=!0,e.resolver?.cancel(),Hi(e),qi(e.parent,e))}var Di=class extends Bn{constructor(e){super(),this.state=`idle`,this.playbackSpeed=1,this.tracks=[],this.startTime=this.holdTime=null,this.calculatedDuration=this.totalDuration=this.currentTime=this.numPending=this.numDone=this.numOut=0,this.options={driver:e},this.stop=()=>this.stopAnimation()}updateTime(e){this.currentTime=this.holdTime??Math.round(e-this.startTime)*this.playbackSpeed}add(e,t,n,r){let i=new Si(this,e,t,n,r);return this.tracks.push(i),this.numPending++,i}onTrackReady(e,t=e){Rn(t,e.options),this.numPending--,this.js?.start();let{calculatedDuration:n,totalDuration:r,options:i}=e;n>this.calculatedDuration&&(this.calculatedDuration=n);let a=r+(i.delay||0);a>this.totalDuration&&(this.totalDuration=a)}start(){zi(this),this.options.autoplay===!1?Bi(this):Vi(this,!1,!0),Ni(this,e=>ji(this,e))}pool(e,t,n){if(e.name===`transform`&&!n[0].pseudoElement&&(e.pooled=[t,n],Jr(e)))return e.init();let r=Ai(e,t,n),{duration:i,iterations:a}=n[0];e.calculatedDuration=e.resolvedDuration=i,e.totalDuration=i*a,e.isReady=!0,e.resolver=void 0,this.onTrackReady(e),ji(this,r)}get js(){return this.isOffloaded?this.driver:void 0}tick(e){if(this.startTime===null)return;Mi(this,e);let{playbackSpeed:t,holdTime:n,totalDuration:r,tracks:i}=this;t&&(this.startTime=Math.min(this.startTime,t>0?e:e-r/t)),this.updateTime(e);let a=this.currentTime,o=t>=0,s=n===null,c=this.state===`finished`&&s,l=this.state===`running`&&s,u=Ii(this),d=this.numPending,f=0,p=!1;for(let e=0;es,g=c?s:Math.max(m,0);if(p||(p=!0,this.currentTime=g),t.native||!c&&!this.isCancelling&&t.isAccelerated()){d++,f++;continue}if(h&&!c&&t.value.get?.()===n.keyframes[0]&&!t.plan.transition.onUpdate&&!t.value.passiveEffect){d++;continue}let _=Pn(t,g,h),{value:v}=_,y=!h&&(o?t.calculatedDuration<1/0?g>=s:_.done:g<=0),b=c||l&&y;b&&n.type!==tt&&(v=Ti(t)),t.update(v),b?wi(t):d++}this.numOut&&=(this.tracks=i.filter(e=>!e.isStopped),0),this.isOffloaded=d>0&&d===f,!d&&(l||c)&&this.finish()}finish(){Gi(this,`finished`),Ri(this)}stopAnimation(){for(let e of this.tracks)e.isStopped||Ki(this,e);this.isStopped=!0,Ui(this),this.state!==`idle`&&(Gi(this),ki(this,`onStop`)),Wi(this)}};function Oi(e,t){return e.holdTime??Math.round((t-e.startTime)*e.playbackSpeed*1e4)/1e4}function ki(e,t){for(let n of e.tracks)n.isStopped||n.options[t]?.()}function Ai(e,t,[n,r]){let{name:i,keyframes:a,times:o,delay:s}=e.options,c={[i]:a};o&&(c.offset=o),r&&(c.easing=r);let l=Ce(t,c,{...n,delay:s});return Xi(e.native=l,e),l}function ji(e,t){if(e.isCancelled)return t.cancel();e.startTime!==null&&(e.state===`paused`?(t.pause(),t.currentTime=e.holdTime??0):(t.startTime=Mi(e,be.now()),e.holdTime===null||(t.currentTime=e.holdTime)))}function Mi(e,t){return e.startTime===e.pendingStartTime&&(e.startTime=In(e.startTime,t)),e.pendingStartTime=void 0,e.startTime}function Ni(e,t,n){for(let r of e.tracks){let{native:e}=r;e&&!r.isStopped&&(n||!r.isScrolling)&&t(e,r)}}var Pi=(e,t)=>e.sampleTime(e.at(t),!1,!0);function Fi(e,{calculatedDuration:t,options:n},r,i=Ii(e)){return i?r*(t+(n.delay||0))/i:r}function Ii(e){return e.unfollow&&L(e.iterationDuration)}function Li(e,t){let n=t.native,r=t.options.pseudoElement;if(t.native=void 0,Xi(n),!t.isDone&&e.startTime!==null){let n=be.now(),i=e.playbackSpeed,a=e.state===`running`&&i?10:0,o=Pi(t,n);r||Yi(t,o),t.value.setWithVelocity(Pi(t,n-a*Math.sign(i)),o,a/Math.abs(i||1))}r||n.cancel()}function Ri(e){e.numDone{e.tick(t),e.isOffloaded&&e.driver?.stop()}),ki(e,`onPlay`);let r=e.driver.now();e.state===`finished`?(e.updateFinished(),e.startTime=r+(e.playbackSpeed<0?e.calculatedDuration:0)):e.holdTime===null?e.startTime||=n??(e.pendingStartTime=r):e.startTime=r-e.holdTime/(e.playbackSpeed||1),e.holdTime=null,e.state=`running`,e.driver.start()}function Bi(e){e.state=`paused`,e.updateTime(be.now()),e.holdTime=e.currentTime}function Vi(e,t,n){for(let r of e.tracks){let{group:e}=r;!r.isTransform||!r.isReady||r.isStopped||r.isDone||r.scrollTimeline||(n?Ci(r):e&&!e.isJS&&e.schedule(!1,t))}}function Hi(e){let{value:t}=e;t.animation===e&&(t.animation=void 0)}function Ui(e){e.tracks.forEach(Hi)}function Wi(e){for(let t of e.tracks)t.group?.release(t)}function Gi(e,t=`idle`){e.state=t,e.driver?.stop(),e.driver=void 0,e.startTime=e.holdTime=null}function Ki(e,t){if(t.pooled&&Xr(t),t.native)Li(e,t);else if(t.isAccelerated())t.sync();else{let n=be.now();t.isReady&&!t.isDone&&e.startTime!==null&&t.value.updatedAt!==n&&(t.value.updatedAt=n,t.update(Pi(t,n)))}}function qi(e,t){Ki(e,t),t.group?.release(t),t.isReady||e.numPending--,t.isDone&&(t.isDone=!1,e.numDone--),e.isInterrupted=!0,e.numOut++,e.numOut===e.tracks.length&&Gi(e)}function Ji(){let e=this.track,t=Ti(e);Xi(this),e.options.pseudoElement||(e.update(t),Yi(e,t),this.cancel()),wi(e)}var Yi=(e,t)=>{let n=e.value.owner.current;n&&Se(n,e.name,t)};function Xi(e,t){let n=e.track;n?.pooled&&hr(n,!1),t?.pooled&&hr(t,!0),e.track=t,e.onfinish=t?Ji:null}var Zi=e=>e*180/Math.PI,Qi=e=>ea(Zi(Math.atan2(e[1],e[0]))),$i={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scaleZ:()=>1,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Qi,rotateZ:Qi,skewX:e=>Zi(Math.atan(e[1])),skewY:e=>Zi(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},ea=e=>(e%=360,e<0&&(e+=360),e),ta=Qi,na=e=>Math.hypot(e[0],e[1]),ra=e=>Math.hypot(e[4],e[5]),ia={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:na,scaleY:ra,scaleZ:e=>Math.hypot(e[8],e[9],e[10]),scale:e=>(na(e)+ra(e))/2,rotateX:e=>ea(Zi(Math.atan2(e[6],e[5]))),rotateY:e=>ea(Zi(Math.atan2(-e[2],e[0]))),rotateZ:ta,rotate:ta,skewX:e=>Zi(Math.atan(e[4])),skewY:e=>Zi(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function aa(e){return+!!e.includes(`scale`)}function oa(e,t){if(!e||e===`none`)return aa(t);let n=e.match(/^matrix(3d)?\(([-\d.e\s,]+)\)$/u);if(!n)return aa(t);let r=(n[1]?ia:$i)[t],i=n[2].split(`,`).map(e=>parseFloat(e));return typeof r==`function`?r(i):i[r]}var sa=!1,ca,la;function ua(e){sa=!0;try{e()}finally{sa=!1,ca=la=void 0}}var da=(e,t)=>(sa&&e===ca||(ca=e,la=getComputedStyle(e).transform||`none`),oa(la,t)),fa=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function pa(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(St)||[];if(!r)return e;let i=n.replace(r,``),a=+!!fa.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var ma=/\b([a-z-]*)\(.*?\)/gu,ha=Object.assign({},rn,{getAnimatableNone:e=>{let t=e.match(ma);return t?t.map(pa).join(` `):e}}),ga=Object.assign({},rn,{getAnimatableNone:e=>{let t=rn.parse(e);return rn.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}}),_a,va,ya;function ba(e,t){return e===_a&&t===va||(ya=(e===`filter`||e===`WebkitFilter`?ha:e===`mask`||e===`WebkitMask`?ga:rn).getAnimatableNone(t),_a=e,va=t),ya}function xa(e){for(let t=1;te===yt||e===Ft,Ca=new Set([`x`,`y`,`z`]),wa=Gn.filter(e=>!Ca.has(e));function Ta(e){let t=[];return wa.forEach(n=>{let r=e.getValue(n);if(r!==void 0){let e=r.get(),i=aa(n);if(e===i)return;t.push([n,e]),r.set(i)}}),t}var Ea=new Set([`bottom`,`right`]);function Da(e,t,n,r,i,a){let o=parseFloat(e);if(!isNaN(o))return o;let{min:s,max:c}=t()[n],l=c-s;return a===`border-box`?l:l-parseFloat(r)-parseFloat(i)}var Oa=({transform:e})=>oa(e,`x`),ka=({transform:e})=>oa(e,`y`),Aa={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>Da(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>Da(e,i,`y`,t,n,r),top:({top:e})=>parseFloat(e),left:({left:e})=>parseFloat(e),bottom:({top:e},t)=>{let{y:n}=t();return parseFloat(e)+(n.max-n.min)},right:({left:e},t)=>{let{x:n}=t();return parseFloat(e)+(n.max-n.min)},x:Oa,y:ka,translateX:Oa,translateY:ka},ja=new Set,Ma=!1,Na=!1,Pa=!1;function Fa(){if(Na){let e=[],t=new Set,n=new Set;ja.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),Ea.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=Ta(e);t.length&&(r.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}Na=!1,Ma=!1,ja.forEach(e=>e.complete(Pa)),ja.clear()}function Ia(){ua(()=>ja.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Na=!0)}))}function La(e,t,n){if(typeof e==`string`){if(k(e)||j(e))return parseFloat(e);if(!rn.test(e)&&rn.test(n))return ba(t,n)}return e??void 0}function Ra(e,t,n,r){e.setCurrent(t),r&&n?.latestValues&&(n.latestValues[r]=t)}var za=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(ja.add(this),Ma||(Ma=!0,st.read(Ia),st.resolveKeyframes(Fa))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=La(n.readValue(t,a),t,a);r!==void 0&&(e[0]=r)}if(e[0]===void 0&&(e[0]=a),r&&i===void 0){let i=e[0];e.some(e=>e!==null&&e!==i)?Ra(r,i,n,t):r.set(i)}}xa(e)}measureInitialState(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ja.delete(this)}cancel(){this.state===`scheduled`&&(ja.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}};function Ba(e,t){if(e)return typeof e==`function`?ur()?Ee(e,t):`ease-out`:pe(e)?Qn(e):Array.isArray(e)?e.map(e=>Ba(e,t)||$n.easeOut):$n[e]}function Va(e){return typeof e==`function`&&`applyToOptions`in e}var Ha=e=>Array.from(e).sort((e,t)=>e.sortNodePosition(t));function Ua(e,t,n,r=0,i=1,a){let o=typeof n==`function`;if(!o&&!r)return 0;let s=(a||Ha(e)).indexOf(t),c=e.size;return o?n(s,c):i===1?s*r:(c-1-s)*r}var Wa=30,Ga=e=>!isNaN(parseFloat(e)),Ka={current:void 0},qa=class{constructor(e,t={}){this.canTrackVelocity=null,this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=be.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Ga(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){var n;return e===`change`?(this.addChangeSubscriber(t),()=>this.removeChangeSubscriber(t)):((n=this.events||={})[e]||(n[e]=new I)).add(t)}addChangeSubscriber(e){var t;if(!this.events?.change&&!this.changeSubscriber)this.changeSubscriber=e;else{let n=(t=this.events||={}).change||(t.change=new I);this.changeSubscriber&&=(n.add(this.changeSubscriber),void 0),n.add(e)}}removeChangeSubscriber(e){this.changeSubscriber===e?this.changeSubscriber=void 0:this.events?.change?.remove(e),this.stopIfUnobserved()}stopIfUnobserved(){st.read(()=>{!this.changeSubscriber&&!this.events?.change?.getSize()&&this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.boundUpdateAndNotify||=e=>this.updateAndNotify(e)):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){t&&(this.updatedAt=be.now(),this.stop()),this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,this.stopPassiveEffect?.()}dirty(){let{current:e,changeSubscriber:t}=this;t?t(e):this.events?.change?.notify(e)}addDependent(e){(this.dependents||=new Set).add(e)}removeDependent(e){this.dependents?.delete(e)}updateAndNotify(e){let t=be.now(),n=this.prev=this.current;if(this.updatedAt!==t&&(this.prevFrameValue=n,this.prevUpdatedAt=this.updatedAt),this.current=e,this.updatedAt=t,this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Ga(e)),e!==n&&(this.dirty(),this.dependents))for(let e of this.dependents)e.dirty()}get(){Ka.current?.push(this);let e=this.animation?.liveValue?.();return e===void 0?this.current:e}getCurrent(){return this.current}getPrevious(){return this.prev}getVelocity(){let e=be.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Wa)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Wa),{current:n,prevFrameValue:r}=this;return R(typeof n==`number`&&typeof r==`number`?n-r:parseFloat(n)-parseFloat(r),t)}start(e){return new Promise(t=>this.run(e,t))}run(e,t){this.stop(),this.hasAnimated=!0;let n=!1,r;r=e(()=>{n=!0,this.events?.animationComplete?.notify(),this.animation===r&&(this.animation=void 0),t?.()}),n||(this.animation=r),this.events?.animationStart?.notify()}stop(){this.animation&&(this.animation.stop(),this.events?.animationCancel?.notify()),this.animation=void 0}isAnimating(){return!!this.animation}destroy(){this.dependents?.clear(),this.events?.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect?.()}};function Ja(e,t){return new qa(e,t)}var Ya=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(rn.test(e)||e===`0`)&&!e.startsWith(`url(`));function Xa(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),eo={type:`keyframes`,duration:.8},to={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},no=(e,{keyframes:t})=>t.length>2?eo:Kn.has(e)?e.startsWith(`scale`)?$a(t[1]):Qa:to;function ro(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function io(e,t){let n=e?.[t]??e?.default??e;return n===e?n:ro(n,e)}var ao=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`,`out`,`mixer`]);function oo(e){for(let t in e)if(!ao.has(t))return!0;return!1}function so(e){e.duration=0,e.type=`keyframes`}function co(e){e.autoplay??=!0,e.delay??=0,e.type??=`keyframes`,e.repeat??=0,e.repeatDelay??=0,e.repeatType??=`loop`}function lo(e,t){if(e===t)return!0;let n=0;for(let r in e){if(r!==`delay`&&r!==`times`&&!uo(e[r],t[r]))return!1;n++}for(let e in t)n--;return n===0}var uo=(e,t)=>e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>e===t[n]);function fo(e,t,n,r){let i={ease:`easeOut`,...t,name:e,element:r,hasOnUpdate:!!t.onUpdate};i.onUpdate=i.onComplete=i.velocity=void 0,oo(t)||Object.assign(i,no(e,{keyframes:n})),i.duration&&=L(i.duration),i.repeatDelay&&=L(i.repeatDelay);let a=i.type===!1||i.duration===0&&!i.repeatDelay,o=!!(O.instantAnimations||O.skipAnimations||r?.shouldSkipAnimations||t.skipAnimations);return(a||o)&&so(i),i.allowFlatten=!t.type&&!t.ease,co(i),{transition:t,base:i,isInstant:a,isSkipped:o,isLong:n.length>2,target:n[1]}}function po(e){if(!(`ease`in e)){let{ease:t}=e.base;e.ease=fe(t)?t:ge(t)}return e.ease}function mo(e,t,n,r,i){let a=e.plans||={},o=a[t];return o&&lo(o.transition,n)&&o.isLong===r.length>2&&(o.target===r[1]||o.target!==0&&r[1]!==0)&&o.base.element?.shouldSkipAnimations===i?.shouldSkipAnimations||(o=a[t]=fo(t,n,r,i)),o}function ho(e,t){let{type:n,repeat:r=0,repeatType:i,pseudoElement:a}=e,{duration:o=300}=e;if(Va(n))ur()&&({duration:o,ease:t}=n.applyToOptions({...e}));else if(n!==An)return!1;let s=Ba(t===`anticipate`||t===`backInOut`||t===`circInOut`?ge(t):t,o),c=Array.isArray(s);return[{duration:o,easing:c?`linear`:s,fill:`both`,iterations:r+1,direction:i===`reverse`?`alternate`:`normal`,pseudoElement:a},c?s:void 0]}function go(e,t){let n=[...e];if(n[0]===null){let e=t.get();n[0]=e??n[n.length-1],e===void 0&&t.set(n[0])}return xa(n),n}function _o(e,t){let{keyframes:n}=e,r=Math.abs(parseFloat(n[1])-parseFloat(n[0]))||100,i=[e.stiffness,e.damping,e.mass,e.duration,e.bounce,e.visualDuration,e.restDelta,e.restSpeed]+``,a=i+r;if(!t[a]){let n=ke(e,r,et);t[a]={ease:n.ease,duration:L(n.duration),type:An,curve:i}}Object.assign(e,t[a])}function vo(e,t,n,r,i){let{options:a}=e,o=(r,o)=>{let{name:s,type:c,velocity:l,delay:u}=a,d=Za(r,s,c,l);if(d||((O.instantAnimations||!u)&&e.update(Te(r,a,o)),r[0]=r[r.length-1],so(a),a.repeat=0),a.finalKeyframe=o,a.keyframes=r,i&&d&&_o(a,i),d&&!e.isTransform&&sr(a)){Mn(a);let{plan:r}=e,i=a.type===An?r.waapi??=ho(a,r.base.ease):ho(a,r.base.ease);if(e.isStopped||t.isStopped)return;if(i)try{return t.pool(e,n.owner.current,i)}catch{}}e.init()},s=r&&(r.KeyframeResolver||za);if(s){let t=new s(a.keyframes,o,a.name,n,r);e.resolver=t,t.scheduleResolve()}else o(go(a.keyframes,n))}var yo=(e,t,n,r,i,a,o,s)=>c=>{let l=io(i,t)||{},u=Array.isArray(r)?r:[null,r],d=mo(e,t,l,u,a),{base:f}=d,p=d.isSkipped?0:-((i.elapsed||0)-L(l.delay||i.delay||0));if(f.from!==void 0&&(u[0]=f.from),(d.isSkipped||d.isInstant&&!p)&&!s&&n.get()!==void 0){let e=Te(u,l);if(e!==void 0){st.update(()=>{n.set(e),l.onUpdate?.(e),c(),l.onComplete?.()});return}}let m=`velocity`in l?l.velocity:n.getVelocity(),h=mi(t,n,o),g=e.animation||=new Di(f.driver),_=g.options;f.autoplay===!1&&(_.autoplay=!1),_.startTime??=f.startTime,(s||f.isSync)&&(a=void 0);let v={...f,element:a,ease:h?f.ease:po(d),keyframes:u,times:l.times,delay:p,velocity:m,motionValue:n},{type:y}=v,b=h&&(y===`spring`||y===et)&&!m&&(e.springs||={}),x=g.add(v,n,d,c);return x.isTransform=h,vo(x,g,n,a,b),x},bo=(e,t,n,r={},i,a)=>o=>{let s={},c=yo(s,e,t,n,r,i,!1,a)(o);return s.animation?.start(),c},xo=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function So(e){let t=xo.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Co(e,t,n=1){let[r,i]=So(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return k(e)?parseFloat(e):e}return ht(i)?Co(i,t,n+1):i}var wo=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Gn]);function To(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Eo(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...To(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function Do(e,t,n){return Eo(e.getProps(),t,n,e)}var Oo=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,ko=e=>Array.isArray(e);function Ao(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ja(n))}function jo(e){return ko(e)?e[e.length-1]||0:e}function Mo(e,t){let{transitionEnd:n={},transition:r={},...i}=Do(e,t)||{};i={...i,...n};for(let t in i)Ao(e,t,jo(i[t]))}var No=e=>!!(e&&e.getVelocity);function Po(e){return!!(No(e)&&e.add)}function Fo(e,t){let n=e.getValue(`willChange`);if(Po(n))return n.add(t);if(!n&&O.WillChange){let n=new O.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}var Io=`data-framer-appear-id`;function Lo(e){return e.props[Io]}var Ro=typeof window<`u`;function zo({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function Bo(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?ro(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f={},p={},m=i&&e.animationState?.getState()[i],h=a?.path;h&&(h.animateValues?h.animateValues(t=>e.getValue(t,e.latestValues[t]??0),s,a,n,d):h.animateVisualElement?.(e,s,a,n,d));for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||m&&zo(m,t))continue;let o={delay:n,...io(m?.out[t]||a,t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){st.update(()=>r.set(i));continue}let h=!1;if(Ro&&window.MotionHandoffAnimation){let n=Lo(e);if(n){let e=window.MotionHandoffAnimation(n,t,st);e!==null&&(o.startTime=e,h=!0)}}Fo(e,t);let g=l??e.shouldReduceMotion;r.run(yo(h?p:f,t,r,i,g&&wo.has(t)?{type:!1}:o,e,!1,h));let _=r.animation;_&&d.push(_)}if(f.animation?.start(),p.animation?.start(),o){let t=()=>st.update(()=>Mo(e,o));d.length?Promise.all(d).then(t):t()}return d}function Vo(e,t,n={}){let r=Do(e,t,Oo(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?Bo(e,r,n):[]),o=(r=0)=>{let{variantChildren:a}=e,{delayChildren:o=0,staggerChildren:s,staggerDirection:c}=i,l=[],u=a&&(typeof o==`function`||s)&&Ha(a);return a?.forEach(e=>{e.notify(`AnimationStart`,t),l.push(Vo(e,t,{...n,delay:r+(typeof o==`function`?0:o)+Ua(a,e,o,s,c,u||void 0)}).then(()=>e.notify(`AnimationComplete`,t)))}),Promise.all(l)},{when:s}=i;return s?s===`beforeChildren`?a().then(()=>o()):o().then(a):Promise.all([a(),o(n.delay)])}function Ho(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>Vo(e,t,n))):typeof t==`string`?Vo(e,t,n):Promise.all(Bo(e,Do(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var Uo={test:e=>e===`auto`,parse:e=>e},Wo=e=>t=>t.test(e),Go=[yt,Ft,Pt,Nt,Lt,It,Uo],Ko=e=>Go.find(Wo(e));function qo(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||j(e)}var Jo=new Set([`auto`,`none`,`0`]);function Yo(e,t,n){let r=0,i;for(;re.measureViewportBox())}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e?.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&this.motionValue?.jump(r,!1)}measureEndState(){let{element:e,unresolvedKeyframes:t}=this;if(!e?.current)return;this.motionValue?.jump(this.measuredOrigin,!1);let n=t.length-1,r=t[n];t[n]=this.measure(),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.resolveNoneKeyframes()}},Zo=new WeakMap;function Qo(e){return A(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function $o(e){return A(e)&&`ownerSVGElement`in e}var es={};function ts(e){return es.current?.add(e),e}var ns=e=>es.current?es.current.bind(e):e;function rs(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=t?t.current:es.current?.root||document,i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var is=()=>({translate:0,scale:1,origin:0,originPoint:0}),as=()=>({x:is(),y:is()}),os=()=>({min:0,max:0}),ss=()=>({x:os(),y:os()}),cs={},ls=new Map;function us(e){let t=ls.get(e);if(!t){let n={nodes:[],flush:()=>{let{nodes:t}=n;n.nodes=[];for(let e=0;e{i&&_e.isProcessing?n?.(t):(r[e]=t,a?.call(this,e),n&&this.schedule(n))})}else n&&this.schedule(n);return()=>{this.bindings[e]===o&&(this.unbind(e),this.values.delete(e))}}unbind(e){let t=this.bindings[e];if(!t)return;let{render:n}=t;if(this.stop(t),n){if(n.shared)this.schedule(n);else{let{pending:e}=this;for(let t=0;t{let r=e.shared||={};return r[t]||(r[t]=Object.assign(n(),{shared:!0}))},ps=(e,t)=>Vn(e.latestValues[t],Wn[t]),ms={},hs=(e,t,n)=>{let r=fs(t,`transform`,()=>{let n=[],r=e=>t.values?.get(e)?.isAnimating(),i=t.scheduleRender?void 0:n,{style:a}=e,o=e.ownerSVGElement!==void 0&&e.tagName!==`svg`,s=()=>{dr.get(e)?.check();let{latestValues:c}=t;if(c.transform)return;let{transformTemplate:l}=t.getProps(),u=Zn(c,l?{}:ms,l,i),d=u===`none`&&a.transform&&a.transform!==`none`&&n.some(r);a.transform=d?`translateX(0px)`:u,d&&t.schedule?.(s),o&&(a.transformOrigin||=`50% 50%`,a.transformBox||=c.transformBox||t.getProps().style?.transformBox||`fill-box`)};return Object.assign(s,{keys:n})}),{keys:i}=r;return n&&!i.includes(n)&&i.splice(0,i.length,...Gn.filter(e=>e===n||i.includes(e))),r},gs=(e,t,n)=>Kn.has(n)?hs(e,t,n):n.startsWith(`origin`)?fs(t,`origin`,()=>()=>{e.style.transformOrigin=`${ps(t,`originX`)??`50%`} ${ps(t,`originY`)??`50%`} ${ps(t,`originZ`)??0}`}):_s(e,t,n),_s=(e,t,n)=>{let r=er.has(n);return()=>{if(!r){let r=t.values?.get(n);r?.isAnimating()&&fr.mark?.(e,r)}Se(e,n,ps(t,n))}},vs=(e,t,n,r)=>t.set(n,r,gs(e,t,n)),ys=(e,t)=>{if(Kn.has(t))return da(e,t);let n=getComputedStyle(e),r=xe(t)?n.getPropertyValue(t):n[t];return typeof r==`string`&&r.trim()||0};function bs(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var xs=[`transform`,`opacity`,`clipPath`,`filter`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function Ss(e,t){if(!(t in e))return!1;let n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t)||Object.getOwnPropertyDescriptor(e,t);return n&&typeof n.set==`function`}var Cs=(e,{latestValues:t},n,r=n)=>{let i=Ss(e,r);!i&&(r.startsWith(`data`)||r.startsWith(`aria`))&&(r=bs(r));let a=Wn[n]||Wn[r];return i?()=>{e[r]=Vn(t[n],Wn[n])}:()=>{let i=Vn(t[n],a);i==null?e.removeAttribute(r):e.setAttribute(r,String(i))}},ws=e=>Kn.has(e)||e.startsWith(`origin`)||xe(e),Ts=(e,t,n)=>{let{latestValues:r}=t;return n.startsWith(`path`)&&!Kn.has(n)?n===`pathOffset`?()=>{e.setAttribute(`pathLength`,`1`),e.setAttribute(`stroke-dashoffset`,`${-r.pathOffset}`)}:fs(t,`dash`,()=>()=>{let{pathLength:t=1,pathSpacing:n}=r;e.setAttribute(`pathLength`,`1`),e.setAttribute(`stroke-dasharray`,`${t} ${n??1-Number(t)}`)}):n.startsWith(`attr`)?Cs(e,t,n,Os(n)):n===`d`?()=>{let t=r.d?.replace(/path\(|["')]/g,``);t===void 0?e.removeAttribute(n):e.setAttribute(n,t)}:(ws(n)||n in e.style&&(n!==`offset`||e.tagName!==`stop`)?gs:Cs)(e,t,n)},Es=(e,t,n,r)=>t.set(n,r,Ts(e,t,n)),Ds=(e,t)=>Kn.has(t)?Wn[t]?.default||0:xe(t)||xs.includes(t)?ys(e,t)||e.getAttribute(bs(t))||0:(t=Os(t),e.getAttribute(bs(t))??e.getAttribute(t)??void 0);function Os(e){return e.replace(/^attr([A-Z])/,(e,t)=>t.toLowerCase())}function ks({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function As({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function js(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Ms(e,t){return ks(js(e.getBoundingClientRect(),t))}var Ns=at(queueMicrotask,!1).schedule;function Ps(){let e=be.now();_e.delta=D(0,1e3/60,e-_e.timestamp),_e.timestamp=e,_e.isProcessing=!0,lt.update.process(_e),lt.preRender.process(_e),lt.render.process(_e),_e.isProcessing=!1}var Fs={},Is={value:null,addProjectionMetrics:null,countProjection:void 0};function Ls(e,t){let n=be.now();e=ns(e);let r=({timestamp:i})=>{let a=i-n;a>=t&&(ct(r),e(a-t))};return st.setup(r,!0),ts(()=>ct(r))}function Rs(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function zs(e){return $o(e)&&e.tagName===`svg`}function Bs(e){return No(e)?e.get():e}var Vs=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`],Hs=e=>typeof e==`number`?e:parseFloat(e);function Us(e){return e===void 0||e===1}function Ws({scale:e,scaleX:t,scaleY:n}){return!Us(e)||!Us(t)||!Us(n)}var Gs=[`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skewX`,`skewY`];function Ks(e){return Ws(e)||Js(e)||qs(e)}function qs(e){return e.z||e.rotate||e.rotateX||e.rotateY||e.rotateZ||e.skewX||e.skewY}function Js(e){return Ys(e.x)||Ys(e.y)}function Ys(e){return e&&e!==`0%`}var Xs=e=>typeof e==`number`||Ft.test(e);function Zs(e,t,n,r,i,a){i?(e.opacity=cn(0,n.opacity??1,$s(r)),e.opacityExit=cn(t.opacity??1,0,ec(r))):a&&(e.opacity=cn(t.opacity??1,n.opacity??1,r));for(let i=0;irt?1:n(F(e,t,r))}var nc=(e,t,{x:n,y:r})=>{let i=e*e+t*t;return i<1?0:-1e3*(n*e+r*t)/i},rc=(e,t=300)=>{let n=D(.25,2,t/300),{stiffness:r,damping:i}=Qe({...e,duration:e.duration&&L(e.duration)});return{...e,stiffness:r,damping:i*Math.sqrt(n),mass:n}};function ic(e,t){e.min=t.min,e.max=t.max}function ac(e,t){ic(e.x,t.x),ic(e.y,t.y)}function oc(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function sc(e,t,n){return n+t*(e-n)}function cc(e,t,n,r,i){return i!==void 0&&(e=sc(e,i,r)),sc(e,n,r)+t}function lc(e,t=0,n=1,r,i){e.min=cc(e.min,t,n,r,i),e.max=cc(e.max,t,n,r,i)}function uc(e,{x:t,y:n}){lc(e.x,t.translate,t.scale,t.originPoint),lc(e.y,n.translate,n.scale,n.originPoint)}var dc=.999999999999,fc=1.0000000000001;function pc(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;sdc&&(t.x=1),t.ydc&&(t.y=1)}function mc(e,t){e.min+=t,e.max+=t}function hc(e,t,n,r,i=.5){lc(e,t,n,cn(e.min,e.max,i),r)}function gc(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function _c(e,t,n){let r=n??e;hc(e.x,gc(t.x,r.x),t.scaleX,t.scale,t.originX),hc(e.y,gc(t.y,r.y),t.scaleY,t.scale,t.originY)}var vc=.9999,yc=1.0001,bc=-.01,xc=.01;function Sc(e){return e.max-e.min}function Cc(e,t,n){return Math.abs(e-t)<=n}function wc(e,t,n,r=.5){e.origin=r,e.originPoint=cn(t.min,t.max,e.origin),e.scale=Sc(n)/Sc(t),e.translate=cn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=vc&&e.scale<=yc||isNaN(e.scale))&&(e.scale=1),(e.translate>=bc&&e.translate<=xc||isNaN(e.translate))&&(e.translate=0)}function Tc(e,t,n,r){wc(e.x,t.x,n.x,r?.originX),wc(e.y,t.y,n.y,r?.originY)}function Ec(e,t,n,r=0){e.min=(r?cn(n.min,n.max,r):n.min)+t.min,e.max=e.min+Sc(t)}function Dc(e,t,n,r){Ec(e.x,t.x,n.x,r?.x),Ec(e.y,t.y,n.y,r?.y)}function Oc(e,t,n,r=0){let i=r?cn(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Sc(t)}function kc(e,t,n,r){Oc(e.x,t.x,n.x,r?.x),Oc(e.y,t.y,n.y,r?.y)}function Ac(e,t,n,r,i){return e-=t,e=sc(e,1/n,r),i!==void 0&&(e=sc(e,1/i,r)),e}function jc(e,t=0,n=1,r=.5,i,a=e,o=e){if(Pt.test(t)&&(t=parseFloat(t),t=cn(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=cn(a.min,a.max,r);e===a&&(s-=t),e.min=Ac(e.min,t,n,s,i),e.max=Ac(e.max,t,n,s,i)}function Mc(e,t,[n,r,i],a,o){jc(e,t[n],t[r],t[i],t.scale,a,o)}var Nc=[`x`,`scaleX`,`originX`],Pc=[`y`,`scaleY`,`originY`];function Fc(e,t,n,r){Mc(e.x,t,Nc,n?.x,r?.x),Mc(e.y,t,Pc,n?.y,r?.y)}var Ic=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Lc;function Rc(e,t){e.min=t(e.min),e.max=t(e.max)}function zc(e){Lc??=Ic(`applewebkit/`)&&!Ic(`chrome/`)?Math.round:N,Rc(e.x,Lc),Rc(e.y,Lc)}function Bc(e){return e.translate===0&&e.scale===1}function Vc(e){return Bc(e.x)&&Bc(e.y)}function Hc(e,t){return e.min===t.min&&e.max===t.max}function Uc(e,t){return Hc(e.x,t.x)&&Hc(e.y,t.y)}function Wc(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Gc(e,t){return Wc(e.x,t.x)&&Wc(e.y,t.y)}function Kc(e){return Sc(e.x)/Sc(e.y)}function qc(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}var Jc=class{constructor(){this.members=[]}add(e){T(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;r&&r.isConnected!==!1||n.snapshot||(E(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(E(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}};function Yc(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var Xc={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(Ft.test(e))e=parseFloat(e);else return e}return`${Yc(e,t.target.x)}% ${Yc(e,t.target.y)}%`}},Zc,Qc,$c,el={borderRadius:Object.assign({},Xc,{applyTo:Vs.slice()}),borderTopLeftRadius:Xc,borderTopRightRadius:Xc,borderBottomLeftRadius:Xc,borderBottomRightRadius:Xc,boxShadow:{correct:(e,{treeScale:t,projectionDelta:n})=>{if(e!==Zc){let t=Zt(e);Zc=e,Qc=t.values,$c=$t(t)}if(Qc.length>5)return e;let r=Qc.slice(),i=$c,a=typeof r[0]==`number`?0:1,o=n.x.scale*t.x,s=n.y.scale*t.y;r[0+a]/=o,r[1+a]/=s;let c=cn(o,s,.5);return typeof r[2+a]==`number`&&(r[2+a]/=c),typeof r[3+a]==`number`&&(r[3+a]/=c),i(r)}}};function tl(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;o?r=`translate3d(${i}px, ${a}px, ${o}px) `:(i||a)&&(r=`translate(${i}px, ${a}px) `);let s=``;if(n){let{transformPerspective:e}=n;e&&(r=`perspective(${e}px) ${r}`);for(let e=0;ee.depth-t.depth,il=class{constructor(){this.children=new Set}add(e){this.children.add(e),this.sorted=void 0}remove(e){this.children.delete(e)&&(this.sorted=void 0)}forEach(e){let{children:t}=this,n=this.sorted||=[...t].sort(rl);for(let r=0;rwindow.matchMedia?.(`(pointer: coarse)`).matches?100:400,cl=0,ll=[],ul=e=>{let{projectionDelta:t,treeScale:n}=e;if(t.x.scale*n.x!==1||t.y.scale*n.y!==1){let t=e.animationValues||e.latestValues;for(let e in Fs)if(t[e]!==void 0)return!0}},dl=e=>ul(e)||br(e.instance),fl=e=>{let{projectionDelta:t,treeScale:n}=e;(e.relativeTarget||e.targetDelta)&&e.layout?e.hasLayer?dl(e)?e.hasLayer=!1:cl++:e.hasLayer===void 0&&t&&(!Vc(t)||n.x!==1||n.y!==1)&&(dl(e)?e.hasLayer=!1:ll.push(e)):e.hasLayer=void 0},pl=e=>!!(e.scroll?.wasRoot||e.options.layoutScroll||Ks(e.latestValues)),ml=(e,t,n,r)=>Math.max(e.max,t.max)>n-r&&Math.min(e.min,t.min)!e.target||pl(e)||e.path.some((e,t)=>!!t&&pl(e))||ml(e.target.x,e.layout.layoutBox.x,t,r)&&ml(e.target.y,e.layout.layoutBox.y,n,i),gl=0,_l=e=>e.instance&&dr.get(e.instance)?.demote()&&e.resetSkewAndRotation();function vl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Lo(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,st,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&vl(r)}function yl(e){if(e)return e.options.allowProjection!==!1&&!e.projection?.isMeasureOnly?e.projection:yl(e.parent)}function bl({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return Object.assign(Fs,{...el,...Fs}),class{static create(e,t,n){let r=e.projection;if(r&&!r.isMeasureOnly)return;let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t,f=e.projection=new this(e.latestValues,t[`data-framer-portal-id`]?void 0:yl(e.parent));f.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Rs(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:n,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u}),r?.isMeasureOnly&&r.upgrade?.([f]),e.current&&!f.instance&&f.mount(e.current);let p=f.getStack()?.lead;p&&!f.root.isUpdateBlocked()&&(p.willUpdate(),p.scheduleCheckAfterUnmount())}constructor(e={},n=t?.()){this.id=gl++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{if(this.projectionUpdateScheduled=!1,this.nodes.forEach(wl),this.nodes.forEach(Ll),this.nodes.forEach(Rl),this.nodes.forEach(Tl),cl=mr,this.nodes.forEach(fl),ll.length){let{x:e,y:t}=this.scroll?.offset||{x:0,y:0},{innerWidth:n,innerHeight:r}=window,i=ll.filter(i=>i.hasLayer=hl(i,e,t,n,r));cl+i.length>sl()&&i.forEach(e=>e.hasLayer=!1),ll.length=0}Is.countProjection?.()},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.written={},this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.stacksChanged=0,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;ethis.root.updateBlockedByResize=!1;st.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n?.(),n=Ls(i,250),al.hasAnimatedSinceResize&&(al.hasAnimatedSinceResize=!1,this.nodes.forEach(Il)))})}n&&this.root.registerSharedNode(n,this),this.addLayoutListener()}addLayoutListener(){let{layoutId:e,layout:t,visualElement:n,animate:r}=this.options;this.instance&&!this.hasLayoutListener&&r!==!1&&n&&(e||t)&&(this.hasLayoutListener=!0,this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:r,layout:i})=>{if(this.isAnimationBlocked){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||n.getDefaultTransition()||Yl,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=n.getProps(),c=!this.targetLayout||!Gc(this.targetLayout,i),l=!t&&r;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...io(a,`layout`),onPlay:o,onComplete:s};(n.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||Il(this),this.isLead()&&this.options.onExitComplete?.();this.targetLayout=i}))}unmount(){this.options.layoutId&&this.willUpdate(!0,!0),this.root.nodes.remove(this),this.getStack()?.remove(this),this.parent?.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),this.hasLayoutListener=!1,ct(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}startUpdate(e){this.isUpdateBlocked()||(this.isUpdating=!0,this.pageBoxes=new Map,this.nodes?.forEach(zl),this.animationId++,e||this.nodes?.forEach(Ml))}getTransformTemplate(){let{visualElement:e}=this.options;return e?.getProps().transformTemplate}willUpdate(e=!0,t){if(this.root.hasTreeAnimated=!0,xl(this,!0),this.root.isUpdateBlocked()){this.options.onExitComplete?.();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&vl(this),!this.root.isUpdating&&this.root.startUpdate(t),t&&(this.root.pageBoxes=void 0),this.isLayoutDirty)return;_l(this),this.isLayoutDirty=!0;for(let e=0;ee.members.length?e.removeLeadSnapshot():this.sharedNodes.delete(t)&&this.stacksChanged++)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,st.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){st.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){if(this.snapshot||!this.instance)return;let e=this.measure(),{x:t,y:n}=e.measuredBox;if(this.snapshot=Sc(t)||Sc(n)?e:void 0,this.snapshot){let{visualElement:e}=this.options,t=this.currentAnimation?.state===`running`,n=t&&this.animationEdges;t&&this.relativeTarget&&(this.snapshot.relativeVelocity=this.relativeVelocity?.slice()||[]);let r=this.motionValue,i=n&&(r.current-r.prevFrameValue)/(r.updatedAt-r.prevUpdatedAt)||0,a=[0,1,2,3,4,5].map(t=>(t<4?n&&(this.edgeValues?this.edgeVelocity(t):-n[t]*i):e?.getValue(t<5?`x`:`y`)?.getVelocity())||0);a.some(Boolean)&&(this.snapshot.velocity=a)}}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e{let{translate:r,scale:i,originPoint:a}=e[n<2?`x`:`y`];return(t-a)*(i-1)+r});h?.every(isFinite)||(h=void 0),this.animationEdges=h,this.edgeValues=this.startVelocity=this.impulse=this.relativeVelocity=this.relativeStart=void 0;let g=r?.velocity,_=r?.relativeVelocity||g;if(_?.slice(0,4).some(Boolean)&&this.getClosestProjectingParent()&&(this.relativeStart=_),g&&h){let t=g.slice(0,4).map((e,t)=>e+(c?g[4+(t>>1)]:0));t.some(Boolean)&&(this.startVelocity=p?nc(e.x.translate,e.y.translate,{x:(t[0]+t[1])/2,y:(t[2]+t[3])/2}):t)}this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n),l=this.edgeValues;for(let t=0;t<2;t++){let r=t?`y`:`x`;l?Bl(o[r],e[r],this.layout.layoutBox[r],l[t*2],l[t*2+1]):Vl(o[r],e[r],n)}if(r&&(o.x.translate=r.x,o.y.translate=r.y),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent?.layout){kc(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0);let e=this.relativeTargetOrigin,t=s;if(Ul(this.relativeTarget,e,t,n),this.isSpringLayout){let e=this.relativeTarget,t=this.impulse||0,n=this.relativeStart,r=be.now(),i=(r-this.relativeTime)/1e3;this.relativeTime=r;let a=this.relativeVelocity||=[0,0,0,0];for(let r=0;r<4;r++){let o=r<2?`x`:`y`,s=r&1?`max`:`min`;n&&(e[o][s]+=n[r]*t),f&&i>0&&(a[r]=(e[o][s]-f[o][s])/i)}}f&&Uc(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=ss(),ac(f,this.relativeTarget)}c&&(this.animationValues=a,Zs(a,i,this.latestValues,n,d,u)),r?.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.animationValues&&this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`);let t=this.isSpringLayout=e.type===`spring`,{transition:n}=this.options;this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.resumingFrom&&(this.resumingFrom.edgeValues=void 0),this.pendingAnimation&&ct(this.pendingAnimation),this.pendingAnimation=st.update(()=>{al.hasAnimatedSinceResize=!0,this.motionValue||=Ja(0),this.motionValue.jump(0,!1);let r=this.startVelocity;this.startVelocity=void 0;let i=e,a=0;if(t){if(e.mass===`auto`){let t=this.layout?.layoutBox;i=rc(e,t&&Math.sqrt(Sc(t.x)*Sc(t.y)))}let t=this.relativeStart;if((r||t)&&!e.repeat){if(typeof r==`number`)a=r;else{let e=r&&this.animationEdges;i={...i,type:n=>{let i=[n.velocity,...r||[]].map((t,r)=>et({...n,keyframes:r?[e[r-1],0]:n.keyframes,velocity:t})),a=i.length;t&&i.push(et({...n,keyframes:[0,0],velocity:1e3,restDelta:.5,restSpeed:5}));let o=0,s=[],c={calculatedDuration:null,next:t=>{o=t;let n=i[0].next(t),r=n.done;for(let e=1;ei[e+1].velocity(o),c}}}}}this.motionValue.run(yo(Kl(n),``,this.motionValue,[0,1e3],{...i,velocity:a,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}})),this.currentAnimation=this.motionValue.animation,zn(this.currentAnimation,this),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0),this.getStack()?.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=this.edgeValues=this.edgeVelocity=this.impulse=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.edgeValues=this.impulse=void 0,this.mixTargetDelta?.(ol),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,layout:n,latestValues:r}=e,{target:i}=e;if(t&&i&&n){if(this!==e&&this.layout&&Zl(this.options.animationType,this.layout.layoutBox,n.layoutBox)){let{layoutBox:e}=this.layout,t=i;i=this.target||ss(),Xl(i.x,t.x,e.x),Xl(i.y,t.y,e.y)}ac(t,i),_c(t,r),Tc(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||(this.sharedNodes.set(e,new Jc),this.stacksChanged++),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?.transition,preserveFollowOpacity:n?.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){return this.getStack()?.lead||this}getPrevLead(){return this.getStack()?.prevLead}getStack(){let{layoutId:e}=this.options;if(!e)return;let{root:t}=this,n=t.stacksChanged+`:`+e;return this.stackFor!==n&&(this.stack=t.sharedNodes.get(e),this.stackFor=n),this.stack}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){this.getStack()?.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){return this.getStack()?.relegate(this)||!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let{latestValues:t}=e;if(!qs(t))return;let n={};[`z`,`skew`,`skewZ`,...Gs].forEach(r=>{t[r]&&(n[r]=t[r],e.setStaticValue(r,0),this.animationValues&&(this.animationValues[r]=0))}),e.render();for(let t in n)e.setStaticValue(t,n[t]),this.animationValues&&(this.animationValues[t]=n[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;let{written:n}=this,r=(t,r)=>{n[t]!==r&&(e[t]=n[t]=r)},i=this.getLead(),a=e=>{(e||this.wroteLayer)&&!t?.willChange&&!this.latestValues.willChange&&(this.wroteLayer=e,r(`willChange`,e?`transform`:``))};if(!this.isVisible&&i!==this){r(`visibility`,`hidden`),a();return}let o=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r(`visibility`,``),r(`opacity`,``),r(`pointerEvents`,Bs(t?.pointerEvents)||``),e.transform=o?o(this.latestValues,``):`none`,a();return}if(!this.projectionDelta||!this.layout||!i.target){(this.options.layoutId||this.needsShow)&&(this.needsShow=!1,r(`visibility`,``),r(`opacity`,this.latestValues.opacity===void 0?1:this.latestValues.opacity),r(`pointerEvents`,Bs(t?.pointerEvents)||``)),this.hasProjected&&!Ks(this.latestValues)&&(e.transform=o?o({},``):`none`,this.hasProjected=!1),a();return}r(`visibility`,``);let s=i.animationValues||i.latestValues,c=tl(i!==this||Ws(this.latestValues)||Js(this.latestValues)?(this.applyTransformsToTarget(),this.projectionDeltaWithTransform):this.projectionDelta,this.treeScale,s);a(c!==`none`&&this.hasLayer),o&&(c=o(s,c)),e.transform=c;let{x:l,y:u}=this.projectionDelta;r(`transformOrigin`,`${l.origin*100}% ${u.origin*100}% 0`),r(`opacity`,i.animationValues?i===this?s.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:s.opacityExit:i===this?s.opacity===void 0?``:s.opacity:s.opacityExit===void 0?0:s.opacityExit);for(let t in Fs){if(s[t]===void 0)continue;let{correct:n,applyTo:r,isCSSVariable:a}=Fs[t],o=c===`none`?s[t]:n(s[t],i);if(r){let t=r.length;for(let n=0;ne.currentAnimation?.stop()),this.root.nodes.forEach(Dl),this.root.sharedNodes.clear(),this.root.stacksChanged++}}}function xl(e,t){let{options:n}=e;!e.inTree&&(t||n.layout||n.layoutId||n.alwaysMeasureLayout||!e.parent||n.visualElement?.getProps().onBeforeLayoutMeasure)&&(e.inTree=!0,e.parent&&xl(e.parent,!0),e.instance&&(e.root.nodes.add(e),t&&e.root.isUpdating&&e.resetSkewAndRotation()))}function Sl(e){e.updateLayout(),Al(e)}function Cl(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source,o=(r,a)=>{if(i===`size`)nl(e=>{let t=Sc(r[e]);r[e].min=a[e].min,r[e].max=r[e].min+t});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;ic(r[e],a[e])}else Zl(i,t.layoutBox,n)&&nl(t=>{let n=Sc(a[t]);r[t].max=r[t].min+n,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[t].max=e.relativeTarget[t].min+n)})},s=a?t.measuredBox:t.layoutBox;o(s,n);let c=as();Tc(c,n,t.layoutBox);let l=as();Tc(l,a?e.applyTransform(r,!0):n,s);let u=!Vc(c),d=!1,f=e.getClosestProjectingParent();if((!a||f?.options.layoutRoot&&e.resumeFrom?.path.includes(f))&&f&&!f.resumeFrom){let{snapshot:r,layout:i}=f;if(r&&i){let s=e.options.layoutAnchor||void 0,c=ss();kc(c,a?e.resumeFrom.applyTransform(t.layoutBox,!0,void 0,!0,f.depth+1):t.layoutBox,r.layoutBox,s);let l=ss();kc(l,n,i.layoutBox,s),a&&o(c,l),Gc(c,l)||(d=!0),f.options.layoutRoot&&(e.relativeTarget=l,e.relativeTargetOrigin=c,e.relativeParent=f)}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:l,layoutDelta:c,hasLayoutChanged:u,hasRelativeLayoutChanged:d})}else e.isLead()&&e.options.onExitComplete?.();e.options.transition=void 0}function wl(e){Is.countProjection?.(0),e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function Tl(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function El(e){e.clearSnapshot()}function Dl(e){e.clearMeasurements()}function Ol(e){e.isLayoutDirty=!0,e.updateLayout()}function kl(e){e.isLayoutDirty=!1}function Al(e){let{snapshot:t,dragAncestor:n}=e,r=n?.isAnimationBlocked&&n.layout;if(!t||!r||e.resumeFrom||e.isAnimationBlocked)return;let i=n.dragSnapshot;nl(e=>mc(t.layoutBox[e],r.layoutBox[e].min-i.layoutBox[e].min))}function jl(e){e.shouldResetTransform=!0,_l(e),(typeof e.latestValues.x==`string`||typeof e.latestValues.y==`string`)&&(e.isLayoutDirty=!0),e.updateScroll(`snapshot`)}function Ml(e){e.isAnimationBlocked&&e.layout&&(e.path.forEach(jl),_l(e),e.dragSnapshot=e.measure())}function Nl(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.dragSnapshot||e.layout,e.isLayoutDirty=!0)}function Pl(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function Fl(e){let{visualElement:t}=e.options;t?.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Il(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Ll(e){e.resolveTargetDelta()}function Rl(e){e.calcProjection()}function zl(e){e.resetSkewAndRotation()}function Bl(e,t,n,r,i){let a=n.max-n.min,o=a?Math.max(0,(a+i-r)/a):1,s=e.originPoint=t.originPoint;e.origin=t.origin,e.scale=o,e.translate=n.min+r-(s+(n.min-s)*o)}function Vl(e,t,n){e.translate=cn(t.translate,0,n),e.scale=cn(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Hl(e,t,n,r){e.min=cn(t.min,n.min,r),e.max=cn(t.max,n.max,r)}function Ul(e,t,n,r){Hl(e.x,t.x,n.x,r),Hl(e.y,t.y,n.y,r)}var Wl=e=>Kn.has(e)||!!Fs[e]||/^(transform|origin|opacity|visibility|pointerEvents)/.test(e),Gl;function Kl(e){Gl||(Gl=new Map,st.update(ql,!1,!0));let t=Gl.get(e);return t||Gl.set(e,t={}),t}function ql(){let e=Gl;Gl=void 0,e.forEach(e=>e.animation?.start())}function Jl(e){return e.animationValues?.opacityExit!==void 0}var Yl={duration:.45,ease:[.4,0,.1,1]};function Xl(e,t,n){e.max=Sc(n)+(e.min=t.min)}function Zl(e,t,n){return e===`position`||e===`preserve-aspect`&&!Cc(Kc(t),Kc(n),.2)}function Ql(e){return e!==e.root&&e.scroll?.wasRoot}function $l(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function eu(e,t,n){let r=Ms(e,n),{scroll:i}=t;return i&&(mc(r.x,i.offset.x),mc(r.y,i.offset.y)),r}var tu=bl({attachResizeListener:(e,t)=>$l(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),nu={current:void 0},ru=bl({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!nu.current){let e=new tu({});e.mount(window),e.setOptions({layoutScroll:!0}),nu.current=e}return nu.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),iu={current:null},au={current:!1},ou=typeof window<`u`;function su(){if(au.current=!0,ou){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>iu.current=e.matches;e.addEventListener(`change`,t),t()}else iu.current=!1}}var cu=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1;function lu(e){return{point:{x:e.pageX,y:e.pageY}}}var uu=e=>t=>cu(t)&&e(t,lu(t));function du(e,t,n,r){return $l(e,t,uu(n),r)}var fu=new Set([`auto`,`scroll`]),pu=class{constructor(e,t,{transformPagePoint:n,contextWindow:r,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o,immediate:s}={}){if(this.handlers={},this.scrollPositions=new Map,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=hu(this.lastRawMoveEventInfo,this.transformPagePoint));let e=_u(this.lastMoveEventInfo,this.history),t=!!this.startEvent,{point:n,offset:r}=e;if(!t&&!(Math.sqrt(r.x**2+r.y**2)>=this.distanceThreshold))return;this.history.push({...n,timestamp:be.now()});let{onStart:i,onMove:a}=this.handlers;t||(i?.(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),a?.(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.handleScroll(window),this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=hu(t,this.transformPagePoint),this.hasPendingMove=!0,st.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.hasPendingMove&&this.updatePoint(),this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i?.(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=_u(e.type===`pointercancel`?this.lastMoveEventInfo:hu(t,this.transformPagePoint),this.history);this.startEvent&&n?.(e,a),r?.(e,a)},!cu(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=s?0:a,this.contextWindow=r||window;let c=lu(e),l=hu(c,this.transformPagePoint),{point:u}=l;this.history=[{...u,timestamp:be.now()}];let{onSessionStart:d}=t;d&&d(e,_u(l,this.history));let f={passive:!0,capture:!0};this.removeListeners=P(du(this.contextWindow,`pointermove`,this.handlePointerMove,f),du(this.contextWindow,`pointerup`,this.handlePointerUp,f),du(this.contextWindow,`pointercancel`,this.handlePointerUp,f)),o&&this.startScrollTracking(o),s&&(this.handlePointerMove(e,c),this.updatePoint())}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(fu.has(e.overflowX)||fu.has(e.overflowY))&&this.scrollPositions.set(t,mu(t)),t=t.parentElement}this.scrollPositions.set(window,mu(window)),this.removeScrollListeners=P($l(window,`scroll`,this.onElementScroll,{capture:!0}),$l(window,`scroll`,this.onWindowScroll,{}))}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=mu(e),i={x:r.x-t.x,y:r.y-t.y};(i.x!==0||i.y!==0)&&(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),st.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners?.(),this.removeScrollListeners?.(),this.scrollPositions.clear(),ct(this.updatePoint)}},mu=e=>e===window?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop};function hu(e,t){return t?{point:t(e.point)}:e}function gu(e,t){return{x:e.x-t.x,y:e.y-t.y}}function _u({point:e},t){return{point:e,delta:gu(e,yu(t)),offset:gu(e,vu(t)),velocity:bu(t,.1)}}function vu(e){return e[0]}function yu(e){return e[e.length-1]}function bu(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r,i=yu(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>L(t)));)n--;r===e[0]&&e.length>2&&i.timestamp-r.timestamp>L(t)*2&&(r=e[1]);let a=ee(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}var xu=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Su(e){return xu.has(e.tagName)||e.isContentEditable===!0}var Cu=new WeakMap,wu={x:!1,y:!1};function Tu(){return wu.x||wu.y}function Eu(e){return e===`x`||e===`y`?wu[e]?null:(wu[e]=!0,()=>{wu[e]=!1}):wu.x||wu.y?null:(wu.x=wu.y=!0,()=>{wu.x=wu.y=!1})}function Du(e,{min:t,max:n},r){return t!==void 0&&en&&(e=r?cn(n,e,r.max):Math.min(e,n)),e}function Ou(e,t){let n={};return e!==void 0&&(n.min=e),t!==void 0&&(n.max=t),n}function ku(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.minr?n=F(t.min,t.max-r,e.min):r>i&&(n=F(e.min,e.max-i,t.min)),D(0,1,n)}var Mu=.35;function Nu(e=Mu){return e===!1?e=0:e===!0&&(e=Mu),{x:Pu(e,`left`,`right`),y:Pu(e,`top`,`bottom`)}}function Pu(e,t,n){return{min:Fu(e,t),max:Fu(e,n)}}function Fu(e,t){return typeof e==`number`?e:e[t]||0}function Iu(e){let t=``;for(let n of e.path){n.scroll=void 0,n.updateScroll();let{scroll:r}=n;n!==e.root&&r&&(t+=r.offset.x+`,`+r.offset.y+`,`)}return t}var Lu=class{constructor(e,t=()=>e.getProps()){this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.elastic=ss(),this.press=e=>{let t=this.visualElement.current,{drag:n,dragListener:r=!0}=this.getProps(),i=e.target,a=i!==t&&Su(i);n&&r&&!a&&this.start(e)},this.visualElement=e,this.readProps=t}start(e,t={}){if(this.visualElement.presenceContext?.isPresent===!1)return;let n=e=>{t.snapToCursor&&this.snapToCursor(e),this.stopAnimation()},r=(e,t)=>{let{drag:n,dragConstraints:r,dragPropagation:i,onDragStart:a}=this.getProps();if(n&&!i&&(this.openDragLock?.(),this.openDragLock=Eu(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null;let{projection:o}=this.visualElement;o?.isMeasureOnly&&(Iu(o),o.updateLayout()),this.resolveConstraints(),o&&(o.isAnimationBlocked=!0,o.target=void 0),nl(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ht(t)&&(t=Co(t,this.visualElement.current)||0),Ft.test(t))t=parseFloat(t);else if(Pt.test(t)){let n=o?.layout?.layoutBox[e];n&&(t=Sc(n)*(parseFloat(t)/100))}this.originPoint[e]=t}),this.point=typeof r==`function`&&r(this),a&&st.update(()=>a(e,t),!1,!0),Fo(this.visualElement,`transform`),this.visualElement.animationState?.setActive(`whileDrag`,!0)},i=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){if(this.currentDirection=Hu(o),this.currentDirection===null)return;i&&i(this.currentDirection)}this.updateAxis(`x`,o),this.updateAxis(`y`,o),this.point&&this.point.move(),this.visualElement.render(),a&&st.update(()=>a(e,t),!1,!0)},a=(e,t)=>{this.stop(e,t),this.latestPointerEvent=this.latestPanInfo=null},o=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints||this.point)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:s}=this.getProps();this.panSession=new pu(e,{onSessionStart:n,onStart:r,onMove:i,onSessionEnd:a,resumeAnimation:o},{...t,transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:s,contextWindow:this.visualElement.current?.ownerDocument.defaultView,element:this.visualElement.current})}stop(e,t,n){let r=e||this.latestPointerEvent,i=t||this.latestPanInfo,a=this.isDragging;if(this.cancel(),!a||!i||!r)return;let{velocity:o}=i;this.startAnimation(o,n);let{onDragEnd:s}=this.getProps();s&&st.postRender(()=>s(r,i))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession(),!this.getProps().dragPropagation&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t?.setActive(`whileDrag`,!1)}endPanSession(){this.panSession?.end(),this.panSession=void 0}updateAxis(e,t){let{drag:n}=this.readProps();if(!t||!Vu(e,n,this.currentDirection))return;let r=this.getAxisMotionValue(e),i=this.originPoint[e]+t[e],a=this.constraints&&this.constraints[e];a&&(i=Du(i,a,this.elastic[e])),this.point?this.point[e]=i:r.set(i)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps();if(Ru(e))this.constraints&&this.scroll===Iu(this.visualElement.projection)||(this.constraints=this.resolveRefConstraints());else if(e&&typeof e==`object`){let{top:t,left:n,bottom:r,right:i}=e;this.constraints={x:Ou(n,i),y:Ou(t,r)}}else this.constraints=!1;this.elastic=Nu(t)}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!Ru(e))return!1;let n=zu(e),{projection:r}=this.visualElement;if(!r||!r.layout)return!1;this.scroll=Iu(r);let i=eu(n,r.root,this.visualElement.getTransformPagePoint()),a=Au(r.layout.layoutBox,r.removeElementScroll(i));if(t){let e=t(As(a));e&&(a=ks(e))}return a}startAnimation(e,t){let{drag:n,dragMomentum:r,dragElastic:i,dragTransition:a,dragSnapToOrigin:o,onDragTransitionEnd:s}=this.getProps(),c={bounceStiffness:i?200:1e6,bounceDamping:i?40:1e7,timeConstant:750,restDelta:1,restSpeed:10,...a},l=i=>r&&!(this.point&&o)&&Vu(i,t||n,this.currentDirection)?e[i]:0;if(this.point&&!o)return this.point.release({x:l(`x`),y:l(`y`)},c).then(s);let u=this.constraints||{},d=nl(e=>{if(!Vu(e,t||n,this.currentDirection))return;let r=u[e]||{};(o===!0||o===e)&&(r={min:0,max:0});let i={type:`inertia`,velocity:l(e),...c,...r};return this.startAxisValueAnimation(e,i)});return Promise.all(d).then(s)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return Fo(this.visualElement,e),n.start(bo(e,n,0,t,this.visualElement,!1))}stopAnimation(){nl(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.readProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor({clientX:e,clientY:t}){let{drag:n}=this.getProps(),r={x:e,y:t},i=this.visualElement.getTransformPagePoint()?.(r)||r,a=this.visualElement.measureViewportBox();nl(e=>{if(!Vu(e,n,this.currentDirection))return;let t=this.getAxisMotionValue(e),{min:r,max:o}=a[e];t.set((t.get()||0)+i[e]-cn(r,o,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Ru(t)||!n||!this.constraints)return;this.stopAnimation();let r=this.constraints,i={x:0,y:0};nl(e=>{let t=this.getAxisMotionValue(e).get();i[e]=ju({min:t,max:t},r[e])});let{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},``):`none`,n.root?.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),nl(t=>{let n=this.getAxisMotionValue(t);if(!Vu(t,e,null)||!n.get())return;let{min:r,max:a}=this.constraints[t];n.set(cn(r,a,i[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Cu.set(this.visualElement,this);let e=this.visualElement.current,t=du(e,`pointerdown`,this.press),n,r=()=>{let{dragConstraints:t}=this.getProps(),r=Ru(t)&&zu(t);r&&(this.constraints=this.resolveRefConstraints(),n||=Bu(e,r,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i.layout||(i.root?.updateScroll(),i.updateLayout()),st.read(r);let o=$l(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(nl(t=>{if(!Vu(t,this.getProps().drag,this.currentDirection))return;let n=this.getAxisMotionValue(t);this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate)}),this.visualElement.render())}));return()=>{o(),t(),a(),s(),n?.()}}getProps(){let e=this.readProps(),{dragElastic:t=Mu,dragMomentum:n=!0}=e;return{...e,dragElastic:t,dragMomentum:n}}};function Ru(e){return!!e&&typeof e==`object`&&(`current`in e||`nodeType`in e)}var zu=e=>`current`in e?e.current:e;function Bu(e,t,n){if(typeof ResizeObserver>`u`)return N;let r=new Set([e,t]),i=new ResizeObserver(e=>e.forEach(({target:e})=>r.delete(e)||n()));return r.forEach(e=>i.observe(e)),ts(()=>i.disconnect())}function Vu(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}var Hu=(e,t=10)=>Math.abs(e.y)>t?`y`:Math.abs(e.x)>t?`x`:null;function Uu(e,t){let n=rs(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},ts(()=>r.abort())]}function Wu(e){return!(e.pointerType===`touch`||Tu())}function Gu(e,t,n={}){t=ns(t);let[r,i,a]=Uu(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{e.pointerType!==`touch`&&(n?r=!0:s(e))};e.addEventListener(`pointerenter`,n=>{if(!Wu(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Ku=(e,t)=>t?e===t||Ku(e,t.parentElement):!1,qu=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Ju(e){return qu.has(e.tagName)||e.isContentEditable===!0}var Yu=new WeakSet;function Xu(e){return t=>{t.key===`Enter`&&e(t)}}function Zu(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Qu=(e,t)=>{let n=!1,r=Xu(()=>{n||Yu.has(e)||(n=!0,Zu(e,`down`))}),i=Xu(()=>{n&&(n=!1,Zu(e,`up`))});e.addEventListener(`keydown`,r,t),e.addEventListener(`keyup`,i,t),e.addEventListener(`blur`,()=>{e.removeEventListener(`keydown`,r),e.removeEventListener(`keyup`,i),n&&Zu(e,`cancel`)},{...t,once:!0})};function $u(e){return cu(e)&&!Tu()}var ed=new WeakSet,td=100,nd=8,rd=(e,t,n)=>Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)>n,id=e=>e.preventDefault();function ad(e,t,n={}){t=ns(t);let[r,i,a]=Uu(e,n),o=new WeakMap,s=e=>{let r=e.currentTarget;if(!$u(e)||ed.has(e))return;n.stopPropagation&&ed.add(e);let{count:a=1,countTimeout:s=.3,hold:c=0,repeat:l}=n,u=be.now(),d=L(c),f=L(s),p=o.get(r);p?.expire(rd(p.event,e,td))?p=void 0:p&&(ct(p.expire),o.delete(r));let m=p?p.count+1:1,h=m>=a,g=h&&(c||l),_=!c,v=0,y;if(Yu.add(r),p)y=p.handlers;else{let n=t(r,e);y=typeof n==`function`?{onComplete:n}:n||{}}h&&_&&y.onActive?.();let b=L(l),x=d||b,S=u+x,C=!0,w=()=>{if(i.signal.aborted)return ct(w);let e=Math.min(1-(S-be.now())/x,1);C&&e<1&&(e=0),C=!1,y.onHold?.(e),e<1||(_?y.onRepeat?.(++v):(_=!0,y.onActive?.()),l?(C=!0,S+=x=b):ct(w))},T={...i,capture:!0},E=(t,n)=>{if(cu(t)){if(window.removeEventListener(`pointerup`,D,T),window.removeEventListener(`pointercancel`,O,T),window.removeEventListener(`pointermove`,k,T),r.removeEventListener(`contextmenu`,id),ct(w),Yu.delete(r),Tu()&&(n=!1),n&&!h){let n=be.now(),a=e=>{let s=i.signal.aborted;if(s||e===!0||be.now()-n>f)return ct(a),o.delete(r),s||y.onComplete?.(t,{success:!1}),!0};o.set(r,{count:m,event:e,handlers:y,expire:a}),st.update(a,!0)}else y.onComplete?.(t,{success:n&&_})}},D=e=>{E(e,r===window||r===document||n.useGlobalTarget||Ku(r,e.target))},O=e=>{E(e,!1)},k=t=>{cu(t)&&((l||!_)&&rd(e,t,nd)||a>1&&Tu())&&O(t)};window.addEventListener(`pointerup`,D,T),window.addEventListener(`pointercancel`,O,T),(g||a>1)&&window.addEventListener(`pointermove`,k,T),g&&(st.update(w,!0),r.addEventListener(`contextmenu`,id,{...i,passive:!1}))};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,s,i),Qo(e)&&(e.addEventListener(`focus`,()=>Qu(e,i),i),!Ju(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function od(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function sd(e){return typeof e==`string`||Array.isArray(e)}var cd=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`whilePinch`,`exit`],ld=[`initial`].concat(cd);function ud(e){if(od(e.animate))return!0;for(let t=0;t{this.current&&(this.requestFlush(),this.isAllPending=!0)},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.renderNow=()=>this.render();let{latestValues:c}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=ud(t),this.isVariantNode=dd(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let l=this.scrapeMotionValuesFromProps(t,{},this);for(let e in l){let t=l[e];e!==`willChange`&&c[e]!==void 0&&No(t)&&t.set(c[e])}}mount(e){let t=this.presenceContext;if(this.hasBeenMounted&&t?.isPresent!==!1&&!t?.keepValuesOnRemount)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];if(this.current=e,Zo.set(e,this),this.projection?.instance||this.projection?.mount(e),this.isVariantNode&&!this.isControllingVariants){let e=this;do e=e.props.inherit!==!1&&e.parent;while(e&&!e.isVariantNode);if(e){let{variantChildren:t}=e;t.add(this),this.removeFromVariantTree=()=>t.delete(this)}}this.values.forEach((e,t)=>this.bindValue(t,e)),this.hasBeenMounted&&this.scheduleRender();let{reducedMotionConfig:n}=this;this.shouldReduceMotion=n!==`never`&&(n===`always`||(au.current||su(),iu.current)),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection?.unmount(),ct(this.notifyUpdate);for(let e in this.bindings){let t=this.bindings[e];t&&this.stop(t)}this.bindings={},this.shared=void 0,this.numPending=0,this.isAllPending=!1,this.removeFromVariantTree?.(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),(this.enteringChildren||=new Set).add(e)}removeChild(e){this.children.delete(e),this.enteringChildren?.delete(e)}bindValue(e,t){let n=t?.accelerate;if(n?.bind&&er.has(e)&&this.current instanceof HTMLElement){this.unbind(e),this.values.set(e,t);let r=t.get();r!==void 0&&(this.latestValues[e]=r),this.bindings[e]={stop:n.bind(this.current,e,n)}}else if(this.isSilent=!0,super.bindValue(e,t),this.isSilent=!1,t&&typeof window<`u`&&window.MotionCheckAppearSync){let n=this.bindings[e];if(n){let{stop:r}=n,i=window.MotionCheckAppearSync(this,e,t);n.stop=()=>{r?.(),i?.()}}}}hasValue(e){return this.values.has(e)}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}queueAll(e){if(!e)for(let e in this.latestValues)this.bindings[e]||this.bindValue(e);super.queueAll(e)}onChange(e){this.props.onUpdate&&st.preRender(this.notifyUpdate),this.projection&&Kn.has(e)&&(this.projection.isTransformDirty=!0)}sortNodePosition(e){return!this.current||!e.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in md){let t=md[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):ss()}update(e,t){let{transformTemplate:n,onUpdate:r}=this.props;(e.transformTemplate||n)&&this.current&&(this.requestFlush(),this.queueAll()),(e.transformTemplate&&!n||e.onUpdate&&!r)&&dr.get(this.current)?.demote(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t{this.current&&(this.current.textContent=`${e}`)}))}},yd=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function bd(e,{layout:t,layoutId:n}){return Kn.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!Fs[e]||e===`opacity`)}function xd(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(No(r[t])||i&&No(i[t])||bd(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function Sd(e){return window.getComputedStyle(e)}var Cd=class extends vd{constructor(e,t){super(e,t),this.type=`html`,this.bind=vs}mount(e){super.mount(e)}readValueFromInstance(e,t){if(Kn.has(t))return this.projection?.isProjecting?aa(t):da(e,t);{let n=Sd(e),r=(pt(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Ms(e,t)}scrapeMotionValuesFromProps(e,t,n){return xd(e,t,n)}};function wd(e,t,n){let r=xd(e,t,n);for(let n in e)if(n!==`children`&&(No(e[n])||No(t[n]))){let t=Gn.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var Td=class extends vd{constructor(e,t){super(e,t),this.type=`svg`,this.measureInstanceViewportBox=ss,this.bind=Es}getBaseTargetFromProps(e,t){return Kn.has(t)?super.getBaseTargetFromProps(e,t)??aa(t):e[t]}getDefaultValue(e){return Kn.has(e)?this.latestValues[e]??aa(e):void 0}readValueFromInstance(e,t){return Ds(e,t)}scrapeMotionValuesFromProps(e,t,n){return wd(e,t,n)}};function Ed(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;re?.out===!0?e:e?.out;function Ad(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>Ho(e,t,n))),n=Md(),r=!0,i=!1;function a(a){let{props:o,parent:s,manuallyAnimateOnMount:c}=e,{initial:l}=o,u=r||i,d=[],f=(t=l)=>typeof t!=`boolean`&&Do(e,Array.isArray(t)?t[0]:t,e.presenceContext?.custom)||void 0,p,m={},h=1/0,g=e;do g=g.props.inherit!==!1&&g.parent;while(g&&!g.isControllingVariants);let _=u&&kd(f(l??(g&&g.props.initial))?.transition);if(Dd.forEach((t,r)=>{let i=n[t],l=o[t],f=g&&g.props[t],v=l===void 0?sd(f)||f===!1?f:void 0:l,y=sd(v),b=t===a?i.isActive:null,x=y&&l===void 0&&!(u&&c);if(i.protectedKeys=m,!i.isActive&&b===null||!v&&!i.prevProp||od(v)||typeof v==`boolean`)return;if(b===!1&&(h=r),t===`exit`&&i.isActive&&b!==!0){m={...m,...i.prevResolvedValues};return}let S=jd(i.prevProp,v),C=S||y&&(b&&!x||r>h),w=!1,T=Array.isArray(v)?v:[v],E={},D;if(b!==!1)for(let n of T){let{transition:r,transitionEnd:i,...a}=Do(e,n,Oo(e,t))||{};Object.assign(E,a,i),D=kd(r)||D}let{prevResolvedValues:O}=i;i.protectedKeys={...m};for(let t in{...O,...E}){if(t in m)continue;let n=E[t],r=O[t],a=Array.isArray(n)&&Array.isArray(r)?!Ed(n,r)||S:n!==r,o;if(a&&n==null)p||=new Map,p.has(t)||p.set(t,i.prevOut);else if(a||n!==void 0&&p?.has(t)){C=!0,o=p?.get(t)||_,p?.delete(t)&&(w=!0),i.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)}else i.protectedKeys[t]=!0;i.out[t]=o}if(i.prevProp=v,i.prevResolvedValues=E,i.prevOut=D,i.isActive&&(m={...m,...E}),C&&(!(x&&S)||w))for(let n of T){let r={type:t};if(typeof n==`string`&&u&&c&&s?.enteringChildren){let t=Do(s,n)?.transition?.delayChildren;r.delay=Ua(s.enteringChildren,e,t)}d.push({animation:n,options:r})}}),p?.size){let t={},n=f(),r=n?.transition;p.forEach((i,a)=>{i&&(r={...r||e.getDefaultTransition(),[a]:i});let s=e.getValue(a);s&&(s.liveStyle=!0);let c=n&&!Array.isArray(l)?n[a]:void 0,u=e.getBaseTargetFromProps(o,a);t[a]=(c===void 0?u!==void 0&&!No(u)?u:e.initialValues[a]===void 0?e.baseTarget[a]:void 0:c)??null}),r&&(t.transition=r),d.push({animation:t})}let v=u&&e.blockInitialAnimation||r&&!c&&(o.initial===!1||o.initial===o.animate);return r=i=!1,!v&&d.length?t(d):Promise.resolve()}function o(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=a(t);for(let e in n)n[e].protectedKeys=Od;return i}return{animateChanges:a,setActive:o,setAnimateFunction:n=>{t=n(e)},getState:()=>n,reset:()=>{n=Md(),i=!0}}}function jd(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!Ed(t,e):!1}function Md(){let e={};for(let t of cd)e[t]={isActive:t===`animate`,protectedKeys:Od,needsAnimating:{},prevResolvedValues:Od,out:{}};return e}var Nd={setProperty(e,t){this[e]=t}};function Pd(e,t,n,r){let i={},a={style:Object.create(Nd),attrs:i,tagName:r,ownerSVGElement:r&&null,setAttribute:(e,t)=>i[e.replace(/^stroke-d/,`strokeD`)]=t,removeAttribute:e=>delete i[e]},o={latestValues:t,getProps:()=>n};for(let n in t){let t=e(a,o,n);t.shared||t()}n.transformTemplate&&hs(a,o);for(let e in o.shared)o.shared[e]();return a}var Fd=(e,t,n)=>(e.tagName===`svg`?n!==`viewBox`:xs.includes(n))?gs(e,t,n):Ts(e,t,n),Id=!1;function Ld(e){return!!this[e]}function Rd(){if(Id)return;let e={animation:[`variants`,...cd],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},t={};for(let n in e){let r=e[n];t[n]={isEnabled:e=>r.some(Ld,e)}}hd(t),Id=!0}function zd(){return Rd(),gd()}function Bd(e){let t=zd();for(let n in e)t[n]={...t[n],...e[n]};hd(t)}var Vd=0,Hd=class extends yd{constructor(){super(...arguments),this.id=Vd++}update(){let{presenceContext:e,animationState:t}=this.node;if(!e||!t)return;this.stop||=e.register?.(this.id,this.node);let{isPresent:n,onExitComplete:r}=e;if(n===!this.exit)return;if(n){if(this.exit===!0){let{initial:e}=this.node.getProps();if(e&&!Array.isArray(e)){let{transition:t,transitionEnd:n,...r}=Do(this.node,e)||{};for(let e in r)this.node.getValue(e)?.jump(r[e])}this.node.blockInitialAnimation=!1,t.reset(),t.animateChanges()}else t.setActive(`exit`,!1);this.exit=void 0;return}let i=this.exit=t.setActive(`exit`,!0);r&&i.then(()=>{this.exit===i&&(this.exit=!0,r(this.id))})}mount(){this.update()}unmount(){this.stop?.(),this.stop=void 0}},Ud=!1,Wd=()=>{Ud||(Ud=!0,Bd({exit:{Feature:Hd}}))},Gd=(0,_.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Kd(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function qd(...e){return t=>{let n=!1,r=e.map(e=>{let r=Kd(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t{let{width:t,height:n}=e?.getBoundingClientRect()||{};return[t/e?.offsetWidth||1,n/e?.offsetHeight||1]},Xd=e=>{let{left:t,top:n}=e.getBoundingClientRect(),r=e;for(;r=r.parentElement||r.parentNode?.host;){let{scrollLeft:e,scrollTop:i}=r;if(e||i){let[a,o]=Yd(r);t+=e*a,n+=i*o}if(getComputedStyle(r).position===`fixed`)break}let[i,a]=Yd(e.offsetParent);return[t/i,n/a]},Zd=class extends _.Component{getSnapshotBeforeUpdate(e){let t=this.props.getElement();if(Qo(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=Qo(e)&&e.offsetWidth||0,r=Qo(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction,a.point=Xd(t)}return null}componentDidUpdate(){}render(){return this.props.children}};function Qd({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a,popNode:o}){let s=(0,_.useId)(),c=(0,_.useRef)(null),l=(0,_.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:u}=(0,_.useContext)(Gd),d=Jd(c,a===!1?void 0:e.props?.ref??e?.ref),f=()=>c.current||o?.current?.current,p=e=>{let{width:t,height:i,top:a,left:o,right:c,bottom:u,direction:d}=l.current,f=d===`rtl`,p=n===`left`?f?`right:${c}`:`left:${o}`:f?`left:${o}`:`right:${c}`,m=r===`bottom`?`bottom:${u}`:`top:${a}`;e?.insertRule(`[data-motion-pop-id="${s}"]{position:absolute!important;width:${t}px!important;height:${i}px!important;${p}px!important;${m}px!important}`)};return(0,_.useInsertionEffect)(()=>{let{width:e,height:n}=l.current,r=f();if(t||!r)return;let o=r.hasAttribute(`inert`),c=()=>{o||r.removeAttribute(`inert`)};if(r.setAttribute(`inert`,``),a===!1||!e||!n)return c;r.dataset.motionPopId=s;let d=r.ownerDocument,m=d.createElement(`style`);u&&(m.nonce=u);let h=i??d.head;h.appendChild(m),p(m.sheet);let g=0,_=0;return Ns.setup(()=>{let[e,t]=Xd(r);g=l.current.point[0]-e,_=l.current.point[1]-t}),Ns.read(()=>{let{sheet:e}=m;if(!e||!g&&!_)return;let t=l.current;t.left+=g,t.right-=g,t.top+=_,t.bottom-=_,e.deleteRule(0),p(e)}),()=>{c(),r.removeAttribute(`data-motion-pop-id`),h.contains(m)&&h.removeChild(m)}},[t]),(0,H.jsx)(Zd,{isPresent:t,getElement:f,sizeRef:l,pop:a,children:a===!1?e:_.cloneElement(e,{ref:d})})}var $d=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{Wd();let u=S(ef),d=(0,_.useId)(),f=(0,_.useRef)(),p=(0,_.useRef)(n),m=(0,_.useRef)(r);C(()=>{p.current=n,m.current=r});let h=!0,g=(0,_.useMemo)(()=>(h=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:(e,t)=>(u.set(e,!1),t&&t.parent?.presenceContext?.id!==d&&(f.current=t),()=>{u.delete(e),!p.current&&!u.size&&m.current?.()})}),[n,u,r]);return a&&h&&(g={...g}),(0,_.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),_.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,H.jsx)(Qd,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,popNode:f,children:e}),(0,H.jsx)(w.Provider,{value:g,children:e})};function ef(){return new Map}function tf(e=!0){let t=(0,_.useContext)(w);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,_.useId)();(0,_.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,_.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var nf=e=>e.key||``;function rf(e){let t=[];return _.Children.forEach(e,e=>{(0,_.isValidElement)(e)&&t.push(e)}),t}var af=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=tf(o),f=(0,_.useMemo)(()=>rf(e),[e]),p=o&&!u?[]:f.map(nf),m=(0,_.useRef)(!0),h=S(()=>new Map),g=(0,_.useRef)(new Set),[v,y]=(0,_.useState)(f),[b,w]=(0,_.useState)(f);C(()=>{o&&!u&&!b.length&&d?.()},[u,o,b.length,d]);let T=(0,_.useRef)();(0,_.useEffect)(()=>()=>{let e=T.current;T.current=void 0,e?.()},[b]),C(()=>{m.current=!1;for(let e=0;eh.get(nf(e)))?e=f:a===`wait`&&(e=E),w(rf(e)),y(f),null}let{forceRender:D}=(0,_.useContext)(x);return(0,H.jsx)(H.Fragment,{children:b.map(e=>{let _=nf(e),v=o&&!u?!1:f===b||p.includes(_);return(0,H.jsx)($d,{isPresent:v,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:v?void 0:()=>{if(g.current.has(_))return;if(h.has(_))g.current.add(_),h.set(_,!0);else return;let e=!0;h.forEach(t=>{t||(e=!1)}),e&&(D?.(),y([]),o&&d?.(),T.current=r)},anchorX:s,anchorY:c,children:e},_)})})},of=(0,_.createContext)({strict:!1}),sf=(0,_.createContext)({});function cf(e,t){if(ud(e)){let{initial:t,animate:n}=e;return{initial:t===!1||sd(t)?t:void 0,animate:sd(n)?n:void 0}}return e.inherit===!1?{}:t}function lf(e){let{initial:t,animate:n}=cf(e,(0,_.useContext)(sf));return(0,_.useMemo)(()=>({initial:t,animate:n}),[uf(t),uf(n)])}function uf(e){return Array.isArray(e)?e.join(` `):e}function df(e,t,n){for(let r in t)!No(t[r])&&!bd(r,n)&&(e[r]=t[r])}function ff(e,t){return(0,_.useMemo)(()=>({...Pd(gs,t,e).style}),[t])}function pf(e,t){let n=e.style||{},r={};return df(r,n,e),Object.assign(r,ff(e,t)),r}function mf(e,t){let n={},r=pf(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}function hf(e,t,n,r){let i=(0,_.useMemo)(()=>{let{attrs:n,style:i}=Pd(Fd,t,e,r);return{...n,style:{...i}}},[t]);if(e.style){let t={};return df(t,e.style,e),{...i,style:{...t,...i.style}}}return i}var gf=new Set(`animate.exit.variants.initial.style.values.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.tap.propagate.ignoreStrict.viewport.pinch`.split(`.`));function _f(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||gf.has(e)}function vf(e,t){return e.startsWith(`on`)?!_f(e):t?.(e)??!_f(e)}function yf(e,t,n,r){let i={};for(let a in e)a===`values`&&typeof e.values==`object`||No(e[a])||(a===`fx`?e.fx&&(i.fx=``):(vf(a,r)||n===!0&&_f(a)||!t&&!_f(a)||e.draggable&&a.startsWith(`onDrag`))&&(i[a]=e[a]));return i}var bf=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function xf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(bf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Sf(e,t,n,{latestValues:r},i,a=!1,o,s){let c=(o??xf(e)?hf:mf)(t,r,i,e),l=yf(t,typeof e==`string`,a,s),{children:u}=t,d=(0,_.useMemo)(()=>No(u)?u.get():u,[u]);return(0,_.createElement)(e,e===_.Fragment?{children:d}:{...l,...c,ref:n,children:d})}function Cf({scrapeMotionValuesFromProps:e},t,n,r){return{latestValues:wf(t,n,r,e)}}function wf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Bs(a[e]);let{initial:o,animate:s}=e,c=ud(e),l=dd(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!od(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n(t,n)=>{let r=(0,_.useContext)(sf),i=(0,_.useContext)(w),a=()=>Cf(e,t,r,i);return n?a():S(a)},Ef=Tf({scrapeMotionValuesFromProps:xd}),Df=Tf({scrapeMotionValuesFromProps:wd});function Of(e,t,n=(e,t)=>e===t){if(e===t)return!0;let r=e?.constructor;if(!t||r!==t.constructor||r!==Object&&r!==Array)return!1;let i=0;for(let r in t)if(i++,!n(e[r],t[r]))return!1;for(let t in e)i--;return!i}var kf=Symbol.for(`motionComponentSymbol`);function Af(e,t,n){let r=(0,_.useRef)(n);(0,_.useInsertionEffect)(()=>{r.current=n});let i=(0,_.useRef)(null);return(0,_.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`){if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n)}else a&&(a.current=n)},[t])}var jf=(0,_.createContext)({});function Mf(e,t,n,r,i,a){let{visualElement:o,project:s}=(0,_.useContext)(sf),c=(0,_.useContext)(of),l=(0,_.useContext)(w),u=(0,_.useContext)(Gd),d=u.reducedMotion,f=u.skipAnimations,p=(0,_.useRef)(null),m=(0,_.useRef)(!1);r||=c.renderer,!p.current&&r&&(p.current=r(e,{visualState:t,parent:o,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:d,skipAnimations:f,isSVG:a}),m.current&&p.current&&(p.current.manuallyAnimateOnMount=!0));let h=p.current,g=(0,_.useContext)(jf);h&&i&&(h.type===`html`||h.type===`svg`)&&(s?.(),i.create(h,n,g)),(0,_.useInsertionEffect)(()=>{h&&h.props!==n&&h.update(n,l)});let v=n[Io],y=(0,_.useRef)(!!v&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return C(()=>{m.current&&h&&(h.animationState?.animateChanges(),h.enteringChildren=void 0)},[]),C(()=>{m.current=!0,h&&(window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),y.current&&h.animationState?.animateChanges())}),(0,_.useEffect)(()=>{h&&(y.current||h.animationState?.animateChanges(),y.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(v)}),!1),h.enteringChildren=void 0)}),h}function Nf(e,{forwardMotionProps:t=!1,type:n}={},r,i,a){r&&Bd(r);let o=n?n===`svg`:xf(e),s=o?Df:Ef;function c(n,r){let c,l=If(n);S(()=>!!nu.current?.sharedNodes.get(l)?.lead&&n.initial)&&(n={...n,initial:!1});let u={...(0,_.useContext)(Gd),...n,layoutId:l},{isStatic:d,isValidProp:f}=u,p=lf(n),m=s(n,d);if(d&&Pf(n),!d&&typeof window<`u`){let t=a?.(u,p),n=(0,_.useRef)(void 0),r=Lf(u);p.visualElement=Mf(e,m,u,i,r.ProjectionNode,o),(r.isEnabled||p.visualElement?.projection?.options.layoutId)&&(c=n.current||=t||r.MeasureLayout)}return(0,H.jsxs)(sf.Provider,{value:p,children:[c&&p.visualElement?(0,H.jsx)(c,{visualElement:p.visualElement,...u}):null,Sf(e,n,Af(m,p.visualElement,r),m,d,t,o,f)]})}c.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let l=(0,_.forwardRef)(c),u=typeof e==`string`?(0,_.memo)(l,Ff):l;return u[kf]=e,u}function Pf(e){let[,t]=(0,_.useReducer)(e=>e+1,0);(0,_.useEffect)(()=>{let n=[],r=()=>queueMicrotask(t),i=(e={})=>{for(let t in e){let i=e[t];No(i)&&n.push(i.on(`change`,r))}};return i(e),i(e.style),()=>n.forEach(e=>e())})}var Ff=(e,t)=>!t.layout&&t.layoutId===void 0&&!t.drag&&Of(e,t,Of);function If({layoutId:e}){let t=(0,_.useContext)(x).id;return t&&e!==void 0?t+`-`+e:e}function Lf(e){let{drag:t,layout:n}=zd();return{...t,...n,isEnabled:t?.isEnabled(e)||n?.isEnabled(e)}}function Rf(e,t,n){if(typeof Proxy>`u`)return Nf;let r=new Map,i=(r,i)=>Nf(r,i,e,t,n);return new Proxy(i,{get:(e,t)=>t===`create`?i:(r.has(t)||r.set(t,i(t)),r.get(t))})}var zf=(e,t)=>t.isSVG??xf(e)?new Td(t):new Cd(t,{allowProjection:e!==_.Fragment}),Bf={animation:{Feature:class extends yd{constructor(e){super(e),e.animationState||=Ad(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();od(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){this.node.getProps().animate!==this.node.prevProps?.animate&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}},exit:{Feature:Hd}},Vf=class extends yd{constructor(e){super(e),this.removeGroupControls=N,this.removeListeners=N,this.controls=new Lu(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||N;let{current:t}=this.node}update(){let{dragControls:e,drag:t}=this.node.getProps(),{dragControls:n,drag:r}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls))),r&&!t&&this.controls.stop(void 0,void 0,r)}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},Hf=e=>(t,n)=>{e&&st.update(()=>e(t,n),!1,!0)},Uf={pan:{Feature:class extends yd{onPointerDown(e){this.session=new pu(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:this.node.current?.ownerDocument.defaultView})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Hf(e),onStart:Hf(t),onMove:Hf(n),onEnd:(e,t)=>{delete this.session,r&&st.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=du(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session?.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session?.end()}}},drag:{Feature:Vf}};function Wf(e,t,n,r,i){let{props:a}=e,o=`while`+n;!i&&e.animationState&&a[o]&&e.animationState.setActive(o,r===`Start`);let s=a[`on`+n+r];s&&st.postRender(()=>s(t,lu(t)))}var Gf=class extends yd{mount(){let{current:e}=this.node;e&&(this.unmount=Gu(e,(e,t)=>(Wf(this.node,t,`Hover`,`Start`),e=>Wf(this.node,e,`Hover`,`End`))))}unmount(){}},Kf=class extends yd{onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}e&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=P($l(this.node.current,`focus`,()=>this.onFocus()),$l(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function qf(e,t,n,r){e.current instanceof HTMLButtonElement&&e.current.disabled||Wf(e,t,`Tap`,n,r)}var Jf=class extends yd{constructor(){super(...arguments),this.options={}}mount(){let{current:e}=this.node;e&&(this.update(),this.unmount=ad(e,(e,t)=>(qf(this.node,t,`Start`),{onComplete:(e,{success:t})=>qf(this.node,e,t?``:`Cancel`),onRepeat:()=>qf(this.node,t,``,!0)}),this.options))}update(){let{options:e,node:t}=this,{globalTapTarget:n,propagate:r,tap:i}=t.props;for(let t in e)delete e[t];Object.assign(e,i,{useGlobalTarget:n,stopPropagation:r?.tap===!1})}unmount(){}},Yf=new WeakMap;function Xf({root:e,...t}){let n=e||document,r=Yf.get(n);r||Yf.set(n,r={});let i=JSON.stringify(t);if(!r[i]){let n=new WeakMap;r[i]={handlers:n,observer:new IntersectionObserver(e=>{for(let t=0;te(r))}},{root:e,...t})}}return r[i]}function Zf({observer:e,handlers:t},n,r){let i=t.get(n);i?(e.unobserve(n),typeof i==`function`?t.set(n,new Set([i,r])):i.add(r)):t.set(n,r),e.observe(n)}function Qf({observer:e,handlers:t},n,r){let i=t.get(n);if(i){if(typeof i==`function`){if(i!==r)return}else if(!i.delete(r)||i.size)return;t.delete(n),e.unobserve(n)}}function $f(e,t,n){let r=Xf(t);return Zf(r,e,n),()=>Qf(r,e,n)}var ep={some:0,all:1},tp=class extends yd{startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e;if(i&&this.hasEnteredView)return;let a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:ep[r]},o=e=>{let{isIntersecting:t}=e;if(!this.isInView==!t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0,i&&this.stopObserver?.()),this.node.animationState?.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps();(t?n:r)?.(e)};this.stopObserver=$f(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(np(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function np({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var rp={inView:{Feature:tp},tap:{Feature:Jf},focus:{Feature:Kf},hover:{Feature:Gf}},ip=!1,ap=({layout:e,layoutDependency:t,layoutAnchor:n})=>({layout:e,layoutDependency:t,layoutAnchor:n,animationType:typeof e==`string`?e:`both`}),op=(e,t)=>{let{snapshot:n}=e,r=e.getStack();r?.remove(e);let i=r?.lead;if(r?.prevLead===e&&i.resumeFrom===e&&(i.resumeFrom=i.currentAnimation=e.resumingFrom=void 0),e.options.layoutId=t,!t)e.needsShow=!0;else return e.root.registerSharedNode(t,e),()=>{let{resumeFrom:t}=e;t?.isPresent!==!1&&e.getStack().members.includes(t)&&(t.hide(),e.resumeFrom=void 0,e.snapshot=n)}},sp=({projection:e})=>e?.isMeasureOnly?void 0:e,cp=class extends _.Component{componentDidMount(){this.attach()}attach(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,i=sp(e);al.hasEverUpdated=!0,i&&i!==this.node&&(this.node=i,t.group?.add(i),r&&n?.register?.(i),ip&&i.root.didUpdate(),i.options.layoutId!==r&&op(i,r)?.(),i.addEventListener(`animationComplete`,()=>this.safeToRemove()),i.setOptions({...ap(this.props),onExitComplete:()=>this.safeToRemove()}))}getSnapshotBeforeUpdate(e){let{layoutDependency:t,layoutId:n,drag:r,isPresent:i}=this.props;this.attach();let a=this.node;return a&&(a.isPresent=i,this.takeOver=e.layoutId===n?void 0:(a.willUpdate(),op(a,n)),a.setOptions(ap(this.props)),ip=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||st.postRender(()=>{a.getStack()?.members.length||this.safeToRemove()}))),null}componentDidUpdate(){let e=this.node;e&&(this.takeOver?.(),e.root.didUpdate(),Ns.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{layoutGroup:e,switchLayoutGroup:t}=this.props,n=this.node;ip=!0,n&&(n.scheduleCheckAfterUnmount(),e.group?.remove(n),t?.deregister?.(n),this.node=void 0)}safeToRemove(){this.props.safeToRemove?.()}render(){return null}};function lp(e){let[t,n]=tf(),r=(0,_.useContext)(x);return(0,H.jsx)(cp,{...e,layoutGroup:r,switchLayoutGroup:(0,_.useContext)(jf),isPresent:t,safeToRemove:n})}var up=Rf(Object.assign({},Bf,rp,Uf,{layout:{ProjectionNode:ru,MeasureLayout:lp,Lifecycle:cp}}),zf),dp=e=>(e.match(/\d+[xX]\d+|[A-Z]?[a-z]+|[A-Z]|\d+/g)??[]).join(`-`).toLowerCase();function fp(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:dp(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var pp=e=>{let t=``,n=!1;for(let r of e)r===`-`||r===`_`||r<=` `?n=t.length>0:(t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1);return t},mp=e=>{let t=pp(e);return t.charAt(0).toUpperCase()+t.slice(1)},hp=(...e)=>{let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of n.split(/\s+/))e&&t.add(e);return[...t].join(` `)},gp={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function _p(e){return e!=null}function vp(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??gp.width,a=e.size??e.height??gp.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?hp(...c):hp(`lucide`,...s,...c),u=t.strokeWidth??gp[`stroke-width`];if(t.absoluteStrokeWidth){let n=Number(u)*Number(e.size??e.width??gp.width)/Number(t.size??t.width??gp.width);Number.isFinite(n)&&(u=n)}return[`svg`,{...Object.entries(gp).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&_p(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&_p(t.width)&&{[r(`width`)]:t.width},...`height`in t&&_p(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function yp(e,t={}){return vp(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var bp=e=>{if(typeof e!=`object`||!e)return!1;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&(t.startsWith(`aria-`)||t===`role`||t===`title`)&&e[t]!=null)return!0;return!1},xp=(0,_.createContext)({}),Sp=()=>(0,_.useContext)(xp),Cp=(0,_.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:g=!1,color:v=`currentColor`,className:y=``}=Sp()??{},b=bp(d),[x,S,C=[]]=yp(u,{color:e??v,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??g,className:hp(y,s),hasA11yProp:b,attributes:d});return(0,_.createElement)(x,{ref:f,...S},[...C.map(([e,t])=>(0,_.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function wp(e,t=[],n=[]){let r=typeof e==`string`?fp(e,t,n):e,i=(0,_.forwardRef)(({className:e,...t},n)=>(0,_.createElement)(Cp,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=mp(r.name)),i}var Tp={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};Tp.node;var Ep=wp(Tp),Dp={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};Dp.node;var Op=wp(Dp),kp={name:`link-horizontal`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]],aliases:[`link-2`]};kp.node;var Ap=wp(kp),jp={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};jp.node;var Mp=wp(jp),Np={name:`radar`,size:24,node:[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62a10 10 0 1 0 19.02-1.27`,key:`uxxui8`}],[`path`,{d:`M16.24 7.76a6 6 0 1 0-8.01 8.91`,key:`3f92ms`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66a6 6 0 0 1-2.22 5.01`,key:`1a22kg`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]};Np.node;var Pp=wp(Np),Fp={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};Fp.node;var Ip=wp(Fp),Lp={name:`target`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};Lp.node;var Rp=wp(Lp),zp={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};zp.node;var Bp=wp(zp),Vp=Object.create,Hp=Object.defineProperty,Up=Object.getOwnPropertyDescriptor,Wp=Object.getOwnPropertyNames,Gp=Object.getPrototypeOf,Kp=Object.prototype.hasOwnProperty,qp=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),Jp=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of Wp(t))!Kp.call(e,i)&&i!==n&&(r=Up(t,i),Hp(e,i,{get:r&&r.get&&!r.configurable?r.get:()=>t[i],enumerable:!r||r.enumerable}));return e},Yp=(e,t,n)=>(n=e==null?{}:Vp(Gp(e)),Jp(t||!e||!e.__esModule||!Kp.call(e,`default`)?Hp(n,`default`,{value:e,enumerable:!0}):n,e)),Xp=`6.21.0`;function U(e,t){this.x=e,this.y=t}U.prototype={clone(){return new U(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){let t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){let t=e[0]*this.x+e[1]*this.y,n=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=n,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){let e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){let t=Math.cos(e),n=Math.sin(e),r=t*this.x-n*this.y,i=n*this.x+t*this.y;return this.x=r,this.y=i,this},_rotateAround(e,t){let n=Math.cos(e),r=Math.sin(e),i=t.x+n*(this.x-t.x)-r*(this.y-t.y),a=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=i,this.y=a,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:U},U.convert=function(e){if(e instanceof U)return e;if(Array.isArray(e))return new U(+e[0],+e[1]);if(e.x!==void 0&&e.y!==void 0)return new U(+e.x,+e.y);throw Error(`Expected [x, y] or {x, y} point format`)};function Zp(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let n=e;for(let r=0;r<8;r++){let r=((o*n+a)*n+i)*n-e;if(Math.abs(r)s?r=n:u=n,n=(r+u)*.5}return((l*n+c)*n+s)*n}}var Qp;function $p(){return Qp??=typeof OffscreenCanvas<`u`&&!!new OffscreenCanvas(1,1).getContext(`2d`)&&typeof createImageBitmap==`function`,Qp}var em;function tm(){if(em==null&&(em=!1,$p())){let e=new OffscreenCanvas(5,5).getContext(`2d`,{willReadFrequently:!0});if(e){for(let t=0;t<25;t++){let n=t*4;e.fillStyle=`rgb(${n},${n+1},${n+2})`,e.fillRect(t%5,Math.floor(t/5),1,1)}let t=e.getImageData(0,0,5,5).data;for(let e=0;e<100;e++)if(e%4!=3&&t[e]!==e){em=!0;break}}}return em||!1}var nm=typeof Float32Array<`u`?Float32Array:Array;function rm(){var e=new nm(4);return nm!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function im(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=n*a-i*r;return o?(o=1/o,e[0]=a*o,e[1]=-r*o,e[2]=-i*o,e[3]=n*o,e):null}function am(e){return e[0]*e[3]-e[2]*e[1]}function om(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=r*c+a*s,e[1]=i*c+o*s,e[2]=r*-s+a*c,e[3]=i*-s+o*c,e}function sm(){var e=new nm(9);return nm!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function cm(e){var t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*(l*a-o*c)+n*(-l*i+o*s)+r*(c*i-a*s)}function lm(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=-n,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function um(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=n+n,s=r+r,c=i+i,l=n*o,u=r*o,d=r*s,f=i*o,p=i*s,m=i*c,h=a*o,g=a*s,_=a*c;return e[0]=1-d-m,e[3]=u-_,e[6]=f+g,e[1]=u+_,e[4]=1-l-m,e[7]=p-h,e[2]=f-g,e[5]=p+h,e[8]=1-l-d,e}function dm(){var e=new nm(16);return nm!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function fm(e){var t=new nm(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function pm(e,t){return 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],e}function mm(e){return 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}function hm(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=n*s-r*o,y=n*c-i*o,b=n*l-a*o,x=r*c-i*s,S=r*l-a*s,C=i*l-a*c,w=u*h-d*m,T=u*g-f*m,E=u*_-p*m,D=d*g-f*h,O=d*_-p*h,k=f*_-p*g,A=v*k-y*O+b*D+x*E-S*T+C*w;return A?(A=1/A,e[0]=(s*k-c*O+l*D)*A,e[1]=(i*O-r*k-a*D)*A,e[2]=(h*C-g*S+_*x)*A,e[3]=(f*S-d*C-p*x)*A,e[4]=(c*E-o*k-l*T)*A,e[5]=(n*k-i*E+a*T)*A,e[6]=(g*b-m*C-_*y)*A,e[7]=(u*C-f*b+p*y)*A,e[8]=(o*O-s*E+l*w)*A,e[9]=(r*E-n*O-a*w)*A,e[10]=(m*S-h*b+_*v)*A,e[11]=(d*b-u*S-p*v)*A,e[12]=(s*T-o*D-c*w)*A,e[13]=(n*D-r*T+i*w)*A,e[14]=(h*y-m*x-g*v)*A,e[15]=(u*x-d*y+f*v)*A,e):null}function gm(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15],y=n[0],b=n[1],x=n[2],S=n[3];return e[0]=y*r+b*s+x*d+S*h,e[1]=y*i+b*c+x*f+S*g,e[2]=y*a+b*l+x*p+S*_,e[3]=y*o+b*u+x*m+S*v,y=n[4],b=n[5],x=n[6],S=n[7],e[4]=y*r+b*s+x*d+S*h,e[5]=y*i+b*c+x*f+S*g,e[6]=y*a+b*l+x*p+S*_,e[7]=y*o+b*u+x*m+S*v,y=n[8],b=n[9],x=n[10],S=n[11],e[8]=y*r+b*s+x*d+S*h,e[9]=y*i+b*c+x*f+S*g,e[10]=y*a+b*l+x*p+S*_,e[11]=y*o+b*u+x*m+S*v,y=n[12],b=n[13],x=n[14],S=n[15],e[12]=y*r+b*s+x*d+S*h,e[13]=y*i+b*c+x*f+S*g,e[14]=y*a+b*l+x*p+S*_,e[15]=y*o+b*u+x*m+S*v,e}function _m(e,t,n){var r=n[0],i=n[1],a=n[2],o,s,c,l,u,d,f,p,m,h,g,_;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*a+t[12],e[13]=t[1]*r+t[5]*i+t[9]*a+t[13],e[14]=t[2]*r+t[6]*i+t[10]*a+t[14],e[15]=t[3]*r+t[7]*i+t[11]*a+t[15]):(o=t[0],s=t[1],c=t[2],l=t[3],u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],e[0]=o,e[1]=s,e[2]=c,e[3]=l,e[4]=u,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h,e[10]=g,e[11]=_,e[12]=o*r+u*i+m*a+t[12],e[13]=s*r+d*i+h*a+t[13],e[14]=c*r+f*i+g*a+t[14],e[15]=l*r+p*i+_*a+t[15]),e}function vm(e,t,n){var r=n[0],i=n[1],a=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]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ym(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=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]=a*i+l*r,e[5]=o*i+u*r,e[6]=s*i+d*r,e[7]=c*i+f*r,e[8]=l*i-a*r,e[9]=u*i-o*r,e[10]=d*i-s*r,e[11]=f*i-c*r,e}function bm(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[8],u=t[9],d=t[10],f=t[11];return 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]=a*i-l*r,e[1]=o*i-u*r,e[2]=s*i-d*r,e[3]=c*i-f*r,e[8]=a*r+l*i,e[9]=o*r+u*i,e[10]=s*r+d*i,e[11]=c*r+f*i,e}function xm(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],c=t[3],l=t[4],u=t[5],d=t[6],f=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]=a*i+l*r,e[1]=o*i+u*r,e[2]=s*i+d*r,e[3]=c*i+f*r,e[4]=l*i-a*r,e[5]=u*i-o*r,e[6]=d*i-s*r,e[7]=f*i-c*r,e}function Sm(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Cm(e,t,n,r,i){var a=1/Math.tan(t/2);if(e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){var o=1/(r-i);e[10]=(i+r)*o,e[14]=2*i*r*o}else e[10]=-1,e[14]=-2*r;return e}var wm=Cm;function Tm(e,t,n,r,i,a,o){var s=1/(t-n),c=1/(r-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*c,e[14]=(o+a)*l,e[15]=1,e}var Em=Tm;function Dm(e,t){return 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]}function Om(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],u=e[8],d=e[9],f=e[10],p=e[11],m=e[12],h=e[13],g=e[14],_=e[15],v=t[0],y=t[1],b=t[2],x=t[3],S=t[4],C=t[5],w=t[6],T=t[7],E=t[8],D=t[9],O=t[10],k=t[11],A=t[12],j=t[13],M=t[14],N=t[15];return Math.abs(n-v)<=1e-6*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(r-y)<=1e-6*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(i-b)<=1e-6*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(a-x)<=1e-6*Math.max(1,Math.abs(a),Math.abs(x))&&Math.abs(o-S)<=1e-6*Math.max(1,Math.abs(o),Math.abs(S))&&Math.abs(s-C)<=1e-6*Math.max(1,Math.abs(s),Math.abs(C))&&Math.abs(c-w)<=1e-6*Math.max(1,Math.abs(c),Math.abs(w))&&Math.abs(l-T)<=1e-6*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(u-E)<=1e-6*Math.max(1,Math.abs(u),Math.abs(E))&&Math.abs(d-D)<=1e-6*Math.max(1,Math.abs(d),Math.abs(D))&&Math.abs(f-O)<=1e-6*Math.max(1,Math.abs(f),Math.abs(O))&&Math.abs(p-k)<=1e-6*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(m-A)<=1e-6*Math.max(1,Math.abs(m),Math.abs(A))&&Math.abs(h-j)<=1e-6*Math.max(1,Math.abs(h),Math.abs(j))&&Math.abs(g-M)<=1e-6*Math.max(1,Math.abs(g),Math.abs(M))&&Math.abs(_-N)<=1e-6*Math.max(1,Math.abs(_),Math.abs(N))}function km(){var e=new nm(3);return nm!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Am(e){var t=new nm(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function jm(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function Mm(e,t,n){var r=new nm(3);return r[0]=e,r[1]=t,r[2]=n,r}function Nm(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function Pm(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Fm(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function Im(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e}function Lm(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)}function Rm(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function zm(e,t){var n=t[0],r=t[1],i=t[2],a=n*n+r*r+i*i;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function Bm(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Vm(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],c=n[2];return e[0]=i*c-a*s,e[1]=a*o-r*c,e[2]=r*s-i*o,e}function Hm(e,t,n,r){var i=t[0],a=t[1],o=t[2];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e[2]=o+r*(n[2]-o),e}function Um(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return o||=1,e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/o,e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,e}function Wm(e,t,n){var r=t[0],i=t[1],a=t[2];return e[0]=r*n[0]+i*n[3]+a*n[6],e[1]=r*n[1]+i*n[4]+a*n[7],e[2]=r*n[2]+i*n[5]+a*n[8],e}function Gm(e,t,n){var r=n[0],i=n[1],a=n[2],o=n[3],s=t[0],c=t[1],l=t[2],u=i*l-a*c,d=a*s-r*l,f=r*c-i*s;return u+=u,d+=d,f+=f,e[0]=s+o*u+i*f-a*d,e[1]=c+o*d+a*u-r*f,e[2]=l+o*f+r*d-i*u,e}function Km(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function qm(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function Jm(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function Ym(e){return e[0]=0,e[1]=0,e[2]=0,e}var Xm=Pm,Zm=jm;(function(){var e=km();return function(t,n,r,i,a,o){var s,c;for(n||=3,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=r*o,e[2]=i*o,e[3]=a*o,e}function rh(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,e}var ih=eh;(function(){var e=Qm();return function(t,n,r,i,a,o){var s,c;for(n||=4,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s1e-6?(f=Math.acos(p),m=Math.sin(f),h=Math.sin((1-r)*f)/m,g=Math.sin(r*f)/m):(h=1-r,g=r),e[0]=h*i+g*c,e[1]=h*a+g*l,e[2]=h*o+g*u,e[3]=h*s+g*d,e}function uh(e,t){var n=t[0]+t[4]+t[8],r;if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[i*3+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;r=Math.sqrt(t[i*3+i]-t[a*3+a]-t[o*3+o]+1),e[i]=.5*r,r=.5/r,e[3]=(t[a*3+o]-t[o*3+a])*r,e[a]=(t[a*3+i]+t[i*3+a])*r,e[o]=(t[o*3+i]+t[i*3+o])*r}return e}function dh(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`zyx`,a=Math.PI/360;t*=a,r*=a,n*=a;var o=Math.sin(t),s=Math.cos(t),c=Math.sin(n),l=Math.cos(n),u=Math.sin(r),d=Math.cos(r);switch(i){case`xyz`:e[0]=o*l*d+s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d-o*c*u;break;case`xzy`:e[0]=o*l*d-s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d+o*c*u;break;case`yxz`:e[0]=o*l*d+s*c*u,e[1]=s*c*d-o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d+o*c*u;break;case`yzx`:e[0]=o*l*d+s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d-o*c*u;break;case`zxy`:e[0]=o*l*d-s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u+o*c*d,e[3]=s*l*d-o*c*u;break;case`zyx`:e[0]=o*l*d-s*c*u,e[1]=s*c*d+o*l*u,e[2]=s*l*u-o*c*d,e[3]=s*l*d+o*c*u;break;default:throw Error(`Unknown angle order `+i)}return e}var fh=$m,ph=nh;(function(){var e=km(),t=Mm(1,0,0),n=Mm(0,1,0);return function(r,i,a){var o=Bm(i,a);return o<-.999999?(Vm(e,t,i),Zm(e)<1e-6&&Vm(e,n,i),zm(e,e),sh(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(Vm(e,i,a),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,ph(r,r))}})(),function(){var e=ah(),t=ah();return function(n,r,i,a,o,s){return lh(e,r,o,s),lh(t,i,a,s),lh(n,e,t,2*s*(1-s)),n}}(),function(){var e=sm();return function(t,n,r,i){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],ph(t,uh(t,e))}}();function mh(){var e=new nm(2);return nm!=Float32Array&&(e[0]=0,e[1]=0),e}function hh(e,t){var n=new nm(2);return n[0]=e,n[1]=t,n}function gh(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function _h(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)}function vh(e){var t=e[0],n=e[1];return t*t+n*n}function yh(e,t){return e[0]*t[0]+e[1]*t[1]}function bh(e){return e[0]=0,e[1]=0,e}var xh=vh;(function(){var e=mh();return function(t,n,r,i,a,o){var s,c;for(n||=2,r||=0,c=i?Math.min(i*n+r,t.length):t.length,s=r;s0?s:-s}function Fh(e,t){let n=Lh(e,360),r=Lh(t,360),i=r-n,a=r>n?i-360:i+360;return Math.abs(i)e.canonical.z)),n=1/0,r=-1/0,i=1/0,a=-1/0,o=[];for(let s of e){let{x:e,y:c,z:l}=s.canonical,u=2**(t-l),d=e*u,f=c*u;o.push({id:s,x:d,y:f}),dr&&(r=d),fa&&(a=f)}let s=new Set;for(let e of o)(e.x===n||e.x===r||e.y===i||e.y===a)&&s.add(e.id);return s}function Hh(e){if(e<=0)return 0;if(e>=1)return 1;let t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function Uh(e,t,n,r){return Zp(e,t,n,r)}var Wh=Uh(.25,.1,.25,1);function G(e,t,n){return Math.min(n,Math.max(t,e))}function Gh(e,t,n){let r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function Kh(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}var qh=1;function Jh(){return qh++}function Yh(e){return Math.log(e)/Math.LN2%1==0}function Xh(e){return e<=1?1:2**Math.ceil(Math.log(e)/Math.LN2)}function Zh(e){return 2**e}function Qh(e){return Math.log(e)/Math.LN2}function $h(e,t,n){if(t<=0)return e;let r=1/t;return n===void 0||Math.abs(n)<1e-10?Math.round(e*r)/r:(n>0?Math.ceil(e*r-1e-9):Math.floor(e*r+1e-10))/r}function eg(e,t,n){let r={};for(let i in e)t.call(n||this,e[i],i,e)&&(r[i]=e[i]);return r}function tg(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n[e,ng(t)])):e}var rg={};function ig(e){rg[e]||(typeof console<`u`&&console.warn(e),rg[e]=!0)}function ag(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function og(e,t,n,r){let i=t.y-e.y,a=t.x-e.x,o=r.y-n.y,s=r.x-n.x,c=o*a-s*i;if(c===0)return null;let l=e.y-n.y,u=e.x-n.x,d=(s*l-o*u)/c;return new U(e.x+d*a,e.y+d*i)}function sg([e,t,n]){return t+=90,t*=Math.PI/180,n*=Math.PI/180,[e*Math.cos(t)*Math.sin(n),e*Math.sin(t)*Math.sin(n),e*Math.cos(n)]}function cg(e){return typeof WorkerGlobalScope<`u`&&e!==void 0&&e instanceof WorkerGlobalScope}function lg(e){let t=/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,n={};if(e.replace(t,(e,t,r,i)=>{let a=r||i;return n[t]=!a||a.toLowerCase(),``}),n[`max-age`]){let e=parseInt(n[`max-age`],10);isNaN(e)?delete n[`max-age`]:n[`max-age`]=e}return n}var ug=null;function dg(e){if(ug==null){let t=e.navigator?e.navigator.userAgent:null;ug=!!e.safari||!!(t&&(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match(`Safari`)&&!t.match(`Chrome`)))}return ug}function fg(e){return typeof ImageBitmap<`u`&&e instanceof ImageBitmap}var eee=async(e,t)=>{let n=new Blob([new Uint8Array(e)],{type:`image/png`});try{return createImageBitmap(n,t)}catch(e){throw Error(`Could not load image because of ${Ch(e).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}},tee=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>r.src=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=`)},r.onerror=()=>n(Error(`Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));let i=new Blob([new Uint8Array(e)],{type:`image/png`});r.src=URL.createObjectURL(i)});function nee(e,t,n,r,i){let a=Math.max(-t,0)*4,o=(Math.max(0,n)-n)*r*4+a,s=r*4,c=Math.max(0,t),l=Math.max(0,n),u=Math.min(e.width,t+r),d=Math.min(e.height,n+i);return{rect:{x:c,y:l,width:u-c,height:d-l},layout:[{offset:o,stride:s}]}}async function pg(e,t,n,r,i){if(typeof VideoFrame>`u`)throw Error(`VideoFrame not supported`);let a=new VideoFrame(e,{timestamp:0});try{let o=a?.format;if(!o||!(o.startsWith(`BGR`)||o.startsWith(`RGB`)))throw Error(`Unrecognized format ${o}`);let s=o.startsWith(`BGR`),c=new Uint8ClampedArray(r*i*4);if(await a.copyTo(c,nee(e,t,n,r,i)),s)for(let e=0;e{e.removeEventListener(t,n,r)}}}function hg(e){return e*Math.PI/180}function gg(e){return e/Math.PI*180}function _g(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing}function vg(e){let t=new Float64Array(9);um(t,e);let n=gg(-Math.asin(G(t[2],-1,1))),r,i;return Math.hypot(t[5],t[8])<.001?(r=0,i=-gg(Math.atan2(t[3],t[4]))):(r=gg(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),i=gg(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:r,pitch:n+90,bearing:i}}function yg(e,t,n){let r=hh(t.x-n.x,t.y-n.y),i=hh(e.x-n.x,e.y-n.y),a=r[0]*i[1]-r[1]*i[0];return gg(Math.atan2(a,yh(r,i)))}function bg(e,t,n){let r=new Float64Array(4);return dh(r,e,t-90,n),r}var xg=85.051129,Sg={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Cg={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function wg(e,t){return Sg[t]&&`touches`in e}function Tg(e,t){if(!Cg[t])return!1;let n=e,r=(n?.target)?.ownerDocument?.defaultView||window;return n instanceof r.MouseEvent||n instanceof r.WheelEvent}function Eg(e){return Sg[e]||Cg[e]}var Dg=`AbortError`,Og=class extends Error{constructor(e=Dg){super(e instanceof Error?e.message:e),this.name=Dg,e instanceof Error&&e.stack&&(this.stack=e.stack)}};function kg(e){return e instanceof Error&&e.name===`AbortError`}function Ag(e){if(e.aborted)throw new Og(e.reason)}var jg,Mg,Ng,Pg={frame(e,t,n,r){let i=r||window,a=i.requestAnimationFrame(e=>{o(),t(e)}),{unsubscribe:o}=mg(e.signal,`abort`,()=>{o(),i.cancelAnimationFrame(a),n(new Og(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((n,r)=>{this.frame(e,n,r,t)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){let t;if($p()&&!tm())t=new OffscreenCanvas(e.width,e.height).getContext(`2d`,{willReadFrequently:!0});else{let n=window.document.createElement(`canvas`);n.width=e.width,n.height=e.height,t=n.getContext(`2d`,{willReadFrequently:!0})}if(!t)throw Error(`failed to create canvas 2d context`);return t.drawImage(e,0,0,e.width,e.height),t},resolveURL(e){return jg||=document.createElement(`a`),jg.href=e,jg.href},get hardwareConcurrency(){return typeof navigator<`u`&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return Ng===void 0?matchMedia?(Mg??=matchMedia(`(prefers-reduced-motion: reduce)`),Mg.matches):!1:Ng},set prefersReducedMotion(e){Ng=e}},Fg=new class{constructor(){this._frozenAt=null}getCurrentTime(){return this._frozenAt===null?performance.now():this._frozenAt}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function Ig(){return Fg.getCurrentTime()}function Lg(e){return e}function Rg(e){return e}var zg=new Set(`a.abbr.b.bdi.bdo.br.cite.code.del.div.em.i.img.ins.kbd.li.mark.ol.p.q.s.samp.small.span.strong.sub.sup.time.u.ul.var.wbr`.split(`.`)),Bg=new Set([`alt`,`class`,`datetime`,`dir`,`height`,`href`,`hreflang`,`lang`,`referrerpolicy`,`rel`,`role`,`src`,`target`,`title`,`translate`,`type`,`width`]),Vg=new Set([`href`,`src`]),Hg=new Set([`http:`,`https:`,`mailto:`]),Ug;function Wg(){return Ug??={getAttribute:Element.prototype.getAttribute,getAttributeNames:Element.prototype.getAttributeNames,querySelectorAll:Element.prototype.querySelectorAll,remove:Element.prototype.remove,removeAttribute:Element.prototype.removeAttribute,localName:Object.getOwnPropertyDescriptor(Element.prototype,`localName`).get,namespaceURI:Object.getOwnPropertyDescriptor(Element.prototype,`namespaceURI`).get,body:Object.getOwnPropertyDescriptor(Document.prototype,`body`).get,childNodes:Object.getOwnPropertyDescriptor(Node.prototype,`childNodes`).get},Ug}var Gg=class e{static{this.docStyle=typeof window<`u`&&window.document?.documentElement.style}static{this.selectProp=!e.docStyle||`userSelect`in e.docStyle?`userSelect`:`webkitUserSelect`}static create(e,t,n){let r=window.document.createElement(e);return t!==void 0&&(r.className=t),n&&n.appendChild(r),r}static createNS(e,t){return window.document.createElementNS(e,t)}static disableDrag(){e.docStyle&&e.selectProp&&(e.userSelect=e.docStyle[e.selectProp],e.docStyle[e.selectProp]=`none`)}static enableDrag(){e.docStyle&&e.selectProp&&(e.docStyle[e.selectProp]=e.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener(`click`,e.suppressClickInternal,!0)}static suppressClick(){window.addEventListener(`click`,e.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener(`click`,e.suppressClickInternal,!0)},0)}static getScale(e){let t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,t,n){let r=t.boundingClientRect;return new U((n.clientX-r.left)/t.x-e.clientLeft,(n.clientY-r.top)/t.y-e.clientTop)}static mousePos(t,n){let r=e.getScale(t);return e.getPoint(t,r,n)}static touchPos(t,n){let r=[],i=e.getScale(t);for(let a of n)r.push(e.getPoint(t,i,a));return r}static sanitize(t){let{querySelectorAll:n,remove:r,body:i,childNodes:a}=Wg(),o=new DOMParser().parseFromString(Lg(t),`text/html`),s=i.call(o);for(let t of Array.from(n.call(s,`*`)))e.isAllowedElement(t)?e.removeDisallowedAttributes(t):r.call(t);let c=document.createDocumentFragment();return c.append(...a.call(s)),c}static isAllowedElement(e){let{namespaceURI:t,localName:n}=Wg();return t.call(e)===`http://www.w3.org/1999/xhtml`&&zg.has(n.call(e))}static removeDisallowedAttributes(t){let{getAttributeNames:n,getAttribute:r,removeAttribute:i}=Wg();for(let a of n.call(t))e.isAllowedAttribute(a,r.call(t,a))||i.call(t,a)}static isAllowedAttribute(e,t){if(!Bg.has(e)&&!e.startsWith(`aria-`))return!1;if(!Vg.has(e))return!0;try{return Hg.has(new URL(t,`https://maplibre.invalid/`).protocol)}catch{return!1}}},Kg={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:``};function qg(e){return Kg.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf(`://`))]}var Jg=`global-dispatcher`,Yg=class extends Error{constructor(e,t,n,r){super(`AJAXError: ${t} (${e}): ${n}`),this.status=e,this.statusText=t,this.url=n,this.body=r}};function Xg(){if(cg(self))return self.worker?.referrer;if(window.location.protocol===`blob:`)try{return window.parent.location.href}catch{}return window.location.href}var Zg=e=>e.startsWith(`file:`)||Xg()?.startsWith(`file:`)&&!/^\w+:/.test(e);async function Qg(e,t){let n=new Request(e.url,{method:e.method||`GET`,body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:Xg(),referrerPolicy:e.referrerPolicy,signal:t.signal});e.type===`json`&&!n.headers.has(`Accept`)&&n.headers.set(`Accept`,`application/json`);let r;try{r=await fetch(n)}catch(t){throw kg(t)?t:new Yg(0,Ch(t).message,e.url,new Blob)}if(!r.ok){let t=await r.blob();throw new Yg(r.status,r.statusText,e.url,t)}let i;i=e.type===`arrayBuffer`||e.type===`image`?r.arrayBuffer():e.type===`json`?r.json():r.text();let a=await i;return Ag(t.signal),{data:a,cacheControl:r.headers.get(`Cache-Control`),expires:r.headers.get(`Expires`),etag:r.headers.get(`ETag`)}}function $g(e,t){return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(e.method||`GET`,e.url,!0),(e.type===`arrayBuffer`||e.type===`image`)&&(i.responseType=`arraybuffer`);for(let t in e.headers)i.setRequestHeader(t,e.headers[t]);e.type===`json`&&(i.responseType=`text`,e.headers?.Accept||i.setRequestHeader(`Accept`,`application/json`)),i.withCredentials=e.credentials===`include`,i.onerror=()=>{r(Error(i.statusText))},i.onload=()=>{if(!t.signal.aborted){if((i.status>=200&&i.status<300||i.status===0)&&i.response!==null){let t=i.response;if(e.type===`json`)try{t=JSON.parse(i.response)}catch(e){r(e);return}n({data:t,cacheControl:i.getResponseHeader(`Cache-Control`),expires:i.getResponseHeader(`Expires`),etag:i.getResponseHeader(`ETag`)})}else{let t=new Blob([i.response],{type:i.getResponseHeader(`Content-Type`)});r(new Yg(i.status,i.statusText,e.url,t))}}},t.signal.addEventListener(`abort`,()=>{i.abort(),r(new Og(t.signal.reason))}),i.send(e.body)})}var e_=async function(e,t){if(e.url.includes(`://`)&&!/^https?:|^file:/.test(e.url)){let n=qg(e.url);if(n){let r=await n(e,t);return!r.data&&e.type===`arrayBuffer`?{...r,data:new ArrayBuffer(0)}:r}if(cg(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:`GR`,data:e,targetMapId:Jg},t)}if(!Zg(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,`signal`))return Qg(e,t);if(cg(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:`GR`,data:e,mustQueue:!0,targetMapId:Jg},t)}return $g(e,t)},t_=(e,t)=>e_({...e,type:`json`},t),n_=(e,t)=>e_({...e,type:`arrayBuffer`},t);function r_(e){if(!e||e.startsWith(`data:image/`))return!0;if(e.startsWith(`blob:`)&&(e=e.slice(5),e.startsWith(`null`)))return!1;if(e.indexOf(`://`)<=0)return!0;let t=new URL(e),n=window.location;return t.protocol===n.protocol&&t.host===n.host}var ree=e=>{let t=window.document.createElement(`video`);return t.muted=!0,new Promise(n=>{t.onloadstart=()=>{n(t)};for(let n of e){let e=window.document.createElement(`source`);r_(n)||(t.crossOrigin=`Anonymous`),e.src=n,t.appendChild(e)}})};function i_(e,t,n){n[e]?.includes(t)||(n[e]||=[],n[e].push(t))}function a_(e,t,n){if(n?.[e]){let r=n[e].indexOf(t);r!==-1&&n[e].splice(r,1)}}function o_(e,t){if(t)for(let[n,r]of Object.entries(t))Object.defineProperty(e,n,{value:r,writable:!0,enumerable:!0,configurable:!0})}var s_=class{constructor(e,t={}){o_(this,t),this.type=e}},c_=class extends s_{constructor(e,t={}){super(`error`,{error:e,...t})}},l_=class{on(e,t){return this._listeners||={},i_(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return a_(e,t,this._listeners),a_(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||={},i_(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){let n=typeof e==`string`?new s_(e,t||{}):e,r=n.type;if(this.listens(r)){n.target=this;let e=this._listeners?.[r]?.slice()??[];for(let t of e)t.call(this,n);let t=this._oneTimeListeners?.[r]?.slice()??[];for(let e of t)a_(r,e,this._oneTimeListeners),e.call(this,n);let i=this._eventedParent;i&&(o_(n,typeof this._eventedParentData==`function`?this._eventedParentData():this._eventedParentData),i.fire(n))}else n instanceof c_&&console.error(n.error);return this}listens(e){return!!(this._listeners?.[e]?.length||this._oneTimeListeners?.[e]?.length||this._eventedParent?.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}},u_=class e{constructor(e,t,n){let r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;let i=new Int32Array(this.arrayBuffer);e=i[0],t=i[1],n=i[2],this.d=t+2*n;for(let e=0;e=l[c+0]&&r>=l[c+1])?(o[u]=!0,a.push(i[u])):o[u]=!1}}}_forEachCell(e,t,n,r,i,a,o,s){let c=this._convertToCellCoord(e),l=this._convertToCellCoord(t),u=this._convertToCellCoord(n),d=this._convertToCellCoord(r);for(let f=c;f<=u;f++)for(let c=l;c<=d;c++){let l=this.d*c+f;if((!s||s(this._convertFromCellCoord(f),this._convertFromCellCoord(c),this._convertFromCellCoord(f+1),this._convertFromCellCoord(c+1)))&&i.call(this,e,t,n,r,l,a,o,s))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let e=this.cells,t=3+this.cells.length+1+1,n=0;for(let e of this.cells)n+=e.length;let r=new Int32Array(t+n+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let i=t;for(let t=0;t":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:`enum`,values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:`expression`},stops:{type:`array`,value:`function_stop`},base:{type:`number`,default:1,minimum:0},property:{type:`string`,default:`$zoom`},type:{type:`enum`,values:{identity:{},exponential:{},interval:{},categorical:{}},default:`exponential`},colorSpace:{type:`enum`,values:{rgb:{},lab:{},hcl:{},oklch:{},oklab:{}},default:`rgb`},default:{type:`*`,required:!1}},function_stop:{type:`array`,minimum:0,maximum:24,value:[`number`,`color`],length:2},expression:{type:`array`,value:`expression_name`,minimum:1},light:{anchor:{type:`enum`,default:`viewport`,values:{map:{},viewport:{}},"property-type":`data-constant`,transition:!1,expression:{interpolated:!1,parameters:[`zoom`]}},position:{type:`array`,default:[1.15,210,30],length:3,value:`number`,"property-type":`data-constant`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]}},color:{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},intensity:{type:`number`,"property-type":`data-constant`,default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0}},sky:{"sky-color":{type:`color`,"property-type":`data-constant`,default:`#88C6FC`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"horizon-color":{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"fog-color":{type:`color`,"property-type":`data-constant`,default:`#ffffff`,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"fog-ground-blend":{type:`number`,"property-type":`data-constant`,default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"horizon-fog-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"sky-horizon-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0},"atmosphere-blend":{type:`number`,"property-type":`data-constant`,default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:[`zoom`]},transition:!0}},terrain:{source:{type:`string`,required:!0},exaggeration:{type:`number`,minimum:0,default:1}},projection:{type:{type:`projectionDefinition`,default:`mercator`,"property-type":`data-constant`,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]}}},paint:[`paint_fill`,`paint_line`,`paint_circle`,`paint_heatmap`,`paint_fill-extrusion`,`paint_symbol`,`paint_raster`,`paint_hillshade`,`paint_color-relief`,`paint_background`],paint_fill:{"fill-antialias":{type:`boolean`,default:!0,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-layer-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`global-state`]},"property-type":`data-constant`},"fill-layer-blend":{type:`enum`,values:{normal:{},multiply:{},color:{},luminosity:{},"plus-lighter":{},screen:{},overlay:{},difference:{},exclusion:{},"soft-light":{},"hard-light":{},darken:{},lighten:{},"color-dodge":{},"color-burn":{},hue:{},saturation:{}},default:`normal`,"property-type":`constant`,transition:!1},"fill-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-outline-color":{type:`color`,transition:!0,requires:[{"!":`fill-pattern`},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`fill-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"fill-rounded-corner-distance":{type:`number`,default:0,minimum:0,units:`meters`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`fill-extrusion-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`,`elevation`]},"property-type":`data-driven`},"fill-extrusion-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`fill-extrusion-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"fill-extrusion-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"fill-extrusion-height":{type:`number`,default:0,units:`meters`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-base":{type:`number`,default:0,units:`meters`,transition:!0,requires:[`fill-extrusion-height`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"fill-extrusion-vertical-gradient":{type:`boolean`,default:!0,transition:!1,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_line:{"line-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-layer-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`global-state`]},"property-type":`data-constant`},"line-layer-blend":{type:`enum`,values:{normal:{},multiply:{},color:{},luminosity:{},"plus-lighter":{},screen:{},overlay:{},difference:{},exclusion:{},"soft-light":{},"hard-light":{},darken:{},lighten:{},"color-dodge":{},"color-burn":{},hue:{},saturation:{}},default:`normal`,"property-type":`constant`,transition:!1},"line-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`line-pattern`}],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"line-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`line-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"line-width":{type:`number`,default:1,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-gap-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-offset":{type:`number`,default:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"line-dasharray":{type:`array`,value:`number`,minimum:0,transition:!0,units:`line widths`,requires:[{"!":`line-pattern`}],expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"line-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`,`feature`]},"property-type":`cross-faded-data-driven`},"line-gradient":{type:`color`,transition:!1,requires:[{"!":`line-dasharray`},{"!":`line-pattern`},{source:`geojson`,has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:[`line-progress`]},"property-type":`color-ramp`}},paint_circle:{"circle-radius":{type:`number`,default:5,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-blur":{type:`number`,default:0,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"circle-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`circle-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-pitch-scale":{type:`enum`,values:{map:{},viewport:{}},default:`map`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-pitch-alignment":{type:`enum`,values:{map:{},viewport:{}},default:`viewport`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"circle-stroke-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-stroke-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"circle-stroke-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`}},paint_heatmap:{"heatmap-radius":{type:`number`,default:30,minimum:1,transition:!0,units:`pixels`,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"heatmap-weight":{type:`number`,default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"heatmap-intensity":{type:`number`,default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"heatmap-color":{type:`color`,default:[`interpolate`,[`linear`],[`heatmap-density`],0,`rgba(0, 0, 255, 0)`,.1,`royalblue`,.3,`cyan`,.5,`lime`,.7,`yellow`,1,`red`],transition:!1,expression:{interpolated:!0,parameters:[`heatmap-density`]},"property-type":`color-ramp`},"heatmap-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},paint_symbol:{"icon-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-color":{type:`color`,default:`#000000`,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-color":{type:`color`,default:`rgba(0, 0, 0, 0)`,transition:!0,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-halo-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"icon-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,requires:[`icon-image`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"icon-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`icon-image`,`icon-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"text-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-color":{type:`color`,default:`#000000`,transition:!0,overridable:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-color":{type:`color`,default:`rgba(0, 0, 0, 0)`,transition:!0,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-width":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-halo-blur":{type:`number`,default:0,minimum:0,transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`,`feature`,`feature-state`]},"property-type":`data-driven`},"text-translate":{type:`array`,value:`number`,length:2,default:[0,0],transition:!0,units:`pixels`,requires:[`text-field`],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"text-translate-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`map`,requires:[`text-field`,`text-translate`],expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_raster:{"raster-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-layer-blend":{type:`enum`,values:{normal:{},multiply:{},color:{},luminosity:{},"plus-lighter":{},screen:{},overlay:{},difference:{},exclusion:{},"soft-light":{},"hard-light":{},darken:{},lighten:{},"color-dodge":{},"color-burn":{},hue:{},saturation:{}},default:`normal`,"property-type":`constant`,transition:!1},"raster-hue-rotate":{type:`number`,default:0,period:360,transition:!0,units:`degrees`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-brightness-min":{type:`number`,default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-brightness-max":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-saturation":{type:`number`,default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"raster-contrast":{type:`number`,default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},resampling:{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"raster-resampling":{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"raster-fade-duration":{type:`number`,default:300,minimum:0,transition:!1,units:`milliseconds`,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},paint_hillshade:{"hillshade-illumination-direction":{type:`numberArray`,default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-illumination-altitude":{type:`numberArray`,default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-illumination-anchor":{type:`enum`,values:{map:{},viewport:{}},default:`viewport`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-exaggeration":{type:`number`,default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-shadow-color":{type:`colorArray`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-highlight-color":{type:`colorArray`,default:`#FFFFFF`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-accent-color":{type:`color`,default:`#000000`,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"hillshade-method":{type:`enum`,values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:`standard`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`},resampling:{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},"paint_color-relief":{"color-relief-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"color-relief-color":{type:`color`,transition:!1,expression:{interpolated:!0,parameters:[`elevation`]},"property-type":`color-ramp`},resampling:{type:`enum`,values:{linear:{},nearest:{}},default:`linear`,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`data-constant`}},paint_background:{"background-color":{type:`color`,default:`#000000`,transition:!0,requires:[{"!":`background-pattern`}],expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`},"background-pattern":{type:`resolvedImage`,transition:!0,expression:{interpolated:!1,parameters:[`zoom`]},"property-type":`cross-faded`},"background-opacity":{type:`number`,default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:[`zoom`]},"property-type":`data-constant`}},transition:{duration:{type:`number`,default:300,minimum:0,units:`milliseconds`},delay:{type:`number`,default:0,minimum:0,units:`milliseconds`}},"property-type":{"data-driven":{type:`property-type`},"cross-faded":{type:`property-type`},"cross-faded-data-driven":{type:`property-type`},"color-ramp":{type:`property-type`},"data-constant":{type:`property-type`},constant:{type:`property-type`}},promoteId:{"*":{type:`string`}},interpolation:{type:`array`,value:`interpolation_name`,minimum:1},interpolation_name:{type:`enum`,values:{linear:{syntax:{overloads:[{parameters:[],"output-type":`interpolation`}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:[`base`],"output-type":`interpolation`}],parameters:[{name:`base`,type:`number literal`}]}},"cubic-bezier":{syntax:{overloads:[{parameters:[`x1`,`y1`,`x2`,`y2`],"output-type":`interpolation`}],parameters:[{name:`x1`,type:`number literal`},{name:`y1`,type:`number literal`},{name:`x2`,type:`number literal`},{name:`y2`,type:`number literal`}]}}}}},K=d_,iee=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function aee(e,t){let n={};for(let t in e)t!==`ref`&&(n[t]=e[t]);return iee.forEach(e=>{e in t&&(n[e]=t[e])}),n}function f_(e){e=e.slice();let t=Object.create(null);for(let n=0;n{`source`in e&&i[e.source]?n.push({command:`removeLayer`,args:[e.id]}):o.push(e)}),n=n.concat(a),x_(o,t.layers,n),r&&t.terrain&&n.push({command:`setTerrain`,args:[t.terrain]})}catch(e){console.warn(`Unable to compute style diff:`,e),n=[{command:`setStyle`,args:[t]}]}return n}var q=class{constructor(e,t,n,r,i=`error`){this.message=(e?`${e}: `:``)+n,r&&(this.identifier=r),this.severity=i,typeof t?.__line__==`number`&&t.__line__&&(this.line=t.__line__)}},C_=class extends Error{constructor(e,t){super(t),this.message=t,this.key=e}},w_=class e{constructor(e,t=[]){this.parent=e,this.bindings=new Map(t)}concat(t){return new e(this,t)}get(e){if(this.bindings.has(e))return this.bindings.get(e);if(this.parent)return this.parent.get(e);throw Error(`${e} not found in scope.`)}has(e){return this.bindings.has(e)?!0:this.parent?this.parent.has(e):!1}},T_={kind:`null`},J={kind:`number`},E_={kind:`string`},D_={kind:`boolean`},O_={kind:`color`},k_={kind:`projectionDefinition`},A_={kind:`object`},j_={kind:`value`},M_={kind:`error`},N_={kind:`collator`},P_={kind:`formatted`},F_={kind:`padding`},I_={kind:`colorArray`},L_={kind:`numberArray`},R_={kind:`resolvedImage`},z_={kind:`variableAnchorOffsetCollection`};function B_(e,t){return{kind:`array`,itemType:e,N:t}}function V_(e){if(e.kind===`array`){let t=V_(e.itemType);return typeof e.N==`number`?`array<${t}, ${e.N}>`:e.itemType.kind===`value`?`array`:`array<${t}>`}return e.kind}var H_=[T_,J,E_,D_,O_,k_,P_,A_,B_(j_),F_,L_,I_,R_,z_];function U_(e,t){if(t.kind===`error`)return null;if(e.kind===`array`){if(t.kind===`array`&&(t.N===0&&t.itemType.kind===`value`||!U_(e.itemType,t.itemType))&&(typeof e.N!=`number`||e.N===t.N))return null}else if(e.kind===t.kind)return null;else if(e.kind===`value`){for(let e of H_)if(!U_(e,t))return null}return`Expected ${V_(e)} but found ${V_(t)} instead.`}function W_(e,t){return t.some(t=>t.kind===e.kind)}function G_(e,t){return t.some(t=>t===`null`?e===null:t===`array`?Array.isArray(e):t===`object`?e&&!Array.isArray(e)&&typeof e==`object`:t===typeof e)}function K_(e,t){return e.kind===`array`&&t.kind===`array`?e.itemType.kind===t.itemType.kind&&typeof e.N==`number`:e.kind===t.kind}var q_=.96422,J_=.82521,Y_=4/29,X_=6/29,Z_=3*X_*X_,Q_=Math.PI/180,$_=180/Math.PI;function e1(e){return e%=360,e<0&&(e+=360),e}function t1([e,t,n,r]){e=n1(e),t=n1(t),n=n1(n);let i,a,o=r1(.2225045*e+.7168786*t+.0606169*n);return e===t&&t===n?i=a=o:(i=r1((.4360747*e+.3850649*t+.1430804*n)/q_),a=r1((.0139322*e+.0971045*t+.7141733*n)/J_)),[116*o-16,500*(i-o),200*(o-a),r]}function n1(e){let t=Math.abs(e);return t<=.04045?e/12.92:Math.sign(e)*((t+.055)/1.055)**2.4}function r1(e){return e>.008856451679035631?e**(1/3):e/Z_+Y_}function i1([e,t,n,r]){let i=(e+16)/116,a=isNaN(t)?i:i+t/500,o=isNaN(n)?i:i-n/200;return i=+o1(i),a=q_*o1(a),o=J_*o1(o),[a1(3.1338561*a-1.6168667*i-.4906146*o),a1(-.9787684*a+1.9161415*i+.033454*o),a1(.0719453*a-.2289914*i+1.4052427*o),r]}function a1(e){let t=Math.abs(e);return t<=.00304?12.92*e:Math.sign(e)*(1.055*t**(1/2.4)-.055)}function o1(e){return e>X_?e*e*e:Z_*(e-Y_)}function lee(e){let[t,n,r,i]=t1(e),a=Math.sqrt(n*n+r*r);return[Math.round(a*1e4)?e1(Math.atan2(r,n)*$_):NaN,a,t,i]}function uee([e,t,n,r]){return e=isNaN(e)?0:e*Q_,i1([n,Math.cos(e)*t,Math.sin(e)*t,r])}function dee([e,t,n,r]){e=e1(e),t/=100,n/=100;function i(r){let i=(r+e/30)%12,a=t*Math.min(n,1-n);return n-a*Math.max(-1,Math.min(i-3,9-i,1))}return[i(0),i(8),i(4),r]}var s1=[[506752/1228815,87881/245763,12673/70218],[87098/409605,175762/245763,12673/175545],[7918/409605,87881/737289,0xf46cf/1053270]],c1=[[12831/3959,-329/214,-1974/3959],[-851781/878810,1648619/878810,36519/878810],[705/12673,-2585/12673,705/667]],fee=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],pee=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],mee=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],hee=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]];function l1(e,[t,n,r]){return[e[0][0]*t+e[0][1]*n+e[0][2]*r,e[1][0]*t+e[1][1]*n+e[1][2]*r,e[2][0]*t+e[2][1]*n+e[2][2]*r]}function u1(e){let t=Math.abs(e);return t>.0031308?Math.sign(e)*(1.055*t**(1/2.4)-.055):12.92*e}function d1([e,t,n]){let[r,i,a]=l1(fee,l1(s1,[n1(e),n1(t),n1(n)]));return l1(pee,[Math.cbrt(r),Math.cbrt(i),Math.cbrt(a)])}function f1(e){let[t,n,r]=l1(mee,e),[i,a,o]=l1(c1,l1(hee,[t*t*t,n*n*n,r*r*r]));return[u1(i),u1(a),u1(o)]}function p1([e,t,n,r]){let[i,a,o]=d1([e,t,n]);return[i,a,o,r]}function m1([e,t,n,r]){let[i,a,o]=d1([e,t,n]),s=Math.sqrt(a*a+o*o);return s<=4e-6?[i,0,NaN,r]:[i,s,e1(Math.atan2(o,a)*$_),r]}function h1([e,t,n,r]){let i=isNaN(n)?0:n*Q_,a=Math.min(t,1e6),[o,s,c]=f1([e,a*Math.cos(i),a*Math.sin(i)]);return[o,s,c,r]}function g1([e,t,n,r]){return h1([e,Math.hypot(t,n),Math.atan2(n,t)*$_,r])}var _1=[[608311/1250200,189793/714400,198249/0xf42e0],[35783/156275,247089/357200,198249/2500400],[0,32229/714400,5220557/5000800]],v1=[[446124/178915,-333277/357830,-72051/178915],[-14852/17905,63121/35810,423/17905],[11844/330415,-50337/660830,316169/330415]];function y1([e,t,n,r]){let[i,a,o]=[e,t,n].map(e=>n1(Math.min(Math.max(e,-1e6),1e6))),[s,c,l]=l1(c1,l1(_1,[i,a,o])).map(u1);return[s,c,l,r]}function b1([e,t,n,r]){let[i,a,o]=l1(v1,l1(s1,[n1(e),n1(t),n1(n)])).map(e=>Math.min(Math.max(u1(e),0),1));return[i,a,o,r]}var x1=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function S1(e,t){return x1(e,t)?e[t]:void 0}function C1(e){if(e=e.toLowerCase().trim(),e===`transparent`)return[0,0,0,0];let t=S1(P1,e);if(t){let[e,n,r]=t;return[e/255,n/255,r/255,1]}if(e.startsWith(`#`)&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){let t=e.length<6?1:2,n=1;return[A1(e.slice(n,n+=t)),A1(e.slice(n,n+=t)),A1(e.slice(n,n+=t)),A1(e.slice(n,n+t)||`ff`)]}if(e.startsWith(`rgb`)){let t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){let[e,n,r,i,a,o,s,c,l,u,d,f]=t,p=[i||` `,s||` `,u].join(``);if(p===` `||p===` /`||p===`,,`||p===`,,,`){let e=[r,o,l].join(``),t=e===`%%%`?100:e===``?255:0;if(t){let e=[M1(+n/t,0,1),M1(+a/t,0,1),M1(+c/t,0,1),d?j1(+d,f):1];if(N1(e))return e}}return}}let n=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(n){let[e,t,r,i,a,o,s,c,l]=n,u=[r||` `,a||` `,s].join(``);if(u===` `||u===` /`||u===`,,`||u===`,,,`){let e=[+t,M1(+i,0,100),M1(+o,0,100),c?j1(+c,l):1];if(N1(e))return dee(e)}}let r=e.match(T1);if(r){let[,e,t,n,i]=r,a=[k1(e,1),k1(t,.4),k1(n,1),i===void 0?1:k1(i,1)];if(a.every(Number.isFinite))return h1([M1(a[0],0,1),Math.max(a[1],0),a[2]%360,M1(a[3],0,1)])}let i=e.match(E1);if(i){let[,e,t,n,r]=i,a=[k1(e,1),k1(t,.4),k1(n,.4),r===void 0?1:k1(r,1)];if(a.every(Number.isFinite))return g1([M1(a[0],0,1),a[1],a[2],M1(a[3],0,1)])}let a=e.match(D1);if(a){let[,e,t,n,r]=a,i=[k1(e,1),k1(t,1),k1(n,1),r===void 0?1:k1(r,1)];if(i.every(Number.isFinite))return y1([i[0],i[1],i[2],M1(i[3],0,1)])}}var w1=`[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:e[+-]?\\d+)?`,T1=RegExp(`^oklch\\(\\s*(none|${w1}%?)\\s+(none|${w1}%?)\\s+(none|${w1}(?:deg|grad|rad|turn)?)\\s*(?:\\/\\s*(none|${w1}%?)\\s*)?\\)$`),E1=RegExp(`^oklab\\(\\s*(none|${w1}%?)\\s+(none|${w1}%?)\\s+(none|${w1}%?)\\s*(?:\\/\\s*(none|${w1}%?)\\s*)?\\)$`),D1=RegExp(`^color\\(\\s*display-p3\\s+(none|${w1}%?)\\s+(none|${w1}%?)\\s+(none|${w1}%?)\\s*(?:\\/\\s*(none|${w1}%?)\\s*)?\\)$`),O1={deg:1,grad:.9,rad:180/Math.PI,turn:360};function k1(e,t){if(e===`none`)return 0;let[,n,r]=e.match(/^(.+?)(%|[a-z]+)?$/);return r===`%`?n/100*t:r?+n%(360/O1[r])*O1[r]:+n}function A1(e){return parseInt(e.padEnd(2,e),16)/255}function j1(e,t){return M1(t?e/100:e,0,1)}function M1(e,t,n){return Math.min(Math.max(t,e),n)}function N1(e){return!e.some(Number.isNaN)}var P1={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function F1(e,t,n){return e+n*(t-e)}function I1(e,t,n){return e.map((e,r)=>F1(e,t[r],n))}function L1(e){return e===`rgb`||e===`hcl`||e===`lab`||e===`oklch`||e===`oklab`}var R1=class e{constructor(e,t,n,r=1,i=!0){!i&&(Math.min(e,t,n)<0||Math.max(e,t,n)>1)&&(this.overwriteGetter(`unclippedRgb`,[e,t,n,r]),e=Math.min(Math.max(e,0),1),t=Math.min(Math.max(t,0),1),n=Math.min(Math.max(n,0),1)),this.r=e,this.g=t,this.b=n,this.a=r,i||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter(`rgb`,[e,t,n,r]))}static{this.black=new e(0,0,0,1)}static{this.white=new e(1,1,1,1)}static{this.transparent=new e(0,0,0,0)}static{this.red=new e(1,0,0,1)}static parse(t){if(t instanceof e)return t;if(typeof t!=`string`)return;let n=C1(t);if(n)return new e(...n,!1)}get rgb(){let{r:e,g:t,b:n,a:r}=this,i=r||1/0;return this.overwriteGetter(`rgb`,[e/i,t/i,n/i,r])}get hcl(){return this.overwriteGetter(`hcl`,lee(this.unclippedRgb))}get lab(){return this.overwriteGetter(`lab`,t1(this.unclippedRgb))}get oklch(){return this.overwriteGetter(`oklch`,m1(this.unclippedRgb))}get oklab(){return this.overwriteGetter(`oklab`,p1(this.unclippedRgb))}get displayP3(){return this.overwriteGetter(`displayP3`,b1(this.unclippedRgb))}get unclippedRgb(){return this.rgb}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){let[e,t,n,r]=this.rgb;return`rgba(${[e,t,n].map(e=>Math.round(e*255)).join(`,`)},${r})`}static interpolate(t,n,r,i=`rgb`){switch(i){case`rgb`:{let[i,a,o,s]=I1(t.unclippedRgb,n.unclippedRgb,r);return new e(i,a,o,s,!1)}case`hcl`:{let[i,a,o,s]=t.hcl,[c,l,u,d]=n.hcl,f,p;if(!isNaN(i)&&!isNaN(c)){let e=c-i;c>i&&e>180?e-=360:c180&&(e+=360),f=i+r*e}else isNaN(i)?isNaN(c)?f=NaN:(f=c,(o===1||o===0)&&(p=l)):(f=i,(u===1||u===0)&&(p=a));let[m,h,g,_]=uee([f,p??F1(a,l,r),F1(o,u,r),F1(s,d,r)]);return new e(m,h,g,_,!1)}case`lab`:{let[i,a,o,s]=i1(I1(t.lab,n.lab,r));return new e(i,a,o,s,!1)}case`oklch`:{let[i,a,o,s]=t.oklch,[c,l,u,d]=n.oklch,f=isNaN(o)?u:o,p=isNaN(u)?o:u;p-f>180?f+=360:p-f<-180&&(p+=360);let m=F1(s,d,r),h=m===0?1:m,[g,_,v]=h1([F1(i*s,c*d,r)/h,F1(a*s,l*d,r)/h,F1(f,p,r),m]);return new e(g,_,v,m,!1)}case`oklab`:{let[i,a,o,s]=t.oklab,[c,l,u,d]=n.oklab,f=F1(s,d,r),p=f===0?1:f,[m,h,g]=g1([F1(i*s,c*d,r)/p,F1(a*s,l*d,r)/p,F1(o*s,u*d,r)/p,f]);return new e(m,h,g,f,!1)}}}},z1=class{constructor(e,t,n){this.sensitivity=e?t?`variant`:`case`:t?`accent`:`base`,this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:`search`})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}},B1=[`bottom`,`center`,`top`],V1=class{constructor(e,t,n,r,i,a){this.text=e,this.image=t,this.scale=n,this.fontStack=r,this.textColor=i,this.verticalAlign=a}},H1=class e{constructor(e){this.sections=e}static fromString(t){return new e([new V1(t,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(t){return t instanceof e?t:e.fromString(t)}toString(){return this.sections.length===0?``:this.sections.map(e=>e.text).join(``)}},U1=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if(typeof t==`number`)return new e([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let e of t)if(typeof e!=`number`)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,n,r){return new e(I1(t.values,n.values,r))}},W1=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if(typeof t==`number`)return new e([t]);if(Array.isArray(t)){for(let e of t)if(typeof e!=`number`)return;return new e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,n,r){return new e(I1(t.values,n.values,r))}},G1=class e{constructor(e){this.values=e.slice()}static parse(t){if(t instanceof e)return t;if(typeof t==`string`){let n=R1.parse(t);return n?new e([n]):void 0}if(!Array.isArray(t))return;let n=[];for(let e of t){if(typeof e!=`string`)return;let t=R1.parse(e);if(!t)return;n.push(t)}return new e(n)}toString(){return JSON.stringify(this.values)}static interpolate(t,n,r,i=`rgb`){let a=[];if(t.values.length!=n.values.length)throw Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${n.values.length}), cannot interpolate.`);for(let e=0;e=0&&e<=255&&typeof t==`number`&&t>=0&&t<=255&&typeof n==`number`&&n>=0&&n<=255?r===void 0||typeof r==`number`&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,n,r].join(`, `)}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r==`number`?[e,t,n,r]:[e,t,n]).join(`, `)}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Q1(e){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`||e instanceof X1||e instanceof R1||e instanceof z1||e instanceof H1||e instanceof U1||e instanceof W1||e instanceof G1||e instanceof J1||e instanceof Y1)return!0;if(Array.isArray(e)){for(let t of e)if(!Q1(t))return!1;return!0}if(typeof e==`object`){for(let t in e)if(!Q1(e[t]))return!1;return!0}return!1}function $1(e){if(e===null)return T_;if(typeof e==`string`)return E_;if(typeof e==`boolean`)return D_;if(typeof e==`number`)return J;if(e instanceof R1)return O_;if(e instanceof X1)return k_;if(e instanceof z1)return N_;if(e instanceof H1)return P_;if(e instanceof U1)return F_;if(e instanceof W1)return L_;if(e instanceof G1)return I_;if(e instanceof J1)return z_;if(e instanceof Y1)return R_;if(Array.isArray(e)){let t=e.length,n;for(let t of e){let e=$1(t);if(!n)n=e;else if(n===e)continue;else{n=j_;break}}return B_(n||j_,t)}return A_}function e0(e){let t=typeof e;return e===null?``:t===`string`||t===`number`||t===`boolean`?String(e):e instanceof R1||e instanceof X1||e instanceof H1||e instanceof U1||e instanceof W1||e instanceof G1||e instanceof J1||e instanceof Y1?e.toString():JSON.stringify(e)}var t0=class e{constructor(e,t){this.type=e,this.value=t}static parse(t,n){if(t.length!==2)return n.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Q1(t[1]))return n.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],i=$1(r),a=n.expectedType;return i.kind===`array`&&i.N===0&&a&&a.kind===`array`&&(typeof a.N!=`number`||a.N===0)&&(i=a),new e(i,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}},n0={string:E_,number:J,boolean:D_,object:A_},r0=class e{constructor(e,t,n){this.type=e,this.args=t,this.key=n}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=1,i,a=t[0];if(a===`array`){let e;if(t.length>2){let i=t[1];if(typeof i!=`string`||!(i in n0)||i===`object`)return n.error(`The item type argument of "array" must be one of string, number, boolean`,1);e=n0[i],r++}else e=j_;let a;if(t.length>3){if(t[2]!==null&&(typeof t[2]!=`number`||t[2]<0||t[2]!==Math.floor(t[2])))return n.error(`The length argument to "array" must be a positive integer literal`,2);a=t[2],r++}i=B_(e,a)}else{if(!n0[a])throw Error(`Types doesn't contain name = ${a}`);i=n0[a]}let o=[];for(;re.outputDefined())}},i0={"to-boolean":D_,"to-color":O_,"to-number":J,"to-string":E_},a0=class e{constructor(e,t,n){this.type=e,this.args=t,this.key=n}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=t[0];if(!i0[r])throw Error(`Can't parse ${r} as it is not part of the known types`);if((r===`to-boolean`||r===`to-string`)&&t.length!==2)return n.error(`Expected one argument.`);let i=i0[r],a=[];for(let e=1;e4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Z1(t[0],t[1],t[2],t[3]),!n))return new R1(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new K1(n||`Could not parse color from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}case`padding`:{let t;for(let n of this.args){t=n.evaluate(e);let r=U1.parse(t);if(r)return r}throw new K1(`Could not parse padding from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}case`numberArray`:{let t;for(let n of this.args){t=n.evaluate(e);let r=W1.parse(t);if(r)return r}throw new K1(`Could not parse numberArray from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}case`colorArray`:{let t;for(let n of this.args){t=n.evaluate(e);let r=G1.parse(t);if(r)return r}throw new K1(`Could not parse colorArray from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}case`variableAnchorOffsetCollection`:{let t;for(let n of this.args){t=n.evaluate(e);let r=J1.parse(t);if(r)return r}throw new K1(`Could not parse variableAnchorOffsetCollection from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}case`number`:{let t=null;for(let n of this.args){if(t=n.evaluate(e),t===null)return 0;let r=Number(t);if(!isNaN(r))return r}throw new K1(`Could not convert ${JSON.stringify(t)} to number.`,this.key)}case`formatted`:return H1.fromString(e0(this.args[0].evaluate(e)));case`resolvedImage`:return Y1.fromString(e0(this.args[0].evaluate(e)));case`projectionDefinition`:{let t=this.args[0].evaluate(e);if(X1.parse(t))return t;throw new K1(`Could not parse projectionDefinition from value '${typeof t==`string`?t:JSON.stringify(t)}'`,this.key)}default:return e0(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}},o0=[`Unknown`,`Point`,`LineString`,`Polygon`],s0=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&`id`in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type==`number`?o0[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&`geometry`in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=R1.parse(e),this._parseColorCache.set(e,t)),t}},c0=class e{constructor(e,t,n=[],r,i=new w_,a=[]){this.registry=e,this.path=n,this.key=n.map(e=>`[${e}]`).join(``),this.scope=i,this.errors=a,this.expectedType=r,this._isConstant=t}parse(e,t,n,r,i={}){return t==null?this._parse(e,i):this.concat(t,n,r)._parse(e,i)}_parse(e,t){(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`)&&(e=[`literal`,e]);let n=this.key;function r(e,t,r){return r===`assert`?new r0(t,[e],n):r===`coerce`?new a0(t,[e],n):e}if(Array.isArray(e)){if(e.length===0)return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);let n=e[0];if(typeof n!=`string`)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let i=S1(this.registry,n);if(i){let n=i.parse(e,this);if(!n)return null;if(this.expectedType){let e=this.expectedType,i=n.type;if((e.kind===`string`||e.kind===`number`||e.kind===`boolean`||e.kind===`object`||e.kind===`array`)&&i.kind===`value`)n=r(n,e,t.typeAnnotation||`assert`);else if(e.kind===`projectionDefinition`&&[`string`,`array`,`value`].includes(i.kind)||[`color`,`formatted`,`resolvedImage`].includes(e.kind)&&[`value`,`string`].includes(i.kind)||[`padding`,`numberArray`].includes(e.kind)&&[`value`,`number`,`array`].includes(i.kind)||e.kind===`colorArray`&&[`value`,`string`,`array`].includes(i.kind)||e.kind===`variableAnchorOffsetCollection`&&[`value`,`array`].includes(i.kind))n=r(n,e,t.typeAnnotation||`coerce`);else if(this.checkSubtype(e,i))return null}if(!(n instanceof t0)&&n.type.kind!==`resolvedImage`&&this._isConstant(n)){let e=new s0;try{n=new t0(n.type,n.evaluate(e))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return e===void 0?this.error(`'undefined' value invalid. Use null instead.`):typeof e==`object`?this.error(`Bare objects invalid. Use ["literal", {...}] instead.`):this.error(`Expected an array, but found ${typeof e} instead.`)}concat(t,n,r){let i=typeof t==`number`?this.path.concat(t):this.path,a=r?this.scope.concat(r):this.scope;return new e(this.registry,this._isConstant,i,n||null,a,this.errors)}error(e,...t){let n=`${this.key}${t.map(e=>`[${e}]`).join(``)}`;this.errors.push(new C_(n,e))}checkSubtype(e,t){let n=U_(e,t);return n&&this.error(n),n}},l0=class e{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let t of this.bindings)e(t[1]);e(this.result)}static parse(t,n){if(t.length<4)return n.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let r=[];for(let e=1;e=n.length)throw new K1(`Array index out of bounds: ${t} > ${n.length-1}.`,this.key);if(t!==Math.floor(t))throw new K1(`Array index must be an integer, but found ${t} instead.`,this.key);return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}},f0=class e{constructor(e,t,n){this.needle=e,this.haystack=t,this.key=n,this.type=D_}static parse(t,n){if(t.length!==3)return n.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=n.parse(t[1],1,j_),i=n.parse(t[2],2,j_);return!r||!i?null:W_(r.type,[D_,E_,J,T_,j_])?new e(r,i,n.key):n.error(`Expected first argument to be of type boolean, string, number or null, but found ${V_(r.type)} instead`)}evaluate(e){let t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!n)return!1;if(!G_(t,[`boolean`,`string`,`number`,`null`]))throw new K1(`Expected first argument to be of type boolean, string, number or null, but found ${V_($1(t))} instead.`,this.key);if(!G_(n,[`string`,`array`]))throw new K1(`Expected second argument to be of type array or string, but found ${V_($1(n))} instead.`,this.key);return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}},p0=class e{constructor(e,t,n,r){this.needle=e,this.haystack=t,this.key=n,this.fromIndex=r,this.type=J}static parse(t,n){if(t.length<=2||t.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=n.parse(t[1],1,j_),i=n.parse(t[2],2,j_);if(!r||!i)return null;if(!W_(r.type,[D_,E_,J,T_,j_]))return n.error(`Expected first argument to be of type boolean, string, number or null, but found ${V_(r.type)} instead`);if(t.length===4){let a=n.parse(t[3],3,J);return a?new e(r,i,n.key,a):null}return new e(r,i,n.key)}evaluate(e){let t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!G_(t,[`boolean`,`string`,`number`,`null`]))throw new K1(`Expected first argument to be of type boolean, string, number or null, but found ${V_($1(t))} instead.`,this.key);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(e)),G_(n,[`string`])){let e=n.indexOf(t,r);return e===-1?-1:[...n.slice(0,e)].length}if(G_(n,[`array`]))return n.indexOf(t,r);throw new K1(`Expected second argument to be of type array or string, but found ${V_($1(n))} instead.`,this.key)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}},m0=class e{constructor(e,t,n,r,i,a){this.inputType=e,this.type=t,this.input=n,this.cases=r,this.outputs=i,this.otherwise=a}static parse(t,n){if(t.length<5)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return n.error(`Expected an even number of arguments.`);let r,i;n.expectedType&&n.expectedType.kind!==`value`&&(i=n.expectedType);let a={},o=[];for(let e=2;e2**53-1)return l.error(`Branch labels must be integers no larger than ${2**53-1}.`);if(typeof e==`number`&&Math.floor(e)!==e)return l.error(`Numeric branch labels must be integer values.`);if(!r)r=$1(e);else if(l.checkSubtype(r,$1(e)))return null;if(a[String(e)]!==void 0)return l.error(`Branch labels must be unique.`);a[String(e)]=o.length}let u=n.parse(c,e,i);if(!u)return null;i||=u.type,o.push(u)}let s=n.parse(t[1],1,j_);if(!s)return null;let c=n.parse(t[t.length-1],t.length-1,i);return!c||s.type.kind!==`value`&&n.concat(1).checkSubtype(r,s.type)?null:new e(r,i,s,a,o,c)}evaluate(e){let t=this.input.evaluate(e);return($1(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}},h0=class e{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}static parse(t,n){if(t.length<4)return n.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return n.error(`Expected an odd number of arguments.`);let r;n.expectedType&&n.expectedType.kind!==`value`&&(r=n.expectedType);let i=[];for(let e=1;et.outputDefined())&&this.otherwise.outputDefined()}},g0=class e{constructor(e,t,n,r,i){this.type=e,this.input=t,this.beginIndex=n,this.key=r,this.endIndex=i}static parse(t,n){if(t.length<=2||t.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);let r=n.parse(t[1],1,j_),i=n.parse(t[2],2,J);if(!r||!i)return null;if(!W_(r.type,[B_(j_),E_,j_]))return n.error(`Expected first argument to be of type array or string, but found ${V_(r.type)} instead`);if(t.length===4){let a=n.parse(t[3],3,J);return a?new e(r.type,r,i,n.key,a):null}return new e(r.type,r,i,n.key)}evaluate(e){let t=this.input.evaluate(e),n=this.beginIndex.evaluate(e),r;if(this.endIndex&&(r=this.endIndex.evaluate(e)),G_(t,[`string`]))return[...t].slice(n,r).join(``);if(G_(t,[`array`]))return t.slice(n,r);throw new K1(`Expected first argument to be of type array or string, but found ${V_($1(t))} instead.`,this.key)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}};function _0(e,t,n){let r=e.length-1,i=0,a=r,o=0,s,c;for(;i<=a;)if(o=Math.floor((i+a)/2),s=e[o],c=e[o+1],s<=t){if(o===r||tt)a=o-1;else throw new K1(`Input is not a number.`,n);return 0}var v0=class e{constructor(e,t,n,r){this.type=e,this.input=t,this.key=r,this.labels=[],this.outputs=[];for(let[e,t]of n)this.labels.push(e),this.outputs.push(t)}static parse(t,n){if(t.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return n.error(`Expected an even number of arguments.`);let r=n.parse(t[1],1,J);if(!r)return null;let i=[],a=null;n.expectedType&&n.expectedType.kind!==`value`&&(a=n.expectedType);for(let e=1;e=r)return n.error(`Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.`,s);let l=n.parse(o,c,a);if(!l)return null;a||=l.type,i.push([r,l])}return new e(a,r,i,n.key)}evaluate(e){let t=this.labels,n=this.outputs;if(t.length===1)return n[0].evaluate(e);let r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);let i=t.length;return r>=t[i-1]?n[i-1].evaluate(e):n[_0(t,r,this.key)].evaluate(e)}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}};function y0(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let n=e;for(let r=0;r<8;r++){let r=((o*n+a)*n+i)*n-e;if(Math.abs(r)s?r=n:u=n,n=(r+u)*.5}return((l*n+c)*n+s)*n}}function b0(e,t){if(!(e instanceof t))return!1;try{return t.prototype.valueOf.call(e),!0}catch{return!1}}function x0(e){return b0(e,Number)||b0(e,String)||b0(e,Boolean)?e.valueOf():e}function S0(e){if(Array.isArray(e))return e.map(S0);let t=x0(e);return t instanceof Object?Object.fromEntries(Object.entries(t).map(([e,t])=>[e,S0(t)])):t}function C0(e){let t=x0(e);return typeof t==`object`&&t?JSON.stringify(t):String(t)}var w0=class e{constructor(e,t,n,r,i,a){this.type=e,this.operator=t,this.interpolation=n,this.input=r,this.key=a,this.labels=[],this.outputs=[];for(let[e,t]of i)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let i=0;if(e.name===`exponential`)i=T0(t,e.base,n,r);else if(e.name===`linear`)i=T0(t,1,n,r);else if(e.name===`cubic-bezier`){let a=e.controlPoints;i=y0(a[0],a[1],a[2],a[3])(T0(t,1,n,r))}return i}static parse(t,n){let[r,i,a,...o]=t;if(!Array.isArray(i)||i.length===0)return n.error(`Expected an interpolation type expression.`,1);if(i[0]===`linear`)i={name:`linear`};else if(i[0]===`exponential`){let e=i[1];if(typeof e!=`number`)return n.error(`Exponential interpolation requires a numeric base.`,1,1);i={name:`exponential`,base:e}}else if(i[0]===`cubic-bezier`){let e=i.slice(1);if(e.length!==4||e.some(e=>typeof e!=`number`||e<0||e>1))return n.error(`Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.`,1);i={name:`cubic-bezier`,controlPoints:e}}else return n.error(`Unknown interpolation type ${C0(i[0])}`,1,0);if(t.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return n.error(`Expected an even number of arguments.`);if(a=n.parse(a,2,J),!a)return null;let s=[],c=null;(r===`interpolate-hcl`||r===`interpolate-lab`||r===`interpolate-oklch`||r===`interpolate-oklab`)&&n.expectedType!=I_?c=O_:n.expectedType&&n.expectedType.kind!==`value`&&(c=n.expectedType);for(let e=0;e=t)return n.error(`Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.`,i);let l=n.parse(r,a,c);if(!l)return null;c||=l.type,s.push([t,l])}return!K_(c,J)&&!K_(c,k_)&&!K_(c,O_)&&!K_(c,F_)&&!K_(c,L_)&&!K_(c,I_)&&!K_(c,z_)&&!K_(c,B_(J))?n.error(`Type ${V_(c)} is not interpolatable.`):new e(c,r,i,a,s,n.key)}evaluate(t){let n=this.labels,r=this.outputs;if(n.length===1)return r[0].evaluate(t);let i=this.input.evaluate(t);if(i<=n[0])return r[0].evaluate(t);let a=n.length;if(i>=n[a-1])return r[a-1].evaluate(t);let o=_0(n,i,this.key),s=n[o],c=n[o+1],l=e.interpolationFactor(this.interpolation,i,s,c),u=r[o].evaluate(t),d=r[o+1].evaluate(t);switch(this.operator){case`interpolate`:switch(this.type.kind){case`number`:return F1(u,d,l);case`color`:return R1.interpolate(u,d,l);case`padding`:return U1.interpolate(u,d,l);case`colorArray`:return G1.interpolate(u,d,l);case`numberArray`:return W1.interpolate(u,d,l);case`variableAnchorOffsetCollection`:return J1.interpolate(u,d,l,this.key);case`array`:return I1(u,d,l);case`projectionDefinition`:return X1.interpolate(u,d,l)}case`interpolate-hcl`:switch(this.type.kind){case`color`:return R1.interpolate(u,d,l,`hcl`);case`colorArray`:return G1.interpolate(u,d,l,`hcl`)}case`interpolate-lab`:switch(this.type.kind){case`color`:return R1.interpolate(u,d,l,`lab`);case`colorArray`:return G1.interpolate(u,d,l,`lab`)}case`interpolate-oklch`:switch(this.type.kind){case`color`:return R1.interpolate(u,d,l,`oklch`);case`colorArray`:return G1.interpolate(u,d,l,`oklch`)}case`interpolate-oklab`:switch(this.type.kind){case`color`:return R1.interpolate(u,d,l,`oklab`);case`colorArray`:return G1.interpolate(u,d,l,`oklab`)}}}eachChild(e){e(this.input);for(let t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}};function T0(e,t,n,r){let i=r-n,a=e-n;return i===0?0:t===1?a/i:(t**+a-1)/(t**+i-1)}var E0={color:R1.interpolate,number:F1,padding:U1.interpolate,numberArray:W1.interpolate,colorArray:G1.interpolate,variableAnchorOffsetCollection:J1.interpolate,array:I1},D0=class e{constructor(e,t){this.type=e,this.args=t}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=null,i=n.expectedType;i&&i.kind!==`value`&&(r=i);let a=[];for(let e of t.slice(1)){let t=n.parse(e,1+a.length,r,void 0,{typeAnnotation:`omit`});if(!t)return null;r||=t.type,a.push(t)}if(!r)throw Error(`No output type`);return i&&a.some(e=>U_(i,e.type))?new e(j_,a):new e(r,a)}evaluate(e){let t=null,n=0,r;for(let i of this.args)if(n++,t=i.evaluate(e),t&&t instanceof Y1&&!t.available&&(r||=t.name,t=null,n===this.args.length&&(t=r)),t!==null)break;return t}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}};function O0(e,t){return e===`==`||e===`!=`?t.kind===`boolean`||t.kind===`string`||t.kind===`number`||t.kind===`null`||t.kind===`value`:t.kind===`string`||t.kind===`number`||t.kind===`value`}function k0(e,t,n){return t===n}function A0(e,t,n){return t!==n}function j0(e,t,n){return tn}function N0(e,t,n){return t<=n}function P0(e,t,n){return t>=n}function F0(e,t,n,r){return r.compare(t,n)===0}function I0(e,t,n,r){return!F0(e,t,n,r)}function L0(e,t,n,r){return r.compare(t,n)<0}function R0(e,t,n,r){return r.compare(t,n)>0}function z0(e,t,n,r){return r.compare(t,n)<=0}function B0(e,t,n,r){return r.compare(t,n)>=0}function V0(e,t,n){let r=e!==`==`&&e!==`!=`;return class i{constructor(e,t,n,r){this.lhs=e,this.rhs=t,this.key=n,this.collator=r,this.type=D_,this.hasUntypedArgument=e.type.kind===`value`||t.type.kind===`value`}static parse(e,t){if(e.length!==3&&e.length!==4)return t.error(`Expected two or three arguments.`);let n=e[0],a=t.parse(e[1],1,j_);if(!a)return null;if(!O0(n,a.type))return t.concat(1).error(`"${n}" comparisons are not supported for type '${V_(a.type)}'.`);let o=t.parse(e[2],2,j_);if(!o)return null;if(!O0(n,o.type))return t.concat(2).error(`"${n}" comparisons are not supported for type '${V_(o.type)}'.`);if(a.type.kind!==o.type.kind&&a.type.kind!==`value`&&o.type.kind!==`value`)return t.error(`Cannot compare types '${V_(a.type)}' and '${V_(o.type)}'.`);r&&(a.type.kind===`value`&&o.type.kind!==`value`?a=new r0(o.type,[a],t.key):a.type.kind!==`value`&&o.type.kind===`value`&&(o=new r0(a.type,[o],t.key)));let s=null;if(e.length===4){if(a.type.kind!==`string`&&o.type.kind!==`string`&&a.type.kind!==`value`&&o.type.kind!==`value`)return t.error(`Cannot use collator to compare non-string types.`);if(s=t.parse(e[3],3,N_),!s)return null}return new i(a,o,t.key,s)}evaluate(i){let a=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){let t=$1(a),n=$1(o);if(t.kind!==n.kind||t.kind!==`string`&&t.kind!==`number`)throw new K1(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${n.kind}) instead.`,this.key)}if(this.collator&&!r&&this.hasUntypedArgument){let e=$1(a),n=$1(o);if(e.kind!==`string`||n.kind!==`string`)return t(i,a,o)}return this.collator?n(i,a,o,this.collator.evaluate(i)):t(i,a,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}var H0=V0(`==`,k0,F0),U0=V0(`!=`,A0,I0),W0=V0(`<`,j0,L0),G0=V0(`>`,M0,R0),K0=V0(`<=`,N0,z0),q0=V0(`>=`,P0,B0),J0=class e{constructor(e,t,n){this.type=N_,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=t}static parse(t,n){if(t.length!==2)return n.error(`Expected one argument.`);let r=t[1];if(typeof r!=`object`||!r||Array.isArray(r))return n.error(`Collator options argument must be an object.`);let i=n.parse(r[`case-sensitive`]!==void 0&&r[`case-sensitive`],1,D_);if(!i)return null;let a=n.parse(r[`diacritic-sensitive`]!==void 0&&r[`diacritic-sensitive`],1,D_);if(!a)return null;let o=null;return r.locale&&(o=n.parse(r.locale,1,E_),!o)?null:new e(i,a,o)}evaluate(e){return new z1(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}},Y0=class e{constructor(e,t,n,r,i,a){this.type=E_,this.number=e,this.locale=t,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=a}static parse(t,n){if(t.length!==3)return n.error(`Expected two arguments.`);let r=n.parse(t[1],1,J);if(!r)return null;let i=t[2];if(typeof i!=`object`||!i||Array.isArray(i))return n.error(`NumberFormat options argument must be an object.`);let a=null;if(i.locale&&(a=n.parse(i.locale,1,E_),!a))return null;let o=null;if(i.currency&&(o=n.parse(i.currency,1,E_),!o))return null;let s=null;if(i.unit&&(s=n.parse(i.unit,1,E_),!s))return null;if(o&&s)return n.error("NumberFormat options `currency` and `unit` are mutually exclusive");let c=null;if(i[`min-fraction-digits`]&&(c=n.parse(i[`min-fraction-digits`],1,J),!c))return null;let l=null;return i[`max-fraction-digits`]&&(l=n.parse(i[`max-fraction-digits`],1,J),!l)?null:new e(r,a,o,s,c,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?`currency`:this.unit?`unit`:`decimal`,currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}},X0=class e{constructor(e){this.type=P_,this.sections=e}static parse(t,n){if(t.length<2)return n.error(`Expected at least one argument.`);let r=t[1];if(!Array.isArray(r)&&typeof r==`object`)return n.error(`First argument must be an image or text section.`);let i=[],a=!1;for(let e=1;e<=t.length-1;++e){let r=t[e];if(a&&typeof r==`object`&&r&&!Array.isArray(r)){a=!1;let e=null;if(r[`font-scale`]&&(e=n.parse(r[`font-scale`],1,J),!e))return null;let t=null;if(r[`text-font`]&&(t=n.parse(r[`text-font`],1,B_(E_)),!t))return null;let o=null;if(r[`text-color`]&&(o=n.parse(r[`text-color`],1,O_),!o))return null;let s=null;if(r[`vertical-align`]){if(typeof r[`vertical-align`]==`string`&&!B1.includes(r[`vertical-align`]))return n.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${r[`vertical-align`]}' instead.`);if(s=n.parse(r[`vertical-align`],1,E_),!s)return null}let c=i[i.length-1];c.scale=e,c.font=t,c.textColor=o,c.verticalAlign=s}else{let r=n.parse(t[e],1,j_);if(!r)return null;let o=r.type.kind;if(o!==`string`&&o!==`value`&&o!==`null`&&o!==`resolvedImage`)return n.error(`Formatted text type must be 'string', 'value', 'image' or 'null'.`);a=!0,i.push({content:r,scale:null,font:null,textColor:null,verticalAlign:null})}}return new e(i)}evaluate(e){return new H1(this.sections.map(t=>{let n=t.content.evaluate(e);return $1(n)===R_?new V1(``,n,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new V1(e0(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(`,`):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)}))}eachChild(e){for(let t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}},Z0=class e{constructor(e){this.type=R_,this.input=e}static parse(t,n){if(t.length!==2)return n.error(`Expected two arguments.`);let r=n.parse(t[1],1,E_);return r?new e(r):n.error(`No image name provided.`)}evaluate(e){let t=this.input.evaluate(e),n=Y1.fromString(t);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(t)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}},Q0=class e{constructor(e,t){this.input=e,this.key=t,this.type=J}static parse(t,n){if(t.length!==2)return n.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=n.parse(t[1],1);return r?r.type.kind!==`array`&&r.type.kind!==`string`&&r.type.kind!==`value`?n.error(`Expected argument of type string or array, but found ${V_(r.type)} instead.`):new e(r,n.key):null}evaluate(e){let t=this.input.evaluate(e);if(typeof t==`string`)return[...t].length;if(Array.isArray(t))return t.length;throw new K1(`Expected value to be of type string or array, but found ${V_($1(t))} instead.`,this.key)}eachChild(e){e(this.input)}outputDefined(){return!1}},$0={Point:0,MultiPoint:1,LineString:1,MultiLineString:2,Polygon:2,MultiPolygon:3};function ev(e,t){return Array.isArray(e)?t===0?e.length>=2&&e.every(e=>typeof e==`number`):e.every(e=>ev(e,t-1)):!1}function tv(e){if(typeof e!=`object`||!e)return!1;let{type:t,coordinates:n}=e;return typeof t==`string`&&Object.keys($0).includes(t)&&ev(n,$0[t])}function nv(e){if(typeof e!=`object`||!e)return null;let{type:t,geometry:n,features:r}=e,i;if(t===`FeatureCollection`){if(!Array.isArray(r))return null;i=[];for(let e of r){if(typeof e!=`object`||!e)return null;e.geometry!==null&&i.push(e.geometry)}}else if(t===`Feature`)i=[n];else return tv(e)?[e]:null;let a=[];for(let e of i)if(tv(e))a.push(e);else if(e?.type!==`GeometryCollection`)return null;return a}var rv=8192;function iv(e,t){let n=ov(e[0]),r=cv(e[1]),i=2**t.z;return[Math.round(n*i*rv),Math.round(r*i*rv)]}function av(e,t){let n=2**t.z,r=(e[0]/rv+t.x)/n,i=(e[1]/rv+t.y)/n;return[sv(r),lv(i)]}function ov(e){return(180+e)/360}function sv(e){return e*360-180}function cv(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function lv(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}function uv(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function dv(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function fv(e,t,n){return t[1]>e[1]!=n[1]>e[1]&&e[0]<(n[0]-t[0])*(e[1]-t[1])/(n[1]-t[1])+t[0]}function pv(e,t,n){let r=e[0]-t[0],i=e[1]-t[1],a=e[0]-n[0],o=e[1]-n[1];return r*o-a*i===0&&r*a<=0&&i*o<=0}function mv(e,t,n,r){let i=[t[0]-e[0],t[1]-e[1]];return bv([r[0]-n[0],r[1]-n[1]],i)!==0&&!!(xv(e,t,n,r)&&xv(n,r,e,t))}function hv(e,t,n){for(let r of n)for(let n=0;n0&&d<0||u<0&&d>0}function Sv(e,t,n){let r=[];for(let i=0;in[2]){let t=r*.5,i=e[0]-n[0]>t?-r:n[0]-e[0]>t?r:0;i===0&&(i=e[0]-n[2]>t?-r:n[2]-e[0]>t?r:0),e[0]+=i}uv(t,e)}function Tv(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}function Ev(e,t,n,r){let i=2**r.z*rv,a=[r.x*rv,r.y*rv],o=[];for(let r of e)for(let e of r){let r=[e.x+a[0],e.y+a[1]];wv(r,t,n,i),o.push(r)}return o}function Dv(e,t,n,r){let i=2**r.z*rv,a=[r.x*rv,r.y*rv],o=[];for(let n of e){let e=[];for(let r of n){let n=[r.x+a[0],r.y+a[1]];uv(t,n),e.push(n)}o.push(e)}if(t[2]-t[0]<=i/2){Tv(t);for(let e of o)for(let r of e)wv(r,t,n,i)}return o}function Ov(e,t){let n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(t.type===`Polygon`){let a=Sv(t.coordinates,r,i),o=Ev(e.geometry(),n,r,i);if(!dv(n,r))return!1;for(let e of o)if(!gv(e,a))return!1}if(t.type===`MultiPolygon`){let a=Cv(t.coordinates,r,i),o=Ev(e.geometry(),n,r,i);if(!dv(n,r))return!1;for(let e of o)if(!_v(e,a))return!1}return!0}function kv(e,t){let n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(t.type===`Polygon`){let a=Sv(t.coordinates,r,i),o=Dv(e.geometry(),n,r,i);if(!dv(n,r))return!1;for(let e of o)if(!vv(e,a))return!1}if(t.type===`MultiPolygon`){let a=Cv(t.coordinates,r,i),o=Dv(e.geometry(),n,r,i);if(!dv(n,r))return!1;for(let e of o)if(!yv(e,a))return!1}return!0}var Av=class e{constructor(e,t){this.type=D_,this.geojson=e,this.geometries=t}static parse(t,n){if(t.length!==2)return n.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);let r=Q1(t[1])?nv(t[1]):null;if(r){let n=t[1];if(n.type===`FeatureCollection`){let t=[];for(let{type:e,coordinates:n}of r)e===`Polygon`&&t.push(n),e===`MultiPolygon`&&t.push(...n);if(t.length)return new e(n,{type:`MultiPolygon`,coordinates:t})}else{let t=r[0];if(t?.type===`Polygon`||t?.type===`MultiPolygon`)return new e(n,t)}}return n.error(`'within' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return Ov(e,this.geometries);if(e.geometryType()===`LineString`)return kv(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},jv=class{constructor(e=[],t=(e,t)=>et)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e=0)break;t[e]=t[r],e=r}t[e]=i}};function Mv(e,t,n=0,r=e.length-1,i=gee){for(;r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);Mv(e,t,Math.max(n,Math.floor(t-o*c/a+l)),Math.min(r,Math.floor(t+(a-o)*c/a+l)),i)}let a=e[t],o=n,s=r;for(Nv(e,n,t),i(e[r],a)>0&&Nv(e,n,r);o0;)s--}i(e[n],a)===0?Nv(e,n,s):(s++,Nv(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function Nv(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function gee(e,t){return et)}function Pv(e,t){if(e.length<=1)return[e];let n=[],r,i;for(let t of e){let e=vee(t);e!==0&&(t.area=Math.abs(e),i===void 0&&(i=e<0),i===e<0?(r&&n.push(r),r=[t]):r.push(t))}if(r&&n.push(r),t>1)for(let e=0;e1?(c=e[s+1][0],l=e[s+1][1]):f>0&&(c+=u/this.kx*f,l+=d/this.ky*f)),u=this.wrap(t[0]-c)*this.kx,d=(t[1]-l)*this.ky;let p=u*u+d*d;p180;)e-=360;return e}};function Lv(e,t){return t[0]-e[0]}function Rv(e){return e[1]-e[0]+1}function zv(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];let n=Rv(e);if(t){if(n===2)return[e,null];let t=Math.floor(n/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(n===1)return[e,null];let r=Math.floor(n/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function Vv(e,t){if(!zv(t,e.length))return[1/0,1/0,-1/0,-1/0];let n=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)uv(n,e[r]);return n}function Hv(e){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)for(let e of n)uv(t,e);return t}function Uv(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Wv(e,t,n){if(!Uv(e)||!Uv(t))return NaN;let r=0,i=0;return e[2]t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]=r)return r;if(dv(i,a)){if(qv(e,t))return 0}else if(qv(t,e))return 0;let o=1/0;for(let r of e)for(let e=0,i=r.length,a=i-1;e0;){let i=o.pop();if(i[0]>=a)continue;let c=i[1],l=t?50:100;if(Rv(c)<=l){if(!zv(c,e.length))return NaN;if(t){let t=See(e,c,n,r);if(isNaN(t)||t===0)return t;a=Math.min(a,t)}else for(let t=c[0];t<=c[1];++t){let i=xee(e[t],n,r);if(a=Math.min(a,i),a===0)return 0}}else{let n=Bv(c,t);Jv(o,a,r,e,s,n[0]),Jv(o,a,r,e,s,n[1])}}return a}function Zv(e,t,n,r,i,a=1/0){let o=Math.min(a,i.distance(e[0],n[0]));if(o===0)return o;let s=new jv([[0,[0,e.length-1],[0,n.length-1]]],Lv);for(;s.length>0;){let a=s.pop();if(a[0]>=o)continue;let c=a[1],l=a[2],u=t?50:100,d=r?50:100;if(Rv(c)<=u&&Rv(l)<=d){if(!zv(c,e.length)&&zv(l,n.length))return NaN;let a;if(t&&r)a=yee(e,c,n,l,i),o=Math.min(o,a);else if(t&&!r){let t=e.slice(c[0],c[1]+1);for(let e=l[0];e<=l[1];++e)if(a=Gv(n[e],t,i),o=Math.min(o,a),o===0)return o}else if(!t&&r){let t=n.slice(l[0],l[1]+1);for(let n=c[0];n<=c[1];++n)if(a=Gv(e[n],t,i),o=Math.min(o,a),o===0)return o}else a=bee(e,c,n,l,i),o=Math.min(o,a)}else{let a=Bv(c,t),u=Bv(l,r);Yv(s,o,i,e,n,a[0],u[0]),Yv(s,o,i,e,n,a[0],u[1]),Yv(s,o,i,e,n,a[1],u[0]),Yv(s,o,i,e,n,a[1],u[1])}}return o}function wee(e,t){let n=e.geometry(),r=n.flat().map(t=>av([t.x,t.y],e.canonical));if(n.length===0)return NaN;let i=new Iv(r[0][1]),a=1/0;for(let e of t){switch(e.type){case`Point`:a=Math.min(a,Zv(r,!1,[e.coordinates],!1,i,a));break;case`LineString`:a=Math.min(a,Zv(r,!1,e.coordinates,!0,i,a));break;case`Polygon`:a=Math.min(a,Xv(r,!1,e.coordinates,i,a))}if(a===0)return a}return a}function Tee(e,t){let n=e.geometry(),r=n.flat().map(t=>av([t.x,t.y],e.canonical));if(n.length===0)return NaN;let i=new Iv(r[0][1]),a=1/0;for(let e of t){switch(e.type){case`Point`:a=Math.min(a,Zv(r,!0,[e.coordinates],!1,i,a));break;case`LineString`:a=Math.min(a,Zv(r,!0,e.coordinates,!0,i,a));break;case`Polygon`:a=Math.min(a,Xv(r,!0,e.coordinates,i,a))}if(a===0)return a}return a}function Eee(e,t){let n=e.geometry();if(n.length===0||n[0].length===0)return NaN;let r=Pv(n,0).map(t=>t.map(t=>t.map(t=>av([t.x,t.y],e.canonical)))),i=new Iv(r[0][0][0][1]),a=1/0;for(let e of t)for(let t of r){switch(e.type){case`Point`:a=Math.min(a,Xv([e.coordinates],!1,t,i,a));break;case`LineString`:a=Math.min(a,Xv(e.coordinates,!0,t,i,a));break;case`Polygon`:a=Math.min(a,Cee(t,e.coordinates,i,a))}if(a===0)return a}return a}function Dee(e){return e.type===`MultiPolygon`?e.coordinates.map(e=>({type:`Polygon`,coordinates:e})):e.type===`MultiLineString`?e.coordinates.map(e=>({type:`LineString`,coordinates:e})):e.type===`MultiPoint`?e.coordinates.map(e=>({type:`Point`,coordinates:e})):[e]}var Qv=class e{constructor(e,t){this.type=J,this.geojson=e,this.geometries=t}static parse(t,n){if(t.length!==2)return n.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);let r=Q1(t[1])?nv(t[1]):null;return r?new e(t[1],r.flatMap(e=>Dee(e))):n.error(`'distance' expression requires valid geojson object that contains polygon geometry type.`)}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()===`Point`)return wee(e,this.geometries);if(e.geometryType()===`LineString`)return Tee(e,this.geometries);if(e.geometryType()===`Polygon`)return Eee(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},Oee=class e{constructor(e){let t=null;for(let n of e)if(!t)t=n.type;else if(t===n.type)continue;else{t=j_;break}this.type=B_(t??j_,e.length),this.arr=e}static parse(t,n){if(t.length!==2)return n.error(`'semiliteral' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Q1(t[1]))return n.error(`invalid value of type "${typeof t[1]}"`);let r=t[1],i=$1(r);if(i.kind===`array`){let t=r,i=n.concat(1),a=[];for(let e=0;et.evaluate(e))}eachChild(e){this.arr.forEach(e)}outputDefined(){return this.arr.every(e=>e.outputDefined())}},$v=class e{constructor(e){this.key=e,this.type=j_}static parse(t,n){if(t.length!==2)return n.error(`Expected 1 argument, but found ${t.length-1} instead.`);let r=t[1];return r==null?n.error(`Global state property must be defined.`):typeof r==`string`?new e(r):n.error(`Global state property must be string, but found ${typeof t[1]} instead.`)}evaluate(e){let t=e.globals?.globalState;return!t||Object.keys(t).length===0?null:S1(t,this.key)??null}eachChild(){}outputDefined(){return!1}},ey={"==":H0,"!=":U0,">":G0,"<":W0,">=":q0,"<=":K0,array:r0,at:d0,boolean:r0,case:h0,coalesce:D0,collator:J0,format:X0,image:Z0,in:f0,"index-of":p0,interpolate:w0,"interpolate-hcl":w0,"interpolate-lab":w0,"interpolate-oklch":w0,"interpolate-oklab":w0,length:Q0,let:l0,literal:t0,match:m0,number:r0,"number-format":Y0,object:r0,semiliteral:Oee,slice:g0,step:v0,string:r0,"to-boolean":a0,"to-color":a0,"to-number":a0,"to-string":a0,var:u0,within:Av,distance:Qv,"global-state":$v},ty=class e{constructor(e,t,n,r,i){this.name=e,this.type=t,this._evaluate=n,this.args=r,this.key=i}evaluate(e){return this._evaluate(e,this.args,this.key)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(t,n){let r=t[0],i=e.definitions[r];if(!i)return n.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let a=Array.isArray(i)?i[0]:i.type,o=Array.isArray(i)?[[i[1],i[2]]]:i.overloads,s=o.filter(([e])=>!Array.isArray(e)||e.length===t.length-1),c=null;for(let[i,o]of s){c=new c0(n.registry,oy,n.path,null,n.scope);let s=[],l=!1;for(let e=1;eAee(e)).join(` | `),r=[];for(let e=1;e>1;if(t[i]===e)return!0;t[i]>e?r=i-1:n=i+1}return!1}function ay(e){return{type:e}}ty.register(ey,{error:[M_,[E_],(e,[t],n)=>{throw new K1(t.evaluate(e),n)}],typeof:[E_,[j_],(e,[t])=>V_($1(t.evaluate(e)))],"to-rgba":[B_(J,4),[O_],(e,[t])=>{let[n,r,i,a]=t.evaluate(e).rgb;return[n*255,r*255,i*255,a]}],rgb:[O_,[J,J,J],ny],rgba:[O_,[J,J,J,J],ny],has:{type:D_,overloads:[[[E_],(e,[t])=>ry(t.evaluate(e),e.properties())],[[E_,A_],(e,[t,n])=>ry(t.evaluate(e),n.evaluate(e))]]},get:{type:j_,overloads:[[[E_],(e,[t])=>iy(t.evaluate(e),e.properties())],[[E_,A_],(e,[t,n])=>iy(t.evaluate(e),n.evaluate(e))]]},"feature-state":[j_,[E_],(e,[t])=>iy(t.evaluate(e),e.featureState||{})],properties:[A_,[],e=>e.properties()],"geometry-type":[E_,[],e=>e.geometryType()],id:[j_,[],e=>e.id()],zoom:[J,[],e=>e.globals.zoom],pitch:[J,[],e=>e.globals.pitch||0],bearing:[J,[],e=>e.globals.bearing||0],"heatmap-density":[J,[],e=>e.globals.heatmapDensity||0],elevation:[J,[],e=>e.globals.elevation||0],"line-progress":[J,[],e=>e.globals.lineProgress||0],accumulated:[j_,[],e=>e.globals.accumulated===void 0?null:e.globals.accumulated],"+":[J,ay(J),(e,t)=>{let n=0;for(let r of t)n+=r.evaluate(e);return n}],"*":[J,ay(J),(e,t)=>{let n=1;for(let r of t)n*=r.evaluate(e);return n}],"-":{type:J,overloads:[[[J,J],(e,[t,n])=>t.evaluate(e)-n.evaluate(e)],[[J],(e,[t])=>-t.evaluate(e)]]},"/":[J,[J,J],(e,[t,n])=>t.evaluate(e)/n.evaluate(e)],"%":[J,[J,J],(e,[t,n])=>t.evaluate(e)%n.evaluate(e)],ln2:[J,[],()=>Math.LN2],pi:[J,[],()=>Math.PI],e:[J,[],()=>Math.E],"^":[J,[J,J],(e,[t,n])=>t.evaluate(e)**+n.evaluate(e)],sqrt:[J,[J],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[J,[J],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[J,[J],(e,[t])=>Math.log(t.evaluate(e))],log2:[J,[J],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[J,[J],(e,[t])=>Math.sin(t.evaluate(e))],cos:[J,[J],(e,[t])=>Math.cos(t.evaluate(e))],tan:[J,[J],(e,[t])=>Math.tan(t.evaluate(e))],asin:[J,[J],(e,[t])=>Math.asin(t.evaluate(e))],acos:[J,[J],(e,[t])=>Math.acos(t.evaluate(e))],atan:[J,[J],(e,[t])=>Math.atan(t.evaluate(e))],min:[J,ay(J),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[J,ay(J),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[J,[J],(e,[t])=>Math.abs(t.evaluate(e))],round:[J,[J],(e,[t])=>{let n=t.evaluate(e);return n<0?-Math.round(-n):Math.round(n)}],floor:[J,[J],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[J,[J],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[D_,[E_,j_],(e,[t,n])=>e.properties()[t.value]===n.value],"filter-id-==":[D_,[j_],(e,[t])=>e.id()===t.value],"filter-type-==":[D_,[E_],(e,[t])=>e.geometryType()===t.value],"filter-<":[D_,[E_,j_],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r{let n=e.id(),r=t.value;return typeof n==typeof r&&n":[D_,[E_,j_],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[D_,[j_],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n>r}],"filter-<=":[D_,[E_,j_],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[D_,[j_],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n<=r}],"filter->=":[D_,[E_,j_],(e,[t,n])=>{let r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[D_,[j_],(e,[t])=>{let n=e.id(),r=t.value;return typeof n==typeof r&&n>=r}],"filter-has":[D_,[j_],(e,[t])=>{let n=t.value,r=e.properties();return n in r&&r[n]!==void 0}],"filter-has-id":[D_,[],e=>e.id()!==null&&e.id()!==void 0],"filter-type-in":[D_,[B_(E_)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[D_,[B_(j_)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[D_,[E_,B_(j_)],(e,[t,n])=>n.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[D_,[E_,B_(j_)],(e,[t,n])=>kee(e.properties()[t.value],n.value,0,n.value.length-1)],all:{type:D_,overloads:[[[D_,D_],(e,[t,n])=>t.evaluate(e)&&n.evaluate(e)],[ay(D_),(e,t)=>{for(let n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:D_,overloads:[[[D_,D_],(e,[t,n])=>t.evaluate(e)||n.evaluate(e)],[ay(D_),(e,t)=>{for(let n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[D_,[D_],(e,[t])=>!t.evaluate(e)],"is-supported-script":[D_,[E_],(e,[t])=>{let n=e.globals&&e.globals.isSupportedScript;return!n||n(t.evaluate(e))}],upcase:[E_,[E_],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[E_,[E_],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[E_,ay(j_),(e,t)=>t.map(t=>e0(t.evaluate(e))).join(``)],split:[B_(E_),[E_,E_],(e,[t,n])=>t.evaluate(e).split(n.evaluate(e))],join:[E_,[B_(E_),E_],(e,[t,n])=>t.evaluate(e).join(n.evaluate(e))],"resolved-locale":[E_,[N_],(e,[t])=>t.evaluate(e).resolvedLocale()]});function Aee(e){return Array.isArray(e)?`(${e.map(V_).join(`, `)})`:`(${V_(e.type)}...)`}function oy(e){if(e instanceof u0)return oy(e.boundExpression);if(e instanceof ty&&e.name===`error`||e instanceof J0||e instanceof Av||e instanceof Qv||e instanceof $v)return!1;let t=e instanceof a0||e instanceof r0,n=!0;return e.eachChild(e=>{n&&=t?oy(e):e instanceof t0}),n?sy(e)&&ly(e,[`zoom`,`pitch`,`bearing`,`heatmap-density`,`elevation`,`line-progress`,`accumulated`,`is-supported-script`]):!1}function sy(e){if(e instanceof ty&&(e.name===`get`&&e.args.length===1||e.name===`feature-state`||e.name===`has`&&e.args.length===1||e.name===`properties`||e.name===`geometry-type`||e.name===`id`||/^filter-/.test(e.name))||e instanceof Av||e instanceof Qv)return!1;let t=!0;return e.eachChild(e=>{t&&!sy(e)&&(t=!1)}),t}function cy(e){if(e instanceof ty&&e.name===`feature-state`)return!1;let t=!0;return e.eachChild(e=>{t&&!cy(e)&&(t=!1)}),t}function ly(e,t){if(e instanceof ty&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild(e=>{n&&!ly(e,t)&&(n=!1)}),n}function uy(e){return{result:`success`,value:e}}function dy(e){return{result:`error`,value:e}}function fy(e){return e[`property-type`]===`data-driven`||e[`property-type`]===`cross-faded-data-driven`}function py(e){return!!e.expression&&e.expression.parameters.indexOf(`zoom`)>-1}function my(e){return!!e.expression&&e.expression.interpolated}var hy=/^(.*)-transition$/;function gy(e){return b0(e,Number)?`number`:b0(e,String)?`string`:b0(e,Boolean)?`boolean`:Array.isArray(e)?`array`:e===null?`null`:typeof e}function _y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&$1(e)===A_}function vy(e){return e}function yy(e){switch(e.type){case`color`:return R1.parse;case`padding`:return U1.parse;case`numberArray`:return W1.parse;case`colorArray`:return G1.parse;default:return null}}function by(e){switch(e){case`exponential`:return Ty;case`interval`:return wy;case`categorical`:return Cy;case`identity`:return Ey;default:throw Error(`Unknown function type "${e}"`)}}function xy(e,t){let n=e.stops&&typeof e.stops[0][0]==`object`,r=n||e.property!==void 0,i=n||!r,a=e.type||(my(t)?`exponential`:`interval`),o=yy(t);if(o&&(e={...e},e.stops&&(e.stops=e.stops.map(e=>[e[0],o(e[1])])),e.default?e.default=o(e.default):e.default=o(t.default)),e.colorSpace&&!L1(e.colorSpace))throw Error(`Unknown color space: "${e.colorSpace}"`);let s=by(a),c,l;if(a===`categorical`){c=Object.create(null);for(let t of e.stops)c[t[0]]=t[1];l=typeof e.stops[0][0]}if(n){let n={},r=[];for(let t=0;te[0]),evaluate({zoom:n},r){return Ty({stops:i,base:e.base,colorSpace:e.colorSpace},t,n).evaluate(n,r)}}}if(i){let n=a===`exponential`?{name:`exponential`,base:e.base===void 0?1:e.base}:null;return{kind:`camera`,interpolationType:n,interpolationFactor:w0.interpolationFactor.bind(void 0,n),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:n})=>s(e,t,n,c,l)}}return{kind:`source`,evaluate(n,r){let i=r&&r.properties?r.properties[e.property]:void 0;return i===void 0?Sy(e.default,t.default):s(e,t,i,c,l)}}}function Sy(e,t,n){if(e!==void 0)return e;if(t!==void 0)return t;if(n!==void 0)return n}function Cy(e,t,n,r,i){return Sy(typeof n===i?r[n]:void 0,e.default,t.default)}function wy(e,t,n){if(gy(n)!==`number`)return Sy(e.default,t.default);let r=e.stops.length;if(r===1||n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[r-1][0])return e.stops[r-1][1];let i=_0(e.stops.map(e=>e[0]),n,``);return e.stops[i][1]}function Ty(e,t,n){let r=e.base===void 0?1:e.base;if(gy(n)!==`number`)return Sy(e.default,t.default);let i=e.stops.length;if(i===1||n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];let a=_0(e.stops.map(e=>e[0]),n,``),o=Dy(n,r,e.stops[a][0],e.stops[a+1][0]),s=e.stops[a][1],c=e.stops[a+1][1],l=E0[t.type]||vy;return typeof s.evaluate==`function`?{evaluate(...t){let n=s.evaluate.apply(void 0,t),r=c.evaluate.apply(void 0,t);if(n!==void 0&&r!==void 0)return l(n,r,o,e.colorSpace)}}:l(s,c,o,e.colorSpace)}function Ey(e,t,n){switch(t.type){case`color`:n=R1.parse(n);break;case`formatted`:n=H1.fromString(n.toString());break;case`resolvedImage`:n=Y1.fromString(n.toString());break;case`padding`:n=U1.parse(n);break;case`colorArray`:n=G1.parse(n);break;case`numberArray`:n=W1.parse(n);break;default:gy(n)===t.type||t.type===`enum`&&t.values[n]||(n=void 0)}return Sy(n,e.default,t.default)}function Dy(e,t,n,r){let i=r-n,a=e-n;return i===0?0:t===1?a/i:(t**+a-1)/(t**+i-1)}var Oy=class{constructor(e,t,n,r){this.expression=e,this._warningHistory={},this._evaluator=new s0,this._defaultValue=n?Hy(n):null,this._enumValues=n&&n.type===`enum`?n.values:null,this._globalState=r,this._rootKey=t}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=Uy(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a,this.expression.evaluate(this._evaluator)}evaluate(e,t,n,r,i,a){this._globalState&&(e=Uy(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a||null;try{let e=this.expression.evaluate(this._evaluator);if(e==null||typeof e==`number`&&e!==e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new K1(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(`, `)}, but found ${JSON.stringify(e)} instead.`,``);return e}catch(e){let t=e instanceof K1?e.path:``,n=`${t}|${e.message}`;return this._warningHistory[n]||(this._warningHistory[n]=!0,typeof console<`u`&&console.warn(ky(this._rootKey,t,e.message,this._defaultValue))),this._defaultValue}}};function ky(e,t,n,r){return`${e}${t}: ${n}${r==null?``:` Falling back to ${String(r)}.`}`}function Ay(e){if(!e)throw Error(`rootKey must identify the location of the expression in the style JSON, e.g. "layers[3].paint.line-width".`)}function jy(e){return Array.isArray(e)&&e.length>0&&typeof e[0]==`string`&&S1(ey,e[0])!==void 0}function My(e,t,n,r){Ay(t);let i=new c0(ey,oy,[],n?Vy(n):void 0),a=i.parse(e,void 0,void 0,void 0,n&&n.type===`string`?{typeAnnotation:`coerce`}:void 0);return a?uy(new Oy(a,t,n,r)):dy(i.errors)}var Ny=class{constructor(e,t,n){this.kind=e,this._styleExpression=t,this.isStateDependent=e!==`constant`&&!cy(t.expression),this.globalStateRefs=By(t.expression),this._globalState=n}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=Uy(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,a)}evaluate(e,t,n,r,i,a){return this._globalState&&(e=Uy(e,this._globalState)),this._styleExpression.evaluate(e,t,n,r,i,a)}},Py=class{constructor(e,t,n,r,i){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent=e!==`camera`&&!cy(t.expression),this.globalStateRefs=By(t.expression),this.interpolationType=r,this._globalState=i}evaluateWithoutErrorHandling(e,t,n,r,i,a){return this._globalState&&(e=Uy(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,a)}evaluate(e,t,n,r,i,a){return this._globalState&&(e=Uy(e,this._globalState)),this._styleExpression.evaluate(e,t,n,r,i,a)}interpolationFactor(e,t,n){return this.interpolationType?w0.interpolationFactor(this.interpolationType,e,t,n):0}};function Fy(e){return e._styleExpression!==void 0}function Iy(e,t,n,r){let i=My(e,t,n,r);if(i.result===`error`)return i;let a=i.value.expression,o=sy(a);if(!o&&!fy(n))return dy([new C_(``,`data expressions not supported`)]);let s=ly(a,[`zoom`]);if(!s&&!py(n))return dy([new C_(``,`zoom expressions not supported`)]);if(!ly(a,[`pitch`,`bearing`]))return dy([new C_(``,`"pitch" and "bearing" expressions are only supported in symbol layer filters.`)]);let c=zy(a);if(!c&&!s)return dy([new C_(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`)]);if(c instanceof C_)return dy([c]);if(c instanceof w0&&!my(n))return dy([new C_(``,`"interpolate" expressions cannot be used with this property`)]);if(!c)return uy(o?new Ny(`constant`,i.value,r):new Ny(`source`,i.value,r));let l=c instanceof w0?c.interpolation:void 0;return uy(o?new Py(`camera`,i.value,c.labels,l,r):new Py(`composite`,i.value,c.labels,l,r))}var Ly=class e{constructor(e,t,n){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,Ay(t),this._parameters=e,this._specification=n,this._rootKey=t,this._defaultValue=Hy(n),this._warningHistory={};let r=xy(this._parameters,this._specification);this.kind=r.kind,this.interpolationFactor=r.interpolationFactor,this.zoomStops=r.zoomStops,this.interpolationType=r.interpolationType,this._innerEvaluate=r.evaluate}evaluate(e,t){try{return this._innerEvaluate(e,t)}catch(e){let t=e instanceof Error?e.message:String(e),n=`|${t}`;return this._warningHistory[n]||(this._warningHistory[n]=!0,typeof console<`u`&&console.warn(ky(this._rootKey,``,t,this._defaultValue))),this._defaultValue}}static deserialize(t){return new e(t._parameters,t._rootKey,t._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification,_rootKey:e._rootKey}}};function Ry(e,t,n,r){if(_y(e))return new Ly(e,t,n);if(jy(e)){let i=Iy(e,t,n,r);if(i.result===`error`)throw Error(i.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return i.value}{let t=e;return n.type===`color`&&typeof e==`string`?t=R1.parse(e):n.type===`padding`&&(typeof e==`number`||Array.isArray(e))?t=U1.parse(e):n.type===`numberArray`&&(typeof e==`number`||Array.isArray(e))?t=W1.parse(e):n.type===`colorArray`&&(typeof e==`string`||Array.isArray(e))?t=G1.parse(e):n.type===`variableAnchorOffsetCollection`&&Array.isArray(e)?t=J1.parse(e):n.type===`projectionDefinition`&&typeof e==`string`&&(t=X1.parse(e)),{globalStateRefs:new Set,_globalState:null,kind:`constant`,evaluate:()=>t}}}function zy(e,t=new Map){if(t.has(e))return t.get(e);let n=null;if(e instanceof l0)n=zy(e.result,t);else if(e instanceof D0){for(let r of e.args)if(n=zy(r,t),n)break}else(e instanceof v0||e instanceof w0)&&e.input instanceof ty&&e.input.name===`zoom`&&(n=e);return n instanceof C_?(t.set(e,n),n):(e.eachChild(e=>{let r=zy(e,t);r instanceof C_?n=r:!n&&r?n=new C_(``,`"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.`):n&&r&&n!==r&&(n=new C_(``,`Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.`))}),t.set(e,n),n)}function By(e,t=new Set){return e instanceof $v&&t.add(e.key),e.eachChild(e=>{By(e,t)}),t}function Vy(e){let t={color:O_,string:E_,number:J,enum:E_,boolean:D_,formatted:P_,padding:F_,numberArray:L_,colorArray:I_,projectionDefinition:k_,resolvedImage:R_,variableAnchorOffsetCollection:z_};return e.type===`array`?B_(t[e.value]||j_,e.length):t[e.type]}function Hy(e){if(e.type===`color`&&_y(e.default))return new R1(0,0,0,0);switch(e.type){case`color`:return R1.parse(e.default)||null;case`padding`:return U1.parse(e.default)||null;case`numberArray`:return W1.parse(e.default)||null;case`colorArray`:return G1.parse(e.default)||null;case`variableAnchorOffsetCollection`:return J1.parse(e.default)||null;case`projectionDefinition`:return X1.parse(e.default)||null;default:return e.default===void 0?null:e.default}}function Uy(e,t){let{zoom:n,pitch:r,bearing:i,heatmapDensity:a,elevation:o,lineProgress:s,isSupportedScript:c,accumulated:l}=e??{};return{zoom:n,pitch:r,bearing:i,heatmapDensity:a,elevation:o,lineProgress:s,isSupportedScript:c,accumulated:l,globalState:t}}function jee(e){let t=!1;for(let n of e){let e=Wy(n);if(e===`expression`)return`expression`;e===`legacy`&&(t=!0)}return t?`legacy`:`neutral`}function Wy(e){if(typeof e==`boolean`)return`neutral`;if(!Array.isArray(e)||e.length===0)return`legacy`;switch(e[0]){case`has`:return e.length<2||e[1]===`$id`||e[1]===`$type`?`legacy`:e.length===2?`neutral`:`expression`;case`in`:return e.length>=3&&(typeof e[1]!=`string`||Array.isArray(e[2]))?`expression`:`legacy`;case`!in`:case`!has`:return`legacy`;case`==`:case`!=`:case`>`:case`>=`:case`<`:case`<=`:return e.length!==3||Array.isArray(e[1])||Array.isArray(e[2])?`expression`:`legacy`;case`none`:return`legacy`;case`any`:case`all`:return jee(e.slice(1));default:return`expression`}}function Gy(e){return Wy(e)!==`legacy`}function Ky(e){return e===`$type`?[`geometry-type`]:e===`$id`?[`id`]:[`get`,e]}function Mee(e){switch(e[0]){case`==`:case`!=`:case`<`:case`<=`:case`>`:case`>=`:return e.length!==3||typeof e[1]!=`string`?null:[e[0],Ky(e[1]),e[2]];case`in`:case`!in`:{if(e.length<2||typeof e[1]!=`string`)return null;let t=[`in`,Ky(e[1]),[`literal`,e.slice(2)]];return e[0]===`!in`?[`!`,t]:t}case`has`:case`!has`:{if(e.length!==2||typeof e[1]!=`string`||e[1]===`$type`||e[1]===`$id`)return null;let t=[`has`,e[1]];return e[0]===`!has`?[`!`,t]:t}default:return null}}function qy(e){if((e[0]===`<`||e[0]===`<=`||e[0]===`>`||e[0]===`>=`)&&e[1]===`$type`)return`"$type" cannot be use with operator "${e[0]}"`;let t=Mee(e);return t?`Mixing deprecated filter syntax with expression syntax is not supported. Replace ${JSON.stringify(e)} with ${JSON.stringify(t)}.`:`Mixing deprecated filter syntax with expression syntax is not supported. Convert ${JSON.stringify(e)} to expression syntax.`}function Jy(e,t,n){let r=n[e];return Array.isArray(r)?Gy(r)?Yy(r,t.concat(e)):{path:t.concat(e),legacyFilter:r}:null}function Yy(e,t=[]){if(!Array.isArray(e)||e.length<1)return null;switch(e[0]){case`all`:case`any`:case`none`:for(let n=1;n`u`)return;let r=n.path.map(e=>`[${e}]`).join(``);console.warn(`${t}${r}: ${qy(n.legacyFilter)}`)}var Pee={type:`boolean`,default:!1,transition:!1,"property-type":`data-driven`,expression:{interpolated:!1,parameters:[`zoom`,`feature`,`pitch`,`bearing`]}};function Xy(e,t,n){if(e==null)return{filter:()=>!0,needGeometry:!1,needCamera:!1,getGlobalStateRefs:()=>new Set};Gy(e)?Nee(e,t):e=Qy(e);let r=My(e,t,Pee,n);if(r.result===`error`)throw Error(r.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return{filter:(e,t,n)=>r.value.evaluate(e,t,{},n),needGeometry:Zy(e),needCamera:!ly(r.value.expression,[`pitch`,`bearing`]),getGlobalStateRefs:()=>By(r.value.expression)}}function Fee(e,t){return et)}function Zy(e){if(!Array.isArray(e))return!1;if(e[0]===`within`||e[0]===`distance`)return!0;for(let t=1;t`||t===`<=`||t===`>=`?$y(e[1],e[2],t):t===`any`?e2(e.slice(1)):t===`all`?[`all`].concat(e.slice(1).map(Qy)):t===`none`?[`all`].concat(e.slice(1).map(Qy).map(r2)):t===`in`?t2(e[1],e.slice(2)):t===`!in`?r2(t2(e[1],e.slice(2))):t===`has`?n2(e[1]):t!==`!has`||r2(n2(e[1]))}function $y(e,t,n){switch(e){case`$type`:return[`filter-type-${n}`,t];case`$id`:return[`filter-id-${n}`,t];default:return[`filter-${n}`,e,t]}}function e2(e){return[`any`].concat(e.map(Qy))}function t2(e,t){if(t.length===0)return!1;switch(e){case`$type`:return[`filter-type-in`,[`literal`,t]];case`$id`:return[`filter-id-in`,[`literal`,t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?[`filter-in-large`,e,[`literal`,t.sort(Fee)]]:[`filter-in-small`,e,[`literal`,t]]}}function n2(e){switch(e){case`$type`:return!0;case`$id`:return[`filter-has-id`];default:return[`filter-has`,e]}}function r2(e){return[`!`,e]}function i2(){let e={},t=K.$version;for(let n in K.$root){let r=K.$root[n];if(r.required){let i=null;i=n===`version`?t:r.type===`array`?[]:{},i!=null&&(e[n]=i)}}return e}function a2(e){let t=e.key,n=e.value;return n?[new q(t,n,`constants have been deprecated as of v8`)]:[]}function o2(e){let t=e.key,n=e.value,r=e.valueSpec||{},i=e.objectElementValidators||{},a=e.style,o=e.styleSpec,s=e.validateSpec,c=[],l=gy(n);if(l!==`object`)return[new q(t,n,`object expected, ${l} found`)];for(let e in n){let l=e.split(`.`)[0],u=S1(r,l)||r[`*`],d;if(S1(i,l))d=i[l];else if(S1(r,l)){if(n[e]===void 0)continue;d=s}else if(i[`*`])d=i[`*`];else if(r[`*`])d=s;else{c.push(new q(t,n[e],`unknown property "${e}"`));continue}c=c.concat(d({key:(t&&`${t}.`)+e,value:n[e],valueSpec:u,style:a,styleSpec:o,object:n,objectKey:e,validateSpec:s},n))}for(let e in r)i[e]||r[e].required&&r[e].default===void 0&&n[e]===void 0&&c.push(new q(t,n,`missing required property "${e}"`));return c}function s2(e){let t=e.value,n=e.valueSpec,r=e.validateSpec,i=e.style,a=e.styleSpec,o=e.key,s=e.arrayElementValidator||r;if(gy(t)!==`array`)return[new q(o,t,`array expected, ${gy(t)} found`)];if(n.length&&t.length!==n.length)return[new q(o,t,`array length ${n.length} expected, length ${t.length} found`)];let c={type:n.value,values:n.values};a.$version<7&&(c.function=n.function),gy(n.value)===`object`&&(c=n.value);let l=[];for(let n=0;nr.maximum?[new q(t,n,`${n} is greater than the maximum value ${r.maximum}`)]:[]:[new q(t,n,`number expected, ${i} found`)]}function l2(e){let t=e.valueSpec,n=x0(e.value.type),r,i={},a,o,s=n!==`categorical`&&e.value.property===void 0,c=!s,l=gy(e.value.stops)===`array`&&gy(e.value.stops[0])===`array`&&gy(e.value.stops[0][0])===`object`,u=o2({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:d,default:m}});return n===`identity`&&s&&u.push(new q(e.key,e.value,`missing required property "property"`)),n!==`identity`&&!e.value.stops&&u.push(new q(e.key,e.value,`missing required property "stops"`)),n===`exponential`&&e.valueSpec.expression&&!my(e.valueSpec)&&u.push(new q(e.key,e.value,`exponential functions not supported`)),e.styleSpec.$version>=8&&(c&&!fy(e.valueSpec)?u.push(new q(e.key,e.value,`property functions not supported`)):s&&!py(e.valueSpec)&&u.push(new q(e.key,e.value,`zoom functions not supported`))),(n===`categorical`||l)&&e.value.property===void 0&&u.push(new q(e.key,e.value,`"property" property is required`)),u;function d(e){if(n===`identity`)return[new q(e.key,e.value,`identity function may not have a "stops" property`)];let t=[],r=e.value;return t=t.concat(s2({key:e.key,value:r,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:f})),gy(r)===`array`&&r.length===0&&t.push(new q(e.key,r,`array must have at least one stop`)),t}function f(e){let n=[],r=e.value,s=e.key;if(gy(r)!==`array`)return[new q(s,r,`array expected, ${gy(r)} found`)];if(r.length!==2)return[new q(s,r,`array length 2 expected, length ${r.length} found`)];if(l){if(gy(r[0])!==`object`)return[new q(s,r,`object expected, ${gy(r[0])} found`)];if(r[0].zoom===void 0)return[new q(s,r,`object stop key must have zoom`)];if(r[0].value===void 0)return[new q(s,r,`object stop key must have value`)];if(gy(r[0].zoom)!==`number`)return[new q(`${s}[0].zoom`,r[0].zoom,`number expected, ${gy(r[0].zoom)} found`)];if(o&&o>x0(r[0].zoom))return[new q(s,r[0].zoom,`stop zoom values must appear in ascending order`)];x0(r[0].zoom)!==o&&(o=x0(r[0].zoom),a=void 0,i={}),n=n.concat(o2({key:`${s}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:c2,value:p}}))}else n=n.concat(p({key:`${s}[0]`,value:r[0],valueSpec:{},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},r));return jy(S0(r[1]))?n.concat([new q(`${s}[1]`,r[1],`expressions are not allowed in function stops.`)]):n.concat(e.validateSpec({key:`${s}[1]`,value:r[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function p(e,o){let s=gy(e.value),c=x0(e.value),l=e.value===null?o:e.value;if(!r)r=s;else if(s!==r)return[new q(e.key,l,`${s} stop domain type must match previous stop domain type ${r}`)];if(s!==`number`&&s!==`string`&&s!==`boolean`)return[new q(e.key,l,`stop domain value must be a number, string, or boolean`)];if(s!==`number`&&n!==`categorical`){let r=`number expected, ${s} found`;return fy(t)&&n===void 0&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new q(e.key,l,r)]}return n===`categorical`&&s===`number`&&(!isFinite(c)||Math.floor(c)!==c)?[new q(e.key,l,`integer expected, found ${c}`)]:n!==`categorical`&&s===`number`&&a!==void 0&&cnew q(`${e.key}${t.key}`,e.value,t.message));let n=t.value.expression||t.value._styleExpression.expression;if(e.expressionContext===`property`&&e.propertyKey===`text-font`&&!n.outputDefined())return[new q(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if(e.expressionContext===`property`&&e.propertyType===`layout`&&!cy(n))return[new q(e.key,e.value,`"feature-state" data expressions are not supported with layout properties.`)];if(e.expressionContext===`filter`&&!cy(n))return[new q(e.key,e.value,`"feature-state" data expressions are not supported with filters.`)];if((e.expressionContext!==`filter`||e.layerType!==`symbol`)&&!ly(n,[`pitch`,`bearing`]))return[new q(e.key,e.value,`"pitch" and "bearing" expressions are only supported in symbol layer filters.`)];if(e.expressionContext&&e.expressionContext.indexOf(`cluster`)===0){if(!ly(n,[`zoom`,`feature-state`]))return[new q(e.key,e.value,`"zoom" and "feature-state" expressions are not supported with cluster properties.`)];if(e.expressionContext===`cluster-initial`&&!sy(n))return[new q(e.key,e.value,`Feature data expressions are not supported with initial expression part of cluster properties.`)]}return[]}function d2(e){let t=e.value,n=e.key,r=gy(t);return r===`boolean`?[]:[new q(n,t,`boolean expected, ${r} found`)]}function f2(e){let t=e.key,n=e.value,r=gy(n);return r===`string`?R1.parse(String(n))?[]:[new q(t,n,`color expected, "${n}" found`)]:[new q(t,n,`color expected, ${r} found`)]}function p2(e){let t=e.key,n=e.value,r=e.valueSpec,i=[];return Array.isArray(r.values)?r.values.indexOf(x0(n))===-1&&i.push(new q(t,n,`expected one of [${r.values.join(`, `)}], ${JSON.stringify(n)} found`)):Object.keys(r.values).indexOf(x0(n))===-1&&i.push(new q(t,n,`expected one of [${Object.keys(r.values).join(`, `)}], ${JSON.stringify(n)} found`)),i}function m2(e,t){let n=e;for(let e of t)n=n[e];return n}function h2(e,t){let n=Yy(t);return n?[new q(`${e.key}${n.path.map(e=>`[${e}]`).join(``)}`,m2(e.value,n.path),qy(n.legacyFilter),null,`warning`)]:[]}function g2(e){let t=S0(e.value);return Gy(t)?[...h2(e,t),...u2({...e,expressionContext:`filter`,valueSpec:{value:`boolean`}})]:_2(e)}function _2(e){let t=e.value,n=e.key;if(gy(t)!==`array`)return[new q(n,t,`array expected, ${gy(t)} found`)];let r=e.styleSpec,i,a=[];if(t.length<1)return[new q(n,t,`filter array must have at least 1 element`)];switch(a=a.concat(p2({key:`${n}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),x0(t[0])){case`<`:case`<=`:case`>`:case`>=`:t.length>=2&&x0(t[1])===`$type`&&a.push(new q(n,t,`"$type" cannot be use with operator "${t[0]}"`));case`==`:case`!=`:t.length!==3&&a.push(new q(n,t,`filter array for operator "${t[0]}" must have 3 elements`));case`in`:case`!in`:t.length>=2&&(i=gy(t[1]),i!==`string`&&a.push(new q(`${n}[1]`,t[1],`string expected, ${i} found`)));for(let o=2;o{e in n&&t.push(new q(r,n[e],`"${e}" is prohibited for ref layers`))});let e;i.layers.forEach(t=>{gy(t)===`object`&&x0(t.id)===s&&(e=t)}),e?e.ref?t.push(new q(r,n.ref,`ref cannot reference another ref layer`)):o=x0(e.type):t.push(new q(r,n.ref,`ref layer "${C0(s)}" not found`))}else if(o!==`background`){if(!n.source)t.push(new q(r,n,`missing required property "source"`));else{let e=C0(n.source),a=i.sources&&S1(i.sources,e),s=a&&x0(a.type);a?s===`vector`&&o===`raster`?t.push(new q(r,n.source,`layer "${C0(n.id)}" requires a raster source`)):s!==`raster-dem`&&o===`hillshade`||s!==`raster-dem`&&o===`color-relief`?t.push(new q(r,n.source,`layer "${C0(n.id)}" requires a raster-dem source`)):s===`raster`&&o!==`raster`?t.push(new q(r,n.source,`layer "${C0(n.id)}" requires a vector source`)):s===`vector`&&!n[`source-layer`]?t.push(new q(r,n,`layer "${C0(n.id)}" must specify a "source-layer"`)):s===`raster-dem`&&o!==`hillshade`&&o!==`color-relief`?t.push(new q(r,n.source,`raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.`)):o===`line`&&n.paint&&n.paint[`line-gradient`]&&(s!==`geojson`||!a.lineMetrics)&&t.push(new q(r,n,`layer "${C0(n.id)}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new q(r,n.source,`source "${e}" not found`))}}return o===`raster`&&n.paint?.resampling&&n.paint?.[`raster-resampling`]&&t.push(new q(r,n.paint,`layer "${C0(n.id)}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),t=t.concat(o2({key:r,value:n,valueSpec:a.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(){return[]},type(){return e.validateSpec({key:`${r}.type`,value:n.type,valueSpec:a.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:n,objectKey:`type`})},filter(e){return g2({layerType:o,...e})},layout(e){return o2({layer:n,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(e){return b2({layerType:o,...e})}}})},paint(e){return o2({layer:n,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*"(e){return y2({layerType:o,...e})}}})}}})),t}function S2(e){let t=e.value,n=e.key,r=gy(t);return r===`string`?[]:[new q(n,t,`string expected, ${r} found`)]}function C2(e){let t=e.sourceName??``,n=e.value,r=e.styleSpec,i=r.source_raster_dem,a=e.style,o=[],s=gy(n);if(n===void 0)return o;if(s!==`object`)return o.push(new q(`source_raster_dem`,n,`object expected, ${s} found`)),o;let c=x0(n.encoding)===`custom`,l=[`redFactor`,`greenFactor`,`blueFactor`,`baseShift`],u=e.value.encoding?`"${C0(e.value.encoding)}"`:`Default`;for(let s in n)!c&&l.includes(s)?o.push(new q(s,n[s],`In "${t}": "${s}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):S1(i,s)?o=o.concat(e.validateSpec({key:s,value:n[s],valueSpec:i[s],validateSpec:e.validateSpec,style:a,styleSpec:r})):o.push(new q(s,n[s],`unknown property "${s}"`));return o}var w2={promoteId:E2};function T2(e){let t=e.value,n=e.key,r=e.styleSpec,i=e.style,a=e.validateSpec;if(gy(t)!==`object`)return[new q(n,t,`object expected, ${gy(t)} found`)];if(!t.type)return[new q(n,t,`"type" is required`)];let o=x0(t.type),s;switch(o){case`vector`:case`raster`:return s=o2({key:n,value:t,valueSpec:r[`source_${o.replace(`-`,`_`)}`],style:e.style,styleSpec:r,objectElementValidators:w2,validateSpec:a}),s;case`raster-dem`:return s=C2({sourceName:n,value:t,style:e.style,styleSpec:r,validateSpec:a}),s;case`geojson`:if(s=o2({key:n,value:t,valueSpec:r.source_geojson,style:i,styleSpec:r,validateSpec:a,objectElementValidators:w2}),t.cluster&&t.clusterProperties!==void 0){if(gy(t.clusterProperties)!==`object`)return s.push(new q(`${n}.clusterProperties`,t.clusterProperties,`object expected, ${gy(t.clusterProperties)} found`)),s;for(let e in t.clusterProperties){let r=t.clusterProperties[e];if(gy(r)!==`array`){s.push(new q(`${n}.${e}`,r,`array expected, ${gy(r)} found`));continue}let[i,o]=r,c=typeof i==`string`?[i,[`accumulated`],[`get`,e]]:i;s.push(...u2({key:`${n}.${e}.map`,value:o,validateSpec:a,expressionContext:`cluster-map`})),s.push(...u2({key:`${n}.${e}.reduce`,value:c,validateSpec:a,expressionContext:`cluster-reduce`}))}}return s;case`video`:return o2({key:n,value:t,valueSpec:r.source_video,style:i,validateSpec:a,styleSpec:r});case`image`:return o2({key:n,value:t,valueSpec:r.source_image,style:i,validateSpec:a,styleSpec:r});case`canvas`:return[new q(n,null,`Please use runtime APIs to add canvas sources, rather than including them in stylesheets.`,`source.canvas`)];default:return p2({key:`${n}.type`,value:t.type,valueSpec:{values:[`vector`,`raster`,`raster-dem`,`geojson`,`video`,`image`]},style:i,validateSpec:a,styleSpec:r})}}function E2({key:e,value:t}){if(gy(t)===`string`)return S2({key:e,value:t});{let n=[];for(let r in t)n.push(...S2({key:`${e}.${r}`,value:t[r]}));return n}}function D2(e){let t=e.value,n=e.styleSpec,r=n.light,i=e.style,a=[],o=gy(t);if(t===void 0)return a;if(o!==`object`)return a=a.concat([new q(`light`,t,`object expected, ${o} found`)]),a;for(let o in t){let s=o.match(hy);a=s&&S1(r,s[1])?.transition?a.concat(e.validateSpec({key:o,value:t[o],valueSpec:n.transition,validateSpec:e.validateSpec,style:i,styleSpec:n})):S1(r,o)?a.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:i,styleSpec:n})):a.concat([new q(o,t[o],`unknown property "${o}"`)])}return a}function O2(e){let t=e.value,n=e.styleSpec,r=n.sky,i=e.style,a=gy(t);if(t===void 0)return[];if(a!==`object`)return[new q(`sky`,t,`object expected, ${a} found`)];let o=[];for(let a in t){let s=a.match(hy);o=s&&S1(r,s[1])?.transition?o.concat(e.validateSpec({key:a,value:t[a],valueSpec:n.transition,style:i,styleSpec:n})):S1(r,a)?o.concat(e.validateSpec({key:a,value:t[a],valueSpec:r[a],style:i,styleSpec:n})):o.concat([new q(a,t[a],`unknown property "${a}"`)])}return o}function k2(e){let t=e.value,n=e.styleSpec,r=n.terrain,i=e.style,a=[],o=gy(t);if(t===void 0)return a;if(o!==`object`)return a=a.concat([new q(`terrain`,t,`object expected, ${o} found`)]),a;for(let o in t)a=S1(r,o)?a.concat(e.validateSpec({key:o,value:t[o],valueSpec:r[o],validateSpec:e.validateSpec,style:i,styleSpec:n})):a.concat([new q(o,t[o],`unknown property "${o}"`)]);return a}function A2(e){return S2(e).length===0?[]:u2(e)}function j2(e){return S2(e).length===0?[]:u2(e)}function M2(e){let t=e.key,n=e.value;if(gy(n)===`array`){if(n.length<1||n.length>4)return[new q(t,n,`padding requires 1 to 4 values; ${n.length} values found`)];let r={type:`number`},i=[];for(let a=0;a[new q(e,t,`invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"`)],i=n.match(W2);if(!i)return r();let[,a,o,s]=i;if(s!==void 0)return s.length>6?r():[];let c=parseInt(a,16),l=o===void 0?c:parseInt(o,16);return c>U2||l>U2?[new q(e,t,`unicode range is out of bounds, the maximum code point is U+10FFFF`)]:c>l?[new q(e,t,`unicode range start must not be greater than its end, but ${n} is`)]:[]}function K2(e){let t=e.key??`font-faces`,n=e.value,r=e.validateSpec,i=e.styleSpec??d_,a=e.style;if(!V2(n))return[new q(t,n,`object expected, ${gy(n)} found`)];let o=[];for(let e in n){let s=n[e],c=gy(s);if(c===`string`)o.push(...S2({key:`${t}.${e}`,value:s}));else if(c===`array`){let n={url:{type:`string`,required:!0},"unicode-range":{type:`array`,value:`string`}};for(let[c,l]of s.entries()){let s=`${t}.${e}[${c}]`;o.push(...o2({key:s,value:l,valueSpec:n,styleSpec:i,style:a,validateSpec:r}));let u=V2(l)?l[`unicode-range`]:void 0;if(gy(u)===`array`)for(let[e,t]of u.entries())o.push(...G2(`${s}.unicode-range[${e}]`,t))}}else o.push(new q(`${t}.${e}`,s,`string or array expected, ${c} found`))}return o}var q2={"*"(){return[]},array:s2,boolean:d2,number:c2,color:f2,constants:a2,enum:p2,filter:g2,function:l2,layer:x2,object:o2,source:T2,light:D2,sky:O2,terrain:k2,projection:L2,projectionDefinition:R2,string:S2,formatted:A2,resolvedImage:j2,padding:M2,numberArray:N2,colorArray:P2,variableAnchorOffsetCollection:F2,sprite:I2,state:H2,fontFaces:K2};function J2(e){let t=e.value,n=e.valueSpec,r=e.styleSpec;return e.validateSpec=J2,n.expression&&_y(x0(t))?l2(e):n.expression&&jy(S0(t))?u2(e):n.type&&q2[n.type]?q2[n.type](e):o2({...e,valueSpec:n.type?r[n.type]:n})}function Y2(e){let t=e.value,n=e.key,r=S2(e);return r.length||(t.indexOf(`{fontstack}`)===-1&&r.push(new q(n,t,`"glyphs" url must include a "{fontstack}" token`)),t.indexOf(`{range}`)===-1&&r.push(new q(n,t,`"glyphs" url must include a "{range}" token`))),r}function X2(e,t=K){let n=[];return n=n.concat(J2({key:``,value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:J2,objectElementValidators:{glyphs:Y2,"*"(){return[]}}})),e?.constants&&(n=n.concat(a2({key:`constants`,value:e.constants,style:e,styleSpec:t,validateSpec:J2}))),Q2(n)}X2.source=$2(Z2(T2)),X2.sprite=$2(Z2(I2)),X2.glyphs=$2(Z2(Y2)),X2.fontFaces=$2(Z2(K2)),X2.light=$2(Z2(D2)),X2.sky=$2(Z2(O2)),X2.terrain=$2(Z2(k2)),X2.state=$2(Z2(H2)),X2.layer=$2(Z2(x2)),X2.filter=$2(Z2(g2)),X2.paintProperty=$2(Z2(y2)),X2.layoutProperty=$2(Z2(b2));function Z2(e){return function(t){return e(Object.assign({},t,{validateSpec:J2}))}}function Q2(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function $2(e){return function(...t){return Q2(e.apply(this,t))}}var e4={type:`enum`,"property-type":`data-constant`,expression:{interpolated:!1,parameters:[`global-state`]},values:{visible:{},none:{}},transition:!1,default:`visible`},t4=class{constructor(e,t,n){this._rootKey=t,this._globalState=n,this.setValue(e)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(e){if(e==null||e===`visible`||e===`none`){this._literalValue=e===`none`?`none`:`visible`,this._compiledValue=void 0,this._globalStateRefs=new Set;return}let t=My(e,this._rootKey,e4,this._globalState);if(t.result===`error`)throw this._literalValue=`visible`,this._compiledValue=void 0,Error(t.value.map(e=>`${e.key}: ${e.message}`).join(`, `));this._literalValue=void 0,this._compiledValue=t.value,this._globalStateRefs=By(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};function n4(e,t,n){return new t4(e,t,n)}var r4={};function Y(e,t,n={}){if(r4[e])throw Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),r4[e]={klass:t,omit:n.omit||[],shallow:n.shallow||[]}}Y(`Object`,Object),Y(`Set`,Set),Y(`TransferableGridIndex`,u_),Y(`Color`,R1),Y(`Error`,Error),Y(`AJAXError`,Yg),Y(`ResolvedImage`,Y1),Y(`StylePropertyFunction`,Ly),Y(`StyleExpression`,Oy,{omit:[`_evaluator`]}),Y(`ZoomDependentExpression`,Py),Y(`ZoomConstantExpression`,Ny),Y(`CompoundExpression`,ty,{omit:[`_evaluate`]});for(let e in ey)ey[e]._classRegistryKey||Y(`Expression_${e}`,ey[e]);function i4(e){return e&&typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||e.constructor?.name===`ArrayBuffer`)}function a4(e){let t=e.constructor;return e.$name||t._classRegistryKey}function o4(e){if(typeof e!=`object`||!e)return!1;let t=a4(e);return t&&t!==`Object`}function s4(e){return!o4(e)&&(e==null||typeof e==`boolean`||typeof e==`number`||typeof e==`string`||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||i4(e)||fg(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function c4(e,t){if(s4(e))return(i4(e)||fg(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){let n=[];for(let r of e)n.push(c4(r,t));return n}if(typeof e!=`object`)throw Error(`can't serialize object of type ${typeof e}`);let n=a4(e);if(!n)throw Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!r4[n])throw Error(`${n} is not registered.`);let{klass:r}=r4[n],i=r.serialize?r.serialize(e,t):{};if(!r.serialize){for(let r in e){if(!e.hasOwnProperty(r)||r4[n].omit.includes(r))continue;let a=e[r];a!==void 0&&(i[r]=r4[n].shallow.includes(r)?a:c4(a,t))}e instanceof Error&&(i.message=e.message)}else if(i===t?.[t.length-1])throw Error(`statically serialized object won't survive transfer of $name property`);if(i.$name)throw Error(`$name property is reserved for worker serialization logic.`);return n!==`Object`&&(i.$name=n),i}function l4(e){if(s4(e))return e;if(Array.isArray(e))return e.map(l4);if(typeof e!=`object`)throw Error(`can't deserialize object of type ${typeof e}`);let t=a4(e)||`Object`;if(!r4[t])throw Error(`can't deserialize unregistered class ${t}`);let{klass:n}=r4[t];if(!n)throw Error(`can't deserialize unregistered class ${t}`);if(n.deserialize)return n.deserialize(e);let r=Object.create(n.prototype);for(let n of Object.keys(e)){if(n===`$name`)continue;let i=e[n];r[n]=r4[t].shallow.includes(n)?i:l4(i)}return r}var u4=class{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>this._invoke()}trigger(){this._triggered||(this._triggered=!0,this._channel?.port1.postMessage(!0),setTimeout(()=>this._invoke(),0))}_invoke(){this._triggered&&(this._triggered=!1,this._methodToThrottle())}remove(){delete this._channel,this._methodToThrottle=()=>{}}},d4={once:!0},f4=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new u4(()=>this.process()),this.subscription=mg(this.target,`message`,e=>this.receive(e),!1),this.globalScope=cg(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((n,r)=>{let i=Math.round(Math.random()*1e18).toString(36).substring(0,10),a=t?mg(t.signal,`abort`,()=>{a?.unsubscribe(),delete this.resolveRejects[i];let n={id:i,type:``,origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(n),r(new Og(t.signal.reason))},d4):null;this.resolveRejects[i]={resolve:e=>{a?.unsubscribe(),n(e)},reject:e=>{a?.unsubscribe(),r(e)}};let o=[],s={...e,id:i,sourceMapId:this.mapId,origin:location.origin,data:c4(e.data,o)};this.target.postMessage(s,{transfer:o})})}receive(e){let t=e.data,n=t.id,r=[`file://`,`resource://android`,`null`],i=[t.origin,location.origin],a=t.origin===location.origin,o=i.some(e=>r.includes(e));if((a||o)&&!(t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type===``){delete this.tasks[n];let e=this.abortControllers[n];delete this.abortControllers[n],e&&e.abort()}else cg(self)||t.mustQueue?(this.tasks[n]=t,this.taskQueue.push(n),this.invoker.trigger()):this.processTask(n,t)}}process(){if(this.taskQueue.length===0)return;let e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}async processTask(e,t){if(t.type===``){let n=this.resolveRejects[e];if(delete this.resolveRejects[e],!n)return;t.error?n.reject(Ch(l4(t.error))):n.resolve(l4(t.data));return}if(!this.messageHandlers[t.type]){this.completeTask(e,null,null);return}let n=l4(t.data),r=new AbortController;this.abortControllers[e]=r;try{let i=await this.messageHandlers[t.type](t.sourceMapId,n,r);this.completeTask(e,null,i)}catch(t){this.completeTask(e,Ch(t))}}completeTask(e,t,n){let r=[];delete this.abortControllers[e];let i={id:e,type:``,sourceMapId:this.mapId,origin:location.origin,error:t?c4(t):null,data:c4(n,r)};this.target.postMessage(i,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function p4(e,t,n){let r=e.map(e=>mg(e,`error`,()=>{n.fire(new c_(Error(`Worker failed to load. Check that the worker URL is correct.`)))},!1));return{actors:e.map((e,n)=>{let r=new f4(e,t);return r.name=`Worker ${n}`,r}),workerErrorSubscriptions:r}}function m4(e){if(!e)return!1;let t=globalThis.location;if(!t)return!1;try{return new URL(e,t.href).origin!==t.origin}catch{return!1}}function h4(){let e=import.meta.url;if(!/^https?:/.test(e))return``;let t=e.endsWith(`-dev.mjs`)?`maplibre-gl-worker-dev.mjs`:`maplibre-gl-worker.mjs`,n=new URL(`./${t}`,e);return n.searchParams.set(`v`,Xp),n.href}function g4(e){return e.endsWith(`.cjs`)||e.split(/[?#]/)[0].endsWith(`.cjs`)}function _4(e,t){let n=Rg(e);if(t)try{return new Worker(n,{type:`module`})}catch(e){console.warn(`Module worker not supported, falling back to classic worker`,e)}return new Worker(n)}async function v4(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch worker script (${t.status}): ${e}`);return t.text()}async function y4(e){let t=new Blob([await v4(e)],{type:`text/javascript`});return URL.createObjectURL(t)}function b4(){return globalThis.origin===`null`}async function Iee(e){return`data:text/javascript;charset=utf-8,${encodeURIComponent(await v4(e))}`}function Lee(e){let t=new Blob([`import ${JSON.stringify(new URL(e,import.meta.url).href)}`],{type:`text/javascript`});return URL.createObjectURL(t)}async function Ree(){let e=Kg.WORKER_URL||h4(),t=!g4(e);if(t&&b4())return _4(await Iee(e),t);if(!m4(e))return _4(e,t);if(t){let n=Lee(e);try{return _4(n,t)}finally{URL.revokeObjectURL(n)}}let n=await y4(e);try{return _4(n,t)}finally{URL.revokeObjectURL(n)}}var zee=`maplibre_preloaded_worker_pool`,x4=class e extends l_{constructor(){super(),this.active={},this.workersPromise=null}acquire(e){return this.active[e]=!0,this.start()}async start(){if(this.workersPromise)return(await this.workersPromise).slice();let t=[];for(;t.lengththis.buildActorsInBackground()),e.on(`terminate`,()=>this.handleWorkersTerminated()),e.isStarted()&&this.buildActorsInBackground()}async buildActorsInBackground(){try{await this.getActors()}catch(e){kg(e)||ig(`Failed to connect to the workers: ${e}`)}}handleWorkersTerminated(){this.workersAbortController?.abort(Error(`The workers were terminated while a message was in flight.`)),this.actorsPromise=void 0}getActors(){return this.actorsPromise??=this.buildActors(),this.actorsPromise}async buildActors(){let e=new AbortController;this.workersAbortController=e;let t=await this.workerPool.start();Ag(e.signal);let{actors:n,workerErrorSubscriptions:r}=p4(t,Jg,this);e.signal.addEventListener(`abort`,()=>{for(let e of n)e.remove();for(let e of r)e.unsubscribe()},{once:!0});for(let e of n)for(let[t,n]of Object.entries(this.messageHandlers))e.registerMessageHandler(t,n);for(let t of this.importedScriptUrls)this.importScriptInto(n,e,t);return this.fire(`workerscreate`),n}async getBuiltActors(){try{return await this.actorsPromise??[]}catch{return[]}}async importScriptInto(e,t,n){try{await Promise.all(e.map(e=>e.sendAsync({type:`IS`,data:n},t)))}catch(e){ig(`Failed to import script ${n} into the workers: ${e}`)}}async broadcast(e,t){let n=this.getActors(),r=this.workersAbortController,i=await n;return Ag(r.signal),Promise.all(i.map(n=>n.sendAsync({type:e,data:t},r)))}async registerMessageHandler(e,t){this.messageHandlers[e]=t;for(let n of await this.getBuiltActors())n.registerMessageHandler(e,t)}async unregisterMessageHandler(e){delete this.messageHandlers[e];for(let t of await this.getBuiltActors())t.unregisterMessageHandler(e)}async importScript(e){this.importedScriptUrls.add(e),await this.broadcast(`IS`,e)}watchWorkers(){this.watchingWorkers||typeof document>`u`||(this.watchingWorkers=!0,document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&this.ensureWorkers()},!1))}ensureWorkers(){return this.ensureWorkersPromise??=this.ensureWorkersInternal(),this.ensureWorkersPromise}async ensureWorkersInternal(){try{await this.ping()||await this.workerPool.restart()}finally{this.ensureWorkersPromise=void 0}}async ping(e=500){if(!this.workerPool.isStarted())return!0;let t;try{return await Promise.race([this.answersPing(),new Promise(n=>{t=setTimeout(()=>n(!1),e)})])}finally{clearTimeout(t)}}async answersPing(){try{await this.broadcast(`PI`,void 0)}catch{}return!0}},w4;function T4(){return w4||(w4=new Vee(C4()),w4.registerMessageHandler(`GR`,(e,t,n)=>e_(t,n))),w4}var E4;(function(e){let t,n,r,i;e.resetRequestQueue=()=>{t=[],n=0,r=0,i={}},e.addThrottleControl=e=>{let t=r++;return i[t]=e,t},e.removeThrottleControl=e=>{delete i[e],c()};let a=()=>{for(let e of Object.keys(i))if(i[e]())return!0;return!1};e.transformAndGetImage=async function(e,t,n,r,i=!0,a){let o=await e.transformRequest(t,n);return Ag(r.signal),E4.getImage(o,r,i,a)},e.getImage=(e,n,r=!0,i)=>new Promise((a,o)=>{e.headers||={},e.headers.accept=`image/webp,*/*`,e.type=`image`;let s={abortController:n,requestParameters:e,supportImageRefresh:r,imageBitmapOptions:i,state:`queued`,onError:e=>{o(e)},onSuccess:e=>{a(e)}};t.push(s),c()});let o=(e,t)=>typeof createImageBitmap==`function`?eee(e,t):tee(e),s=async e=>{e.state=`running`;let{requestParameters:t,supportImageRefresh:r,imageBitmapOptions:i,onError:a,onSuccess:s,abortController:u}=e,d=r===!1&&!i&&!cg(self)&&!qg(t.url)&&(!t.headers||Object.keys(t.headers).reduce((e,t)=>e&&t===`accept`,!0));n++;let f=d?l(t,u):e_(t,u);try{let t=await f;delete e.abortController,e.state=`completed`,t.data instanceof HTMLImageElement||fg(t.data)?s(t):!t.data||t.data.byteLength===0?s({data:null,cacheControl:t.cacheControl,expires:t.expires}):s({data:await o(t.data,i),cacheControl:t.cacheControl,expires:t.expires})}catch(t){delete e.abortController,a(Ch(t))}finally{n--,c()}},c=()=>{let e=a()?Kg.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:Kg.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=n;r0;r++){let e=t.shift();e.abortController.signal.aborted?r--:s(e)}},l=(e,t)=>new Promise((n,r)=>{let i=new Image,a=e.url,o=e.credentials;o&&o===`include`?i.crossOrigin=`use-credentials`:(o&&o===`same-origin`||!r_(a))&&(i.crossOrigin=`anonymous`),t.signal.addEventListener(`abort`,()=>{i.src=``,r(new Og(t.signal.reason))}),i.fetchPriority=`high`,i.onload=()=>{i.onerror=i.onload=null,n({data:i})},i.onerror=()=>{i.onerror=i.onload=null,t.signal.aborted||r(Error(`Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))},i.src=a})})(E4||={}),E4.resetRequestQueue();var Hee=class{constructor(e){this._transformRequestFn=e??null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}getTransformRequest(){return this._transformRequestFn}},D4=class extends s_{},O4=class extends D4{},k4=class extends D4{constructor(e={}){super(`style.load`,e)}},A4=class extends D4{constructor(e,t={}){super(e,t),this.dataType=`style`}},j4=class extends D4{constructor(e,t={}){super(e,t),this.dataType=`source`}},Uee=class extends D4{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n,r={}){n=n instanceof MouseEvent?n:new MouseEvent(e,n);let i=Gg.mousePos(t.getCanvas(),n),a=t.unproject(i);super(e,{point:i,lngLat:a,originalEvent:n,...r}),this._defaultPrevented=!1,this.target=t}},Wee=class extends D4{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){let r=e===`touchend`?n.changedTouches:n.touches,i=Gg.touchPos(t.getCanvasContainer(),r),a=i.map(e=>t.unproject(e)),o=i.reduce((e,t,n,r)=>e.add(t.div(r.length)),new U(0,0)),s=t.unproject(o);super(e,{points:i,point:o,lngLats:a,lngLat:s,originalEvent:n}),this._defaultPrevented=!1}},Gee=class extends D4{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super(`wheel`,{originalEvent:t}),this._defaultPrevented=!1}},M4=class extends D4{},Kee=class extends D4{constructor(e={}){super(`terrain`,e)}},qee=class extends D4{constructor(e={}){super(`projectiontransition`,e)}},N4=class extends D4{},Jee=class extends D4{constructor(e={}){super(`styleimagemissing`,e)}},P4=class{constructor(){this.first=!0}update(e,t){let n=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=t):this.lastFloorZoomthis.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*t}}},I4=class{constructor(e,t,n,r){this.property=e,this.value=t,this.expression=Ry(t===void 0?e.specification.default:t,n,e.specification,r)}isDataDriven(){return this.expression.kind===`source`||this.expression.kind===`composite`}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}readsGlobalState(e){let t=this.getGlobalStateRefs();return e.some(e=>t.has(e))}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}},L4=class{constructor(e,t,n){this.property=e,this.value=new I4(e,void 0,t,n)}transitioned(e,t){return t.value===this.value?t:new z4(this.property,this.value,t,{...e.transition,...this.transition},e.now)}untransitioned(){return new z4(this.property,this.value,null,{},0)}},R4=class{constructor(e,t,n){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=n,this._rootKey=t}_propertyRootKey(e){return`${this._rootKey}.${String(e)}`}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return ng(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new L4(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].value=new I4(this._values[e].property,t===null?void 0:ng(t),this._propertyRootKey(e),this._globalState)}setValues(e){for(let t in e){let n=e[t];t.endsWith(`-transition`)?this.setTransition(t.slice(0,-11),n):tg(this._values[t].value.value,n)||this.setValue(t,n)}}getTransition(e){return ng(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new L4(this._values[e].property,this._propertyRootKey(e),this._globalState)),this._values[e].transition=ng(t)||void 0}retainPriorGlobalState(e,t,n){for(let r of Object.keys(n._values))for(let i=n._values[r];i;i=i.prior){let{value:n}=i;n.property.specification.transition&&!n.isDataDriven()&&n.expression._globalState===this._globalState&&n.readsGlobalState(e)&&(i.value=new I4(n.property,n.value,this._propertyRootKey(r),t))}}applyGlobalStateChange(e,t,n,r){this.retainPriorGlobalState(e,t,n);let i=!1;for(let t of Object.keys(this._values)){let{value:n}=this._values[t];n.readsGlobalState(e)&&(this.setValue(t,n.value),i=!0)}return i?this.transitioned(r,n):n}serialize(){let e={};for(let t of Object.keys(this._values)){let n=this.getValue(t);n!==void 0&&(e[t]=n);let r=this.getTransition(t);r!==void 0&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){let n=new B4(this._properties);for(let r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(e,t._values[r]);return n}untransitioned(){let e=new B4(this._properties);for(let t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}},z4=class{constructor(e,t,n,r,i){this.property=e,this.value=t,this.begin=i+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){let r=e.now||0,i=this.value.possiblyEvaluate(e,t,n),a=this.prior;if(!a)return i;if(r>this.end||this.value.isDataDriven())return this.prior=null,i;if(rr.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}},J4=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,n,r){if(e.value!==void 0){if(e.expression.kind===`constant`){let i=e.expression.evaluate(t,null,{},n,r);return this._calculate(i,i,i,t)}return this._calculate(e.expression.evaluate(new F4(Math.floor(t.zoom-1),t)),e.expression.evaluate(new F4(Math.floor(t.zoom),t)),e.expression.evaluate(new F4(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}},Y4=class{constructor(e,t){this.specification=e,this.name=t}possiblyEvaluate(e,t,n,r){return!!e.expression.evaluate(t,null,{},n,r)}interpolate(){return!1}},X4=class{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let t in e){let n=e[t];n.specification.overridable&&this.overridableProperties.push(t);let r=this.defaultPropertyValues[t]=new I4(n,void 0,n.name,void 0),i=this.defaultTransitionablePropertyValues[t]=new L4(n,n.name,void 0);this.defaultTransitioningPropertyValues[t]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}};Y(`DataDrivenProperty`,K4),Y(`DataConstantProperty`,X),Y(`CrossFadedDataDrivenProperty`,q4),Y(`CrossFadedProperty`,J4),Y(`ColorRampProperty`,Y4);var Z4=` is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?`,Q4=` is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?`,$4=class extends l_{constructor(e,t,n){if(super(),this.id=e.id,this.type=e.type,this._globalState=n,this._featureFilter={filter:()=>!0,needGeometry:!1,needCamera:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=n4(this.visibility,`layers[${this.id}].layout.visibility`,n),e.type!==`custom`&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!==`background`&&(this.source=e.source,this.sourceLayer=e[`source-layer`],this.filter=e.filter,this._featureFilter=Xy(e.filter,`layers[${this.id}].filter`,n)),t.layout&&(this._unevaluatedLayout=new V4(t.layout,`layers[${this.id}].layout`,n)),t.paint)){this._transitionablePaint=new R4(t.paint,`layers[${this.id}].paint`,n);for(let t in e.paint)this.setPaintProperty(t,e.paint[t]);for(let t in e.layout)this.setLayoutProperty(t,e.layout[t]);this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new U4(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=Xy(e,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){if(e===`visibility`)return this.visibility;if(this._transitionablePaint?.hasProperty(e))throw Error(e+Z4);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${e}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){let e=new Set;for(let t of this._visibilityExpression.getGlobalStateRefs())e.add(t);if(this._unevaluatedLayout)for(let t in this._unevaluatedLayout._values){let n=this._unevaluatedLayout._values[t];for(let t of n.getGlobalStateRefs())e.add(t)}for(let t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){let e=new globalThis.Map;if(this._transitionablePaint)for(let t in this._transitionablePaint._values){let n=this._transitionablePaint._values[t].value;for(let r of n.getGlobalStateRefs()){let i=e.get(r)??[];i.push({name:t,value:n.value}),e.set(r,i)}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t){e===`visibility`?(this.visibility=t,this._visibilityExpression.setValue(t),this.recalculateVisibility()):this._transitionablePaint?.hasProperty(e)?this.fire(new c_(Error(e+Z4))):this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){if(e.endsWith(`-transition`)){let t=e.slice(0,-11);if(t===`visibility`||this._unevaluatedLayout?.hasProperty(t))throw Error(e+Q4);return this._transitionablePaint.getTransition(t)}if(e===`visibility`||this._unevaluatedLayout?.hasProperty(e))throw Error(e+Q4);return this._transitionablePaint.getValue(e)}setPaintProperty(e,t){if(e===`visibility`||this._unevaluatedLayout?.hasProperty(e))return this.fire(new c_(Error(e+Q4))),!1;if(e.endsWith(`-transition`))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{let n=this._transitionablePaint._values[e],r=n.property.specification[`property-type`]===`cross-faded-data-driven`,i=n.value.isDataDriven(),a=n.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);let o=this._transitionablePaint._values[e].value;return o.isDataDriven()||i||r||this._paintPropertyRequiresRelayout(e,a,o)}}_handleSpecialPaintPropertyUpdate(e){}_paintPropertyRequiresRelayout(e,t,n){return!1}isHidden(e=this.minzoom,t=!1){return this.minzoom&&e<(t?Math.floor(this.minzoom):this.minzoom)||this.maxzoom&&e>=this.maxzoom?!0:this._evaluatedVisibility===`none`}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}retainPriorGlobalState(e,t){this._transitionablePaint?.retainPriorGlobalState(e,t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){let e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout?.serialize(),paint:this._transitionablePaint?.serialize()};return this.visibility&&(e.layout||={},e.layout.visibility=this.visibility),eg(e,(e,t)=>e!==void 0&&!(t===`layout`&&!Object.keys(e).length)&&!(t===`paint`&&!Object.keys(e).length))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let t=this.paint.get(e);if(t instanceof H4&&fy(t.property.specification)&&(t.value.kind===`source`||t.value.kind===`composite`)&&t.value.isStateDependent)return!0}return!1}},e3,t3=()=>e3||=new X4({"raster-opacity":new X(K.paint_raster[`raster-opacity`],`raster-opacity`),"raster-layer-blend":new X(K.paint_raster[`raster-layer-blend`],`raster-layer-blend`),"raster-hue-rotate":new X(K.paint_raster[`raster-hue-rotate`],`raster-hue-rotate`),"raster-brightness-min":new X(K.paint_raster[`raster-brightness-min`],`raster-brightness-min`),"raster-brightness-max":new X(K.paint_raster[`raster-brightness-max`],`raster-brightness-max`),"raster-saturation":new X(K.paint_raster[`raster-saturation`],`raster-saturation`),"raster-contrast":new X(K.paint_raster[`raster-contrast`],`raster-contrast`),resampling:new X(K.paint_raster.resampling,`resampling`),"raster-resampling":new X(K.paint_raster[`raster-resampling`],`raster-resampling`),"raster-fade-duration":new X(K.paint_raster[`raster-fade-duration`],`raster-fade-duration`)}),n3={get paint(){return t3()}},r3=e=>e.type===`raster`,i3=class extends $4{constructor(e,t){super(e,n3,t)}},a3,o3=()=>a3||=new X4({"hillshade-illumination-direction":new X(K.paint_hillshade[`hillshade-illumination-direction`],`hillshade-illumination-direction`),"hillshade-illumination-altitude":new X(K.paint_hillshade[`hillshade-illumination-altitude`],`hillshade-illumination-altitude`),"hillshade-illumination-anchor":new X(K.paint_hillshade[`hillshade-illumination-anchor`],`hillshade-illumination-anchor`),"hillshade-exaggeration":new X(K.paint_hillshade[`hillshade-exaggeration`],`hillshade-exaggeration`),"hillshade-shadow-color":new X(K.paint_hillshade[`hillshade-shadow-color`],`hillshade-shadow-color`),"hillshade-highlight-color":new X(K.paint_hillshade[`hillshade-highlight-color`],`hillshade-highlight-color`),"hillshade-accent-color":new X(K.paint_hillshade[`hillshade-accent-color`],`hillshade-accent-color`),"hillshade-method":new X(K.paint_hillshade[`hillshade-method`],`hillshade-method`),resampling:new X(K.paint_hillshade.resampling,`resampling`)}),s3={get paint(){return o3()}},c3=e=>e.type===`hillshade`,l3=class extends $4{constructor(e,t){super(e,s3,t),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get(`hillshade-illumination-direction`).values,t=this.paint.get(`hillshade-illumination-altitude`).values,n=this.paint.get(`hillshade-highlight-color`).values,r=this.paint.get(`hillshade-shadow-color`).values,i=Math.max(e.length,t.length,n.length,r.length);e=e.concat(Array(i-e.length).fill(e.at(-1))),t=t.concat(Array(i-t.length).fill(t.at(-1))),n=n.concat(Array(i-n.length).fill(n.at(-1))),r=r.concat(Array(i-r.length).fill(r.at(-1)));let a=t.map(hg);return{directionRadians:e.map(hg),altitudeRadians:a,shadowColor:r,highlightColor:n}}hasOffscreenPass(){return this.paint.get(`hillshade-exaggeration`)!==0&&!this.isHidden()}},u3,d3=()=>u3||=new X4({"color-relief-opacity":new X(K[`paint_color-relief`][`color-relief-opacity`],`color-relief-opacity`),"color-relief-color":new Y4(K[`paint_color-relief`][`color-relief-color`],`color-relief-color`),resampling:new X(K[`paint_color-relief`].resampling,`resampling`)}),f3={get paint(){return d3()}};function p3(e,{width:t,height:n},r,i){if(!i)i=new Uint8Array(t*n*r);else if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==t*n*r)throw RangeError(`mismatched image size. expected: ${i.length} but got: ${t*n*r}`);return e.width=t,e.height=n,e.data=i,e}function m3(e,{width:t,height:n},r){if(t===e.width&&n===e.height)return;let i=p3({},{width:t,height:n},r);h3(e,i,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,n)},r),e.width=t,e.height=n,e.data=i.data}function h3(e,t,n,r,i,a){if(i.width===0||i.height===0)return t;if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw RangeError(`out of range source coordinates for image copy`);if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw RangeError(`out of range destination coordinates for image copy`);let o=e.data,s=t.data;if(o===s)throw Error(`srcData equals dstData, so image is already copied`);for(let c=0;c0&&i>0){let t=this.useMipmap?Math.floor(Math.log2(Math.max(r,i)))+1:1;if(s.texStorage2D(s.TEXTURE_2D,t,s.RGBA8,r,i),y3(e)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:t}=e;c&&t&&(t=v3(t)),t&&s.texSubImage2D(s.TEXTURE_2D,0,0,0,r,i,s.RGBA,s.UNSIGNED_BYTE,t)}else o.pixelStoreUnpackPremultiplyAlpha.set(c),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,e)}else y3(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,c,r,i,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(c),this._uploadDomImage(e,s))}else{let{x:t,y:a}=n||{x:0,y:0};y3(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,c,t,a,r,i,s)):(o.pixelStoreUnpackPremultiplyAlpha.set(c),this._updateDomImage(e,t,a,s))}this.useMipmap&&!(y3(e)&&e.data===null)&&s.generateMipmap(s.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,t){t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,t.UNSIGNED_BYTE,e)}_uploadRawData(e,t,n,r,i){let{data:a}=e;t&&a&&(a=v3(a)),i.texImage2D(i.TEXTURE_2D,0,this.format,n,r,0,this.format,i.UNSIGNED_BYTE,a)}_updateDomImage(e,t,n,r){r.texSubImage2D(r.TEXTURE_2D,0,t,n,r.RGBA,r.UNSIGNED_BYTE,e)}_updateRawData(e,t,n,r,i,a,o){let{data:s}=e;t&&s&&(s=v3(s)),o.texSubImage2D(o.TEXTURE_2D,0,n,r,i,a,o.RGBA,o.UNSIGNED_BYTE,s)}bind(e,t,n){let{context:r}=this,{gl:i}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),i.bindTexture(i.TEXTURE_2D,this.texture),n!==i.LINEAR_MIPMAP_NEAREST&&n!==i.LINEAR_MIPMAP_LINEAR||this.useMipmap||(n=i.LINEAR);let a=n||e;e!==this.magFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),this.magFilter=e),a!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,a),this.minFilter=a),t!==this.wrap&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrap=t)}generateMipmap(){if(!this.useMipmap)return;let{gl:e}=this.context;e.bindTexture(e.TEXTURE_2D,this.texture),e.generateMipmap(e.TEXTURE_2D)}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},x3=class e{static{this.byteViewCache=new WeakMap}constructor(t,n,r,i=1,a=1,o=1,s=0){if(this.uid=t,n.height!==n.width)throw RangeError(`DEM tiles must be square`);if(r&&![`mapbox`,`terrarium`,`custom`].includes(r)){ig(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);return}this.stride=n.height;let c=this.dim=n.height-4;switch(this.data=new Uint32Array(n.data.buffer),e.byteViewCache.set(this,new Uint8Array(this.data.buffer)),r){case`terrarium`:this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case`custom`:this.redFactor=i,this.greenFactor=a,this.blueFactor=o,this.baseShift=s;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let e=-2;e=c)&&this.data.copyWithin(this._idx(0,e),t,t+c),this.data.fill(this.data[t],this._idx(-2,e),this._idx(0,e)),this.data.fill(this.data[t+c-1],this._idx(c,e),this._idx(c+1,e)+1)}let l=this._getByteView();this.min=2**53-1,this.max=-(2**53-1);for(let e=0;ethis.max&&(this.max=r),r=this.dim||r<-1||r>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);let i=this._getByteView(),a=((r+2)*this.stride+n+2)*4,o=this.stride*4,s=e-n,c=t-r,l=this._unpackAtIndex(i,a),u=this._unpackAtIndex(i,a+4),d=this._unpackAtIndex(i,a+o),f=this._unpackAtIndex(i,a+o+4);return l*(1-s)*(1-c)+u*s*(1-c)+d*(1-s)*c+f*s*c}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-2||e>=this.dim+2||t<-2||t>=this.dim+2)throw RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);return(t+2)*this.stride+(e+2)}unpack(e,t,n){return e*this.redFactor+t*this.greenFactor+n*this.blueFactor-this.baseShift}pack(e){return S3(e,this.getUnpackVector())}getPixels(){return new _3({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(e,t,n){if(this.dim!==e.dim)throw Error(`dem dimension mismatch`);let r=t*this.dim,i=t*this.dim+this.dim,a=n*this.dim,o=n*this.dim+this.dim;switch(t){case-1:r=i-2;break;case 1:i=r+2}switch(n){case-1:a=o-2;break;case 1:o=a+2}let s=-t*this.dim,c=-n*this.dim;for(let t=a;te!==0);if(o.length===0)return{r:0,g:0,b:0};let s=Math.min(...o),c=Math.round((e+a)/s),l=e=>e===0?0:Math.floor(c*s/e)%256;return{r:l(n),g:l(r),b:l(i)}}Y(`DEMData`,x3);var C3=e=>e.type===`color-relief`,w3=class extends $4{constructor(e,t){super(e,f3,t)}_createColorRamp(e){let t={elevationStops:[],colorStops:[]},n=this._transitionablePaint._values[`color-relief-color`].value.expression;if(n instanceof Ny&&n._styleExpression.expression instanceof w0){this.colorRampExpression=n;let e=n._styleExpression.expression;t.elevationStops=e.labels,t.colorStops=[];for(let n of t.elevationStops)t.colorStops.push(e.evaluate({globals:{elevation:n}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[R1.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;let r={elevationStops:[],colorStops:[]},i=(t.elevationStops.length-1)/(e-1);for(let e=0;eT3||=new X4({"background-color":new X(K.paint_background[`background-color`],`background-color`),"background-pattern":new J4(K.paint_background[`background-pattern`],`background-pattern`),"background-opacity":new X(K.paint_background[`background-opacity`],`background-opacity`)}),D3={get paint(){return E3()}},O3=e=>e.type===`background`,k3=class extends $4{constructor(e,t){super(e,D3,t)}};function A3(e){let t=[],n=e.id;return n===void 0&&t.push(new q(`layers.${n}`,null,`missing required property "id"`)),e.render===void 0&&t.push(new q(`layers.${n}`,null,`missing required method "render"`)),e.renderingMode&&e.renderingMode!==`2d`&&e.renderingMode!==`3d`&&t.push(new q(`layers.${n}`,null,`property "renderingMode" must be either "2d" or "3d"`)),t}var j3=e=>e.type===`custom`,M3=class extends $4{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode===`3d`}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error(`Custom layers cannot be serialized`)}},N3={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},P3=class{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}},F3=class{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(this.capacity*5),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw Error(`_refreshViews() must be implemented by each concrete StructArray layout`)}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}};function I3(e,t=1){let n=0,r=0;return{members:e.map(e=>{let i=L3(e.type),a=n=R3(n,Math.max(t,i)),o=e.components||1;return r=Math.max(r,i),n+=i*o,{name:e.name,type:e.type,components:o,offset:a}}),size:R3(n,Math.max(r,t)),alignment:t}}function L3(e){return N3[e].BYTES_PER_ELEMENT}function R3(e,t){return Math.ceil(e/t)*t}var z3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=e*2;return this.int16[r+0]=t,this.int16[r+1]=n,e}};z3.prototype.bytesPerElement=4,Y(`StructArrayLayout2i4`,z3);var B3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=e*3;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=r,e}};B3.prototype.bytesPerElement=6,Y(`StructArrayLayout3i6`,B3);var V3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){let i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){let a=e*4;return this.int16[a+0]=t,this.int16[a+1]=n,this.int16[a+2]=r,this.int16[a+3]=i,e}};V3.prototype.bytesPerElement=8,Y(`StructArrayLayout4i8`,V3);var H3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=e*6;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,e}};H3.prototype.bytesPerElement=12,Y(`StructArrayLayout2i4i12`,H3);var U3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.int8=new Int8Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s){let c=this.length;return this.resize(c+1),this.emplace(c,e,t,n,r,i,a,o,s)}emplace(e,t,n,r,i,a,o,s,c){let l=e*5,u=e*10;return this.int16[l+0]=t,this.int16[l+1]=n,this.uint8[u+4]=r,this.uint8[u+5]=i,this.uint8[u+6]=a,this.uint8[u+7]=o,this.int8[u+8]=s,this.int8[u+9]=c,e}};U3.prototype.bytesPerElement=10,Y(`StructArrayLayout2i4ub2b10`,U3);var W3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=e*2;return this.float32[r+0]=t,this.float32[r+1]=n,e}};W3.prototype.bytesPerElement=8,Y(`StructArrayLayout2f8`,W3);var G3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let n=+e;return this.float32[n+0]=t,e}};G3.prototype.bytesPerElement=4,Y(`StructArrayLayout1f4`,G3);var K3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,t,n,r,i,a,o,s,c,l)}emplace(e,t,n,r,i,a,o,s,c,l,u){let d=e*10;return this.uint16[d+0]=t,this.uint16[d+1]=n,this.uint16[d+2]=r,this.uint16[d+3]=i,this.uint16[d+4]=a,this.uint16[d+5]=o,this.uint16[d+6]=s,this.uint16[d+7]=c,this.uint16[d+8]=l,this.uint16[d+9]=u,e}};K3.prototype.bytesPerElement=20,Y(`StructArrayLayout10ui20`,K3);var q3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s){let c=this.length;return this.resize(c+1),this.emplace(c,e,t,n,r,i,a,o,s)}emplace(e,t,n,r,i,a,o,s,c){let l=e*8;return this.uint16[l+0]=t,this.uint16[l+1]=n,this.uint16[l+2]=r,this.uint16[l+3]=i,this.uint16[l+4]=a,this.uint16[l+5]=o,this.uint16[l+6]=s,this.uint16[l+7]=c,e}};q3.prototype.bytesPerElement=16,Y(`StructArrayLayout8ui16`,q3);var J3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=this.length;return this.resize(p+1),this.emplace(p,e,t,n,r,i,a,o,s,c,l,u,d,f)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=e*14,h=e*7;return this.int16[m+0]=t,this.int16[m+1]=n,this.int16[m+2]=r,this.int16[m+3]=i,this.uint16[m+4]=a,this.uint16[m+5]=o,this.uint16[m+6]=s,this.uint16[m+7]=c,this.int16[m+8]=l,this.int16[m+9]=u,this.int16[m+10]=d,this.int16[m+11]=f,this.float32[h+6]=p,e}};J3.prototype.bytesPerElement=28,Y(`StructArrayLayout4i4ui4i1f28`,J3);var Y3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=e*3;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}};Y3.prototype.bytesPerElement=12,Y(`StructArrayLayout3f12`,Y3);var X3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let n=+e;return this.uint32[n+0]=t,e}};X3.prototype.bytesPerElement=4,Y(`StructArrayLayout1ul4`,X3);var Z3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c){let l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,r,i,a,o,s,c)}emplace(e,t,n,r,i,a,o,s,c,l){let u=e*10,d=e*5;return this.int16[u+0]=t,this.int16[u+1]=n,this.int16[u+2]=r,this.int16[u+3]=i,this.int16[u+4]=a,this.int16[u+5]=o,this.uint32[d+3]=s,this.uint16[u+8]=c,this.uint16[u+9]=l,e}};Z3.prototype.bytesPerElement=20,Y(`StructArrayLayout6i1ul2ui20`,Z3);var Q3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=e*6;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=a,this.int16[s+5]=o,e}};Q3.prototype.bytesPerElement=12,Y(`StructArrayLayout2i2i2i12`,Q3);var $3=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){let a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i)}emplace(e,t,n,r,i,a){let o=e*4,s=e*8;return this.float32[o+0]=t,this.float32[o+1]=n,this.float32[o+2]=r,this.int16[s+6]=i,this.int16[s+7]=a,e}};$3.prototype.bytesPerElement=16,Y(`StructArrayLayout2f1f2i16`,$3);var e6=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a){let o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i,a)}emplace(e,t,n,r,i,a,o){let s=e*16,c=e*4,l=e*8;return this.uint8[s+0]=t,this.uint8[s+1]=n,this.float32[c+1]=r,this.float32[c+2]=i,this.int16[l+6]=a,this.int16[l+7]=o,e}};e6.prototype.bytesPerElement=16,Y(`StructArrayLayout2ub2f2i16`,e6);var t6=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=e*3;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=r,e}};t6.prototype.bytesPerElement=6,Y(`StructArrayLayout3ui6`,t6);var n6=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){let v=this.length;return this.resize(v+1),this.emplace(v,e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=e*28,b=e*14,x=e*56;return this.int16[y+0]=t,this.int16[y+1]=n,this.uint32[b+1]=r,this.uint16[y+4]=i,this.uint32[b+3]=a,this.uint32[b+4]=o,this.uint32[b+5]=s,this.uint16[y+12]=c,this.uint16[y+13]=l,this.uint16[y+14]=u,this.float32[b+8]=d,this.float32[b+9]=f,this.uint8[x+40]=p,this.uint8[x+41]=m,this.uint8[x+42]=h,this.uint32[b+11]=g,this.int16[y+24]=_,this.float32[b+13]=v,e}};n6.prototype.bytesPerElement=56,Y(`StructArrayLayout2i1ul1ui3ul3ui2f3ub1ul1i1f56`,n6);var r6=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O){let k=this.length;return this.resize(k+1),this.emplace(k,e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O)}emplace(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k){let A=e*34,j=e*17;return this.int16[A+0]=t,this.int16[A+1]=n,this.int16[A+2]=r,this.int16[A+3]=i,this.int16[A+4]=a,this.int16[A+5]=o,this.int16[A+6]=s,this.int16[A+7]=c,this.uint16[A+8]=l,this.uint16[A+9]=u,this.uint16[A+10]=d,this.uint16[A+11]=f,this.uint16[A+12]=p,this.uint16[A+13]=m,this.uint16[A+14]=h,this.uint16[A+15]=g,this.uint16[A+16]=_,this.uint16[A+17]=v,this.uint16[A+18]=y,this.uint16[A+19]=b,this.uint16[A+20]=x,this.uint16[A+21]=S,this.uint16[A+22]=C,this.uint32[j+12]=w,this.float32[j+13]=T,this.float32[j+14]=E,this.uint16[A+30]=D,this.uint16[A+31]=O,this.float32[j+16]=k,e}};r6.prototype.bytesPerElement=68,Y(`StructArrayLayout8i15ui1ul2f2ui1f68`,r6);var i6=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=e*6,a=e*3;return this.uint16[i+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,e}};i6.prototype.bytesPerElement=12,Y(`StructArrayLayout1ui2f12`,i6);var a6=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){let r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){let i=e*2,a=e*4;return this.uint32[i+0]=t,this.uint16[a+2]=n,this.uint16[a+3]=r,e}};a6.prototype.bytesPerElement=8,Y(`StructArrayLayout1ul2ui8`,a6);var o6=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){let n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){let r=e*2;return this.uint16[r+0]=t,this.uint16[r+1]=n,e}};o6.prototype.bytesPerElement=4,Y(`StructArrayLayout2ui4`,o6);var s6=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){let n=+e;return this.uint16[n+0]=t,e}};s6.prototype.bytesPerElement=2,Y(`StructArrayLayout1ui2`,s6);var c6=class extends F3{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){let i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){let a=e*4;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.float32[a+3]=i,e}};c6.prototype.bytesPerElement=16,Y(`StructArrayLayout4f16`,c6);var l6=class extends P3{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new U(this.anchorPointX,this.anchorPointY)}};l6.prototype.size=20;var u6=class extends Z3{get(e){return new l6(this,e)}};Y(`CollisionBoxArray`,u6);var d6=class extends P3{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint32[this._pos4+1]}get numGlyphs(){return this._structArray.uint16[this._pos2+4]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineStartIndex(){return this._structArray.uint32[this._pos4+4]}get lineLength(){return this._structArray.uint32[this._pos4+5]}get segment(){return this._structArray.uint16[this._pos2+12]}get lowerSize(){return this._structArray.uint16[this._pos2+13]}get upperSize(){return this._structArray.uint16[this._pos2+14]}get lineOffsetX(){return this._structArray.float32[this._pos4+8]}get lineOffsetY(){return this._structArray.float32[this._pos4+9]}get writingMode(){return this._structArray.uint8[this._pos1+40]}get placedOrientation(){return this._structArray.uint8[this._pos1+41]}set placedOrientation(e){this._structArray.uint8[this._pos1+41]=e}get hidden(){return this._structArray.uint8[this._pos1+42]}set hidden(e){this._structArray.uint8[this._pos1+42]=e}get crossTileID(){return this._structArray.uint32[this._pos4+11]}set crossTileID(e){this._structArray.uint32[this._pos4+11]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+24]}get heightOffset(){return this._structArray.float32[this._pos4+13]}};d6.prototype.size=56;var f6=class extends n6{get(e){return new d6(this,e)}};Y(`PlacedSymbolArray`,f6);var p6=class extends P3{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}get heightOffset(){return this._structArray.float32[this._pos4+16]}};p6.prototype.size=68;var m6=class extends r6{get(e){return new p6(this,e)}};Y(`SymbolInstanceArray`,m6);var h6=class extends G3{getoffsetX(e){return this.float32[+e+0]}};Y(`GlyphOffsetArray`,h6);var g6=class extends B3{getx(e){return this.int16[e*3+0]}gety(e){return this.int16[e*3+1]}gettileUnitDistanceFromAnchor(e){return this.int16[e*3+2]}};Y(`SymbolLineVertexArray`,g6);var _6=class extends P3{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}};_6.prototype.size=12;var v6=class extends i6{get(e){return new _6(this,e)}};Y(`TextAnchorOffsetArray`,v6);var y6=class extends P3{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}};y6.prototype.size=8;var b6=class extends a6{get(e){return new y6(this,e)}};Y(`FeatureIndexArray`,b6);var x6=class extends z3{},S6=class extends B3{},C6=class extends V3{},w6=class extends z3{},T6=class extends z3{},E6=class extends H3{},D6=class extends U3{},O6=class extends W3{},k6=class extends G3{},A6=class extends K3{},j6=class extends q3{},M6=class extends J3{},N6=class extends Y3{},P6=class extends X3{},F6=class extends Q3{},I6=class extends $3{},L6=class extends e6{},R6=class extends t6{},z6=class extends t6{},B6=class extends o6{},V6=class extends s6{},H6=I3([{name:`a_pos`,components:2,type:`Int16`}],4),U6=H6.members;H6.size,H6.alignment;var W6=class e{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(t,n,r,i){let a=this.segments[this.segments.length-1];return t>e.MAX_VERTEX_ARRAY_LENGTH&&ig(`Max vertices per segment is ${e.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${e.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!a||a.vertexLength+t>e.MAX_VERTEX_ARRAY_LENGTH||a.sortKey!==i?this.createNewSegment(n,r,i):a}createNewSegment(e,t,n){let r={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return n!==void 0&&(r.sortKey=n),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(e,t,n){return this.prepareSegment(0,e,t,n)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let e of this.segments)for(let t in e.vaos)e.vaos[t].destroy()}static simpleSegment(t,n,r,i){return new e([{vertexOffset:t,primitiveOffset:n,vertexLength:r,primitiveLength:i,vaos:{},sortKey:0}])}};W6.MAX_VERTEX_ARRAY_LENGTH=2**16-1,Y(`SegmentVector`,W6);function G6(e,t){return e=G(Math.floor(e),0,255),t=G(Math.floor(t),0,255),256*e+t}var K6=I3([{name:`a_pattern_from`,components:4,type:`Uint16`},{name:`a_pattern_to`,components:4,type:`Uint16`},{name:`a_pixel_ratio_from`,components:1,type:`Uint16`},{name:`a_pixel_ratio_to`,components:1,type:`Uint16`}]),q6=I3([{name:`a_dasharray_from`,components:4,type:`Uint16`},{name:`a_dasharray_to`,components:4,type:`Uint16`}]),J6=qp(((e,t)=>{function n(e,t){for(var n=e.length&3,r=e.length-n,i=t,a,o=0xcc9e2d51,s=461845907,c,l=0;l>>16)*o&65535)<<16)|0,c=c<<15|c>>>17,c=(c&65535)*s+(((c>>>16)*s&65535)<<16)|0,i^=c,i=i<<13|i>>>19,a=(i&65535)*5+(((i>>>16)*5&65535)<<16)|0,i=(a&65535)+27492+(((a>>>16)+58964&65535)<<16);switch(c=0,n){case 3:c^=(e.charCodeAt(l+2)&255)<<16;case 2:c^=(e.charCodeAt(l+1)&255)<<8;case 1:c^=e.charCodeAt(l)&255,c=(c&65535)*o+(((c>>>16)*o&65535)<<16)|0,c=c<<15|c>>>17,c=(c&65535)*s+(((c>>>16)*s&65535)<<16)|0,i^=c}return i^=e.length,i^=i>>>16,i=(i&65535)*0x85ebca6b+(((i>>>16)*0x85ebca6b&65535)<<16)|0,i^=i>>>13,i=(i&65535)*0xc2b2ae35+(((i>>>16)*0xc2b2ae35&65535)<<16)|0,i^=i>>>16,i>>>0}t!==void 0&&(t.exports=n)})),Y6=qp(((e,t)=>{t.exports=function(e,t){for(var n=e.length,r=t^n,i=0,a;n>=4;)a=e.charCodeAt(i)&255|(e.charCodeAt(++i)&255)<<8|(e.charCodeAt(++i)&255)<<16|(e.charCodeAt(++i)&255)<<24,a=(a&65535)*0x5bd1e995+(((a>>>16)*0x5bd1e995&65535)<<16),a^=a>>>24,a=(a&65535)*0x5bd1e995+(((a>>>16)*0x5bd1e995&65535)<<16),r=(r&65535)*0x5bd1e995+(((r>>>16)*0x5bd1e995&65535)<<16)^a,n-=4,++i;switch(n){case 3:r^=(e.charCodeAt(i+2)&255)<<16;case 2:r^=(e.charCodeAt(i+1)&255)<<8;case 1:r^=e.charCodeAt(i)&255,r=(r&65535)*0x5bd1e995+(((r>>>16)*0x5bd1e995&65535)<<16)}return r^=r>>>13,r=(r&65535)*0x5bd1e995+(((r>>>16)*0x5bd1e995&65535)<<16),r^=r>>>15,r>>>0}})),X6=Yp(qp(((e,t)=>{var n=J6(),r=Y6();t.exports=n,t.exports.murmur3=n,t.exports.murmur2=r}))(),1),Z6=class e{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(Q6(e)),this.positions.push(t,n,r)}getPositions(e){if(!this.indexed)throw Error(`Trying to get index, but feature positions are not indexed`);let t=Q6(e),n=0,r=this.ids.length-1;for(;n>1;this.ids[e]>=t?r=e:n=e+1}let i=[];for(;this.ids[n]===t;){let e=this.positions[3*n],t=this.positions[3*n+1],r=this.positions[3*n+2];i.push({index:e,start:t,end:r}),n++}return i}static serialize(e,t){let n=new Float64Array(e.ids),r=new Uint32Array(e.positions);return $6(n,r,0,n.length-1),t&&t.push(n.buffer,r.buffer),{ids:n,positions:r}}static deserialize(t){let n=new e;return n.ids=t.ids,n.positions=t.positions,n.indexed=!0,n}};function Q6(e){let t=+e;return!isNaN(t)&&t<=2**53-1?t:(0,X6.default)(String(e))}function $6(e,t,n,r){let i=!1;for(;n>1],o=n-1,s=r+1;for(;;){do o++;while(e[o]a);if(o>=s)break;eb(e,o,s),eb(t,3*o,3*s),eb(t,3*o+1,3*s+1),eb(t,3*o+2,3*s+2)}i=Math.min(s-n,r-s)>3,s-n`u_${e}`),this.type=n}setUniform(e,t,n){e.set(n.constantOr(this.value))}getBinding(e,t,n){return this.type===`color`?new ob(e,t):new Z(e,t)}},pb=class{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.dashFrom=null,this.dashTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,n,r){let i=null;r===`u_pattern_to`?i=this.patternTo:r===`u_pattern_from`?i=this.patternFrom:r===`u_dasharray_to`?i=this.dashTo:r===`u_dasharray_from`?i=this.dashFrom:r===`u_pixel_ratio_to`?i=this.pixelRatioTo:r===`u_pixel_ratio_from`&&(i=this.pixelRatioFrom),i!==null&&e.set(i)}getBinding(e,t,n){return n.startsWith(`u_pattern`)||n.startsWith(`u_dasharray_`)?new ab(e,t):new Z(e,t)}},mb=class{constructor(e,t,n,r){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:`Float32`,components:n===`color`?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,n){let r=this.paintVertexArray.length,i=this.expression.evaluate(new F4(0,n),t,{},n.canonical,[],n.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,i)}updatePaintArray(e,t,n,r,i){let a=this.expression.evaluate(new F4(0,i),n,r);this._setPaintValue(e,t,a)}_setPaintValue(e,t,n){if(this.type===`color`){let r=db(n);for(let n=e;n`u_${e}_t`),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:`Float32`,components:n===`color`?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(e,t,n){let r=this.expression.evaluate(new F4(this.zoom,n),t,{},n.canonical,[],n.formattedSection),i=this.expression.evaluate(new F4(this.zoom+1,n),t,{},n.canonical,[],n.formattedSection),a=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(a,e,r,i)}updatePaintArray(e,t,n,r,i){let a=this.expression.evaluate(new F4(this.zoom,i),n,r),o=this.expression.evaluate(new F4(this.zoom+1,i),n,r);this._setPaintValue(e,t,a,o)}_setPaintValue(e,t,n,r){if(this.type===`color`){let i=db(n),a=db(r);for(let n=e;n`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){let e=[];for(let t in this.binders){let n=this.binders[t];if(n instanceof mb||n instanceof hb)for(let t of n.paintVertexAttributes)e.push(t.name);else if(n instanceof gb){let t=n.getVertexAttributes();for(let n of t)e.push(n.name)}}return e}getBinderUniforms(){let e=[];for(let t in this.binders){let n=this.binders[t];if(n instanceof fb||n instanceof pb||n instanceof hb)for(let t of n.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){let n=[];for(let r in this.binders){let i=this.binders[r];if(i instanceof fb||i instanceof pb||i instanceof hb){for(let a of i.uniformNames)if(t[a]){let o=i.getBinding(e,t[a],a);n.push({name:a,property:r,binding:o})}}}return n}setUniforms(e,t,n,r){for(let{name:e,property:i,binding:a}of t)this.binders[i].setUniform(a,r,n.get(i),e)}updatePaintBuffers(e){this._buffers=[];for(let t in this.binders){let n=this.binders[t];if(e&&n instanceof gb){let t=e.fromScale===2?n.zoomInPaintVertexBuffer:n.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(n instanceof mb||n instanceof hb)&&n.paintVertexBuffer&&this._buffers.push(n.paintVertexBuffer)}}upload(e){for(let t in this.binders){let n=this.binders[t];(n instanceof mb||n instanceof hb||n instanceof gb)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let t=this.binders[e];(t instanceof mb||t instanceof hb||t instanceof gb)&&t.destroy()}}},bb=class{constructor(e,t,n=()=>!0){this.programConfigurations={};for(let r of e)this.programConfigurations[r.id]=new yb(r,t,n);this.needsUpload=!1,this._featureMap=new Z6,this._bufferOffset=0}populatePaintArrays(e,t,n,r){for(let n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r);t.id!==void 0&&this._featureMap.add(t.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r){for(let i of n)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(e,this._featureMap,t,i,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}};function xb(e,t){return{"text-opacity":[`opacity`],"icon-opacity":[`opacity`],"text-color":[`fill_color`],"icon-color":[`fill_color`],"text-halo-color":[`halo_color`],"icon-halo-color":[`halo_color`],"text-halo-blur":[`halo_blur`],"icon-halo-blur":[`halo_blur`],"text-halo-width":[`halo_width`],"icon-halo-width":[`halo_width`],"line-gap-width":[`gapwidth`],"line-dasharray":[`dasharray_to`,`dasharray_from`],"line-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`],"fill-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`],"fill-extrusion-pattern":[`pattern_to`,`pattern_from`,`pixel_ratio_to`,`pixel_ratio_from`]}[e]||[e.replace(`${t}-`,``).replace(/-/g,`_`)]}function Sb(e){return{"line-pattern":{source:A6,composite:A6},"fill-pattern":{source:A6,composite:A6},"fill-extrusion-pattern":{source:A6,composite:A6},"line-dasharray":{source:j6,composite:j6}}[e]}function Cb(e,t,n){let r={color:{source:W3,composite:c6},number:{source:G3,composite:W3}};return Sb(e)?.[n]||r[t][n]}Y(`ConstantBinder`,fb),Y(`CrossFadedConstantBinder`,pb),Y(`SourceExpressionBinder`,mb),Y(`CrossFadedPatternBinder`,_b),Y(`CrossFadedDasharrayBinder`,vb),Y(`CompositeExpressionBinder`,hb),Y(`ProgramConfiguration`,yb,{omit:[`_buffers`]}),Y(`ProgramConfigurationSet`,bb);var wb=2**14-1,Tb=-wb-1;function Eb(e){let t=W/e.extent,n=e.loadGeometry();for(let e of n)for(let n of e){let e=Math.round(n.x*t),r=Math.round(n.y*t);n.x=G(e,Tb,wb),n.y=G(r,Tb,wb),(en.x+1||rn.y+1)&&ig(`Geometry exceeds allowed extent, reduce your vector tile buffer size`)}return n}function Db(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Eb(e):[]}}var Ob=class e{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(t){let n=new e;return n.extend(t(new U(this.minX,this.minY))),n.extend(t(new U(this.maxX,this.minY))),n.extend(t(new U(this.minX,this.maxY))),n.extend(t(new U(this.maxX,this.maxY))),n}static fromPoints(t){let n=new e;for(let e of t)n.extend(e);return n}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}},kb=Ob.fromPoints([new U(0,0),new U(W,W)]);function Ab(e,t){return e.x===t.x&&(e.x<0||e.x>8192)||e.y===t.y&&(e.y<0||e.y>8192)}function jb(e){return e.every(e=>e.x<0)||e.every(e=>e.x>8192)||e.every(e=>e.y<0)||e.every(e=>e.y>8192)}function Mb(e){return e.x<0||e.x>=8192||e.y<0||e.y>=8192}var Nb=-32768;function Pb(e,t,n,r,i){e.emplaceBack(Nb+t*8+r,Nb+n*8+i)}var Fb=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new w6,this.indexArray=new z6,this.segments=new W6,this.programConfigurations=new bb(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n){let r=this.layers[0],i=[],a=null,o=!1,s=r.type===`heatmap`;if(r.type===`circle`){let e=r;a=e.layout.get(`circle-sort-key`),o=!a.isConstant(),s||=e.paint.get(`circle-pitch-alignment`)===`map`}let c=s?t.subdivisionGranularity.circle:1,l=new F4(this.zoom),u=this.layers[0]._featureFilter.needGeometry;for(let{feature:r,id:s,index:d,sourceLayerIndex:f}of e){let e=Db(r,u);if(!this.layers[0]._featureFilter.filter(l,e,n))continue;let p=o?a.evaluate(e,{},n):void 0,m={id:s,properties:r.properties,type:r.type,sourceLayerIndex:f,index:d,geometry:u?e.geometry:Eb(r),patterns:{},sortKey:p};o?i.push(m):this.addBucketFeature(m,r,t,n,c)}if(o){i.sort((e,t)=>e.sortKey-t.sortKey);for(let r of i)this.addBucketFeature(r,e[r.index].feature,t,n,c)}}addBucketFeature(e,t,n,r,i){let{geometry:a,index:o,sourceLayerIndex:s}=e;this.addFeature(e,a,o,r,i),n.featureIndex.insert(t,a,o,s,this.index)}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}addFeatures(e){}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,U6),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,n,r,i=1){let a;switch(i){case 1:a=[0,7];break;case 3:a=[0,2,5,7];break;case 5:a=[0,1,3,4,6,7];break;case 7:a=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}let o=a.length;for(let n of t)for(let t of n){let n=t.x,r=t.y;if(Mb(t))continue;let i=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),s=i.vertexLength;for(let e=0;e=3){for(let t of r)if(Kb(e,t))return!0}if(Bb(e,r,n))return!0}return!1}function Bb(e,t,n){if(e.length>1){if(Vb(e,t))return!0;for(let r of t)if(Ub(r,e,n))return!0}for(let r of e)if(Ub(r,t,n))return!0;return!1}function Vb(e,t){if(e.length===0||t.length===0)return!1;for(let n=0;n1?e.distSqr(n):e.distSqr(n.sub(t)._mult(i)._add(t))}function Gb(e,t){let n=!1,r,i,a;for(let o of e){r=o;for(let e=0,o=r.length-1;et.y!=a.y>t.y&&t.x<(a.x-i.x)*(t.y-i.y)/(a.y-i.y)+i.x&&(n=!n)}return n}function Kb(e,t){let n=!1;for(let r=0,i=e.length-1;rt.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}function qb(e,t,n,r,i){for(let a of e)if(t<=a.x&&n<=a.y&&r>=a.x&&i>=a.y)return!0;let a=[new U(t,n),new U(t,i),new U(r,i),new U(r,n)];if(e.length>2){for(let t of a)if(Kb(e,t))return!0}for(let t=0;ti.x&&t.x>i.x||e.yi.y&&t.y>i.y)return!1;let a=ag(e,t,n[0]);return a!==ag(e,t,n[1])||a!==ag(e,t,n[2])||a!==ag(e,t,n[3])}var Yb=6371008.8,Xb=class e{constructor(e,t){if(isNaN(e)||isNaN(t))throw Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw Error(`Invalid LngLat latitude value: must be between -90 and 90`)}wrap(){return new e(Gh(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let t=Math.PI/180,n=this.lat*t,r=e.lat*t,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return Yb*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof e)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new e(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t==`object`&&t)return new e(Number(`lng`in t?t.lng:t.lon),Number(t.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}},Zb=6378137,Qb={origin:[-Math.PI*Zb,Math.PI*Zb],extentAtZoom0:2*Math.PI*Zb},$b=2*Math.PI*Yb;function e8(e){return $b*Math.cos(e*Math.PI/180)}function t8(e){return(180+e)/360}function n8(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function r8(e,t){return e/e8(t)}function i8(e){return e*360-180}function a8(e){let t=180-e*360;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function o8(e,t){return e*e8(a8(t))}function s8(e){return 1/Math.cos(e*Math.PI/180)}var c8=class e{constructor(e,t,n=0){this.x=+e,this.y=+t,this.z=+n}static fromLngLat(t,n=0){let r=Xb.convert(t);return new e(t8(r.lng),n8(r.lat),r8(n,r.lat))}toLngLat(){return new Xb(i8(this.x),a8(this.y))}toAltitude(){return o8(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/$b*s8(a8(this.y))}},l8=new class{constructor(){this.name=`mercator`,this.wraps=!0,this.tileMatrixSet=Qb}worldFromLngLat(e,t,n){return new c8(t8(e),n8(t),n===void 0?0:r8(n,t))}lngLatFromWorld(e,t){return new Xb(i8(e),a8(t))}hasLngLat(e,t){return!0}metersPerWorldUnit(e,t){return 1/(1/$b*s8(a8(t)))}worldZFromAltitude(e,t){return r8(e,t.lat)}};function u8(e,t,n){return!(e<0||e>25||n<0||n>=2**e||t<0||t>=2**e)}function d8(e,t,n){let{x:r,y:i}=n.worldFromLngLat(t.lng,t.lat);return!(e<0||e>25||i<0||i>=1||r<0||r>=1)}var f8=class{constructor(e,t,n){if(!u8(e,t,n))throw Error(`x=${t}, y=${n}, z=${e} outside of bounds. 0<=x<${2**e}, 0<=y<${2**e} 0<=z<=25 `);this.z=e,this.x=t,this.y=n,this.key=h8(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,n,r=Qb){let i=_8(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(n===`tms`?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,t>1?`@2x`:``).replace(/{quadkey}/g,i).replace(/{bbox-epsg-3857}/g,()=>g8(this.x,this.y,this.z,Qb)).replace(/{bbox}/g,()=>g8(this.x,this.y,this.z,r))}isChildOf(e){let t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){let t=2**this.z;return new U((e.x*t-this.x)*W,(e.y*t-this.y)*W)}toString(){return`${this.z}/${this.x}/${this.y}`}},p8=class{constructor(e,t){this.wrap=e,this.canonical=t,this.key=h8(e,t.z,t.z,t.x,t.y)}},m8=class e{constructor(e,t,n,r,i){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${n}`);this.overscaledZ=e,this.wrap=t,this.canonical=new f8(n,+r,+i),this.key=h8(t,e,n,r,i)}clone(){return new e(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(t){if(t>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let n=this.canonical.z-t;return t>this.canonical.z?new e(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new e(t,this.wrap,t,this.canonical.x>>n,this.canonical.y>>n)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let n=this.canonical.z-e;return e>this.canonical.z?h8(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):h8(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(e.overscaledZ===0)return this.overscaledZ>0;let t=this.canonical.z-e.canonical.z;return t<0?!1:e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(t){if(this.overscaledZ>=t)return[new e(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let n=this.canonical.z+1,r=this.canonical.x*2,i=this.canonical.y*2;return[new e(n,this.wrap,n,r,i),new e(n,this.wrap,n,r+1,i),new e(n,this.wrap,n,r,i+1),new e(n,this.wrap,n,r+1,i+1)]}isLessThan(e){return this.wrape.wrap?!1:this.overscaledZe.overscaledZ?!1:this.canonical.xe.canonical.x?!1:this.canonical.y=0&&t=0&&n=l)return null;let d=this.canonical.x+i,f=this.wrap;return d<0?(f-=Math.ceil(-d/l),d=(d%l+l)%l):d>=l&&(f+=Math.floor(d/l),d%=l),{tileID:new e(this.overscaledZ,f,c,d,u),x:o,y:s}}};function h8(e,t,n,r,i){e*=2,e<0&&(e=e*-1-1);let a=1<0;i--){let e=1<this._ne.lng&&(i=this._sw.lng>=t&&t>=this._ne.lng),r&&i}intersects(t){if(t=e.convert(t),!(t.getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;let n=Math.abs(this.getEast()-this.getWest()),r=Math.abs(t.getEast()-t.getWest());if(n>=360||r>=360)return!0;let i=Gh(this.getWest(),-180,180),a=Gh(this.getEast(),-180,180),o=Gh(t.getWest(),-180,180),s=Gh(t.getEast(),-180,180),c=i>a,l=o>s;return c&&l?!0:c?s>=i||o<=a:l?a>=o||i<=s:o<=a&&s>=i}static convert(t){return t instanceof e||!t?t:new e(t)}static fromLngLat(t,n=0){let r=360*n/40075017,i=r/Math.cos(Math.PI/180*t.lat);return new e(new Xb(t.lng-i,t.lat-r),new Xb(t.lng+i,t.lat+r))}adjustAntiMeridian(){let t=new Xb(this._sw.lng,this._sw.lat),n=new Xb(this._ne.lng,this._ne.lat);return t.lng>n.lng?new e(t,new Xb(n.lng+360,n.lat)):new e(t,n)}},b8=89.25;function x8(e,t,n){let r=1/(1<=0?1<{let{x:r,y:i}=e.worldFromLngLat(t,n);return new U(r,i)},o=e=>e===16?r:t+(r-t)*e/16,s=e=>e===16?n:i+(n-i)*e/16,c=[];for(let e=0;e<=16;e++)for(let t=0;t<=16;t++)c.push(a(o(t),s(e)));let l=(e,t)=>c[e*17+t],u=0;for(let e=0;e<16;e++){let c=(o(e)+o(e+1))/2,d=(s(e)+s(e+1))/2,f=[[l(0,e),l(0,e+1),a(c,i)],[l(16,e),l(16,e+1),a(c,n)],[l(e,0),l(e+1,0),a(t,d)],[l(e,16),l(e+1,16),a(r,d)]];for(let[e,t,n]of f){let r=t.sub(e),i=n.sub(e),a=r.mag(),o=a>0?Math.abs(r.x*i.y-r.y*i.x)/a:i.mag();o>u&&(u=o)}}return{points:c,bulge:u}}function M8(e,t,n,r,i){let{points:a,bulge:o}=j8(e,t,n,r,i),s=1/0,c=1/0,l=-1/0,u=-1/0;for(let{x:e,y:t}of a)el&&(l=e),t>u&&(u=t);return{minX:s-o,minY:c-o,maxX:l+o,maxY:u+o}}function N8(e,t,n,r,i){let a=[e.lngLatFromWorld(t,n),e.lngLatFromWorld(r,n),e.lngLatFromWorld(r,i),e.lngLatFromWorld(t,i)];return{west:Math.min(a[0].lng,a[1].lng,a[2].lng,a[3].lng),south:Math.min(a[0].lat,a[1].lat,a[2].lat,a[3].lat),east:Math.max(a[0].lng,a[1].lng,a[2].lng,a[3].lng),north:Math.max(a[0].lat,a[1].lat,a[2].lat,a[3].lat)}}var P8=1e-4;function F8(e,t){if(e.wraps)return 360;let n=t.lat>0?-1e-4:P8,r=e.worldFromLngLat(t.lng,t.lat),i=e.worldFromLngLat(t.lng+P8,t.lat),a=e.worldFromLngLat(t.lng,t.lat+n);return P8/Math.max(Math.hypot(i.x-r.x,i.y-r.y),Math.hypot(a.x-r.x,a.y-r.y))}function I8(e,t){let n=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),r=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),i=t[0]*n,a=t[4]*n,o=t[8]*r,s=t[1]*n,c=t[5]*n,l=t[9]*r,u=t[2]*n,d=t[6]*n,f=t[10]*r;e[0]=i,e[1]=a,e[2]=o,e[4]=s,e[5]=c,e[6]=l,e[8]=u,e[9]=d,e[10]=f;let p=t[12],m=t[13],h=t[14];return e[12]=-i*p-s*m-u*h,e[13]=-a*p-c*m-d*h,e[14]=-o*p-l*m-f*h,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}function L8(e,t){return e[0]=1/t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1/t[5],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=0,e[11]=1/t[14],e[12]=0,e[13]=0,e[14]=-1,e[15]=t[10]/t[14],e}function R8(e,t){let n=1/(t[0]*t[5]-t[1]*t[4]);return e[0]=t[5]*n,e[1]=-t[1]*n,e[2]=0,e[3]=0,e[4]=-t[4]*n,e[5]=t[0]*n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1/t[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1/t[15],e}function z8(e,t,n){let 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[3]=n[3]*r+n[7]*i+n[15],e}var B8=class e{constructor(e=0,t=0,n=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0)throw Error(`Invalid value for edge-insets, top, bottom, left and right must all be numbers`);this.top=e,this.bottom=t,this.left=n,this.right=r}interpolate(e,t,n){return t.top!=null&&e.top!=null&&(this.top=E0.number(e.top,t.top,n)),t.bottom!=null&&e.bottom!=null&&(this.bottom=E0.number(e.bottom,t.bottom,n)),t.left!=null&&e.left!=null&&(this.left=E0.number(e.left,t.left,n)),t.right!=null&&e.right!=null&&(this.right=E0.number(e.right,t.right,n)),this}getCenter(e,t){return new U(G((this.left+e-this.right)/2,0,e),G((this.top+t-this.bottom)/2,0,t))}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new e(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function V8(e){return{tileSize:512,width:0,height:0,center:new Xb(0,0),elevation:0,zoom:0,bearingInRadians:0,pitchInRadians:0,rollInRadians:0,fovInRadians:.6435011087932844,padding:{top:0,bottom:0,left:0,right:0},minZoom:e?.minZoom||0,maxZoom:e?.maxZoom||22,minPitch:e?.minPitch===void 0||e?.minPitch===null?0:e?.minPitch,maxPitch:e?.maxPitch===void 0||e?.maxPitch===null?60:e?.maxPitch,lngRange:null,latRange:[-85.051129,xg],renderWorldCopies:e?.renderWorldCopies===void 0||!!e?.renderWorldCopies,minElevationForCurrentTile:0,nearFarZOverride:null,unmodified:!0}}function H8(e,t,n){let{top:r=0,bottom:i=0,left:a=0,right:o=0}=e;return new B8(r,i,a,o).interpolate(e,t,n).toJSON()}function U8(e,t){return new B8(e.top,e.bottom,e.left,e.right).equals(t)}function W8(e){let{top:t,bottom:n,left:r,right:i}=e.padding;return new B8(t,n,r,i).getCenter(e.width,e.height)}function G8(e){return W8(e)._sub(new U(e.width,e.height)._div(2))}function K8(e){return e.bearingInRadians/Math.PI*180}function q8(e){return e.pitchInRadians/Math.PI*180}function J8(e){return e.rollInRadians/Math.PI*180}function Y8(e){let{lngRange:t,latRange:n}=e;return!t&&n[0]===-85.051129&&n[1]===85.051129?null:new y8([t?.[0]??-1/0,n[0],t?.[1]??1/0,n[1]])}function X8(e){return gg(e.fovInRadians)}function Z8(e,t){let n=Zh(e.zoom),r=e.tileSize*n,i=!!e.width&&!!e.height,a=i?$8(e.width,e.height):void 0;return{...e,tileZoom:Math.max(0,Math.floor(e.zoom)),scale:n,worldSize:r,pixelsPerMeter:t.worldZFromAltitude(1,e.center)*r,cameraToCenterDistance:i?.5/Math.tan(e.fovInRadians/2)*e.height:void 0,rotationMatrix:om(rm(),rm(),-e.bearingInRadians),pixelsToGLUnits:a?.pixelsToGLUnits,pixelsToClipSpaceMatrix:a?.pixelsToClipSpaceMatrix,clipSpaceToPixelsMatrix:a?.clipSpaceToPixelsMatrix,pitch:q8(e),bearing:K8(e),roll:J8(e),fov:X8(e),centerPoint:W8(e)}}var Q8;function $8(e,t){return(Q8?.width!==e||Q8.height!==t)&&(Q8={width:e,height:t,pixelsToGLUnits:[2/e,-2/t],pixelsToClipSpaceMatrix:tx(e,t),clipSpaceToPixelsMatrix:ex(e,t)}),Q8}function ex(e,t){let n=mm(new Float64Array(16));return vm(n,n,[e/2,-t/2,1]),_m(n,n,[1,-1,0]),n}function tx(e,t){let n=mm(new Float64Array(16));return vm(n,n,[1,-1,1]),_m(n,n,[-1,-1,0]),vm(n,n,[2/e,2/t,1]),n}function nx(e){return e.projection===`globe`?e.globeness>0?e.verticalPerspective:e.mercator:e}function rx(e){return nx(e).projection===`vertical-perspective`}function ix(e){let t=Math.tan(e.pitchInRadians)*(e.cameraToCenterDistance||1);return e.centerPoint.add(new U(t*Math.sin(e.rollInRadians),t*Math.cos(e.rollInRadians)))}function ax(e,t){let n=ix(e);if(t.length===1)return[t[0],n];let{minX:r,minY:i,maxX:a,maxY:o}=Ob.fromPoints(t).extend(n);return[new U(r,i),new U(a,i),new U(a,o),new U(r,o),new U(r,i)]}function ox(e,t=1,n=0,r,i){let a=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]],o=i?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],s=2**n,c=a.map(n=>sx(n,e,t,s));r&&cx(c,o[0],r,i);let l=o.map(e=>{let t=zm([],Vm([],Xm([],c[e[0]],c[e[1]]),Xm([],c[e[2]],c[e[1]]))),n=-Bm(t,c[e[1]]);return t.concat(n)}),u=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(let e of c)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),d[t]=Math.max(d[t],e[t]);return{points:c,planes:l,aabb:{min:u,max:d}}}function sx(e,t,n,r){let i=rh([],e,t),a=1/i[3]/n*r;return ih(i,i,[a,a,1/i[3],a])}function cx(e,t,n,r){let i=r?4:0,a=r?0:4,o=0,s=[],c=[];for(let t=0;t<4;t++){let n=Xm([],e[t+a],e[t+i]),r=jm(n);Fm(n,n,1/r),s.push(r),c.push(n)}for(let t=0;t<4;t++){let r=Nh(e[t+i],c[t],n);o=r!==null&&r>=0?Math.max(o,r):Math.max(o,s[t])}let l=lx(e,t),u=ux(n,l);if(u!==null){let e=u/Bm(c[0],l);o=Math.min(o,e)}for(let t=0;t<4;t++){let n=Math.min(o,s[t]);e[t+a]=[e[t+i][0]+c[t][0]*n,e[t+i][1]+c[t][1]*n,e[t+i][2]+c[t][2]*n,1]}}function lx(e,t){let n=Xm([],e[t[0]],e[t[1]]),r=Xm([],e[t[2]],e[t[1]]),i=[0,0,0,0];return zm(i,Vm([],n,r)),i[3]=-Bm(i,e[t[0]]),i}function ux(e,t){let n=th([],e,1/Zm(e)),r=Xm([],t,Fm([],n,Bm(t,n))),i=Zm(r);if(i>0){let e=Math.sqrt(1-n[3]*n[3]);return jh(t,Nm([],Fm([],n,-n[3]),Fm([],r,e/i)))}return null}var dx=W*(1-1e-12),fx=-.5,px={covered:!1,demLoaded:!1,elevation:0},mx=class{constructor(e,t,n=()=>l8){this.tileManager=e,this.exaggeration=t,this.getWorldCoordinateHelper=n,this._samplerCache=new Map}reset(){this._samplerCache.clear(),this._index=void 0,this._ownDemIndex=void 0}getIndex(e=!1){return e?(this._ownDemIndex===void 0&&(this._ownDemIndex=this._build(!0)),this._ownDemIndex):(this._index===void 0&&(this._index=this._build(!1)),this._index)}sample(e,t=!1){let n=this.getIndex(t);if(!n)return;let r=this.getWorldCoordinateHelper(),{x:i,y:a}=r.worldFromLngLat(e.lng,e.lat),o=hx(n,this.exaggeration,i,a,r.wraps);return o.demLoaded?o.elevation:void 0}getSampler(e){let t=e.key,n=this._samplerCache.get(t);if(n)return n;let r=this._createElevationSampler(e);return r&&this._samplerCache.set(t,r),r}_createElevationSampler(e){let t=this.tileManager.getSourceTile(e,!0),n=t?.dem;if(!t||!n)return null;let r=e.canonical.z-t.tileID.canonical.z,i=1<>r<>r<{let i=r===8192?1:W/r;return n.sampleBilinear(e*i*a+o,t*i*a+s)}}_build(e){let{tileManager:t}=this,n=[],r=new Map,i=0,a=0;for(let o of t.getRenderableTiles()){if(!o)continue;let{canonical:s,wrap:c}=o.tileID;n.includes(s.z)||n.push(s.z);let l=e&&!t.getSourceTile(o.tileID)?.dem?null:this.getSampler(o.tileID);r.set(`${c}/${s.z}/${s.x}/${s.y}`,l);let u=t.getSourceTile(o.tileID,!0)?.dem;i=Math.min(i,(u?.min??0)*this.exaggeration),a=Math.max(a,(u?.max??0)*this.exaggeration)}return r.size===0?null:(n.sort((e,t)=>t-e),{zooms:n,samplerPerTile:r,minElevation:i-10,maxElevation:a+10})}};function hx(e,t,n,r,i){if(r<0||r>=1||!i&&(n<0||n>=1))return px;let a=i?Math.floor(n):0,o=n-a;for(let n of e.zooms){let i=1<i;a++){let i=(n+r)/2;t(e,i)?r=i:n=i}return{lo:n,hi:r}}var vx=new WeakMap;function yx(e){let t=vx.get(e);return t||(t={posMatrices:new Map,alignedPosMatrices:new Map,fogMatrices:new Map},vx.set(e,t)),t}function bx(e,t,n=e.nearFarZOverride){let r={...e,projection:`mercator`,clippingPlane:null};if(!e.width||!e.height)return r;let i=G8(e),a=w8(e.worldSize,e.center,t),o=a.x,s=a.y,c=hg(Math.min(e.pitch,b8)),l=Math.max(e.cameraToCenterDistance/2,e.cameraToCenterDistance+e.elevation*e.pixelsPerMeter/Math.cos(c)),{nearZ:u,farZ:d}=n??xx(e,l,c,i),f=new Float64Array(16);wm(f,e.fovInRadians,e.width/e.height,u,d);let p=new Float64Array(16);L8(p,f),f[8]=-i.x*2/e.width,f[9]=i.y*2/e.height;let m=fm(f);vm(f,f,[1,-1,1]),_m(f,f,[0,0,-e.cameraToCenterDistance]),xm(f,f,-e.rollInRadians),ym(f,f,e.pitchInRadians),xm(f,f,-e.bearingInRadians),_m(f,f,[-o,-s,0]);let h=vm([],f,[e.worldSize,e.worldSize,e.worldSize]);vm(f,f,[1,1,e.pixelsPerMeter]);let g=gm(new Float64Array(16),e.clipSpaceToPixelsMatrix,f);_m(f,f,[0,0,-e.elevation]);let _=f,v=hm([],f),y=[0,0,-1,1];rh(y,y,v);let b=[y[0]/y[3],y[1]/y[3],y[2]/y[3]],x=new Float64Array(16);wm(x,e.fovInRadians,e.width/e.height,l,d),x[8]=-i.x*2/e.width,x[9]=i.y*2/e.height,vm(x,x,[1,-1,1]),_m(x,x,[0,0,-e.cameraToCenterDistance]),xm(x,x,-e.rollInRadians),ym(x,x,e.pitchInRadians),xm(x,x,-e.bearingInRadians),_m(x,x,[-o,-s,0]),vm(x,x,[1,1,e.pixelsPerMeter]),_m(x,x,[0,0,-e.elevation]);let S=gm(new Float64Array(16),e.clipSpaceToPixelsMatrix,f),C=e.width%2/2,w=e.height%2/2,T=Math.cos(e.bearingInRadians),E=Math.sin(-e.bearingInRadians),D=o-Math.round(o)+T*C+E*w,O=s-Math.round(s)+T*w+E*C,k=new Float64Array(f);_m(k,k,[D>.5?D-1:D,O>.5?O-1:O,0]);let A=hm(new Float64Array(16),g);if(!A)throw Error(`failed to invert matrix`);return{...r,nearZ:u,farZ:d,projectionMatrix:m,modelViewProjectionMatrix:_,inverseProjectionMatrix:p,cameraPosition:b,mercatorMatrix:h,inverseModelViewProjectionMatrix:v,alignedModelViewProjectionMatrix:k,pixelMatrix:g,pixelMatrix3D:S,pixelMatrixInverse:A,fogMatrix:x}}function xx(e,t,n,r){let i=Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.pixelsPerMeter+e.elevation,a=Math.min(e.elevation,e.minElevationForCurrentTile,i-100),o=t-a*e.pixelsPerMeter/Math.cos(n),s=a<0?o:t,c=Math.PI/2+e.pitchInRadians,l=hg(e.fov)*(Math.abs(Math.cos(hg(e.roll)))*e.height+Math.abs(Math.sin(hg(e.roll)))*e.width)/e.height*(.5+r.y/e.height),u=Math.sin(l)*s/Math.sin(G(Math.PI-c-l,.01,Math.PI-.01)),d=E8(e),f=Math.atan(d/e.cameraToCenterDistance),p=hg(.75),m=f>p?2*f*(.5+r.y/(d*2)):p,h=Math.sin(m)*s/Math.sin(G(Math.PI-c-m,.01,Math.PI-.01)),g=Math.min(u,h),_=(Math.cos(Math.PI/2-n)*g+s)*1.01;return{nearZ:e.height/50,farZ:_}}function Sx(e){return E8(e)}function Cx(e,t){return t?e.lngLatFromWorld(t.x,t.y):void 0}function wx(e,t,n){let r=n.getCoverageIndex();if(!r)return null;let{near:i,far:a}=Ex(e,e.centerPoint,-1),o=e.cameraToCenterDistance*Zh(e.zoom-e.maxZoom),s=Hm([],i,a,Math.max(0,(o-e.nearZ)/(e.farZ-e.nearZ)));return gx(hx(r,n.exaggeration,s[0]/e.worldSize,s[1]/e.worldSize,t.wraps),s[2])?null:Cx(t,Tx(e,t,s,a,n))??null}function Tx(e,t,n,r,i){let a=i.getCoverageIndex();if(!a)return null;let o=e.worldSize,s=r[0]-n[0],c=r[1]-n[1],l=r[2]-n[2],u={index:a,exaggeration:i.exaggeration,near:n,dx:s,dy:c,dz:l,worldSize:o,wraps:t.wraps},d=0,f=1;if(l===0){if(n[2]>a.maxElevation||n[2]f)return null}let p=Math.hypot(s,c),m=G(Math.ceil(p*(f-d)/4),1,512),h=0,g=!Nx(u,0);for(let e=0;e<=m;e++){let t=d+(f-d)*e/m;if(!g)g=!Nx(u,t);else if(Nx(u,t)){let{lo:e,hi:r}=_x(u,Nx,h,t,.001/p),i=Mx(u,e),a=Mx(u,r),d=n[2]+e*l-i.elevation,f=n[2]+r*l-a.elevation,m=i.covered&&d>f?G(e+d*(r-e)/(d-f),e,r):r;return new c8((n[0]+m*s)/o,(n[1]+m*c)/o,Mx(u,m).elevation)}h=t}return null}function Ex(e,t,n=0){let r=[t.x,t.y,n,1],i=[t.x,t.y,1,1];rh(r,r,e.pixelMatrixInverse),rh(i,i,e.pixelMatrixInverse);let a=r[3],o=i[3],s=e.elevation;return{near:[r[0]/a,r[1]/a,r[2]/a+s],far:[i[0]/o,i[1]/o,i[2]/o+s]}}function Dx(e,t,n){let r=n||0,{near:i,far:a}=Ex(e,t),o=i[2]===a[2]?0:(r+e.elevation-i[2])/(a[2]-i[2]);return new c8(E0.number(i[0],a[0],o)/e.worldSize,E0.number(i[1],a[1],o)/e.worldSize,r)}function Ox(e,t,n=0,r=e.pixelMatrix){let i=kx(e,t,n,r),a=i[3];return a>0?new U(i[0]/a,i[1]/a):Ax(e,i[0],i[1],a)}function kx(e,t,n,r){let i=[t.x*e.worldSize,t.y*e.worldSize,n,1];return rh(i,i,r)}function Ax(e,t,n,r){let i=e.width/2,a=e.height/2,o=t-i*r,s=n-a*r;o===0&&s===0&&(s=1);let c=i+e.width,l=a+e.height,u=Math.min(o===0?1/0:c/Math.abs(o),s===0?1/0:l/Math.abs(s));return new U(i+o*u,a+s*u)}function jx(e,t,n=!1,r=!1){let i=t.key??h8(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),a=n?yx(e).alignedPosMatrices:yx(e).posMatrices;if(a.has(i)){let e=a.get(i);return r?e.f32:e.f64}let o=D8(t,e.worldSize);gm(o,n?e.alignedModelViewProjectionMatrix:e.modelViewProjectionMatrix,o);let s={f64:o,f32:new Float32Array(o)};return a.set(i,s),r?s.f32:s.f64}function Mx(e,t){return hx(e.index,e.exaggeration,(e.near[0]+t*e.dx)/e.worldSize,(e.near[1]+t*e.dy)/e.worldSize,e.wraps)}function Nx(e,t){return gx(Mx(e,t),e.near[2]+t*e.dz)}function Px({near:e,far:t},n,r,i){let a=t[0]-e[0],o=t[1]-e[1],s=t[2]-e[2];return((n-e[0])*a+(r-e[1])*o+(i-e[2])*s)/(a*a+o*o+s*s)}var Fx=class{getVisibleUnwrappedCoordinates(e,t,n){let r=[new p8(0,n)];if(e.renderWorldCopies&&t.wraps){let t=Dx(e,new U(0,0)),i=Dx(e,new U(e.width,0)),a=Dx(e,new U(e.width,e.height)),o=Dx(e,new U(0,e.height)),s=Math.floor(Math.min(t.x,i.x,a.x,o.x)),c=Math.floor(Math.max(t.x,i.x,a.x,o.x));for(let e=s-1;e<=c+1;e++)e!==0&&r.push(new p8(e,n))}return r}getCameraFrustum(e){return ox(e.inverseModelViewProjectionMatrix,e.worldSize)}locationToScreenPoint(e,t,n,r){let i=t.worldFromLngLat(n.lng,n.lat);return r?Ox(e,i,r.getElevationForLngLat(n,e.tileZoom),e.pixelMatrix3D):Ox(e,i)}screenPointToLocation(e,t,n,r){return Cx(t,this.screenPointToMercatorCoordinate(e,t,n,r))}screenPointToLocationAtElevation(e,t,n,r){return Cx(t,Dx(e,n,r-e.elevation))}screenPointToMercatorCoordinate(e,t,n,r){if(r){let i=this.screenTerrainPointToMercatorCoordinate(e,t,n,r);if(i!=null)return i}return Dx(e,n)}screenTerrainPointToMercatorCoordinate(e,t,n,r){let{near:i,far:a}=Ex(e,n,-1);return Tx(e,t,i,a,r)}getBounds(e,t){let n=Math.max(0,e.height/2-Sx(e));return new y8().extend(this.screenPointToLocation(e,t,new U(0,n))).extend(this.screenPointToLocation(e,t,new U(e.width,n))).extend(this.screenPointToLocation(e,t,new U(e.width,e.height))).extend(this.screenPointToLocation(e,t,new U(0,e.height)))}isPointOnMapSurface(e,t,n,r){if(r)return this.screenTerrainPointToMercatorCoordinate(e,t,n,r)!=null;let i=n.y>e.centerPoint.y-Sx(e);if(!i||t.wraps)return i;let a=Dx(e,n);return t.hasLngLat(a.x,a.y)}calculateFogMatrix(e,t){let n=t.key,r=yx(e).fogMatrices;if(r.has(n))return r.get(n);let i=D8(t,e.worldSize);return gm(i,e.fogMatrix,i),r.set(n,new Float32Array(i)),r.get(n)}maxPitchScaleFactor(e){if(!e.pixelMatrixInverse)return 1;let t=Dx(e,new U(0,0)),n=[t.x*e.worldSize,t.y*e.worldSize,0,1];return rh(n,n,e.pixelMatrix)[3]/e.cameraToCenterDistance}getCameraAltitude(e){return Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.pixelsPerMeter+e.elevation}getCameraLngLat(e,t){let n=e.center,r=t.worldZFromAltitude(1,n),i=r*e.worldSize,a=e.cameraToCenterDistance/i,o=O8(t.worldFromLngLat(n.lng,n.lat,e.elevation),e.pitch,e.bearing,a*r);return t.lngLatFromWorld(o.x,o.y)}getProjectionData(e,t){let{overscaledTileID:n,aligned:r,applyTerrainMatrix:i}=t,a=S8(n),o=n?jx(e,n,r,!0):null,s;return s=n?.terrainRttPosMatrix32f&&i?n.terrainRttPosMatrix32f:o||kh(),{mainMatrix:s,tileMercatorCoords:a,clippingPlane:[0,0,0,0],tileOrigin:[0,0,0,0],tileOriginPosition:[0,0],projectionTransition:0,fallbackMatrix:s,clipAntimeridian:!1}}isLocationOccluded(e,t,n,r,i){if(!r?.getCoverageIndex())return!1;let a=t.worldFromLngLat(n.lng,n.lat);i??=r.getElevationForLngLat(n,e.tileZoom);let o=kx(e,a,i,e.pixelMatrix3D),s=o[3];if(s<=0||o[2]>s)return!0;let c=new U(o[0]/s,o[1]/s),l=this.screenTerrainPointToMercatorCoordinate(e,t,c,r);if(l==null)return!1;let u=Ex(e,c,-1),d=Px(u,a.x*e.worldSize,a.y*e.worldSize,i);return Px(u,l.x*e.worldSize,l.y*e.worldSize,l.z)1e-6){let r=e[0]/n,i=e[2]/n,a=Math.acos(i);return new Xb(Gh((r>0?a:-a)/Math.PI*180,-180,180),t)}return new Xb(0,t)}function Yee(e,t){return dh(wh(),-e.lng,-e.lat,t)}function Xee(e){let t=e[0],n=e[1],r=e[2],i=e[3];return{lng:-Math.atan2(2*(i*t+n*r),1-2*(t*t+n*n))*180/Math.PI,lat:-Math.asin(G(2*(i*n-r*t),-1,1))*180/Math.PI,bearing:Math.atan2(2*(i*r+t*n),1-2*(n*n+r*r))*180/Math.PI}}function Zee(e){let t=Th();return t[0]=e[0]*-e[3],t[1]=e[1]*-e[3],t[2]=e[2]*-e[3],{center:t,radius:Math.sqrt(1-e[3]*e[3])}}function Qee(e,t,n){let r=Th();Xm(r,n,e);let i=Th();return Im(i,e,r,t/Zm(r)),i}function Gx(e){return Math.cos(Math.min(Math.abs(e),xg)*Math.PI/180)}function Kx(e,t){let n=Gx(e);return Qh(Gx(t)/n)}function $ee(e,t){return 360/Ix({worldSize:e,center:{lat:t}})}function ete(e,t){let n=e.rotate(t.bearingInRadians),r=t.zoom+Kx(t.center.lat,0),i=zh(1/Gx(t.center.lat),1/Gx(Math.min(Math.abs(t.center.lat),60)),Rh(r,7,3,0,1)),a=$ee(t.worldSize,t.center.lat);return new Xb(t.center.lng-n.x*a*i,G(t.center.lat+n.y*a,-90,90))}function qx(e){let t=.5*e,n=Math.sin(t),r=Math.cos(t);return Math.log(n+r)-Math.log(r-n)}function Jx(e,t,n,r){let i=G(e.lat+n*r,-90,90),a=G(e.lat,-85.051129,xg),o=G(e.lat+n,-85.051129,xg);if(Math.abs(o-a)>1){let n=(Math.sign(o)===Math.sign(a)?Math.abs(a):-Math.abs(a))*Math.PI/180,s=Math.abs(o)*Math.PI/180,c=qx(n+r*(s-n)),l=qx(n),u=qx(s),d=(c-l)/(u-l);return new Xb(e.lng+t*d,i)}return new Xb(e.lng+t*r,i)}function Yx(e,t,n=1){let r=Bm(e,t),i=n*n,a=Th(),o=Th();Fm(o,t,r),Xm(a,e,o);let s=i-Bm(a,a);if(s<0)return null;let c=Bm(e,e)-i,l=-r+(r<0?1:-1)*Math.sqrt(s),u=c/l,d=l,f=Math.max(u,d);return f<0?null:{tMin:Math.min(u,d),tMax:f}}function Xx(e,t){let n=t*.01569612305760477,r=G((e-n)/(9*n),0,1);return r*r*(3-2*r)}var Zx=new WeakMap;function tte(e,t){let n=Zx.get(e);n||(n=new Map,Zx.set(e,n));let r=n.get(t.key);if(r)return r;let i=1<=0}function i5(e,t){if(!r5(e,t))return!1;let n=wh();return rh(n,[...t,1],e.modelViewProjectionMatrix),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}function a5(e,t){let n=e.cameraPosition,r=n5(e,t),i=Yx(n,r);if(i){let e=Th();Nm(e,n,[r[0]*i.tMin,r[1]*i.tMin,r[2]*i.tMin]);let t=Th();return zm(t,e),Wx(t)}let a=e.clippingPlane,o=a[0]*r[0]+a[1]*r[1]+a[2]*r[2],s=-jh(a,n)/o,c=Th();if(s>0)Nm(c,n,[r[0]*s,r[1]*s,r[2]*s]);else{let e=Th();Nm(e,n,[r[0]*2,r[1]*2,r[2]*2]);let t=jh(a,e);Xm(c,e,[a[0]*t,a[1]*t,a[2]*t])}let l=Zee(a);return Wx(Qee(l.center,l.radius,c))}function o5(e,t){let n=Th();Im(n,e.origin,e.direction,t);let r=jm(n),i=Th();Fm(i,n,1/r);let a=Wx(i),o=c8.fromLngLat(a),s=new c8(o.x,G(o.y,0,.999999999)),c=hx(e.index,e.exaggeration,s.x,s.y,!1),l=Math.abs(a.lat)>85.051129?0:c.elevation;return{sample:{...c,elevation:l},radius:r,mercator:s}}function s5(e,t){let{sample:n,radius:r}=o5(e,t);return gx(n,(r-1)*Yb)}function c5(e,t){let n=Vx(e);return Fm(n,n,1+t/Yb)}function l5(e,t,n){return Bm(Pm(Th(),n,e),t)}var ite=class{getProjectionData(e,t){let{overscaledTileID:n,applyGlobeMatrix:r,applyTerrainMatrix:i}=t,a=Qx(e,n,r);if(n?.terrainRttPosMatrix32f&&i&&(a.fallbackMatrix=n.terrainRttPosMatrix32f),!(r&&n!=null&&e.zoom>=10))return a;let o=tte(e,n.canonical);return a.mainMatrix=o.matrix,a.clippingPlane=o.clippingPlane,a.tileOrigin=o.tileOrigin,a.tileOriginPosition=o.tileOriginPosition,a}isLocationOccluded(e,t,n,r,i){let a=r?.getCoverageIndex();i??=a?r.getElevationForLngLat(n,e.tileZoom):0;let o=c5(n,i);if(!r5(e,o))return!0;if(!a)return!1;let s=e5(e,o),c=e.cameraPosition,l=n5(e,s),u=l5(c,l,o);if(u<=0)return!0;let d=this.screenTerrainPointToMercatorCoordinate(e,t,s,r);return d!=null&&l5(c,l,c5(d.toLngLat(),d.z))o&&(o=t),nc&&(c=n)}let d=[u.lng+s,u.lat+l,u.lng+o,u.lat+c];return i5(e,[0,1,0])&&(d[3]=90,d[0]=-180,d[2]=180),i5(e,[0,-1,0])&&(d[1]=-90,d[0]=-180,d[2]=180),new y8(d)}locationToScreenPoint(e,t,n,r){let i=Vx(n);return r&&Fm(i,i,1+r.getElevationForLngLat(n,e.tileZoom)/Yb),e5(e,i)}getCameraQueryGeometry(e,t){if(t.length!==1||!t5(e,t[0]))return ax(e,t);let n=Vx(a5(e,t[0])),r=zm(Th(),e.cameraPosition),i=[t[0]];for(let t=1;t<=8;t++){let a=Hm(Th(),n,r,t/8);i.push(e5(e,zm(a,a)))}return i}screenPointToMercatorCoordinate(e,t,n,r){if(r){let i=this.screenTerrainPointToMercatorCoordinate(e,t,n,r);if(i)return i}return c8.fromLngLat(a5(e,n))}screenTerrainPointToMercatorCoordinate(e,t,n,r){let i=r.getCoverageIndex();if(!i)return null;let a=e.cameraPosition,o=n5(e,n),s=Yx(a,o,1+i.maxElevation/Yb);if(!s)return null;let c=Yx(a,o,1+i.minElevation/Yb),l=Math.max(s.tMin,0),u=c?c.tMin:s.tMax;if(u<=l)return null;let d={index:i,exaggeration:r.exaggeration,origin:a,direction:o},f=0;for(let e=0;e<=256;e++){let t=l+(u-l)*e/256;if(s5(d,t)){let{hi:e}=_x(d,s5,f,t,1e-12),{sample:n,mercator:r}=o5(d,e);return new c8(r.x,r.y,n.elevation)}f=t}return null}screenPointToLocation(e,t,n,r){return this.screenPointToMercatorCoordinate(e,t,n,r)?.toLngLat()}screenPointToLocationAtElevation(e,t,n,r){return this.screenPointToLocation(e,t,n)}isPointOnMapSurface(e,t,n,r){return t5(e,n)}getProjectionDataForCustomLayer(e,t=!0){let n=Qx(e,new m8(0,0,0,0,0),t),r=Eh();return pm(r,e.modelViewProjectionMatrix),{...n,mainMatrix:r,tileMercatorCoords:[0,0,1,1]}}getFastPathSimpleProjectionMatrix(e,t){}getClippingPlane(e){return e.clippingPlane}getRayDirectionFromPixel(e,t){return n5(e,t)}},ate=class{constructor(e,t){this._mercator=e,this._verticalPerspective=t}_renderedMath(e){return rx(e)?this._verticalPerspective:this._mercator}getProjectionData(e,t){let n=this._mercator.getProjectionData(e.mercator,t),r=Qx(e.verticalPerspective,t.overscaledTileID,t.applyGlobeMatrix);return{mainMatrix:rx(e)?r.mainMatrix:n.mainMatrix,clippingPlane:r.clippingPlane,tileMercatorCoords:r.tileMercatorCoords,tileOrigin:r.tileOrigin,tileOriginPosition:r.tileOriginPosition,projectionTransition:t.applyGlobeMatrix?e.globeness:0,fallbackMatrix:n.fallbackMatrix,clipAntimeridian:r.clipAntimeridian}}getProjectionDataForCustomLayer(e,t=!0){let n=this._mercator.getProjectionDataForCustomLayer(e.mercator,t);if(!rx(e))return n;let r=this._verticalPerspective.getProjectionDataForCustomLayer(e.verticalPerspective,t);return r.fallbackMatrix=n.mainMatrix,r.projectionTransition=e.globeness,r}getFastPathSimpleProjectionMatrix(e,t){return this._renderedMath(e).getFastPathSimpleProjectionMatrix(nx(e),t)}projectTileCoordinates(e,t,n,r,i){return this._renderedMath(e).projectTileCoordinates(nx(e),t,n,r,i)}getPitchedTextCorrection(e,t,n,r){return zh(this._mercator.getPitchedTextCorrection(e.mercator,t,n,r),this._verticalPerspective.getPitchedTextCorrection(e.verticalPerspective,t,n,r),e.globeness)}getCircleRadiusCorrection(e){return this._renderedMath(e).getCircleRadiusCorrection(nx(e))}getPixelScale(e){return zh(this._mercator.getPixelScale(e.mercator),this._verticalPerspective.getPixelScale(e.verticalPerspective),e.globeness)}transformLightDirection(e,t){return this._renderedMath(e).transformLightDirection(nx(e),t)}calculateFogMatrix(e,t){return this._renderedMath(e).calculateFogMatrix(nx(e),t)}getVisibleUnwrappedCoordinates(e,t,n){return this._renderedMath(e).getVisibleUnwrappedCoordinates(nx(e),t,n)}getCameraFrustum(e){return this._renderedMath(e).getCameraFrustum(nx(e))}getClippingPlane(e){return this._renderedMath(e).getClippingPlane(nx(e))}maxPitchScaleFactor(e){return this._mercator.maxPitchScaleFactor(e.mercator)}getCameraAltitude(e){return this._renderedMath(e).getCameraAltitude(nx(e))}getCameraLngLat(e,t){return this._renderedMath(e).getCameraLngLat(nx(e),t)}getBounds(e,t){return this._renderedMath(e).getBounds(nx(e),t)}isLocationOccluded(e,t,n,r,i){return this._renderedMath(e).isLocationOccluded(nx(e),t,n,r,i)}locationToScreenPoint(e,t,n,r){return this._renderedMath(e).locationToScreenPoint(nx(e),t,n,r)}screenPointToLocation(e,t,n,r){return this._renderedMath(e).screenPointToLocation(nx(e),t,n,r)}screenPointToLocationAtElevation(e,t,n,r){return this._renderedMath(e).screenPointToLocationAtElevation(nx(e),t,n,r)}screenPointToMercatorCoordinate(e,t,n,r){return this._renderedMath(e).screenPointToMercatorCoordinate(nx(e),t,n,r)}screenTerrainPointToMercatorCoordinate(e,t,n,r){return this._renderedMath(e).screenTerrainPointToMercatorCoordinate(nx(e),t,n,r)}isPointOnMapSurface(e,t,n,r){return this._renderedMath(e).isPointOnMapSurface(nx(e),t,n,r)}getRayDirectionFromPixel(e,t){return this._verticalPerspective.getRayDirectionFromPixel(e.verticalPerspective,t)}getCameraQueryGeometry(e,t){return this._renderedMath(e).getCameraQueryGeometry(nx(e),t)}},u5=new Fx,d5=new ite,ote=new ate(u5,d5);function Q(e){switch(e.projection){case`mercator`:return u5;case`vertical-perspective`:return d5;case`globe`:return ote}}function f5(e,t,n){let r=t.paint.get(e).value;return r.kind===`constant`?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function p5(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function m5(e,t,n,r,i){if(!t[0]&&!t[1])return e;let a=U.convert(t)._mult(i);n===`viewport`&&a._rotate(-r);let o=[];for(let t of e)o.push(t.sub(a));return o}function ste(e){let t=[];for(let n=0;ng5(e,t,n,r))}var mte,hte=()=>mte||=new X4({"circle-sort-key":new K4(K.layout_circle[`circle-sort-key`],`circle-sort-key`)}),gte,_te=()=>gte||=new X4({"circle-radius":new K4(K.paint_circle[`circle-radius`],`circle-radius`),"circle-color":new K4(K.paint_circle[`circle-color`],`circle-color`),"circle-blur":new K4(K.paint_circle[`circle-blur`],`circle-blur`),"circle-opacity":new K4(K.paint_circle[`circle-opacity`],`circle-opacity`),"circle-translate":new X(K.paint_circle[`circle-translate`],`circle-translate`),"circle-translate-anchor":new X(K.paint_circle[`circle-translate-anchor`],`circle-translate-anchor`),"circle-pitch-scale":new X(K.paint_circle[`circle-pitch-scale`],`circle-pitch-scale`),"circle-pitch-alignment":new X(K.paint_circle[`circle-pitch-alignment`],`circle-pitch-alignment`),"circle-stroke-width":new K4(K.paint_circle[`circle-stroke-width`],`circle-stroke-width`),"circle-stroke-color":new K4(K.paint_circle[`circle-stroke-color`],`circle-stroke-color`),"circle-stroke-opacity":new K4(K.paint_circle[`circle-stroke-opacity`],`circle-stroke-opacity`)}),vte={get paint(){return _te()},get layout(){return hte()}},yte=e=>e.type===`circle`,bte=class extends $4{constructor(e,t){super(e,vte,t)}createBucket(e){return new Fb(e)}queryRadius(e){let t=e;return f5(`circle-radius`,this,t)+f5(`circle-stroke-width`,this,t)+p5(this.paint.get(`circle-translate`))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,projectedCamera:i,pixelsToTileUnits:a,unwrappedTileID:o,getElevation:s}){let c=m5(e,this.paint.get(`circle-translate`),this.paint.get(`circle-translate-anchor`),-i.bearingInRadians,a),l=this.paint.get(`circle-radius`).evaluate(t,n)+this.paint.get(`circle-stroke-width`).evaluate(t,n),u=this.paint.get(`circle-pitch-scale`),d=this.paint.get(`circle-pitch-alignment`),f,p;return d===`map`?(f=c,p=l*a):(f=pte(c,i,o,s),p=l),h5({queryGeometry:f,size:p,projectedCamera:i,unwrappedTileID:o,getElevation:s,pitchAlignment:d,pitchScale:u},r)}},_5=I3([{name:`a_pos`,components:2,type:`Int16`}],4),xte=_5.members;_5.size,_5.alignment;function v5(e,t,n){let r=n.patternDependencies,i=!1;for(let n of t){let t=n.paint.get(`${e}-pattern`);t.isConstant()||(i=!0);let a=t.constantOr(null);a&&(i=!0,r[a.to]=!0,r[a.from]=!0)}return i}function y5(e,t,n,r,i){let{zoom:a}=r,o=i.patternDependencies;for(let r of t){let t=r.paint.get(`${e}-pattern`).value;if(t.kind!==`constant`){let e=t.evaluate({zoom:a-1},n,{},i.availableImages),s=t.evaluate({zoom:a},n,{},i.availableImages),c=t.evaluate({zoom:a+1},n,{},i.availableImages);e=e?.name?e.name:e,s=s?.name?s.name:s,c=c?.name?c.name:c,o[e]=!0,o[s]=!0,o[c]=!0,n.patterns[r.id]={min:e,mid:s,max:c}}}return n}var b5=new Set,x5=!1;function Ste(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length;b5.size&&b5.clear();let a=S5(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s=0,c=0,l=0;if(r&&(a=Dte(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;at&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return w5(a,o,s,c,l),o}function S5(e,t,n,r,i){let a=null;if(i===Bte(e,t,n,r)>0)for(let i=t;i=t;i-=r)a=q5(i/r|0,e[i],e[i+1],a);return a&&H5(a,a.next)&&(J5(a),a=a.next),a}function C5(e,t=e){let n=t===e,r=e,i;do i=!1,r!==r.next&&(b5.size===0||!b5.has(r))&&(H5(r,r.next)||V5(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),x5=!0,J5(r),r=r.prev,i=!0):(n||r!==t)&&(r=r.next,i=!n);while(i||r!==t);return t}function w5(e,t,n,r,i){i&&Pte(e,n,r,i);let a=e,o=!1;for(;e.prev!==e.next;){let s=e.prev,c=e.next;if(V5(s,e,c)<0&&(i?wte(e,n,r,i):Cte(e)))t.push(s.i,e.i,c.i),J5(e),e=c,a=c;else if(e=c,e===a){if(x5=!1,e=C5(e),x5){a=e;continue}if(!o){e=Tte(e,t),a=e,o=!0;continue}Ete(e,t,n,r,i);break}}}function Cte(e){let t=e.prev,n=e,r=e.next,i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&(i!==m.x||s!==m.y)&&B5(i,s,a,c,o,l,m.x,m.y)&&V5(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function wte(e,t,n,r){let i=e.prev,a=e,o=e.next,s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=z5(p,m,t,n,r),v=z5(h,g,t,n,r),y=e.prevZ;for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==o&&(s!==y.x||u!==y.y)&&B5(s,u,c,d,l,f,y.x,y.y)&&V5(y.prev,y,y.next)>=0)return!1;y=y.prevZ}let b=e.nextZ;for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==o&&(s!==b.x||u!==b.y)&&B5(s,u,c,d,l,f,b.x,b.y)&&V5(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Tte(e,t){let n=e,r=!1;do{let i=n.prev,a=n.next.next;U5(i,n,n.next,a,!1)&&G5(i,a)&&G5(a,i)&&(t.push(i.i,n.i,a.i),J5(n),J5(n.next),n=e=a,r=!0),n=n.next}while(n!==e);return r?C5(n):n}function Ete(e,t,n,r,i){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Lte(a,e)){let o=K5(a,e);a=C5(a,a.next),o=C5(o,o.next),w5(a,t,n,r,i),w5(o,t,n,r,i);return}e=e.next}a=a.next}while(a!==e)}var T5=!1;function Dte(e,t,n,r){let i=[];for(let n=0,a=t.length;na&&(a=t.x),t.yo&&(o=t.y),n=t}while(++s<16&&n!==t);k5[e]=n;let c=e*4;E5[c]=r,E5[c+1]=i,E5[c+2]=a,E5[c+3]=o}while(n!==t)}function jte(e,t){let n=e.z*4;t.xE5[n+2]&&(E5[n+2]=t.x),t.y>E5[n+3]&&(E5[n+3]=t.y)}function j5(e){let t=k5[e];for(;t.prev.next!==t;)t=t.next;return k5[e]=t,t}function M5(e){let t=O5[e];for(;t.prev.next!==t;)t=t.next;return O5[e]=t,t}function Mte(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(H5(e,n))return n;for(let t=0,s=0;tE5[s+3]||E5[s]>r||E5[s+2]<=a)continue;let c=j5(t);n=M5(t);do{if(n.prev.next===n){if(H5(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.xr||E5[f+3]u)continue;let p=j5(t);n=M5(t);do{if(n.prev.next===n&&r>=n.x&&n.x>=s&&r!==n.x&&B5(ir)&&(to.x||n.x===o.x&&Nte(o,n)))&&(o=n,d=t)}n=n.next}while(n!==p)}return o}function Nte(e,t){return V5(e.prev,e,t.prev)<0&&V5(t.next,e,e.next)<0}var N5=[],P5=[],F5=new Uint32Array,I5=new Uint32Array,L5=new Uint32Array(256);function Pte(e,t,n,r){let i=e,a=0;do i.z=z5(i.x,i.y,t,n,r),N5[a++]=i,i=i.next;while(i!==e);Fte(a);let o=null;for(let e=0;e=0&&N5[r].z>n;)N5[r+1]=N5[r],r--;N5[r+1]=e}else{F5.length>>a&255]++;let o=0;for(let e=0;e<256;e++){let t=L5[e];L5[e]=o,o+=t}for(let o=0;o>>a&255]++;r[s]=t[o],i[s]=e}}function z5(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&0xff00ff,e=(e|e<<4)&0xf0f0f0f,e=(e|e<<2)&858993459,e=(e|e<<1)&0x55555555,t=(t|t<<8)&0xff00ff,t=(t|t<<4)&0xf0f0f0f,t=(t|t<<2)&858993459,t=(t|t<<1)&0x55555555,e|t<<1}function Ite(e){let t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Lte(e,t){let n=H5(e,t)&&V5(e.prev,e,e.next)>0&&V5(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||G5(e,t)&&G5(t,e)&&(V5(e.prev,e,t.prev)!==0||V5(e,t.prev,t)!==0))&&!Rte(e,t)&&(n||zte(e,t))}function V5(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function H5(e,t){return e.x===t.x&&e.y===t.y}function U5(e,t,n,r,i=!0){let a=V5(e,t,n),o=V5(e,t,r),s=V5(n,r,e),c=V5(n,r,t);return(a>0&&o<0||a<0&&o>0)&&(s>0&&c<0||s<0&&c>0)?!0:i?!!(a===0&&W5(e,n,t)||o===0&&W5(e,r,t)||s===0&&W5(n,e,r)||c===0&&W5(n,t,r)):!1}function W5(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 Rte(e,t){let n=Math.min(e.x,t.x),r=Math.max(e.x,t.x),i=Math.min(e.y,t.y),a=Math.max(e.y,t.y),o=e;do{let s=o.next;if(o.x>r&&s.x>r||o.xa&&s.y>a||o.y=0&&V5(e,e.prev,t)>=0:V5(e,t,e.prev)<0||V5(e,e.next,t)<0}function zte(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{let e=n.next;n.y>a!=e.y>a&&i<(e.x-n.x)*(a-n.y)/(e.y-n.y)+n.x&&(r=!r),n=e}while(n!==e);return r}function K5(e,t){let n=Y5(e.i,e.x,e.y),r=Y5(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function q5(e,t,n,r){let i=Y5(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 J5(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),T5&&jte(e.prev,e.next)}function Y5(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function Bte(e,t,n,r){let i=0;for(let a=t,o=n-r;ae)throw Error(`Min granularity must not be greater than base granularity.`);this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){let t=1<32767||t>32767)throw Error(`Vertex coordinates are out of signed 16 bit integer range.`);let n=Math.round(e)|0,r=Math.round(t)|0,i=this._getKey(n,r),a=this._vertexDictionary.get(i);if(a!==void 0)return a;let o=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,o),this._vertexBuffer.push(n,r),o}_subdivideTrianglesScanline(e,t){if(this._granularity<2)return Wte(this._vertexBuffer,Ute(e,t));let n=[],r=e.length;for(let i=0;i=1||y<=0)||h&&(si)){l>=r&&l<=i&&a.push(n[(e+1)%3]);continue}if(!h&&v>0){let e=o+f*v,t=s+p*v;a.push(this._vertexToIndex(e,t))}let b=o+f*Math.max(v,0),x=o+f*Math.min(y,1);if(m||this._generateIntraEdgeVertices(a,o,s,c,l,b,x),!h&&y<1){let e=o+f*y,t=s+p*y;a.push(this._vertexToIndex(e,t))}(h||l>=r&&l<=i)&&a.push(n[(e+1)%3]),!h&&(l<=r||l>=i)&&this._generateInterEdgeVertices(a,o,s,c,l,u,d,x,r,i)}return a}_generateIntraEdgeVertices(e,t,n,r,i,a,o){let s=r-t,c=i-n,l=c===0,u=l?Math.min(t,r):Math.min(a,o),d=l?Math.max(t,r):Math.max(a,o),f=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(d/this._granularityCellSize)-1;if(l?t=f;r--){let i=r*this._granularityCellSize,a=n+c*(i-t)/s;e.push(this._vertexToIndex(i,a))}}_generateInterEdgeVertices(e,t,n,r,i,a,o,s,c,l){let u=i-n,d=a-r,f=o-i,p=(c-i)/f,m=(l-i)/f,h=Math.min(p,m),g=Math.max(p,m),_=r+d*h,v=Math.floor(Math.min(_,s)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,s)/this._granularityCellSize)-1,b=s<_,x=f===0;if(x&&(o===c||o===l))return;if(x||h>=1||g<=0){let e=t-a,r=n-o,i=(c-o)/r,u=(l-o)/r,d=a+e*Math.min(i,u);v=Math.floor(Math.min(d,s)/this._granularityCellSize)+1,y=Math.ceil(Math.max(d,s)/this._granularityCellSize)-1,b=s0?l:c;if(b)for(let t=v;t<=y;t++){let n=t*this._granularityCellSize;e.push(this._vertexToIndex(n,S))}else for(let t=y;t>=v;t--){let n=t*this._granularityCellSize;e.push(this._vertexToIndex(n,S))}}_generateOutline(e,t){let n=[],r=0;for(let i of e){let e=this._granularity<2?this._ringPathIndices(i,r,t):this._pointArrayToIndices(t7(i,this._granularity,!0));r+=i.length;let a=[];for(let t=1;t=2&&n7(e)&&r.push(r[0]),r}_handlePoles(e){let t=!1,n=!1;this._canonical&&(this._canonical.y===0&&(t=!0),this._canonical.y===(1<i==(a===-32768)?(e.push(n),e.push(t),e.push(this._vertexToIndex(r,a)),e.push(this._vertexToIndex(i,a)),e.push(n),e.push(this._vertexToIndex(r,a))):(e.push(t),e.push(n),e.push(this._vertexToIndex(r,a)),e.push(n),e.push(this._vertexToIndex(i,a)),e.push(this._vertexToIndex(r,a)))}_fillPoles(e,t,n){let r=this._vertexBuffer,i=W,a=e.length;for(let o=2;o=2&&this._canonical?.z===0&&(a=this._removeTrianglesOutsideTileX(a),o=o.map(e=>this._removeLinesOutsideTileX(e))),{verticesFlattened:this._vertexBuffer,indicesTriangles:a,indicesLineList:o}}_vertexOutsideTileX(e){let t=this._vertexBuffer[e*2];return t<0||t>8192}_removeTrianglesOutsideTileX(e){let t=[];for(let n=0;n0?(Math.floor(_/i)+1)*i:(Math.ceil(_/i)-1)*i,t=m>0?(Math.floor(v/i)+1)*i:(Math.ceil(v/i)-1)*i,n=Math.abs(_-e),r=Math.abs(v-t),o=Math.abs(_-l),s=Math.abs(v-u),c=d?n/h:1/0,y=f?r/g:1/0;if((o<=n||!d)&&(s<=r||!f))break;if(c0?(n.push(i),n.push(o),n.push(a)):(n.push(i),n.push(a),n.push(o))}return n}function Gte(e,t,n){if(t.length===0)throw Error(`Subdivision vertex ring is empty.`);let r=0,i=e[t[0]*2];for(let n=1;n=0?o-1:a-1,i=(s+1)%a,c=e[t[r]*2],l=e[t[r]*2+1],u=e[t[i]*2],d=e[t[i]*2+1],f=e[t[o]*2],p=e[t[o]*2+1],m=e[t[s]*2],h=e[t[s]*2+1],g=!1;if(cu)g=!1;else{let e=h-p,t=-(m-f),n=p((u-f)*e+(d-p)*t)*n&&(g=!0)}if(g){let e=t[r],i=t[o],c=t[s];e!==i&&e!==c&&i!==c&&n.push(c,i,e),o--,o<0&&(o=a-1)}else{let e=t[i],r=t[o],c=t[s];e!==r&&e!==c&&r!==c&&n.push(c,r,e),s++,s>=a&&(s=0)}if(r===i)break}}function r7(e,t,n,r,i,a,o,s,c){let l=i.length/2,u=o&&s&&c;if(lW6.MAX_VERTEX_ARRAY_LENGTH&&(l=e.createNewSegment(t,n),c=s.count,h=!0,g=!0,_=!0,u=0);let y=i7(o,r,a,s,f,h,l),b=i7(o,r,a,s,p,g,l),x=i7(o,r,a,s,m,_,l);n.emplaceBack(u+y-c,u+b-c,u+x-c),l.primitiveLength++}}function qte(e,t,n,r,i,a){let o=[];for(let e=0;eW6.MAX_VERTEX_ARRAY_LENGTH&&(l=e.createNewSegment(t,n),c=s.count,m=!0,h=!0,u=0);let _=i7(o,r,a,s,f,m,l),v=i7(o,r,a,s,p,h,l);n.emplaceBack(u+_-c,u+v-c),l.primitiveLength++}}function a7(e,t){return t<=0||!e||e.length===0?e:e.map(e=>Xte(e,t))}function o7(e,t){let n=C8(W/2,W/2,t),r=c8.fromLngLat(n).meterInMercatorCoordinateUnits(),i=(1<0;t.push(i?r._perp():null)}let n=e.length-1,r=n>1&&e[0].equals(e[n]),i=[null];for(let e=1;e<=n;e++){let a=t[e];if(!a){i.push(null);continue}let o=r&&e===1?t[n]:t[e-1],s=r&&e===n?t[1]:t[e+1];i.push({start:s7(a,o),end:s7(a,s)})}return i}function s7(e,t){if(!t)return e.unit();let n=e.mag(),r=t.mag();return e.x*t.x+e.y*t.y=2*r?e.unit():r>=2*n?t.unit():e.add(t)._unit()}function Xte(e,t){if(!e||e.length<3)return e;let n=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,r=n?e.length-1:e.length;if(r<3)return e;let i=[],a=Ab(e[r-1],e[0]);for(let n=0;n1&&t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y;)t.pop();return t}function Qte(e,t,n,r,i){let a=t.sub(n),o=r.sub(n),s=a.mag(),c=o.mag();if(s<1e-6||c<1e-6){e.push(n.clone());return}a._div(s),o._div(c);let l=a.x*o.x+a.y*o.y;if(Math.abs(l)>Math.cos(5*Math.PI/180)){e.push(n.clone());return}let u=.2,d=Math.min(i,s*u,c*u),f=n.add(a.mult(d)),p=n.add(o.mult(d)),m=Math.sqrt((1+l)/2),h=n.add(a.add(o)._unit()._mult(d/m)),g=f.sub(h).angleWith(p.sub(h)),_=Math.max(2,Math.ceil(Math.abs(g)/(Math.PI/6)-1e-6));for(let t=0;t<=_;t++)e.push(f.rotateAround(t/_*g,h))}var c7=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.sdfPatterns={},this.patternFeatures=[],this.layoutVertexArray=new T6,this.indexArray=new z6,this.indexArray2=new B6,this.programConfigurations=new bb(e.layers,e.zoom),this.segments=new W6,this.segments2=new W6,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n){this.hasDependencies=v5(`fill`,this.layers,t);let r=this.layers[0].layout.get(`fill-sort-key`),i=!r.isConstant(),a=[],o=new F4(this.zoom),s=this.layers[0]._featureFilter.needGeometry,c=this.layers[0].paint.get(`fill-rounded-corner-distance`),l=c>0?o7(c,n):0;for(let{feature:c,id:u,index:d,sourceLayerIndex:f}of e){let e=Db(c,s);if(!this.layers[0]._featureFilter.filter(o,e,n))continue;let p=i?r.evaluate(e,{},n,t.availableImages):void 0,m={id:u,properties:c.properties,type:c.type,sourceLayerIndex:f,index:d,geometry:a7(s?e.geometry:Eb(c),l),patterns:{},sortKey:p};i?a.push(m):this.addBucketFeature(m,c,t,n)}if(i){a.sort((e,t)=>e.sortKey-t.sortKey);for(let r of a)this.addBucketFeature(r,e[r.index].feature,t,n)}}addBucketFeature(e,t,n,r){let{geometry:i,index:a,sourceLayerIndex:o}=e;if(this.hasDependencies){let t=y5(`fill`,this.layers,e,{zoom:this.zoom},n);this.patternFeatures.push(t)}else this.addFeature(e,i,a,r,{},n.subdivisionGranularity);n.featureIndex.insert(t,i,a,o,this.index)}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}addFeatures({options:e,canonical:t,patternPositions:n,patternMap:r}){this.detectSdfPatterns(r);for(let r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,n,e.subdivisionGranularity)}detectSdfPatterns(e){for(let t of this.patternFeatures)for(let n in t.patterns){let r=t.patterns[n];this.recordSdfPattern(n,e[r.min]),this.recordSdfPattern(n,e[r.mid]),this.recordSdfPattern(n,e[r.max])}for(let t of this.layers){let n=t.paint.get(`fill-pattern`).constantOr(null);n&&(this.recordSdfPattern(t.id,e[n.from.toString()]),this.recordSdfPattern(t.id,e[n.to.toString()]))}}recordSdfPattern(e,t){if(!t)return;let n=t.sdf===!0,r=this.sdfPatterns[e];r===void 0?this.sdfPatterns[e]=n:r!==n&&ig(`Style sheet warning: Cannot mix SDF and non-SDF fill patterns in layer "${e}"`)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,xte),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,n,r,i,a){for(let e of Pv(t,500)){let t=e7(e,r,a.fill.getGranularityForZoomLevel(r.z)),n=this.layoutVertexArray;r7((e,t)=>{n.emplaceBack(e,t)},this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,canonical:r})}};Y(`FillBucket`,c7,{omit:[`layers`,`patternFeatures`]});var $te,ene=()=>$te||=new X4({"fill-sort-key":new K4(K.layout_fill[`fill-sort-key`],`fill-sort-key`)}),tne,nne=()=>tne||=new X4({"fill-antialias":new X(K.paint_fill[`fill-antialias`],`fill-antialias`),"fill-opacity":new K4(K.paint_fill[`fill-opacity`],`fill-opacity`),"fill-layer-opacity":new X(K.paint_fill[`fill-layer-opacity`],`fill-layer-opacity`),"fill-layer-blend":new X(K.paint_fill[`fill-layer-blend`],`fill-layer-blend`),"fill-color":new K4(K.paint_fill[`fill-color`],`fill-color`),"fill-outline-color":new K4(K.paint_fill[`fill-outline-color`],`fill-outline-color`),"fill-translate":new X(K.paint_fill[`fill-translate`],`fill-translate`),"fill-translate-anchor":new X(K.paint_fill[`fill-translate-anchor`],`fill-translate-anchor`),"fill-pattern":new q4(K.paint_fill[`fill-pattern`],`fill-pattern`),"fill-rounded-corner-distance":new X(K.paint_fill[`fill-rounded-corner-distance`],`fill-rounded-corner-distance`)}),rne={get paint(){return nne()},get layout(){return ene()}},l7=e=>e.type===`fill`,u7=class extends $4{constructor(e,t){super(e,rne,t)}recalculate(e,t){super.recalculate(e,t);let n=this.paint._values[`fill-outline-color`];n.value.kind===`constant`&&n.value.value===void 0&&(this.paint._values[`fill-outline-color`]=this.paint._values[`fill-color`])}_paintPropertyRequiresRelayout(e){return e===`fill-rounded-corner-distance`}createBucket(e){return new c7(e)}queryRadius(){return p5(this.paint.get(`fill-translate`))}queryIntersectsFeature({queryGeometry:e,geometry:t,projectedCamera:n,pixelsToTileUnits:r}){return Rb(m5(e,this.paint.get(`fill-translate`),this.paint.get(`fill-translate-anchor`),-n.bearingInRadians,r),t)}isTileClipped(){return!0}},d7=I3([{name:`a_pos`,components:2,type:`Int16`},{name:`a_normal_ed`,components:4,type:`Int16`}],4),ine=I3([{name:`a_centroid`,components:2,type:`Int16`}],4),f7=d7.members;d7.size,d7.alignment;var p7=class{constructor(e,t,n,r,i){for(this.properties=Object.create(null),this.extent=n,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=i;e.pos>3,a===0)continue}if(a--,i===1)o+=e.readSVarint(),s+=e.readSVarint(),r&&n.push(r),r=[new U(o,s)];else if(i===2)o+=e.readSVarint(),s+=e.readSVarint(),r&&r.push(new U(o,s));else if(i===7)r&&r.push(r[0].clone());else throw Error(`unknown command ${i}`)}return r&&n.push(r),n}bbox(){if(this._geometry<0)throw Error(`feature has no geometry`);let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,n=1,r=0,i=0,a=0,o=1/0,s=-1/0,c=1/0,l=-1/0;for(;e.pos>3,r===0)continue}if(r--,n===1||n===2)i+=e.readSVarint(),a+=e.readSVarint(),is&&(s=i),al&&(l=a);else if(n!==7)throw Error(`unknown command ${n}`)}return[o,c,s,l]}toGeoJSON(e,t,n){let r=this.extent*2**n,i=this.extent*e,a=this.extent*t,o=this.loadGeometry();function s(e){return[(e.x+i)*360/r-180,360/Math.PI*Math.atan(Math.exp((1-(e.y+a)*2/r)*Math.PI))-90]}function c(e){return e.map(s)}let l;if(this.type===1){let e=[];for(let t of o)e.push(t[0]);let t=c(e);l=e.length===1?{type:`Point`,coordinates:t[0]}:{type:`MultiPoint`,coordinates:t}}else if(this.type===2){let e=o.map(c);l=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e}}else if(this.type===3){let e=m7(o),t=[];for(let n of e)t.push(n.map(c));l=t.length===1?{type:`Polygon`,coordinates:t[0]}:{type:`MultiPolygon`,coordinates:t}}else throw Error(`unknown feature type`);let u={type:`Feature`,geometry:l,properties:this.properties};return this.id!=null&&(u.id=this.id),u}};p7.types=[`Unknown`,`Point`,`LineString`,`Polygon`];function m7(e){let t=e.length;if(t<=1)return[e];let n=[],r,i;for(let a=0;a=this._features.length)throw Error(`feature index out of bounds`);this._pbf.pos=this._features[e];let t=this._pbf.readVarint()+this._pbf.pos;return new p7(this._pbf,t,this.extent,this._keys,this._values)}};function g7(e){let t=null,n=e.readVarint()+e.pos;for(;e.pose.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new E6,this.centroidVertexArray=new x6,this.indexArray=new z6,this.programConfigurations=new bb(e.layers,e.zoom),this.segments=new W6,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n){this.features=[],this.hasDependencies=v5(`fill-extrusion`,this.layers,t);let r=new F4(this.zoom),i=this.layers[0],a=i.layout.get(`fill-extrusion-rounded-corner-distance`),o=a>0?o7(a,n):0,s=i._featureFilter.needGeometry;for(let{feature:a,id:c,index:l,sourceLayerIndex:u}of e){let e=Db(a,s);if(!i._featureFilter.filter(r,e,n))continue;let d={id:c,sourceLayerIndex:u,index:l,geometry:a7(s?e.geometry:Eb(a),o),properties:a.properties,type:a.type,patterns:{}};this.hasDependencies?this.features.push(y5(`fill-extrusion`,this.layers,d,{zoom:this.zoom},t)):this.addFeature(d,d.geometry,l,n,{},t.subdivisionGranularity),t.featureIndex.insert(a,d.geometry,l,u,this.index,!0)}}addFeatures({options:e,canonical:t,patternPositions:n}){for(let r of this.features){let{geometry:i}=r;this.addFeature(r,i,r.index,t,n,e.subdivisionGranularity)}}update(e,t,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,f7),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,ine.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,n,r,i,a){for(let n of Pv(t,500)){let t={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(t,r,e,n,a);let o=this.layoutVertexArray.length-i,s=Math.floor(t.x/t.sampleCount),c=Math.floor(t.y/t.sampleCount);for(let e=0;e{y7(l,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,c.verticesFlattened,c.indicesTriangles)}_generateSideFaces(e,t){let n=0,r=this.layers[0].layout.get(`fill-extrusion-rounded-corner-distance`)>0?Yte(e):null;for(let i=1;iW6.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let s=a.sub(o)._perp()._unit(),{start:c,end:l}=r?r[i]:{start:s,end:s},u=o.dist(a);n+u>32768&&(n=0),y7(this.layoutVertexArray,a.x,a.y,l.x,l.y,0,0,n),y7(this.layoutVertexArray,a.x,a.y,l.x,l.y,0,1,n),n+=u,y7(this.layoutVertexArray,o.x,o.y,c.x,c.y,0,0,n),y7(this.layoutVertexArray,o.x,o.y,c.x,c.y,0,1,n);let d=t.segment.vertexLength;this.indexArray.emplaceBack(d,d+2,d+1),this.indexArray.emplaceBack(d+1,d+2,d+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}};function x7(e,t){for(let n=0;nS7||=new X4({"fill-extrusion-rounded-corner-distance":new X(K[`layout_fill-extrusion`][`fill-extrusion-rounded-corner-distance`],`fill-extrusion-rounded-corner-distance`)}),w7,T7=()=>w7||=new X4({"fill-extrusion-opacity":new K4(K[`paint_fill-extrusion`][`fill-extrusion-opacity`],`fill-extrusion-opacity`),"fill-extrusion-color":new K4(K[`paint_fill-extrusion`][`fill-extrusion-color`],`fill-extrusion-color`),"fill-extrusion-translate":new X(K[`paint_fill-extrusion`][`fill-extrusion-translate`],`fill-extrusion-translate`),"fill-extrusion-translate-anchor":new X(K[`paint_fill-extrusion`][`fill-extrusion-translate-anchor`],`fill-extrusion-translate-anchor`),"fill-extrusion-pattern":new q4(K[`paint_fill-extrusion`][`fill-extrusion-pattern`],`fill-extrusion-pattern`),"fill-extrusion-height":new K4(K[`paint_fill-extrusion`][`fill-extrusion-height`],`fill-extrusion-height`),"fill-extrusion-base":new K4(K[`paint_fill-extrusion`][`fill-extrusion-base`],`fill-extrusion-base`),"fill-extrusion-vertical-gradient":new X(K[`paint_fill-extrusion`][`fill-extrusion-vertical-gradient`],`fill-extrusion-vertical-gradient`)}),E7={get paint(){return T7()},get layout(){return C7()}},D7=e=>e.type===`fill-extrusion`,O7=class extends $4{constructor(e,t){super(e,E7,t)}createBucket(e){return new b7(e)}queryRadius(){return p5(this.paint.get(`fill-extrusion-translate`))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,projectedCamera:i,pixelsToTileUnits:a,unwrappedTileID:o}){let s=m5(e,this.paint.get(`fill-extrusion-translate`),this.paint.get(`fill-extrusion-translate-anchor`),-i.bearingInRadians,a),c=this.paint.get(`fill-extrusion-height`).evaluate(t,n),l=this.paint.get(`fill-extrusion-base`).evaluate(t,n),u=s.map(e=>k7(e,0,i,o));return M7(r.map(e=>e.map(e=>k7(e,l,i,o))),r.map(e=>e.map(e=>k7(e,c,i,o))),u)}};function k7(e,t,n,r){let{point:i,signedDistanceFromCamera:a}=Q(n).projectTileCoordinates(n,e.x,e.y,r,t),o=i;return o.z=a,o}function A7(e,t){return e.x*t.x+e.y*t.y}function j7(e,t){if(e.length===1){let n=0,r=t[n++],i;for(;!i||r.equals(i);)if(i=t[n++],!i)return 1/0;for(;nP7||=new X4({"heatmap-radius":new K4(K.paint_heatmap[`heatmap-radius`],`heatmap-radius`),"heatmap-weight":new K4(K.paint_heatmap[`heatmap-weight`],`heatmap-weight`),"heatmap-intensity":new X(K.paint_heatmap[`heatmap-intensity`],`heatmap-intensity`),"heatmap-color":new Y4(K.paint_heatmap[`heatmap-color`],`heatmap-color`),"heatmap-opacity":new X(K.paint_heatmap[`heatmap-opacity`],`heatmap-opacity`)}),I7={get paint(){return F7()}};function L7(e){let t={},n=e.resolution||256,r=e.clips?e.clips.length:1,i=e.image||new _3({width:n,height:r});if(!Yh(n))throw Error(`width is not a power of 2 - ${n}`);let a=(r,a,o)=>{t[e.evaluationKey]=o;let s=e.expression.evaluate(t);i.setPixel(r/4/n,a/4,s)};if(e.clips)for(let t=0,i=0;te.type===`heatmap`,B7=class extends $4{createBucket(e){return new N7(e)}constructor(e,t){super(e,I7,t),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e===`heatmap-color`&&this._updateColorRamp()}_updateColorRamp(){let e=this._transitionablePaint._values[`heatmap-color`].value.expression;this.colorRamp=L7({expression:e,evaluationKey:`heatmapDensity`,image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(`big-fb`)&&this.heatmapFbos.delete(R7)}queryRadius(e){return f5(`heatmap-radius`,this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,projectedCamera:i,pixelsToTileUnits:a,unwrappedTileID:o,getElevation:s}){return h5({queryGeometry:e,size:this.paint.get(`heatmap-radius`).evaluate(t,n)*a,projectedCamera:i,unwrappedTileID:o,getElevation:s},r)}hasOffscreenPass(){return this.paint.get(`heatmap-opacity`)!==0&&!this.isHidden()}},V7=class{projectX(e){return e/360+.5}projectY(e){let t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}unprojectX(e){return(e-.5)*360}unprojectY(e){let t=(180-e*360)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}},H7=class{projectX(e){return e}projectY(e){return e}unprojectX(e){return e}unprojectY(e){return e}};new V7,new H7;var U7=I3([{name:`a_pos_normal`,components:2,type:`Int16`},{name:`a_data`,components:4,type:`Uint8`},{name:`a_offset_normal`,components:2,type:`Int8`}],2),W7=U7.members;U7.size,U7.alignment;var G7=I3([{name:`a_uv_x`,components:1,type:`Float32`},{name:`a_split_index`,components:1,type:`Float32`}]),K7=G7.members;G7.size,G7.alignment;var q7=I3([{name:`a_offset_distance`,components:1,type:`Float32`}]),J7=q7.members;q7.size,q7.alignment;var Y7=Math.cos(Math.PI/180*37.5),X7=[1];function Z7(e,t){let n=t.x*e.x+t.y*e.y,r=t.sub(e.mult(n)),i=Math.sqrt(3),a=r.mag();return a>i&&r._mult(i/a),r._add(e)}function Q7(e){return!!e.paint.get(`line-dasharray`).constantOr(1)&&e.paint.get(`line-offset`).constantOr(1)!==0}var $7=.5,e9=2**14/$7,t9=class{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(let e of this.layers)this.gradients[e.id]={};this.layoutVertexArray=new D6,this.layoutVertexArray2=new O6,this.offsetDistanceArray=this.layers.some(Q7)?new k6:void 0,this.offsetDistanceBuffer=void 0,this.indexArray=new z6,this.programConfigurations=new bb(e.layers,e.zoom),this.segments=new W6,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n){this.hasDependencies=v5(`line`,this.layers,t)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get(`line-sort-key`),i=!r.isConstant(),a=[],o=new F4(this.zoom),s=this.layers[0]._featureFilter.needGeometry;for(let{feature:c,id:l,index:u,sourceLayerIndex:d}of e){let e=Db(c,s);if(!this.layers[0]._featureFilter.filter(o,e,n))continue;let f=i?r.evaluate(e,{},n):void 0,p={id:l,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:s?e.geometry:Eb(c),patterns:{},dashes:{},sortKey:f};i?a.push(p):this.addBucketFeature(p,c,t,n)}if(i){a.sort((e,t)=>e.sortKey-t.sortKey);for(let r of a)this.addBucketFeature(r,e[r.index].feature,t,n)}}addBucketFeature(e,t,n,r){let{geometry:i,index:a,sourceLayerIndex:o}=e;this.hasDependencies?(v5(`line`,this.layers,n)?y5(`line`,this.layers,e,{zoom:this.zoom},n):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,e,this.zoom,n),this.patternFeatures.push(e)):this.addFeature(e,i,a,r,{},{},n.subdivisionGranularity),n.featureIndex.insert(t,i,a,o,this.index)}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:n,dashPositions:r})}addFeatures({options:e,canonical:t,patternPositions:n,dashPositions:r}){for(let i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,n,r,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,K7)),this.offsetDistanceArray?.length&&(this.offsetDistanceBuffer=e.createVertexBuffer(this.offsetDistanceArray,J7)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,W7),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.offsetDistanceBuffer?.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.hasOwn(e.properties,`geojsonvt_clip_start`)&&Object.hasOwn(e.properties,`geojsonvt_clip_end`))return{start:+e.properties.geojsonvt_clip_start,end:+e.properties.geojsonvt_clip_end}}addFeature(e,t,n,r,i,a,o){let s=this.layers[0].layout,c=s.get(`line-join`).evaluate(e,{}),l=s.get(`line-cap`).evaluate(e,{}),u=s.get(`line-miter-limit`).evaluate(e,{}),d=s.get(`line-round-limit`).evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(let n of t){let t=this.layoutVertexArray.length;this.addLine(n,e,c,l,u,d,r,o),this.offsetDistanceArray&&this.addOffsetDistances(t)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{imagePositions:i,dashPositions:a,canonical:r})}addLine(e,t,n,r,i,a,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0;let c=o?s.line.getGranularityForZoomLevel(o.z):1;if(e=t7(e,c),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[u-1].equals(e[u-2]);)u--;let d=0;for(;d0,C=o.mult(Math.min(y,2)),w=G((y-3)/5,0,1);if(x&&t>d){let e=m.dist(h);if(e>2*f){let t=m.sub(m.sub(h)._mult(f/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,_,0,0,p,!1,Z7(_,C),w),h=t}}let T=h&&g,E=T?n:l?`butt`:r;if(T&&E===`round`&&(yi&&(E=`bevel`),E===`bevel`&&(y>2&&(E=`flipbevel`),y100)o=v.mult(-1);else{let e=y*_.add(v).mag()/_.sub(v).mag();o._perp()._mult(e*(S?-1:1))}this.addCurrentVertex(m,o,0,0,p,!1,C,w),this.addCurrentVertex(m,o.mult(-1),0,0,p,!1,C,w)}else if(E===`bevel`||E===`fakeround`){let e=-Math.sqrt(y*y-1),t=S?e:0,n=S?0:e;if(h&&this.addCurrentVertex(m,_,t,n,p,!1,C),E===`fakeround`){let e=Math.round(b*180/Math.PI/20);for(let t=1;t2*f){let t=m.add(g.sub(m)._mult(f/e)._round());this.updateDistance(m,t),this.addCurrentVertex(t,v,0,0,p,!1,Z7(v,C),w),m=t}}}}addCurrentVertex(e,t,n,r,i,a=!1,o=t,s=0){let c=t.x+t.y*n,l=t.y-t.x*n,u=-t.x+t.y*r,d=-t.y-t.x*r,f=o.x+(t.x-o.x)*s,p=o.y+(t.y-o.y)*s;this.addHalfVertex(e,c,l,f,p,a,!1,i),this.addHalfVertex(e,u,d,-f,-p,a,!0,i),this.distance>e9/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,n,r,i,a,o,s))}addHalfVertex({x:e,y:t},n,r,i,a,o,s,c){let l=(this.lineClips?this.scaledDistance*(e9-1):this.scaledDistance)*$7;if(this.layoutVertexArray.emplaceBack((e<<1)+ +!!o,(t<<1)+ +!!s,Math.round(63*n)+128,Math.round(63*r)+128,(l&63)<<2,l>>6,Math.round(63*i),Math.round(63*a)),this.lineClips){let e=(this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start);this.layoutVertexArray2.emplaceBack(e,this.lineClipsArray.length)}let u=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),c.primitiveLength++),s?this.e2=u:this.e1=u}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}addOffsetDistances(e){let{int16:t,int8:n}=this.layoutVertexArray,r=this.lineClips?(this.lineClips.end-this.lineClips.start)*(e9-1)/this.totalDistance:1,i=0,a=0,o=0,s=0,c=0;for(let l=e;l>1,d=t[l*5+1]>>1,f=t[l*5+1]&1?-1:1,p=f*n[l*10+8]/63,m=f*n[l*10+9]/63,h=u-a,g=d-o;l>e&&(h!==0||g!==0)&&(i+=((p-s)*h+(m-c)*g)/Math.hypot(h,g)),this.offsetDistanceArray.emplaceBack(i*r),a=u,o=d,s=p,c=m}}hasLineDasharray(e){for(let t of e){let e=t.paint.get(`line-dasharray`);if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,n,r){for(let i of e){let e=i.paint.get(`line-dasharray`);if(!e||e.value.kind===`constant`)continue;let a=i.layout.get(`line-cap`).evaluate(t,{})===`round`,o={dasharray:e.value.evaluate({zoom:n-1},t,{})??X7,round:a},s={dasharray:e.value.evaluate({zoom:n},t,{})??X7,round:a},c={dasharray:e.value.evaluate({zoom:n+1},t,{})??X7,round:a},l=`${o.dasharray.join(`,`)},${o.round}`,u=`${s.dasharray.join(`,`)},${s.round}`,d=`${c.dasharray.join(`,`)},${c.round}`;r.dashDependencies[l]=o,r.dashDependencies[u]=s,r.dashDependencies[d]=c,t.dashes[i.id]={min:l,mid:u,max:d}}}};Y(`LineBucket`,t9,{omit:[`layers`,`patternFeatures`]});var n9,r9=()=>n9||=new X4({"line-cap":new K4(K.layout_line[`line-cap`],`line-cap`),"line-join":new K4(K.layout_line[`line-join`],`line-join`),"line-miter-limit":new K4(K.layout_line[`line-miter-limit`],`line-miter-limit`),"line-round-limit":new K4(K.layout_line[`line-round-limit`],`line-round-limit`),"line-sort-key":new K4(K.layout_line[`line-sort-key`],`line-sort-key`)}),i9,a9=()=>i9||=new X4({"line-opacity":new K4(K.paint_line[`line-opacity`],`line-opacity`),"line-layer-opacity":new X(K.paint_line[`line-layer-opacity`],`line-layer-opacity`),"line-layer-blend":new X(K.paint_line[`line-layer-blend`],`line-layer-blend`),"line-color":new K4(K.paint_line[`line-color`],`line-color`),"line-translate":new X(K.paint_line[`line-translate`],`line-translate`),"line-translate-anchor":new X(K.paint_line[`line-translate-anchor`],`line-translate-anchor`),"line-width":new K4(K.paint_line[`line-width`],`line-width`),"line-gap-width":new K4(K.paint_line[`line-gap-width`],`line-gap-width`),"line-offset":new K4(K.paint_line[`line-offset`],`line-offset`),"line-blur":new K4(K.paint_line[`line-blur`],`line-blur`),"line-dasharray":new q4(K.paint_line[`line-dasharray`],`line-dasharray`),"line-pattern":new q4(K.paint_line[`line-pattern`],`line-pattern`),"line-gradient":new Y4(K.paint_line[`line-gradient`],`line-gradient`)}),o9={get paint(){return a9()},get layout(){return r9()}},s9=class extends K4{possiblyEvaluate(e,t){return t=new F4(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,r){return t=new F4(Math.floor(t.zoom),t),super.evaluate(e,t,n,r)}},c9,l9=e=>e.type===`line`,u9=class extends $4{constructor(e,t){super(e,o9,t),this.gradientVersion=0,c9||(c9=new s9(o9.paint.properties[`line-width`].specification,`line-floorwidth`),c9.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e===`line-gradient`){let e=this.gradientExpression();this.stepInterpolant=Fy(e)?e._styleExpression.expression instanceof v0:!1,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values[`line-gradient`].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values[`line-floorwidth`]=c9.possiblyEvaluate(this._transitioningPaint._values[`line-width`].value,e)}createBucket(e){return new t9(e)}queryRadius(e){let t=e,n=d9(f5(`line-width`,this,t),f5(`line-gap-width`,this,t)),r=f5(`line-offset`,this,t);return n/2+Math.abs(r)+p5(this.paint.get(`line-translate`))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,projectedCamera:i,pixelsToTileUnits:a}){let o=m5(e,this.paint.get(`line-translate`),this.paint.get(`line-translate-anchor`),-i.bearingInRadians,a),s=a/2*d9(this.paint.get(`line-width`).evaluate(t,n),this.paint.get(`line-gap-width`).evaluate(t,n)),c=this.paint.get(`line-offset`).evaluate(t,n);return c&&(r=cte(r,c*a)),zb(o,r,s)}isTileClipped(){return!0}};function d9(e,t){return t>0?t+2*e:e}var f9=I3([{name:`a_pos_offset`,components:4,type:`Int16`},{name:`a_data`,components:4,type:`Uint16`},{name:`a_pixeloffset`,components:4,type:`Int16`},{name:`a_height_offset`,components:1,type:`Float32`}],4),p9=I3([{name:`a_projected_pos`,components:3,type:`Float32`}],4);I3([{name:`a_fade_opacity`,components:1,type:`Uint32`}],4);var m9=I3([{name:`a_placed`,components:2,type:`Uint8`},{name:`a_shift`,components:2,type:`Float32`},{name:`a_box_real`,components:2,type:`Int16`}]);I3([{type:`Int16`,name:`anchorPointX`},{type:`Int16`,name:`anchorPointY`},{type:`Int16`,name:`x1`},{type:`Int16`,name:`y1`},{type:`Int16`,name:`x2`},{type:`Int16`,name:`y2`},{type:`Uint32`,name:`featureIndex`},{type:`Uint16`,name:`sourceLayerIndex`},{type:`Uint16`,name:`bucketIndex`}]);var h9=I3([{name:`a_pos`,components:2,type:`Int16`},{name:`a_anchor_pos`,components:2,type:`Int16`},{name:`a_extrude`,components:2,type:`Int16`}],4),g9=I3([{name:`a_pos`,components:2,type:`Float32`},{name:`a_radius`,components:1,type:`Float32`},{name:`a_flags`,components:2,type:`Int16`}],4);I3([{name:`triangle`,components:3,type:`Uint16`}]),I3([{type:`Int16`,name:`anchorX`},{type:`Int16`,name:`anchorY`},{type:`Uint32`,name:`glyphStartIndex`},{type:`Uint16`,name:`numGlyphs`},{type:`Uint32`,name:`vertexStartIndex`},{type:`Uint32`,name:`lineStartIndex`},{type:`Uint32`,name:`lineLength`},{type:`Uint16`,name:`segment`},{type:`Uint16`,name:`lowerSize`},{type:`Uint16`,name:`upperSize`},{type:`Float32`,name:`lineOffsetX`},{type:`Float32`,name:`lineOffsetY`},{type:`Uint8`,name:`writingMode`},{type:`Uint8`,name:`placedOrientation`},{type:`Uint8`,name:`hidden`},{type:`Uint32`,name:`crossTileID`},{type:`Int16`,name:`associatedIconIndex`},{type:`Float32`,name:`heightOffset`}]);var _9=I3([{type:`Int16`,name:`anchorX`},{type:`Int16`,name:`anchorY`},{type:`Int16`,name:`rightJustifiedTextSymbolIndex`},{type:`Int16`,name:`centerJustifiedTextSymbolIndex`},{type:`Int16`,name:`leftJustifiedTextSymbolIndex`},{type:`Int16`,name:`verticalPlacedTextSymbolIndex`},{type:`Int16`,name:`placedIconSymbolIndex`},{type:`Int16`,name:`verticalPlacedIconSymbolIndex`},{type:`Uint16`,name:`key`},{type:`Uint16`,name:`textBoxStartIndex`},{type:`Uint16`,name:`textBoxEndIndex`},{type:`Uint16`,name:`verticalTextBoxStartIndex`},{type:`Uint16`,name:`verticalTextBoxEndIndex`},{type:`Uint16`,name:`iconBoxStartIndex`},{type:`Uint16`,name:`iconBoxEndIndex`},{type:`Uint16`,name:`verticalIconBoxStartIndex`},{type:`Uint16`,name:`verticalIconBoxEndIndex`},{type:`Uint16`,name:`featureIndex`},{type:`Uint16`,name:`numHorizontalGlyphVertices`},{type:`Uint16`,name:`numVerticalGlyphVertices`},{type:`Uint16`,name:`numIconVertices`},{type:`Uint16`,name:`numVerticalIconVertices`},{type:`Uint16`,name:`useRuntimeCollisionCircles`},{type:`Uint32`,name:`crossTileID`},{type:`Float32`,name:`textBoxScale`},{type:`Float32`,name:`collisionCircleDiameter`},{type:`Uint16`,name:`textAnchorOffsetStartIndex`},{type:`Uint16`,name:`textAnchorOffsetEndIndex`},{type:`Float32`,name:`heightOffset`}]);I3([{type:`Float32`,name:`offsetX`}]),I3([{type:`Int16`,name:`x`},{type:`Int16`,name:`y`},{type:`Int16`,name:`tileUnitDistanceFromAnchor`}]),I3([{type:`Uint16`,name:`textAnchor`},{type:`Float32`,components:2,name:`textOffset`}]);var v9=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus=`unavailable`,this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(v9.isParsed())throw Error(`RTL text plugin already registered.`);this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}async syncState(e,t){if(this.isParsed())return this.getState();if(e.pluginStatus!==`loading`)return this.setState(e),e;let n=e.pluginURL,r=new Promise(e=>{this.loadScriptResolve=e}),i=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(await t(n),await Promise.race([r,i]),this.isParsed()){let e={pluginStatus:`loaded`,pluginURL:n};return this.setState(e),e}throw this.setState({pluginStatus:`error`,pluginURL:``}),Error(`RTL Text Plugin failed to import scripts from ${n}`)}};function y9(e){return/[\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u077F\u07C0-\u07FA\u07FD-\u07FF\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\u1800\u1801\u1804\u1806-\u1819\u1820-\u1878\u1880-\u18AA\uA840-\uA877\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF80-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDD00-\uDD27\uDD30-\uDD39\uDE60-\uDE7E\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDEFF\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB]|\uD805[\uDE60-\uDE6C]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9C-\uDC9F]|\uD83A[\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(e))}function b9(e){return/[\u0591-\u05C7\u05D0-\u05EA\u05EF-\u05F4\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u07B1\u07C0-\u07FA\u07FD-\u082D\u0830-\u083E\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\uFB1D-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC57-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD1F-\uDD39\uDD3F-\uDD59\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE50-\uDE58\uDE60-\uDE9F\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF00-\uDF35\uDF39-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD85\uDD8E\uDD8F\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB-\uDEAD\uDEB0\uDEB1\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDF27\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(e))}function x9(e){return/[\u0900-\u109F\u1700-\u17FF\u1900-\u194F\u19E0-\u1AAF\u1B00-\u1C4F\u1CC0-\u1CCF\uA800-\uA82F\uA880-\uA8FF\uA930-\uA95F\uA980-\uAAFF\uABC0-\uABFF]|\uD802[\uDE00-\uDE5F]|\uD804[\uDC00-\uDCCF\uDD00-\uDD4F\uDD80-\uDE4F\uDEB0-\uDFFF]|\uD805[\uDC00-\uDCDF\uDD80-\uDE5F\uDE80-\uDF4F]|\uD806[\uDC00-\uDC4F\uDD00-\uDD5F\uDDA0-\uDEAF\uDF00-\uDF7F]|\uD807[\uDC00-\uDCBF\uDD00-\uDDAF\uDEE0-\uDF5F\uDFC0-\uDFFF]|\uD818[\uDD00-\uDD3F]/gim.test(String.fromCodePoint(e))}function S9(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function C9(e){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function w9(e){return/[\u02EA\u02EB\u1100-\u11FF\u1401-\u167F\u18B0-\u18FF\u2065\u20DD-\u20E0\u20E2-\u20E4\u2B97\u2BF0-\u2BFF\u2E50\u2E51\u2E80-\u3007\u3012\u3013\u3020-\u302F\u3031-\u30FB\u30FD-\uA4CF\uA960-\uA97F\uAC00-\uD7FF\uF900-\uFAFF\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7\uFFF0-\uFFF8]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|[\uD80C-\uD810\uD81C-\uD822\uD83C\uD83D\uD840-\uD87E\uD880-\uD8BE][\uDC00-\uDFFF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFFF]|\uD823[\uDC00-\uDDFF]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFF]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83E[\uDD00-\uDEFF]|[\uD87F\uD8BF][\uDC00-\uDFFD]/gim.test(String.fromCodePoint(e))}function T9(e){return/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))}function E9(e){return/[\r\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0600-\u0605\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DD\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u070F\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0890\u0891\u0897-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E33-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB3-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1037\u1039-\u103E\u1056-\u1059\u105E-\u1060\u1071-\u1074\u1082\u1084-\u1086\u108D\u109D\u1100-\u11FF\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60\u1A62\u1A65-\u1A7C\u1A7F\u1AB0-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA960-\uA97C\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDEFA-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCBD\uDCC2\uDCCD\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC2\uDDC3\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDE41\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDFB8-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD2\uDFE1\uDFE2]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF1F\uDF22-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE84-\uDE99\uDF60-\uDF67]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6\uDF00-\uDF03\uDF34-\uDF3A\uDF3E-\uDF42\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDD63\uDD67-\uDD6A\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDDE6-\uDDFF\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF]/.test(e)}function D9(e){return/[\u0E01-\u0E3A\u0E40-\u0E4E\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0EDC-\u0EDF\u0F00-\u0F47\u0F49-\u0F6C\u0F71-\u0F97\u0F99-\u0FBC\u0FBE-\u0FCC\u0FCE-\u0FD4\u0FD9\u0FDA\u1000-\u103F\u1050-\u108F\u109A-\u109F\u1780-\u17D3\u17D7\u17DC\u17DD\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19DE\u19DF\u1A20-\u1A5E\u1A60-\u1A7C\u1AA0-\u1AAD\u1B00-\u1B4C\u1B4E-\u1B7F\uA980-\uA9CD\uA9D0-\uA9D9\uA9DE-\uA9EF\uA9FA-\uA9FE\uAA60-\uAAC2\uAADB-\uAADF]|\uD805[\uDF00-\uDF1A\uDF1D-\uDF2B\uDF3A\uDF3B\uDF3F-\uDF46]/gim.test(String.fromCodePoint(e))}function O9(e,t){return/(?:[\u1039\u17D2\u1A60\u1BAB\u200D\uAAF6]|\uD802\uDE3F|\uD804[\uDD33\uDFD0]|\uD806[\uDD3E\uDE47\uDE99]|\uD807[\uDD45\uDD97\uDF42])$/.test(e)||/^\p{gc=Mc}/u.test(t)}var k9={C:`18g,1;g2,3;4nb,1`,D:`17k,1;5,1;1,1;1,5;4,d;1,7;1,2;z,2;8,g;i,12;1,2;9,1;1,1;1,2;14,3;2,1;28,9;3,f;2,4;1,1;2,3;2,6;7a,1;2,5;1,1;g,a;5,2;2,6;1,f`,R:`17m,4;1,1;1,1;5,4;l,1;14,3;1,3;g,i;12,1;2,9;1,1;1,1;2,2;1,1;o,2;2x,3;f,2;4,1;1,2;3,2;6u,j;b,1;r,3;1,1;2,2;6,1`,T:`174,b;1,1;1a,l;g,1;2t,7;2,6;2,2;1,4;bt,9;16,o;1,t;1clb,1`},one={1569:[65152,0,0,0],1570:[65153,65154,0,0],1571:[65155,65156,0,0],1572:[65157,65158,0,0],1573:[65159,65160,0,0],1574:[65161,65162,65163,65164],1575:[65165,65166,0,0],1576:[65167,65168,65169,65170],1577:[65171,65172,0,0],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194,0,0],1584:[65195,65196,0,0],1585:[65197,65198,0,0],1586:[65199,65200,0,0],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262,0,0],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1611:[65136,0,0,65137],1612:[65138,0,0,0],1613:[65140,0,0,0],1614:[65142,0,0,65143],1615:[65144,0,0,65145],1616:[65146,0,0,65147],1617:[65148,0,0,65149],1618:[65150,0,0,65151],1649:[64336,64337,0,0],1655:[64477,0,0,0],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393,0,0],1676:[64388,64389,0,0],1677:[64386,64387,0,0],1678:[64390,64391,0,0],1681:[64396,64397,0,0],1688:[64394,64395,0,0],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415,0,0],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421,0,0],1729:[64422,64423,64424,64425],1733:[64480,64481,0,0],1734:[64473,64474,0,0],1735:[64471,64472,0,0],1736:[64475,64476,0,0],1737:[64482,64483,0,0],1739:[64478,64479,0,0],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431,0,0],1747:[64432,64433,0,0]},sne={لآ:[65269,65270],لأ:[65271,65272],لإ:[65273,65274],لا:[65275,65276]},A9=1604,cne=/[\u0600-\u06ff\u0750-\u077f\u0870-\u089f\u08a0-\u08ff\ufb50-\ufdff\ufe70-\ufeff]/;function lne(e,t,n){let r=0;for(let i of e.split(`;`)){let[e,a]=i.split(`,`).map(e=>parseInt(e,36)),o=r+e;for(let e=o;e{let t=e.codePointAt(0);return{codePoint:t,type:une(t),form:null}})}function hne(e){let t=e.filter(e=>e.type!==`T`);for(let e=0;e0&&dne(t[e-1].type),i=e+1String.fromCodePoint(vne(e))).join(``)}function N9(e,t,n){let r=t.layout.get(`text-transform`).evaluate(n,{});return r===`uppercase`?e=e.toLocaleUpperCase():r===`lowercase`&&(e=e.toLocaleLowerCase()),(v9.applyArabicShaping??M9)(e)}function P9(e,t,n){for(let r of e.sections)r.text=N9(r.text,t,n);return e}function F9(e,t,n){let r=n?t.last.points:t.first.points,i=n?r[r.length-1]:r[0];return`${e}:${i.x}:${i.y}`}function I9(e){let t=e.first.points,n=t.length;for(let t=e.first.next;t;t=t.next)n+=t.points.length-1;let r=Array(n);for(let e=0;e=0&&O9(t[e],n)?t[e]+=n:t.push(n)}return t}function G9(e){let t=new Set;if(V9){U9??=new Intl.Segmenter(void 0,{granularity:`word`});for(let{index:n}of U9.segment(e))t.add(n);return t}let n=0;for(let r of e.split(/\b|(?=\p{Ideo})/u))t.add(n),n+=r.length;return t}function K9(e){let t=e.codePointAt(0);return e.length>(t>65535?2:1)}function q9(e){return/\s/u.test(String.fromCodePoint(e))}function J9(e){return/[\p{P}\p{S}]/u.test(String.fromCodePoint(e))}function Y9(e){for(let t of e)if(w9(t.codePointAt(0)))return!0;return!1}function X9(e){for(let t of e)if(!Z9(t.codePointAt(0)))return!1;return!0}function Z9(e){return!y9(e)}function Q9(e){return!(w9(e)||T9(e))}function $9(e){return/\p{sc=Arab}/u.test(String.fromCodePoint(e))}function eS(e){return b9(e)}function tS(e){for(let t of e)if(eS(t.codePointAt(0)))return!0;return!1}var nS={"!":`︕`,"#":`#`,$:`$`,"%":`%`,"&":`&`,"(":`︵`,")":`︶`,"*":`*`,"+":`+`,",":`︐`,"-":`︲`,".":`・`,"/":`/`,":":`︓`,";":`︔`,"<":`︿`,"=":`=`,">":`﹀`,"?":`︖`,"@":`@`,"[":`﹇`,"\\":`\`,"]":`﹈`,"^":`^`,_:`︳`,"`":```,"{":`︷`,"|":`―`,"}":`︸`,"~":`~`,"¢":`¢`,"£":`£`,"¥":`¥`,"¦":`¦`,"¬":`¬`,"¯":` ̄`,"–":`︲`,"—":`︱`,"‘":`﹃`,"’":`﹄`,"“":`﹁`,"”":`﹂`,"…":`︙`,"⋯":`︙`,"‧":`・`,"₩":`₩`,"、":`︑`,"。":`︒`,"〈":`︿`,"〉":`﹀`,"《":`︽`,"》":`︾`,"「":`﹁`,"」":`﹂`,"『":`﹃`,"』":`﹄`,"【":`︻`,"】":`︼`,"〔":`︹`,"〕":`︺`,"〖":`︗`,"〗":`︘`,"!":`︕`,"(":`︵`,")":`︶`,",":`︐`,"-":`︲`,".":`・`,":":`︓`,";":`︔`,"<":`︿`,">":`﹀`,"?":`︖`,"[":`﹇`,"]":`﹈`,"_":`︳`,"{":`︷`,"|":`―`,"}":`︸`,"⦅":`︵`,"⦆":`︶`,"。":`︒`,"「":`﹁`,"」":`﹂`};function rS(e){let t=``,n={premature:!0,value:void 0},r=e[Symbol.iterator](),i=r.next(),a=e[Symbol.iterator]();a.next();let o=a.next();for(;!i.done;)(o.done||!Q9(o.value.codePointAt(0))||nS[o.value])&&(n.premature||!Q9(n.value.codePointAt(0))||nS[n.value])&&nS[i.value]?t+=nS[i.value]:t+=i.value,n={value:i.value,premature:!1},i=r.next(),o=a.next();return t}var iS={10:!0,13:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},aS={40:!0};function oS(e,t,n,r,i,a){if(`fontStack`in t){let r=n[t.fontStack]?.default,a=r?.[e];if(a)return a.metrics.advance*t.scale+i;let o=0;for(let n of e){let e=r?.[n];e&&(o+=e.metrics.advance*t.scale+i)}return o}{let e=r[t.imageName];return e?e.displaySize[0]*t.scale*24/a+i:0}}function sS(e,t,n,r){let i=(e-t)**2;return r?e{let o=n.slice(r,r+i.length);r+=i.length;let s=this.getSection(a);return t?.[a]!==!1&&`fontStack`in s&&e[s.fontStack]?.vertical?.[i]?i:o}),this.text=this.cachedGraphemes.join(``)}hasZeroWidthSpaces(){return this.text.includes(`​`)}trim(){let e=this.graphemes(),t=0;for(;tt&&cS(e[n-1]);)n--;this.text=e.slice(t,n).join(``),this.sectionIndex=this.sectionIndex.slice(t,n),this.cachedGraphemes=null}substring(t,n){let r=this.graphemes().slice(t,n).join(``),i=this.sectionIndex.slice(t,n);return new e(r,this.sections,i)}toCodeUnitIndex(e){return this.graphemes().slice(0,e).join(``).length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}getMaxImageSize(e){let t=0,n=0;for(let r=0;r0?n[n.length-1]:``,i=W9(r+e);this.text+=e,this.cachedGraphemes=n.slice(0,r?-1:void 0).concat(i);let a=i.length-+!!r;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,n,r,i){let a=this.determineTotalWidth(e,n,r,i);if(e>=0&&a>0&&a<=t&&!/[\n\r]/.test(this.text))return[this.length()];let o=[],s=a/Math.max(1,Math.ceil(a/t)),c=this.hasZeroWidthSpaces(),l=this.graphemes(),u=null,d=0,f=0;for(let t=0;t0){let e=l[t-1].codePointAt(0),n=a.codePointAt(0),r=C9(e),i=D9(e)&&D9(n);(iS[e]||r||`imageName`in this.getSection(t-1)||l[t+1]!==void 0&&aS[n]||i&&(u??=G9(this.text)).has(f))&&o.push(uS(t,d,s,o,lS(e,n,r&&c),!1))}q9(a.codePointAt(0))||(d+=oS(a,this.getSection(t),n,r,e,i)),f+=a.length}return dS(uS(this.length(),d,s,o,0,!0))}determineTotalWidth(e,t,n,r){let i=0,a=0;for(let o of this.graphemes()){let s=this.getSection(a);i+=oS(o,s,t,n,e,r),a++}return i}};function pS(){return(function(e){var t={R:`13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73`,EN:`1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9`,ES:`17,2,6dp+1,f+1,av,16vr,mx+1,4o,2`,ET:`z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj`,AN:`16o+5,2j+9,2+1,35,ed,1ff2+9,87+u`,CS:`18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b`,B:`a,3,f+2,2v,690`,S:`9,2,k`,WS:`c,k,4f4,1vk+a,u,1j,335`,ON:`x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i`,BN:`0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1`,NSM:`lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n`,AL:`16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d`,LRO:`6ct`,RLO:`6cu`,LRE:`6cq`,RLE:`6cr`,PDF:`6cs`,LRI:`6ee`,RLI:`6ef`,FSI:`6eg`,PDI:`6eh`},n={},r={};n.L=1,r[1]=`L`,Object.keys(t).forEach(function(e,t){n[e]=1<1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1`,canonical:`6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye`};function p(e,t){var n=0,r=new Map,i=t&&new Map,a;return e.split(`,`).forEach(function e(o){if(o.indexOf(`+`)!==-1)for(var s=+o;s--;)e(a);else{a=o;var c=o.split(`>`),l=c[0],u=c[1];l=String.fromCodePoint(n+=parseInt(l,36)),u=String.fromCodePoint(n+=parseInt(u,36)),r.set(l,u),t&&i.set(u,l)}}),{map:r,reverseMap:i}}var m,h,g;function _(){if(!m){var e=p(f.pairs,!0),t=e.map,n=e.reverseMap;m=t,h=n,g=p(f.canonical,!1).map}}function v(e){return _(),m.get(e)||null}function y(e){return _(),h.get(e)||null}function b(e){return _(),g.get(e)||null}var x=n.L,S=n.R,C=n.EN,w=n.ES,T=n.ET,E=n.AN,D=n.CS,O=n.B,k=n.S,A=n.ON,j=n.BN,M=n.NSM,N=n.AL,P=n.LRO,F=n.RLO,I=n.LRE,L=n.RLE,ee=n.PDF,R=n.LRI,z=n.RLI,B=n.FSI,te=n.PDI,ne=`14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1`,re;function ie(){if(!re){var e=p(ne,!0),t=e.map;e.reverseMap.forEach(function(e,n){t.set(n,e)}),re=t}}function ae(e){return ie(),re.get(e)||null}function oe(e,t,n,r){var i=e.length;n=Math.max(0,n==null?0:+n),r=Math.min(i-1,r==null?i-1:+r);var a=[];return t.paragraphs.forEach(function(i){var o=Math.max(n,i.start),s=Math.min(r,i.end);if(o=o&&d(e[u])&c;u--)l[u]=i.level;for(var f=i.level,p=1/0,m=0;mf&&(f=h),h=p;g--)for(var _=0;_=g){for(var v=_;_+1=g;)_++;_>v&&a.push([v+o,_+o])}}}),a}function se(e,t,n,r){for(var i=oe(e,t,n,r),a=[],o=0;o0)ce--;else if(V>0){for(le=0;!oe[oe.length-1]._isolate;)oe.pop();var he=oe[oe.length-1]._isolInitIndex;he!=null&&(m.set(he,ue),m.set(ue,he)),oe.pop(),V--}se=oe[oe.length-1],p[ue]=se._level,se._override&&f(ue,se._override)}else de&ee?(ce===0&&(le>0?le--:!se._isolate&&oe.length>1&&(oe.pop(),se=oe[oe.length-1])),p[ue]=se._level):de&O&&(p[ue]=g.level)}else p[ue]=se._level,se._override&&de!==j&&f(ue,se._override)}for(var ge=[],_e=null,ve=g.start;ve<=g.end;ve++){var ye=r[ve];if(!(ye&s)){var be=p[ve],xe=ye&i,Se=ye===te;_e&&be===_e._level?(_e._end=ve,_e._endsWithIsolInit=xe):ge.push(_e={_start:ve,_end:ve,_level:be,_startsWithPDI:Se,_endsWithIsolInit:xe})}}for(var Ce=[],we=0;we=0;Fe--)if(!(r[Fe]&s)){Pe=p[Fe];break}var Ie=ke[ke.length-1],Le=p[Ie],Re=g.level;if(!(r[Ie]&i)){for(var ze=Ie+1;ze<=g.end;ze++)if(!(r[ze]&s)){Re=p[ze];break}}Ce.push({_seqIndices:ke,_sosType:Math.max(Pe,Ne)%2?S:x,_eosType:Math.max(Re,Le)%2?S:x})}}for(var Be=0;Be=0;Ye--)if(!(r[He[Ye]]&s)){Je=r[He[Ye]];break}f(qe,Je&(i|te)?A:Je)}}if(u.get(C))for(var Xe=0;Xe=-1;Qe--){var $e=Qe===-1?Ue:r[He[Qe]];if($e&a){$e===N&&f(Ze,E);break}}}if(u.get(N))for(var et=0;et=0&&(it=r[He[ot]],it&s);ot--);for(var st=nt+1;st=0&&r[He[lt]]&(T|s);lt--)f(He[lt],C);for(ct++;ct=0&&r[He[ft]]&s;ft--)f(He[ft],A);for(var pt=ut+1;pt=0;Tt--){var Et=xt[Tt].char;if(Et===wt||Et===y(b(Ct))||v(b(Et))===Ct){bt.push([xt[Tt].seqIndex,St]),xt.length=Tt;break}}}bt.sort(function(e,t){return e[0]-t[0]});for(var Dt=0;Dt=0;It--){var Lt=He[It];if(r[Lt]&yt){var Rt=r[Lt]&vt?S:x;Mt=Rt===Ge?Ge:Rt;break}}}if(Mt){if(r[He[kt]]=r[He[At]]=Mt,Mt!==Ge){for(var zt=kt+1;zt=0;Gt--)if(r[He[Gt]]&s)Ht=Gt;else{Wt=r[He[Gt]]&vt?S:x;break}for(var Kt=We,qt=Vt+1;qt=0&&d(e[Qt])&c;Qt--)p[Qt]=g.level}}return{levels:p,paragraphs:h};function $t(t,n){for(var a=t;a=0;r--){let i=mS.getBidiCharTypeName(e[r].text[0]);_S.has(i)?(e[r].level=t,n=!0):n&&gS.has(i)?e[r].level=t:n=!1}}function bS(e,t){let n=t,r=1/0;for(let{level:t}of e)t>n&&(n=t),(t|1)=r;e--)for(let t=0;t=e;)n++;for(let e=t,r=n;et>=e.start&&t<=e.end)?.level??0}function CS(e,t,n,r,i){let a=vS(e,t,r,i);yS(a,n);let o=``,s=[];for(let e of bS(a,n)){if(hS.test(e.text))continue;let t=xS(e);o+=t,s.push(...Array(t.length).fill(e.index))}return{text:o,sourceIndices:s}}function wS(e,t){let n=t.filter(t=>t>0&&te-t),i=[];for(let e=0;e+1e.start))).map(([t,i])=>CS(e,n,SS(r,t),t,i))}function ES(e,t){return TS(e,t).map(e=>e.text)}function DS(e,t,n){return TS(e,n).map(e=>[e.text,e.sourceIndices.map(e=>t[e]??0)])}var OS=4294967296,kS=new TextDecoder,AS=class{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(e,t,n=this.length){let r;for(;r=this.nextField(n);)e(r,t,this);return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*OS;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*OS;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,n=t[this.pos++];if(n<128)return n;let r=n&127,i;return i=t[this.pos++],r|=(i&127)<<7,i<128||(i=t[this.pos++],r|=(i&127)<<14,i<128)||(i=t[this.pos++],r|=(i&127)<<21,i<128)?r:(i=t[this.pos],r|=(i&15)<<28,jS(r,e,this))}readSVarint(){let e=this.readVarint();return e<4294967296?e>>>1^-(e&1):e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=(this.buf[t]<128?12:32)?kS.decode(this.buf.subarray(t,e)):NS(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let n=this.readPackedEnd(),r=this.buf,i=this.pos;for(;i=e)return 0;let t=this.readVarint();return this.type=t&7,this._valueStart=this.pos,t>>>3}skip(e){let t=e&7;if(t===0)for(;this.buf[this.pos++]>127;);else if(t===2)this.pos=this.readVarint()+this.pos;else if(t===5)this.pos+=4;else if(t===1)this.pos+=8;else throw Error(`Unimplemented type: ${t}`)}};function jS(e,t,n){let r=n.buf,i,a;if(a=r[n.pos++],i=(a&112)>>4,a<128||(a=r[n.pos++],i|=(a&127)<<3,a<128)||(a=r[n.pos++],i|=(a&127)<<10,a<128)||(a=r[n.pos++],i|=(a&127)<<17,a<128)||(a=r[n.pos++],i|=(a&127)<<24,a<128)||(a=r[n.pos++],i|=(a&1)<<31,a<128))return MS(e,i,t);throw Error(`Expected varint not more than 10 bytes`)}function MS(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function NS(e,t,n){let r=``;for(let i=t;i127){let r=e[i+1]^128,o=e[i+2]^128;if(a>=194&&a<224&&r<64&&i+1=2048&&(a<55296||a>57343))i+=2;else return kS.decode(e.subarray(t,n))}r+=String.fromCharCode(a)}return r}function PS(e,t,n){e===1&&n.readMessage(FS,t)}function FS(e,t,n){if(e===3){let{id:e,bitmap:r,width:i,height:a,left:o,top:s,advance:c}=n.readMessage(IS,{});t.push({id:e,bitmap:new g3({width:i+6,height:a+6},r),metrics:{width:i,height:a,left:o,top:s,advance:c}})}}function IS(e,t,n){e===1?t.id=n.readVarint():e===2?t.bitmap=n.readBytes():e===3?t.width=n.readVarint():e===4?t.height=n.readVarint():e===5?t.left=n.readSVarint():e===6?t.top=n.readSVarint():e===7&&(t.advance=n.readVarint())}function LS(e){return new AS(e).readFields(PS,[])}function RS(e){return typeof e?.renderWithWebGL==`function`}function zS(e){let{userImage:t}=e;return!t?.render||!t.render()?!1:(RS(t.data)||e.data.replace(new Uint8Array(t.data.buffer)),!0)}function BS(e){let t=0,n=0;for(let r of e)t+=r.w*r.h,n=Math.max(n,r.w);e.sort((e,t)=>t.h-e.h);let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}],i=0,a=0;for(let t of e)for(let e=r.length-1;e>=0;e--){let n=r[e];if(!(t.w>n.w||t.h>n.h)){if(t.x=n.x,t.y=n.y,a=Math.max(a,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===n.w&&t.h===n.h){let t=r.pop();t&&e=n;e--)t.push(e);n=r+1}else{for(let e=n;ee.toCodeUnitIndex(t)),r=v9.isParsed()?v9:null;if(e.sections.length===1)return r?r.processBidirectionalText(e.toString(),n).map(t=>QS(t,e.sections,[...t].map(()=>0))):ES(e.toString(),n).map(t=>XS([...t],e.sections,[...t].map(()=>0)));let i=JS(e);return r?r.processStyledBidirectionalText(e.text,i,n).map(([t,n])=>QS(t,e.sections,n)):DS(e.text,i,n).map(([t,n])=>{let r=[...t];return XS(r,e.sections,ZS(r).map(e=>n[e]??0))})}function XS(e,t,n){let r=new fS(e.join(``),t,[]),i=0;for(let e of r.graphemes())r.sectionIndex.push(n[i]??0),i+=[...e].length;return r}function ZS(e){let t=[],n=0;for(let r of e)t.push(n),n+=r.length;return t}function QS(e,t,n){let r=[...e],i=ZS(r),a=qS(r);return XS(a.map(e=>r[e]),t,a.map(e=>n[i[e]]??0))}function $S(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h=fS.fromFeature(e,i,d===2,t),g=h.determineLineBreaks(l,a,t,r,p),_=tS(h.text)?YS(h,g):GS(h,g),v=[],y={positionedLines:v,text:h.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:d,iconsInText:!1,verticalizable:!1};return pC(y,t,n,r,_,o,s,c,d,l,f,m),!WS(v)&&y}function eC(e){let t=.5,n=.5;switch(e){case`right`:case`top-right`:case`bottom-right`:t=1;break;case`left`:case`top-left`:case`bottom-left`:t=0}switch(e){case`bottom`:case`bottom-right`:case`bottom-left`:n=1;break;case`top`:case`top-right`:case`top-left`:n=0}return{horizontalAlign:t,verticalAlign:n}}function tC(e,t,n){let r=t.getMaxScale()*24,{maxImageWidth:i,maxImageHeight:a}=t.getMaxImageSize(e),o=Math.max(r,a*n);return{verticalLineContentWidth:Math.max(r,i*n),horizontalLineContentHeight:o}}function nC(e){switch(e){case`top`:return 0;case`center`:return .5;default:return 1}}function rC(e,t){return e?.rect?e:t?{rect:null,metrics:t.metrics}:null}function iC(e,t,n){return!(e===1||!t&&!w9(n)||t&&(q9(n)||$9(n)))}function aC(e){return/\p{Nd}/u.test(String.fromCodePoint(e))}function oC(e){return/\p{Lu}/u.test(String.fromCodePoint(e))}function sC(e){let t=e.some(aC)&&e.every(e=>aC(e)||J9(e)),n=e.length<=3&&e.every(e=>oC(e)||aC(e));return t||n}function cC(e){return(aC(e)||oC(e))&&!$9(e)}function lC(e,t){return t?iC(2,!0,e):!Q9(e)||cC(e)||J9(e)}function uC(e,t,n){let r=!1;for(let i=0;i=0&&t=0&&te.codePointAt(0)),i=n.map((n,r)=>{let i=e.getSection(r);return`fontStack`in i&&!!t[i.fontStack]?.vertical?.[n]}),a=r.map(w9),o=t=>!a[t]&&!q9(r[t])&&!(`imageName`in e.getSection(t));for(let e=0;ee&&!a[t])){let n=e.text;if(e.verticalizePunctuation(t,a),e.text!==n)return fC(e,t)}return uC(n,a,i)&&(e.text=n.join(``),e.cachedGraphemes=n),a}function pC(e,t,n,r,i,a,o,s,c,l,u,d){let f=0,p=0,m=0,h=0,g=s===`right`?1:s===`left`?0:.5,_=24/d,v=0;for(let o of i){o.trim();let i=o.getMaxScale(),s={positionedGlyphs:[],lineOffset:0};e.positionedLines[v]=s;let d=s.positionedGlyphs,y=0;if(!o.length()){p+=a,++v;continue}let b=tC(r,o,_),x=c===2&&!u?fC(o,t):null,S=o.graphemes();for(let a=0;al){let e=Math.ceil(r/l);n*=e/i,i=e}return{x1:t,y1:n,x2:t+r,y2:n+i}}function bC(e,t,n,r,i,a,o=1){let s=e.image,c;if(s.content){let e=s.content,t=s.pixelRatio||1;c=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}let l=o>0?a/o:a,u=o>0?1/o:1,d=t.left*l,f=t.right*l,p,m,h,g;n===`width`||n===`both`?(g=i[0]+d-r[3]*u,m=i[0]+f+r[1]*u):(g=i[0]+(d+f-s.displaySize[0])/2,m=g+s.displaySize[0]);let _=t.top*l,v=t.bottom*l;return n===`height`||n===`both`?(p=i[1]+_-r[0]*u,h=i[1]+v+r[2]*u):(p=i[1]+(_+v-s.displaySize[1])/2,h=p+s.displaySize[1]),{image:s,top:p,right:m,bottom:h,left:g,collisionPadding:c}}var xC=32640;function SC(e,t){let{expression:n}=t;if(n.kind===`constant`)return{kind:`constant`,layoutSize:n.evaluate(new F4(e+1))};if(n.kind===`source`)return{kind:`source`};if(n.kind===`composite`){let{minZoom:t,maxZoom:r}=CC(n.zoomStops,e);return{kind:`composite`,minZoom:t,maxZoom:r,interpolationType:n.interpolationType}}{let t=wC(n),r=n.evaluate(new F4(e+1));return{kind:`camera`,zoomStops:n.zoomStops,sizes:t,layoutSize:r,interpolationType:n.interpolationType}}}function CC(e,t){let n=0;for(;ne.evaluate(new F4(t===-1/0?e.zoomStops[1]-1:t)))}function TC(e,{uSize:t,uSizeT:n},{lowerSize:r,upperSize:i}){return e.kind===`source`?r/128:e.kind===`composite`?E0.number(r/128,i/128,n):t}function EC(e,t){let n=0,r=0;return e.kind===`constant`?r=e.layoutSize:e.kind===`camera`?r=DC(e,t):e.kind===`composite`&&(n=OC(e,t)),{uSizeT:n,uSize:r}}function DC({zoomStops:e,sizes:t,layoutSize:n,interpolationType:r},i){let a=e.length-1;for(;a>0&&e[a]>i;)a--;let o=Math.min(a+1,e.length-1),s=r?G(w0.interpolationFactor(r,i,e[a],e[o]),0,1):0;return Math.min(E0.number(t[a],t[o],s),n)}function OC({interpolationType:e,minZoom:t,maxZoom:n},r){return e?G(w0.interpolationFactor(e,r,t,n),0,1):0}var kC=class e extends U{constructor(e,t,n,r){super(e,t),this.angle=n,r!==void 0&&(this.segment=r)}clone(){return new e(this.x,this.y,this.angle,this.segment)}};Y(`Anchor`,kC);function AC(e,t,n,r,i){if(t.segment===void 0||n===0)return!0;let a=t,o=t.segment+1,s=0;for(;s>-n/2;){if(o--,o<0)return!1;s-=e[o].dist(a),a=e[o]}s+=e[o].dist(e[o+1]),o++;let c=[],l=0;for(;sr;)l-=c.shift().angleDelta;if(l>i)return!1;o++,s+=n.dist(a)}return!0}function jC(e){let t=0;for(let n=0;nl){let u=(l-c)/a,d=new kC(E0.number(r.x,i.x,u),E0.number(r.y,i.y,u),i.angleTo(r),n);return d._round(),!o||AC(e,d,s,o,t)?d:void 0}c+=a}}function FC(e,t,n,r,i,a,o,s,c){let l=MC(r,a,o),u=NC(r,i),d=u*o,f=e[0].x===0||e[0].x===c||e[0].y===0||e[0].y===c;t-d=0&&_=0&&v=0&&f+l<=u){let n=new kC(_,v,h,t);n._round(),(!r||AC(e,n,a,r,i))&&p.push(n)}}d+=m}return s||p.length||o||(p=IC(e,d/2,n,r,i,a,o,!0,c)),p}function LC(e,t,n,r,i){let a=[];for(let o of e){let e;for(let s=0;s=r&&l.x>=r||(c.x>=r?c=new U(r,c.y+(l.y-c.y)*((r-c.x)/(l.x-c.x)))._round():l.x>=r&&(l=new U(r,c.y+(l.y-c.y)*((r-c.x)/(l.x-c.x)))._round()),c.y>=i&&l.y>=i||(c.y>=i?c=new U(c.x+(l.x-c.x)*((i-c.y)/(l.y-c.y)),i)._round():l.y>=i&&(l=new U(c.x+(l.x-c.x)*((i-c.y)/(l.y-c.y)),i)._round()),e&&c.equals(e[e.length-1])||(e=[c],a.push(e)),e.push(l)))))}}return a}function RC(e,t,n,r,i=1){let a=[],o=e.image,s=o.pixelRatio,c=o.paddedRect.w-2,l=o.paddedRect.h-2,u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom},d=o.stretchX||[[0,c]],f=o.stretchY||[[0,l]],p=(e,t)=>e+t[1]-t[0],m=d.reduce(p,0),h=f.reduce(p,0),g=c-m,_=l-h,v=0,y=m,b=0,x=h,S=0,C=g,w=0,T=_;if(o.content&&r){let t=o.content,n=t[2]-t[0],r=t[3]-t[1];(o.textFitWidth||o.textFitHeight)&&(u=yC(e)),v=zC(d,0,t[0]),b=zC(f,0,t[1]),y=zC(d,t[0],t[2]),x=zC(f,t[1],t[3]),S=t[0]-v,w=t[1]-b,C=n-y,T=r-x}let E=u.x1,D=u.y1,O=u.x2-E,k=u.y2-D,A=(e,r,a,c)=>{let l=VC(e.stretch-v,y,O,E),u=HC(e.fixed-S,C,e.stretch,m),d=VC(r.stretch-b,x,k,D),f=HC(r.fixed-w,T,r.stretch,h),p=VC(a.stretch-v,y,O,E),g=HC(a.fixed-S,C,a.stretch,m),_=VC(c.stretch-b,x,k,D),A=HC(c.fixed-w,T,c.stretch,h),j=new U(l,d),M=new U(p,d),N=new U(p,_),P=new U(l,_),F=i/s,I=new U(u*F,f*F),L=new U(g*F,A*F),ee=t*Math.PI/180;if(ee){let e=Math.sin(ee),t=Math.cos(ee),n=[t,-e,e,t];j._matMult(n),M._matMult(n),P._matMult(n),N._matMult(n)}let R=e.stretch+e.fixed,z=a.stretch+a.fixed,B=r.stretch+r.fixed,te=c.stretch+c.fixed;return{tl:j,tr:M,bl:P,br:N,tex:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:z-R,h:te-B},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:I,pixelOffsetBR:L,minFontScaleX:C*F/O,minFontScaleY:T*F/k,isSDF:n}};if(!r||!o.stretchX&&!o.stretchY)a.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:c+1},{fixed:0,stretch:l+1}));else{let e=BC(d,g,m),t=BC(f,_,h);for(let n=0;n0&&(r=Math.max(10,r),this.circleDiameter=r)}else{let c=a.image?.content&&(a.image.textFitWidth||a.image.textFitHeight)?yC(a):{x1:a.left,y1:a.top,x2:a.right,y2:a.bottom};c.y1=c.y1*o-s[0],c.y2=c.y2*o+s[2],c.x1=c.x1*o-s[3],c.x2=c.x2*o+s[1];let u=a.collisionPadding;if(u&&(c.x1-=u[0]*o,c.y1-=u[1]*o,c.x2+=u[2]*o,c.y2+=u[3]*o),l){let e=new U(c.x1,c.y1),t=new U(c.x2,c.y1),n=new U(c.x1,c.y2),r=new U(c.x2,c.y2),i=l*Math.PI/180;e._rotate(i),t._rotate(i),n._rotate(i),r._rotate(i),c.x1=Math.min(e.x,t.x,n.x,r.x),c.x2=Math.max(e.x,t.x,n.x,r.x),c.y1=Math.min(e.y,t.y,n.y,r.y),c.y2=Math.max(e.y,t.y,n.y,r.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,n,r,i)}this.boxEndIndex=e.length}},bne=class{constructor(e=[],t=(e,t)=>et)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e=0)break;t[e]=t[r],e=r}t[e]=i}};function xne(e,t=1){let n=Ob.fromPoints(e[0]),r=Math.min(n.width(),n.height()),i=r/2,a=new bne([],Sne),{minX:o,minY:s,maxX:c,maxY:l}=n;if(r===0)return new U(o,s);for(let t=o;td.d||!d.d)&&(d=n),n.max-d.d<=t||(i=n.h/2,a.push(new WC(n.p.x-i,n.p.y-i,i,e)),a.push(new WC(n.p.x+i,n.p.y-i,i,e)),a.push(new WC(n.p.x-i,n.p.y+i,i,e)),a.push(new WC(n.p.x+i,n.p.y+i,i,e)))}return u.d>0&&d.d-u.d<=t?u.p:d.p}function Sne(e,t){return t.max-e.max}var WC=class{constructor(e,t,n,r){this.p=new U(e,t),this.h=n,this.d=Cne(this.p,r),this.max=this.d+this.h*Math.SQRT2}};function Cne(e,t){let n=!1,r=1/0;for(let i of t)for(let t=0,a=i.length,o=a-1;te.y!=s.y>e.y&&e.x<(s.x-a.x)*(e.y-a.y)/(s.y-a.y)+a.x&&(n=!n),r=Math.min(r,Wb(e,a,s))}return(n?1:-1)*Math.sqrt(r)}function wne(e){let t=0,n=0,r=0,i=e[0];for(let e=0,a=i.length,o=a-1;ee*24);r.startsWith(`top`)?i[1]-=7:r.startsWith(`bottom`)&&(i[1]+=7),t[n+1]=i}return new J1(t)}let a=r.get(`text-variable-anchor`);if(a){let i;i=e._unevaluatedLayout.getValue(`text-radial-offset`)===void 0?r.get(`text-offset`).evaluate(t,{},n).map(e=>e*24):[r.get(`text-radial-offset`).evaluate(t,{},n)*24,KC];let o=[];for(let e of a)o.push(e,qC(e,i));return new J1(o)}return null}function Tne(e){e.bucket.createArrays();let t=512*e.bucket.overscaling;e.bucket.tilePixelRatio=W/t,e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;let n=e.bucket.layers[0],r=n.layout,i=n._unevaluatedLayout._values,a={layoutIconSize:i[`icon-size`].possiblyEvaluate(new F4(e.bucket.zoom+1),e.canonical),layoutTextSize:i[`text-size`].possiblyEvaluate(new F4(e.bucket.zoom+1),e.canonical),textMaxSize:i[`text-size`].possiblyEvaluate(new F4(18))};if(e.bucket.textSizeData.kind===`composite`){let{minZoom:t,maxZoom:n}=e.bucket.textSizeData;a.compositeTextSizes=[i[`text-size`].possiblyEvaluate(new F4(t),e.canonical),i[`text-size`].possiblyEvaluate(new F4(n),e.canonical)]}if(e.bucket.iconSizeData.kind===`composite`){let{minZoom:t,maxZoom:n}=e.bucket.iconSizeData;a.compositeIconSizes=[i[`icon-size`].possiblyEvaluate(new F4(t),e.canonical),i[`icon-size`].possiblyEvaluate(new F4(n),e.canonical)]}let o=r.get(`text-line-height`)*24,s=r.get(`text-rotation-alignment`)!==`viewport`&&r.get(`symbol-placement`)!==`point`,c=r.get(`text-keep-upright`),l=r.get(`text-size`);for(let t of e.bucket.features){let i=r.get(`text-font`).evaluate(t,{},e.canonical).join(`,`),u=l.evaluate(t,{},e.canonical),d=a.layoutTextSize.evaluate(t,{},e.canonical),f=a.layoutIconSize.evaluate(t,{},e.canonical),p={horizontal:{},vertical:void 0},m=t.text,h=[0,0];if(m){let a=m.toString(),l=r.get(`text-letter-spacing`).evaluate(t,{},e.canonical)*24,f=X9(a)?l:0,g=r.get(`text-anchor`).evaluate(t,{},e.canonical),_=JC(n,t,e.canonical);if(!_){let n=r.get(`text-radial-offset`).evaluate(t,{},e.canonical);h=n?qC(g,[n*24,KC]):r.get(`text-offset`).evaluate(t,{},e.canonical).map(e=>e*24)}let v=s?`center`:r.get(`text-justify`).evaluate(t,{},e.canonical),y=r.get(`symbol-placement`)===`point`?r.get(`text-max-width`).evaluate(t,{},e.canonical)*24:1/0,b=()=>{e.bucket.allowVerticalPlacement&&Y9(a)&&(p.vertical=$S(m,e.glyphMap,e.glyphPositions,e.imagePositions,i,y,o,g,`left`,f,h,2,!0,d,u))};if(!s&&_){let t=new Set;if(v===`auto`)for(let e=0;e<_.values.length;e+=2)t.add(YC(_.values[e]));else t.add(v);let n=!1;for(let r of t)if(!p.horizontal[r]){if(n)p.horizontal[r]=p.horizontal[0];else{let t=$S(m,e.glyphMap,e.glyphPositions,e.imagePositions,i,y,o,`center`,r,f,h,1,!1,d,u);t&&(p.horizontal[r]=t,n=t.positionedLines.length===1)}}b()}else{v===`auto`&&(v=YC(g));let t=$S(m,e.glyphMap,e.glyphPositions,e.imagePositions,i,y,o,g,v,f,h,1,!1,d,u);t&&(p.horizontal[v]=t),b(),Y9(a)&&s&&c&&(p.vertical=$S(m,e.glyphMap,e.glyphPositions,e.imagePositions,i,y,o,g,v,f,h,2,!1,d,u))}}let g,_=!1;if(t.icon?.name){let n=e.imageMap[t.icon.name];n&&(g=vC(e.imagePositions[t.icon.name],r.get(`icon-offset`).evaluate(t,{},e.canonical),r.get(`icon-anchor`).evaluate(t,{},e.canonical)),_=!!n.sdf,e.bucket.sdfIcons===void 0?e.bucket.sdfIcons=_:e.bucket.sdfIcons!==_&&ig(`Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer`),n.pixelRatio===e.bucket.pixelRatio?r.get(`icon-rotate`).constantOr(1)!==0&&(e.bucket.iconsNeedLinear=!0):e.bucket.iconsNeedLinear=!0)}let v=ZC(p.horizontal)||p.vertical;e.bucket.iconsInText||=v?v.iconsInText:!1,(v||g)&&Ene(e.bucket,t,p,g,e.imageMap,a,d,f,h,_,e.canonical,e.subdivisionGranularity,e.hasPromoteId)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()}function YC(e){switch(e){case`right`:case`top-right`:case`bottom-right`:return`right`;case`left`:case`top-left`:case`bottom-left`:return`left`}return`center`}function Ene(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=a.textMaxSize.evaluate(t,{});p===void 0&&(p=o);let m=e.layers[0].layout,h=m.get(`icon-offset`).evaluate(t,{},u),g=ZC(n.horizontal),_=o/24,v=e.tilePixelRatio*_,y=e.tilePixelRatio*p/24,b=e.tilePixelRatio*s,x=e.tilePixelRatio*m.get(`symbol-spacing`),S=m.get(`text-padding`)*e.tilePixelRatio,C=cw(m,t,u,e.tilePixelRatio),w=m.get(`text-max-angle`)/180*Math.PI,T=m.get(`text-rotation-alignment`)!==`viewport`&&m.get(`symbol-placement`)!==`point`,E=m.get(`icon-rotation-alignment`).constantOr(`viewport`)===`map`&&m.get(`symbol-placement`)!==`point`,D=m.get(`symbol-placement`),O=x/2,k=m.get(`icon-text-fit`),A;r&&k!==`none`&&(e.allowVerticalPlacement&&n.vertical&&(A=bC(r,n.vertical,k,m.get(`icon-text-fit-padding`),h,_,s)),g&&(r=bC(r,g,k,m.get(`icon-text-fit-padding`),h,_,s)));let j=u?d.line.getGranularityForZoomLevel(u.z):1,M=(d,p)=>{Mb(p)||One(e,p,d,n,r,i,A,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,v,[S,S,S,S],T,c,b,C,E,h,t,a,l,u,o,s,f)};if(D===`line`)for(let i of LC(t.geometry,0,0,W,W)){let t=t7(i,j),a=FC(t,x,w,n.vertical||g,r,24,y,e.overscaling,W);for(let n of a){let r=g;r&&kne(e,r.text,O,n)||M(t,n)}}else if(D===`line-center`){for(let e of t.geometry)if(e.length>1){let t=t7(e,j),i=PC(t,w,n.vertical||g,r,24,y);i&&M(t,i)}}else if(t.type===`Polygon`)for(let e of Pv(t.geometry,0)){let t=xne(e,16);M(t7(e[0],j,!0),new kC(t.x,t.y,0))}else if(t.type===`LineString`)for(let e of t.geometry){let t=t7(e,j);M(t,new kC(t[0].x,t[0].y,0))}else if(t.type===`Point`)for(let e of t.geometry)for(let t of e)M([t],new kC(t.x,t.y,0))}function Dne(e,t){let n=e.length,r=t?.values;if(r?.length>0)for(let t=0;t32640&&ig(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):_.kind===`composite`&&(v=[128*m.compositeTextSizes[0].evaluate(o,{},h),128*m.compositeTextSizes[1].evaluate(o,{},h)],(v[0]>32640||v[1]>32640)&&ig(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,v,s,a,o,u,t,l.lineStartIndex,l.lineLength,p,h,c);for(let t of d)f[t]=e.text.placedSymbolArray.length-1;return g.length*4}function ZC(e){for(let t in e)return e[t];return null}function One(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E){let D=e.addToLineVertexArray(t,n),O=s.layout.get(`symbol-height-offset`).evaluate(b,{},C);O>e.maxHeightOffset&&(e.maxHeightOffset=O);let k,A,j,M,N=0,P=0,F=0,I=0,L=-1,ee=-1,R={},z=(0,X6.default)(``);if(e.allowVerticalPlacement&&r.vertical){let e=s.layout.get(`text-rotate`).evaluate(b,{},C)+90;j=new UC(c,t,l,u,d,r.vertical,f,p,m,e),o&&(M=new UC(c,t,l,u,d,o,g,_,m,e))}if(i){let n=s.layout.get(`icon-rotate`).evaluate(b,{}),r=s.layout.get(`icon-text-fit`)!==`none`,a=RC(i,n,S,r,T),f=o?RC(o,n,S,r,T):void 0;A=new UC(c,t,l,u,d,i,g,_,!1,n),N=a.length*4;let p=e.iconSizeData,m=null;p.kind===`source`?(m=[128*s.layout.get(`icon-size`).evaluate(b,{})],m[0]>32640&&ig(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):p.kind===`composite`&&(m=[128*x.compositeIconSizes[0].evaluate(b,{},C),128*x.compositeIconSizes[1].evaluate(b,{},C)],(m[0]>32640||m[1]>32640)&&ig(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,m,y,v,b,0,t,D.lineStartIndex,D.lineLength,-1,C,O),L=e.icon.placedSymbolArray.length-1,f&&(P=f.length*4,e.addSymbols(e.icon,f,m,y,v,b,2,t,D.lineStartIndex,D.lineLength,-1,C,O),ee=e.icon.placedSymbolArray.length-1)}let B=Object.keys(r.horizontal);for(let n of B){let i=r.horizontal[n];k||=(z=(0,X6.default)(i.text),new UC(c,t,l,u,d,i,f,p,m,s.layout.get(`text-rotate`).evaluate(b,{},C)));let o=i.positionedLines.length===1;if(F+=XC(e,t,i,a,s,m,b,h,O,D,r.vertical?1:3,o?B:[n],R,L,x,C),o)break}r.vertical&&(I+=XC(e,t,r.vertical,a,s,m,b,h,O,D,2,[`vertical`],R,ee,x,C));let te=k?k.boxStartIndex:e.collisionBoxArray.length,ne=k?k.boxEndIndex:e.collisionBoxArray.length,re=j?j.boxStartIndex:e.collisionBoxArray.length,ie=j?j.boxEndIndex:e.collisionBoxArray.length,ae=A?A.boxStartIndex:e.collisionBoxArray.length,oe=A?A.boxEndIndex:e.collisionBoxArray.length,se=M?M.boxStartIndex:e.collisionBoxArray.length,ce=M?M.boxEndIndex:e.collisionBoxArray.length,le=-1,V=(e,t)=>e?.circleDiameter?Math.max(e.circleDiameter,t):t;le=V(k,le),le=V(j,le),le=V(A,le),le=V(M,le);let ue=+(le>-1);ue&&(le*=w/24),e.glyphOffsetArray.length>=e.maxGlyphs&&ig(`Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907`),b.sortKey!==void 0&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey);let de=JC(s,b,C),[fe,pe]=Dne(e.textAnchorOffsets,de);E&&(z=Ane(z,b)),e.symbolInstances.emplaceBack(t.x,t.y,R.right>=0?R.right:-1,R.center>=0?R.center:-1,R.left>=0?R.left:-1,R.vertical||-1,L,ee,z,te,ne,re,ie,ae,oe,se,ce,l,F,I,N,P,ue,0,f,le,fe,pe,O)}function kne(e,t,n,r){let i=e.compareText;if(!(t in i))i[t]=[];else{let e=i[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])!X9(e.text))}var tw=class{constructor(e){this.layoutVertexArray=new M6,this.indexArray=new z6,this.programConfigurations=e,this.segments=new W6,this.dynamicLayoutVertexArray=new N6,this.opacityVertexArray=new P6,this.hasVisibleVertices=!1,this.placedSymbolArray=new f6}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,t,n,r){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,f9.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,p9.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,jne,!0),this.opacityVertexBuffer.itemSize=1),(n||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}};Y(`SymbolBuffers`,tw);var nw=class{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new W6,this.collisionVertexArray=new L6}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,m9.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};Y(`CollisionBuffers`,nw);var rw=class{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!0,this.hasRTLText=!1,this.hasCursiveText=!1,this.maxHeightOffset=0,this.sortKeyRanges=[],this.collisionCircleArray=[],this.maxGlyphs=65535;let t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=SC(this.zoom,t[`text-size`]),this.iconSizeData=SC(this.zoom,t[`icon-size`]);let n=this.layers[0].layout,r=n.get(`symbol-sort-key`),i=n.get(`symbol-z-order`);this.canOverlap=QC(n,`text-overlap`,`text-allow-overlap`)!==`never`||QC(n,`icon-overlap`,`icon-allow-overlap`)!==`never`||n.get(`text-ignore-placement`)||n.get(`icon-ignore-placement`),this.sortFeaturesByKey=i!==`viewport-y`&&!r.isConstant();let a=i===`viewport-y`||i===`auto`&&!this.sortFeaturesByKey;this.sortFeaturesByY=a&&this.canOverlap,n.get(`symbol-placement`)===`point`&&(this.writingModes=n.get(`text-writing-mode`).map(e=>US[e])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID}createArrays(){this.text=new tw(new bb(this.layers,this.zoom,e=>e.startsWith(`text`))),this.icon=new tw(new bb(this.layers,this.zoom,e=>e.startsWith(`icon`))),this.glyphOffsetArray=new h6,this.lineVertexArray=new g6,this.symbolInstances=new m6,this.textAnchorOffsets=new v6}calculateGlyphDependencies(e,t,n,r){let i=fS.fromFeature(e,n,!1),a=i.graphemes();for(let e=0;e0)&&(a.value.kind!==`constant`||a.value.value.length>0),l=s.value.kind!==`constant`||!!s.value.value||Object.keys(s.parameters).length>0,u=i.get(`symbol-sort-key`),d=i.get(`symbol-placement`)===`point`;if(this.features=[],!c&&!l)return;let f=t.iconDependencies,p=t.glyphDependencies,m=t.availableImages,h=new F4(this.zoom),g=i.get(`text-keep-upright`);for(let{feature:t,id:o,index:s,sourceLayerIndex:_}of e){let{needGeometry:e,needCamera:v}=r._featureFilter,y=Db(t,e);if(!v&&!r._featureFilter.filter(h,y,n)||(e||(y.geometry=Eb(t)),d&&t.type===1&&Pne(y.geometry)))continue;let b;if(c){let e=r.getValueAndResolveTokens(`text-field`,y,n,m),t=H1.factory(e);this.hasRTLText||=Mne(t),this.hasCursiveText||=Nne(t),b=P9(t,r,y)}let x;if(l){let e=r.getValueAndResolveTokens(`icon-image`,y,n,m);x=e instanceof Y1?e:Y1.fromString(e)}if(!b&&!x)continue;let S=this.sortFeaturesByKey?u.evaluate(y,{},n):void 0,C={id:o,text:b,icon:x,index:s,sourceLayerIndex:_,geometry:y.geometry,properties:t.properties,type:p7.types[t.type],sortKey:S};if(this.features.push(C),x&&(f[x.name]=!0),b){let e=a.evaluate(y,{},n).join(`,`),t=i.get(`text-rotation-alignment`)!==`viewport`&&i.get(`symbol-placement`)!==`point`;this.allowVerticalPlacement=this.writingModes?.includes(2);let r=(t&&g||this.allowVerticalPlacement)&&Y9(b.toString());this.calculateGlyphDependencies(b,p,e,r);for(let e of b.sections)e.image&&(f[e.image.name]=!0)}}i.get(`symbol-placement`)===`line`&&(this.features=B9(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:n}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:n}))}addFeatures({options:e,canonical:t,glyphMap:n,glyphPositions:r,iconMap:i,iconPositions:a,showCollisionBoxes:o}){Tne({bucket:this,glyphMap:n,glyphPositions:r,imageMap:i,imagePositions:a,showCollisionBoxes:o,canonical:t,subdivisionGranularity:e.subdivisionGranularity,hasPromoteId:e.featureIndex.promoteId!=null})}isEmpty(){return this.symbolInstances.length===0}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){let n=this.lineVertexArray.length;if(e.segment!==void 0){let n=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]),i={};for(let r=e.segment+1;r=0;n--)i[n]={x:t[n].x,y:t[n].y,tileUnitDistanceFromAnchor:r},n>0&&(r+=t[n-1].dist(t[n]));for(let e=0;e0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){let n=e.placedSymbolArray.get(t),r=n.vertexStartIndex+n.numGlyphs*4;for(let t=n.vertexStartIndex;tr[e]-r[t]||i[t]-i[e]),a}addToSortKeyRanges(e,t){let n=this.sortKeyRanges[this.sortKeyRanges.length-1];n?.sortKey===t?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let e of this.symbolInstanceIndexes){let t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);let n=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let e=0;e=0&&n.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)}t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};function Pne(e){return e.every(e=>e.every(Mb))}Y(`SymbolBucket`,rw,{omit:[`layers`,`collisionBoxArray`,`features`,`compareText`]});function Fne(e,t){return t.replace(/{([^{}]+)}/g,(t,n)=>e&&n in e?String(e[n]):``)}var Ine,Lne=()=>Ine||=new X4({"symbol-placement":new X(K.layout_symbol[`symbol-placement`],`symbol-placement`),"symbol-spacing":new X(K.layout_symbol[`symbol-spacing`],`symbol-spacing`),"symbol-avoid-edges":new X(K.layout_symbol[`symbol-avoid-edges`],`symbol-avoid-edges`),"symbol-sort-key":new K4(K.layout_symbol[`symbol-sort-key`],`symbol-sort-key`),"symbol-z-order":new X(K.layout_symbol[`symbol-z-order`],`symbol-z-order`),"icon-allow-overlap":new X(K.layout_symbol[`icon-allow-overlap`],`icon-allow-overlap`),"icon-overlap":new X(K.layout_symbol[`icon-overlap`],`icon-overlap`),"icon-ignore-placement":new X(K.layout_symbol[`icon-ignore-placement`],`icon-ignore-placement`),"icon-optional":new X(K.layout_symbol[`icon-optional`],`icon-optional`),"icon-rotation-alignment":new K4(K.layout_symbol[`icon-rotation-alignment`],`icon-rotation-alignment`),"icon-size":new K4(K.layout_symbol[`icon-size`],`icon-size`),"icon-text-fit":new X(K.layout_symbol[`icon-text-fit`],`icon-text-fit`),"icon-text-fit-padding":new X(K.layout_symbol[`icon-text-fit-padding`],`icon-text-fit-padding`),"icon-image":new K4(K.layout_symbol[`icon-image`],`icon-image`),"icon-rotate":new K4(K.layout_symbol[`icon-rotate`],`icon-rotate`),"icon-padding":new K4(K.layout_symbol[`icon-padding`],`icon-padding`),"icon-keep-upright":new X(K.layout_symbol[`icon-keep-upright`],`icon-keep-upright`),"icon-offset":new K4(K.layout_symbol[`icon-offset`],`icon-offset`),"icon-anchor":new K4(K.layout_symbol[`icon-anchor`],`icon-anchor`),"icon-pitch-alignment":new X(K.layout_symbol[`icon-pitch-alignment`],`icon-pitch-alignment`),"text-pitch-alignment":new X(K.layout_symbol[`text-pitch-alignment`],`text-pitch-alignment`),"text-rotation-alignment":new X(K.layout_symbol[`text-rotation-alignment`],`text-rotation-alignment`),"text-field":new K4(K.layout_symbol[`text-field`],`text-field`),"text-font":new K4(K.layout_symbol[`text-font`],`text-font`),"text-size":new K4(K.layout_symbol[`text-size`],`text-size`),"text-max-width":new K4(K.layout_symbol[`text-max-width`],`text-max-width`),"text-line-height":new X(K.layout_symbol[`text-line-height`],`text-line-height`),"text-letter-spacing":new K4(K.layout_symbol[`text-letter-spacing`],`text-letter-spacing`),"text-justify":new K4(K.layout_symbol[`text-justify`],`text-justify`),"text-radial-offset":new K4(K.layout_symbol[`text-radial-offset`],`text-radial-offset`),"text-variable-anchor":new X(K.layout_symbol[`text-variable-anchor`],`text-variable-anchor`),"text-variable-anchor-offset":new K4(K.layout_symbol[`text-variable-anchor-offset`],`text-variable-anchor-offset`),"text-anchor":new K4(K.layout_symbol[`text-anchor`],`text-anchor`),"text-max-angle":new X(K.layout_symbol[`text-max-angle`],`text-max-angle`),"text-writing-mode":new X(K.layout_symbol[`text-writing-mode`],`text-writing-mode`),"text-rotate":new K4(K.layout_symbol[`text-rotate`],`text-rotate`),"text-padding":new X(K.layout_symbol[`text-padding`],`text-padding`),"text-keep-upright":new X(K.layout_symbol[`text-keep-upright`],`text-keep-upright`),"text-transform":new K4(K.layout_symbol[`text-transform`],`text-transform`),"text-offset":new K4(K.layout_symbol[`text-offset`],`text-offset`),"text-allow-overlap":new X(K.layout_symbol[`text-allow-overlap`],`text-allow-overlap`),"text-overlap":new X(K.layout_symbol[`text-overlap`],`text-overlap`),"text-ignore-placement":new X(K.layout_symbol[`text-ignore-placement`],`text-ignore-placement`),"text-optional":new X(K.layout_symbol[`text-optional`],`text-optional`),"symbol-height-offset":new K4(K.layout_symbol[`symbol-height-offset`],`symbol-height-offset`),"symbol-height-anchor":new X(K.layout_symbol[`symbol-height-anchor`],`symbol-height-anchor`)}),Rne,zne=()=>Rne||=new X4({"icon-opacity":new K4(K.paint_symbol[`icon-opacity`],`icon-opacity`),"icon-color":new K4(K.paint_symbol[`icon-color`],`icon-color`),"icon-halo-color":new K4(K.paint_symbol[`icon-halo-color`],`icon-halo-color`),"icon-halo-width":new K4(K.paint_symbol[`icon-halo-width`],`icon-halo-width`),"icon-halo-blur":new K4(K.paint_symbol[`icon-halo-blur`],`icon-halo-blur`),"icon-translate":new X(K.paint_symbol[`icon-translate`],`icon-translate`),"icon-translate-anchor":new X(K.paint_symbol[`icon-translate-anchor`],`icon-translate-anchor`),"text-opacity":new K4(K.paint_symbol[`text-opacity`],`text-opacity`),"text-color":new K4(K.paint_symbol[`text-color`],`text-color`,{runtimeType:O_,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new K4(K.paint_symbol[`text-halo-color`],`text-halo-color`),"text-halo-width":new K4(K.paint_symbol[`text-halo-width`],`text-halo-width`),"text-halo-blur":new K4(K.paint_symbol[`text-halo-blur`],`text-halo-blur`),"text-translate":new X(K.paint_symbol[`text-translate`],`text-translate`),"text-translate-anchor":new X(K.paint_symbol[`text-translate-anchor`],`text-translate-anchor`)}),iw={get paint(){return zne()},get layout(){return Lne()}},aw=class{constructor(e){if(e.property.overrides===void 0)throw Error(`overrides must be provided to instantiate FormatSectionOverride class`);this.type=e.property.overrides?e.property.overrides.runtimeType:T_,this.defaultValue=e}evaluate(e){if(e.formattedSection){let t=this.defaultValue.property.overrides;if(t?.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}};Y(`FormatSectionOverride`,aw,{omit:[`defaultValue`]});var ow=e=>e.type===`symbol`,sw=class e extends $4{constructor(e,t){super(e,iw,t)}recalculate(e,t){super.recalculate(e,t);let n=this.layout.get(`icon-rotation-alignment`);if((n.value.kind!==`constant`||n.value.value===`auto`)&&(this.layout._values[`icon-rotation-alignment`]=new H4(n.property,{kind:`constant`,value:this.layout.get(`symbol-placement`)===`point`?`viewport`:`map`},n.parameters)),this.layout.get(`text-rotation-alignment`)===`auto`&&(this.layout.get(`symbol-placement`)===`point`?this.layout._values[`text-rotation-alignment`]=`viewport`:this.layout._values[`text-rotation-alignment`]=`map`),this.layout.get(`text-pitch-alignment`)===`auto`&&(this.layout._values[`text-pitch-alignment`]=this.layout.get(`text-rotation-alignment`)===`map`?`map`:`viewport`),this.layout.get(`icon-pitch-alignment`)===`auto`&&(this.layout._values[`icon-pitch-alignment`]=this.layout.get(`icon-rotation-alignment`).constantOr(`viewport`)),this.layout.get(`symbol-placement`)===`point`){let e=this.layout.get(`text-writing-mode`);if(e){let t=[];for(let n of e)t.includes(n)||t.push(n);this.layout._values[`text-writing-mode`]=t}else this.layout._values[`text-writing-mode`]=[`horizontal`]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,n,r){let i=this.layout.get(e).evaluate(t,{},n,r),a=this._unevaluatedLayout._values[e];return!a.isDataDriven()&&!jy(a.value)&&i?Fne(t.properties,i):i}createBucket(e){return new rw(e)}queryRadius(){return 0}queryIntersectsFeature(){throw Error(`Should take a different path in FeatureIndex`)}_setPaintOverrides(){for(let t of iw.paint.overridableProperties){if(!e.hasPaintOverride(this.layout,t))continue;let n=this.paint.get(t),r=new Oy(new aw(n),`layers[${this.id}].paint.${n.property.name}`,n.property.specification),i=null;i=n.value.kind===`constant`||n.value.kind===`source`?new Ny(`source`,r):new Py(`composite`,r,n.value.zoomStops),this.paint._values[t]=new H4(n.property,i,n.parameters)}}_paintPropertyRequiresRelayout(t,n,r){return!this.layout||n.isDataDriven()||r.isDataDriven()?!1:e.hasPaintOverride(this.layout,t)}static hasPaintOverride(e,t){let n=e.get(`text-field`),r=iw.paint.properties[t],i=!1,a=e=>{for(let t of e)if(r.overrides?.hasOverride(t)){i=!0;return}};if(n.value.kind===`constant`&&n.value.value instanceof H1)a(n.value.value.sections);else if(n.value.kind===`source`||n.value.kind===`composite`){let e=t=>{if(!i){if(t instanceof t0&&$1(t.value)===P_){let e=t.value;a(e.sections)}else t instanceof X0?a(t.sections):t.eachChild(e)}},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}};function cw(e,t,n,r=1){let i=e.get(`icon-padding`).evaluate(t,{},n)?.values;return[i[0]*r,i[1]*r,i[2]*r,i[3]*r]}function lw(e,t){switch(e.type){case`circle`:return new bte(e,t);case`fill`:return new u7(e,t);case`fill-extrusion`:return new O7(e,t);case`heatmap`:return new B7(e,t);case`line`:return new u9(e,t);case`symbol`:return new sw(e,t);default:return null}}function uw(e,t){if(e.type===`custom`)return new M3(e,t);switch(e.type){case`background`:return new k3(e,t);case`color-relief`:return new w3(e,t);case`hillshade`:return new l3(e,t);case`raster`:return new i3(e,t);default:return lw(e,t)}}function dw(e){let t=[];if(typeof e==`string`)t.push({id:`default`,url:e});else if(e&&e.length>0){let n=[];for(let{id:r,url:i}of e){let e=`${r}${i}`;n.includes(e)||(n.push(e),t.push({id:r,url:i}))}}return t}function fw(e,t,n){try{let r=new URL(e);return r.pathname+=`${t}${n}`,r.toString()}catch{throw Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}async function pw(e,t,n,r){let i=dw(e),a=n>1?`@2x`:``,o={},s={};for(let{id:e,url:n}of i){o[e]=t_(await t.transformRequest(fw(n,a,`.json`),`SpriteJSON`),r);let i=await t.transformRequest(fw(n,a,`.png`),`SpriteImage`);s[e]=E4.getImage(i,r)}return await Promise.all([...Object.values(o),...Object.values(s)]),mw(o,s)}async function mw(e,t){let n={};for(let r in e){n[r]={};let i=(await t[r]).data;if(!i)throw Error(`Could not load sprite image for ${r}: the response is empty`);let a=Pg.getImageCanvasContext(i),o=(await e[r]).data;for(let e in o){let{width:t,height:i,x:s,y:c,sdf:l,pixelRatio:u,stretchX:d,stretchY:f,content:p,textFitWidth:m,textFitHeight:h}=o[e],g={width:t,height:i,x:s,y:c,context:a};n[r][e]={data:null,pixelRatio:u,sdf:l,stretchX:d,stretchY:f,content:p,textFitWidth:m,textFitHeight:h,spriteData:g}}}return n}var hw=class extends l_{constructor(){super(),this.images={},this.updateVersion=0,this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this._spriteImagesIds={},this._imagesIds=null,this._renderCallbacksDispatchedThisFrame={}}destroy(){for(let e of Object.keys(this.images))this.removeImage(e);this._spriteImagesIds={}}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){let t=this.images[e];if(t&&!t.data&&t.spriteData){let e=t.spriteData;t.data=new _3({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),t.spriteData=null}return t}addImage(e,t){if(this.images[e])throw Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t,this._imagesIds=null,t.isWebGLImage&&this.updateImage(e,t,!1))}_validate(e,t){let n=!0,r=t.data||t.spriteData;return this._validateStretch(t.stretchX,r?.width)||(this.fire(new c_(Error(`Image "${e}" has invalid "stretchX" value`))),n=!1),this._validateStretch(t.stretchY,r?.height)||(this.fire(new c_(Error(`Image "${e}" has invalid "stretchY" value`))),n=!1),this._validateContent(t.content,t)||(this.fire(new c_(Error(`Image "${e}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let n=0;for(let r of e){if(r[0]=e[1]}updateImage(e,t,n=!0){let r=this.images[e];if(n){let e=r.data||r.spriteData;if(e.width!==t.data.width||e.height!==t.data.height)throw Error(`size mismatch between old image (${e.width}x${e.height}) and new image (${t.data.width}x${t.data.height}).`)}t.version=(r.version??0)+1,this.images[e]=t,this.updateVersion++}removeImage(e){let t=this.images[e];t&&(delete this.images[e],this._imagesIds=null,t.userImage?.onRemove&&t.userImage.onRemove())}listImages(){return this._imagesIds??=Object.keys(this.images),this._imagesIds}_getSpriteImageId(e,t){return e==="default"?t:`${e}:${t}`}setSpriteImages(e,t){let n=this._spriteImagesIds[e]??[],r=[];for(let n in t){let i=this._getSpriteImageId(e,n);r.push(i),i in this.images?this.updateImage(i,t[n],!1):this.addImage(i,t[n])}let i=new Set(r),a=n.filter(e=>!i.has(e));for(let e of a)this.removeImage(e);return this._spriteImagesIds[e]=r,{loaded:r,removed:a}}removeSpriteImages(e){let t=this._spriteImagesIds[e]??[];for(let e of t)this.removeImage(e);return delete this._spriteImagesIds[e],t}removeAllSpriteImages(){let e=Object.values(this._spriteImagesIds).flat();for(let t of e)this.removeImage(t);return this._spriteImagesIds={},e}setMissingImageResolver(e){this.missingImageResolver=e}getImages(e){return new Promise((t,n)=>{let r=!0;if(!this.isLoaded())for(let t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}async _getImagesForIds(e){let t=new Set(e.filter(e=>!this.getImage(e))),n=this.missingImageResolver;n&&await Promise.allSettled(Array.from(t,e=>n(e)));let r={};for(let n of e){let e=this.getImage(n);e&&(t.delete(n),r[n]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:!!e.userImage?.render,isWebGLImage:e.isWebGLImage})}for(let e of t)this.fire(new Jee({id:e})),ig(`Image "${e}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return r}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let t of e){if(this._renderCallbacksDispatchedThisFrame[t])continue;this._renderCallbacksDispatchedThisFrame[t]=!0;let e=this.getImage(t);e||ig(`Image with ID: "${t}" was not found`),zS(e)&&this.updateImage(t,e)}}cloneImages(){let e={};for(let t in this.images){let n=this.images[t];e[t]={...n,data:n.data?n.data.clone():null}}return e}},gw=class{constructor(e){this._imageManager=e,this._entries={},this._image=new _3({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&=(this._texture.destroy(),null),this._entries={},this._image=new _3({width:1,height:1}),this._dirty=!0}getPixelSize(){let{width:e,height:t}=this._image;return{width:e,height:t}}getPattern(e){let t=this._imageManager.getImage(e);if(!t)return null;let n=this._entries[e];if(n?.image!==t){let n={w:t.data.width+2,h:t.data.height+2,x:0,y:0};this._entries[e]={bin:n,position:new VS(n,t),image:t}}else if(n.position.version!==t.version)n.position.version=t.version;else return n.position;return this._update(),this._entries[e].position}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let t=this.getPattern(e.from.toString()),n=this.getPattern(e.to.toString());return!t||!n}bind(e){let t=e.gl;this._texture?this._dirty&&=(this._texture.update(this._image),!1):(this._texture=new b3(e,this._image,t.RGBA),this._dirty=!1),this._texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_update(){for(let e in this._entries)this._imageManager.getImage(e)||delete this._entries[e];let e=[];for(let t in this._entries)e.push(this._entries[t].bin);let{w:t,h:n}=BS(e),r=this._image;r.resize({width:t||1,height:n||1});for(let e in this._entries){let{bin:t}=this._entries[e],n=t.x+1,i=t.y+1,a=this._entries[e].image.data,o=a.width,s=a.height;_3.copy(a,r,{x:0,y:0},{x:n,y:i},{width:o,height:s}),_3.copy(a,r,{x:0,y:s-1},{x:n,y:i-1},{width:o,height:1}),_3.copy(a,r,{x:0,y:0},{x:n,y:i+s},{width:o,height:1}),_3.copy(a,r,{x:o-1,y:0},{x:n-1,y:i},{width:1,height:s}),_3.copy(a,r,{x:0,y:0},{x:n+o,y:i},{width:1,height:s})}this._dirty=!0}},_w=1114111,vw={start:0,end:_w},yw=0;function bw(e){let t=/^u\+([0-9a-f]*)(\?+)$/i.exec(e);if(t){let[,e,n]=t;return e.length+n.length>6?null:xw(parseInt(`${e}${`0`.repeat(n.length)}`,16),parseInt(`${e}${`f`.repeat(n.length)}`,16))}let n=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(e);if(!n)return null;let r=parseInt(n[1],16);return xw(r,n[2]===void 0?r:parseInt(n[2],16))}function xw(e,t){return e>t||e>_w?null:{start:e,end:Math.min(t,_w)}}function Sw(e,t){return e.ranges.some(({start:e,end:n})=>t>=e&&t<=n)}var Cw=class{constructor(e){this.requestManager=e,this._faces={},this._registered=new Set}setFontFaces(e){this._unregisterAll(),this._faces={};for(let[t,n]of Object.entries(e??{})){let e=Array.isArray(n)?n:[n];this._faces[t]=e.map(e=>this._declareFontFace(t,e)).filter(e=>e!==null)}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(e,t,n){for(let r of e.split(`,`))for(let e of this._faces[r.trim()]??[]){if(!Sw(e,t))continue;e.loads.normal??=this._loadFontFace(e,`normal`);let r=e.data,i=await e.loads.normal;if(i)return n===`normal`?i:(e.loads[n]??=this._loadFontFace(e,n,r),e.loads[n])}return null}_declareFontFace(e,t){let n=typeof t==`string`?{url:t}:t;if(typeof n?.url!=`string`)return ig(`Ignoring the font face declared for "${e}": it has no URL.`),null;let r=`maplibre-gl-font-face-${yw++}`,i=n[`unicode-range`];if(!i?.length)return{url:n.url,ranges:[vw],family:r,loads:{}};let a=[];for(let e of i){let t=bw(e);t?a.push(t):ig(`Ignoring the unicode range "${e}" of the font face at ${n.url}: it is not a valid range.`)}return a.length?{url:n.url,ranges:a,family:r,loads:{}}:null}async _loadFontFace(e,t,n){let r=t===`normal`?`font face`:`font face with "${t}" enabled`;if(typeof FontFace>`u`||typeof document>`u`||!document.fonts)return ig(`Ignoring the ${r} at ${e.url}: this environment has no CSS Font Loading API.`),null;let i;try{n||=(e.data??=this._downloadFontFile(e.url),e.data);let r=t===`normal`?e.family:`${e.family}-${t}`;return i=new FontFace(r,await n,{featureSettings:t===`normal`?`normal`:`"${t}" 1`}),!Object.values(this._faces).some(t=>t.includes(e))||t!==`normal`&&(!i.featureSettings||i.featureSettings===`normal`)?null:(document.fonts.add(i),this._registered.add(i),await i.load(),this._registered.has(i)?r:null)}catch(t){return i&&this._unregister(i),ig(`Ignoring the ${r} at ${e.url}: ${Ch(t).message}`),null}finally{e.data===n&&delete e.data}}async _downloadFontFile(e){let t=await n_(await this.requestManager.transformRequest(e,`Glyphs`),new AbortController);if(!t?.data)throw Error(`the response was empty for the font file at ${e}`);return t.data}_unregister(e){document.fonts?.delete(e),this._registered.delete(e)}_unregisterAll(){for(let e of Object.values(this._faces))for(let t of e)delete t.data;for(let e of this._registered)document.fonts?.delete(e);this._registered.clear()}destroy(){this._unregisterAll(),this._faces={}}},ww=1e20,Tw=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-(e/255)**(1/2.2);Tw[e]=t*Math.abs(t)}Tw[255]=-1e20;var Ew=class{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i=`sans-serif`,fontWeight:a=`normal`,fontStyle:o=`normal`,lang:s=null}={}){t=this.buffer=Math.round(t),this.radius=n,this.cutoff=r,this.lang=s;let c=this.size=Math.ceil(e)+t*4,l=this._createCanvas(c),u=this.ctx=l.getContext(`2d`,{willReadFrequently:!0});u.font=`${o} ${a} ${e}px ${i}`,u.textBaseline=`alphabetic`,u.textAlign=`left`,u.fillStyle=`black`,s&&(u.lang=s);let d=(this.maxGlyphDim=c-t)+2*t;this.gridOuter=new Float64Array(d*d),this.gridInner=new Float64Array(d*d),this.f=new Float64Array(d),this.z=new Float64Array(d+1),this.v=new Uint16Array(d)}_createCanvas(e){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(e,e);let t=document.createElement(`canvas`);return t.width=t.height=e,t}draw(e){let{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:a}=this.ctx.measureText(e),o=Math.ceil(n),s=Math.floor(-i),c=Math.max(0,Math.min(this.maxGlyphDim,Math.ceil(a)-s)),l=Math.max(0,Math.min(this.maxGlyphDim,o+Math.ceil(r))),u=c+2*this.buffer,d=l+2*this.buffer,f=u*d,p=new Uint8ClampedArray(f),m={data:p,width:u,height:d,glyphWidth:c,glyphHeight:l,glyphTop:o,glyphLeft:s,glyphAdvance:t};if(c===0||l===0)return m;let{ctx:h,buffer:g,gridInner:_,gridOuter:v}=this;h.clearRect(g,g,c,l),h.fillText(e,g-s,g+o);let y=h.getImageData(g,g,c,l);v.fill(ww,0,f),_.fill(0,0,f);let b=3;for(let e=0;e-1);c++,a[c]=s,o[c]=u,o[c+1]=ww}for(let s=0,c=0;s{let n=new Ew(e);return n.buffer=t,n},Aw={vertical:`vert`};function jw(e,t){return e.bitmap.width===t.bitmap.width&&e.bitmap.height===t.bitmap.height&&e.metrics.width===t.metrics.width&&e.metrics.height===t.metrics.height&&e.metrics.left===t.metrics.left&&e.metrics.top===t.metrics.top&&e.metrics.advance===t.metrics.advance&&e.bitmap.data.every((e,n)=>e===t.bitmap.data[n])}var Mw=class{constructor(e,t,n,r=kw){this.rasterizedGlyphs=new WeakMap,this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=n,this.fontFaceManager=new Cw(e),this.createRasterizer=r}setURL(e){this.url=e}setFontFaces(e){this.fontFaceManager.setFontFaces(e),this.entries={}}async getGlyphs(e){let t=[],n=this.fontFaceManager.hasFontFaces();for(let r in e)for(let i in e[r])if(!Aw[i]||n)for(let n of e[r][i])t.push(this._getAndCacheGlyphsPromise(r,n,i));let r=await Promise.all(t),i={};for(let{stack:e,id:t,variant:n,glyph:a}of r)i[e]||={},i[e][n]||={},i[e][n][t]=a&&{id:a.id,bitmap:a.bitmap.clone(),metrics:a.metrics};return i}async _getAndCacheGlyphsPromise(e,t,n){this.entries[e]??={glyphs:{default:{}},requests:{}};let r=this.entries[e],i=r.glyphs[n]||={},a=i[t];if(a!==void 0)return{stack:e,id:t,variant:n,glyph:a};if(n!=="default"){let o=Aw[n];return a=o?await this._drawAlternateGlyph(r,e,t,o):null,i[t]=a,{stack:e,id:t,variant:n,glyph:a}}let o=t.codePointAt(0),s=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(e,o,`normal`):null;return s?(a=await this._drawGlyph(r,e,t,s),i[t]=a,{stack:e,id:t,variant:n,glyph:a}):!this.url||K9(t)||this._charUsesLocalIdeographFontFamily(o)||x9(o)?(a=await this._drawGlyph(r,e,t),i[t]=a,{stack:e,id:t,variant:n,glyph:a}):{...await this._downloadAndCacheRangePromise(e,t),variant:n}}async _drawAlternateGlyph(e,t,n,r){let i=await this._getFontFaceTinySDF(e,t,n,r);if(!i||this.entries[t]!==e)return null;let a=i.draw(n);if(!a.glyphWidth||!a.glyphHeight)return null;let o=await this._getFontFaceTinySDF(e,t,n,`normal`);if(!o||this.entries[t]!==e)return null;let s=this._createGlyph(n,a);return jw(this._getRasterizedGlyph(o,n),s)?null:s}async _downloadAndCacheRangePromise(e,t){let n=t.codePointAt(0),r=this.entries[e],i=Math.floor(n/256);r.requests[i]||=this._loadGlyphRange(e,i);try{let a=(await r.requests[i])[n]||null;return r.glyphs.default[t]=a,{stack:e,id:t,glyph:a}}catch(a){let o=await this._drawGlyph(r,e,t);return r.glyphs.default[t]=o,this._warnOnMissingGlyphRange(o,i,n,Ch(a)),{stack:e,id:t,glyph:o}}}async _loadGlyphRange(e,t){let n=t*256,r=n+255,i=await this.requestManager.transformRequest(this.url.replace(`{fontstack}`,e).replace(`{range}`,`${n}-${r}`),`Glyphs`),a=await n_(i,new AbortController);if(!a?.data)throw Error(`Could not load glyph range. range: ${t}, ${n}-${r}`);let o;try{o=LS(a.data)}catch(e){throw Error(`Unable to parse the glyph range at ${i.url}, got error: ${Ch(e).message}`)}let s={};for(let e of o)s[e.id]=e;return s}_warnOnMissingGlyphRange(e,t,n,r){let i=t*256;ig(`Unable to load glyph range ${t}, ${i}-${i+255}. Rendering codepoint U+${n.toString(16).padStart(4,`0`).toUpperCase()} locally instead. ${r}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&S9(e)}async _drawGlyph(e,t,n,r){let i=await this._getTinySDF(e,t,n,r);return this._getRasterizedGlyph(i,n)}_getRasterizedGlyph(e,t){let n=this.rasterizedGlyphs.get(e);return n||(n={},this.rasterizedGlyphs.set(e,n)),n[t]??=this._createGlyph(t,e.draw(t)),n[t]}_createGlyph(e,t){let n=/^\p{gc=Cf}+$/u.test(e);return{id:e.codePointAt(0),bitmap:new g3({width:t.width||60,height:t.height||60},t.data),metrics:{width:n?0:t.glyphWidth/2||24,height:t.glyphHeight/2||24,left:t.glyphLeft/2+.5||0,top:t.glyphTop/2-27.5||-8,advance:n?0:t.glyphAdvance/2||24,isDoubleResolution:!0}}}async _getFontFaceTinySDF(e,t,n,r){if(this.entries[t]!==e)return null;let i=await this.fontFaceManager.getFontFamily(t,n.codePointAt(0),r);return!i||this.entries[t]!==e?null:this._getTinySDF(e,t,n,i)}_getTinySDF(e,t,n,r){let i=K9(n);if(r){let t=i?`clusterTinySDFs`:`fontFaceTinySDFs`;return e[t]??={},e[t][r]||=this._createTinySDF(r,!1,i?3:1),e[t][r]}let a=this._charUsesLocalIdeographFontFamily(n.codePointAt(0)),o=a?`${t},${this.localIdeographFontFamily}`:t;if(i)return e.clusterTinySDFs??={},e.clusterTinySDFs[o]||=this._createTinySDF(o,!0,3),e.clusterTinySDFs[o];let s=a?`ideographTinySDF`:`tinySDF`;return e[s]||=this._createTinySDF(o),e[s]}async _createTinySDF(e,t=!0,n=1){let r=e?e.split(`,`):[];r.push(`sans-serif`);let i=r.map(e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(`,`),a=t?this._fontWeight(r[0]):void 0,o=t?this._fontStyle(r[0]):`normal`;if(typeof document<`u`&&document.fonts?.load)try{await document.fonts.load(`${o} ${a||`normal`} 48px ${i}`)}catch(e){ig(`Failed to load font "${i}": ${Ch(e).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(n-1)/4)),radius:16,cutoff:.25,fontFamily:i,fontWeight:a,fontStyle:o,lang:this.lang},6)}_fontStyle(e){return/italic/i.test(e)?`italic`:/oblique/i.test(e)?`oblique`:`normal`}_fontWeight(e){let t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950},n;for(let[r,i]of Object.entries(t))RegExp(`\\b${r}\\b`,`i`).test(e)&&(n=`${i}`);return n}destroy(){for(let e in this.entries){let t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.fontFaceTinySDFs={},t.glyphs={default:{}},t.requests={}}this.entries={},this.fontFaceManager.destroy()}},Nw=X2,Pw=new Set(Object.keys(K).filter(e=>e.startsWith(`source_`)).map(e=>e.slice(7).replaceAll(`_`,`-`)));function Fw(e){return Object.entries(e.sources??{}).filter(([,e])=>!Pw.has(e.type)).map(([e])=>`sources.${e}`)}function Iw(e,t){let n=Fw(t);return Lw(e,Nw(t).filter(({message:e})=>!n.some(t=>e.startsWith(`${t}:`)||e.startsWith(`${t}.`))))}function Lw(e,t){let n=!1;for(let r of t)r.severity===`warning`?ig(r.message):(e.fire(new c_(Error(r.message))),n=!0);return n}function Rw(e,t,n,r){return r?.validate!==!1&&Lw(e,t({styleSpec:K,...n}))}var zw,Bw=()=>zw||=new X4({anchor:new X(K.light.anchor,`anchor`),position:new X(K.light.position,`position`),color:new X(K.light.color,`color`),intensity:new X(K.light.intensity,`intensity`)}),Vw=class extends l_{constructor(e,t){super(),this._transitionable=new R4(Bw(),`light`,t),this.setLight(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new F4(0))}getLight(){return this._transitionable.serialize()}getEvaluated(){return{anchor:this.properties.get(`anchor`),position:this.properties.get(`position`),color:this.properties.get(`color`),intensity:this.properties.get(`intensity`)}}setLight(e,t={}){return!this._validate(Nw.light,e,t)&&(this._transitionable.setValues(e),!0)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}applyGlobalStateChange(e,t,n){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,n)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,n){return Rw(this,e,{value:t},n)}},Hw,Uw=()=>Hw||=new X4({"sky-color":new X(K.sky[`sky-color`],`sky-color`),"horizon-color":new X(K.sky[`horizon-color`],`horizon-color`),"fog-color":new X(K.sky[`fog-color`],`fog-color`),"fog-ground-blend":new X(K.sky[`fog-ground-blend`],`fog-ground-blend`),"horizon-fog-blend":new X(K.sky[`horizon-fog-blend`],`horizon-fog-blend`),"sky-horizon-blend":new X(K.sky[`sky-horizon-blend`],`sky-horizon-blend`),"atmosphere-blend":new X(K.sky[`atmosphere-blend`],`atmosphere-blend`)}),Ww=class extends l_{constructor(e,t){super(),this._transitionable=new R4(Uw(),`sky`,t),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new F4(0))}setSky(e,t={}){return!this._validate(Nw.sky,e,t)&&(e||={"sky-color":`transparent`,"horizon-color":`transparent`,"fog-color":`transparent`,"fog-ground-blend":1,"atmosphere-blend":0},this._transitionable.setValues(e),!0)}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}applyGlobalStateChange(e,t,n){this._transitioning=this._transitionable.applyGlobalStateChange(e,t,this._transitioning,n)}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,n={}){return Rw(this,e,{value:t},n)}getEvaluated(){return{"sky-color":this.properties.get(`sky-color`),"horizon-color":this.properties.get(`horizon-color`),"fog-color":this.properties.get(`fog-color`),"fog-ground-blend":this.properties.get(`fog-ground-blend`),"horizon-fog-blend":this.properties.get(`horizon-fog-blend`),"sky-horizon-blend":this.properties.get(`sky-horizon-blend`),"atmosphere-blend":this.properties.get(`atmosphere-blend`)}}};function Gw(e){return e<60?0:e<70?(e-60)/10:1}var Kw=class{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,t){let n=e.join(`,`)+String(t);return this.dashEntry[n]||=this.addDash(e,t),this.dashEntry[n]}getDashRanges(e,t,n){let r=e.length%2==1,i=[],a=r?-e[e.length-1]*n:0,o=e[0]*n,s=!0;i.push({left:a,right:o,isDash:s,zeroLength:e[0]===0});let c=e[0];for(let t=1;t1&&(s=e[++o]);let c=Math.abs(i-s.left),l=Math.abs(i-s.right),u=Math.min(c,l),d,f=t/n*(r+1);if(s.isDash){let e=r-Math.abs(f);d=Math.sqrt(u*u+e*e)}else d=r-Math.sqrt(u*u+f*f);this.data[a+i]=Math.max(0,Math.min(255,d+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){let n=e[t],r=e[t+1];n.zeroLength?e.splice(t,1):r?.isDash===n.isDash&&(r.left=n.left,e.splice(t,1))}let t=e[0],n=e[e.length-1];t.isDash===n.isDash&&(t.left=n.left-this.width,n.right=t.right+this.width);let r=this.width*this.nextRow,i=0,a=e[i];for(let t=0;t1&&(a=e[++i]);let n=Math.abs(t-a.left),o=Math.abs(t-a.right),s=Math.min(n,o),c=a.isDash?s:-s;this.data[r+t]=Math.max(0,Math.min(255,c+128))}}addDash(e,t){let n=t?7:0,r=2*n+1;if(this.nextRow+r>this.height)return ig(`LineAtlas out of space`),null;let i=0;for(let t of e)i+=t;if(i!==0){let r=this.width/i,a=this.getDashRanges(e,this.width,r);t?this.addRoundDash(a,r,n):this.addRegularDash(a)}let a={y:this.nextRow+n,height:2*n,width:i};return this.nextRow+=r,this.dirty=!0,a}bind(e){let t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}},qw=class extends l_{constructor(e,t){super(),this.workerPool=e,this.actors=[],this.currentActor=0,this.id=t,this.removed=!1,this.workerErrorSubscriptions=[],this.actorsPromise=this.initActors(t)}async initActors(e){let t=await this.workerPool.acquire(e);if(this.removed)return[];let{actors:n,workerErrorSubscriptions:r}=p4(t,e,this);if(this.actors=n,this.workerErrorSubscriptions=r,!this.actors.length)throw Error(`No actors found`);return this.actors}async broadcast(e,t){let n=await this.actorsPromise;return Promise.all(n.map(n=>n.sendAsync({type:e,data:t})))}async getActor(){let e=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%e.length,e[this.currentActor]}async waitForInitComplete(){this.actors.length===0&&await this.actorsPromise}getReadyActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.removed=!0;for(let e of this.actors)e.remove();for(let e of this.workerErrorSubscriptions)e.unsubscribe();this.actors=[],this.workerErrorSubscriptions=[],this.setEventedParent(null),e&&this.workerPool.release(this.id)}async registerMessageHandler(e,t){let n=await this.actorsPromise;for(let r of n)r.registerMessageHandler(e,t)}async unregisterMessageHandler(e){let t=await this.actorsPromise;for(let n of t)n.unregisterMessageHandler(e)}};function Jw(e,t,n){if(e)for(let r of e){let e=t[r];if(e?.source===n&&e.type===`fill-extrusion`)return!0}else for(let e in t){let r=t[e];if(r.source===n&&r.type===`fill-extrusion`)return!0}return!1}function Yw(e,t,n,r,i,a,o,s){let c=Jw(i?.layers??null,t,e.id),l=Q(a).maxPitchScaleFactor(a),u=e.tilesIn(r,l,c,a,o);u.sort(Qw);let d=[];for(let r of u)d.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,n,e.getState(),r.queryGeometry,r.cameraQueryGeometry,r.scale,i,a,o,l,s?(e,t)=>s(r.tileID,e,t):void 0)});return eT($w(d),e)}function Xw(e,t,n,r,i,a,o,s){let c={},l=a.queryRenderedSymbols(r),u=[];for(let e of Object.keys(l).map(Number))u.push(o[e]);u.sort(Qw);for(let n of u){let r=n.featureIndex.lookupSymbolFeatures(l[n.bucketInstanceId],t,n.bucketIndex,n.sourceLayerIndex,{filterSpec:i.filter,globalState:i.globalState,worldCoordinateHelper:s},i.layers,i.availableImages,e);for(let e in r){c[e]||=[];let t=r[e];t.sort((e,t)=>{let r=n.featureSortOrder;if(r){let n=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-n}return t.featureIndex-e.featureIndex});for(let n of t)c[e].push(n)}}return tT(c,e,n)}function Zw(e,t){let n=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],i={};for(let e of n){let n=e.tileID.canonical.key;i[n]||(i[n]=!0,e.querySourceFeatures(r,t))}return r}function Qw(e,t){let n=e.tileID,r=t.tileID;return n.overscaledZ-r.overscaledZ||n.canonical.y-r.canonical.y||n.wrap-r.wrap||n.canonical.x-r.canonical.x}function $w(e){let t={},n={};for(let{queryResults:r,wrappedTileID:i}of e){n[i]||={};let e=n[i];for(let n in r){let i=r[n];e[n]||={};let a=e[n];t[n]||=[];for(let e of i)a[e.featureIndex]||(a[e.featureIndex]=!0,t[n].push(e))}}return t}function eT(e,t){for(let n in e)for(let r of e[n])nT(r,t);return e}function tT(e,t,n){for(let r in e)for(let i of e[r])nT(i,n[t[r].source]);return e}function nT(e,t){let n=e.feature,r=t.getFeatureState(n.layer[`source-layer`],n.id);n.source=n.layer.source,n.layer[`source-layer`]&&(n.sourceLayer=n.layer[`source-layer`]),n.state=r}async function rT(e,t,n,r){let i=e;if(e.url?i=(await t_(await t.transformRequest(e.url,`Source`),n)).data:await Pg.frameAsync(n,r),!i)return null;let a=e,o=i,s={tiles:a.tiles??o.tiles,minzoom:a.minzoom??o.minzoom,maxzoom:a.maxzoom??o.maxzoom,attribution:a.attribution??o.attribution,bounds:a.bounds??o.bounds,scheme:a.scheme??o.scheme,tileSize:a.tileSize??o.tileSize,encoding:a.encoding??o.encoding,sparse:a.sparse??o.sparse};return iT(s),`vector_layers`in i&&i.vector_layers&&(s.vectorLayerIds=i.vector_layers.map(e=>e.id)),s}function iT({minzoom:e,maxzoom:t,tileSize:n}){for(let[n,r]of Object.entries({minzoom:e,maxzoom:t}))if(r!==void 0&&!Number.isFinite(r))throw Error(`${n} must be a finite number, got ${JSON.stringify(r)}`);if(n!==void 0&&!(Number.isFinite(n)&&n>=16))throw Error(`tileSize must be a number of at least 16, got ${JSON.stringify(n)}`)}var aT=class{constructor(e,t,n,r){this.bounds=y8.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=n||24,this._worldBox=M8(r,this.bounds.getWest(),this.bounds.getSouth(),this.bounds.getEast(),this.bounds.getNorth())}validateBounds(e){return!Array.isArray(e)||e.length!==4?[-180,-90,180,90]:[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]}contains(e){let t=2**e.z,n={minX:Math.floor(this._worldBox.minX*t),minY:Math.floor(this._worldBox.minY*t),maxX:Math.ceil(this._worldBox.maxX*t),maxY:Math.ceil(this._worldBox.maxY*t)};return e.x>=n.minX&&e.x=n.minY&&e.y{this.tiles=e,this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return{...this._options}}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme,this.map.style.projection.worldCoordinateHelper.tileMatrixSet),n={request:await this.map._requestManager.transformRequest(t,`Tile`),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:await this._getOverzoomParameters(e),etag:e.etag};if(this._setAcceptHeader(n.request),n.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete(),e.aborted)return;let r=`RT`;if(!e.actor||e.state===`expired`)e.actor=this.dispatcher.getReadyActor(),r=`LT`;else if(e.state===`loading`)return new Promise((t,n)=>{e.reloadPromise={resolve:t,reject:n}});e.abortController=new AbortController;let i;try{i=await e.actor.sendAsync({type:r,data:n},e.abortController)}catch(t){if(delete e.abortController,e.aborted||kg(t))return;if(t&&t.status!==404)throw t;i=null}if(delete e.abortController,e.aborted)return;let a={};if(i?.resourceTiming&&(e.resourceTiming=i.resourceTiming),!(i===null&&this.sparse&&(i=await this._loadFromNearestAncestor(e,n),e.aborted)))return this._afterTileLoadWorkerResponse(e,i),i?.etagUnmodified&&(a.unmodified=!0),this._reloadIfRequestedWhileLoading(e),a}async _loadFromNearestAncestor(e,t){let n=Math.min(e.tileID.canonical.z,this.maxzoom),r=Math.max(n-oj.maxUnderzooming,this.minzoom);for(let i=n-1;i>=r;i--){let n=e.tileID.scaledTo(i).canonical;t.overzoomParameters={maxZoomTileID:n,overzoomRequest:await this._getTileRequest(n)},e.abortController=new AbortController;try{let n=await e.actor.sendAsync({type:`LT`,data:t},e.abortController);return delete e.abortController,n}catch(t){if(delete e.abortController,e.aborted||kg(t))return null;if(t&&t.status!==404)throw t}}return null}async _getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;let t=e.tileID.scaledTo(this.maxzoom).canonical;return{maxZoomTileID:t,overzoomRequest:await this._getTileRequest(t)}}async _getTileRequest(e){let t=e.url(this.tiles,this.map.getPixelRatio(),this.scheme,this.map.style.projection.worldCoordinateHelper.tileMatrixSet),n=await this.map._requestManager.transformRequest(t,`Tile`);return this._setAcceptHeader(n),n}_setAcceptHeader(e){this.encoding===`mlt`&&(e.headers??={},e.headers.Accept??=`application/vnd.maplibre-tile`)}_afterTileLoadWorkerResponse(e,t){t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=t?.etag,e.loadVectorData(t,this.map.style)}_reloadIfRequestedWhileLoading(e){if(e.reloadPromise){let t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&await e.actor.sendAsync({type:`AT`,data:{uid:e.uid,type:this.type,source:this.id}})}async unloadTile(e){e.unloadVectorData(),e.actor&&await this.dispatcher.broadcast(`RMT`,{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}},sT=class extends l_{constructor(e,t,n,r){super(),this.id=e,this.dispatcher=n,this.setEventedParent(r),this.type=`raster`,this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme=`xyz`,this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options={type:`raster`,...t},this.url=t.url,`scheme`in t&&(this.scheme=t.scheme),this.tileSize=t.tileSize??this.tileSize}async load(e=!1){this._loaded=!1,this.fire(new j4(`dataloading`)),this._tileJSONRequest=new AbortController;try{let t=await rT(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,t&&(this._applyTileJSON(t),t.bounds&&(this.tileBounds=new aT(t.bounds,this.minzoom,this.maxzoom,this.map.style.projection.worldCoordinateHelper)),this.fire(new j4(`data`,{sourceDataType:`metadata`})),this.fire(new j4(`data`,{sourceDataType:`content`,sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,kg(e)||this.fire(new c_(Ch(e)))}}_applyTileJSON(e){this.tiles=e.tiles??this.tiles,this.minzoom=e.minzoom??this.minzoom,this.maxzoom=e.maxzoom??this.maxzoom,this.attribution=e.attribution??this.attribution,this.bounds=e.bounds??this.bounds,this.scheme=e.scheme??this.scheme,this.tileSize=e.tileSize??this.tileSize}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(e){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this.tiles=e,this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return{...this._options}}setPremultiplyAlpha(e){return this._premultiplyAlpha===e||this.setSourceProperty(()=>{this._premultiplyAlpha=e}),this}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme,this.map.style.projection.worldCoordinateHelper.tileMatrixSet),n=this._premultiplyAlpha,r=n?void 0:{premultiplyAlpha:`none`};e.abortController=new AbortController;try{let i=await E4.transformAndGetImage(this.map._requestManager,t,`Tile`,e.abortController,this.map._refreshExpiredTiles,r);if(delete e.abortController,e.aborted){e.state=`unloaded`;return}if(i){this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});let t=this.map.painter.context,r=t.gl,a=i.data??new _3({width:1,height:1},new Uint8Array(4));e.texture=this.map.painter.getTileTexture(a.width),e.texture?e.texture.update(a,{useMipmap:!0,premultiply:n}):(e.texture=new b3(t,a,r.RGBA,{useMipmap:!0,premultiply:n}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state=`loaded`}}catch(t){if(delete e.abortController,e.aborted)e.state=`unloaded`;else if(t)throw e.state=`errored`,t}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController)}async unloadTile(e){e.texture&&this.map.painter.saveTileTexture(e.texture)}hasTransition(){return!1}},cT=class extends sT{constructor(e,t,n,r){super(e,t,n,r),this.type=`raster-dem`,this.maxzoom=22,this._options={type:`raster-dem`,...t},this.encoding=t.encoding||`mapbox`,this.redFactor=t.redFactor,this.greenFactor=t.greenFactor,this.blueFactor=t.blueFactor,this.baseShift=t.baseShift}_applyTileJSON(e){super._applyTileJSON(e),this.encoding=e.encoding??this.encoding}async loadTile(e){let t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme,this.map.style.projection.worldCoordinateHelper.tileMatrixSet);e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let n=await E4.transformAndGetImage(this.map._requestManager,t,`Tile`,e.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:`none`});if(delete e.abortController,e.aborted){e.state=`unloaded`;return}if(n){if(this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires}),!n.data){e.state=`loaded`;return}let t=n.data,r=fg(t)&&$p()?t:await this.readImageNow(t),i={type:this.type,uid:e.uid,source:this.id,rawImageData:r,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&e.state!==`expired`&&e.state!==`reloading`)return;await this.dispatcher.waitForInitComplete(),e.actor&&e.state!==`expired`||(e.actor=this.dispatcher.getReadyActor()),e.dem=await e.actor.sendAsync({type:`LDT`,data:i}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0,e.state=`loaded`}}catch(t){if(delete e.abortController,e.aborted)e.state=`unloaded`;else if(t)throw e.state=`errored`,t}}async readImageNow(e){if(typeof VideoFrame<`u`&&tm()){let t=e.width+4,n=e.height+4;try{return new _3({width:t,height:n},await pg(e,-2,-2,t,n))}catch{}}return Pg.getImageData(e,2)}_getNeighboringTiles(e){let t=e.canonical,n=2**t.z,r=(t.x-1+n)%n,i=t.x===0?e.wrap-1:e.wrap,a=(t.x+1+n)%n,o=t.x+1===n?e.wrap+1:e.wrap,s={};return s[new m8(e.overscaledZ,i,t.z,r,t.y).key]={backfilled:!1},s[new m8(e.overscaledZ,o,t.z,a,t.y).key]={backfilled:!1},t.y>0&&(s[new m8(e.overscaledZ,i,t.z,r,t.y-1).key]={backfilled:!1},s[new m8(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},s[new m8(e.overscaledZ,o,t.z,a,t.y-1).key]={backfilled:!1}),t.y+10||n.addOrUpdateProperties?.length>0;if(!i&&!a)continue;r.push(t.geometry);let o={...t};if(e.set(n.id,o),i&&(r.push(n.newGeometry),o.geometry=n.newGeometry),a){if(o.properties=n.removeAllProperties?{}:{...o.properties||{}},n.removeProperties)for(let e of n.removeProperties)delete o.properties[e];if(n.addOrUpdateProperties)for(let{key:e,value:t}of n.addOrUpdateProperties)o.properties[e]=t}}return r}function fT(e,t,n){if(!e)return t||{};if(!t)return e||{};let r=hT(e,n),i=hT(t,n);pT(r,i);let a={};if((r.removeAll||i.removeAll)&&(a.removeAll=!0),a.remove=new Set([...r.remove,...i.remove]),a.add=new Map([...r.add,...i.add]),a.update=new Map([...r.update,...i.update]),a.remove.size&&a.add.size)for(let e of a.add.keys())a.remove.delete(e);return gT(a)}function pT(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(let n of t.remove)e.add.delete(n),e.update.delete(n);for(let n of t.add.keys())e.update.delete(n);for(let[n,r]of t.update){let i=e.update.get(n);i&&(t.update.set(n,mT(i,r)),e.update.delete(n))}}function mT(e,t){let n={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties&&e.addOrUpdateProperties){let n=new Set(t.removeProperties);e.addOrUpdateProperties=e.addOrUpdateProperties.filter(e=>!n.has(e.key))}return(e.removeAllProperties||t.removeAllProperties)&&(n.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(n.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(n.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(n.newGeometry=t.newGeometry||e.newGeometry),n}function hT(e,t){if(!e)return{};let n={};return n.removeAll=e.removeAll,n.remove=new Set(e.remove||[]),n.add=new Map(e.add?.map(e=>[lT(e,t),e])),n.update=new Map(e.update?.map(e=>[e.id,e])),n}function gT(e){let t={};return e.removeAll&&(t.removeAll=e.removeAll),e.remove&&(t.remove=Array.from(e.remove)),e.add&&(t.add=Array.from(e.add.values())),e.update&&(t.update=Array.from(e.update.values())),t}function _T(e){return!e||e.length===0?[]:typeof e[0]==`number`?[e]:e.flatMap(e=>_T(e))}function vT(e){return e?e.type===`GeometryCollection`?e.geometries.flatMap(e=>vT(e)):_T(e.coordinates):[]}function yT(e){let t=new y8,n;switch(e.type){case`FeatureCollection`:n=e.features.flatMap(e=>vT(e.geometry));break;case`Feature`:n=vT(e.geometry);break;default:n=vT(e)}if(n.length===0)return t;for(let e of n){let[n,r]=e;t.extend([n,r])}return t}function bT({x:e,y:t,z:n},r,i){let a=2**n,{west:o,south:s,east:c,north:l}=N8(i,(e-r)/a,(t-r)/a,(e+1+r)/a,(t+1+r)/a);return new y8([o,s],[c,l])}var xT=class{constructor(e){this._waiting=[],this._sending=!1,this._replacedWhileSending=!1,this._handlers=e}isIdle(){return!this._sending&&this._waiting.length===0}top(){return this._waiting.length?this._waiting[this._waiting.length-1]:void 0}some(e){return this._waiting.some(e)}enqueue(e){this._waiting.push(e)}replace(e){this._waiting=[e],this._replacedWhileSending=this._sending}clear(){this._waiting=[]}flush(){if(this.isIdle())return Promise.resolve();if(!this._flushing){let e,t=new Promise(t=>{e=t});this._flushing={promise:t,resolve:e}}let{promise:e}=this._flushing;return this._next(),e}_next(){if(this._sending)return;let e=this._waiting.shift();e===void 0?(this._flushing?.resolve(),this._flushing=void 0):(this._sending=!0,this._replacedWhileSending=!1,this._send(e).finally(()=>this._next()))}async _send(e){let t;try{t=await this._handlers.send(e)}catch(t){this._sending=!1,this._handlers.onError(e,t);return}this._sending=!1;try{this._handlers.onResult(e,t,this._replacedWhileSending)}catch(t){this._handlers.onError(e,t)}}},ST=class{constructor(e){this.wraps=!1,this._crs=e,this._originX=e.tileMatrixSet.origin[0],this._originY=e.tileMatrixSet.origin[1],this._extent=e.tileMatrixSet.extentAtZoom0}get name(){return this._crs.name}get tileMatrixSet(){return this._crs.tileMatrixSet}worldFromLngLat(e,t,n){let[r,i]=this._crs.projection.forward([e,t]);return new c8((r-this._originX)/this._extent,(this._originY-i)/this._extent,n===void 0?0:n/this._extent)}lngLatFromWorld(e,t){let n=G(e,0,1),r=G(t,0,1),i=this._inverse(e,t)??this._inverse(n,r)??this._inverseTowardCenter(n,r)??this._finiteInverse(n,r);if(!i)throw Error(`The inverse of the projection "${this._crs.name}" has no answer inside its tile matrix set.`);return new Xb(i[0],G(i[1],-90,90))}hasLngLat(e,t){let n=this._inverse(e,t);return n!==null&&Math.abs(n[1])<=90}_inverse(e,t){let n=this._finiteInverse(e,t);if(!n)return null;let r=this._originX+e*this._extent,i=this._originY-t*this._extent,[a,o]=this._crs.projection.forward(n);return Math.hypot(a-r,o-i)<=.001*this._extent?n:null}_finiteInverse(e,t){let n;try{n=this._crs.projection.inverse([this._originX+e*this._extent,this._originY-t*this._extent])}catch{return null}return n&&Number.isFinite(n[0])&&Number.isFinite(n[1])?n:null}_inverseTowardCenter(e,t){let n=0,r=1;for(let i=0;i<30;i++){let i=(n+r)/2;this._inverse(.5+(e-.5)*i,.5+(t-.5)*i)?n=i:r=i}return this._inverse(.5+(e-.5)*n,.5+(t-.5)*n)}metersPerWorldUnit(e,t){return this._extent}worldZFromAltitude(e,t){return e/this._extent}get latitudeRange(){return this._latitudeRange??=[this._findLatitudeLimit(-90),this._findLatitudeLimit(90)],this._latitudeRange}_findLatitudeLimit(e){let t=this.lngLatFromWorld(.5,.5),n=10*this._meridianStretch(t.lng,t.lat);if(!(n>0))return e;let r=Math.sign(e-t.lat);for(let i=t.lat;Math.abs(e-i)>1;i+=r)if(!(this._meridianStretch(t.lng,i+r)<=n))return i;return e}_meridianStretch(e,t){let[n,r]=this._crs.projection.forward([e,t]),[i,a]=this._crs.projection.forward([e,t>=0?t-.01:t+.01]);return Math.hypot(i-n,a-r)}},CT=class{forward(e){return[e[0],e[1]]}inverse(e){return[e[0],e[1]]}},wT=new class{constructor(){this.name=`identity`,this.projection=new CT,this.tileMatrixSet={origin:[-90,90],extentAtZoom0:180}}},TT=new Map([[wT.name,wT]]);function ET(e){return typeof e==`string`?TT.get(e):void 0}var DT=class extends l_{constructor(e,t,n,r){super(),this.id=e,this.type=`geojson`,this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._workerUpdates=new xT({send:e=>this._sendWorkerUpdate(e),onResult:(e,t,n)=>this._onWorkerUpdateResult(e,t,n),onError:(e,t)=>this._onWorkerUpdateError(t)}),t.data!==void 0&&this._workerUpdates.enqueue({data:t.data}),this.actorPromise=n.getActor(),this.setEventedParent(r),this._data=typeof t.data==`string`?{url:t.data}:{geojson:t.data},this._options={...t},this._collectResourceTiming=t.collectResourceTiming,t.maxzoom!==void 0&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId,t.clusterMaxZoom!==void 0&&this.maxzoom<=t.clusterMaxZoom&&ig(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${t.clusterMaxZoom}".`),this.workerOptions={source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(t.buffer===void 0?128:t.buffer),tolerance:this._pixelsToTileUnits(t.tolerance===void 0?.375:t.tolerance),extent:W,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1,promoteId:this._promoteIdKey,cluster:t.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(t.clusterMaxZoom),minPoints:Math.max(2,t.clusterMinPoints||2),extent:W,radius:this._pixelsToTileUnits(t.clusterRadius||50),log:!1,generateId:t.generateId||!1}},clusterProperties:t.clusterProperties,filter:t.filter,...t.workerOptions}}get _promoteIdKey(){return typeof this.promoteId==`string`?this.promoteId:void 0}_pixelsToTileUnits(e){return e*(W/this.tileSize)}_tileUnitsToPixels(e){return e/(W/this.tileSize)}_getClusterMaxZoom(e){let t=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||ig(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${t}"`),t}async load(){this._workerUpdates.isIdle()?ig(`No pending worker updates for GeoJSONSource ${this.id}.`):await this._workerUpdates.flush()}onAdd(e){this.map=e,this.load()}setData(e){return this._data=typeof e==`string`?{url:e}:{geojson:e},this._workerUpdates.replace({data:e}),this._workerUpdates.flush()}updateData(e){let t=this._getWaitingWorkerChange();return t?t.diff=fT(t.diff,e,this._promoteIdKey):this._workerUpdates.enqueue({diff:e}),this._workerUpdates.flush()}async getData(){for(;this._data.url;)await this.once(`data`);return this._data.geojson?this._data.geojson:{type:`FeatureCollection`,features:Array.from(this._data.updateable.values())}}async getBounds(){return yT(await this.getData())}setClusterOptions(e){if(this.workerOptions.geojsonVtOptions.cluster=e.cluster,e.clusterRadius!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),!this._workerUpdates.some(e=>`data`in e)){let e=this._getWaitingWorkerChange();e?e.updateCluster=!0:this._workerUpdates.enqueue({updateCluster:!0})}return this._workerUpdates.flush()}_getWaitingWorkerChange(){let e=this._workerUpdates.top();return e&&!(`data`in e)?e:void 0}getClusterOptions(){let{cluster:e,clusterOptions:t}=this.workerOptions.geojsonVtOptions;return{cluster:e,clusterMaxZoom:t.maxZoom,clusterRadius:this._tileUnitsToPixels(t.radius)}}async getClusterExpansionZoom(e){return(await this.actorPromise).sendAsync({type:`GCEZ`,data:{type:this.type,clusterId:e,source:this.id}})}async getClusterChildren(e){return(await this.actorPromise).sendAsync({type:`GCC`,data:{type:this.type,clusterId:e,source:this.id}})}async getClusterLeaves(e,t,n){return(await this.actorPromise).sendAsync({type:`GCL`,data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:n}})}async _getLoadGeoJSONParameters(e){let t={type:this.type,source:this.id,...this.workerOptions},n=this._getCRSParameters();return n&&(t.crs=n),`data`in e?typeof e.data==`string`?(t.request=await this.map._requestManager.transformRequest(Pg.resolveURL(e.data),`Source`),t.request.collectResourceTiming=this._collectResourceTiming,t):(t.data=e.data,t):(e.diff&&(t.dataDiff=e.diff),e.updateCluster&&(t.updateCluster=!0),t)}_getCRSParameters(){let e=ET(this.map?.style?.projection?.name);if(e){if(!e.definition&&e!==wT)ig(`GeoJSON source "${this.id}" is drawn in the wrong place: the projection "${e.name}" has no \`definition\` to project its data with.`);else return{name:e.name,definition:e.definition,tileMatrixSet:e.tileMatrixSet}}}async _sendWorkerUpdate(e){this.fire(new j4(`dataloading`));let t=await this._getLoadGeoJSONParameters(e);return(await this.actorPromise).sendAsync({type:`LD`,data:t})}_onWorkerUpdateResult(e,t,n){if(this._removed||t.abandoned){this.fire(new j4(`dataabort`));return}t.data&&!n&&(this._data={geojson:t.data});let r=`data`in e||n?void 0:e.diff,i=this._applyDiffToSource(r),a=!(`data`in e)&&e.updateCluster||this.map?.style?.projection?.worldCoordinateHelper.wraps===!1?void 0:this._getShouldReloadTileOptions(i),o={};this._applyResourceTiming(o,t),this.fire(new j4(`data`,{...o,sourceDataType:`metadata`})),this.fire(new j4(`data`,{...o,sourceDataType:`content`,shouldReloadTileOptions:a}))}_onWorkerUpdateError(e){this._removed?this.fire(new j4(`dataabort`)):this.fire(new c_(Ch(e)))}_applyResourceTiming(e,t){if(!this._collectResourceTiming)return;let n=t.resourceTiming?.[this.id];if(!n)return;let r=n.slice(0);r?.length&&(e.resourceTiming=r)}_applyDiffToSource(e){if(!e)return;let t=this._promoteIdKey;if(!this._data.url&&!this._data.updateable){let e=uT(this._data.geojson,t);if(!e)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;let n=dT(this._data.updateable,e,t);if(!(e.removeAll||this.workerOptions.geojsonVtOptions.cluster))return n}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(e=>yT(e)).filter(e=>!e.isEmpty())}}shouldReloadTile(e,{affectedBounds:t}){if(e.state===`loading`)return!0;if(e.state===`unloaded`)return!1;let{buffer:n,extent:r}=this.workerOptions.geojsonVtOptions,i=bT(e.tileID.canonical,n/r,this.map.style.projection.worldCoordinateHelper);for(let e of t)if(i.intersects(e))return!0;return!1}loaded(){return this._workerUpdates.isIdle()}async loadTile(e){let t=e.actor?`RT`:`LT`;e.actor=await this.actorPromise;let n={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;try{let r=await(await this.actorPromise).sendAsync({type:t,data:n},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.style,t===`RT`)}catch(t){if(delete e.abortController,e.aborted||kg(t))return;throw t}}async abortTile(e){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}async unloadTile(e){e.unloadVectorData(),await(await this.actorPromise).sendAsync({type:`RMT`,data:{uid:e.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this._workerUpdates.clear(),this.actorPromise.then(e=>e.sendAsync({type:`RS`,data:{type:this.type,source:this.id}}))}serialize(){return{...this._options,type:this.type,data:this._data.updateable?{type:`FeatureCollection`,features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson}}hasTransition(){return!1}},OT=[0,0,1],kT=(e,t)=>({u_tl_parent:new rb(e,t.u_tl_parent),u_scale_parent:new Z(e,t.u_scale_parent),u_buffer_scale:new Z(e,t.u_buffer_scale),u_image_warp:new ib(e,t.u_image_warp),u_fade_t:new Z(e,t.u_fade_t),u_opacity:new Z(e,t.u_opacity),u_image0:new nb(e,t.u_image0),u_image1:new nb(e,t.u_image1),u_brightness_low:new Z(e,t.u_brightness_low),u_brightness_high:new Z(e,t.u_brightness_high),u_saturation_factor:new Z(e,t.u_saturation_factor),u_contrast_factor:new Z(e,t.u_contrast_factor),u_spin_weights:new ib(e,t.u_spin_weights),u_coords_top:new ab(e,t.u_coords_top),u_coords_bottom:new ab(e,t.u_coords_bottom)}),AT=(e,t,n,r,i,a)=>({u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_image_warp:a,u_fade_t:n.mix,u_opacity:n.opacity*r.paint.get(`raster-opacity`),u_image0:0,u_image1:1,u_brightness_low:r.paint.get(`raster-brightness-min`),u_brightness_high:r.paint.get(`raster-brightness-max`),u_saturation_factor:NT(r.paint.get(`raster-saturation`)),u_contrast_factor:MT(r.paint.get(`raster-contrast`)),u_spin_weights:jT(r.paint.get(`raster-hue-rotate`)),u_coords_top:[i[0].x,i[0].y,i[1].x,i[1].y],u_coords_bottom:[i[3].x,i[3].y,i[2].x,i[2].y]});function jT(e){e*=Math.PI/180;let t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}function MT(e){return e>0?1/(1-e):1+e}function NT(e){return e>0?1-1/(1.001-e):-e}var PT=class{constructor(e,t,n){this.vertexBuffer=e,this.indexBuffer=t,this.segments=n}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}},FT=I3([{name:`a_pos`,type:`Int16`,components:2}]);function IT(e,t){let n=LT(t,`16bit`),r=x6.deserialize({arrayBuffer:n.vertices,length:n.vertices.byteLength/2/2}),i=z6.deserialize({arrayBuffer:n.indices,length:n.indices.byteLength/2/3});return new PT(e.createVertexBuffer(r,FT.members),e.createIndexBuffer(i),W6.simpleSegment(0,0,r.length,i.length))}function LT(e,t){let n=e.granularity===void 0?1:Math.max(e.granularity,1),r=n+(e.generateBorders?2:0),i=n+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),a=r+1,o=i+1,s=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,l=n+ +!!e.generateBorders,u=n+(e.generateBorders||e.extendToSouthPole?1:0),d=a*o,f=r*i*6,p=a*o>65536;if(p&&t===`16bit`)throw Error(`Granularity is too large and meshes would not fit inside 16 bit vertex indices.`);let m=p||t===`32bit`,h=new Int16Array(d*2),g=0;for(let t=c;t<=u;t++)for(let r=s;r<=l;r++){let i=r/n*W;r===-1&&(i=-64),r===n+1&&(i=8256);let a=t/n*W;t===-1&&(a=e.extendToNorthPole?Q5:-64),t===n+1&&(a=e.extendToSouthPole?$5:8256),h[g++]=i,h[g++]=a}let _=m?new Uint32Array(f):new Uint16Array(f),v=0;for(let e=0;e{let n=Xb.convert(e);return t.worldFromLngLat(n.lng,n.lat)});return this.tileID=zT(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map(e=>this.tileID.getTilePoint(e)._round()),this.imageWarp=VT(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!UT(this.tileCoords),this.flippedWindingOrder=BT(this.tileCoords),this.fire(new j4(`data`,{sourceDataType:`content`})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let e=this.map.painter.context,t=e.gl;this.texture?this._imageDirty&&(this.texture.update(this.image),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)):(this.texture=new b3(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._imageDirty=!1;let n=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,n=!0)}n&&this.fire(new j4(`data`,{sourceDataType:`idle`,sourceId:this.id}))}async loadTile(e){this.tileID?.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state=`errored`}serialize(){let e={type:`image`,coordinates:this.coordinates};return this.options.url!==void 0&&(e.url=this.options.url),e}hasTransition(){return!1}_getOverlappingTileRanges(e){let{minX:t,minY:n,maxX:r,maxY:i}=Ob.fromPoints(e),a={};for(let e=0;e<=25;e++){let o=2**e,s=Math.floor(t*o),c=Math.floor(n*o),l=Math.floor(r*o),u=Math.floor(i*o),d=(s%o+o)%o,f=l%o,p=Math.floor(s/o),m=Math.floor(l/o);a[e]={minWrap:p,maxWrap:m,minTileXWrapped:d,maxTileXWrapped:f,minTileY:c,maxTileY:u}}return a}};function zT(e){let t=Ob.fromPoints(e),n=t.width(),r=t.height(),i=Math.max(0,Math.floor(-Math.log(Math.max(n,r))/Math.LN2)),a=2**i;return new f8(i,Math.floor((t.minX+t.maxX)/2*a),Math.floor((t.minY+t.maxY)/2*a))}function BT(e){let t=e[1].x-e[0].x,n=e[1].y-e[0].y,r=e[2].x-e[0].x;return t*(e[2].y-e[0].y)-n*r<0}function VT(e,t){if(t===`flat`||UT(e))return OT;let[n,r,i,a]=e,o=n.x-r.x+i.x-a.x,s=n.y-r.y+i.y-a.y,c=[r.x-i.x,r.y-i.y,a.x-i.x,a.y-i.y],[l,u,d,f]=c,p=am(c),m=(o*f-d*s)/p,h=(l*s-o*u)/p,g=[1,1+m,1+m+h,1+h],_=Math.max(...g)/Math.min(...g),v=t===`perspective`?0:HT(_);return!(_>=1&&_<=512)||v>=1?OT:[m,h,v]}function HT(e){let t=(1-4/e)/(1-4/512);return Math.max(0,t)}function UT(e){let[t,n,r,i]=e;return t.x+r.x===n.x+i.x&&t.y+r.y===n.y+i.y}var WT=class extends RT{constructor(e,t,n,r){super(e,t,n,r),this._onPlayingHandler=()=>{this.map?.triggerRepaint()},this.roundZoom=!0,this.type=`video`,this.options=t}async load(){this._loaded=!1;let e=this.options;this.urls=[];for(let t of e.urls)this.urls.push((await this.map._requestManager.transformRequest(t,`Source`)).url);try{let e=await ree(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener(`playing`,this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new c_(Ch(e)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let t=this.video.seekable;et.end(0)?this.fire(new c_(new q(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener(`playing`,this._onPlayingHandler),this.video.pause())}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new b3(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE));let n=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,n=!0)}n&&this.fire(new j4(`data`,{sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`video`,urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},GT=class extends RT{constructor(e,t,n,r){super(e,t,n,r),t.coordinates?(!Array.isArray(t.coordinates)||t.coordinates.length!==4||t.coordinates.some(e=>!Array.isArray(e)||e.length!==2||e.some(e=>typeof e!=`number`)))&&this.fire(new c_(new q(`sources.${e}`,null,`"coordinates" property must be an array of 4 longitude/latitude array pairs`))):this.fire(new c_(new q(`sources.${e}`,null,`missing required property "coordinates"`))),t.animate&&typeof t.animate!=`boolean`&&this.fire(new c_(new q(`sources.${e}`,null,`optional "animate" property must be a boolean value`))),t.canvas?typeof t.canvas!=`string`&&!(t.canvas instanceof HTMLCanvasElement)&&this.fire(new c_(new q(`sources.${e}`,null,`"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance`))):this.fire(new c_(new q(`sources.${e}`,null,`missing required property "canvas"`))),this.options=t,this.animate=t.animate===void 0||t.animate}async load(){this._loaded=!0,this.canvas||=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new c_(Error(`Canvas dimensions cannot be less than or equal to zero.`))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&=(this.prepare(),!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this._playing=!1,super.onRemove()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let t=this.map.painter.context,n=t.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new b3(t,this.canvas,n.RGBA,{premultiply:!0}),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(let e in this.tiles){let t=this.tiles[e];t.state!==`loaded`&&(t.state=`loaded`,t.texture=this.texture,r=!0)}r&&this.fire(new j4(`data`,{sourceDataType:`idle`,sourceId:this.id}))}serialize(){return{type:`canvas`,animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},KT={},qT=(e,t,n,r)=>{let i=new(JT(t.type))(e,t,n,r);if(i.id!==e)throw Error(`Expected Source id to be ${e} instead of ${i.id}`);return i},JT=e=>{switch(e){case`geojson`:return DT;case`image`:return RT;case`raster`:return sT;case`raster-dem`:return cT;case`vector`:return oT;case`video`:return WT;case`canvas`:return GT}return KT[e]};function YT(e,t){let n={};if(!t)return n;for(let r of e){let e=r.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(e.length!==0){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(let t of e)n[t.id]=r}}return n}var XT=`_geojsonTileLayer`,ZT=class{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}},QT=class e{static{this.worldCoordinateHelpers=new WeakMap}constructor(t,n,r,i,a,o){this.type=`Feature`,this._vectorTileFeature=t,this._x=r,this._y=i,this._z=n,o!==l8&&e.worldCoordinateHelpers.set(this,o);for(let e in t.properties)typeof t.properties[e]==`string`&&t.properties[e].startsWith(`__$json__:`)&&(t.properties[e]=JSON.parse(t.properties[e].slice(10)));this.properties=t.properties,this.id=a}projectPoint(e,t,n,r,i){if(i){let a=i.lngLatFromWorld((e.x+t)/r,(e.y+n)/r);return[a.lng,a.lat]}return[(e.x+t)*360/r-180,360/Math.PI*Math.atan(Math.exp((1-(e.y+n)*2/r)*Math.PI))-90]}projectLine(e,t,n,r,i){return e.map(e=>this.projectPoint(e,t,n,r,i))}get geometry(){if(this._geometry)return this._geometry;let t=this._vectorTileFeature,n=e.worldCoordinateHelpers.get(this),r=t.extent*2**this._z,i=t.extent*this._x,a=t.extent*this._y,o=t.loadGeometry();switch(t.type){case 1:{let e=[];for(let t of o)e.push(t[0]);let t=this.projectLine(e,i,a,r,n);this._geometry=e.length===1?{type:`Point`,coordinates:t[0]}:{type:`MultiPoint`,coordinates:t};break}case 2:{let e=o.map(e=>this.projectLine(e,i,a,r,n));this._geometry=e.length===1?{type:`LineString`,coordinates:e[0]}:{type:`MultiLineString`,coordinates:e};break}case 3:{let e=m7(o),t=[];for(let o of e)t.push(o.map(e=>this.projectLine(e,i,a,r,n)));this._geometry=t.length===1?{type:`Polygon`,coordinates:t[0]}:{type:`MultiPolygon`,coordinates:t};break}default:throw Error(`unknown feature type: ${t.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={geometry:this.geometry};for(let t in this)t!==`_geometry`&&t!==`_vectorTileFeature`&&t!==`_x`&&t!==`_y`&&t!==`_z`&&(e[t]=this[t]);return e}},$T=class{constructor(e,t,n){this._name=e,this.dataBuffer=t,typeof n==`number`?this._size=n:(this.nullabilityBuffer=n,this._size=n.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer?.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},eE=class extends $T{},tE=class extends eE{getValueFromBuffer(e){return this.dataBuffer[e]}},nE=class extends eE{getValueFromBuffer(e){return this.dataBuffer[e]}},rE=class extends $T{constructor(e,t,n,r){super(e,t,r),this.delta=n}},iE=class extends rE{constructor(e,t,n,r,i){super(e,i?Int32Array.of(t):Uint32Array.of(t),n,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}},aE=class extends $T{constructor(e,t,n,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),n)}getValueFromBuffer(e){return this.dataBuffer[0]}},oE=class{constructor(e,t,n,r,i=4096){if(this._name=e,this._geometryVector=t,this._idVector=n,this._propertyVectors=r,this._extent=i,e.length===0)throw Error(`Missing layer name`)}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors??[]}getPropertyVector(e){return this.propertyVectorsMap||=new Map(this.propertyVectors.map(e=>[e.name,e])),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let e=[],t=this.geometryVector.getGeometries();for(let n=0;n>>32-e;var hE=mE,gE=65536;function _E(e,t){return e-e%t}function vE(e){return _E(e+31,32)}function yE(e){if(!Number.isFinite(e)||e<=0)return gE;let t=_E(Math.floor(e),256);return t===0?256:t}function bE(e){let t=e>>>0;return((t&255)<<24|(t&65280)<<8|t>>>8&65280|t>>>24&255)>>>0}function xE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0;n[i++]=a>>>0&3,n[i++]=a>>>2&3,n[i++]=a>>>4&3,n[i++]=a>>>6&3,n[i++]=a>>>8&3,n[i++]=a>>>10&3,n[i++]=a>>>12&3,n[i++]=a>>>14&3,n[i++]=a>>>16&3,n[i++]=a>>>18&3,n[i++]=a>>>20&3,n[i++]=a>>>22&3,n[i++]=a>>>24&3,n[i++]=a>>>26&3,n[i++]=a>>>28&3,n[i++]=a>>>30&3,n[i++]=o>>>0&3,n[i++]=o>>>2&3,n[i++]=o>>>4&3,n[i++]=o>>>6&3,n[i++]=o>>>8&3,n[i++]=o>>>10&3,n[i++]=o>>>12&3,n[i++]=o>>>14&3,n[i++]=o>>>16&3,n[i++]=o>>>18&3,n[i++]=o>>>20&3,n[i++]=o>>>22&3,n[i++]=o>>>24&3,n[i++]=o>>>26&3,n[i++]=o>>>28&3,n[i]=o>>>30&3}function SE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0;n[i++]=a>>>0&7,n[i++]=a>>>3&7,n[i++]=a>>>6&7,n[i++]=a>>>9&7,n[i++]=a>>>12&7,n[i++]=a>>>15&7,n[i++]=a>>>18&7,n[i++]=a>>>21&7,n[i++]=a>>>24&7,n[i++]=a>>>27&7,n[i++]=(a>>>30|(o&1)<<2)&7,n[i++]=o>>>1&7,n[i++]=o>>>4&7,n[i++]=o>>>7&7,n[i++]=o>>>10&7,n[i++]=o>>>13&7,n[i++]=o>>>16&7,n[i++]=o>>>19&7,n[i++]=o>>>22&7,n[i++]=o>>>25&7,n[i++]=o>>>28&7,n[i++]=(o>>>31|(s&3)<<1)&7,n[i++]=s>>>2&7,n[i++]=s>>>5&7,n[i++]=s>>>8&7,n[i++]=s>>>11&7,n[i++]=s>>>14&7,n[i++]=s>>>17&7,n[i++]=s>>>20&7,n[i++]=s>>>23&7,n[i++]=s>>>26&7,n[i]=s>>>29&7}function CE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0;n[i++]=a>>>0&15,n[i++]=a>>>4&15,n[i++]=a>>>8&15,n[i++]=a>>>12&15,n[i++]=a>>>16&15,n[i++]=a>>>20&15,n[i++]=a>>>24&15,n[i++]=a>>>28&15,n[i++]=o>>>0&15,n[i++]=o>>>4&15,n[i++]=o>>>8&15,n[i++]=o>>>12&15,n[i++]=o>>>16&15,n[i++]=o>>>20&15,n[i++]=o>>>24&15,n[i++]=o>>>28&15,n[i++]=s>>>0&15,n[i++]=s>>>4&15,n[i++]=s>>>8&15,n[i++]=s>>>12&15,n[i++]=s>>>16&15,n[i++]=s>>>20&15,n[i++]=s>>>24&15,n[i++]=s>>>28&15,n[i++]=c>>>0&15,n[i++]=c>>>4&15,n[i++]=c>>>8&15,n[i++]=c>>>12&15,n[i++]=c>>>16&15,n[i++]=c>>>20&15,n[i++]=c>>>24&15,n[i]=c>>>28&15}function wE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0;n[i++]=a>>>0&31,n[i++]=a>>>5&31,n[i++]=a>>>10&31,n[i++]=a>>>15&31,n[i++]=a>>>20&31,n[i++]=a>>>25&31,n[i++]=(a>>>30|(o&7)<<2)&31,n[i++]=o>>>3&31,n[i++]=o>>>8&31,n[i++]=o>>>13&31,n[i++]=o>>>18&31,n[i++]=o>>>23&31,n[i++]=(o>>>28|(s&1)<<4)&31,n[i++]=s>>>1&31,n[i++]=s>>>6&31,n[i++]=s>>>11&31,n[i++]=s>>>16&31,n[i++]=s>>>21&31,n[i++]=s>>>26&31,n[i++]=(s>>>31|(c&15)<<1)&31,n[i++]=c>>>4&31,n[i++]=c>>>9&31,n[i++]=c>>>14&31,n[i++]=c>>>19&31,n[i++]=c>>>24&31,n[i++]=(c>>>29|(l&3)<<3)&31,n[i++]=l>>>2&31,n[i++]=l>>>7&31,n[i++]=l>>>12&31,n[i++]=l>>>17&31,n[i++]=l>>>22&31,n[i]=l>>>27&31}function TE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0;n[i++]=a>>>0&63,n[i++]=a>>>6&63,n[i++]=a>>>12&63,n[i++]=a>>>18&63,n[i++]=a>>>24&63,n[i++]=(a>>>30|(o&15)<<2)&63,n[i++]=o>>>4&63,n[i++]=o>>>10&63,n[i++]=o>>>16&63,n[i++]=o>>>22&63,n[i++]=(o>>>28|(s&3)<<4)&63,n[i++]=s>>>2&63,n[i++]=s>>>8&63,n[i++]=s>>>14&63,n[i++]=s>>>20&63,n[i++]=s>>>26&63,n[i++]=c>>>0&63,n[i++]=c>>>6&63,n[i++]=c>>>12&63,n[i++]=c>>>18&63,n[i++]=c>>>24&63,n[i++]=(c>>>30|(l&15)<<2)&63,n[i++]=l>>>4&63,n[i++]=l>>>10&63,n[i++]=l>>>16&63,n[i++]=l>>>22&63,n[i++]=(l>>>28|(u&3)<<4)&63,n[i++]=u>>>2&63,n[i++]=u>>>8&63,n[i++]=u>>>14&63,n[i++]=u>>>20&63,n[i]=u>>>26&63}function EE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0;n[i++]=a>>>0&127,n[i++]=a>>>7&127,n[i++]=a>>>14&127,n[i++]=a>>>21&127,n[i++]=(a>>>28|(o&7)<<4)&127,n[i++]=o>>>3&127,n[i++]=o>>>10&127,n[i++]=o>>>17&127,n[i++]=o>>>24&127,n[i++]=(o>>>31|(s&63)<<1)&127,n[i++]=s>>>6&127,n[i++]=s>>>13&127,n[i++]=s>>>20&127,n[i++]=(s>>>27|(c&3)<<5)&127,n[i++]=c>>>2&127,n[i++]=c>>>9&127,n[i++]=c>>>16&127,n[i++]=c>>>23&127,n[i++]=(c>>>30|(l&31)<<2)&127,n[i++]=l>>>5&127,n[i++]=l>>>12&127,n[i++]=l>>>19&127,n[i++]=(l>>>26|(u&1)<<6)&127,n[i++]=u>>>1&127,n[i++]=u>>>8&127,n[i++]=u>>>15&127,n[i++]=u>>>22&127,n[i++]=(u>>>29|(d&15)<<3)&127,n[i++]=d>>>4&127,n[i++]=d>>>11&127,n[i++]=d>>>18&127,n[i]=d>>>25&127}function DE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0;n[i++]=a>>>0&255,n[i++]=a>>>8&255,n[i++]=a>>>16&255,n[i++]=a>>>24&255,n[i++]=o>>>0&255,n[i++]=o>>>8&255,n[i++]=o>>>16&255,n[i++]=o>>>24&255,n[i++]=s>>>0&255,n[i++]=s>>>8&255,n[i++]=s>>>16&255,n[i++]=s>>>24&255,n[i++]=c>>>0&255,n[i++]=c>>>8&255,n[i++]=c>>>16&255,n[i++]=c>>>24&255,n[i++]=l>>>0&255,n[i++]=l>>>8&255,n[i++]=l>>>16&255,n[i++]=l>>>24&255,n[i++]=u>>>0&255,n[i++]=u>>>8&255,n[i++]=u>>>16&255,n[i++]=u>>>24&255,n[i++]=d>>>0&255,n[i++]=d>>>8&255,n[i++]=d>>>16&255,n[i++]=d>>>24&255,n[i++]=f>>>0&255,n[i++]=f>>>8&255,n[i++]=f>>>16&255,n[i]=f>>>24&255}function OE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0;n[i++]=a>>>0&511,n[i++]=a>>>9&511,n[i++]=a>>>18&511,n[i++]=(a>>>27|(o&15)<<5)&511,n[i++]=o>>>4&511,n[i++]=o>>>13&511,n[i++]=o>>>22&511,n[i++]=(o>>>31|(s&255)<<1)&511,n[i++]=s>>>8&511,n[i++]=s>>>17&511,n[i++]=(s>>>26|(c&7)<<6)&511,n[i++]=c>>>3&511,n[i++]=c>>>12&511,n[i++]=c>>>21&511,n[i++]=(c>>>30|(l&127)<<2)&511,n[i++]=l>>>7&511,n[i++]=l>>>16&511,n[i++]=(l>>>25|(u&3)<<7)&511,n[i++]=u>>>2&511,n[i++]=u>>>11&511,n[i++]=u>>>20&511,n[i++]=(u>>>29|(d&63)<<3)&511,n[i++]=d>>>6&511,n[i++]=d>>>15&511,n[i++]=(d>>>24|(f&1)<<8)&511,n[i++]=f>>>1&511,n[i++]=f>>>10&511,n[i++]=f>>>19&511,n[i++]=(f>>>28|(p&31)<<4)&511,n[i++]=p>>>5&511,n[i++]=p>>>14&511,n[i]=p>>>23&511}function kE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0;n[i++]=a>>>0&1023,n[i++]=a>>>10&1023,n[i++]=a>>>20&1023,n[i++]=(a>>>30|(o&255)<<2)&1023,n[i++]=o>>>8&1023,n[i++]=o>>>18&1023,n[i++]=(o>>>28|(s&63)<<4)&1023,n[i++]=s>>>6&1023,n[i++]=s>>>16&1023,n[i++]=(s>>>26|(c&15)<<6)&1023,n[i++]=c>>>4&1023,n[i++]=c>>>14&1023,n[i++]=(c>>>24|(l&3)<<8)&1023,n[i++]=l>>>2&1023,n[i++]=l>>>12&1023,n[i++]=l>>>22&1023,n[i++]=u>>>0&1023,n[i++]=u>>>10&1023,n[i++]=u>>>20&1023,n[i++]=(u>>>30|(d&255)<<2)&1023,n[i++]=d>>>8&1023,n[i++]=d>>>18&1023,n[i++]=(d>>>28|(f&63)<<4)&1023,n[i++]=f>>>6&1023,n[i++]=f>>>16&1023,n[i++]=(f>>>26|(p&15)<<6)&1023,n[i++]=p>>>4&1023,n[i++]=p>>>14&1023,n[i++]=(p>>>24|(m&3)<<8)&1023,n[i++]=m>>>2&1023,n[i++]=m>>>12&1023,n[i]=m>>>22&1023}function AE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0;n[i++]=a>>>0&2047,n[i++]=a>>>11&2047,n[i++]=(a>>>22|(o&1)<<10)&2047,n[i++]=o>>>1&2047,n[i++]=o>>>12&2047,n[i++]=(o>>>23|(s&3)<<9)&2047,n[i++]=s>>>2&2047,n[i++]=s>>>13&2047,n[i++]=(s>>>24|(c&7)<<8)&2047,n[i++]=c>>>3&2047,n[i++]=c>>>14&2047,n[i++]=(c>>>25|(l&15)<<7)&2047,n[i++]=l>>>4&2047,n[i++]=l>>>15&2047,n[i++]=(l>>>26|(u&31)<<6)&2047,n[i++]=u>>>5&2047,n[i++]=u>>>16&2047,n[i++]=(u>>>27|(d&63)<<5)&2047,n[i++]=d>>>6&2047,n[i++]=d>>>17&2047,n[i++]=(d>>>28|(f&127)<<4)&2047,n[i++]=f>>>7&2047,n[i++]=f>>>18&2047,n[i++]=(f>>>29|(p&255)<<3)&2047,n[i++]=p>>>8&2047,n[i++]=p>>>19&2047,n[i++]=(p>>>30|(m&511)<<2)&2047,n[i++]=m>>>9&2047,n[i++]=m>>>20&2047,n[i++]=(m>>>31|(h&1023)<<1)&2047,n[i++]=h>>>10&2047,n[i]=h>>>21&2047}function jE(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0,g=e[t+11]>>>0;n[i++]=a>>>0&4095,n[i++]=a>>>12&4095,n[i++]=(a>>>24|(o&15)<<8)&4095,n[i++]=o>>>4&4095,n[i++]=o>>>16&4095,n[i++]=(o>>>28|(s&255)<<4)&4095,n[i++]=s>>>8&4095,n[i++]=s>>>20&4095,n[i++]=c>>>0&4095,n[i++]=c>>>12&4095,n[i++]=(c>>>24|(l&15)<<8)&4095,n[i++]=l>>>4&4095,n[i++]=l>>>16&4095,n[i++]=(l>>>28|(u&255)<<4)&4095,n[i++]=u>>>8&4095,n[i++]=u>>>20&4095,n[i++]=d>>>0&4095,n[i++]=d>>>12&4095,n[i++]=(d>>>24|(f&15)<<8)&4095,n[i++]=f>>>4&4095,n[i++]=f>>>16&4095,n[i++]=(f>>>28|(p&255)<<4)&4095,n[i++]=p>>>8&4095,n[i++]=p>>>20&4095,n[i++]=m>>>0&4095,n[i++]=m>>>12&4095,n[i++]=(m>>>24|(h&15)<<8)&4095,n[i++]=h>>>4&4095,n[i++]=h>>>16&4095,n[i++]=(h>>>28|(g&255)<<4)&4095,n[i++]=g>>>8&4095,n[i]=g>>>20&4095}function ME(e,t,n,r){let i=r,a=e[t]>>>0,o=e[t+1]>>>0,s=e[t+2]>>>0,c=e[t+3]>>>0,l=e[t+4]>>>0,u=e[t+5]>>>0,d=e[t+6]>>>0,f=e[t+7]>>>0,p=e[t+8]>>>0,m=e[t+9]>>>0,h=e[t+10]>>>0,g=e[t+11]>>>0,_=e[t+12]>>>0,v=e[t+13]>>>0,y=e[t+14]>>>0,b=e[t+15]>>>0;n[i++]=a>>>0&65535,n[i++]=a>>>16&65535,n[i++]=o>>>0&65535,n[i++]=o>>>16&65535,n[i++]=s>>>0&65535,n[i++]=s>>>16&65535,n[i++]=c>>>0&65535,n[i++]=c>>>16&65535,n[i++]=l>>>0&65535,n[i++]=l>>>16&65535,n[i++]=u>>>0&65535,n[i++]=u>>>16&65535,n[i++]=d>>>0&65535,n[i++]=d>>>16&65535,n[i++]=f>>>0&65535,n[i++]=f>>>16&65535,n[i++]=p>>>0&65535,n[i++]=p>>>16&65535,n[i++]=m>>>0&65535,n[i++]=m>>>16&65535,n[i++]=h>>>0&65535,n[i++]=h>>>16&65535,n[i++]=g>>>0&65535,n[i++]=g>>>16&65535,n[i++]=_>>>0&65535,n[i++]=_>>>16&65535,n[i++]=v>>>0&65535,n[i++]=v>>>16&65535,n[i++]=y>>>0&65535,n[i++]=y>>>16&65535,n[i++]=b>>>0&65535,n[i]=b>>>16&65535}function NE(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0;n[i++]=t>>>0&1,n[i++]=t>>>1&1,n[i++]=t>>>2&1,n[i++]=t>>>3&1,n[i++]=t>>>4&1,n[i++]=t>>>5&1,n[i++]=t>>>6&1,n[i++]=t>>>7&1,n[i++]=t>>>8&1,n[i++]=t>>>9&1,n[i++]=t>>>10&1,n[i++]=t>>>11&1,n[i++]=t>>>12&1,n[i++]=t>>>13&1,n[i++]=t>>>14&1,n[i++]=t>>>15&1,n[i++]=t>>>16&1,n[i++]=t>>>17&1,n[i++]=t>>>18&1,n[i++]=t>>>19&1,n[i++]=t>>>20&1,n[i++]=t>>>21&1,n[i++]=t>>>22&1,n[i++]=t>>>23&1,n[i++]=t>>>24&1,n[i++]=t>>>25&1,n[i++]=t>>>26&1,n[i++]=t>>>27&1,n[i++]=t>>>28&1,n[i++]=t>>>29&1,n[i++]=t>>>30&1,n[i++]=t>>>31&1}}function PE(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0;n[i++]=t>>>0&3,n[i++]=t>>>2&3,n[i++]=t>>>4&3,n[i++]=t>>>6&3,n[i++]=t>>>8&3,n[i++]=t>>>10&3,n[i++]=t>>>12&3,n[i++]=t>>>14&3,n[i++]=t>>>16&3,n[i++]=t>>>18&3,n[i++]=t>>>20&3,n[i++]=t>>>22&3,n[i++]=t>>>24&3,n[i++]=t>>>26&3,n[i++]=t>>>28&3,n[i++]=t>>>30&3,n[i++]=r>>>0&3,n[i++]=r>>>2&3,n[i++]=r>>>4&3,n[i++]=r>>>6&3,n[i++]=r>>>8&3,n[i++]=r>>>10&3,n[i++]=r>>>12&3,n[i++]=r>>>14&3,n[i++]=r>>>16&3,n[i++]=r>>>18&3,n[i++]=r>>>20&3,n[i++]=r>>>22&3,n[i++]=r>>>24&3,n[i++]=r>>>26&3,n[i++]=r>>>28&3,n[i++]=r>>>30&3}}function FE(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0;n[i++]=t>>>0&7,n[i++]=t>>>3&7,n[i++]=t>>>6&7,n[i++]=t>>>9&7,n[i++]=t>>>12&7,n[i++]=t>>>15&7,n[i++]=t>>>18&7,n[i++]=t>>>21&7,n[i++]=t>>>24&7,n[i++]=t>>>27&7,n[i++]=(t>>>30|(r&1)<<2)&7,n[i++]=r>>>1&7,n[i++]=r>>>4&7,n[i++]=r>>>7&7,n[i++]=r>>>10&7,n[i++]=r>>>13&7,n[i++]=r>>>16&7,n[i++]=r>>>19&7,n[i++]=r>>>22&7,n[i++]=r>>>25&7,n[i++]=r>>>28&7,n[i++]=(r>>>31|(o&3)<<1)&7,n[i++]=o>>>2&7,n[i++]=o>>>5&7,n[i++]=o>>>8&7,n[i++]=o>>>11&7,n[i++]=o>>>14&7,n[i++]=o>>>17&7,n[i++]=o>>>20&7,n[i++]=o>>>23&7,n[i++]=o>>>26&7,n[i++]=o>>>29&7}}function IE(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0;n[i++]=t>>>0&15,n[i++]=t>>>4&15,n[i++]=t>>>8&15,n[i++]=t>>>12&15,n[i++]=t>>>16&15,n[i++]=t>>>20&15,n[i++]=t>>>24&15,n[i++]=t>>>28&15,n[i++]=r>>>0&15,n[i++]=r>>>4&15,n[i++]=r>>>8&15,n[i++]=r>>>12&15,n[i++]=r>>>16&15,n[i++]=r>>>20&15,n[i++]=r>>>24&15,n[i++]=r>>>28&15,n[i++]=o>>>0&15,n[i++]=o>>>4&15,n[i++]=o>>>8&15,n[i++]=o>>>12&15,n[i++]=o>>>16&15,n[i++]=o>>>20&15,n[i++]=o>>>24&15,n[i++]=o>>>28&15,n[i++]=s>>>0&15,n[i++]=s>>>4&15,n[i++]=s>>>8&15,n[i++]=s>>>12&15,n[i++]=s>>>16&15,n[i++]=s>>>20&15,n[i++]=s>>>24&15,n[i++]=s>>>28&15}}function LE(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0;n[i++]=t>>>0&31,n[i++]=t>>>5&31,n[i++]=t>>>10&31,n[i++]=t>>>15&31,n[i++]=t>>>20&31,n[i++]=t>>>25&31,n[i++]=(t>>>30|(r&7)<<2)&31,n[i++]=r>>>3&31,n[i++]=r>>>8&31,n[i++]=r>>>13&31,n[i++]=r>>>18&31,n[i++]=r>>>23&31,n[i++]=(r>>>28|(o&1)<<4)&31,n[i++]=o>>>1&31,n[i++]=o>>>6&31,n[i++]=o>>>11&31,n[i++]=o>>>16&31,n[i++]=o>>>21&31,n[i++]=o>>>26&31,n[i++]=(o>>>31|(s&15)<<1)&31,n[i++]=s>>>4&31,n[i++]=s>>>9&31,n[i++]=s>>>14&31,n[i++]=s>>>19&31,n[i++]=s>>>24&31,n[i++]=(s>>>29|(c&3)<<3)&31,n[i++]=c>>>2&31,n[i++]=c>>>7&31,n[i++]=c>>>12&31,n[i++]=c>>>17&31,n[i++]=c>>>22&31,n[i++]=c>>>27&31}}function RE(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0;n[i++]=t>>>0&63,n[i++]=t>>>6&63,n[i++]=t>>>12&63,n[i++]=t>>>18&63,n[i++]=t>>>24&63,n[i++]=(t>>>30|(r&15)<<2)&63,n[i++]=r>>>4&63,n[i++]=r>>>10&63,n[i++]=r>>>16&63,n[i++]=r>>>22&63,n[i++]=(r>>>28|(o&3)<<4)&63,n[i++]=o>>>2&63,n[i++]=o>>>8&63,n[i++]=o>>>14&63,n[i++]=o>>>20&63,n[i++]=o>>>26&63,n[i++]=s>>>0&63,n[i++]=s>>>6&63,n[i++]=s>>>12&63,n[i++]=s>>>18&63,n[i++]=s>>>24&63,n[i++]=(s>>>30|(c&15)<<2)&63,n[i++]=c>>>4&63,n[i++]=c>>>10&63,n[i++]=c>>>16&63,n[i++]=c>>>22&63,n[i++]=(c>>>28|(l&3)<<4)&63,n[i++]=l>>>2&63,n[i++]=l>>>8&63,n[i++]=l>>>14&63,n[i++]=l>>>20&63,n[i++]=l>>>26&63}}function zE(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0,u=e[a++]>>>0;n[i++]=t>>>0&127,n[i++]=t>>>7&127,n[i++]=t>>>14&127,n[i++]=t>>>21&127,n[i++]=(t>>>28|(r&7)<<4)&127,n[i++]=r>>>3&127,n[i++]=r>>>10&127,n[i++]=r>>>17&127,n[i++]=r>>>24&127,n[i++]=(r>>>31|(o&63)<<1)&127,n[i++]=o>>>6&127,n[i++]=o>>>13&127,n[i++]=o>>>20&127,n[i++]=(o>>>27|(s&3)<<5)&127,n[i++]=s>>>2&127,n[i++]=s>>>9&127,n[i++]=s>>>16&127,n[i++]=s>>>23&127,n[i++]=(s>>>30|(c&31)<<2)&127,n[i++]=c>>>5&127,n[i++]=c>>>12&127,n[i++]=c>>>19&127,n[i++]=(c>>>26|(l&1)<<6)&127,n[i++]=l>>>1&127,n[i++]=l>>>8&127,n[i++]=l>>>15&127,n[i++]=l>>>22&127,n[i++]=(l>>>29|(u&15)<<3)&127,n[i++]=u>>>4&127,n[i++]=u>>>11&127,n[i++]=u>>>18&127,n[i++]=u>>>25&127}}function BE(e,t,n,r){let i=r,a=t;for(let t=0;t<8;t++){let t=e[a++]>>>0,r=e[a++]>>>0,o=e[a++]>>>0,s=e[a++]>>>0,c=e[a++]>>>0,l=e[a++]>>>0,u=e[a++]>>>0,d=e[a++]>>>0;n[i++]=t>>>0&255,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=r>>>0&255,n[i++]=r>>>8&255,n[i++]=r>>>16&255,n[i++]=r>>>24&255,n[i++]=o>>>0&255,n[i++]=o>>>8&255,n[i++]=o>>>16&255,n[i++]=o>>>24&255,n[i++]=s>>>0&255,n[i++]=s>>>8&255,n[i++]=s>>>16&255,n[i++]=s>>>24&255,n[i++]=c>>>0&255,n[i++]=c>>>8&255,n[i++]=c>>>16&255,n[i++]=c>>>24&255,n[i++]=l>>>0&255,n[i++]=l>>>8&255,n[i++]=l>>>16&255,n[i++]=l>>>24&255,n[i++]=u>>>0&255,n[i++]=u>>>8&255,n[i++]=u>>>16&255,n[i++]=u>>>24&255,n[i++]=d>>>0&255,n[i++]=d>>>8&255,n[i++]=d>>>16&255,n[i++]=d>>>24&255}}function VE(e,t,n,r){let i=r,a=t;for(let t=0;t<128;t++){let t=e[a++]>>>0;n[i++]=t&65535,n[i++]=t>>>16&65535}}function HE(e,t,n,r,i){let a=hE[i]>>>0,o=t,s=0,c=e[o]>>>0,l=r;for(let t=0;t<8;t++){for(let t=0;t<32;t++)if(s+i<=32){let r=c>>>s&a;n[l+t]=r|0,s+=i,s===32&&(s=0,o++,t!==31&&(c=e[o]>>>0))}else{let r=32-s,u=c>>>s;o++,c=e[o]>>>0;let d=i-r,f=-1>>>32-d>>>0,p=(u|(c&f)<>>0)}}var UE=yE(gE),WE=3*UE/256+UE|0;function GE(){let e=new Uint8Array(WE);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function KE(e=16){if(e<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);let t=Math.max(16,e|0);return{encodedWords:new Uint32Array(t),decoderWorkspace:GE()}}function qE(e,t){if(t<=e.encodedWords.length)return e.encodedWords;let n=new Uint32Array(Math.max(16,t*2));return e.encodedWords=n,n}function JE(e,t,n,r){r.byteContainer.length>>2;if(i.byteOffset&3)for(let n=0;n>>8&255,i[a+2|0]=r>>>16&255,i[a+3|0]=r>>>24&255}else{let n=r.byteContainerI32;(!n||n.buffer!==i.buffer||n.byteOffset!==i.byteOffset||n.length>>2)),n.set(e.subarray(t,t+a))}let o=n&3;if(o>0){let n=e[t+a|0]|0,r=a<<2;for(let e=0;e>>(e<<3)&255}return i}function YE(e,t,n){let r=e[t++]|0,i=n.dataToBePacked;for(let a=2;a<=32;a=a+1|0){if(!(r>>>a-1&1))continue;if(t>=e.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${a}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);let o=e[t++]>>>0,s=vE(o),c=o*a+31>>>5;if(t+c>e.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${a}, size=${o}, streamWordIndex=${t}, needWords=${c}, availableWords=${e.length-t}, encodedWords=${e.length})`);let l=i[a];(!l||l.length>>5)|0,n.exceptionSizes[a]=o}return t}function XE(e,t,n,r,i){switch(i){case 1:NE(e,t,n,r);break;case 2:PE(e,t,n,r);break;case 3:FE(e,t,n,r);break;case 4:IE(e,t,n,r);break;case 5:LE(e,t,n,r);break;case 6:RE(e,t,n,r);break;case 7:zE(e,t,n,r);break;case 8:BE(e,t,n,r);break;case 16:VE(e,t,n,r);break;default:HE(e,t,n,r,i)}return t+(i<<3)|0}function ZE(e,t,n,r){if(n+2>t)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${n}, byteSize=${t})`);let i=e[n++],a=e[n++];if(i>32)throw Error(`FastPFOR decode: invalid bitWidth=${i} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:i,exceptionCount:a,bytePosIn:n}}function QE(e,t,n,r,i,a){if(n+1>t)throw Error(`FastPFOR decode: exception header underflow at block=${a} (need 1 byte for maxBits, bytePos=${n}, byteSize=${t})`);let o=e[n++];if(o32)throw Error(`FastPFOR decode: invalid maxBits=${o} at block=${a} (bitWidth=${r}, expected ${r}..32)`);let s=o-r|0;if(s<1||s>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${s} at block=${a} (bitWidth=${r}, maxBits=${o})`);if(n+i>t)throw Error(`FastPFOR decode: exception positions underflow at block=${a} (need=${i}, have=${t-n})`);return{maxBits:o,exceptionBitWidth:s,bytePosIn:n}}function $E(e,t,n,r,i,a,o,s,c){let{maxBits:l,exceptionBitWidth:u,bytePosIn:d}=QE(i,a,o,n,r,c);if(o=d,u===1){let a=1<h)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${u} (ptr=${m}, need ${r}, size=${h}) at block ${c}`);for(let a=0;a0&&(d=$E(i,f,r,o,s,c,d,l,t))}if(u!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${n}, consumedPackedEnd=${u}, expectedPackedEnd=${r}, packedWords=${r-n}, encoded.length=${e.length})`)}function tD(e,t,n,r,i,a){let o=n|0,s=e[o]|0;if(s<=0||o+s>e.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${s} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);let c=o+1|0,l=o+s|0,u=e[l]>>>0,d=u+3>>>2,f=l+1,p=f+d;if(p>=e.length)throw Error(`FastPFOR decode: invalid byteSize=${u} (metaInts=${d}, pageStart=${o}, packedEnd=${l}, byteContainerStart=${f}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);let m=JE(e,f,u,a),h=u,g=YE(e,p,a);return a.dataPointers.fill(0),eD(e,o,c,l,t,r|0,i/256|0,m,h,a),g}function nD(e,t,n,r,i,a){let o=r+_E(i,256),s=r,c=n;for(;s!==o;){let n=Math.min(UE,o-s);c=tD(e,t,c,s,n,a),s=s+n|0}return c}function rD(e,t,n,r,i,a){if(a===0)return t;let o=0,s=t,c=t+n,l=i,u=i,d=i+a,f=0,p=0;for(;s>>o&255;if(o+=8,s+=o>>>5,o&=31,f|=(t&127)<28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${f}, decoded=${u-l}/${a}, inPos=${s}, inEnd=${c})`)}if(u!==d)throw Error(`FastPFOR VByte: truncated stream (decoded=${u-l}, expected=${a}, consumedWords=${s-t}/${n}, vbyteStart=${t}, vbyteEnd=${c})`);return s}function iD(e,t,n){let r=0,i=0,a=new Uint32Array(t),o=n??GE();if(e.length>0){let t=e[r]|0;if(r=r+1|0,t&255)throw Error(`FastPFOR decode: invalid alignedLength=${t} (expected multiple of 256)`);if(i+t>a.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${i}, alignedLength=${t}, out.length=${a.length})`);r=nD(e,a,r,i,t,o),i=i+t|0}let s=e.length-r|0,c=t-i|0;return rD(e,r,s,a,i,c),a}function aD(e,t,n,r,i){switch(i){case 2:xE(e,t,n,r);return;case 3:SE(e,t,n,r);return;case 4:CE(e,t,n,r);return;case 5:wE(e,t,n,r);return;case 6:TE(e,t,n,r);return;case 7:EE(e,t,n,r);return;case 8:DE(e,t,n,r);return;case 9:OE(e,t,n,r);return;case 10:kE(e,t,n,r);return;case 11:AE(e,t,n,r);return;case 12:jE(e,t,n,r);return;case 16:ME(e,t,n,r);return;case 32:for(let i=0;i<32;i=i+1|0)n[r+i|0]=e[t+i|0]|0;return}let a=hE[i]>>>0,o=t,s=0,c=e[o]>>>0;for(let t=0;t<32;t++)if(s+i<=32){let l=c>>>s&a;n[r+t]=l|0,s+=i,s===32&&(s=0,o++,t!==31&&(c=e[o]>>>0))}else{let l=32-s,u=c>>>s;o++,c=e[o]>>>0;let d=hE[i-l]>>>0,f=(u|(c&d)<e.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${n}, bytes.length=${e.length})`);let i=Math.floor(n/4),a=n%4!=0,o=a?i+1:i;if(r.length0){let n=e.byteOffset+t;if(n&3)for(let n=0;n=64)throw Error(`Varint too long`)}return t.set(i),n}function uD(e,t,n){let r=t.get();if(n>e.length-r)throw dD(e,n);let i=new Float64Array(n);for(let t=0;t>4;for(let t=3;n>=128;t+=7){if(t>31)throw Error(`Expected varint not more than 10 bytes`);n=e[r++],o|=(n&127)<>>0)*4294967296+(a>>>0)}if(r>e.length)throw dD(e,n);return t.set(r),i}function dD(e,t){return Error(`Unexpected end of buffer while decoding varints (expected ${t} values, buffer length ${e.length})`)}function fD(e,t,n,r){return pD(e,t,n,r,KE(n>>>2))}function pD(e,t,n,r,i){let a=r.get();if(n&3)throw Error(`FastPFOR: invalid encodedByteLength=${n} at offset=${a} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let o=n>>>2,s=qE(i,o);oD(e,a,n,s);let c=iD(s.subarray(0,o),t,i.decoderWorkspace);return r.add(n),c}function mD(e){return e>>>1^-(e&1)}function hD(e){return e>>1n^-(e&1n)}function gD(e){return e%2==1?(e+1)/-2:e/2}function _D(e){let t=new Int32Array(e.length);for(let n=0;n=4)for(;r=4)for(;r=4)for(;n=4)for(let r=e[0];n=4)for(;r=4)for(;c>>0;for(let n=1;n>>0;return t}function BD(e){let t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,hD(e[0]));for(let n=1;n>>0,t[1]=mD(e[1])>>>0;for(let n=2;n>>0,t[n+1]=t[n-1]+mD(e[n+1])>>>0;return t}function HD(e,t,n,r){let i=MD(e,t,n,r);return new Uint32Array(i)}function UD(e){return e[1]}function WD(e){return mD(e[1])}function GD(e){if(e.length===2){let t=mD(e[1]);return[t,t]}return[mD(e[2]),mD(e[3])]}function KD(e){return e[1]}function qD(e){return hD(e[1])}function JD(e){if(e.length===2){let t=hD(e[1]);return[t,t]}return[hD(e[2]),hD(e[3])]}var YD;(function(e){e.PRESENT=`PRESENT`,e.DATA=`DATA`,e.OFFSET=`OFFSET`,e.LENGTH=`LENGTH`})(YD||={});var XD;(function(e){e.NONE=`NONE`,e.SINGLE=`SINGLE`,e.SHARED=`SHARED`,e.VERTEX=`VERTEX`,e.MORTON=`MORTON`,e.FSST=`FSST`})(XD||={});var ZD;(function(e){e.VERTEX=`VERTEX`,e.INDEX=`INDEX`,e.STRING=`STRING`,e.KEY=`KEY`})(ZD||={});var QD;(function(e){e.VAR_BINARY=`VAR_BINARY`,e.GEOMETRIES=`GEOMETRIES`,e.PARTS=`PARTS`,e.RINGS=`RINGS`,e.TRIANGLES=`TRIANGLES`,e.SYMBOL=`SYMBOL`,e.DICTIONARY=`DICTIONARY`})(QD||={});var $D=[YD.PRESENT,YD.DATA,YD.OFFSET,YD.LENGTH],eO=[fE.NONE,fE.DELTA,fE.COMPONENTWISE_DELTA,fE.RLE,fE.MORTON],tO=[pE.NONE,pE.FAST_PFOR,pE.VARINT],nO=[XD.NONE,XD.SINGLE,XD.SHARED,XD.VERTEX,XD.MORTON,XD.FSST],rO=[ZD.VERTEX,ZD.INDEX,ZD.STRING,ZD.KEY],iO=[QD.VAR_BINARY,QD.GEOMETRIES,QD.PARTS,QD.RINGS,QD.TRIANGLES,QD.SYMBOL,QD.DICTIONARY];function aO(e,t){let n=cO(e,t);return n.logicalLevelTechnique1===fE.MORTON?oO(n,e,t):(fE.RLE===n.logicalLevelTechnique1||fE.RLE===n.logicalLevelTechnique2)&&pE.NONE!==n.physicalLevelTechnique?sO(n,e,t):n}function oO(e,t,n){let r=sD(t,n,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:r[0],coordinateShift:r[1]}}function sO(e,t,n){let r=sD(t,n,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}function cO(e,t){let n=e[t.get()],r=$D[n>>4],i={};switch(r){case YD.DATA:i={dictionaryType:nO[n&15]};break;case YD.OFFSET:i={offsetType:rO[n&15]};break;case YD.LENGTH:i={lengthType:iO[n&15]}}t.increment();let a=e[t.get()],o=eO[a>>5],s=eO[a>>2&7],c=tO[a&3];t.increment();let l=sD(e,t,2),u=l[0],d=l[1];return{physicalStreamType:r,logicalStreamType:i,logicalLevelTechnique1:o,logicalLevelTechnique2:s,physicalLevelTechnique:c,numValues:u,byteLength:d,decompressedCount:u}}var lO;(function(e){e[e.FLAT=0]=`FLAT`,e[e.CONST=1]=`CONST`,e[e.SEQUENCE=2]=`SEQUENCE`,e[e.DICTIONARY=3]=`DICTIONARY`,e[e.FSST_DICTIONARY=4]=`FSST_DICTIONARY`})(lO||={});var uO=class{constructor(e,t){this.values=e,this._size=t}get(e){let t=Math.floor(e/8),n=e%8;return(this.values[t]>>n&1)==1}set(e,t){let n=Math.floor(e/8),r=e%8;this.values[n]=this.values[n]|+!!t<>n&1}size(){return this._size}getBuffer(){return this.values}};function dO(e,t,n){if(!t)return e;let r=t.size(),i=new e.constructor(r);n!==0&&n!==0n&&i.fill(n);let a=t.getBuffer(),o=r+7>>3,s=255>>(o<<3)-r,c=0;for(let t=0;t=o);){let n=e[r.increment()];if(n<=127){let o=n+3,s=e[r.increment()],c=Math.min(a+o,t);i.fill(s,a,c),a=c}else{let o=256-n;for(let n=0;n=12?bO.decode(e.subarray(t,n)):SO(e,t,n)}function SO(e,t,n){let r=``,i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+o>n)break;let s,c,l;o===1?t<128&&(a=t):o===2?(s=e[i+1],(s&192)==128&&(a=(t&31)<<6|s&63,a<=127&&(a=null))):o===3?(s=e[i+1],c=e[i+2],(s&192)==128&&(c&192)==128&&(a=(t&15)<<12|(s&63)<<6|c&63,(a<=2047||a>=55296&&a<=57343)&&(a=null))):o===4&&(s=e[i+1],c=e[i+2],l=e[i+3],(s&192)==128&&(c&192)==128&&(l&192)==128&&(a=(t&15)<<18|(s&63)<<12|(c&63)<<6|l&63,(a<=65535||a>=1114112)&&(a=null))),a===null?(a=65533,o=1):a>65535&&(a-=65536,r+=String.fromCharCode(a>>>10&1023|55296),a=56320|a&1023),r+=String.fromCharCode(a),i+=o}return r}function CO(e,t,n,r,i){return RO(EO(e,t,n),n,r,i)}function wO(e,t,n,r,i){return zO(EO(e,t,n),n,r,i)}function TO(e,t,n){return UO(EO(e,t,n),n)}function EO(e,t,n){let r=n.physicalLevelTechnique;switch(r){case pE.FAST_PFOR:return fD(e,n.numValues,n.byteLength,t);case pE.VARINT:return sD(e,t,n.numValues);case pE.NONE:return vO(e,t,n.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function DO(e,t,n){let r=n.physicalLevelTechnique;switch(r){case pE.VARINT:return cD(e,t,n.numValues);case pE.NONE:return yO(e,t,n.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function OO(e,t,n){let r=EO(e,t,n);return r.length===1?mD(r[0]):WD(r)}function kO(e,t,n){let r=EO(e,t,n);return r.length===1?n.logicalLevelTechnique1===fE.DELTA?mD(r[0]):r[0]:UD(r)}function AO(e,t,n){return GD(EO(e,t,n))}function jO(e,t,n){return JD(cD(e,t,n.numValues))}function MO(e,t,n,r){return BO(DO(e,t,n),n,r)}function NO(e,t,n,r){return VO(DO(e,t,n),n,r)}function PO(e,t,n,r){let i=FO(e,t,n,!1);return r?dO(i,r,0):i}function FO(e,t,n,r){if(n.physicalLevelTechnique===pE.VARINT)return HO(uD(e,t,n.numValues),n,r);let i=DO(e,t,n),a=r?BO(i,n):VO(i,n);return Float64Array.from(a,Number)}function IO(e,t,n){let r=DO(e,t,n);return r.length===1?hD(r[0]):qD(r)}function LO(e,t,n){let r=DO(e,t,n);return r.length===1?n.logicalLevelTechnique1===fE.DELTA?hD(r[0]):r[0]:KD(r)}function RO(e,t,n,r){let i;switch(t.logicalLevelTechnique1){case fE.DELTA:if(t.logicalLevelTechnique2===fE.RLE){let n=t;if(!r)return LD(e,n.runs,n.numRleValues);e=bD(e,n.runs,n.numRleValues),i=CD(e)}else i=CD(e);break;case fE.RLE:i=ED(e,t.runs,t.numRleValues);break;case fE.MORTON:kD(e),i=new Int32Array(e);break;case fE.COMPONENTWISE_DELTA:if(n&&!r)return MD(e,n.scale,n.min,n.max);i=jD(e);break;case fE.NONE:i=_D(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?dO(i,r,0):i}function zO(e,t,n,r){let i;switch(t.logicalLevelTechnique1){case fE.DELTA:if(t.logicalLevelTechnique2===fE.RLE){let n=t;i=zD(bD(e,n.runs,n.numRleValues))}else i=zD(e);break;case fE.RLE:i=bD(e,t.runs,t.numRleValues);break;case fE.MORTON:kD(e),i=e;break;case fE.COMPONENTWISE_DELTA:i=n&&!r?HD(e,n.scale,n.min,n.max):VD(e);break;case fE.NONE:i=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?dO(i,r,0):i}function BO(e,t,n){let r;switch(t.logicalLevelTechnique1){case fE.DELTA:if(t.logicalLevelTechnique2===fE.RLE){let i=t;if(!n)return RD(e,i.runs,i.numRleValues);e=xD(e,i.runs,i.numRleValues),r=wD(e)}else r=wD(e);break;case fE.RLE:r=DD(e,t.runs,t.numRleValues);break;case fE.NONE:r=vD(e);break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return n?dO(r,n,0n):r}function VO(e,t,n){let r;switch(t.logicalLevelTechnique1){case fE.DELTA:if(t.logicalLevelTechnique2===fE.RLE){let n=t;r=BD(xD(e,n.runs,n.numRleValues))}else r=BD(e);break;case fE.RLE:r=xD(e,t.runs,t.numRleValues);break;case fE.NONE:r=e;break;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return n?dO(r,n,0n):r}function HO(e,t,n){switch(t.logicalLevelTechnique1){case fE.DELTA:if(t.logicalLevelTechnique2===fE.RLE){let n=t;e=SD(e,n.runs,n.numRleValues)}return TD(e),e;case fE.RLE:return KO(e,t,n);case fE.NONE:return n&&yD(e),e;default:throw Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}function UO(e,t){if(t.logicalLevelTechnique1===fE.DELTA&&t.logicalLevelTechnique2===fE.NONE)return PD(e);if(t.logicalLevelTechnique1===fE.RLE&&t.logicalLevelTechnique2===fE.NONE){let n=t;return ID(e,n.runs,n.numRleValues)}if(t.logicalLevelTechnique1===fE.NONE&&t.logicalLevelTechnique2===fE.NONE){AD(e);let n=new Uint32Array(t.numValues+1);return n[0]=0,n.set(e,1),n}if(t.logicalLevelTechnique1===fE.DELTA&&t.logicalLevelTechnique2===fE.RLE){let n=t,r=FD(e,n.runs,n.numRleValues);return kD(r),new Uint32Array(r)}throw Error(`Only delta encoding is supported for transforming length to offset streams yet.`)}function WO(e,t,n,r,i=`int32`){let a=e.logicalLevelTechnique1;if(a===fE.RLE)return e.runs===1?lO.CONST:lO.FLAT;if(a!==fE.DELTA||e.logicalLevelTechnique2!==fE.RLE)return e.numValues===1?lO.CONST:lO.FLAT;let o=t instanceof uO?t.size():t,s=e;if(s.numRleValues!==o)return lO.FLAT;if(s.runs===1)return lO.SEQUENCE;if(s.runs!==2)return e.numValues===1?lO.CONST:lO.FLAT;let c=r.get();if(e.physicalLevelTechnique===pE.VARINT)return GO(n,r,i)?lO.SEQUENCE:e.numValues===1?lO.CONST:lO.FLAT;let l=EO(n,r,e);return r.set(c),l[2]===2&&l[3]===2?lO.SEQUENCE:e.numValues===1?lO.CONST:lO.FLAT}function GO(e,t,n){let r=new dE(t.get());if(n===`int64`){let t=cD(e,r,4);return t[2]===2n&&t[3]===2n}let i=sD(e,r,4);return i[2]===2&&i[3]===2}function KO(e,t,n){return n?OD(e,t.runs,t.numRleValues):SD(e,t.runs,t.numRleValues)}var qO=class extends eE{getValueFromBuffer(e){return this.dataBuffer[e]}},JO=class extends rE{constructor(e,t,n,r,i){super(e,i?BigInt64Array.of(t):BigUint64Array.of(t),n,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}};function YO(e,t,n){return{x:XO(e,t)-n,y:XO(e>>1,t)-n}}function XO(e,t){let n=0;for(let r=0;r>r;return n}var ZO;(function(e){e[e.POINT=0]=`POINT`,e[e.LINESTRING=1]=`LINESTRING`,e[e.POLYGON=2]=`POLYGON`,e[e.MULTIPOINT=3]=`MULTIPOINT`,e[e.MULTILINESTRING=4]=`MULTILINESTRING`,e[e.MULTIPOLYGON=5]=`MULTIPOLYGON`})(ZO||={});var QO;(function(e){e[e.POINT=0]=`POINT`,e[e.LINESTRING=1]=`LINESTRING`,e[e.POLYGON=2]=`POLYGON`})(QO||={});var $O;(function(e){e[e.MORTON=0]=`MORTON`,e[e.VEC_2=1]=`VEC_2`,e[e.VEC_3=2]=`VEC_3`})($O||={});function ek(e){let t=Array(e.numGeometries),n=1,r=1,i=1,a=0,o=0,s=0,c=e.mortonSettings,l=e.topologyVector,u=l.geometryOffsets,d=l.partOffsets,f=l.ringOffsets,p=e.vertexOffsets,m=!p||p.length===0,h=e.containsPolygonGeometry(),g=e.vertexBuffer;for(let l=0;l[e]),n+=l,r+=l}break;case ZO.LINESTRING:{let l;h?(l=f[r]-f[r-1],r++):l=d[n]-d[n-1],n++;let _;m?(_=nk(g,o,l,!1),o+=l*2):(_=tk(e.vertexBufferType,g,p,s,l,!1,c),s+=l),t[a++]=[_],u&&i++}break;case ZO.POLYGON:{let l=d[n]-d[n-1];n++;let h=Array(l-1),_,v=f[r]-f[r-1];if(r++,m){_=nk(g,o,v,!0),o+=v*2;for(let e=0;en?t[a++]:1);return r}function yk(e,t,n,r){let i=new Uint32Array(t[t.length-1]+1),a=0;i[0]=a;let o=1,s=0;for(let c=0;c0;)i[a++]=e[o++]}}return i}var Ak=class extends Tk{constructor(e,t,n,r,i,a,o,s){super(e,n,r,o??t.length),this.indexBuffer=t,this.symbolOffsetBuffer=i,this.symbolTableBuffer=a,this.sharedDictionaryCache=s}getValueFromBuffer(e){this.decodedDictionary??(this.decodedDictionary=this.sharedDictionaryCache?.decodedDictionary,this.decodedDictionary??(this.decodedDictionary=this.decodeDictionary(),this.sharedDictionaryCache&&(this.sharedDictionaryCache.decodedDictionary=this.decodedDictionary)));let t=this.indexBuffer[e],n=this.offsetBuffer[t],r=this.offsetBuffer[t+1];return xO(this.decodedDictionary,n,r)}decodeDictionary(){return this.symbolLengthBuffer??=this.offsetToLengthBuffer(this.symbolOffsetBuffer),kk(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer)}offsetToLengthBuffer(e){let t=new Uint32Array(e.length-1),n=e[0];for(let r=1;r1&&!c.nullable||l===1&&c.nullable)throw Error(`The number of streams for the child field ${c.name} does not match its nullability. nullibilty: ${c.nullable}, numStreams: ${l}`);let m;if(c.nullable){let n=aO(e,t);m=new uO(mO(e,n.numValues,n.byteLength,t),n.numValues)}let h=wO(e,t,aO(e,t),void 0,m);if(s){if(!o)throw Error(`Incomplete shared FSST dictionary for column "${p}"`);u[f++]=new Ak(p,h,i,a,o,s,m,d)}else u[f++]=new Dk(p,h,i,a,m)}return u}var Ik=class extends $T{constructor(e,t,n){super(e,new Uint8Array,n??t.length),this.values=t}getValueFromBuffer(e){return this.values[e]}},Lk;(function(e){e[e.STRING=1]=`STRING`,e[e.INT32=2]=`INT32`,e[e.UINT32=4]=`UINT32`,e[e.INT64=8]=`INT64`,e[e.UINT64=16]=`UINT64`,e[e.FLOAT=32]=`FLOAT`,e[e.DOUBLE=64]=`DOUBLE`,e[e.PRESENCE=128]=`PRESENCE`})(Lk||={});var Rk;(function(e){e[e.FALSE=0]=`FALSE`,e[e.TRUE=1]=`TRUE`,e[e.START_MAP=2]=`START_MAP`,e[e.START_LIST=3]=`START_LIST`,e[e.COUNT=4]=`COUNT`})(Rk||={});function zk(e,t,n,r){let i=Bk(n);if(r===0)return i.map(e=>new Ik(e,[]));let a=Vk(e,t,r),o=(a.presentStream?a.presentCount:a.lengthStream.length)/i.length,s=[],c=0,l=0;for(let e=0;ee.name+(t.name??``))}function Vk(e,t,n){let r=e[t.get()];t.add(1);let i=wO(e,t,aO(e,t)),a=n-1,o=[];r&Lk.STRING&&(a-=Hk(e,t,o)),a-=Uk(e,t,r,o),a-=Wk(e,t,r,o);let s,c=0;if(r&Lk.PRESENCE){let n=Gk(e,t);s=n.value,c=n.count,a--}let l=new Uint32Array;if(a>0&&(l=wO(e,t,aO(e,t)),a--),a!==0)throw Error(`Unexpected number of remaining streams while decoding map column: ${a}`);return{lengthStream:i,dictionary:o,presentStream:s,presentCount:c,flattenedValues:l}}function Hk(e,t,n){let r=e[t.get()];t.add(1);let i=jk(``,e,t,r);if(i)for(let e=0;ea.length)throw Error(`Merged map counts underflow while decoding child streams`);let p=Array(n),m=r,h=i;for(let e=0;eo.length)throw Error(`Map value stream underflow while decoding feature payload`);let n=qk(o,h,t,c);p[e]=n.value,h=n.nextIndex}let g=0;for(let e=r;e=n)throw Error(`Unexpected end of map value stream`);let i=e[t];if(i===Rk.FALSE)return{value:!1,nextIndex:t+1};if(i===Rk.TRUE)return{value:!0,nextIndex:t+1};if(i===Rk.START_MAP){let i=Xk(e,t,n);return{value:Jk(e,t+2,i,r).value,nextIndex:i}}if(i===Rk.START_LIST){let i=Xk(e,t,n),a=[],o=t+2;for(;o=n)throw Error(`Missing length for nested map/list payload`);let r=e[t+1];if(r<2)throw Error(`Invalid nested payload length: ${r}`);let i=t+r;if(i>n)throw Error(`Nested payload exceeds containing payload bounds`);return i}function Zk(e,t){let n=e-Rk.COUNT;if(n<0||n>=t.length)throw Error(`Scalar dictionary index out of range: ${e}`);return t[n]}function Qk(e,t){for(let n of t)e.push(n)}function $k(e,t,n,r,i,a){return n.type===`scalarType`?a&&!a.has(n.name)?(pO(r,e,t),null):eA(r,e,t,i,n.scalarType,n):n.complexType?.physicalType===lE.MAP?zk(e,t,n,r):r===0?null:Fk(e,t,n,a)}function eA(e,t,n,r,i,a){let o;if(e===0)return null;if(a.nullable){let e=aO(t,n),r=e.numValues,i=n.get(),a=mO(t,r,e.byteLength,n);n.set(i+e.byteLength),o=new uO(a,e.numValues)}let s=o??r;switch(i.physicalType){case cE.UINT_32:case cE.INT_32:return aA(t,n,a,i,s);case cE.STRING:{let r=a.nullable?e-1:e;return jk(a.name,t,n,r,o)??null}case cE.BOOLEAN:return tA(t,n,a,r,s);case cE.UINT_64:case cE.INT_64:return iA(t,n,a,s,i);case cE.FLOAT:return nA(t,n,a,s);case cE.DOUBLE:return rA(t,n,a,s);default:throw Error(`The specified data type for the field is currently not supported: ${i}`)}}function tA(e,t,n,r,i){let a=aO(e,t),o=a.numValues,s=t.get(),c=oA(i)?i:void 0,l=mO(e,o,a.byteLength,t,c);t.set(s+a.byteLength);let u=new uO(l,o);return new Sk(n.name,u,i)}function nA(e,t,n,r){let i=aO(e,t),a=oA(r)?r:void 0,o=gO(e,t,i.numValues,a);return new Ck(n.name,o,r)}function rA(e,t,n,r){let i=aO(e,t),a=oA(r)?r:void 0,o=_O(e,t,i.numValues,a);return new nE(n.name,o,r)}function iA(e,t,n,r,i){let a=aO(e,t),o=WO(a,r,e,t,`int64`),s=i.physicalType===cE.INT_64;if(o===lO.FLAT){let i=oA(r)?r:void 0,o=s?MO(e,t,a,i):NO(e,t,a,i);return new qO(n.name,o,r)}if(o===lO.SEQUENCE){let r=jO(e,t,a);return new JO(n.name,r[0],r[1],a.numRleValues,s)}let c=s?IO(e,t,a):LO(e,t,a);return new wk(n.name,c,r,s)}function aA(e,t,n,r,i){let a=aO(e,t),o=WO(a,i,e,t),s=r.physicalType===cE.INT_32;if(o===lO.FLAT){let r=oA(i)?i:void 0,o=s?CO(e,t,a,void 0,r):wO(e,t,a,void 0,r);return new tE(n.name,o,i)}if(o===lO.SEQUENCE){let r=AO(e,t,a);return new iE(n.name,r[0],r[1],a.numRleValues,s)}let c=s?OO(e,t,a):kO(e,t,a);return new aE(n.name,c,i,s)}function oA(e){return e instanceof uO}var sA={ID:0,ID_NULLABLE:1,ID_LONG:2,GEOMETRY:4,SCALAR_BASE:10,STRUCT:30,MAP:31};function cA(e){switch(e){case sA.ID:case sA.ID|sA.ID_NULLABLE:case sA.ID|sA.ID_LONG:case sA.ID|sA.ID_LONG|sA.ID_NULLABLE:return{nullable:(e&sA.ID_NULLABLE)!==0,columnScope:sE.FEATURE,type:`scalarType`,scalarType:{longID:(e&sA.ID_LONG)!==0,type:`logicalType`,logicalType:uE.ID}};case sA.GEOMETRY:return{nullable:!1,columnScope:sE.FEATURE,type:`complexType`,complexType:{type:`physicalType`,physicalType:lE.GEOMETRY,children:[]}};case sA.STRUCT:return{nullable:!1,columnScope:sE.FEATURE,type:`complexType`,complexType:{type:`physicalType`,physicalType:lE.STRUCT,children:[]}};case sA.MAP:return{nullable:!0,columnScope:sE.FEATURE,type:`complexType`,complexType:{type:`physicalType`,physicalType:lE.MAP,children:[]}};default:return mA(e)}}function lA(e){return e>=sA.SCALAR_BASE}function uA(e){return e===sA.STRUCT||e===sA.MAP}function dA(e){if(e.type===`scalarType`){let t=e.scalarType;if(t.type===`physicalType`)switch(t.physicalType){case cE.BOOLEAN:case cE.INT_8:case cE.UINT_8:case cE.INT_32:case cE.UINT_32:case cE.INT_64:case cE.UINT_64:case cE.FLOAT:case cE.DOUBLE:return!1;case cE.STRING:return!0;default:return!1}if(t.type===`logicalType`)return!1}else if(e.type===`complexType`){let t=e.complexType;if(t.type===`physicalType`)switch(t.physicalType){case lE.GEOMETRY:case lE.STRUCT:case lE.MAP:return!0;default:return!1}}return console.warn(`Unexpected column type in hasStreamCount`,e),!1}function fA(e){return e.type===`scalarType`&&e.scalarType?.type===`logicalType`&&e.scalarType.logicalType===uE.ID}function pA(e){return e.type===`complexType`&&e.complexType?.type===`physicalType`&&e.complexType.physicalType===lE.GEOMETRY}function mA(e){let t;switch(e){case 10:case 11:t=cE.BOOLEAN;break;case 12:case 13:t=cE.INT_8;break;case 14:case 15:t=cE.UINT_8;break;case 16:case 17:t=cE.INT_32;break;case 18:case 19:t=cE.UINT_32;break;case 20:case 21:t=cE.INT_64;break;case 22:case 23:t=cE.UINT_64;break;case 24:case 25:t=cE.FLOAT;break;case 26:case 27:t=cE.DOUBLE;break;case 28:case 29:t=cE.STRING;break;default:return null}return{nullable:!!(e&1),columnScope:sE.FEATURE,type:`scalarType`,scalarType:{longID:!1,type:`physicalType`,physicalType:t}}}var hA=new TextDecoder(`utf-8`,{ignoreBOM:!0}),gA=`0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)`;function _A(e,t){let n=sD(e,t,1)[0];if(n===0)return``;let r=t.get(),i=r+n,a=e.subarray(r,i);return t.add(n),hA.decode(a)}function vA(e){let t=e.name,n=e.nullable;return e.type===`scalarType`?{type:`scalarField`,scalarField:e.scalarType,name:t,nullable:n}:{type:`complexField`,complexField:e.complexType,name:t,nullable:n}}function yA(e,t){let n=sD(e,t,1)[0]>>>0,r=n>=sA.SCALAR_BASE?cA(n):null;if(!r)throw Error(`Unsupported field type code ${n}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let i={...r,name:_A(e,t)};if(i.type===`complexType`&&uA(n)){let n=i.complexType,r=sD(e,t,1)[0]>>>0;n.children=Array(r);for(let i=0;i>>0,r=cA(n);if(!r)throw Error(`Unsupported column type code ${n}. Supported: ${gA}`);let i;if(lA(n))i=_A(e,t);else if(n>>0,r=a.complexType;r.children=Array(n);for(let i=0;i>>0,a=sD(e,t,1)[0]>>>0;r.columns=Array(a);for(let n=0;n>>0,o=r.get()+a;if(o>e.length)throw Error(`Block overruns tile: ${o} > ${e.length}`);let s=sD(e,r,1)[0]>>>0;if(s!==1&&s!==2){r.set(o);continue}let[c,l]=xA(e,r),u=c.featureTables[0],d=null,f=null,p=[],m=0;for(let i of u.columns){let a=i.name;if(fA(i)){let t=null;if(i.nullable){let n=aO(e,r),i=r.get(),a=mO(e,n.numValues,n.byteLength,r);r.set(i+n.byteLength),t=new uO(a,n.numValues)}let o=aO(e,r);m=t?t.size():o.decompressedCount,d=CA(e,i,r,a,o,t??m,n)}else if(pA(i)){let n=sD(e,r,1)[0];if(m===0){let t=r.get();m=aO(e,r).decompressedCount,r.set(t)}t&&(t.scale=t.extent/l),f=_k(e,n,r,m,t)}else{let t=dA(i)?sD(e,r,1)[0]:1;if(t===0)continue;let n=$k(e,r,i,t,m,void 0);if(n){if(Array.isArray(n))for(let e of n)p.push(e);else p.push(n)}}}let h=new oE(u.name,f,d,p,l);i.push(h),r.set(o)}return i}function CA(e,t,n,r,i,a,o=!1){let s=t.scalarType?.longID?cE.UINT_64:cE.UINT_32,c=typeof a==`number`?void 0:a,l=WO(i,a,e,n,s===cE.UINT_64?`int64`:`int32`);if(s===cE.UINT_32)switch(l){case lO.FLAT:return new tE(r,wO(e,n,i,void 0,c),a);case lO.SEQUENCE:{let t=AO(e,n,i);return new iE(r,t[0],t[1],i.numRleValues,!1)}case lO.CONST:return new aE(r,kO(e,n,i),a,!1)}switch(l){case lO.FLAT:return o?new nE(r,PO(e,n,i,c),a):new qO(r,NO(e,n,i,c),a);case lO.SEQUENCE:{let t=jO(e,n,i);return new JO(r,t[0],t[1],i.numRleValues,!1)}case lO.CONST:return new wk(r,LO(e,n,i),a,!1)}throw Error(`Vector type not supported for id column.`)}new TextEncoder;var wA=yE(gE);wA/32*4,3*wA/256+wA|0,BigInt(2**53-1);function TA(e){let t={};for(let n in e){let r=e[n];t[n]=typeof r==`bigint`?Number(r):r}return t}var EA=class{constructor(e,t){switch(this._featureData=e,this.properties=TA(this._featureData.properties),this._featureData.geometry?.type){case ZO.POINT:case ZO.MULTIPOINT:this.type=1;break;case ZO.LINESTRING:case ZO.MULTILINESTRING:this.type=2;break;case ZO.POLYGON:case ZO.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){let e=[];for(let t of this._featureData.geometry.coordinates){let n=[];for(let e of t)n.push(new U(e.x,e.y));e.push(n)}return e}},DA=class{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new EA(this.features[e],this.extent)}},OA=class{constructor(e){this.layers={};let t=SA(new Uint8Array(e));this.layers=t.reduce((e,t)=>({...e,[t.name]:new DA(t)}),{})}};Y(`FeatureIndex`,class{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new u_(W,16,0),this.grid3D=new u_(W,16,0),this.featureIndexArray=new b6,this.promoteId=t}insert(e,t,n,r,i,a){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,r,i);let s=a?this.grid3D:this.grid;for(let e of t){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)t[0]=Math.min(t[0],n.x),t[1]=Math.min(t[1],n.y),t[2]=Math.max(t[2],n.x),t[3]=Math.max(t[3],n.y);t[0]<8192&&t[1]<8192&&t[2]>=0&&t[3]>=0&&s.insert(o,t[0],t[1],t[2],t[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=this.encoding===`mlt`?new OA(this.rawTileData).layers:new _7(new AS(this.rawTileData)).layers,this.sourceLayerCoder=new ZT(this.vtLayers?Object.keys(this.vtLayers).sort():[XT])),this.vtLayers}query(e,t,n,r){this.loadVTLayers();let i=e.params,a=W/e.tileSize/e.scale,o=Xy(i.filter,`queryRenderedFeatures filter`,i.globalState),s=e.queryGeometry,c=e.queryPadding*a,l=Ob.fromPoints(s),u=this.grid.query(l.minX-c,l.minY-c,l.maxX+c,l.maxY+c),d=Ob.fromPoints(e.cameraQueryGeometry).expandBy(c),f=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,n,r,i)=>qb(e.cameraQueryGeometry,t-c,n-c,r+c,i+c));for(let e of f)u.push(e);u.sort(MA);let p={},m;for(let c of u){if(c===m)continue;m=c;let l=this.featureIndexArray.get(c),u=null;this.loadMatchingFeature(p,l.bucketIndex,l.sourceLayerIndex,l.featureIndex,o,i.layers,i.availableImages,t,n,e.worldCoordinateHelper,r,(t,n,r)=>(u||=Eb(t),n.queryIntersectsFeature({queryGeometry:s,feature:t,featureState:r,geometry:u,zoom:this.z,projectedCamera:e.projectedCamera,pixelsToTileUnits:a,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return p}loadMatchingFeature(e,t,n,r,i,a,o,s,c,l,u,d){let f=this.bucketLayerIDs[t];if(a&&!f.some(e=>a.has(e)))return;let p=this.sourceLayerCoder.decode(n),m=this.vtLayers[p].feature(r),h=this.getId(m,p);this.setPromotedId(m,p,h);let g=this.tileID.canonical,_=i.needGeometry?kA(m):void 0;if(!i.filter(new F4(this.tileID.overscaledZ),_??m,g))return;let v=_??kA(m);for(let t of f){if(a&&!a.has(t))continue;let n=s[t];if(!n)continue;let i={};h&&u&&(i=u.getState(n.sourceLayer||`_geojsonTileLayer`,h));let f={...c[t]};f.paint=jA(f.paint,n.paint,v,i,g,o),f.layout=jA(f.layout,n.layout,v,i,g,o);let p=!d||d(m,n,i);if(!p)continue;let _=new QT(m,this.z,this.x,this.y,h,l);_.layer=f;let y=e[t];y===void 0&&(y=e[t]=[]),y.push({featureIndex:r,feature:_,intersectionZ:p})}}lookupSymbolFeatures(e,t,n,r,i,a,o,s){let c={};this.loadVTLayers();let l=Xy(i.filterSpec,`queryRenderedFeatures symbol filter`,i.globalState);for(let u of e)this.loadMatchingFeature(c,n,r,u,l,a,o,s,t,i.worldCoordinateHelper);return c}hasLayer(e){for(let t of this.bucketLayerIDs)for(let n of t)if(e===n)return!0;return!1}getId(e,t){let n=e.id;if(this.promoteId){let r=typeof this.promoteId==`string`?this.promoteId:this.promoteId[t];n=e.properties[r],typeof n==`boolean`&&(n=Number(n)),n===void 0&&e.properties?.cluster&&this.promoteId&&(n=Number(e.properties.cluster_id))}return n}setPromotedId(e,t,n){this.promoteId&&t===`_geojsonTileLayer`&&n!==void 0&&(e.id=n)}},{omit:[`rawTileData`,`sourceLayerCoder`]});function kA(e){let t=Db(e,!0);return t.geometry.some(e=>e.length>0)?t:e}function AA(e){return typeof e==`object`&&!!e&&`evaluate`in e}function jA(e,t,n,r,i,a){return Object.fromEntries(Object.keys(e??{}).map(e=>{let o=t instanceof U4?t.get(e):null;return[e,AA(o)?o.evaluate(n,r,i,a):o]}))}function MA(e,t){return t-e}var NA=`RTLPluginLoaded`,PA=class extends l_{constructor(){super(),this.status=`unavailable`,this.url=null,this.dispatcher=T4(),this.dispatcher.on(`workerscreate`,()=>this._resyncWorkers())}async _resyncWorkers(){try{this.status===`deferred`?await this._syncState(`deferred`):this.status===`loaded`&&await this._requestImport()}catch(e){ig(`Failed to load the RTL text plugin into the new workers: ${e}`)}}_syncState(e){return this.status=e,this.dispatcher.broadcast(`SRPS`,{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status=`error`,e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status=`unavailable`,this.url=null}async setRTLTextPlugin(e,t=!1){if(this.url)throw Error(`setRTLTextPlugin cannot be called multiple times.`);if(this.url=Pg.resolveURL(e),!this.url)throw Error(`requested url ${e} is invalid`);if(this.status===`unavailable`){if(t)this.status=`deferred`,this._syncState(this.status);else return this._requestImport()}else if(this.status===`requested`)return this._requestImport()}async _requestImport(){await this._syncState(`loading`),this.status=`loaded`,this.fire(new s_(NA))}lazyLoad(){this.status===`unavailable`?this.status=`requested`:this.status===`deferred`&&this._requestImport()}},FA=null;function IA(){return FA||=new PA,FA}var LA=class{constructor(e,t){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=Jh(),this.uses=0,this.tileSize=t,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state=`loading`,this.featureStateRevision=-1}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadingDirection!==0||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:n,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=n,this.fadeEndTime=r}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=Ig(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state===`errored`||this.state===`loaded`||this.state===`reloading`}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(e){return this.rttObjects[e]}acquireRTT(e,t,n){return this.rttObjects[t]=e.acquireRTT(n)}releaseRTT(e){if(this.rttObjects.length!==0){for(let t of this.rttObjects)t&&e.releaseRTT(t);this.rttObjects.length=0}}releaseRTTStack(e,t){let n=this.rttObjects[t];n&&(e.releaseRTT(n),this.rttObjects[t]=void 0)}loadVectorData(e,t,n){if(e?.etagUnmodified===!0)this.state=`loaded`;else if(this.hasData()&&this.unloadVectorData(),this.state=`loaded`,!e)this.collisionBoxArray=new u6;else{e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=YT(e.buckets,t),this.hasSymbolBuckets=!1;for(let e in this.buckets){let t=this.buckets[e];if(t instanceof rw){if(this.hasSymbolBuckets=!0,n)t.justReloaded=!0;else break}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let e in this.buckets){let t=this.buckets[e];if(t instanceof rw&&t.hasRTLText){this.hasRTLText=!0,IA().lazyLoad();break}}this.queryPadding=0;for(let e in this.buckets){let n=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.getLayer(e).queryRadius(n))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state=`unloaded`}getBucket(e){return this.buckets[e.id]}upload(e){for(let t in this.buckets){let n=this.buckets[t];n.uploadPending()&&n.upload(e)}let t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new b3(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new b3(e,this.glyphAtlasImage,t.ALPHA),null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,n,r,i,a,o,s,c,l,u){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:i,scale:a,tileSize:this.tileSize,projectedCamera:s,worldCoordinateHelper:c,params:o,queryPadding:this.queryPadding*l,getElevation:u},e,t,n):{}}querySourceFeatures(e,t){let n=this.latestFeatureIndex;if(!n?.rawTileData)return;let r=n.loadVTLayers(),i=t.sourceLayer?t.sourceLayer:``,a=r._geojsonTileLayer||r[i];if(!a)return;let o=Xy(t.filter,`querySourceFeatures[${i}].filter`,t.globalState),{z:s,x:c,y:l}=this.tileID.canonical,u={z:s,x:c,y:l};for(let r=0;re)n=!1;else if(!t)n=!0;else if(this.expirationTime{this.remove(e,i)},n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){let t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;let n=e.wrapped().key,r=t===void 0?0:this.data[n].indexOf(t),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),this.data[n].length===0&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){let t=[];for(let n in this.data)for(let r of this.data[n])e(r.value)||t.push(r);for(let e of t)this.remove(e.value.tileID,e)}};function zA(e){let t=[];for(let n in e)t.push({id:n,state:e[n]});return t}var BA=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,t,n){let r=String(t);if(this.stateChanges[e]||={},this.stateChanges[e][r]={...this.stateChanges[e][r],...n},this.deletedStates[e]===null){this.deletedStates[e]={};for(let t in this.state[e])if(t===r){this.deletedStates[e][r]={};for(let i in this.state[e][t])n[i]===void 0&&(this.deletedStates[e][r][i]=null)}else this.deletedStates[e][t]=null}else if(this.deletedStates[e]?.[r]===null){this.deletedStates[e][r]={};for(let t in this.state[e][r])n[t]===void 0&&(this.deletedStates[e][r][t]=null)}else for(let t in n)this.deletedStates[e]?.[r]?.[t]===null&&delete this.deletedStates[e][r][t]}removeFeatureState(e,t,n){if(this.deletedStates[e]===null)return;let r=String(t);if(this.deletedStates[e]||={},n&&t!==void 0)this.deletedStates[e][r]!==null&&(this.deletedStates[e][r]||={},this.deletedStates[e][r][n]=null);else if(t!==void 0){if(this.stateChanges[e]?.[r])for(n in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][n]=null;else this.deletedStates[e][r]=null}else this.deletedStates[e]=null}getState(e,t){let n=String(t),r=this.state[e]||{},i=this.stateChanges[e]||{},a={...r[n],...i[n]};if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let n=this.deletedStates[e][t];if(n===null)return{};for(let e in n)delete a[e]}return a}initializeTileState(e,t){let n={};for(let e in this.state)n[e]=zA(this.state[e]);e.setFeatureState(n,t,this.revision)}coalesceChanges(e,t){let n={};for(let e in this.stateChanges){this.state[e]||={},n[e]||={};for(let t in this.stateChanges[e])this.state[e][t]={...this.state[e][t],...this.stateChanges[e][t]},n[e][t]=this.state[e][t]}for(let e in this.deletedStates)if(this.state[e]||={},n[e]||={},this.deletedStates[e]===null)for(let t in this.state[e])this.state[e][t]={},n[e][t]={};else for(let t in this.deletedStates[e]){if(this.deletedStates[e][t]===null)this.state[e][t]={};else if(this.state[e][t])for(let n of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][n];else continue;n[e][t]=this.state[e][t]}if(this.stateChanges={},this.deletedStates={},Object.keys(n).length===0)return;this.revision++;let r={};for(let e in n)r[e]=zA(n[e]);e.setFeatureState(r,t,this.revision)}},VA=class e{constructor(e,t){this.min=e,this.max=t,this.center=Fm([],Nm([],this.min,this.max),.5)}quadrant(t){let n=[t%2==0,t<2],r=Am(this.min),i=Am(this.max);for(let e=0;ethis.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[r]*this.min[r],n+=e[r]*this.max[r]):(n+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:n<0?0:1}},HA=class{getCenter(e){return e.center}distanceToTile2d(e,t,n,r){let i=r,a=i.distanceX([e,t]),o=i.distanceY([e,t]);return Math.hypot(a,o)}getWrap(e,t,n){return n}getTileBoundingVolume(e,t,n,r){let i=Math.min(0,n),a=Math.max(0,n);if(r?.terrain){let n=new m8(e.z,t,e.z,e.x,e.y),o=r.terrain.getMinMaxElevation(n);i=o.minElevation??i,a=o.maxElevation??a}let o=1<n}allowWorldCopies(){return!0}};function UA(e,t,n,r){let i=`${e.z}_${e.x}_${e.y}_${Math.round(n)}`;if(!r?.terrain)return i;let{minElevation:a,maxElevation:o}=r.terrain.getMinMaxElevation(new m8(e.z,t,e.z,e.x,e.y));return`${i}_${a}_${o}`}var Bne=class{constructor(e,t=4096){this._volumes=new Map,this._boundingVolumeFactory=e,this._capacity=t}getTileBoundingVolume(e,t,n,r){let i=UA(e,t,n,r),a=this._volumes.get(i);return a?this._volumes.delete(i):(a=this._boundingVolumeFactory(e,t,n,r),this._volumes.size>=this._capacity&&this._volumes.delete(this._volumes.keys().next().value)),this._volumes.set(i,a),a}},WA=class e{constructor(e,t,n,r){this.min=n,this.max=r,this.points=e,this.planes=t}static fromAabb(t,n){let r=[];for(let e=0;e<8;e++)r.push([(e&1)==1?n[0]:t[0],(e>>1&1)==1?n[1]:t[1],(e>>2&1)==1?n[2]:t[2]]);return new e(r,[[-1,0,0,n[0]],[1,0,0,-t[0]],[0,-1,0,n[1]],[0,1,0,-t[1]],[0,0,-1,n[2]],[0,0,1,-t[2]]],t,n)}static fromCenterSizeAngles(t,n,r){let i=dh([],r[0],r[1],r[2]),a=Gm([],[n[0],0,0],i),o=Gm([],[0,n[1],0],i),s=Gm([],[0,0,n[2]],i),c=[...t],l=[...t];for(let e=0;e<8;e++)for(let n=0;n<3;n++){let r=t[n]+a[n]*((e&1)==1?1:-1)+o[n]*((e>>1&1)==1?1:-1)+s[n]*((e>>2&1)==1?1:-1);c[n]=Math.min(c[n],r),l[n]=Math.max(l[n],r)}let u=[];for(let e=0;e<8;e++){let n=[...t];Nm(n,n,Fm([],a,(e&1)==1?1:-1)),Nm(n,n,Fm([],o,(e>>1&1)==1?1:-1)),Nm(n,n,Fm([],s,(e>>2&1)==1?1:-1)),u.push(n)}return new e(u,[[...a,-Bm(a,u[0])],[...o,-Bm(o,u[0])],[...s,-Bm(s,u[0])],[-a[0],-a[1],-a[2],-Bm(a,u[7])],[-o[0],-o[1],-o[2],-Bm(o,u[7])],[-s[0],-s[1],-s[2],-Bm(s,u[7])]],c,l)}intersectsFrustum(e){let t=!0,n=this.points.length,r=this.planes.length,i=e.planes.length,a=e.points.length;for(let r=0;r=0&&a++}if(a===0)return 0;a=0&&r++}if(r===0)return 0}return 1}intersectsPlane(e){let t=this.points.length,n=0;for(let r=0;r=0&&n++}return n===t?2:n===0?0:1}};function GA(e,t,n){let r=e-t;return r<0?-r:Math.max(0,r-n)}function KA(e,t,n,r,i){let a=e-n,o;return o=a<0?Math.min(-a,1+a-i):a>i?Math.min(Math.max(a-i,0),1-a):0,Math.max(o,GA(t,r,i))}var Vne=class{constructor(){this._boundingVolumeCache=new Bne(this._computeTileBoundingVolume)}getCenter(e){return new Xb(e.center.lng,G(e.center.lat,-85.051129,xg))}distanceToTile2d(e,t,n,r){let i=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,n,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,n,r)}_computeTileBoundingVolume(e,t,n,r){let i=Math.min(0,n),a=Math.max(0,n);if(r?.terrain){let n=new m8(e.z,t,e.z,e.x,e.y),o=r.terrain.getMinMaxElevation(n);i=o.minElevation??i,a=Math.max(o.maxElevation??a,a)}if(i/=Yb,a/=Yb,i+=1,a+=1,e.z<=0)return WA.fromAabb([-a,-a,-a],[a,a,a]);if(e.z===1)return WA.fromAabb([e.x===0?-a:0,e.y===0?0:-a,-a],[e.x===0?0:a,e.y===0?a:0,a]);{let t=[Bx(0,0,e.x,e.y,e.z),Bx(W,0,e.x,e.y,e.z),Bx(W,W,e.x,e.y,e.z),Bx(0,W,e.x,e.y,e.z)],n=[];for(let e of t)n.push(Fm([],e,a));if(a!==i)for(let e of t)n.push(Fm([],e,i));e.y===0&&n.push([0,1,0]),e.y===(1<=(1<{let i=r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3];if(Math.abs(i)>1e-6)return e;let a=[e[0]-n[0],e[1]-n[1],e[2]-n[2]],o=r[0]*a[0]+r[1]*a[1]+r[2]*a[2];if(o>=-1e-9)return e;let s=t/-o;return[e[0]+a[0]*s,e[1]+a[1]*s,e[2]+a[2]*s,e[3]]}),a=e.planes.map((e,n)=>n===1?[e[0],e[1],e[2],e[3]+t]:e),o=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let e of i)for(let t=0;t<3;t++)o[t]=Math.min(o[t],e[t]),s[t]=Math.max(s[t],e[t]);return{points:i,planes:a,aabb:{min:o,max:s}}}function Kne(e,t,n,r){let i=Math.hypot(t[0],t[1],t[2]);if(i===0)return{frustum:e,plane:t};let a=1+r/Yb,o=G(-t[3]/i,-1,1),s=Math.cos(Math.acos(o)+Math.acos(1/a));return{frustum:Gne(e,Math.sqrt(a*a-1),n),plane:[t[0],t[1],t[2],-s*i]}}function ej(e,t,n){let r=Q(e).getCameraFrustum(e),i=Q(e).getClippingPlane(e);i&&n.maxContentElevation>0&&({frustum:r,plane:i}=Kne(r,i,e.cameraPosition,n.maxContentElevation));let a=XA(e),o=a.getCenter(e),s=k8(e,t,o),c=t.worldFromLngLat(o.lng,o.lat,e.elevation),l=Wne(e,n.maxContentElevation),u=a.allowVariableZoom(e,n),d=$A(e,n),f=n.minzoom||0,p=n.maxzoom===void 0?e.maxZoom:n.maxzoom,m=Math.min(Math.max(0,d),p),h=2**m,g=[h*s.x,h*s.y,0],_=[h*c.x,h*c.y,0],v=Math.hypot(c.x-s.x,c.y-s.y),y=Math.abs(c.z-s.z),b=Math.hypot(v,y),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),S=[],C=[];if(e.renderWorldCopies&&t.wraps&&a.allowWorldCopies())for(let e=1;e<=3;e++)S.push(x(-e)),S.push(x(e));for(S.push(x(0));S.length>0;){let t=S.pop(),o=t.x,h=t.y,v=t.fullyVisible,x={x:o,y:h,z:t.zoom},w=a.getTileBoundingVolume(x,t.wrap,l,n);if(!v){let e=Hne(r,w,i);if(e===0)continue;v=e===2}let T=a.distanceToTile2d(s.x,s.y,x,w),E=d;u&&(E=(n.calculateTileZoom||Une)(e.zoom+Qh(e.tileSize/n.tileSize),T,y,b,e.fov)),E=(n.roundZoom?Math.round:Math.floor)(E),E=Math.max(0,E);let D=Math.min(E,p);if(t.wrap=a.getWrap(c,x,t.wrap),t.zoom>=D){if(t.zoom>1),i=t.zoom+1;S.push({zoom:i,x:n,y:r,wrap:t.wrap,fullyVisible:v})}}return C.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}function tj(e){return e===`raster`||e===`image`||e===`video`}function qne(e,t,n,r,i,a,o){let s=Ig(),c=Vh(t);for(let l of t){let t=e.getTileById(l.key);(t.fadingDirection===0||t.fadeOpacity===0)&&t.resetFadeLogic(),Jne(e,t,n,s,r,i,o)||Yne(e,t,n,s,a,o)||Xne(t,c,s,o)||t.resetFadeLogic()}}function Jne(e,t,n,r,i,a,o){if(!t.hasData())return!1;let{tileID:s,fadingRole:c,fadingDirection:l,fadingParentID:u}=t;if(c===0&&l===1&&u)return n[u.key]=u,!0;let d=Math.max(s.overscaledZ-i,a);for(let i=s.overscaledZ-1;i>=d;i--){let a=s.scaledTo(i),c=e.getLoadedTile(a);if(c)return t.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:c.tileID,fadeEndTime:r+o}),c.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:r+o}),n[a.key]=a,!0}return!1}function Yne(e,t,n,r,i,a){if(!t.hasData())return!1;let o=t.tileID.children(i),s=nj(e,t,o,n,r,i,a);if(s)return!0;for(let c of o)nj(e,t,c.children(i),n,r,i,a)&&(s=!0);return s}function nj(e,t,n,r,i,a,o){if(n[0].overscaledZ>a)return!1;let s=!1;for(let a of n){let n=e.getLoadedTile(a);if(!n)continue;let{fadingRole:c,fadingDirection:l,fadingParentID:u}=n;c===0&&l===0&&u||(n.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:t.tileID,fadeEndTime:i+o}),t.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:i+o})),r[a.key]=a,s=!0}return s}function Xne(e,t,n,r){let i=e.tileID;if(e.selfFading)return!0;if(e.hasData())return!1;if(t.has(i)){let t=n+r;return e.setSelfFadeLogic(t),!0}return!1}function Zne(e,t){if(t<=0)return!1;let n=Ig();for(let t of e.getAllTiles())if(t.fadeEndTime>=n)return!0;return!1}function Qne(e,t){let n=t.getRenderableIds();for(let r of n){if(!e.neighboringTiles?.[r])continue;let n=t.getTileById(r);e.neighboringTiles[r].backfilled||rj(e,n),n.neighboringTiles?.[e.tileID.key]?.backfilled||rj(n,e)}}function rj(e,t){e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.needsColorReliefPrepare=!0;let n=t.tileID.canonical.x-e.tileID.canonical.x,r=t.tileID.canonical.y-e.tileID.canonical.y,i=2**e.tileID.canonical.z,a=t.tileID.key;n===0&&r===0||Math.abs(r)>1||(Math.abs(n)>1&&(Math.abs(n+i)===1?n+=i:Math.abs(n-i)===1&&(n-=i)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,n,r),e.neighboringTiles?.[a]&&(e.neighboringTiles[a].backfilled=!0)))}var ij=class{constructor(){this._tiles={}}handleWrapJump(e){let t={};for(let n in this._tiles){let r=this._tiles[n];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t}setFeatureState(e,t,n){for(let r in this._tiles)this._tiles[r].setFeatureState(e,t,n)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(e=>e.tileID).sort(v8).map(e=>e.key):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,t){this._tiles[e]=t}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){let t=this.getTileById(e.key);return t?.hasData()?t:null}isIdRenderable(e,t=!1){return this.getTileById(e)?.isRenderable(t)}getRenderableIds(e=0,t){let n=[];for(let e of this.getAllIds())this.isIdRenderable(e,t)&&n.push(this.getTileById(e));return t?n.sort((t,n)=>{let r=t.tileID,i=n.tileID,a=new U(r.canonical.x,r.canonical.y)._rotate(-e),o=new U(i.canonical.x,i.canonical.y)._rotate(-e);return r.overscaledZ-i.overscaledZ||o.y-a.y||o.x-a.x}).map(e=>e.tileID.key):n.map(e=>e.tileID).sort(v8).map(e=>e.key)}},aj=.5,oj=class e extends l_{static{this.maxUnderzooming=10}static{this.maxOverzooming=3}constructor(e,t,n){super(),this._maxContentElevationSeen=0,this.id=e,this.dispatcher=n,this.on(`data`,e=>{this._dataHandler(e)}),this.on(`dataloading`,()=>{this._sourceErrored=!1}),this.on(`error`,e=>{e.tile||(this._sourceErrored=this._source.loaded())}),this._source=qT(e,t,n,this),this._inViewTiles=new ij,this._outOfViewCache=new RA(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new BA,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source?.onAdd&&this._source.onAdd(e)}onRemove(e){for(let e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),this._source?.onRemove&&this._source.onRemove(e),this._inViewTiles=new ij}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if((this.used!==void 0||this.usedForTerrain!==void 0)&&!this.used&&!this.usedForTerrain)return!0;if(!this._updated)return!1;for(let e of this._inViewTiles.getAllTiles())if(e.state!==`loaded`&&e.state!==`errored`)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.projectedCamera&&this.update(this.projectedCamera,this.worldCoordinateHelper,this.terrain)}async _loadTile(e,t,n,r){try{let i=await this._source.loadTile(e);this._tileLoaded(e,t,n,r,i)}catch(n){e.state=`errored`,n.status===404?this._inViewTiles.getTileById(t)===e&&(this.update(this.projectedCamera,this.worldCoordinateHelper,this.terrain),this._source.fire(new j4(`data`,{tile:e,coord:e.tileID}))):this._source.fire(new c_(Ch(n),{tile:e}))}}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new j4(`dataabort`,{tile:e,coord:e.tileID}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.style);for(let t of this._inViewTiles.getAllTiles())t.upload(e),t.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){return this._inViewTiles.getRenderableIds(this.projectedCamera?.bearingInRadians,e)}hasRenderableParent(e){let t=e.overscaledZ-1;if(t>=this._source.minzoom){let n=this.getLoadedTile(e.scaledTo(t));if(n)return this._inViewTiles.isIdRenderable(n.tileID.key)}return!1}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(let n of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(n);(!t||this._source.shouldReloadTile(r,t))&&(e?this._reloadTile(n,r.state===`errored`?`loading`:`expired`):r.state!==`errored`&&this._reloadTile(n,`reloading`))}}}async _reloadTile(e,t){let n=this._inViewTiles.getTileById(e);if(!n)return;let r=n.hasData();n.state!==`loading`&&(n.state=t),await this._loadTile(n,e,t,r)}_tileLoaded(e,t,n,r,i){r||(e.timeAdded=Ig(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration)),n===`expired`&&(e.refreshedUponExpiration=!0),this._inViewTiles.getTileById(t)===e&&this._setTileReloadTimer(t,e),i?.unmodified||(this.getSource().type===`raster-dem`&&e.dem&&Qne(e,this._inViewTiles),e.featureStateRevision=-1,this._state.initializeTileState(e,this.style),e.aborted||this._source.fire(new j4(`data`,{tile:e,coord:e.tileID})))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(t,n){let r=this._getLoadedDescendents(n),i=new Set;for(let a of n){let n=r[a.key];if(!n?.length){i.add(a);continue}let o=a.overscaledZ+e.maxOverzooming,s=n.filter(e=>e.tileID.overscaledZ<=o);if(!s.length){i.add(a);continue}let c=Math.min(...s.map(e=>e.tileID.overscaledZ)),l=s.filter(e=>e.tileID.overscaledZ===c).map(e=>e.tileID);for(let e of l)t[e.key]=e;this._areDescendentsComplete(l,c,a.overscaledZ)||i.add(a)}return i}_getLoadedDescendents(e){let t={};for(let n of this._inViewTiles.getAllTiles().filter(e=>e.hasData()))for(let r of e)n.tileID.isChildOf(r)&&(t[r.key]||=[],t[r.key].push(n));return t}_areDescendentsComplete(e,t,n){return e.length===1&&e[0].isOverscaled()?e[0].overscaledZ===t:4**(t-n)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){let t=(Math.ceil(e.width/this._source.tileSize)+1)*(Math.ceil(e.height/this._source.tileSize)+1),n=this._maxTileCacheZoomLevels===null?Kg.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels,r=Math.floor(t*n),i=typeof this._maxTileCacheSize==`number`?Math.min(this._maxTileCacheSize,r):r;this._outOfViewCache.setMaxSize(i)}handleWrapJump(e){let t=(e-(this._prevLng===void 0?e:this._prevLng))/360,n=Math.round(t);this._prevLng=e,n&&(this._inViewTiles.handleWrapJump(n),this._resetTileReloadTimers())}_updateMaxContentElevation(){let e=this._maxContentElevationSeen,t=this.map?.style?._layers;if(!t)return e;let n=this._inViewTiles.getAllTiles();for(let r in t){let i=t[r];if(i.type!==`symbol`||i.source!==this.id||i.isHidden(this.projectedCamera.zoom))continue;let a=i;if(!a.layout)continue;let o=a.layout.get(`symbol-height-offset`);if(e=Math.max(e,o.constantOr(0)),!o.isConstant())for(let t of n){let n=t.getBucket(i);n&&n.maxHeightOffset>e&&(e=n.maxHeightOffset)}}return this._maxContentElevationSeen=e,e}update(e,t,n){if(!this._sourceLoaded||this._paused)return;this.projectedCamera=e,this.worldCoordinateHelper=t,this.terrain=n,this.updateCacheSize(e),t.wraps&&this.handleWrapJump(this.projectedCamera.center.lng);let r;!this.used&&!this.usedForTerrain?r=[]:this._source.tileID?r=Q(e).getVisibleUnwrappedCoordinates(e,t,this._source.tileID).map(e=>new m8(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(r=ej(e,t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type===`vector`&&this.map._zoomLevelsToOverscale!==void 0?Math.max(this._source.maxzoom,e.maxZoom-this.map._zoomLevelsToOverscale):this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom,maxContentElevation:this._updateMaxContentElevation()}),this._source.hasTile&&(r=r.filter(e=>this._source.hasTile(e)))),this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));let i=r.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,i&&this.fire(new j4(`data`,{sourceDataType:`idle`,sourceId:this.id}));let a=$A(e,this._source),o=this._updateRetainedTiles(r,a),s=tj(this._source.type);s&&this._rasterFadeDuration>0&&!n&&qne(this._inViewTiles,r,o,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),s?this._cleanUpRasterTiles(o):this._cleanUpVectorTiles(o)}_cleanUpRasterTiles(e){for(let t of this._inViewTiles.getAllIds())e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(let t of this._inViewTiles.getAllIds()){let n=this._inViewTiles.getTileById(t);e[t]?n.clearSymbolFadeHold():n.hasSymbolBuckets?n.holdingForSymbolFade()?n.symbolFadeFinished()&&this._removeTile(t):n.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){let t=[];for(let n of e)if(n.canonical.z>this._source.minzoom){let e=n.scaledTo(n.canonical.z-1);t.push(e);let r=n.scaledTo(Math.max(this._source.minzoom,Math.min(n.canonical.z,5)));t.push(r)}return e.concat(t)}releaseSymbolFadeTiles(){for(let e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(t,n){let r=new Set;for(let e of t)this._addTile(e).hasData()||r.add(e);let i=t.reduce((e,t)=>(e[t.key]=t,e),{}),a=this._retainLoadedChildren(i,r),o={},s=Math.max(n-e.maxUnderzooming,this._source.minzoom);for(let e of a){let t=this._inViewTiles.getTileById(e.key),n=t?.wasRequested();for(let r=e.overscaledZ-1;r>=s;--r){let a=e.scaledTo(r);if(o[a.key])break;if(o[a.key]=!0,t=this.getTile(a),!t&&(n||this._outOfViewCache.has(a))&&(t=this._addTile(a)),t){let e=t.hasData();if((e||!this.map?.cancelPendingTileRequestsWhileZooming||n)&&(i[a.key]=a),n=t.wasRequested(),e)break}}}return i}_addTile(e){let t=this._inViewTiles.getTileById(e.key);if(t)return t;t=this._outOfViewCache.getAndRemove(e),t&&(t.resetFadeLogic(),this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.style));let n=t;return t||(t=new LA(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(t,e.key,t.state,!1)),t.uses++,this._inViewTiles.setTile(e.key,t),n||this._source.fire(new j4(`dataloading`,{tile:t,coord:t.tileID})),t}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);let n=t.getExpiryTimeout();if(n){let t=()=>{this._reloadTile(e,`expired`),delete this._timers[e]};this._timers[e]=setTimeout(t,n)}}_clearTileReloadTimer(e){let t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){for(let e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(let e of this._inViewTiles.getAllIds()){let t=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,t)}}refreshTiles(e){for(let t of this._inViewTiles.getAllIds()){let n=this._inViewTiles.getTileById(t);(this._inViewTiles.isIdRenderable(t)||n.state==`errored`)&&e.some(e=>e.equals(n.tileID.canonical))&&this._reloadTile(t,`expired`)}}_removeTile(e){let t=this._inViewTiles.getTileById(e);t&&(t.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),t.uses>0||(t.hasData()&&t.state!==`reloading`?this._outOfViewCache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){e.dataType===`source`&&(e.sourceDataType===`metadata`?this._sourceLoaded=!0:e.sourceDataType===`content`&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.projectedCamera&&this.update(this.projectedCamera,this.worldCoordinateHelper,this.terrain),this._didEmitContent=!0))}resetMaxContentElevation(){this._maxContentElevationSeen=0}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1,this.resetMaxContentElevation();for(let e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,t,n,r=this.projectedCamera,i=this.worldCoordinateHelper){let a=[];if(!r)return a;let o=XA(r).allowWorldCopies(),s=n?Q(r).getCameraQueryGeometry(r,e):e,c=e=>Q(r).screenPointToMercatorCoordinate(r,i,e,this.terrain),l=this.transformBbox(e,c,!o),u=this.transformBbox(s,c,!o),d=this.getIds(),f=Ob.fromPoints(u);for(let e of d){let n=this._inViewTiles.getTileById(e);if(n.holdingForSymbolFade())continue;let i=o?[n.tileID]:[n.tileID.unwrapTo(-1),n.tileID.unwrapTo(0)],s=2**(r.zoom-n.tileID.overscaledZ),c=t*n.queryPadding*W/n.tileSize/s;for(let e of i){let t=f.map(t=>e.getTilePoint(new c8(t.x,t.y)));if(t.expandBy(c),t.intersects(kb)){let t=l.map(t=>e.getTilePoint(t)),r=u.map(t=>e.getTilePoint(t));a.push({tile:n,tileID:o?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:r,scale:s})}}}return a}transformBbox(e,t,n){let r=e.map(t);if(n){let n=Ob.fromPoints(e);n.shrinkBy(Math.min(n.width(),n.height())*.001);let i=n.map(t),a=Ob.fromPoints(r);a.width()>aj&&!a.covers(i)&&(r=r.map(e=>e.x>aj?new c8(e.x-1,e.y,e.z):e))}return r}getVisibleCoordinates(e){return this.getRenderableIds(e).map(e=>this._inViewTiles.getTileById(e).tileID)}hasTransition(){return this._source.hasTransition()?!0:tj(this._source.type)&&Zne(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,t,n){e||=XT,this._state.updateState(e,t,n)}removeFeatureState(e,t,n){e||=XT,this._state.removeFeatureState(e,t,n)}getFeatureState(e,t){return e||=XT,this._state.getState(e,t)}setDependencies(e,t,n){let r=this._inViewTiles.getTileById(e);r&&r.setDependencies(t,n)}reloadTilesForDependencies(e,t){for(let n of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(n).hasDependency(e,t)&&this._reloadTile(n,`reloading`);this._outOfViewCache.filter(n=>!n.hasDependency(e,t))}areTilesLoaded(){for(let e of this._inViewTiles.getAllTiles())if(e.state!==`loaded`&&e.state!==`errored`)return!1;return!0}},$ne=class{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(r-a)/o:0;return this.points[i].mult(1-s).add(this.points[t].mult(s))}};function sj(e,t,n,r,i){return i?e?e(t,n)+r:r===0?void 0:r:r}function cj(e,t){let n=!0;return e===`always`||(e===`never`||t===`never`)&&(n=!1),n}var lj=class{constructor(e,t,n){let r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);for(let e=0;ethis.width||r<0||t>this.height)return[];let s=[];if(e<=0&&t<=0&&this.width<=n&&this.height<=r){if(i)return[{key:null,x1:e,y1:t,x2:n,y2:r}];for(let e=0;e0}hitTestCircle(e,t,n,r,i){let a=e-n,o=e+n,s=t-n,c=t+n;if(o<0||a>this.width||c<0||s>this.height)return!1;let l=[],u={hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:n},seenUids:{box:{},circle:{}}};return this._forEachCell(a,s,o,c,this._queryCellCircle,l,u,i),l.length>0}_queryCell(e,t,n,r,i,a,o,s){let{seenUids:c,hitTest:l,overlapMode:u}=o,d=this.boxCells[i],f=1e-6;if(d!==null){let i=this.bboxes;for(let o of d)if(!c.box[o]){c.box[o]=!0;let d=o*4,p=this.boxKeys[o];if(e<=i[d+2]+f&&t<=i[d+3]+f&&n>=i[d+0]-f&&r>=i[d+1]-f&&(!s||s(p))&&(!l||!cj(u,p.overlapMode))&&(a.push({key:p,x1:i[d],y1:i[d+1],x2:i[d+2],y2:i[d+3]}),l))return!0}}let p=this.circleCells[i];if(p!==null){let i=this.circles;for(let o of p)if(!c.circle[o]){c.circle[o]=!0;let d=o*3,f=this.circleKeys[o];if(this._circleAndRectCollide(i[d],i[d+1],i[d+2],e,t,n,r)&&(!s||s(f))&&(!l||!cj(u,f.overlapMode))){let e=i[d],t=i[d+1],n=i[d+2];if(a.push({key:f,x1:e-n,y1:t-n,x2:e+n,y2:t+n}),l)return!0}}}return!1}_queryCellCircle(e,t,n,r,i,a,o,s){let{circle:c,seenUids:l,overlapMode:u}=o,d=this.boxCells[i];if(d!==null){let e=this.bboxes;for(let t of d)if(!l.box[t]){l.box[t]=!0;let n=t*4,r=this.boxKeys[t];if(this._circleAndRectCollide(c.x,c.y,c.radius,e[n+0],e[n+1],e[n+2],e[n+3])&&(!s||s(r))&&!cj(u,r.overlapMode))return a.push(!0),!0}}let f=this.circleCells[i];if(f!==null){let e=this.circles;for(let t of f)if(!l.circle[t]){l.circle[t]=!0;let n=t*3,r=this.circleKeys[t];if(this._circlesCollide(e[n],e[n+1],e[n+2],c.x,c.y,c.radius)&&(!s||s(r))&&!cj(u,r.overlapMode))return a.push(!0),!0}}}_forEachCell(e,t,n,r,i,a,o,s){let c=this._convertToXCellCoord(e),l=this._convertToYCellCoord(t),u=this._convertToXCellCoord(n),d=this._convertToYCellCoord(r);for(let f=c;f<=u;f++)for(let c=l;c<=d;c++){let l=this.xCellCount*c+f;if(i.call(this,e,t,n,r,l,a,o,s))return}}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,n,r,i,a){let o=r-e,s=i-t,c=n+a;return c*c>o*o+s*s}_circleAndRectCollide(e,t,n,r,i,a,o){let s=(a-r)/2,c=Math.abs(e-(r+s));if(c>s+n)return!1;let l=(o-i)/2,u=Math.abs(t-(i+l));if(u>l+n)return!1;if(c<=s||u<=l)return!0;let d=c-s,f=u-l;return d*d+f*f<=n*n}},ere=dm();function uj(e,t,n){let r=dm();if(!e){let{vecSouth:e,vecEast:n}=dj(t),i=rm();i[0]=n[0],i[1]=n[1],i[2]=e[0],i[3]=e[1],im(i,i),r[0]=i[0],r[1]=i[1],r[4]=i[2],r[5]=i[3]}return vm(r,r,[1/n,1/n,1]),r}function tre(e,t,n,r){if(e){let e=dm();if(!t){let{vecSouth:t,vecEast:r}=dj(n);e[0]=r[0],e[1]=r[1],e[4]=t[0],e[5]=t[1]}return vm(e,e,[r,r,1]),e}return n.pixelsToClipSpaceMatrix}function dj(e){let t=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),i=Math.cos(e.bearingInRadians),a=Math.sin(e.bearingInRadians),o=mh();o[0]=-i*r*n-a*t,o[1]=-a*r*n+i*t;let s=_h(o);s<1e-9?bh(o):gh(o,o,1/s);let c=mh();c[0]=i*r*t-a*n,c[1]=a*r*t+i*n;let l=_h(c);return l<1e-9?bh(c):gh(c,c,1/l),{vecEast:c,vecSouth:o}}function fj(e,t,n){return sj(e.getElevation,t,n,e.heightOffset??0,e.heightAnchorGround??!0)}function pj(e,t,n,r){let i;r==null?(i=[e,t,0,1],z8(i,i,n)):(i=[e,t,r,1],rh(i,i,n));let a=i[3];return{point:new U(i[0]/a,i[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}function mj(e,t){return .5+e/t*.5}function nre(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function rre(e,t,n,r,i,a,o,s,c,l,u,d){let f=r?e.textSizeData:e.iconSizeData,p=EC(f,n.zoom),m=[256/t.width*2+1,256/t.height*2+1],h=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;h.clear();let g=e.lineVertexArray,_=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=n.width/n.height,y=!1;for(let t=0;t<_.length;t++){let r=_.get(t);if(r.hidden||r.writingMode===2&&!y){Tj(r.numGlyphs,h);continue}y=!1;let b={getElevation:d,pitchedLabelPlaneMatrix:i,lineVertexArray:g,pitchWithMap:o,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projectedCamera:n,tileAnchorPoint:new U(r.anchorX,r.anchorY),unwrappedTileID:l,width:n.width,height:n.height,translation:u},x=Sj(r.anchorX,r.anchorY,b);if(!nre(x.point,m)){Tj(r.numGlyphs,h);continue}let S=x.signedDistanceFromCamera,C=mj(n.cameraToCenterDistance,S),w=TC(f,p,r),T=o?w*Q(n).getPitchedTextCorrection(n,r.anchorX,r.anchorY,l)/C:w*C,E=_j({projectionContext:b,pitchedLabelPlaneMatrixInverse:a,symbol:r,fontSize:T,flip:!1,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:h,aspectRatio:v,rotateToLine:c});y=E.useVertical,(E.notEnoughRoom||y||E.needsFlipping&&_j({projectionContext:b,pitchedLabelPlaneMatrixInverse:a,symbol:r,fontSize:T,flip:!0,keepUpright:s,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:h,aspectRatio:v,rotateToLine:c}).notEnoughRoom)&&Tj(r.numGlyphs,h)}r?e.text.dynamicLayoutVertexBuffer.updateData(h):e.icon.dynamicLayoutVertexBuffer.updateData(h)}function hj(e,t,n,r,i,a,o,s){let c=a.glyphStartIndex+a.numGlyphs,l=a.lineStartIndex,u=a.lineStartIndex+a.lineLength,d=t.getoffsetX(a.glyphStartIndex),f=t.getoffsetX(c-1),p=wj(e*d,n,r,i,a.segment,l,u,s,o);if(!p)return null;let m=wj(e*f,n,r,i,a.segment,l,u,s,o);return!m||s.projectionCache.anyProjectionOccluded?null:{first:p,last:m}}function gj(e,t,n,r){return e===1&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*r?{useVertical:!0}:(e===2?t.yn.x)?{needsFlipping:!0}:null}function _j(e){let{projectionContext:t,pitchedLabelPlaneMatrixInverse:n,symbol:r,fontSize:i,flip:a,keepUpright:o,glyphOffsetArray:s,dynamicLayoutVertexArray:c,aspectRatio:l,rotateToLine:u}=e,d=i/24,f=r.lineOffsetX*d,p=r.lineOffsetY*d,m;if(r.numGlyphs>1){let e=r.glyphStartIndex+r.numGlyphs,i=r.lineStartIndex,c=r.lineStartIndex+r.lineLength,h=hj(d,s,f,p,a,r,u,t);if(!h)return{notEnoughRoom:!0};let g=xj(h.first.point.x,h.first.point.y,t,n),_=xj(h.last.point.x,h.last.point.y,t,n);if(o&&!a){let e=gj(r.writingMode,g,_,l);if(e)return e}m=[h.first];for(let n=r.glyphStartIndex+1;n0?o.point:vj(t.tileAnchorPoint,a,e,1,t),c=xj(e.x,e.y,t,n),u=xj(s.x,s.y,t,n),d=gj(r.writingMode,c,u,l);if(d)return d}let e=wj(d*s.getoffsetX(r.glyphStartIndex),f,p,a,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,t,u);if(!e||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[e]}for(let e of m)ew(c,e.point,e.angle);return{}}function vj(e,t,n,r,i){let a=e.add(e.sub(t)._unit()),o=bj(a.x,a.y,i).point,s=n.sub(o);return n.add(s._mult(r/s.mag()))}function yj(e,t,n){let r=t.projectionCache;if(r.projections[e])return r.projections[e];let i=new U(t.lineVertexArray.getx(e),t.lineVertexArray.gety(e)),a=bj(i.x,i.y,t);if(a.signedDistanceFromCamera>0)return r.projections[e]=a.point,r.anyProjectionOccluded||=a.isOccluded,a.point;let o=e-n.direction,s=n.distanceFromAnchor===0?t.tileAnchorPoint:new U(t.lineVertexArray.getx(o),t.lineVertexArray.gety(o)),c=n.absOffsetX-n.distanceFromAnchor+1;return vj(s,i,n.previousVertex,c,t)}function bj(e,t,n){let r=e+n.translation[0],i=t+n.translation[1],a;return n.pitchWithMap?(a=pj(r,i,n.pitchedLabelPlaneMatrix,fj(n,r,i)),a.isOccluded=!1):(a=Q(n.projectedCamera).projectTileCoordinates(n.projectedCamera,r,i,n.unwrappedTileID,fj(n,r,i)),a.point.x=(a.point.x*.5+.5)*n.width,a.point.y=(-a.point.y*.5+.5)*n.height),a}function xj(e,t,n,r){if(n.pitchWithMap){let i=[e,t,0,1];rh(i,i,r);let a=i[0]/i[3],o=i[1]/i[3];return Q(n.projectedCamera).projectTileCoordinates(n.projectedCamera,a,o,n.unwrappedTileID,fj(n,a,o)).point}return{x:e/n.width*2-1,y:1-t/n.height*2}}function Sj(e,t,n){return Q(n.projectedCamera).projectTileCoordinates(n.projectedCamera,e,t,n.unwrappedTileID,fj(n,e,t))}function Cj(e,t,n){return e._unit()._perp()._mult(t*n)}function ire(e,t,n,r,i,a,o,s,c){if(s.projectionCache.offsets[e])return s.projectionCache.offsets[e];let l=n.add(t);if(e+c.direction=i)return s.projectionCache.offsets[e]=l,l;let u=yj(e+c.direction,s,c),d=Cj(u.sub(n),o,c.direction),f=n.add(d),p=u.add(d),m=are(e,c.direction,r,i,s.lineVertexArray);return s.projectionCache.offsets[e]=m?l:og(a,l,f,p)||l,s.projectionCache.offsets[e]}function are(e,t,n,r,i){let a=e-t,o=e+t;if(Math.min(a,o)=r)return!1;let s=i.getx(e)-i.getx(a),c=i.gety(e)-i.gety(a),l=i.getx(o)-i.getx(e),u=i.gety(o)-i.gety(e);return s*u-c*l===0&&s*l+c*u<0}function wj(e,t,n,r,i,a,o,s,c){let l=r?e-t:e+t,u=l>0?1:-1,d=0;r&&(u*=-1,d=Math.PI),u<0&&(d+=Math.PI);let f=u>0?a+i:a+i+1,p;s.projectionCache.cachedAnchorPoint?p=s.projectionCache.cachedAnchorPoint:(p=bj(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,s.projectionCache.cachedAnchorPoint=p);let m=p,h=p,g,_,v=0,y=0,b=Math.abs(l),x=[],S;for(;v+y<=b;){if(f+=u,f=o)return null;v+=y,h=m,_=g;let e={absOffsetX:b,direction:u,distanceFromAnchor:v,previousVertex:h};if(m=yj(f,s,e),n===0)x.push(h),S=m.sub(h);else{let t,r=m.sub(h);t=r.mag()===0?Cj(yj(f+u,s,e).sub(m),n,u):Cj(r,n,u),_||=h.add(t),g=ire(f,t,m,a,o,_,n,s,e),x.push(_),S=g.sub(_)}y=S.mag()}let C=(b-v)/y,w=S._mult(C)._add(_||h),T=d+Math.atan2(m.y-h.y,m.x-h.x);return x.push(w),{point:w,angle:c?T:0,path:x}}var ore=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Tj(e,t){for(let n=0;n{let r=pj(e.x,e.y,n,fj(t,e.x,e.y)),i=Q(t.projectedCamera).projectTileCoordinates(t.projectedCamera,r.point.x,r.point.y,t.unwrappedTileID,fj(t,r.point.x,r.point.y));return i.point.x=(i.point.x*.5+.5)*t.width,i.point.y=(-i.point.y*.5+.5)*t.height,i})}function cre(e){let t=0,n=0,r=0,i=0;for(let a=0;an&&(n=i,t=r));return e.slice(t,t+n)}var lre=class{constructor(e,t=new lj(e.width+200,e.height+200,25),n=new lj(e.width+200,e.height+200,25)){this.projectedCamera=e,this.grid=t,this.ignoredGrid=n,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+100,this.screenBottomBoundary=e.height+100,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,t,n,r,i,a,o,s,c,l,u,d,f=0,p=!0){let m=e.anchorPointX+s[0],h=e.anchorPointY+s[1],g=this.projectAndGetPerspectiveRatio(m,h,i,sj(l,m,h,f,p),d),_=n*g.perspectiveRatio,v;if(!a&&!o){let t=g.x+(u?u.x*_:0),n=g.y+(u?u.y*_:0);v={allPointsOccluded:!1,box:[t+e.x1*_,n+e.y1*_,t+e.x2*_,n+e.y2*_]}}else v=this._projectCollisionBox(e,_,r,i,a,o,s,g,l,u,d,f,p);let[y,b,x,S]=v.box,C=a?v.allPointsOccluded:g.isOccluded,w=C;return w||=g.perspectiveRatio=1;e--)f.push(a.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let h=[];if(f.length>0){let e=f[0].clone(),t=f[0].clone();for(let n=1;n=n.x&&t.x<=r.x&&e.y>=n.y&&t.y<=r.y?[f]:t.xr.x||t.yr.y?[]:LC([f],n.x,n.y,r.x,r.y)}for(let n of h){i.reset(n,t*.25);let r=0;r=i.length<=.5*t?1:Math.ceil(i.paddedLength/p)+1;for(let n=0;n=this.screenRightBoundary||r<100||t>this.screenBottomBoundary}isInsideGrid(e,t,n,r){return n>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,r,sj(c,e.x,e.y,d,f),u));A=e.some(e=>!e.isOccluded),k=e.map(e=>new U(e.x,e.y))}else A=!0;return{box:Bh(k),allPointsOccluded:!A}}},Ej=class{constructor(e,t,n,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&n?1:0,this.placed=n}isHidden(){return this.opacity===0&&!this.placed}},Dj=class{constructor(e,t,n,r,i){this.text=new Ej(e?e.text:null,t,n,i),this.icon=new Ej(e?e.icon:null,t,r,i)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Oj=class{constructor(e,t,n){this.text=e,this.icon=t,this.skipFade=n}},ure=class{constructor(e,t,n,r,i){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=n,this.bucketIndex=r,this.tileID=i}},dre=class{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}};function kj(e,t,n,r,i){let{horizontalAlign:a,verticalAlign:o}=eC(e),s=-(a-.5)*t,c=-(o-.5)*n;return new U(s+r[0]*i,c+r[1]*i)}var fre=_9.members.find(e=>e.name===`crossTileID`).offset/4,pre=class{constructor(e,t,n,r,i){this.projectedCamera=e,this.terrain=t,this.collisionIndex=new lre(this.projectedCamera),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=n,this.retainedQueryData={},this.collisionGroups=new dre(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.lastOpacityInputs=new WeakMap,this.prevPlacement=i,i&&(i.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let t=this.terrain;if(t)return(n,r)=>t.getElevation(e,n,r)}_passesCameraFilter(e,t,n){let{featureIndex:r,sourceLayerIndex:i,tileID:a}=this.retainedQueryData[t.bucketInstanceId],o=Db(r.loadVTLayers()[r.sourceLayerCoder.decode(i)].feature(n.featureIndex),e.needGeometry),s={zoom:a.overscaledZ,pitch:this.projectedCamera.pitch,bearing:this.projectedCamera.bearing};return e.filter(s,o,a.canonical)}getBucketParts(e,t,n,r){let i=n.getBucket(t),a=n.latestFeatureIndex;if(!i||!a||t.id!==i.layerIds[0])return;let o=n.collisionBoxArray,s=i.layers[0].layout,c=i.layers[0].paint,l=2**(this.projectedCamera.zoom-n.tileID.overscaledZ),u=n.tileSize/W,d=n.tileID.toUnwrapped(),f=s.get(`text-rotation-alignment`)===`map`,p=Sh(n,1,this.projectedCamera.zoom),m=Ah(this.collisionIndex.projectedCamera,n,c.get(`text-translate`),c.get(`text-translate-anchor`)),h=Ah(this.collisionIndex.projectedCamera,n,c.get(`icon-translate`),c.get(`icon-translate-anchor`)),g=uj(f,this.projectedCamera,p);this.retainedQueryData[i.bucketInstanceId]=new ure(i.bucketInstanceId,a,i.sourceLayerIndex,i.index,n.tileID);let _={bucket:i,layout:s,translationText:m,translationIcon:h,unwrappedTileID:d,pitchedLabelPlaneMatrix:g,scale:l,textPixelRatio:u,holdingForFade:n.holdingForSymbolFade(),collisionBoxArray:o,partiallyEvaluatedTextSize:EC(i.textSizeData,this.projectedCamera.zoom),collisionGroup:this.collisionGroups.get(i.sourceID)};if(r)for(let t of i.sortKeyRanges){let{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=t;e.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:_})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:i.symbolInstances.length,parameters:_})}attemptAnchorPlacement(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x){let S=GC[e.textAnchor],C=[e.textOffset0,e.textOffset1],w=kj(S,n,r,C,i),T=this.collisionIndex.placeCollisionBox(t,d,s,c,l,o,a,h,u.predicate,v,w,y,b,x);if((!_||this.collisionIndex.placeCollisionBox(_,d,s,c,l,o,a,g,u.predicate,v,w,y,b,x).placeable)&&T.placeable){let e;if(this.prevPlacement?.variableOffsets[f.crossTileID]&&this.prevPlacement?.placements[f.crossTileID]?.text&&(e=this.prevPlacement.variableOffsets[f.crossTileID].anchor),f.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);return this.variableOffsets[f.crossTileID]={textOffset:C,width:n,height:r,anchor:S,textBoxScale:i,prevAnchor:e},this.markUsedJustification(p,S,f,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,f),this.placedOrientations[f.crossTileID]=m),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(e,t,n){let{bucket:r,layout:i,collisionBoxArray:a}=e.parameters,o=i.get(`text-optional`),s=i.get(`icon-optional`),c=QC(i,`text-overlap`,`text-allow-overlap`),l=c===`always`,u=QC(i,`icon-overlap`,`icon-allow-overlap`),d=u===`always`,f=i.get(`text-rotation-alignment`)===`map`,p=i.get(`text-pitch-alignment`)===`map`,m=i.get(`icon-text-fit`)!==`none`,h=i.get(`symbol-z-order`)===`viewport-y`,g=i.get(`symbol-height-anchor`)===`ground`,_=l&&(d||!r.hasIconData()||s),v=d&&(l||!r.hasTextData()||o);!r.collisionArrays&&a&&r.deserializeCollisionBoxes(a);let y=this.retainedQueryData[r.bucketInstanceId].tileID,b=this._getTerrainElevationFunc(y),x=Q(this.projectedCamera).getFastPathSimpleProjectionMatrix(this.projectedCamera,y),S={...e.parameters,textOptional:o,iconOptional:s,textOverlapMode:c,textAlwaysOverlap:l,iconOverlapMode:u,rotateWithMap:f,pitchWithMap:p,hasIconTextFit:m,heightAnchorGround:g,alwaysShowText:_,alwaysShowIcon:v,tileID:y,getElevation:b,simpleProjectionMatrix:x,seenCrossTileIDs:t,showCollisionBoxes:n,filter:r.layers[0]._featureFilter};if(h){if(e.symbolInstanceStart!==0)throw Error(`bucket.bucketInstanceId should be 0`);let t=r.getSortedSymbolIndexes(-this.projectedCamera.bearingInRadians);for(let e=t.length-1;e>=0;--e){let n=t[e];this._placeSymbol(S,r.symbolInstances.get(n),r.collisionArrays[n],n)}}else for(let t=e.symbolInstanceStart;t=0){let n=e.bucket.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),r=TC(e.bucket.textSizeData,e.partiallyEvaluatedTextSize,n),i=e.layout.get(`text-padding`),o=t.collisionCircleDiameter;f=this.collisionIndex.placeCollisionCircles(e.textOverlapMode,n,e.bucket.lineVertexArray,e.bucket.glyphOffsetArray,r,e.unwrappedTileID,e.pitchedLabelPlaneMatrix,e.showCollisionBoxes,e.pitchWithMap,e.collisionGroup.predicate,o,i,e.translationText,e.getElevation),f.circles.length&&f.collisionDetected&&!e.showCollisionBoxes&&ig(`Collisions detected, but collision boxes are not shown`),a=e.textAlwaysOverlap||f.circles.length>0&&!f.collisionDetected,s&&=f.offscreen}if(n.iconFeatureIndex&&(g=n.iconFeatureIndex),n.iconBox){let t=t=>this.collisionIndex.placeCollisionBox(t,e.iconOverlapMode,e.textPixelRatio,e.tileID,e.unwrappedTileID,e.pitchWithMap,e.rotateWithMap,e.translationIcon,e.collisionGroup.predicate,e.getElevation,e.hasIconTextFit&&c?c:void 0,e.simpleProjectionMatrix,i,e.heightAnchorGround);u&&u.placeable&&n.verticalIconBox?(p=t(n.verticalIconBox),o=p.placeable):(p=t(n.iconBox),o=p.placeable),s&&=p.offscreen}let v=e.textOptional||t.numHorizontalGlyphVertices===0&&t.numVerticalGlyphVertices===0,y=e.iconOptional||t.numIconVertices===0;!v&&!y?o=a=o&&a:y?v||(o&&=a):a=o&&a;let b=a&&d.placeable,x=o&&p.placeable;if(b&&(u&&u.placeable&&h?this.collisionIndex.insertCollisionBox(d.box,e.textOverlapMode,e.layout.get(`text-ignore-placement`),e.bucket.bucketInstanceId,h,e.collisionGroup.ID):this.collisionIndex.insertCollisionBox(d.box,e.textOverlapMode,e.layout.get(`text-ignore-placement`),e.bucket.bucketInstanceId,m,e.collisionGroup.ID)),x&&this.collisionIndex.insertCollisionBox(p.box,e.iconOverlapMode,e.layout.get(`icon-ignore-placement`),e.bucket.bucketInstanceId,g,e.collisionGroup.ID),f&&a&&this.collisionIndex.insertCollisionCircles(f.circles,e.textOverlapMode,e.layout.get(`text-ignore-placement`),e.bucket.bucketInstanceId,m,e.collisionGroup.ID),e.showCollisionBoxes&&this.storeCollisionData(e.bucket.bucketInstanceId,r,n,d,p,f),t.crossTileID===0)throw Error(`symbolInstance.crossTileID can't be 0`);if(e.bucket.bucketInstanceId===0)throw Error(`context.bucket.bucketInstanceId can't be 0`);let S=(a||e.alwaysShowText)&&!d?.occluded,C=(o||e.alwaysShowIcon)&&!p?.occluded;this.placements[t.crossTileID]=new Oj(S,C,s||e.bucket.justReloaded),e.seenCrossTileIDs[t.crossTileID]=!0}_placeTextBox(e,t,n,r){let i=this.collisionIndex.placeCollisionBox(n,e.textOverlapMode,e.textPixelRatio,e.tileID,e.unwrappedTileID,e.pitchWithMap,e.rotateWithMap,e.translationText,e.collisionGroup.predicate,e.getElevation,void 0,e.simpleProjectionMatrix,t.heightOffset,e.heightAnchorGround);return i?.placeable&&(this.markUsedOrientation(e.bucket,r,t),this.placedOrientations[t.crossTileID]=r),i}_placeTextAtVariableAnchors(e,t,n,r,i,a,o){let s=r.x2-r.x1,c=r.y2-r.y1,l=t.textBoxScale,u=e.hasIconTextFit&&e.iconOverlapMode===`never`?i:null,d=null,f=e.textOverlapMode===`never`?1:2,p=`never`;o&&f++;for(let n=0;n=0&&(a>=0&&t!==a?e.text.placedSymbolArray.get(t).crossTileID=0:e.text.placedSymbolArray.get(t).crossTileID=n.crossTileID)}markUsedOrientation(e,t,n){let r=t===1||t===3?t:0,i=t===2?t:0,a=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(let t of a)e.text.placedSymbolArray.get(t).placedOrientation=r;n.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=i)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.projectedCamera.zoom;let t=this.prevPlacement,n=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.projectedCamera.zoom):0;let r=t?t.symbolFadeChange(e):1,i=t?t.opacities:{},a=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(let e in this.placements){let t=this.placements[e],a=i[e];a?(this.opacities[e]=new Dj(a,r,t.text,t.icon),n||=t.text!==a.text.placed,n||=t.icon!==a.icon.placed):(this.opacities[e]=new Dj(null,r,t.text,t.icon,t.skipFade),n||=t.text||t.icon)}for(let e in i){let t=i[e];if(!this.opacities[e]){let i=new Dj(t,r,!1,!1);i.isHidden()||(this.opacities[e]=i,n||=t.text.placed,n||=t.icon.placed)}}for(let e in a)!this.variableOffsets[e]&&this.opacities[e]&&!this.opacities[e].isHidden()&&(this.variableOffsets[e]=a[e]);for(let e in o)!this.placedOrientations[e]&&this.opacities[e]&&!this.opacities[e].isHidden()&&(this.placedOrientations[e]=o[e]);if(t&&t.lastPlacementChangeTime===void 0)throw Error(`Last placement time for previous placement is not defined`);n?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!=`number`&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){let n={};for(let r of t){let t=r.getBucket(e);if(!t||!r.latestFeatureIndex||e.id!==t.layerIds[0])continue;let{duplicates:i,changed:a}=this._markDuplicates(t,n),o=!!t.hasDebugData()||t.bucketInstanceId in this.collisionCircleArrays;(a||o)&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray),t.sortFeatures(-this.projectedCamera.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder)}}_markDuplicates(e,t){let n=e.symbolInstances.length,r=this.lastOpacityInputs.get(e),i=!1;r||(r={crossTileIDs:Array(n).fill(0),duplicates:Array(n).fill(!1)},this.lastOpacityInputs.set(e,r),i=!0);let{crossTileIDs:a,duplicates:o}=r,s=e.symbolInstances.uint32,c=e.symbolInstances.bytesPerElement/4;for(let e=0;e{for(let r=0;r0||a>0,v=r.numIconVertices>0,y=this.placedOrientations[r.crossTileID],b=y===2,x=y===1||y===3;if(_){let t=jj(g.text),n=b?0:t;m(e.text,i,n);let o=x?0:t;m(e.text,a,o);let s=g.text.isHidden(),c=[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex];for(let t of c)t>=0&&(e.text.placedSymbolArray.get(t).hidden=s||b?1:0);r.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=s||x?1:0);let l=this.variableOffsets[r.crossTileID];l&&this.markUsedJustification(e,l.anchor,r,y);let u=this.placedOrientations[r.crossTileID];u&&(this.markUsedJustification(e,`left`,r,u),this.markUsedOrientation(e,u,r))}if(v){let t=jj(g.icon),n=!(f&&r.verticalPlacedIconSymbolIndex&&b);if(r.placedIconSymbolIndex>=0){let i=n?t:0;m(e.icon,r.numIconVertices,i),e.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=g.icon.isHidden()}if(r.verticalPlacedIconSymbolIndex>=0){let i=n?0:t;m(e.icon,r.numVerticalIconVertices,i),e.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden()}}let S=h?.has(t)?h.get(t):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let n=e.collisionArrays[t];if(n){let t=new U(0,0);if(n.textBox||n.verticalTextBox){let r=!0;if(l){let e=this.variableOffsets[s];e?(t=kj(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&t._rotate(d?-this.projectedCamera.bearingInRadians:this.projectedCamera.bearingInRadians)):r=!1}if(n.textBox||n.verticalTextBox){let i;n.textBox&&(i=b),n.verticalTextBox&&(i=x),Aj(e.textCollisionBox.collisionVertexArray,g.text.placed,!r||i,S.text,t.x,t.y)}}if(n.iconBox||n.verticalIconBox){let r=!(x||!n.verticalIconBox),i;n.iconBox&&(i=r),n.verticalIconBox&&(i=!r),Aj(e.iconCollisionBox.collisionVertexArray,g.icon.placed,i,S.icon,f?t.x:0,f?t.y:0)}}}}if(e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.projectedCamera.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}};function Aj(e,t,n,r,i,a){r&&r.length!==0||(r=[0,0,0,0]);let o=r[0]-100,s=r[1]-100,c=r[2]-100,l=r[3]-100;e.emplaceBack(+!!t,+!!n,i||0,a||0,o,s),e.emplaceBack(+!!t,+!!n,i||0,a||0,c,s),e.emplaceBack(+!!t,+!!n,i||0,a||0,c,l),e.emplaceBack(+!!t,+!!n,i||0,a||0,o,l)}var mre=2**25,hre=2**24,gre=2**17,_re=2**16;function jj(e){if(e.opacity===0&&!e.placed)return 0;if(e.opacity===1&&e.placed)return vre;let t=+!!e.placed,n=Math.floor(e.opacity*127);return n*mre+t*hre+n*gre+t*_re+n*512+t*256+n*2+t}var vre=0xffffffff;function yre(e,t,n){return e.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&n.verticalTextBox?e.writingModes.map(e=>e===2?2:1):bre}var bre=[1],xre=class{constructor(e){this._sortAcrossTiles=e.layout.get(`symbol-z-order`)!==`viewport-y`&&!e.layout.get(`symbol-sort-key`).isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,n,r,i){let a=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex!this._forceFullPlacement&&Ig()-r>2;for(;this._currentPlacementIndex>=0;){let r=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.projectedCamera.zoom;if(ow(r)&&r.layout&&(!r.minzoom||r.minzoom<=a)&&(!r.maxzoom||r.maxzoom>a)){if(this._inProgressLayer||=new xre(r),this._inProgressLayer.continuePlacement(n[r.source],this.placement,this._showCollisionBoxes,r,i))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}},Mj=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Nj=new Uint32Array(96),Cre=class e{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error(`Data must be an instance of ArrayBuffer or SharedArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==1)throw Error(`Got v${i} data when expected v1.`);let a=Mj[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,void 0,t)}constructor(e,t=64,n=Float64Array,r=ArrayBuffer,i){if(isNaN(e)||e<0)throw Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let a=Mj.indexOf(this.ArrayType),o=e*2*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,c=(8-s%8)%8;if(a<0)throw Error(`Unexpected typed array class: ${n}.`);if(i)this.data=i,this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=e*2,this._finished=!0;else{let i=this.data=new r(8+o+s+c);this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=0,this._finished=!1,new Uint8Array(i,0,2).set([219,16+a]),new Uint16Array(i,2,1)[0]=t,new Uint32Array(i,4,1)[0]=e}}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return Pj(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;Nj[0]=0,Nj[1]=i.length-1,Nj[2]=0;let s=3,c=[];for(;s>0;){let l=Nj[--s],u=Nj[--s],d=Nj[--s];if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&(Nj[s++]=d,Nj[s++]=f-1,Nj[s++]=1-l),(l===0?n>=p:r>=m)&&(Nj[s++]=f+1,Nj[s++]=u,Nj[s++]=1-l)}return c}within(e,t,n){let r=[];return this.withinInto(e,t,n,r),r}withinInto(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;Nj[0]=0,Nj[1]=i.length-1,Nj[2]=0;let s=3,c=0,l=n*n;for(;s>0;){let u=Nj[--s],d=Nj[--s],f=Nj[--s];if(d-f<=o){for(let n=f;n<=d;n++)Rj(a[2*n],a[2*n+1],e,t)<=l&&(r[c++]=i[n]);continue}let p=f+d>>1,m=a[2*p],h=a[2*p+1];Rj(m,h,e,t)<=l&&(r[c++]=i[p]),(u===0?e-n<=m:t-n<=h)&&(Nj[s++]=f,Nj[s++]=p-1,Nj[s++]=1-u),(u===0?e+n>=m:t+n>=h)&&(Nj[s++]=p+1,Nj[s++]=d,Nj[s++]=1-u)}return c}};function Pj(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;Fj(e,t,o,r,i,a),Pj(e,t,n,r,o-1,1-a),Pj(e,t,n,o+1,i,1-a)}function Fj(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);Fj(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(Ij(e,t,r,n),t[2*i+a]>o&&Ij(e,t,r,i);so;)c--}t[2*r+a]===o?Ij(e,t,r,c):(c++,Ij(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function Ij(e,t,n,r){Lj(e,n,r),Lj(t,2*n,2*r),Lj(t,2*n+1,2*r+1)}function Lj(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function Rj(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}var zj=512/W/2,wre=class{constructor(e,t,n){this.tileID=e,this.bucketInstanceId=n,this._symbolsByKey={};let r=new Map;for(let e=0;e({x:Math.floor(e.anchorX*zj),y:Math.floor(e.anchorY*zj)})),crossTileIDs:t.map(e=>e.crossTileID)};if(n.positions.length>128){let e=new Cre(n.positions.length,16,Uint16Array);for(let{x:t,y:r}of n.positions)e.add(t,r);e.finish(),delete n.positions,n.index=e}this._symbolsByKey[e]=n}}getScaledCoordinates(e,t){let{x:n,y:r,z:i}=this.tileID.canonical,{x:a,y:o,z:s}=t.canonical,c=zj/2**(s-i),l=(a*W+e.anchorX)*c,u=(o*W+e.anchorY)*c,d=n*W*zj,f=r*W*zj;return{x:Math.floor(l-d),y:Math.floor(u-f)}}findMatches(e,t,n){let r=this.tileID.canonical.ze)}},Tre=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},Ere=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let t=Math.round((e-this.lng)/360);if(t!==0)for(let e in this.indexes){let n=this.indexes[e],r={};for(let e in n){let i=n[e];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+t),r[i.tileID.key]=i}this.indexes[e]=r}this.lng=e}addBucket(e,t,n){if(this.indexes[e.overscaledZ]?.[e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;ee.overscaledZ)for(let n in i){let a=i[n];a.tileID.isChildOf(e)&&a.findMatches(t.symbolInstances,e,r)}else{let a=i[e.scaledTo(Number(n)).key];a&&a.findMatches(t.symbolInstances,e,r)}}for(let e=0;e> 1u)/127.0,float(packedOpacity & 1u));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c );} #ifdef TERRAIN3D uniform sampler2D u_terrain;uniform highp sampler2D u_depth;layout(std140) uniform TerrainUBO {highp mat4 u_terrain_matrix;highp vec4 u_terrain_unpack;highp float u_terrain_dim;highp float u_terrain_exaggeration;}; #endif const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) { #ifdef TERRAIN3D highp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0)); #else return 1.0; #endif }float calculate_visibility(vec4 pos) { #ifdef TERRAIN3D vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0; #else return 1.0; #endif }float ele(ivec2 pos) { #ifdef TERRAIN3D vec4 rgb=(texelFetch(u_terrain,pos,0)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a; #else return 0.0; #endif }float get_elevation(vec2 pos) { #ifdef TERRAIN3D #ifdef GLOBE if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;} #endif vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.5;vec2 f=fract(coord);ivec2 c=ivec2(floor(coord));ivec2 hi=textureSize(u_terrain,0)-1;float tl=ele(clamp(c,ivec2(0),hi));float tr=ele(clamp(c+ivec2(1,0),ivec2(0),hi));float bl=ele(clamp(c+ivec2(0,1),ivec2(0),hi));float br=ele(clamp(c+ivec2(1,1),ivec2(0),hi));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration; #else return 0.0; #endif }const float PI=3.141592653589793; #define PROJECTION_UBO layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp vec4 u_projection_tile_origin;highp vec2 u_projection_tile_origin_position;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};`,Are=`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity; #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,jre=`layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}`,Mre=`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity; #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,Nre=`uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}`,Pre=`in vec3 v_data;in float v_visibility; #pragma maplibre: define highp vec4 color #pragma maplibre: define mediump float radius #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity #pragma maplibre: define highp vec4 stroke_color #pragma maplibre: define mediump float stroke_width #pragma maplibre: define lowp float stroke_opacity void main() { #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize mediump float radius #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize highp vec4 stroke_color #pragma maplibre: initialize mediump float stroke_width #pragma maplibre: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;} #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,Fre=`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform vec2 u_translate;layout(location=0) in ivec2 a_pos;out vec3 v_data;out float v_visibility; #pragma maplibre: define highp vec4 color #pragma maplibre: define mediump float radius #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity #pragma maplibre: define highp vec4 stroke_color #pragma maplibre: define mediump float stroke_width #pragma maplibre: define lowp float stroke_opacity void main(void) { #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize mediump float radius #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize highp vec4 stroke_color #pragma maplibre: initialize mediump float stroke_width #pragma maplibre: initialize lowp float stroke_opacity ivec2 pos_raw=a_pos+32768;vec2 extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;vec2 circle_center=vec2(pos_raw >> 3)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) { #ifdef GLOBE vec3 center_vector=projectToSphereOffset(circle_center); #endif float angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else { #ifdef GLOBE vec4 projected_center=interpolateProjection(circle_center,center_vector,ele); #else vec4 projected_center=projectTileWithElevation(circle_center,ele); #endif corner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);} #ifdef GLOBE vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVectorOffset(circle_center,center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele); #else gl_Position=projectTileWithElevation(corner_position,ele); #endif } else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`,Vj=`void main() {fragColor=vec4(1.0);}`,Hj={prelude:Uj(Ore,kre),projectionMercator:Uj(` void clipAntimeridian() {}`,`float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}`),projectionGlobe:Uj(`in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian !=0 && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}`,`#define GLOBE_RADIUS 6371008.8 #ifndef PROJECTION_UBO uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp vec4 u_projection_tile_origin;uniform highp vec2 u_projection_tile_origin_position;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix; #endif out highp float v_projection_tile_x;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos );}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float t=exp(PI-(mercator_pos_y*PI*2.0));return (2.0*t)/(t*t+1.0);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;float spherical_x=mercator_pos.x*PI*2.0+PI;float t=exp(PI-(mercator_pos.y*PI*2.0));float t2=t*t;float denom=t2+1.0;float sin_sy=(t2-1.0)/denom;float cos_sy=(2.0*t)/denom;vec3 pos=vec3(sin(spherical_x)*cos_sy,sin_sy,cos(spherical_x)*cos_sy );if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeSinSmall(float x) {float x2=x*x;return x*(1.0-x2/6.0*(1.0-x2/20.0*(1.0-x2/42.0*(1.0-x2/72.0*(1.0-x2/110.0*(1.0-x2/156.0))))));}float globeTanSmall(float x) {if (abs(x) >=0.5) {return tan(x);}float s=globeSinSmall(x);return s/sqrt(1.0-s*s);}float globeExpm1Small(float x) {if (abs(x) >=0.5) {return exp(x)-1.0;}return x*(1.0+x/2.0*(1.0+x/3.0*(1.0+x/4.0*(1.0+x/5.0*(1.0+x/6.0*(1.0+x/7.0*(1.0+x/8.0)))))));}vec3 globeTileOrigin() {if (u_projection_tile_origin.w < 0.5) {return vec3(0.0);}float t=u_projection_tile_origin.z;float denom=t*t+1.0;float cos_sy=2.0*t/denom;return vec3(u_projection_tile_origin.x*cos_sy,(t*t-1.0)/denom,u_projection_tile_origin.y*cos_sy);}vec2 globeAnglesFromTileOrigin(vec2 translatedPos) {return u_projection_tile_mercator_coords.zw*(translatedPos-u_projection_tile_origin_position)*(PI*2.0);}bool globeIsNearTileOrigin(vec2 translatedPos) {if (u_projection_tile_origin.w < 0.5) {return false;}vec2 delta=abs(globeAnglesFromTileOrigin(translatedPos));return delta.x <=PI*0.5 && delta.y <=PI*0.5;}vec3 projectToSphereOffset(vec2 translatedPos,vec2 rawPos) {if (!globeIsNearTileOrigin(translatedPos)) {return projectToSphere(translatedPos,rawPos)-globeTileOrigin();}if (rawPos.y <-32767.5) {return vec3(0.0,1.0,0.0)-globeTileOrigin();}if (rawPos.y > 32766.5) {return vec3(0.0,-1.0,0.0)-globeTileOrigin();}vec2 delta=globeAnglesFromTileOrigin(translatedPos);float sin_x0=u_projection_tile_origin.x;float cos_x0=u_projection_tile_origin.y;float t0=u_projection_tile_origin.z;float t0_2=t0*t0;float e=globeExpm1Small(-delta.y);float t=t0+t0*e;float denom=(t*t+1.0)*(t0_2+1.0);float d_sin_sy=2.0*t0_2*e*(2.0+e)/denom;float d_cos_sy=2.0*t0*e*(1.0-t*t0)/denom;float cos_sy=2.0*t0/(t0_2+1.0)+d_cos_sy;float sin_dx=globeSinSmall(delta.x);float half_sin_dx=globeSinSmall(delta.x*0.5);float cos_dx_minus_one=-2.0*half_sin_dx*half_sin_dx;float d_sin_x=sin_x0*cos_dx_minus_one+cos_x0*sin_dx;float d_cos_x=cos_x0*cos_dx_minus_one-sin_x0*sin_dx;return vec3(sin_x0*d_cos_sy+d_sin_x*cos_sy,d_sin_sy,cos_x0*d_cos_sy+d_cos_x*cos_sy );}vec3 projectToSphereOffset(vec2 posInTile) {return projectToSphereOffset(posInTile,vec2(0.0,0.0));}vec3 globeRotateVectorOffset(vec2 posInTile,vec3 offset,vec2 angles) {if (!globeIsNearTileOrigin(posInTile)) {return globeRotateVector(projectToSphere(posInTile),angles)-globeTileOrigin();}vec3 vec=globeTileOrigin()+offset;mat3 axes=globeGetRotationMatrix(vec);vec3 d=axes[0]*globeTanSmall(angles.x)+axes[1]*globeTanSmall(angles.y);float len=sqrt(1.0+dot(d,d));return offset+(d-vec*(dot(d,d)/(1.0+len)))/len;}float globeComputeClippingZ(vec3 spherePos) {return (1.0-min(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w,0.5));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 origin=globeTileOrigin();vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS)+origin*(elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS)+globeTileOrigin()*(elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphereOffset(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphereOffset(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphereOffset(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphereOffset(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:Uj(Are,jre),backgroundPattern:Uj(Mre,Nre),circle:Uj(Pre,Fre),clippingMask:Uj(Vj,`layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}`),heatmap:Uj(`uniform highp float u_intensity;in vec2 v_extrude; #pragma maplibre: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma maplibre: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0); #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;layout(location=0) in ivec2 a_pos;out vec2 v_extrude; #pragma maplibre: define highp float weight #pragma maplibre: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main(void) { #pragma maplibre: initialize highp float weight #pragma maplibre: initialize mediump float radius ivec2 pos_raw=a_pos+32768;vec2 unscaled_extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=vec2(pos_raw >> 3); #ifdef GLOBE vec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphereOffset(circle_center);vec3 corner_vector=globeRotateVectorOffset(circle_center,center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0); #else gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center)); #endif }`),heatmapTexture:Uj(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR fragColor=vec4(0.0); #endif }`,`uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world_size,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}`),collisionBox:Uj(`in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}`,`layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Uj(`in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}`,`layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),colorRelief:Uj(`#ifdef GL_ES precision highp float; #endif uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {vec4 data=texelFetch(u_elevation_stops,ivec2(stop,0),0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else {l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0)); #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=2.0/u_dimension;float scale=(u_dimension.x-4.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}`),debug:Uj(`uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}`,`layout(location=0) in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}`),depth:Uj(Vj,`layout(location=0) in vec2 a_pos;void main() { #ifdef GLOBE gl_Position=projectTileFor3D(a_pos,0.0); #else gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0); #endif }`),fill:Uj(`#pragma maplibre: define highp vec4 color #pragma maplibre: define lowp float opacity void main() { #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize lowp float opacity fragColor=color*opacity; #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos; #pragma maplibre: define highp vec4 color #pragma maplibre: define lowp float opacity void main() { #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize lowp float opacity if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:Uj(`in vec2 v_pos; #ifdef GLOBE in float v_depth; #endif #pragma maplibre: define highp vec4 outline_color #pragma maplibre: define lowp float opacity void main() { #pragma maplibre: initialize highp vec4 outline_color #pragma maplibre: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity); #ifdef GLOBE if (v_depth > 1.0) {discard;} #endif #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos; #ifdef GLOBE out float v_depth; #endif #pragma maplibre: define highp vec4 outline_color #pragma maplibre: define lowp float opacity void main() { #pragma maplibre: initialize highp vec4 outline_color #pragma maplibre: initialize lowp float opacity if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size; #ifdef GLOBE v_depth=gl_Position.z/gl_Position.w; #endif }`),fillOutlinePattern:Uj(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;uniform bool u_sdf_pattern;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos; #ifdef GLOBE in float v_depth; #endif #pragma maplibre: define lowp float opacity #pragma maplibre: define highp vec4 color #pragma maplibre: define lowp vec4 pattern_from #pragma maplibre: define lowp vec4 pattern_to void main() { #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize mediump vec4 pattern_from #pragma maplibre: initialize mediump vec4 pattern_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*alpha*opacity;} else {fragColor=mix(color1,color2,u_fade)*alpha*opacity;} #ifdef GLOBE if (v_depth > 1.0) {discard;} #endif #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos; #ifdef GLOBE out float v_depth; #endif #pragma maplibre: define lowp float opacity #pragma maplibre: define highp vec4 color #pragma maplibre: define lowp vec4 pattern_from #pragma maplibre: define lowp vec4 pattern_to #pragma maplibre: define lowp float pixel_ratio_from #pragma maplibre: define lowp float pixel_ratio_to void main() { #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize mediump vec4 pattern_from #pragma maplibre: initialize mediump vec4 pattern_to #pragma maplibre: initialize lowp float pixel_ratio_from #pragma maplibre: initialize lowp float pixel_ratio_to if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size; #ifdef GLOBE v_depth=gl_Position.z/gl_Position.w; #endif }`),fillPattern:Uj(`#ifdef GL_ES precision highp float; #endif uniform vec2 u_texsize;uniform float u_fade;uniform bool u_sdf_pattern;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b; #pragma maplibre: define lowp float opacity #pragma maplibre: define highp vec4 color #pragma maplibre: define lowp vec4 pattern_from #pragma maplibre: define lowp vec4 pattern_to void main() { #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize mediump vec4 pattern_from #pragma maplibre: initialize mediump vec4 pattern_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*opacity;} else {fragColor=mix(color1,color2,u_fade)*opacity;} #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b; #pragma maplibre: define lowp float opacity #pragma maplibre: define highp vec4 color #pragma maplibre: define lowp vec4 pattern_from #pragma maplibre: define lowp vec4 pattern_to #pragma maplibre: define lowp float pixel_ratio_from #pragma maplibre: define lowp float pixel_ratio_to void main() { #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize mediump vec4 pattern_from #pragma maplibre: initialize mediump vec4 pattern_to #pragma maplibre: initialize lowp float pixel_ratio_from #pragma maplibre: initialize lowp float pixel_ratio_to if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:Uj(`in vec4 v_color;void main() {fragColor=v_color; #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed; #ifdef TERRAIN3D layout(location=2) in vec2 a_centroid; #endif out vec4 v_color; #pragma maplibre: define highp float base #pragma maplibre: define highp float height #pragma maplibre: define highp vec4 color #pragma maplibre: define highp float opacity void main() { #pragma maplibre: initialize highp float base #pragma maplibre: initialize highp float height #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize highp float opacity opacity=clamp(opacity,0.0,1.0);if (opacity <=0.0) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec3 normal=vec3(a_normal_ed.xyz);float gradient_base=max(0.0,base);float gradient_height=max(0.0,height); #ifdef TERRAIN3D float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); #else float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; #endif base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate; #ifdef GLOBE vec3 spherePos=projectToSphereOffset(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation); #else gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0); #endif float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0); #ifdef GLOBE mat3 rotMatrix=globeGetRotationMatrix(globeTileOrigin()+spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition); #endif directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.z==0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+gradient_base)*pow(gradient_height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=opacity;}`),fillExtrusionPattern:Uj(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting; #pragma maplibre: define lowp float base #pragma maplibre: define lowp float height #pragma maplibre: define lowp vec4 pattern_from #pragma maplibre: define lowp vec4 pattern_to #pragma maplibre: define lowp float pixel_ratio_from #pragma maplibre: define lowp float pixel_ratio_to void main() { #pragma maplibre: initialize lowp float base #pragma maplibre: initialize lowp float height #pragma maplibre: initialize mediump vec4 pattern_from #pragma maplibre: initialize mediump vec4 pattern_to #pragma maplibre: initialize lowp float pixel_ratio_from #pragma maplibre: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting; #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed; #ifdef TERRAIN3D layout(location=2) in vec2 a_centroid; #endif #ifdef GLOBE out vec3 v_sphere_pos; #endif out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting; #pragma maplibre: define lowp float base #pragma maplibre: define lowp float height #pragma maplibre: define lowp vec4 pattern_from #pragma maplibre: define lowp vec4 pattern_to #pragma maplibre: define lowp float pixel_ratio_from #pragma maplibre: define lowp float pixel_ratio_to #pragma maplibre: define highp float opacity void main() { #pragma maplibre: initialize lowp float base #pragma maplibre: initialize lowp float height #pragma maplibre: initialize mediump vec4 pattern_from #pragma maplibre: initialize mediump vec4 pattern_to #pragma maplibre: initialize lowp float pixel_ratio_from #pragma maplibre: initialize lowp float pixel_ratio_to #pragma maplibre: initialize highp float opacity opacity=clamp(opacity,0.0,1.0);if (opacity <=0.0) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=vec3(a_normal_ed.xyz);float edgedistance=float(a_normal_ed.w);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;float gradient_base=max(0.0,base);float gradient_height=max(0.0,height); #ifdef TERRAIN3D float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); #else float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; #endif base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate; #ifdef GLOBE vec3 spherePos=projectToSphereOffset(posInTile,a_pos);vec3 elevatedPos=(globeTileOrigin()+spherePos)*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation); #else gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0); #endif vec2 pos=a_normal_ed.x==1 && a_normal_ed.y==0 && a_normal_ed.z==16384 ? a_pos : vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.z==0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+gradient_base)*pow(gradient_height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=opacity;}`),hillshadePrepare:Uj(`#ifdef GL_ES precision highp float; #endif uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;uniform float u_log2_world_width;float getElevation(ivec2 texel) {vec4 data=texelFetch(u_image,texel,0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {ivec2 pos=ivec2(gl_FragCoord.xy)+ivec2(1);float tileSize=u_dimension.x-4.0;float a=getElevation(pos+ivec2(-1,-1));float b=getElevation(pos+ivec2(0,-1));float c=getElevation(pos+ivec2(1,-1));float d=getElevation(pos+ivec2(-1,0));float e=getElevation(pos);float f=getElevation(pos+ivec2(1,0));float g=getElevation(pos+ivec2(-1,1));float h=getElevation(pos+ivec2(0,1));float i=getElevation(pos+ivec2(1,1));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(3.0+u_log2_world_width-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+128.0/255.0,deriv.y/8.0+128.0/255.0,1.0,1.0),0.0,1.0); #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;layout(location=1) in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}`),hillshade:Uj(`uniform sampler2D u_image;in highp vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES]; #define PI 3.141592653589793 #define STANDARD 0 #define COMBINED 1 #define IGOR 2 #define MULTIDIRECTIONAL 3 #define BASIC 4 float get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else {fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else {fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {highp vec2 size=vec2(textureSize(u_image,0));highp vec2 texturePos=(v_pos*(size-2.0)+1.0)/size;vec4 pixel=texture(u_image,texturePos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=(pixel.rg-128.0/255.0)*8.0/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);} #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}`),line:Uj(`in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale; #ifdef GLOBE in float v_depth; #endif #pragma maplibre: define highp vec4 color #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity void main() { #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity); #ifdef GLOBE if (v_depth > 1.0) {discard;} #endif #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar; #ifdef GLOBE out float v_depth; #endif #pragma maplibre: define highp vec4 color #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity #pragma maplibre: define mediump float gapwidth #pragma maplibre: define lowp float offset #pragma maplibre: define mediump float width void main() { #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize mediump float gapwidth #pragma maplibre: initialize lowp float offset #pragma maplibre: initialize mediump float width if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);v_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*2.0;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump vec2 offset2=offset*a_offset_normal*scale*normal.y;float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; #ifdef GLOBE v_depth=gl_Position.z/gl_Position.w; #endif #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_width2=vec2(outset,inset);}`),lineGradient:Uj(`uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv; #ifdef GLOBE in float v_depth; #endif #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity void main() { #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity); #ifdef GLOBE if (v_depth > 1.0) {discard;} #endif #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;layout(location=3) in float a_uv_x;layout(location=4) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv; #ifdef GLOBE out float v_depth; #endif #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity #pragma maplibre: define mediump float gapwidth #pragma maplibre: define lowp float offset #pragma maplibre: define mediump float width void main() { #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize mediump float gapwidth #pragma maplibre: initialize lowp float offset #pragma maplibre: initialize mediump float width if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump vec2 offset2=offset*a_offset_normal*scale*normal.y;float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; #ifdef GLOBE v_depth=gl_Position.z/gl_Position.w; #endif #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_width2=vec2(outset,inset);}`),linePattern:Uj(`#ifdef GL_ES precision highp float; #endif uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width; #ifdef GLOBE in float v_depth; #endif #pragma maplibre: define lowp vec4 pattern_from #pragma maplibre: define lowp vec4 pattern_to #pragma maplibre: define lowp float pixel_ratio_from #pragma maplibre: define lowp float pixel_ratio_to #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity void main() { #pragma maplibre: initialize mediump vec4 pattern_from #pragma maplibre: initialize mediump vec4 pattern_to #pragma maplibre: initialize lowp float pixel_ratio_from #pragma maplibre: initialize lowp float pixel_ratio_to #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity clipAntimeridian();vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity; #ifdef GLOBE if (v_depth > 1.0) {discard;} #endif #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width; #ifdef GLOBE out float v_depth; #endif #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity #pragma maplibre: define lowp float offset #pragma maplibre: define mediump float gapwidth #pragma maplibre: define mediump float width #pragma maplibre: define lowp float floorwidth #pragma maplibre: define lowp vec4 pattern_from #pragma maplibre: define lowp vec4 pattern_to #pragma maplibre: define lowp float pixel_ratio_from #pragma maplibre: define lowp float pixel_ratio_to void main() { #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize lowp float offset #pragma maplibre: initialize mediump float gapwidth #pragma maplibre: initialize mediump float width #pragma maplibre: initialize lowp float floorwidth #pragma maplibre: initialize mediump vec4 pattern_from #pragma maplibre: initialize mediump vec4 pattern_to #pragma maplibre: initialize lowp float pixel_ratio_from #pragma maplibre: initialize lowp float pixel_ratio_to if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump vec2 offset2=offset*a_offset_normal*scale*normal.y;float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; #ifdef GLOBE v_depth=gl_Position.z/gl_Position.w; #endif #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:Uj(`uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale; #ifdef GLOBE in float v_depth; #endif #pragma maplibre: define highp vec4 color #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity #pragma maplibre: define mediump float width #pragma maplibre: define lowp float floorwidth #pragma maplibre: define mediump vec4 dasharray_from #pragma maplibre: define mediump vec4 dasharray_to void main() { #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize mediump float width #pragma maplibre: initialize lowp float floorwidth #pragma maplibre: initialize mediump vec4 dasharray_from #pragma maplibre: initialize mediump vec4 dasharray_to clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity); #ifdef GLOBE if (v_depth > 1.0) {discard;} #endif #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;layout(location=3) in float a_offset_distance;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale; #ifdef GLOBE out float v_depth; #endif #pragma maplibre: define highp vec4 color #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity #pragma maplibre: define mediump float gapwidth #pragma maplibre: define lowp float offset #pragma maplibre: define mediump float width #pragma maplibre: define lowp float floorwidth #pragma maplibre: define mediump vec4 dasharray_from #pragma maplibre: define mediump vec4 dasharray_to void main() { #pragma maplibre: initialize highp vec4 color #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize mediump float gapwidth #pragma maplibre: initialize lowp float offset #pragma maplibre: initialize mediump float width #pragma maplibre: initialize lowp float floorwidth #pragma maplibre: initialize mediump vec4 dasharray_from #pragma maplibre: initialize mediump vec4 dasharray_to if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump vec2 offset2=offset*a_offset_normal*scale*normal.y;float adjustedThickness=projectLineThickness(pos.y);float linesofar=a_linesofar-offset/u_ratio*adjustedThickness*a_offset_distance;vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; #ifdef GLOBE v_depth=gl_Position.z/gl_Position.w; #endif #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),lineGradientSDF:Uj(`uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv; #ifdef GLOBE in float v_depth; #endif #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity #pragma maplibre: define mediump float width #pragma maplibre: define lowp float floorwidth #pragma maplibre: define mediump vec4 dasharray_from #pragma maplibre: define mediump vec4 dasharray_to void main() { #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize mediump float width #pragma maplibre: initialize lowp float floorwidth #pragma maplibre: initialize mediump vec4 dasharray_from #pragma maplibre: initialize mediump vec4 dasharray_to clipAntimeridian();float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity); #ifdef GLOBE if (v_depth > 1.0) {discard;} #endif #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;layout(location=3) in float a_uv_x;layout(location=4) in float a_split_index;layout(location=5) in float a_offset_distance;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b; #ifdef GLOBE out float v_depth; #endif #pragma maplibre: define lowp float blur #pragma maplibre: define lowp float opacity #pragma maplibre: define mediump float gapwidth #pragma maplibre: define lowp float offset #pragma maplibre: define mediump float width #pragma maplibre: define lowp float floorwidth #pragma maplibre: define mediump vec4 dasharray_from #pragma maplibre: define mediump vec4 dasharray_to void main() { #pragma maplibre: initialize lowp float blur #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize mediump float gapwidth #pragma maplibre: initialize lowp float offset #pragma maplibre: initialize mediump float width #pragma maplibre: initialize lowp float floorwidth #pragma maplibre: initialize mediump vec4 dasharray_from #pragma maplibre: initialize mediump vec4 dasharray_to if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump vec2 offset2=offset*a_offset_normal*scale*normal.y;float adjustedThickness=projectLineThickness(pos.y);float linesofar=a_linesofar-offset/u_ratio*adjustedThickness*a_offset_distance;vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude; #ifdef GLOBE v_depth=gl_Position.z/gl_Position.w; #endif #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),layerComposite:Uj(`uniform sampler2D u_image;uniform float u_opacity; #ifdef LAYER_BLEND uniform sampler2D u_backdrop;uniform highp vec2 u_backdrop_offset; #ifdef LAYER_BLEND_NONSEPARABLE float lum(vec3 c) {return dot(c,vec3(0.3,0.59,0.11));}vec3 clipColor(vec3 c) {float l=lum(c);float n=min(min(c.r,c.g),c.b);float x=max(max(c.r,c.g),c.b);if (n < 0.0) c=l+(c-l)*l/(l-n);if (x > 1.0) c=l+(c-l)*(1.0-l)/(x-l);return c;}vec3 setLum(vec3 c,float l) {return clipColor(c+(l-lum(c)));}float sat(vec3 c) {return max(max(c.r,c.g),c.b)-min(min(c.r,c.g),c.b);}vec3 setSat(vec3 c,float s) {float n=min(min(c.r,c.g),c.b);float x=max(max(c.r,c.g),c.b);return x > n ? (c-n)*s/(x-n) : vec3(0.0);} #endif #ifdef LAYER_BLEND_SOFT_LIGHT vec3 softLight(vec3 cs,vec3 cb) {vec3 d=mix(sqrt(cb),((16.0*cb-12.0)*cb+4.0)*cb,step(cb,vec3(0.25)));vec3 darkened=cb-(1.0-2.0*cs)*cb*(1.0-cb);vec3 lightened=cb+(2.0*cs-1.0)*(d-cb);return mix(darkened,lightened,step(0.5,cs));} #endif #ifdef LAYER_BLEND_COLOR_DODGE vec3 colorDodge(vec3 cs,vec3 cb) {return min(vec3(1.0),cb/max(1.0-cs,1e-3));} #endif #ifdef LAYER_BLEND_COLOR_BURN vec3 colorBurn(vec3 cs,vec3 cb) {return 1.0-min(vec3(1.0),(1.0-cb)/max(cs,1e-3));} #endif vec4 composite(vec4 src,vec4 dst) {vec3 co=vec3(0.0);float invDstA=1.0-dst.a;float invSrcA=1.0-src.a; #ifdef LAYER_BLEND_MULTIPLY co=invDstA*src.rgb+invSrcA*dst.rgb+src.rgb*dst.rgb; #endif #if defined(LAYER_BLEND_OVERLAY) || defined(LAYER_BLEND_HARD_LIGHT) #ifdef LAYER_BLEND_OVERLAY vec3 cond=step(dst.a,2.0*dst.rgb); #else vec3 cond=step(src.a,2.0*src.rgb); #endif vec3 case1=invDstA*src.rgb+invSrcA*dst.rgb+2.0*dst.rgb*src.rgb;vec3 case2=src.rgb+dst.rgb+dst.a*src.rgb+src.a*dst.rgb-vec3(src.a*dst.a)-2.0*dst.rgb*src.rgb;co=mix(case1,case2,cond); #endif #ifdef LAYER_BLEND_DIFFERENCE co=src.rgb+dst.rgb-2.0*min(src.rgb*dst.a,dst.rgb*src.a); #endif #ifdef LAYER_BLEND_EXCLUSION co=src.rgb+dst.rgb-2.0*src.rgb*dst.rgb; #endif #ifdef LAYER_BLEND_DARKEN co=src.rgb+dst.rgb-max(src.rgb*dst.a,dst.rgb*src.a); #endif #ifdef LAYER_BLEND_LIGHTEN co=src.rgb+dst.rgb-min(src.rgb*dst.a,dst.rgb*src.a); #endif #ifdef LAYER_BLEND_UNPREMULTIPLIED vec3 cs=src.rgb/src.a;vec3 cb=dst.a > 0.0 ? dst.rgb/dst.a : vec3(0.0);vec3 blended=vec3(0.0); #ifdef LAYER_BLEND_SOFT_LIGHT blended=softLight(cs,cb); #endif #ifdef LAYER_BLEND_COLOR_DODGE blended=colorDodge(cs,cb); #endif #ifdef LAYER_BLEND_COLOR_BURN blended=colorBurn(cs,cb); #endif #ifdef LAYER_BLEND_HUE blended=setLum(setSat(cs,sat(cb)),lum(cb)); #endif #ifdef LAYER_BLEND_SATURATION blended=setLum(setSat(cb,sat(cs)),lum(cb)); #endif #ifdef LAYER_BLEND_COLOR blended=setLum(cs,lum(cb)); #endif #ifdef LAYER_BLEND_LUMINOSITY blended=setLum(cb,lum(cs)); #endif co=invDstA*src.rgb+invSrcA*dst.rgb+src.a*dst.a*blended; #endif return vec4(co,src.a+dst.a*invSrcA);} #endif void main() {ivec2 texel=ivec2(gl_FragCoord.xy); #ifdef OVERDRAW_INSPECTOR fragColor=texelFetch(u_image,texel,0); #else vec4 src=texelFetch(u_image,texel,0)*u_opacity;if (src.a==0.0) {discard;} #ifdef LAYER_BLEND vec4 dst=texelFetch(u_backdrop,texel-ivec2(u_backdrop_offset),0);fragColor=composite(src,dst); #else fragColor=src; #endif #endif }`,`layout(location=0) in vec2 a_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);}`),raster:Uj(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec3 v_pos0;in vec3 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0.xy/v_pos0.z);vec4 color1=texture(u_image1,v_pos1.xy/v_pos1.z);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a); #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec3 u_image_warp;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec3 v_pos0;out vec3 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 topLeft=u_coords_top.xy;vec2 topRight=u_coords_top.zw;vec2 bottomLeft=u_coords_bottom.xy;vec2 bottomRight=u_coords_bottom.zw;vec2 bilinearPos=mix(mix(topLeft,topRight,fractionalPos.x),mix(bottomLeft,bottomRight,fractionalPos.x),fractionalPos.y);float denominator=dot(u_image_warp.xy,fractionalPos)+1.0;vec2 acrossTop=topRight-topLeft+u_image_warp.x*topRight;vec2 downLeft=bottomLeft-topLeft+u_image_warp.y*bottomLeft;vec2 projectivePos=(acrossTop*fractionalPos.x+downLeft*fractionalPos.y+topLeft)/denominator;vec2 position=mix(projectivePos,bilinearPos,u_image_warp.z);gl_Position=projectTile(position,position);vec2 texturePos=((fractionalPos-0.5)/u_buffer_scale)+0.5; #ifdef GLOBE if (a_pos.y <-32767.5) {texturePos.y=0.0;}if (a_pos.y > 32766.5) {texturePos.y=1.0;} #endif float perspectiveRatio=mix(1.0/denominator,1.0,u_image_warp.z);v_pos0=vec3(texturePos*perspectiveRatio,perspectiveRatio);vec2 parentPos=(texturePos*u_scale_parent)+u_tl_parent;v_pos1=vec3(parentPos*perspectiveRatio,perspectiveRatio);}`),symbolIcon:Uj(`uniform sampler2D u_texture;in vec2 v_tex;in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity; #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform bool u_rotate_symbol;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_tex;out float v_total_opacity; #pragma maplibre: define lowp float opacity void main() { #pragma maplibre: initialize lowp float opacity vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=mix(-u_symbol_fade_change,u_symbol_fade_change,fade_opacity[1]);float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0; #ifdef GLOBE if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);} #endif vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}`),symbolSDF:Uj(`#define SDF_PX 8.0 uniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1; #pragma maplibre: define highp vec4 fill_color #pragma maplibre: define highp vec4 halo_color #pragma maplibre: define lowp float halo_width #pragma maplibre: define lowp float halo_blur void main() { #pragma maplibre: initialize highp vec4 fill_color #pragma maplibre: initialize highp vec4 halo_color #pragma maplibre: initialize lowp float halo_width #pragma maplibre: initialize lowp float halo_blur float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;} #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_data0;out vec3 v_data1; #pragma maplibre: define highp vec4 fill_color #pragma maplibre: define highp vec4 halo_color #pragma maplibre: define lowp float opacity #pragma maplibre: define lowp float halo_width #pragma maplibre: define lowp float halo_blur void main() { #pragma maplibre: initialize highp vec4 fill_color #pragma maplibre: initialize highp vec4 halo_color #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize lowp float halo_width #pragma maplibre: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=mix(-u_symbol_fade_change,u_symbol_fade_change,fade_opacity[1]);float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0; #ifdef GLOBE if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);} #endif vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}`),symbolTextAndIcon:Uj(`#define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;in vec4 v_data0;in vec3 v_data1;in float v_is_sdf; #pragma maplibre: define highp vec4 fill_color #pragma maplibre: define highp vec4 halo_color #pragma maplibre: define lowp float halo_width #pragma maplibre: define lowp float halo_blur void main() { #pragma maplibre: initialize highp vec4 fill_color #pragma maplibre: initialize highp vec4 halo_color #pragma maplibre: initialize lowp float halo_width #pragma maplibre: initialize lowp float halo_blur float total_opacity=v_data1[2];if (v_is_sdf==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity; #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;} #ifdef OVERDRAW_INSPECTOR fragColor=vec4(1.0); #endif }`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec3 a_projected_pos;layout(location=3) in uint a_fade_opacity;layout(location=4) in float a_height_offset;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec4 v_data0;out vec3 v_data1;out float v_is_sdf; #pragma maplibre: define highp vec4 fill_color #pragma maplibre: define highp vec4 halo_color #pragma maplibre: define lowp float opacity #pragma maplibre: define lowp float halo_width #pragma maplibre: define lowp float halo_blur void main() { #pragma maplibre: initialize highp vec4 fill_color #pragma maplibre: initialize highp vec4 halo_color #pragma maplibre: initialize lowp float opacity #pragma maplibre: initialize lowp float halo_width #pragma maplibre: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);float is_sdf=float(a_data.z & 1u);float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=mix(-u_symbol_fade_change,u_symbol_fade_change,fade_opacity[1]);float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0; #ifdef GLOBE if(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);} #endif vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec3(gamma_scale,size,total_opacity);v_is_sdf=is_sdf;}`),terrain:Uj(`uniform sampler2D u_texture;in vec2 v_texture_pos;void main() {fragColor=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));}`,`layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;invariant gl_Position;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}`),terrainDepth:Uj(`in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}`,`layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}`),terrainHeight:Uj(`in highp float v_elevation;void main() {fragColor=vec4(v_elevation,0.0,0.0,1.0);}`,`layout(location=0) in vec3 a_pos3d;uniform vec4 u_tile_bounds;out highp float v_elevation;void main() {v_elevation=get_elevation(a_pos3d.xy);vec2 position=u_tile_bounds.xy+a_pos3d.xy/8192.0*u_tile_bounds.zw;gl_Position=vec4(position.x*2.0-1.0,1.0-position.y*2.0,0.0,1.0);}`),atmosphere:Uj(`#ifdef GL_ES precision highp float; #endif in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758 );color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,`layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}`),sky:Uj(`uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;in vec3 v_view_direction;const float ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS=100000.0/6371000.0;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;float opacity=1.0;if (u_sky_blend > 0.0) {vec3 ray=normalize(v_view_direction);float globe_distance=length(u_globe_position);float angle_to_globe_center=acos(clamp(dot(ray,u_globe_position)/globe_distance,-1.0,1.0));float horizon_angle=asin(min(u_globe_radius/globe_distance,1.0));blend=mix(blend,((angle_to_globe_center-horizon_angle)*u_camera_to_center_distance+1.0)*u_device_pixel_ratio,u_sky_blend);float closest_approach=max(dot(ray,u_globe_position),0.0);float lowest_altitude=sqrt(max(globe_distance*globe_distance-closest_approach*closest_approach,0.0))-u_globe_radius;float atmosphere_height=u_globe_radius*ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS;float inside_atmosphere=1.0-smoothstep(atmosphere_height,10.0*atmosphere_height,globe_distance-u_globe_radius);float through_atmosphere=1.0-smoothstep(0.0,atmosphere_height,lowest_altitude);opacity=inside_atmosphere*through_atmosphere*(1.0-u_atmosphere_blend);}if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor*=mix(1.0,opacity,u_sky_blend);}`,`layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 v_view_direction;void main() {v_view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,1.0,1.0);}`),fog:Uj(`uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;in vec2 v_fog_pos;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {float fog_depth=v_fog_pos.x/v_fog_pos.y*0.5+0.5;if (fog_depth <=u_fog_ground_blend) {discard;}float blend_color=u_horizon_fog_blend < 1.0 ? smoothstep(u_horizon_fog_blend,1.0,fog_depth) : 0.0;vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=clamp((fog_depth-u_fog_ground_blend)/(1.0-u_fog_ground_blend),0.0,1.0);fragColor=linearToGamma(fog_horizon_color_linear)*pow(factor_fog,2.0)*u_fog_ground_blend_opacity;}`,`layout(location=0) in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_fog_pos;invariant gl_Position;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_fog_pos=(u_fog_matrix*vec4(a_pos3d.xy,ele,1.0)).zw;}`)};function Uj(e,t){let n=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),i=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=a?a.concat(i):i,s=r?r.length:0,c={};return e=e.replace(n,(e,t,n,r,i)=>(c[i]=!0,t===`define`?` #ifndef HAS_UNIFORM_u_${i} in ${n} ${r} ${i}; #else uniform ${n} ${r} u_${i}; #endif `:` #ifdef HAS_UNIFORM_u_${i} ${n} ${r} ${i} = u_${i}; #endif `)),t=t.replace(n,(e,t,n,r,i)=>{let a=r===`float`?`vec2`:`vec4`,o=i.match(/color/)?`color`:a;return c[i]?t===`define`?` #ifndef HAS_UNIFORM_u_${i} uniform lowp float u_${i}_t; layout(location = ${s++}) in ${n} ${a} a_${i}; out ${n} ${r} ${i}; #else uniform ${n} ${r} u_${i}; #endif `:o===`vec4`?` #ifndef HAS_UNIFORM_u_${i} ${i} = a_${i}; #else ${n} ${r} ${i} = u_${i}; #endif `:` #ifndef HAS_UNIFORM_u_${i} ${i} = unpack_mix_${o}(a_${i}, u_${i}_t); #else ${n} ${r} ${i} = u_${i}; #endif `:t===`define`?` #ifndef HAS_UNIFORM_u_${i} uniform lowp float u_${i}_t; layout(location = ${s++}) in ${n} ${a} a_${i}; #else uniform ${n} ${r} u_${i}; #endif `:o===`vec4`?` #ifndef HAS_UNIFORM_u_${i} ${n} ${r} ${i} = a_${i}; #else ${n} ${r} ${i} = u_${i}; #endif `:` #ifndef HAS_UNIFORM_u_${i} ${n} ${r} ${i} = unpack_mix_${o}(a_${i}, u_${i}_t); #else ${n} ${r} ${i} = u_${i}; #endif `}),{fragmentSource:e,vertexSource:t,staticAttributes:r,staticUniforms:o}}var Wj=`#define PROJECTION_MERCATOR`,Gj=`mercator`,Kj=class{constructor(e=l8){this._cachedMesh=null,this._worldCoordinateHelper=e}get name(){return this._worldCoordinateHelper.name}get worldCoordinateHelper(){return this._worldCoordinateHelper}getTransitionStateForZoom(){return 0}get useSubdivision(){return!1}get shaderVariantName(){return Gj}get shaderDefine(){return Wj}get shaderPreludeCode(){return Hj.projectionMercator}get vertexShaderPreludeCode(){return Hj.projectionMercator.vertexSource}get subdivisionGranularity(){return Z5.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(e,t,n,r,i){if(this._cachedMesh)return this._cachedMesh;let a=new x6;a.emplaceBack(0,0),a.emplaceBack(W,0),a.emplaceBack(0,W),a.emplaceBack(W,W);let o=e.createVertexBuffer(a,FT.members),s=W6.simpleSegment(0,0,4,2),c=new z6;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);let l=e.createIndexBuffer(c);return this._cachedMesh=new PT(o,l,s),this._cachedMesh}recalculate(){}hasTransition(){return!1}},Ire,Lre=()=>Ire||=new X4({type:new X(K.projection.type,`type`)}),qj=new Z5({fill:new X5(128,2),line:new X5(512,0),tile:new X5(128,32),stencil:new X5(128,1),circle:3}),Jj=class{constructor(){this._tileMeshCache={}}get name(){return`vertical-perspective`}get worldCoordinateHelper(){return l8}get transitionState(){return 1}getTransitionStateForZoom(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return`globe`}get shaderDefine(){return`#define GLOBE`}get shaderPreludeCode(){return Hj.projectionGlobe}get vertexShaderPreludeCode(){return Hj.projectionMercator.vertexSource}get subdivisionGranularity(){return qj}get useGlobeControls(){return!0}destroy(){}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?`b`:``}${e.extendToNorthPole?`n`:``}${e.extendToSouthPole?`s`:``}`}getMeshFromTileID(e,t,n,r,i){let a=(i===`stencil`?qj.stencil:qj.tile).getGranularityForZoomLevel(t.z),o=t.y===0&&r,s=t.y===(1<0}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return`globe`}get worldCoordinateHelper(){return this.currentProjection.worldCoordinateHelper}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}getMeshFromTileID(e,t,n,r,i){return this.currentProjection.getMeshFromTileID(e,t,n,r,i)}setProjection(e){this._transitionable.setValue(`type`,e?.type||`mercator`)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}};function Xj(e,t){if(Array.isArray(e)){let n=Rre(e);return n&&ig(`Projection expressions cannot use the registered projection "${n}", which only works as a plain name. Falling back to the globe projection.`),{projection:new Yj({type:e},t),cameraProjection:`globe`}}let n=ET(e);if(n)return{projection:new Kj(new ST(n)),cameraProjection:`mercator`};switch(e){case`mercator`:return{projection:new Kj,cameraProjection:`mercator`};case`globe`:return{projection:new Yj({type:[`interpolate`,[`linear`],[`zoom`],11,`vertical-perspective`,12,`mercator`]},{}),cameraProjection:`globe`};case`vertical-perspective`:return{projection:new Jj,cameraProjection:`vertical-perspective`};default:return ig(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Kj,cameraProjection:`mercator`}}}function Rre(e){return e.flat(1/0).find(e=>typeof e==`string`&&ET(e)!==void 0)}var zre=i2(),Zj=class extends l_{constructor(e,t,n={}){super(),this._rtlPluginLoaded=()=>{for(let e in this.tileManagers){let t=this.tileManagers[e].getSource().type;(t===`vector`||t===`geojson`)&&this.tileManagers[e].reload()}},this.map=e,this._store=t,this._store.setState({style:Bj(n)}),this.dispatcher=new qw(C4(),e._getMapId()).setEventedParent(this),this.dispatcher.registerMessageHandler(`GG`,(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler(`GI`,(e,t)=>this.getImages(e,t)),this.dispatcher.registerMessageHandler(`GDA`,(e,t)=>this.getDashes(e,t)),this.imageManager=new hw,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(e._missingStyleImageResolver),this.patternAtlas=new gw(this.imageManager);let r=e._container?.lang||typeof document<`u`&&document.documentElement?.lang||void 0;this.glyphManager=new Mw(e._requestManager,n.localIdeographFontFamily,r),this.lineAtlas=new Kw(256,512),this.crossTileSymbolIndex=new Dre,this._setInitialValues(),this._initialGlobalState=n.globalState??{},this._resetUpdates(),this.dispatcher.broadcast(`SR`,Xg()),IA().on(NA,this._rtlPluginLoaded),this.on(`data`,e=>{if(e.dataType!==`source`||e.sourceDataType!==`metadata`)return;let t=this.tileManagers[e.sourceId];if(!t)return;let n=t.getSource();if(n?.vectorLayerIds)for(let e in this._layers){let t=this._layers[e];t.source===n.id&&this._validateLayer(t)}})}_setInitialValues(){this._layers={},this._order=[],this.tileManagers=Object.create(null),this.zoomHistory=new P4,this._imagesListDirty=!1,this._initialGlobalState={},this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this._symbolPlacementTriggered=!1,this._placedProjectionTransition=void 0,this.crossTileSymbolIndex=new((this.crossTileSymbolIndex?.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,t){this._checkLoaded();let n=t===null?this.stylesheet.state?.[e]?.default??null:t;return this._setGlobalStateValues({[e]:n}),this}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let t={},n=new Set([...Object.keys(e??{}),...Object.keys(this._initialGlobalState)]);for(let r of n)t[r]=this._initialGlobalState[r]??e[r]?.default??null;this._setGlobalStateValues(t)}_setGlobalStateValues(e){let t=[];for(let n in e)tg(e[n],this._globalState[n])||t.push(n);if(t.length===0)return;let n={...this._globalState};for(let n of t)this._globalState[n]=e[n];this._applyGlobalStateChanges(t,n)}_applyGlobalStateChanges(e,t){let n=new Set,r={};for(let t of e)r[t]=this._globalState[t];for(let r in this._layers){let i=this._layers[r];i.retainPriorGlobalState(e,t);let a=i.getLayoutAffectingGlobalStateRefs(),o=i.getPaintAffectingGlobalStateRefs(),s=i.getVisibilityAffectingGlobalStateRefs();for(let t of e){if(a.has(t)&&n.add(i.source),o.has(t))for(let{name:e,value:n}of o.get(t))this._updatePaintProperty(i,e,n);s?.has(t)&&(i.recalculateVisibility(),this._updateLayer(i))}}let i={now:Ig(),transition:this.getTransition()};this.light?.applyGlobalStateChange(e,t,i),this.sky?.applyGlobalStateChange(e,t,i),this.dispatcher.broadcast(`UGS`,r);for(let e in this.tileManagers)n.has(e)&&(this._reloadSource(e),this._changed=!0)}async loadURL(e,t={},n){this._setDefinition(e,t),this.fire(new A4(`dataloading`)),t.validate=typeof t.validate!=`boolean`||t.validate,this._loadStyleRequest=new AbortController;let r=this._loadStyleRequest;try{let i=await this.map._requestManager.transformRequest(e,`Style`);Ag(r.signal);let a=await t_(i,r);this._loadStyleRequest===r&&(this._loadStyleRequest=null),this._load(a.data,t,n)}catch(e){this._loadStyleRequest===r&&(this._loadStyleRequest=null),e&&!r.signal.aborted&&this.fire(new c_(Ch(e)))}}loadJSON(e,t={},n){this._setDefinition(e,t),this.fire(new A4(`dataloading`)),this._frameRequest=new AbortController,Pg.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,t.validate=t.validate!==!1,this._load(e,t,n)}).catch(()=>{})}_setDefinition(e,t){this._store.setState(n=>({style:{...n.style,definition:e,options:{...n.style.options,...t}}}))}loadEmpty(){this.fire(new A4(`dataloading`)),this._load(zre,{validate:!1})}_load(e,t,n){let r=t.transformStyle?t.transformStyle(n,e):e;if(t.validate&&Iw(this,r))return;r={...r},this._loaded=!0,this.stylesheet=r,this.setGlobalState(this.stylesheet.state??null);let i=Xj(this.stylesheet.projection?.type||`mercator`,this._globalState);this.projection=i.projection;for(let e in r.sources)this.addSource(e,r.sources[e],{validate:!1});r.sprite?this._loadSprite(r.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(r.glyphs),this.glyphManager.setFontFaces(r[`font-faces`]),this._createLayers(),this.light=new Vw(this.stylesheet.light??{},this._globalState),this._applyProjection(i),this.sky=new Ww(this.stylesheet.sky,this._globalState),this.sky.setEventedParent(this),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new A4(`data`)),this.fire(new k4)}_createLayers(){let e=f_(this.stylesheet.layers);this.dispatcher.broadcast(`SL`,e),this._order=e.map(e=>e.id),this._layers={},this._serializedLayers=null;for(let t of e){let e=uw(t,this._globalState);if(e.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=e,r3(e)&&this.tileManagers[e.source]){let n=t.paint?.[`raster-fade-duration`]??e.paint.get(`raster-fade-duration`);this.tileManagers[e.source].setRasterFadeDuration(n)}}}async _loadSprite(e,t=!1,n=void 0){this.imageManager.setLoaded(!1);let r=new AbortController;this._spriteRequest=r;let i;try{let n=await pw(e,this.map._requestManager,this.map.getPixelRatio(),r);if(!n)return;for(let e in n){let{loaded:r,removed:i}=this.imageManager.setSpriteImages(e,n[e]);this._markImagesChanged(i),t&&this._markImagesChanged(r)}}catch(e){i=e,r.signal.aborted||this.fire(new c_(i))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),t&&(this._changed=!0),this.dispatcher.broadcast(`SI`,this.imageManager.listImages()),this.fire(new A4(`data`)),n?.(i)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new A4(`data`))}_validateLayer(e){let t=this.tileManagers[e.source];if(!t)return;let n=e.sourceLayer;if(!n)return;let r=t.getSource();(r.type===`geojson`||r.vectorLayerIds&&!r.vectorLayerIds.includes(n))&&this.fire(new c_(Error(`Source layer "${n}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(e,t=!1){let n=this._serializedAllLayers();if(!e||e.length===0)return Object.values(t?ng(n):n);let r=[];for(let i of e)if(n[i]){let e=t?ng(n[i]):n[i];r.push(e)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let n of t){let t=this._layers[n];t.type!==`custom`&&(e[n]=t.serialize())}return e}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error(`Style is not done loading.`)}update(e){if(!this._loaded)return;let t=this._changed;if(t){this._imagesListDirty&&=(this.dispatcher.broadcast(`SI`,this.imageManager.listImages()),!1);let t=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(t.length||n.length)&&this._updateWorkerLayers(t,n);for(let e in this._updatedSources){let t=this._updatedSources[e];if(t===`reload`)this._reloadSource(e);else if(t===`clear`)this._clearSource(e);else throw Error(`Invalid action ${t}`)}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this._resetUpdates()}let n={};for(let e in this.tileManagers){let t=this.tileManagers[e];n[e]=t.used,t.used=!1}let r=this.imageManager.listImages();for(let t of this._order){let n=this._layers[t];if(n.recalculate(e,r),n.isHidden(e.zoom)||!n.source)continue;let i=this.tileManagers[n.source];i&&(i.used=!0)}for(let e in n){let t=this.tileManagers[e];!!n[e]!=!!t.used&&t.fire(new j4(`data`,{sourceDataType:`visibility`,sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,t&&this.fire(new A4(`data`))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies([`icons`,`patterns`],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies([`glyphs`],[``]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast(`UL`,{layers:this._serializeByIds(e,!1),removedIds:t})}resize(){for(let e of this._order)this._layers[e].resize()}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,t={}){this._checkLoaded();let n=this.serialize();if(e=t.transformStyle?t.transformStyle(n,e):e,(t.validate??!0)&&Iw(this,e))return!1;e=ng(e),e.layers=f_(e.layers);let r=S_(n,e),i=this._getOperationsToPerform(r);if(i.unimplemented.length>0)throw Error(`Unimplemented: ${i.unimplemented.join(`, `)}.`);if(i.operations.length===0)return!1;this._initialGlobalState=t.globalState??{};for(let e of i.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new k4({style:this})),!0}_getOperationsToPerform(e){let t=[],n=[];for(let r of e)switch(r.command){case`setCenter`:case`setZoom`:case`setBearing`:case`setPitch`:case`setRoll`:continue;case`addLayer`:{let[e,n]=r.args;t.push(()=>this.addLayer(e,n));break}case`removeLayer`:{let[e]=r.args;t.push(()=>this.removeLayer(e));break}case`setPaintProperty`:{let[e,n,i]=r.args;t.push(()=>this.setPaintProperty(e,n,i));break}case`setLayoutProperty`:{let[e,n,i]=r.args;t.push(()=>this.setLayoutProperty(e,n,i));break}case`setFilter`:{let[e,n]=r.args;t.push(()=>this.setFilter(e,n));break}case`addSource`:{let[e,n]=r.args;t.push(()=>this.addSource(e,n));break}case`removeSource`:{let[e]=r.args;t.push(()=>this.removeSource(e));break}case`setLayerZoomRange`:{let[e,n,i]=r.args;t.push(()=>this.setLayerZoomRange(e,n,i));break}case`setLight`:{let[e]=r.args;t.push(()=>this.setLight(e));break}case`setGeoJSONSourceData`:{let[e,n]=r.args;t.push(()=>this.setGeoJSONSourceData(e,n));break}case`setGlyphs`:{let[e]=r.args;t.push(()=>this.setGlyphs(e));break}case`setFontFaces`:{let[e]=r.args;t.push(()=>this.setFontFaces(e));break}case`setSprite`:{let[e]=r.args;t.push(()=>this.setSprite(e));break}case`setTerrain`:{let[e]=r.args;t.push(()=>this.map.setTerrain(e));break}case`setSky`:{let[e]=r.args;t.push(()=>this.setSky(e));break}case`setProjection`:{let[e]=r.args;t.push(()=>this.setProjection(e));break}case`setGlobalState`:{let[e]=r.args;t.push(()=>this.setGlobalState(e));break}case`setTransition`:t.push(()=>{});break;default:n.push(r.command)}return{operations:t,unimplemented:n}}addImage(e,t){this.getImage(e)?this.fire(new c_(Error(`An image named "${e}" already exists.`))):(this.imageManager.addImage(e,t),this._afterImageUpdated(e))}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}setMissingImageResolver(e){this.imageManager.setMissingImageResolver(e)}removeImage(e){this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e)):this.fire(new c_(Error(`An image named "${e}" does not exist.`)))}_markImagesChanged(e){for(let t of e)this._changedImages[t]=!0}_afterImageUpdated(e){this._changedImages[e]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new A4(`data`))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,t,n={}){if(this._checkLoaded(),this.tileManagers[e]!==void 0)throw Error(`Source "${e}" already exists.`);if(!t.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(`, `)}.`);if(Pw.has(t.type)&&this._validate(Nw.source,`sources.${e}`,t,null,n))return;this.map?._collectResourceTiming&&(t.collectResourceTiming=!0);let r=this.tileManagers[e]=new oj(e,t,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);for(let t in this._layers)if(this._layers[t].source===e)return this.fire(new c_(Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));let t=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],t.fire(new j4(`data`,{sourceDataType:`metadata`,sourceId:e})),t.setEventedParent(null),t.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw Error(`There is no source with this ID=${e}`);let n=this.tileManagers[e].getSource();if(n.type!==`geojson`)throw Error(`geojsonSource.type is ${n.type}, which is !== 'geojson`);n.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]?.getSource()}addLayer(e,t,n={}){this._checkLoaded();let r=e.id;if(this.getLayer(r)){this.fire(new c_(Error(`Layer "${r}" already exists on this map.`)));return}let i;if(e.type===`custom`){if(Lw(this,A3(e)))return;i=uw(e,this._globalState)}else{if(`source`in e&&typeof e.source==`object`&&(this.addSource(r,e.source),e={...e,source:r}),this._validate(Nw.layer,`layers.${r}`,e,{arrayIndex:-1},n))return;i=uw(e,this._globalState),this._validateLayer(i),i.setEventedParent(this,{layer:{id:r}})}let a=t?this._order.indexOf(t):this._order.length;if(t&&a===-1)this.fire(new c_(Error(`Cannot add layer "${r}" before non-existing layer "${t}".`)));else{if(this._order.splice(a,0,r),this._layerOrderChanged=!0,this._layers[r]=i,this._removedLayers[r]&&i.source&&i.type!==`custom`){let e=this._removedLayers[r];delete this._removedLayers[r],e.type===i.type?(this._updatedSources[i.source]=`reload`,this.tileManagers[i.source].pause()):this._updatedSources[i.source]=`clear`}this._updateLayer(i),i.onAdd&&i.onAdd(this.map)}}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e]){this.fire(new c_(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));return}if(e===t)return;if(t&&!this._order.includes(t)){this.fire(new c_(Error(`Cannot move layer "${e}" before non-existing layer "${t}".`)));return}let n=this._order.indexOf(e);this._order.splice(n,1);let r=t?this._order.indexOf(t):this._order.length;this._order.splice(r,0,e),this._layerOrderChanged=!0}removeLayer(e){this._checkLoaded();let t=this._layers[e];if(!t){this.fire(new c_(Error(`Cannot remove non-existing layer "${e}".`)));return}t.setEventedParent(null);let n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],t.type===`symbol`&&t.source&&this.tileManagers[t.source]?.resetMaxContentElevation(),t.onRemove&&t.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,t,n){this._checkLoaded();let r=this.getLayer(e);r?(r.minzoom!==t||r.maxzoom!==n)&&(t!=null&&(r.minzoom=t),n!=null&&(r.maxzoom=n),this._updateLayer(r)):this.fire(new c_(Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,t,n={}){this._checkLoaded();let r=this.getLayer(e);r?tg(r.filter,t)||(t==null?(r.setFilter(void 0),this._updateLayer(r)):this._validate(Nw.filter,`layers.${r.id}.filter`,t,{layerType:r.type},n)||(r.setFilter(ng(t)),this._updateLayer(r))):this.fire(new c_(Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return ng(this.getLayer(e).filter)}setLayoutProperty(e,t,n,r={}){this._checkLoaded();let i=this.getLayer(e);i?tg(i.getLayoutProperty(t),n)||t!==`visibility`&&n!=null&&this._validateLayerProperty(i,Nw.layoutProperty,`layers.${i.id}.layout.${t}`,t,n,r)||(i.setLayoutProperty(t,n),this._updateLayer(i)):this.fire(new c_(Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,t){let n=this.getLayer(e);if(!n)this.fire(new c_(Error(`Cannot get style of non-existing layer "${e}".`)));else return n.getLayoutProperty(t)}setPaintProperty(e,t,n,r={}){this._checkLoaded();let i=this.getLayer(e);i?tg(i.getPaintProperty(t),n)||n!=null&&this._validateLayerProperty(i,Nw.paintProperty,`layers.${i.id}.paint.${t}`,t,n,r)||this._updatePaintProperty(i,t,n):this.fire(new c_(Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,t,n){e.setPaintProperty(t,n)&&this._updateLayer(e),r3(e)&&t===`raster-fade-duration`&&this.tileManagers[e.source].setRasterFadeDuration(n),this._changed=!0,this._updatedPaintProps[e.id]=!0,e.type===`symbol`&&this.triggerSymbolPlacement(),this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();let n=e.source,r=e.sourceLayer,i=this.tileManagers[n];if(i===void 0){this.fire(new c_(Error(`The source '${n}' does not exist in the map's style.`)));return}let a=i.getSource().type;if(a===`geojson`&&r){this.fire(new c_(Error(`GeoJSON sources cannot have a sourceLayer parameter.`)));return}if(a===`vector`&&!r){this.fire(new c_(Error(`The sourceLayer parameter must be provided for vector source types.`)));return}if(e.id===void 0){this.fire(new c_(Error(`The feature id parameter must be provided.`)));return}let o=[`__proto__`,`constructor`,`prototype`];t&&Object.keys(t).some(e=>o.includes(e))?this.fire(new c_(Error(`The feature state should not include one of the following keys: ${o}`))):i.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();let n=e.source,r=this.tileManagers[n];if(r===void 0){this.fire(new c_(Error(`The source '${n}' does not exist in the map's style.`)));return}let i=r.getSource().type,a=i===`vector`?e.sourceLayer:void 0;i===`vector`&&!a?this.fire(new c_(Error(`The sourceLayer parameter must be provided for vector source types.`))):t&&typeof e.id!=`string`&&typeof e.id!=`number`?this.fire(new c_(Error(`A feature id is required to remove its specific state property.`))):r.removeFeatureState(a,e.id,t)}getFeatureState(e){this._checkLoaded();let t=e.source,n=e.sourceLayer,r=this.tileManagers[t];if(r===void 0)this.fire(new c_(Error(`The source '${t}' does not exist in the map's style.`)));else if(r.getSource().type===`vector`&&!n)this.fire(new c_(Error(`The sourceLayer parameter must be provided for vector source types.`)));else return e.id===void 0&&this.fire(new c_(Error(`The feature id parameter must be provided.`))),r.getFeatureState(n,e.id)}getTransition(){return{duration:300,delay:0,...this.stylesheet?.transition}}serialize(){if(!this._loaded)return;let e=Object.fromEntries(Object.entries(this.tileManagers).map(([e,t])=>[e,t.serialize()])),t=this._serializeByIds(this._order,!0),n=this.map.getTerrain()||void 0,r=this.stylesheet;return eg({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,"font-faces":r[`font-faces`],transition:r.transition,projection:r.projection,state:r.state,sources:e,layers:t,terrain:n},e=>e!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.tileManagers[e.source].getSource().type!==`raster`&&(this._updatedSources[e.source]=`reload`,this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=e=>this._layers[e].type===`fill-extrusion`,n={},r=[];for(let i=this._order.length-1;i>=0;i--){let a=this._order[i];if(t(a)){n[a]=i;for(let t of e){let e=t[a];if(e)for(let t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);let i=[];for(let a=this._order.length-1;a>=0;a--){let o=this._order[a];if(t(o))for(let e=r.length-1;e>=0;e--){let t=r[e].feature;if(n[t.layer.id]this.map.terrain.getElevation(e,t,n):void 0));return this.placement&&a.push(Xw(this._layers,o,this.tileManagers,e,c,this.placement.collisionIndex,this.placement.retainedQueryData,r)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,t){t?.filter&&this._validate(Nw.filter,`querySourceFeatures.filter`,t.filter,null,t);let n=this.tileManagers[e];return n?Zw(n,{...t,globalState:this._globalState,worldCoordinateHelper:this.projection.worldCoordinateHelper}):[]}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();let n=this.light.getLight(),r=!1;for(let t in e)if(!tg(e[t],n[t])){r=!0;break}if(!r)return;let i={now:Ig(),transition:{duration:300,delay:0,...this.stylesheet.transition}};this.light.setLight(e,t)&&(this.stylesheet.light=this.light.getLight(),this.light.updateTransitions(i))}getProjection(){return this.stylesheet?.projection}setProjection(e){this._checkLoaded();let t=e??{type:`mercator`};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(t.type)}getSky(){return this.stylesheet?.sky}setSky(e,t={}){this._checkLoaded();let n=this.getSky(),r=!1;if(!e&&!n)return;if(e&&!n)r=!0;else if(!e&&n)r=!0;else for(let t in e)if(!tg(e[t],n[t])){r=!0;break}if(!r)return;let i={now:Ig(),transition:{duration:300,delay:0,...this.stylesheet.transition}};this.sky.setSky(e,t)&&(this.stylesheet.sky=e,this.sky.updateTransitions(i))}_setProjectionInternal(e){this._applyProjection(Xj(e,this._globalState))}_applyProjection(e){this.projection=e.projection,this.map.migrateProjection(e.cameraProjection,e.projection.worldCoordinateHelper);for(let e in this.tileManagers)this.tileManagers[e].reload()}_validate(e,t,n,r,i={}){return i.validate!==!1&&Rw(this,e,{key:t,style:this.serialize(),value:n,...r},i)}_validateLayerProperty(e,t,n,r,i,a){return Rw(e,t,{key:n,layerType:e.type,objectKey:r,value:i},a)}_remove(e=!0){this._detach(),e&&this.dispatcher.broadcast(`RM`,void 0),this.dispatcher.remove(e)}_detach(){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),IA().off(NA,this._rtlPluginLoaded);for(let e in this._layers)this._layers[e].setEventedParent(null);for(let e in this.tileManagers){let t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e,t){for(let n in this.tileManagers)this.tileManagers[n].update(e,t,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.tileManagers)this._reloadSource(e)}triggerSymbolPlacement(){this._symbolPlacementTriggered=!0}_placementInputsChanged(e,t,n){let r=this.pauseablePlacement;return!r||this._symbolPlacementTriggered||this._placedProjectionTransition!==this.projection?.transitionState||r._showCollisionBoxes!==t||r.placement.collisionGroups.crossSourceCollisions!==n||r.placement.projectedCamera.renderWorldCopies!==e.renderWorldCopies||!Dm(r.placement.projectedCamera.modelViewProjectionMatrix,e.modelViewProjectionMatrix)}_updatePlacement(e,t,n,r,i,a=!1){let o=!1,s=!1,c={};for(let n of this._order){let r=this._layers[n];if(r.type!==`symbol`)continue;if(!c[r.source]){let e=this.tileManagers[r.source];c[r.source]=e.getRenderableIds(!0).map(t=>e.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}let i=this.crossTileSymbolIndex.addLayer(r,c[r.source],t.wraps?e.center.lng:0);o||=i}this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a||=this._layerOrderChanged||r===0;let l=o||this._placementInputsChanged(e,n,i),u=this.pauseablePlacement?.isDone()&&!this.placement.stillRecent(Ig(),e.zoom);if((a||!this.pauseablePlacement||u&&(l||this.placement.stale))&&(this._symbolPlacementTriggered=!1,this._placedProjectionTransition=this.projection?.transitionState,this.pauseablePlacement=new Sre(e,this.map.terrain,this._order,a,n,r,i,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?l&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,c),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Ig()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(let e of this._order){let t=this._layers[e];t.type===`symbol`&&this.placement.updateLayerOpacities(t,c[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Ig())}_releaseSymbolFadeTiles(){for(let e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}async getImages(e,t){let n=await this.imageManager.getImages(t.icons);this._updateTilesForChangedImages();let r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,t.icons),n}async getGlyphs(e,t){let n=await this.glyphManager.getGlyphs(t.stacks),r=this.tileManagers[t.source];return r&&r.setDependencies(t.tileID.key,t.type,[``]),n}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,t={}){this._checkLoaded(),e&&this._validate(Nw.glyphs,`glyphs`,e,null,t)||(this._changed=!0,this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getFontFaces(){return this.stylesheet[`font-faces`]||null}setFontFaces(e){this._checkLoaded(),this._changed=!0,this._glyphsDidChange=!0,this.stylesheet[`font-faces`]=e,this.glyphManager.setFontFaces(e)}async getDashes(e,t){let n={};for(let[e,r]of Object.entries(t.dashes))n[e]=this.lineAtlas.getDash(r.dasharray,r.round);return n}addSprite(e,t,n={},r){this._checkLoaded();let i=[{id:e,url:t}],a=[...dw(this.stylesheet.sprite),...i];this._validate(Nw.sprite,`sprite`,a,null,n)||(this.stylesheet.sprite=a,this._loadSprite(i,!0,r))}removeSprite(e){this._checkLoaded();let t=dw(this.stylesheet.sprite);if(!t.find(t=>t.id===e)){this.fire(new c_(Error(`Sprite "${e}" doesn't exists on this map.`)));return}let n=this.imageManager.removeSpriteImages(e);this._markImagesChanged(n),t.splice(t.findIndex(t=>t.id===e),1),this.stylesheet.sprite=t.length>0?t:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new A4(`data`))}getSprite(){return dw(this.stylesheet.sprite)}setSprite(e,t={},n){this._checkLoaded(),e&&this._validate(Nw.sprite,`sprite`,e,null,t)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,n):(this._unloadSprite(),n&&n(null)))}destroy(){this._detach(),this.tileManagers=Object.create(null),this.imageManager&&(this.imageManager.destroy(),this.patternAtlas.destroy()),this.glyphManager&&this.glyphManager.destroy();for(let e in this._layers){let t=this._layers[e];t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.dispatcher.unregisterMessageHandler(`GG`),this.dispatcher.unregisterMessageHandler(`GI`),this.dispatcher.unregisterMessageHandler(`GDA`),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}},Bre=I3([{name:`a_pos`,type:`Int16`,components:2},{name:`a_texture_pos`,type:`Int16`,components:2}]),Vre=class{constructor(e,t,n){this.context=e;let r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!n,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let t=this.context.gl;if(!this.dynamicDraw)throw Error(`Attempted to update data while not in dynamic mode.`);this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},Qj={Int8:`BYTE`,Uint8:`UNSIGNED_BYTE`,Int16:`SHORT`,Uint16:`UNSIGNED_SHORT`,Int32:`INT`,Uint32:`UNSIGNED_INT`,Float32:`FLOAT`},Hre=class{constructor(e,t,n,r){this.length=t.length,this.attributes=n,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;let i=e.gl;this.buffer=i.createBuffer(),e.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let n of this.attributes){let r=t.attributes[n.name];r!==void 0&&e.enableVertexAttribArray(r.location)}}setVertexAttribPointers(e,t,n){for(let r of this.attributes){let i=t.attributes[r.name];if(i!==void 0){let t=r.offset+this.itemSize*(n||0);i.isInteger?e.vertexAttribIPointer(i.location,r.components,e[Qj[r.type]],this.itemSize,t):e.vertexAttribPointer(i.location,r.components,e[Qj[r.type]],!1,this.itemSize,t)}}}destroy(){let e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}},$j=class{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}},Ure=class extends $j{getDefault(){return R1.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}},Wre=class extends $j{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}},Gre=class extends $j{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}},Kre=class extends $j{getDefault(){return[!0,!0,!0,!0]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}},qre=class extends $j{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}},Jre=class extends $j{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}},Yre=class extends $j{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}},Xre=class extends $j{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}},Zre=class extends $j{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}},Qre=class extends $j{getDefault(){return[0,1]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}},$re=class extends $j{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}},eie=class extends $j{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}},tie=class extends $j{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}},nie=class extends $j{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}},rie=class extends $j{getDefault(){return R1.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}},iie=class extends $j{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}},aie=class extends $j{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}},oie=class extends $j{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}},sie=class extends $j{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}},cie=class extends $j{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}},lie=class extends $j{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}},uie=class extends $j{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}},die=class extends $j{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}},fie=class extends $j{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},pie=class extends $j{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}},mie=class extends $j{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},hie=class extends $j{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}},gie=class extends $j{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}},_ie=class extends $j{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}},vie=class extends $j{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}},yie=class extends $j{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}},eM=class extends $j{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}},tM=class extends eM{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}},nM=class extends eM{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},rM=class extends eM{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}},iM=class{constructor(e,t,n,r,i){this.context=e,this.width=t,this.height=n;let a=e.gl,o=this.framebuffer=a.createFramebuffer();if(this.colorAttachment=new tM(e,o),r)this.depthAttachment=i?new rM(e,o):new nM(e,o);else if(i)throw Error(`Stencil cannot be set without depth`)}destroy(){let e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){let t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}},aM={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2};function oM(e,t){for(let[n,r]of Object.entries(aM)){let i=e.getUniformBlockIndex(t,n);i!==e.INVALID_INDEX&&e.uniformBlockBinding(t,i,r)}}var sM={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function cM(e){let t={},n=0;for(let{name:r,type:i}of e){let[e,a]=sM[i];n=Math.ceil(n/a)*a,t[r]=n,n+=e}return{offsets:t,contentWords:n,sizeWords:Math.ceil(n/4)*4}}var lM=class{constructor(e,t,n){this.context=e,this.binding=t,this.contentWords=n.contentWords;let r=e.gl;this.buffer=r.createBuffer(),r.bindBuffer(r.UNIFORM_BUFFER,this.buffer),r.bufferData(r.UNIFORM_BUFFER,n.sizeWords*4,r.DYNAMIC_DRAW),this.uploaded=new Float32Array(n.sizeWords),this.pending=new Float32Array(n.sizeWords),this.uploadedWords=new Uint32Array(this.uploaded.buffer),this.pendingWords=new Uint32Array(this.pending.buffer),this.hasData=!1}upload(){let e=this.context.gl,t=!this.hasData;if(!t){let e=this.pendingWords,n=this.uploadedWords;for(let r=0;r({u_depth:new nb(e,t.u_depth),u_terrain:new nb(e,t.u_terrain)}),AM=(e,t)=>({u_texture:new nb(e,t.u_texture),u_ele_delta:new Z(e,t.u_ele_delta)}),jM=(e,t)=>({u_ele_delta:new Z(e,t.u_ele_delta)}),MM=(e,t)=>({u_tile_bounds:new ab(e,t.u_tile_bounds)}),NM=e=>({u_texture:0,u_ele_delta:e}),PM=e=>({u_ele_delta:e}),FM=e=>({u_tile_bounds:e});function IM(e){let t=[];for(let n of e){if(n===null)continue;let e=n.split(` `);t.push(e.pop())}return t}function LM(e,t){let n=new Set([e.INT,e.INT_VEC2,e.INT_VEC3,e.INT_VEC4,e.UNSIGNED_INT,e.UNSIGNED_INT_VEC2,e.UNSIGNED_INT_VEC3,e.UNSIGNED_INT_VEC4]),r=new Set,i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let a=0;a=0&&(this.attributes[e]={location:t,isInteger:w.has(e)})}l.deleteShader(S),l.deleteShader(x);for(let e of _)if(e&&!C[e]){let t=l.getUniformLocation(this.program,e);t&&(C[e]=t)}this.fixedUniforms=r(e,C),this.terrainUniforms=kM(e,C),this.binderUniforms=n?n.getUniforms(e,C):[]}draw(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.terrainUniformBuffer.bind(),e.frameUniformBuffer.bind(),e.setDepthMode(n),e.setStencilMode(r),e.setColorMode(i),e.setCullFace(a),s){e.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,s.depthTexture),e.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,s.texture);for(let e in this.terrainUniforms)this.terrainUniforms[e].set(s[e]);TM(e.terrainUniformBuffer,s)}if(mM(e,c),o)for(let e in this.fixedUniforms)this.fixedUniforms[e].set(o[e]);h&&h.setUniforms(e,this.binderUniforms,p,{zoom:m});let b=0;switch(t){case y.LINES:b=2;break;case y.TRIANGLES:b=3;break;case y.LINE_STRIP:b=1}for(let n of f.get())n.vaos||={},n.vaos[l]||=new OM,n.vaos[l].bind(e,this,u,h?h.getPaintVertexBuffers():[],d,n.vertexOffset,g,_,v),y.drawElements(t,n.primitiveLength*b,y.UNSIGNED_SHORT,n.primitiveOffset*b*2)}};function zM(e,t,n){let r=1/Sh(n,1,t.tileZoom),i=2**n.tileID.overscaledZ,a=n.tileSize*2**t.tileZoom/i,o=a*(n.tileID.canonical.x+n.tileID.wrap*i),s=a*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[o&65535,s&65535]}}function BM(e,t,n,r,i){let a=n.getPattern(e.from.toString()),o=n.getPattern(e.to.toString()),{width:s,height:c}=n.getPixelSize(),l=2**i.tileID.overscaledZ,u=i.tileSize*2**r.tileZoom/l,d=u*(i.tileID.canonical.x+i.tileID.wrap*l),f=u*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,c],u_mix:t.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/Sh(i,1,r.tileZoom),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[d&65535,f&65535]}}var VM=(e,t)=>({u_lightpos:new ib(e,t.u_lightpos),u_lightpos_globe:new ib(e,t.u_lightpos_globe),u_lightintensity:new Z(e,t.u_lightintensity),u_lightcolor:new ib(e,t.u_lightcolor),u_vertical_gradient:new Z(e,t.u_vertical_gradient),u_fill_translate:new rb(e,t.u_fill_translate)}),HM=(e,t)=>({u_lightpos:new ib(e,t.u_lightpos),u_lightpos_globe:new ib(e,t.u_lightpos_globe),u_lightintensity:new Z(e,t.u_lightintensity),u_lightcolor:new ib(e,t.u_lightcolor),u_vertical_gradient:new Z(e,t.u_vertical_gradient),u_height_factor:new Z(e,t.u_height_factor),u_fill_translate:new rb(e,t.u_fill_translate),u_image:new nb(e,t.u_image),u_texsize:new rb(e,t.u_texsize),u_pixel_coord_upper:new rb(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new rb(e,t.u_pixel_coord_lower),u_scale:new ib(e,t.u_scale),u_fade:new Z(e,t.u_fade)}),UM=(e,t,n,r)=>{let i=sg(t.position),a=sm();t.anchor===`viewport`&&lm(a,e.bearingInRadians),Wm(i,i,a);let o=Q(e).transformLightDirection(e,i),s=t.color;return{u_lightpos:i,u_lightpos_globe:o,u_lightintensity:t.intensity,u_lightcolor:[s.r,s.g,s.b],u_vertical_gradient:+n,u_fill_translate:r}},WM=(e,t,n,r,i,a,o)=>({...UM(e,t,n,r),...zM(a,e,o),u_height_factor:-(2**i.overscaledZ)/o.tileSize/8}),GM=(e,t)=>({u_fill_translate:new rb(e,t.u_fill_translate)}),KM=(e,t)=>({u_image:new nb(e,t.u_image),u_texsize:new rb(e,t.u_texsize),u_pixel_coord_upper:new rb(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new rb(e,t.u_pixel_coord_lower),u_scale:new ib(e,t.u_scale),u_fade:new Z(e,t.u_fade),u_sdf_pattern:new nb(e,t.u_sdf_pattern),u_fill_translate:new rb(e,t.u_fill_translate)}),qM=(e,t)=>({u_fill_translate:new rb(e,t.u_fill_translate)}),JM=(e,t)=>({u_image:new nb(e,t.u_image),u_texsize:new rb(e,t.u_texsize),u_pixel_coord_upper:new rb(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new rb(e,t.u_pixel_coord_lower),u_scale:new ib(e,t.u_scale),u_fade:new Z(e,t.u_fade),u_sdf_pattern:new nb(e,t.u_sdf_pattern),u_fill_translate:new rb(e,t.u_fill_translate)}),YM=(e,t,n,r,i)=>({...zM(t,e,n),u_fill_translate:r,u_sdf_pattern:+!!i}),XM=e=>({u_fill_translate:e}),ZM=e=>({u_fill_translate:e}),QM=(e,t,n,r,i)=>YM(e,t,n,r,i),$M=(e,t)=>({u_scale_with_map:new nb(e,t.u_scale_with_map),u_pitch_with_map:new nb(e,t.u_pitch_with_map),u_extrude_scale:new rb(e,t.u_extrude_scale),u_globe_extrude_scale:new Z(e,t.u_globe_extrude_scale),u_translate:new rb(e,t.u_translate)}),eN=(e,t,n,r,i)=>{let a,o,s=0;if(n.paint.get(`circle-pitch-alignment`)===`map`){let n=Sh(t,1,e.zoom);a=!0,o=[n,n],s=n/(W*2**t.tileID.overscaledZ)*2*Math.PI*i}else a=!1,o=e.pixelsToGLUnits;return{u_scale_with_map:+(n.paint.get(`circle-pitch-scale`)===`map`),u_pitch_with_map:+a,u_extrude_scale:o,u_globe_extrude_scale:s,u_translate:r}},tN=(e,t)=>({u_color:new ob(e,t.u_color),u_overlay:new nb(e,t.u_overlay),u_overlay_scale:new Z(e,t.u_overlay_scale)}),nN=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),rN=(e,t)=>({u_extrude_scale:new Z(e,t.u_extrude_scale),u_intensity:new Z(e,t.u_intensity),u_globe_extrude_scale:new Z(e,t.u_globe_extrude_scale)}),iN=(e,t)=>({u_matrix:new ub(e,t.u_matrix),u_image:new nb(e,t.u_image),u_color_ramp:new nb(e,t.u_color_ramp),u_opacity:new Z(e,t.u_opacity)}),aN=(e,t,n,r)=>{let i=Sh(e,1,t)/(W*2**e.tileID.overscaledZ)*2*Math.PI*r;return{u_extrude_scale:Sh(e,1,t),u_intensity:n,u_globe_extrude_scale:i}},oN=(e,t,n,r)=>{let i=dm();return Em(i,0,e.width,e.height,0,0,1),{u_matrix:i,u_image:n,u_color_ramp:r,u_opacity:t.paint.get(`heatmap-opacity`)}},sN=(e,t)=>({u_image:new nb(e,t.u_image),u_latrange:new rb(e,t.u_latrange),u_exaggeration:new Z(e,t.u_exaggeration),u_altitudes:new cb(e,t.u_altitudes),u_azimuths:new cb(e,t.u_azimuths),u_accent:new ob(e,t.u_accent),u_method:new nb(e,t.u_method),u_shadows:new sb(e,t.u_shadows),u_highlights:new sb(e,t.u_highlights)}),cN=(e,t)=>({u_matrix:new ub(e,t.u_matrix),u_image:new nb(e,t.u_image),u_dimension:new rb(e,t.u_dimension),u_zoom:new Z(e,t.u_zoom),u_unpack:new ab(e,t.u_unpack),u_log2_world_width:new Z(e,t.u_log2_world_width)}),lN=(e,t,n,r)=>{let i=r.paint.get(`hillshade-accent-color`),a;switch(r.paint.get(`hillshade-method`)){case`basic`:a=4;break;case`combined`:a=1;break;case`igor`:a=2;break;case`multidirectional`:a=3;break;default:a=0}let o=r.getIlluminationProperties();for(let t=0;t{let r=n.stride,i=dm();return Em(i,0,W,-8192,0,0,1),_m(i,i,[0,-8192,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:n.getUnpackVector(),u_log2_world_width:dN(e)}};function dN(e){return e.wraps?25.2562:Math.log2(e.metersPerWorldUnit(.5,.5))}function fN(e,t){if(!e.wraps)return[0,0];let n=2**t.canonical.z,r=t.canonical.y;return[e.lngLatFromWorld(0,r/n).lat,e.lngLatFromWorld(0,(r+1)/n).lat]}var pN=(e,t)=>({u_image:new nb(e,t.u_image),u_unpack:new ab(e,t.u_unpack),u_dimension:new rb(e,t.u_dimension),u_elevation_stops:new nb(e,t.u_elevation_stops),u_color_stops:new nb(e,t.u_color_stops),u_color_ramp_size:new nb(e,t.u_color_ramp_size),u_opacity:new Z(e,t.u_opacity)}),mN=(e,t,n=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:e.paint.get(`color-relief-opacity`)}),hN=(e,t)=>({u_translation:new rb(e,t.u_translation),u_ratio:new Z(e,t.u_ratio)}),gN=(e,t)=>({u_translation:new rb(e,t.u_translation),u_ratio:new Z(e,t.u_ratio),u_image:new nb(e,t.u_image),u_image_height:new Z(e,t.u_image_height)}),_N=(e,t)=>({u_translation:new rb(e,t.u_translation),u_texsize:new rb(e,t.u_texsize),u_ratio:new Z(e,t.u_ratio),u_image:new nb(e,t.u_image),u_scale:new ib(e,t.u_scale),u_fade:new Z(e,t.u_fade)}),vN=(e,t)=>({u_translation:new rb(e,t.u_translation),u_ratio:new Z(e,t.u_ratio),u_image:new nb(e,t.u_image),u_mix:new Z(e,t.u_mix),u_tileratio:new Z(e,t.u_tileratio),u_crossfade_from:new Z(e,t.u_crossfade_from),u_crossfade_to:new Z(e,t.u_crossfade_to),u_lineatlas_width:new Z(e,t.u_lineatlas_width),u_lineatlas_height:new Z(e,t.u_lineatlas_height)}),yN=(e,t)=>({u_translation:new rb(e,t.u_translation),u_ratio:new Z(e,t.u_ratio),u_image:new nb(e,t.u_image),u_image_height:new Z(e,t.u_image_height),u_tileratio:new Z(e,t.u_tileratio),u_crossfade_from:new Z(e,t.u_crossfade_from),u_crossfade_to:new Z(e,t.u_crossfade_to),u_image_dash:new nb(e,t.u_image_dash),u_mix:new Z(e,t.u_mix),u_lineatlas_width:new Z(e,t.u_lineatlas_width),u_lineatlas_height:new Z(e,t.u_lineatlas_height)}),bN=(e,t,n,r)=>({u_translation:EN(e,t,n),u_ratio:r/Sh(t,1,e.zoom)}),xN=(e,t,n,r,i)=>({...bN(e,t,n,r),u_image:0,u_image_height:i}),SN=(e,t,n,r,i)=>{let a=TN(t,e);return{u_translation:EN(e,t,n),u_texsize:t.imageAtlasTexture.size,u_ratio:r/Sh(t,1,e.zoom),u_image:0,u_scale:[a,i.fromScale,i.toScale],u_fade:i.t}},CN=(e,t,n,r,i,a)=>{let o=TN(n,e);return{...bN(e,n,r,i),u_tileratio:o,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image:0,u_mix:a.t,u_lineatlas_width:t.width,u_lineatlas_height:t.height}},wN=(e,t,n,r,i,a,o)=>{let s=TN(n,e);return{...bN(e,n,r,i),u_image:0,u_image_height:o,u_tileratio:s,u_crossfade_from:a.fromScale,u_crossfade_to:a.toScale,u_image_dash:1,u_mix:a.t,u_lineatlas_width:t.width,u_lineatlas_height:t.height}};function TN(e,t){return 1/Sh(e,1,t.tileZoom)}function EN(e,t,n){return Ah(e,t,n.paint.get(`line-translate`),n.paint.get(`line-translate-anchor`))}var DN=(e,t)=>({u_image:new nb(e,t.u_image),u_backdrop:new nb(e,t.u_backdrop),u_backdrop_offset:new rb(e,t.u_backdrop_offset),u_opacity:new Z(e,t.u_opacity)}),ON=(e,t,n,r)=>({u_image:t,u_backdrop:n,u_backdrop_offset:r,u_opacity:e}),kN=(e,t)=>({u_is_size_zoom_constant:new nb(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new nb(e,t.u_is_size_feature_constant),u_size_t:new Z(e,t.u_size_t),u_size:new Z(e,t.u_size),u_rotate_symbol:new nb(e,t.u_rotate_symbol),u_label_plane_matrix:new ub(e,t.u_label_plane_matrix),u_coord_matrix:new ub(e,t.u_coord_matrix),u_is_text:new nb(e,t.u_is_text),u_pitch_with_map:new nb(e,t.u_pitch_with_map),u_is_along_line:new nb(e,t.u_is_along_line),u_is_variable_anchor:new nb(e,t.u_is_variable_anchor),u_texsize:new rb(e,t.u_texsize),u_texture:new nb(e,t.u_texture),u_translation:new rb(e,t.u_translation),u_pitched_scale:new Z(e,t.u_pitched_scale),u_is_offset:new nb(e,t.u_is_offset),u_height_anchor_ground:new nb(e,t.u_height_anchor_ground)}),AN=(e,t)=>({u_is_size_zoom_constant:new nb(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new nb(e,t.u_is_size_feature_constant),u_size_t:new Z(e,t.u_size_t),u_size:new Z(e,t.u_size),u_rotate_symbol:new nb(e,t.u_rotate_symbol),u_label_plane_matrix:new ub(e,t.u_label_plane_matrix),u_coord_matrix:new ub(e,t.u_coord_matrix),u_is_text:new nb(e,t.u_is_text),u_pitch_with_map:new nb(e,t.u_pitch_with_map),u_is_along_line:new nb(e,t.u_is_along_line),u_is_variable_anchor:new nb(e,t.u_is_variable_anchor),u_texsize:new rb(e,t.u_texsize),u_texture:new nb(e,t.u_texture),u_gamma_scale:new Z(e,t.u_gamma_scale),u_is_halo:new nb(e,t.u_is_halo),u_is_plain:new nb(e,t.u_is_plain),u_translation:new rb(e,t.u_translation),u_pitched_scale:new Z(e,t.u_pitched_scale),u_is_offset:new nb(e,t.u_is_offset),u_height_anchor_ground:new nb(e,t.u_height_anchor_ground)}),jN=(e,t)=>({u_is_size_zoom_constant:new nb(e,t.u_is_size_zoom_constant),u_is_size_feature_constant:new nb(e,t.u_is_size_feature_constant),u_size_t:new Z(e,t.u_size_t),u_size:new Z(e,t.u_size),u_rotate_symbol:new nb(e,t.u_rotate_symbol),u_label_plane_matrix:new ub(e,t.u_label_plane_matrix),u_coord_matrix:new ub(e,t.u_coord_matrix),u_is_text:new nb(e,t.u_is_text),u_pitch_with_map:new nb(e,t.u_pitch_with_map),u_is_along_line:new nb(e,t.u_is_along_line),u_is_variable_anchor:new nb(e,t.u_is_variable_anchor),u_texsize:new rb(e,t.u_texsize),u_texsize_icon:new rb(e,t.u_texsize_icon),u_texture:new nb(e,t.u_texture),u_texture_icon:new nb(e,t.u_texture_icon),u_gamma_scale:new Z(e,t.u_gamma_scale),u_is_halo:new nb(e,t.u_is_halo),u_translation:new rb(e,t.u_translation),u_pitched_scale:new Z(e,t.u_pitched_scale),u_is_offset:new nb(e,t.u_is_offset),u_height_anchor_ground:new nb(e,t.u_height_anchor_ground)}),MN=(e,t,n,r,i,a,o,s,c,l,u,d,f,p)=>({u_is_size_zoom_constant:+(e===`constant`||e===`source`),u_is_size_feature_constant:+(e===`constant`||e===`camera`),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_rotate_symbol:+n,u_label_plane_matrix:o,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+r,u_is_along_line:i,u_is_variable_anchor:a,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d,u_is_offset:f,u_height_anchor_ground:+p}),NN=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)=>({...MN(e,t,n,r,i,a,s,c,l,u,d,p,m,h),u_gamma_scale:r?Math.cos(o.pitch*Math.PI/180)*o.cameraToCenterDistance:1,u_is_halo:+!!f,u_is_plain:1}),PN=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m)=>({...NN(e,t,n,r,i,a,o,s,c,l,!0,u,!0,f,p,m),u_texsize_icon:d,u_texture_icon:1}),FN=(e,t)=>({u_opacity:new Z(e,t.u_opacity),u_color:new ob(e,t.u_color)}),IN=(e,t)=>({u_opacity:new Z(e,t.u_opacity),u_image:new nb(e,t.u_image),u_pattern_tl_a:new rb(e,t.u_pattern_tl_a),u_pattern_br_a:new rb(e,t.u_pattern_br_a),u_pattern_tl_b:new rb(e,t.u_pattern_tl_b),u_pattern_br_b:new rb(e,t.u_pattern_br_b),u_texsize:new rb(e,t.u_texsize),u_mix:new Z(e,t.u_mix),u_pattern_size_a:new rb(e,t.u_pattern_size_a),u_pattern_size_b:new rb(e,t.u_pattern_size_b),u_scale_a:new Z(e,t.u_scale_a),u_scale_b:new Z(e,t.u_scale_b),u_pixel_coord_upper:new rb(e,t.u_pixel_coord_upper),u_pixel_coord_lower:new rb(e,t.u_pixel_coord_lower),u_tile_units_to_pixels:new Z(e,t.u_tile_units_to_pixels)}),LN=(e,t)=>({u_opacity:e,u_color:t}),RN=(e,t,n,r,i,a)=>({...BM(r,a,t,n,i),u_opacity:e}),zN=(e,t)=>({u_sun_pos:new ib(e,t.u_sun_pos),u_atmosphere_blend:new Z(e,t.u_atmosphere_blend),u_globe_position:new ib(e,t.u_globe_position),u_globe_radius:new Z(e,t.u_globe_radius),u_inv_proj_matrix:new ub(e,t.u_inv_proj_matrix)}),BN=(e,t,n,r,i)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:n,u_globe_radius:r,u_inv_proj_matrix:i}),VN=(e,t)=>({u_sky_color:new ob(e,t.u_sky_color),u_horizon_color:new ob(e,t.u_horizon_color),u_horizon:new rb(e,t.u_horizon),u_horizon_normal:new rb(e,t.u_horizon_normal),u_sky_horizon_blend:new Z(e,t.u_sky_horizon_blend),u_sky_blend:new Z(e,t.u_sky_blend),u_inv_proj_matrix:new ub(e,t.u_inv_proj_matrix),u_globe_position:new ib(e,t.u_globe_position),u_globe_radius:new Z(e,t.u_globe_radius),u_atmosphere_blend:new Z(e,t.u_atmosphere_blend)});function HN(e){let t=E8(e),n=nx(e);if(n.projection!==`mercator`)return t;let r=Math.sin(n.pitchInRadians);if(r<=1e-6)return t;let i=Math.cos(n.pitchInRadians),a=Math.min(0,n.elevation,n.minElevationForCurrentTile),o=n.cameraToCenterDistance*i+(n.elevation-a)*n.pixelsPerMeter;if(o<=0)return t;let s=n.cameraToCenterDistance*(i-o/n.farZ)/r-1;return Math.max(t,s)}var UN=(e,t,n)=>{let r=Math.cos(t.rollInRadians),i=Math.sin(t.rollInRadians),a=HN(t),o=Q(t).getProjectionData(t,{overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition,s=Ux(t),c=Hx(t.worldSize,t.center.lat);return{u_sky_color:e[`sky-color`],u_horizon_color:e[`horizon-color`],u_horizon:[(t.width/2-a*i)*n,(t.height/2+a*r)*n],u_horizon_normal:[-i,r],u_sky_horizon_blend:e[`sky-horizon-blend`]*t.height/2*n,u_sky_blend:o,u_inv_proj_matrix:t.inverseProjectionMatrix,u_globe_position:s,u_globe_radius:c,u_atmosphere_blend:e[`atmosphere-blend`]*Xx(jm(s)-c,c)}},WN=(e,t)=>({u_ele_delta:new Z(e,t.u_ele_delta),u_fog_matrix:new ub(e,t.u_fog_matrix),u_fog_color:new ob(e,t.u_fog_color),u_fog_ground_blend:new Z(e,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new Z(e,t.u_fog_ground_blend_opacity),u_horizon_color:new ob(e,t.u_horizon_color),u_horizon_fog_blend:new Z(e,t.u_horizon_fog_blend)}),GN=(e,t,n,r)=>({u_ele_delta:e,u_fog_matrix:t,u_fog_color:n[`fog-color`],u_fog_ground_blend:n[`fog-ground-blend`],u_fog_ground_blend_opacity:r,u_horizon_color:n[`horizon-color`],u_horizon_fog_blend:n[`horizon-fog-blend`]}),KN=(e,t)=>({}),qN={fillExtrusion:VM,fillExtrusionPattern:HM,fill:GM,fillPattern:KM,fillOutline:qM,fillOutlinePattern:JM,circle:$M,collisionBox:KN,collisionCircle:KN,debug:tN,depth:KN,clippingMask:KN,heatmap:rN,heatmapTexture:iN,hillshade:sN,hillshadePrepare:cN,colorRelief:pN,line:hN,lineGradient:gN,linePattern:_N,lineSDF:vN,lineGradientSDF:yN,layerComposite:DN,raster:kT,symbolIcon:kN,symbolSDF:AN,symbolTextAndIcon:jN,background:FN,backgroundPattern:IN,terrain:AM,terrainDepth:jM,terrainHeight:MM,atmosphere:zN,sky:VN,fog:WN},JN=class{constructor(e){this.compiled=[],this.programs=new Map,this.context=e}getProgram(e){let t=e.defines?.length?`${e.name}/${e.defines.join(`/`)}`:e.name,n=this.programs.get(t);n||(n=new Map,this.programs.set(t,n));let r=e.programConfiguration?e.programConfiguration.cacheKey:``,i=n.get(r);i||(i=new Map,n.set(r,i));let a=i.get(e.projectionShaderVariant.name);a||(a=[],i.set(e.projectionShaderVariant.name,a));let o=YN(e),s=a[o];return s||(s=new RM(this.context,Hj[e.name],e.programConfiguration,qN[e.name],e.showOverdrawInspector,e.useTerrain,e.projectionShaderVariant.prelude,e.projectionShaderVariant.define,e.defines),a[o]=s,this.compiled.push(s)),s}destroy(){for(let e of this.compiled)e.program&&this.context.gl.deleteProgram(e.program);this.compiled=[],this.programs=new Map}};function YN(e){return+!!e.showOverdrawInspector+(e.useTerrain?2:0)}var XN=7680,ZN=class{constructor(e,t,n,r,i,a){this.test=e,this.ref=t,this.mask=n,this.fail=r,this.depthFail=i,this.pass=a}};ZN.disabled=new ZN({func:519,mask:0},0,0,XN,XN,XN);var QN=1029,$N=2305,eP=class{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}};eP.disabled=new eP(!1,QN,$N),eP.backCCW=new eP(!0,QN,$N),eP.frontCCW=new eP(!0,1028,$N);var tP=class{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}};tP.ReadOnly=!1,tP.ReadWrite=!0,tP.disabled=new tP(519,tP.ReadOnly,[0,1]);var nP;function rP(e,t,n,r,i){let a=i.context,o=a.gl,s=i.useProgram(`collisionBox`),c=[],l=0,u=0;for(let d of n){let n=e.getTile(d).getBucket(t);if(!n)continue;let f=r?n.textCollisionBox:n.iconCollisionBox,p=n.collisionCircleArray;p.length>0&&(c.push({circleArray:p,circleOffset:u,coord:d}),l+=p.length/4,u=l),f&&s.draw(a,o.LINES,tP.disabled,ZN.disabled,i.colorModeForRenderPass(),eP.disabled,null,i.getTerrainDataForTile(d),i.getProjectionDataForTile(d),t.id,f.layoutVertexBuffer,f.indexBuffer,f.segments,null,i.projectedCamera.zoom,null,null,f.collisionVertexBuffer)}if(!r||!c.length)return;let d=i.useProgram(`collisionCircle`),f=new I6;f.resize(l*4),f._trim();let p=0;for(let e of c)for(let t=0;tl.getElevation(r,e,t):void 0;uP(i,d,f,u,c,p,n,s,m,Ah(c,e,a,o),r.toUnwrapped(),h,t.layout.get(`symbol-height-anchor`)===`ground`)}}}function lP(e,t,n,r,i,a){let o=t.tileAnchorPoint.add(new U(t.translation[0],t.translation[1]));if(t.pitchWithMap){let e=r.mult(a);n||(e=e.rotate(-i));let s=o.add(e);return pj(s.x,s.y,t.pitchedLabelPlaneMatrix,fj(t,s.x,s.y)).point}if(n){let n=bj(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(e),i=Math.atan(n.y/n.x)+(n.x<0?Math.PI:0);return e.add(r.rotate(i))}return e.add(r)}function uP(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=e.text.placedSymbolArray,m=e.text.dynamicLayoutVertexArray,h=e.icon.dynamicLayoutVertexArray,g={};m.clear();for(let h=0;h=0&&(g[_.associatedIconIndex]={shiftedAnchor:O,angle:k})}}if(c){h.clear();let t=e.icon.placedSymbolArray;for(let e=0;ef.terrain.getElevation(s,e,t):void 0;rre(c,e,h,i,L,t,_,l,n.layout.get(`text-rotation-alignment`)===`map`,s.toUnwrapped(),R,r)}let ie=i&&C||te,ae=_?L:f.projectedCamera.clipSpaceToPixelsMatrix,oe=v||ie?aP:ae,se=p&&n.paint.get(i?`text-halo-width`:`icon-halo-width`).constantOr(1)!==0,ce;ce=p?i&&c.iconsInText?PN(S.kind,O,y,_,v,ie,h,oe,ee,R,A,j,T,ne,re):NN(S.kind,O,y,_,v,ie,h,oe,ee,R,i,A,se,T,ne,re):MN(S.kind,O,y,_,v,ie,oe,ee,R,i,A,T,ne,re);let le={program:D,buffers:u,uniformValues:ce,projectionData:z,atlasTexture:M,atlasTextureIcon:P,atlasInterpolation:N,atlasInterpolationIcon:F,isSDF:p,hasHalo:se,hasCursiveText:i&&c.hasCursiveText};if(b&&c.canOverlap){x=!0;let e=u.segments.get();for(let t of e)w.push({segments:new W6([t]),sortKey:t.sortKey,state:le,terrainData:k})}else w.push({segments:u.segments,sortKey:0,state:le,terrainData:k})}x&&w.sort((e,t)=>e.sortKey-t.sortKey);let E=n.paint.get(i?`text-halo-width`:`icon-halo-width`).constantOr(null)??1/0,D=n.layout.get(`text-letter-spacing`).constantOr(0)*24<0||E>1;for(let e of w){let t=e.state;p.activeTexture.set(m.TEXTURE0),t.atlasTexture.bind(t.atlasInterpolation,m.CLAMP_TO_EDGE),t.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),t.atlasTextureIcon&&t.atlasTextureIcon.bind(t.atlasInterpolationIcon,m.CLAMP_TO_EDGE));let r=t.isSDF&&t.hasHalo,i=D||t.hasCursiveText;if(r){let r=t.uniformValues;r.u_is_halo=1,i&&(r.u_is_plain=0,pP(t.buffers,e.segments,n,f,t.program,S,u,d,r,t.projectionData,e.terrainData),r.u_is_halo=0,r.u_is_plain=1)}pP(t.buffers,e.segments,n,f,t.program,S,u,d,t.uniformValues,t.projectionData,e.terrainData),r&&!i&&(t.uniformValues.u_is_halo=0)}}function pP(e,t,n,r,i,a,o,s,c,l,u){let d=r.context,f=d.gl;i.draw(d,f.TRIANGLES,a,o,s,eP.backCCW,c,u,l,n.id,e.layoutVertexBuffer,e.indexBuffer,t,n.paint,r.projectedCamera.zoom,e.programConfigurations.get(n.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function mP(e,t,n,r){if(r.currentPass!==`translucent`)return;let i=t.paint.get(`circle-opacity`),a=t.paint.get(`circle-stroke-width`),o=t.paint.get(`circle-stroke-opacity`),s=!t.layout.get(`circle-sort-key`).isConstant();if(i.constantOr(1)===0&&(a.constantOr(1)===0||o.constantOr(1)===0))return;let c=r.context,l=c.gl,u=r.projectedCamera,d=r.getDepthModeForSublayer(0,tP.ReadOnly),f=ZN.disabled,p=r.colorModeForRenderPass(),m=[],h=Q(u).getCircleRadiusCorrection(u);for(let i of n){let n=e.getTile(i),a=n.getBucket(t);if(!a)continue;let o=Ah(u,n,t.paint.get(`circle-translate`),t.paint.get(`circle-translate-anchor`)),c=a.programConfigurations.get(t.id),l=r.useProgram(`circle`,c),d=a.layoutVertexBuffer,f=a.indexBuffer,p=r.getTerrainDataForTile(i),g={programConfiguration:c,program:l,layoutVertexBuffer:d,indexBuffer:f,uniformValues:eN(u,n,t,o,h),terrainData:p,projectionData:r.getProjectionDataForTile(i)};if(s){let e=a.segments.get();for(let t of e)m.push({segments:new W6([t]),sortKey:t.sortKey,state:g})}else m.push({segments:a.segments,sortKey:0,state:g})}s&&m.sort((e,t)=>e.sortKey-t.sortKey);for(let e of m){let{programConfiguration:n,program:i,layoutVertexBuffer:a,indexBuffer:o,uniformValues:s,terrainData:u,projectionData:m}=e.state,h=e.segments;i.draw(c,l.TRIANGLES,d,f,p,eP.backCCW,s,u,m,t.id,a,o,h,t.paint,r.projectedCamera.zoom,n)}}function hP(e,t,n,r,i){if(n.paint.get(`heatmap-opacity`)===0)return;let a=i.context;if(i.terrain){for(let a of r){let r=t.getTile(a);t.hasRenderableParent(a)||(i.currentPass===`offscreen`?vP(r,n,a,i):i.currentPass===`translucent`&&yP(e,n,a,i))}a.viewport.set([0,0,e.width,e.height])}else i.currentPass===`offscreen`?gP(e,t,n,r,i):i.currentPass===`translucent`&&_P(e,n,i)}function gP(e,t,n,r,i){let a=i.context,o=a.gl,s=i.projectedCamera,c=ZN.disabled,l=new EM([o.ONE,o.ONE],R1.transparent,[!0,!0,!0,!0]);bP(a,e,n),a.clear({color:R1.transparent});for(let e of r){if(t.hasRenderableParent(e))continue;let r=t.getTile(e),u=r.getBucket(n);if(!u)continue;let d=u.programConfigurations.get(n.id),f=i.useProgram(`heatmap`,d),p=i.getProjectionDataForTile(e,{applyTerrainMatrix:!1}),m=Q(s).getCircleRadiusCorrection(s);f.draw(a,o.TRIANGLES,tP.disabled,c,l,eP.backCCW,aN(r,s.zoom,n.paint.get(`heatmap-intensity`),m),null,p,n.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,n.paint,s.zoom,d)}a.viewport.set([0,0,e.width,e.height])}function _P(e,t,n){let r=n.context,i=r.gl;r.setColorMode(n.colorModeForRenderPass());let a=t.heatmapFbos.get(R7);a&&(r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1),SP(r,t).bind(i.LINEAR,i.CLAMP_TO_EDGE),n.useProgram(`heatmapTexture`).draw(r,i.TRIANGLES,tP.disabled,ZN.disabled,n.colorModeForRenderPass(),eP.disabled,oN(e,t,0,1),null,null,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,n.projectedCamera.zoom))}function vP(e,t,n,r){let i=r.context,a=i.gl,o=ZN.disabled,s=new EM([a.ONE,a.ONE],R1.transparent,[!0,!0,!0,!0]),c=e.getBucket(t);if(!c)return;let l=n.key,u=t.heatmapFbos.get(l);u||(u=xP(i,e.tileSize,e.tileSize),t.heatmapFbos.set(l,u)),i.bindFramebuffer.set(u.framebuffer),i.viewport.set([0,0,e.tileSize,e.tileSize]),i.clear({color:R1.transparent});let d=c.programConfigurations.get(t.id),f=r.useProgram(`heatmap`,d,!r.data.isRenderingGlobe),p=r.getProjectionDataForTile(e.tileID),m=r.getTerrainDataForTile(n);f.draw(i,a.TRIANGLES,tP.disabled,o,s,eP.disabled,aN(e,r.projectedCamera.zoom,t.paint.get(`heatmap-intensity`),1),m,p,t.id,c.layoutVertexBuffer,c.indexBuffer,c.segments,t.paint,r.projectedCamera.zoom,d)}function yP(e,t,n,r){let i=r.context,a=i.gl,o=r.projectedCamera;i.setColorMode(r.colorModeForRenderPass());let s=SP(i,t),c=n.key,l=t.heatmapFbos.get(c);if(!l)return;i.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,l.colorAttachment.get()),i.activeTexture.set(a.TEXTURE1),s.bind(a.LINEAR,a.CLAMP_TO_EDGE);let u=r.getProjectionDataForTile(n,{applyTerrainMatrix:r.data.isRenderingGlobe});r.useProgram(`heatmapTexture`).draw(i,a.TRIANGLES,tP.disabled,ZN.disabled,r.colorModeForRenderPass(),eP.disabled,oN(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,o.zoom),l.destroy(),t.heatmapFbos.delete(c)}function bP(e,t,n){let r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let i=n.heatmapFbos.get(R7);i?(r.bindTexture(r.TEXTURE_2D,i.colorAttachment.get()),e.bindFramebuffer.set(i.framebuffer)):(i=xP(e,t.width/4,t.height/4),n.heatmapFbos.set(R7,i))}function xP(e,t,n){let r=e.gl,i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texStorage2D(r.TEXTURE_2D,1,r.RGBA16F,t,n);let a=e.createFramebuffer(t,n,!1,!1);return a.colorAttachment.set(i),a}function SP(e,t){return t.colorRampTexture||=new b3(e,t.colorRamp,e.gl.RGBA),t.colorRampTexture}var CP={multiply:[`#define LAYER_BLEND;`,`#define LAYER_BLEND_MULTIPLY;`],overlay:[`#define LAYER_BLEND;`,`#define LAYER_BLEND_OVERLAY;`],"hard-light":[`#define LAYER_BLEND;`,`#define LAYER_BLEND_HARD_LIGHT;`],difference:[`#define LAYER_BLEND;`,`#define LAYER_BLEND_DIFFERENCE;`],exclusion:[`#define LAYER_BLEND;`,`#define LAYER_BLEND_EXCLUSION;`],darken:[`#define LAYER_BLEND;`,`#define LAYER_BLEND_DARKEN;`],lighten:[`#define LAYER_BLEND;`,`#define LAYER_BLEND_LIGHTEN;`],"soft-light":[`#define LAYER_BLEND;`,`#define LAYER_BLEND_UNPREMULTIPLIED;`,`#define LAYER_BLEND_SOFT_LIGHT;`],"color-dodge":[`#define LAYER_BLEND;`,`#define LAYER_BLEND_UNPREMULTIPLIED;`,`#define LAYER_BLEND_COLOR_DODGE;`],"color-burn":[`#define LAYER_BLEND;`,`#define LAYER_BLEND_UNPREMULTIPLIED;`,`#define LAYER_BLEND_COLOR_BURN;`],color:[`#define LAYER_BLEND;`,`#define LAYER_BLEND_UNPREMULTIPLIED;`,`#define LAYER_BLEND_NONSEPARABLE;`,`#define LAYER_BLEND_COLOR;`],luminosity:[`#define LAYER_BLEND;`,`#define LAYER_BLEND_UNPREMULTIPLIED;`,`#define LAYER_BLEND_NONSEPARABLE;`,`#define LAYER_BLEND_LUMINOSITY;`],hue:[`#define LAYER_BLEND;`,`#define LAYER_BLEND_UNPREMULTIPLIED;`,`#define LAYER_BLEND_NONSEPARABLE;`,`#define LAYER_BLEND_HUE;`],saturation:[`#define LAYER_BLEND;`,`#define LAYER_BLEND_UNPREMULTIPLIED;`,`#define LAYER_BLEND_NONSEPARABLE;`,`#define LAYER_BLEND_SATURATION;`]};function wP(e){return e in CP}function TP(e){return l7(e)?wP(e.paint.get(`fill-layer-blend`)):l9(e)?wP(e.paint.get(`line-layer-blend`)):r3(e)?wP(e.paint.get(`raster-layer-blend`)):!1}var EP={"plus-lighter":EM.plusLighter,screen:EM.screen},DP=[[0,0],[W,0],[0,W],[W,W]];function OP(e,t){let[,,n,r]=t.context.viewport.get(),i=[0,0,n,r];if(e.length===0)return[0,0,0,0];if(t.terrain||t.data.useSubdivision)return i;let a=1/0,o=-1/0,s=1/0,c=-1/0;for(let l of e){let e=l.toUnwrapped();for(let[l,u]of DP){let{point:d,signedDistanceFromCamera:f}=Q(t.projectedCamera).projectTileCoordinates(t.projectedCamera,l,u,e,null);if(f<=0)return i;let p=(d.x+1)*.5*n,m=(d.y+1)*.5*r;po&&(o=p),mc&&(c=m)}}let l=Math.max(0,Math.floor(a)),u=Math.max(0,Math.floor(s)),d=Math.min(n,Math.ceil(o)),f=Math.min(r,Math.ceil(c));return d<=l||f<=u?[0,0,0,0]:[l,u,d-l,f-u]}function kP(e,t,n,r,i){let a=i.context,o=a.bindFramebuffer.get(),s=a.viewport.get(),[,,c,l]=s;i.layerCompositeSampled&&a.gl.flush(),AP(e,c,l),a.viewport.set([0,0,c,l]),a.clear({color:R1.transparent,depth:1,stencil:0}),i.invalidateTileClippingMasks(),i.renderTileClippingMasks(n,r);let u=r.filter(e=>t.getTile(e)?.getBucket(n));return{compositeTarget:o,compositeViewport:s,bounds:r3(n)?[0,0,c,l]:OP(u,i)}}function AP(e,t,n){let r=e.context.gl;if(!e.layerCompositeFbo){let i=e.context.createFramebuffer(t,n,!0,!0);i.colorAttachment.set(jP(e,t,n)),i.depthAttachment.set(e.context.createRenderbuffer(r.DEPTH_STENCIL,t,n)),e.layerCompositeFbo=i,e.context.bindFramebuffer.set(e.layerCompositeFbo.framebuffer);return}if(e.layerCompositeFbo.width===t&&e.layerCompositeFbo.height===n){e.context.bindFramebuffer.set(e.layerCompositeFbo.framebuffer);return}let i=e.layerCompositeFbo;r.bindTexture(r.TEXTURE_2D,i.colorAttachment.get()),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,n,0,r.RGBA,r.UNSIGNED_BYTE,null),e.context.bindRenderbuffer.set(i.depthAttachment.get()),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,n),e.context.bindRenderbuffer.set(null),i.width=t,i.height=n,e.context.bindFramebuffer.set(i.framebuffer)}function jP(e,t,n){let r=e.context.gl,i=r.createTexture();return r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,t,n,0,r.RGBA,r.UNSIGNED_BYTE,null),i}function MP(e,t,n,r,i){let a=e.context.gl,o=e.layerCompositeBackdrop;o?o.widthl.data.anisotropicFilterPitch&&p.texParameterf(p.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax);let D=l.getTerrainDataForTile(x),O=l.getProjectionDataForTile(x,{aligned:g}),k=AT(T,w,E.fadeMix,t,o,s),A=u??l.getMeshFromTileID(x.canonical,i,a,`raster`),j=r?r[x.overscaledZ]:ZN.disabled;m.draw(f,p.TRIANGLES,n,j,h,c?eP.frontCCW:eP.backCCW,k,D,O,t.id,A.vertexBuffer,A.indexBuffer,A.segments)}}function iF(e,t,n,r){let i={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(n===0||r)return i;if(e.fadingParentID){let r=t.getLoadedTile(e.fadingParentID);if(!r)return i;let a=2**(r.tileID.overscaledZ-e.tileID.overscaledZ);return{parentTile:r,parentScaleBy:a,parentTopLeft:[e.tileID.canonical.x*a%1,e.tileID.canonical.y*a%1],fadeValues:aF(e,r,n)}}return e.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:oF(e,n)}:i}function aF(e,t,n){let r=Ig(),i=(r-e.timeAdded)/n,a=(r-t.timeAdded)/n,o=e.fadingDirection===1,s=G(i,0,1),c=G(1-a,0,1),l=o?s:c;return{tileOpacity:l,parentTileOpacity:o?c:s,fadeMix:{opacity:1,mix:1-l}}}function oF(e,t){let n=G((Ig()-e.timeAdded)/t,0,1);return{tileOpacity:n,fadeMix:{opacity:n,mix:0}}}function sF(e,t,n,r,i){let a=n.paint.get(`background-color`),o=n.paint.get(`background-opacity`);if(o===0)return;let s=i.context,c=s.gl,l=i.projectedCamera,u=l.tileSize,d=n.paint.get(`background-pattern`);if(e.patternAtlas.isPatternMissing(d))return;let f=!d&&a.a===1&&o===1&&i.opaquePassEnabledForLayer()?`opaque`:`translucent`;if(i.currentPass!==f)return;let p=ZN.disabled,m=i.getDepthModeForSublayer(0,f===`opaque`?tP.ReadWrite:tP.ReadOnly),h=i.colorModeForRenderPass(),g=i.useProgram(d?`backgroundPattern`:`background`),_=r||ej(l,i.worldCoordinateHelper,{tileSize:u,terrain:i.terrain});d&&(s.activeTexture.set(c.TEXTURE0),e.patternAtlas.bind(s));let v=n.getCrossfadeParameters();for(let t of _){let r=i.getProjectionDataForTile(t),f=d?RN(o,e.patternAtlas,l,d,{tileID:t,tileSize:u},v):LN(o,a),_=i.getTerrainDataForTile(t),y=i.getMeshFromTileID(t.canonical,!1,!0,`raster`);g.draw(s,c.TRIANGLES,m,p,h,eP.backCCW,f,_,r,n.id,y.vertexBuffer,y.indexBuffer,y.segments)}}var cF=new R1(1,0,0,1),lF=new R1(0,1,0,1),uF=new R1(0,0,1,1),dF=new R1(1,0,1,1),fF=new R1(0,1,1,1);function pF(e){let t=e.projectedCamera.padding;hF(e,e.projectedCamera.height-(t.top||0),3,cF),hF(e,t.bottom||0,3,lF),gF(e,t.left||0,3,uF),gF(e,e.projectedCamera.width-(t.right||0),3,dF);let n=e.projectedCamera.centerPoint;mF(e,n.x,e.projectedCamera.height-n.y,fF)}function mF(e,t,n,r){_F(e,t-1,n-10,2,20,r),_F(e,t-10,n-1,20,2,r)}function hF(e,t,n,r){_F(e,0,t+n/2,e.projectedCamera.width,n,r)}function gF(e,t,n,r){_F(e,t-n/2,0,n,e.projectedCamera.height,r)}function _F(e,t,n,r,i,a){let o=e.context,s=o.gl,c=e.data.pixelRatio;s.enable(s.SCISSOR_TEST),s.scissor(t*c,n*c,r*c,i*c),o.clear({color:a}),s.disable(s.SCISSOR_TEST)}function vF(e,t,n,r){for(let i of n)yF(e,t,i,r)}function yF(e,t,n,r){let i=r.context,a=i.gl,o=r.useProgram(`debug`),s=tP.disabled,c=ZN.disabled,l=r.colorModeForRenderPass(),u=`$debug`,d=r.getTerrainDataForTile(n);i.activeTexture.set(a.TEXTURE0);let f=t.getTileByID(n.key).latestRawTileData?.byteLength||0,p=Math.floor(f/1024),m=t.getTile(n).tileSize,h=512/Math.min(m,512)*(n.overscaledZ/r.projectedCamera.zoom)*.5,g=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(g+=` => ${n.overscaledZ}`),bF(e,`${g} ${p}kB`);let _=r.getProjectionDataForTile(n);o.draw(i,a.TRIANGLES,s,c,EM.alphaBlended,eP.disabled,nN(R1.transparent,h),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),o.draw(i,a.LINE_STRIP,s,c,l,eP.disabled,nN(R1.red),d,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function bF(e,t){e.initDebugOverlayCanvas();let n=e.debugOverlayCanvas,r=e.context.gl,i=e.debugOverlayCanvas.getContext(`2d`);i.clearRect(0,0,n.width,n.height),i.shadowColor=`white`,i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle=`white`,i.textBaseline=`top`,i.font=`bold 36px Open Sans, sans-serif`,i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}function xF(e,t){let n=null,r=Object.values(e._layers).flatMap(n=>n.source&&!n.isHidden(t)?[e.tileManagers[n.source]]:[]),i=r.filter(e=>e.getSource().type===`vector`),a=r.filter(e=>e.getSource().type!==`vector`),o=e=>{(!n||n.getSource().maxzoomQ(u).getProjectionData(u,{overscaledTileID:new m8(e.tileID.canonical.z,e.tileID.wrap??0,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),aligned:e.aligned,applyGlobeMatrix:e.applyGlobeMatrix,applyTerrainMatrix:e.applyTerrainMatrix}),renderTerrainHeightMap:s&&i.currentPass===`offscreen`?e=>wF(i,s,e):void 0},p=l.renderingMode?l.renderingMode:`2d`;if(i.currentPass===`offscreen`){let t=l.prerender;t&&(c.setCustomLayerDefaults(),c.setColorMode(i.colorModeForRenderPass()),t.call(l,c.gl,f),c.setDirty(),e.setBaseState())}else if(i.currentPass===`translucent`){c.setCustomLayerDefaults(),c.setColorMode(i.colorModeForRenderPass()),c.setStencilMode(ZN.disabled);let t=p===`3d`?i.getDepthModeFor3D():i.getDepthModeForSublayer(0,tP.ReadOnly);c.setDepthMode(t),l.render(c.gl,f),c.setDirty(),e.setBaseState(),c.bindFramebuffer.set(null)}}function EF(e,t,n,r){let i=r.context,a=i.bindFramebuffer.get(),o=i.viewport.get();i.setCustomLayerDefaults(),i.setColorMode(r.colorModeForRenderPass()),i.setDepthMode(tP.disabled),i.setStencilMode(ZN.disabled),t.implementation.renderToTerrainTile(i.gl,{tileID:{canonical:n.canonical,wrap:n.wrap},width:o[2],height:o[3]}),i.setDirty(),e.setBaseState(),i.bindFramebuffer.set(a),i.viewport.set(o)}function DF(e,t){let n=t.context,r=n.gl,{sky:i,pixelRatio:a}=t.data,o=UN(i,t.projectedCamera,a),s=new tP(r.LEQUAL,tP.ReadWrite,[0,1]),c=ZN.disabled,l=t.colorModeForRenderPass();t.useProgram(`sky`).draw(n,r.TRIANGLES,s,c,l,eP.disabled,o,null,void 0,`sky`,e.vertexBuffer,e.indexBuffer,e.segments)}function OF(e,t){let n=sg(e.position);Rm(n,n);let r=mm(new Float64Array(16));return e.anchor===`map`&&(xm(r,r,t.rollInRadians),ym(r,r,-t.pitchInRadians),xm(r,r,t.bearingInRadians),ym(r,r,t.center.lat*Math.PI/180),bm(r,r,-t.center.lng*Math.PI/180)),Um(n,n,r),n}function kF(e,t){let n=t.context,r=n.gl,{sky:i,light:a}=t.data,o=t.useProgram(`atmosphere`),s=new tP(r.LEQUAL,tP.ReadOnly,[0,1]),c=t.projectedCamera,l=OF(a,c),u=Q(c).getProjectionData(c,{overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),d=Hx(c.worldSize,c.center.lat),f=Ux(c),p=Xx(jm(f)-d,d),m=i[`atmosphere-blend`]*u.projectionTransition*p;if(m===0)return;let h=BN(l,m,f,d,c.inverseProjectionMatrix);o.draw(n,r.TRIANGLES,s,ZN.disabled,EM.alphaBlended,eP.disabled,h,null,null,`atmosphere`,e.vertexBuffer,e.indexBuffer,e.segments)}var AF=[`none`,`zoom`,`sourceTiles`,`visibleLayers`,`revision`],jF=class{constructor(e,t,n,r){this._tileKeys=e.map(e=>e.key).sort().join(),this._revision=t,this._zoom=n,this._visibleLayerIds=r}difference(e){return this._revision===e?._revision?this._visibleLayerIds===e._visibleLayerIds?this._tileKeys===e._tileKeys?this._zoom===e._zoom?`none`:`zoom`:`sourceTiles`:`visibleLayers`:`revision`}},MF={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};function NF(e){return j3(e)?`custom-layer:${e.id}`:e.source}function PF(e){return j3(e)?e.implementation.renderToTerrainTile!==void 0:MF[e.type]===!0}function FF(e,t){let n=[],r=!1;for(let i of t){let t=PF(e._layers[i]);t&&!r&&n.push([]),t&&n[n.length-1].push(i),r=t}return n}var IF=class{constructor(e,t){this.needsFollowUpFrame=!1,this.painter=e,this.terrain=t,this.rttSize=t.tileManager.tileSize*t.qualityFactor}getTexture(e){return e.getRTT(this._stacks.length-1).texture}prepareForRender(e,t,n){let r=t!==this._lastPrepareZoom;this._lastPrepareZoom=t,this._stacks=[],this._prevRenderedToTexture=!1,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(n=>!e._layers[n].isHidden(t));let i=FF(e,this._renderableLayerIds),a=this._renderableLayerIds.join(),o=new Set;for(let t of this._renderableLayerIds){let n=e._layers[t],r=n.source;r&&MF[n.type]&&o.add(r)}this._coordsAscending={},this._rttFingerprints={};for(let n of o){let r=e.tileManagers[n];if(!r)continue;this._coordsAscending[n]={};let i=this._coordsAscending[n],o=r.getSource(),s=o instanceof RT?o.terrainTileRanges:null;for(let e of r.getVisibleCoordinates()){let t=this.terrain.tileManager.getTerrainCoords(e,s);for(let e in t)i[e]||=[],i[e].push(t[e])}this._rttFingerprints[n]={};let c=this._rttFingerprints[n],l=r.getState().revision;for(let e in i)c[e]=new jF(i[e],l,t,a)}for(let n of this._renderableLayerIds){let r=e._layers[n];if(!j3(r)||!PF(r))continue;let i=r.implementation.terrainTileRevision??0,o={};for(let e of this._renderableTiles)o[e.tileID.key]=new jF([e.tileID],i,t,a);this._rttFingerprints[NF(r)]=o}this.needsFollowUpFrame=!1;let s=r||n,c=!1;for(let t of this._renderableTiles){let n=this._textureDifference(t);n!==`none`&&(n===`zoom`&&s||n===`visibleLayers`&&r?this.needsFollowUpFrame=!0:n===`zoom`||n===`sourceTiles`?(c?this.needsFollowUpFrame=!0:this._releaseChangedTextures(t,e,i),c=!0):this._releaseChangedTextures(t,e,i))}}_releaseChangedTextures(e,t,n){let r=n.map(n=>this._hasStackChanged(e,t,n));if(!r.includes(!1))e.releaseRTT(this.painter);else for(let[t,n]of r.entries())n&&e.releaseRTTStack(this.painter,t)}_hasStackChanged(e,t,n){let r=!1;for(let i of n){let n=NF(t._layers[i]),a=this._rttFingerprints[n]?.[e.tileID.key],o=e.rttFingerprint[n];if(a||o){if(a?.difference(o)!==`none`)return!0;r=!0}}return!r}_textureDifference(e){let t=`none`;for(let n in this._rttFingerprints){let r=this._rttFingerprints[n][e.tileID.key];if(!r)continue;let i=r.difference(e.rttFingerprint[n]);AF.indexOf(i)>AF.indexOf(t)&&(t=i)}return t}renderLayer(e,t,n){if(e.isHidden(n.projectedCamera.zoom))return!1;let r=PF(e),i=this.painter,a=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(r&&(this._prevRenderedToTexture||this._stacks.push([]),this._prevRenderedToTexture=!0,this._stacks[this._stacks.length-1].push(e.id),!a))return!0;if(this._prevRenderedToTexture||r&&a){this._prevRenderedToTexture=r;let e=this._stacks.length-1,a=this._stacks[e]||[];n.isRenderingToTexture=!0,xM(i.context.frameUniformBuffer,this.rttSize,this.rttSize);for(let r of this._renderableTiles){if(this._rttTiles.push(r),r.getRTT(e))continue;let o=r.acquireRTT(i,e,this.rttSize);i.bindRTT(o),i.context.clear({color:R1.transparent,stencil:0}),n.invalidateTileClippingMasks();for(let e of a){let a=t._layers[e],o=a.source?this._coordsAscending[a.source][r.tileID.key]:[r.tileID];i.context.viewport.set([0,0,this.rttSize,this.rttSize]),n.renderTileClippingMasks(a,o),i.renderLayer(i,t.tileManagers[a.source],a,o,n);let s=NF(a);s&&(r.rttFingerprint[s]=this._rttFingerprints[s][r.tileID.key])}o.texture.generateMipmap()}return n.isRenderingToTexture=!1,xM(i.context.frameUniformBuffer,i.context.gl.drawingBufferWidth,i.context.gl.drawingBufferHeight),CF(this.painter,this.terrain,this._rttTiles,n),this._rttTiles=[],r}return!1}};function LF(e){let{sky:t,isRenderingGlobe:n}=e.data;return!e.terrain||n||!t||t[`fog-ground-blend`]>=1?0:Gw(e.projectedCamera.pitch)}function RF(e,t,n){for(let r=e.length-1;r>=0;r--){let i=t[e[r]];if(PF(i)&&!i.isHidden(n))return r}return-1}function zF(e,t,n){let{sky:r}=n.data,i=n.context,a=i.gl,o=n.projectedCamera,s=n.useProgram(`fog`),c=new tP(a.LEQUAL,tP.ReadOnly,n.depthRangeFor3D),l=n.stencilModeFor3D(),u=e.getSkirtLength(o.zoom),d=Q(o);for(let f of e.tileManager.getRenderableTiles()){let p=e.getTerrainMesh(f.tileID,!1),m=e.getTerrainData(f.tileID),h=GN(u,d.calculateFogMatrix(o,f.tileID.toUnwrapped()),r,t),g=n.getProjectionDataForTile(f.tileID,{applyTerrainMatrix:!1});s.draw(i,a.TRIANGLES,c,l,EM.alphaBlended,eP.backCCW,h,m,g,`fog`,p.vertexBuffer,p.indexBuffer,p.segments)}}var BF={symbol:oP,circle:mP,heatmap:hP,line:zP,fill:HP,fillExtrusion:KP,hillshade:JP,colorRelief:ZP,raster:tF,background:sF,sky:DF,atmosphere:kF,fog:zF,custom:TF,debug:vF,debugPadding:pF,terrainDepth:SF},VF=oj.maxOverzooming+oj.maxUnderzooming+1,HF=1/2**16,UF={name:Gj,define:Wj,prelude:Hj.projectionMercator},WF=class{constructor(e){this.currentLayer=0,this.opaquePassCutoff=1/0,this.depthRangeFor3D=[0,1],this.isRenderingToTexture=!1,this.layerCompositeSampled=!1,this.nextStencilID=1,this.tileClippingMaskIDs={},this.projectedCamera=e.projectedCamera,this.worldCoordinateHelper=e.worldCoordinateHelper,this.terrain=e.terrain,this.data=e.data,this.context=e.context,this.programCache=e.programCache,this.currentPass=e.currentPass,this.projection=e.projection}getProjectionDataForTile(e,t={}){let n=Q(this.projectedCamera).getProjectionData(this.projectedCamera,{overscaledTileID:e,aligned:t.aligned,applyGlobeMatrix:!this.isRenderingToTexture,applyTerrainMatrix:t.applyTerrainMatrix??!0});return this.isRenderingToTexture||(n.uniformBufferKey=t.aligned?`${e.key}/aligned`:e.key),n}getTerrainDataForTile(e){return this.isRenderingToTexture?null:this.terrain?.getTerrainData(e)??null}getMeshFromTileID(e,t,n,r){return this.projection.getMeshFromTileID(this.context,e,t,n,r)}useProgram(e,t,n=!1,r=[]){return this.programCache.getProgram({name:e,programConfiguration:t,projectionShaderVariant:n?UF:this.data.projectionShaderVariant,showOverdrawInspector:this.data.showOverdrawInspector,useTerrain:this.terrain!==null,defines:r})}colorModeForRenderPass(){let e=this.context.gl;if(this.data.showOverdrawInspector){let t=1/8;return new EM([e.CONSTANT_COLOR,e.ONE],new R1(t,t,t,0),[!0,!0,!0,!0])}return this.currentPass===`opaque`?EM.unblended:EM.alphaBlended}getDepthModeForSublayer(e,t,n){if(!this.opaquePassEnabledForLayer())return tP.disabled;let r=1-((1+this.currentLayer)*VF+e)*HF;return new tP(n||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new tP(this.context.gl.LEQUAL,tP.ReadWrite,this.depthRangeFor3D)}setDepthRangeFor3D(e){this.depthRangeFor3D=[0,1-(e+2)*VF*HF]}opaquePassEnabledForLayer(){return this.currentLayer256&&this.clearStencil();let n=this.context;n.setColorMode(EM.disabled),n.setDepthMode(tP.disabled);let r={};for(let e of t)r[e.key]=this.nextStencilID++;this.data.useSubdivision&&this.renderTileMasks(r,t,!0),this.renderTileMasks(r,t,!1),this.tileClippingMaskIDs=r}renderTileMasks(e,t,n){let r=this.context,i=r.gl,a=this.useProgram(`clippingMask`);for(let o of t){let t=e[o.key],s=this.getTerrainDataForTile(o),c=this.getMeshFromTileID(o.canonical,n,!0,`stencil`),l=this.getProjectionDataForTile(o);a.draw(r,i.TRIANGLES,tP.disabled,new ZN({func:i.ALWAYS,mask:0},t,255,i.KEEP,i.KEEP,i.REPLACE),EM.disabled,this.isRenderingToTexture?eP.disabled:eP.backCCW,null,s,l,`$clipping`,c.vertexBuffer,c.indexBuffer,c.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,t=this.context.gl;return new ZN({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new ZN({func:t.EQUAL,mask:255},this.tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let t=this.context.gl,n=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(i>1){this.currentStencilSource=void 0,this.nextStencilID+i>256&&this.clearStencil();let e={};for(let n=0;nt.overscaledZ-e.overscaledZ),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(this.clearStencil(),i>1){let e={},a={};for(let n=0;n=0;i.currentLayer--){let n=e._layers[a[i.currentLayer]];if(n.isHidden(t.zoom))continue;let r=o[n.source],c=s[n.source];i.renderTileClippingMasks(n,c),this.renderLayer(this,r,n,c,i)}i.currentPass=`translucent`;let u=LF(i),d=u>0?RF(a,e._layers,t.zoom):-1,f=!1,p=!1;for(i.currentLayer=0;i.currentLayer=0&&!f&&i.currentLayer>d&&(this.drawFunctions.fog(i.terrain,u,i),f=!0),!i.opaquePassEnabledForLayer()&&!p&&(p=!0,r.isRenderingGlobe&&!i.terrain&&this._renderTilesDepthBuffer(i));let h=(n.type===`symbol`?l:c)[n.source];i.renderTileClippingMasks(n,s[n.source]),this.renderLayer(this,m,n,h,i)}if(d>=0&&!f&&this.drawFunctions.fog(i.terrain,u,i),r.isRenderingGlobe&&this.drawFunctions.atmosphere(this.skyMesh,i),r.showTileBoundaries){let n=xF(e,t.zoom);n&&this.drawFunctions.debug(this,n,n.getVisibleCoordinates(),i)}r.showPadding&&this.drawFunctions.debugPadding(i),this.renderToTexture&&!r.moving&&this.clearRTTPool(),this.context.setDefault()}markTerrainDepthDirty(){this.terrainFacilitator.depthDirty=!0}maybeDrawDepth(e){if(!e.data.projectionShaderVariant||!e.terrain)return;let t=this.terrainFacilitator.matrix,n=e.projectedCamera.modelViewProjectionMatrix,r=this.terrainFacilitator.depthDirty;r||=!Om(t,n),r||=e.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime),r&&(pm(t,n),this.terrainFacilitator.renderTime=Ig(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,e.terrain,e))}renderLayer(e,t,n,r,i){if(n.isHidden(i.projectedCamera.zoom)||n.type!==`background`&&n.type!==`custom`&&!(r||[]).length)return;let a=this.drawFunctions;ow(n)?a.symbol(e,t,n,r,i):yte(n)?a.circle(t,n,r,i):z7(n)?a.heatmap(e,t,n,r,i):l9(n)?a.line(e,t,n,r,i):l7(n)?a.fill(e,t,n,r,i):D7(n)?a.fillExtrusion(t,n,r,i):c3(n)?a.hillshade(e,t,n,r,i):C3(n)?a.colorRelief(e,t,n,r,i):r3(n)?a.raster(e,t,n,r,i):O3(n)?a.background(e,t,n,r,i):j3(n)&&a.custom(e,t,n,r,i)}static{this.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50}saveTileTexture(t){let n=this._tileTextures[t.size[0]];n?n.length0?t.pop():null}acquireRTT(e){let t=this.context.gl,n=this._rttObjectRecyclePool.pop();if(n)return n.size!==e&&(n.texture.update({width:e,height:e,data:null},{premultiply:!1,useMipmap:!0}),n.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE,t.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),n.size=e),n;let r=new b3(this.context,{width:e,height:e,data:null},t.RGBA,{premultiply:!1,useMipmap:!0});return r.bind(t.LINEAR,t.CLAMP_TO_EDGE,t.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:r,size:e}}bindRTT(e){let t=this.context.gl,n=e.size;if(!this._rttSharedFbo){let e=this.context.createFramebuffer(n,n,!0,!0),r=this.context.createRenderbuffer(t.DEPTH_STENCIL,n,n);e.depthAttachment.set(r),this._rttSharedFbo={fbo:e,depthRenderbuffer:r,size:n}}this._rttSharedFbo.size!==n&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,n,n),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=n,this._rttSharedFbo.fbo.height=n,this._rttSharedFbo.size=n),this._rttSharedFbo.fbo.colorAttachment.set(e.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(e){this._rttObjectRecyclePool.push(e)}clearRTTPool(){for(let e of this._rttObjectRecyclePool)e.texture.destroy();this._rttObjectRecyclePool.length=0}destroyRTTResources(){if(this.clearRTTPool(),!this._rttSharedFbo)return;this._rttSharedFbo.fbo.colorAttachment.set(null),this._rttSharedFbo.fbo.depthAttachment.set(null);let e=this.context.gl;e.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),e.deleteFramebuffer(this._rttSharedFbo.fbo.framebuffer),this._rttSharedFbo=null}setBaseState(){let e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){if(this.debugOverlayCanvas==null){this.debugOverlayCanvas=document.createElement(`canvas`),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;let e=this.context.gl;this.debugOverlayTexture=new b3(this.context,this.debugOverlayCanvas,e.RGBA)}}destroy(){if(this._tileTextures){for(let e in this._tileTextures){let t=this._tileTextures[e];if(t)for(let e of t)e.destroy()}this._tileTextures={}}this.destroyRTTResources(),this.layerCompositeFbo?.destroy(),this.layerCompositeFbo=null,this.layerCompositeBackdrop&&=(this.context.gl.deleteTexture(this.layerCompositeBackdrop.texture),null),this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&this.tileExtentMesh.vertexBuffer?.destroy(),this.tileExtentMesh&&this.tileExtentMesh.indexBuffer?.destroy(),this.skyMesh?.destroy(),this.skyMesh=null,this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.context.destroy(),this.programCache.destroy(),this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}},KF=class extends Error{constructor(e,t){super(`WebGL2 is required to display this map. We are sorry, but it seems that your browser does not support WebGL2, a technology for rendering 3D graphics on the web. Read more on https://wiki.openstreetmap.org/wiki/This_map_requires_WebGL`),this.name=`GPUInitializationError`,this.requestedAttributes=e,this.statusMessage=t?.statusMessage??null}};function qF(e,t){let n=!1,r=null,i,a=()=>{r=null,n&&=(e(...i),r=setTimeout(a,t),!1)};return(...e)=>(n=!0,i=e,r||a(),r)}var JF=class{constructor(e){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace(`#`,``)),this._getCurrentHash=()=>{let e=this._getHashParams();return this._hashName?(e.get(this._hashName)||``).split(`/`):([...e.keys()][0]??``).split(`/`)},this._onHashChange=()=>{let e=this._getCurrentHash();if(!this._isValidHash(e))return!1;let t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{let e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{let e=this._getHashParams();if(this._hashName)e.delete(this._hashName);else{let t=Array.from(e.keys());t.length>0&&e.delete(t[0])}let t=decodeURIComponent(e.toString()).replace(/=&/g,`&`).replace(/=$/g,``),n=t?`#${t}`:``,r=window.location.href.replace(/(#.+)?$/,n);r=r.replace(`&&`,`&`),window.history.replaceState(window.history.state,null,r)},this._updateHash=qF(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener(`hashchange`,this._onHashChange,!1),this._map.on(`moveend`,this._updateHash),this}remove(){return removeEventListener(`hashchange`,this._onHashChange,!1),this._map.off(`moveend`,this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let t=this._map.getCenter(),n=Math.round(this._map.getZoom()*100)/100,r=F8(this._map._camera.context.worldCoordinateHelper,t),i=10**Math.ceil((n*Math.LN2+Math.log(512/r/.5))/Math.LN10),a=Math.round(t.lng*i)/i,o=Math.round(t.lat*i)/i,s=this._map.getBearing(),c=this._map.getPitch(),l=``;if(l+=e?`/${a}/${o}/${n}`:`${n}/${o}/${a}`,(s||c)&&(l+=`/${Math.round(s*10)/10}`),c&&(l+=`/${Math.round(c)}`),this._hashName){let e=this._getHashParams();return e.set(this._hashName,l),`#${decodeURIComponent(e.toString()).replace(/=&/g,`&`).replace(/=$/g,``)}`}return`#${l}`}_isValidHash(e){if(e.length<3||e.some(e=>isNaN(+e)))return!1;try{new Xb(+e[2],+e[1])}catch{return!1}let t=+e[0],n=+(e[3]||0),r=+(e[4]||0);return t>=this._map.getMinZoom()&&t<=this._map.getMaxZoom()&&n>=-180&&n<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}};function YF(e={}){return{projection:e.projection??`mercator`,projectionTransition:e.projectionTransition??1,worldCoordinateHelper:e.worldCoordinateHelper??l8,constrainOverride:e.constrainOverride??null}}function XF(e){return e.projection===`globe`?e.projectionTransition>0?`vertical-perspective`:`mercator`:e.projection}function ZF(e){return XF(e)===`vertical-perspective`}function QF(e,t,n,r){return t.constrainOverride===null?$F(e,t,n,r):t.constrainOverride(n,r)}function $F(e,t,n,r){return XF(t)===`mercator`?eI(e,t.worldCoordinateHelper,n,r):iI(e,n,r)}function eI(e,t,n,r){if(r=G(+r,e.minZoom,e.maxZoom),!t.wraps)return tI(e,t,n,r);let i={center:new Xb(n.lng,n.lat),zoom:r},a=e.lngRange;a&&(a[1]-a[0])%360==0&&(a=null),!e.renderWorldCopies&&a===null&&(a=[-179.9999999999,180-1e-10]);let o=e.tileSize*Zh(i.zoom),s=0,c=o,l=0,u=o,d=0,f=0,{top:p,bottom:m,left:h,right:g}=e.padding,_=e.width-h-g,v=e.height-p-m;if(e.latRange){let t=e.latRange;s=n8(t[1])*o,c=n8(t[0])*o,c-sc&&(S=c-e)}if(a){let t=(l+u)/2,n=y;e.renderWorldCopies&&(n=Gh(y,t-o/2,t+o/2));let r=_/2;n-ru&&(x=u-r)}return(x!==void 0||S!==void 0)&&(i.center=T8(o,new U(x??y,S??b),t).wrap()),i}function tI(e,t,n,r){let i=e.lngRange,a=e.tileSize*Zh(r);if(!i){let{x:e,y:i}=w8(a,n,t),o=G(e,0,a),s=G(i,0,a);return o!==e||s!==i?{center:T8(a,new U(o,s),t),zoom:r}:{center:new Xb(n.lng,n.lat),zoom:r}}let o=rI(t,i,e.latRange),s=Math.max(o.minX,0)*a,c=Math.min(o.maxX,1)*a,l=Math.max(o.minY,0)*a,u=Math.min(o.maxY,1)*a,{width:d,height:f}=e,p=c-s0,s=bx(r,n,o&&e.width&&e.height?{nearZ:a.nearZ,farZ:a.farZ}:e.nearFarZOverride),c=o?a:s;return{...r,projection:`globe`,globeness:i,mercator:s,verticalPerspective:a,nearZ:c.nearZ,farZ:c.farZ,projectionMatrix:c.projectionMatrix,modelViewProjectionMatrix:c.modelViewProjectionMatrix,inverseProjectionMatrix:c.inverseProjectionMatrix,cameraPosition:c.cameraPosition,clippingPlane:c.clippingPlane}}function fI(e,t){if(!e.width||!e.height)return e;let{center:n,zoom:r}=QF(e,t,e.center,e.zoom),i=e;(n.lat!==i.center.lat||n.lng!==i.center.lng)&&(i={...i,center:n});let a=QF(i,t,i.center,r).zoom;return i.zoom!==a&&(i={...i,zoom:a}),i}function pI(e,t,n,r){if(!e.width||!e.height)return{center:n,zoom:r};let i=QF(e,t,n,r);return{center:i.center,zoom:QF(e,t,i.center,i.zoom).zoom}}function mI(e,t,n){return e.minZoom===n?e:II(e,e=>{let r={...e,minZoom:n};return CI(r,t,QF(r,t,r.center,r.zoom).zoom)})}function hI(e,t,n){return e.maxZoom===n?e:II(e,e=>{let r={...e,maxZoom:n};return CI(r,t,QF(r,t,r.center,r.zoom).zoom)})}function gI(e,t){return e.minPitch===t?e:II(e,e=>{let n={...e,minPitch:t};return bI(n,Math.max(q8(n),t))})}function _I(e,t){return e.maxPitch===t?e:II(e,e=>{let n={...e,maxPitch:t};return bI(n,Math.min(q8(n),t))})}function vI(e,t,n){return n===void 0?n=!0:n===null&&(n=!1),n&&!t.wraps&&ig(`renderWorldCopies has no effect in a projection whose world does not wrap.`),e.renderWorldCopies===n?e:{...e,renderWorldCopies:n}}function yI(e,t){let n=Gh(t,-180,180)*Math.PI/180;return e.bearingInRadians===n?e:{...e,unmodified:!1,bearingInRadians:n}}function bI(e,t){let n=G(t,e.minPitch,e.maxPitch)/180*Math.PI;return e.pitchInRadians===n?e:{...e,unmodified:!1,pitchInRadians:n}}function xI(e,t){let n=t/180*Math.PI;return e.rollInRadians===n?e:{...e,unmodified:!1,rollInRadians:n}}function SI(e,t){return t=G(t,.1,150),X8(e)===t?e:{...e,unmodified:!1,fovInRadians:hg(t)}}function CI(e,t,n){let r=QF(e,t,e.center,n).zoom;return e.zoom===r?e:fI({...e,unmodified:!1,zoom:r},t)}function wI(e,t,n){return n.lat===e.center.lat&&n.lng===e.center.lng?e:fI({...e,unmodified:!1,center:n},t)}function TI(e,t,n){return{...e,unmodified:!1,center:t,zoom:n}}function EI(e,t,n){return n===e.elevation?e:fI({...e,elevation:n},t)}function DI(e,t,n){return U8(e.padding,n)?e:fI({...e,unmodified:!1,padding:H8(e.padding,n,1)},t)}function OI(e,t,n,r,i){return fI({...e,unmodified:!1,padding:H8(n,r,i)},t)}function kI(e,t,n,r,i=!0){let a=e.width===n&&e.height===r?e:{...e,width:n,height:r};return i?fI(a,t):a}function AI(e,t){return t===e.minElevationForCurrentTile?e:{...e,minElevationForCurrentTile:t}}function jI(e,t,n){if(!n)return{...e,lngRange:null,latRange:[-85.051129,xg]};let r=n.getWest(),i=n.getEast(),a=n.getSouth(),o=n.getNorth(),s=r===-1/0&&i===1/0;if((!Number.isFinite(r)||!Number.isFinite(i))&&!s)throw Error(`Longitude maxBounds values must either be finite or span from -Infinity to Infinity`);return fI({...e,lngRange:s?null:[r,i],latRange:[G(a,-85.051129,xg),G(o,-85.051129,xg)]},t)}function MI(e,t,n){if(e.elevation-n===0)return e;let r=t.worldCoordinateHelper,i=lI(e,r),{x:a,y:o,z:s}=A8(i.pitch,i.bearing),c=r.worldFromLngLat(i.center.lng,i.center.lat,i.elevation),l=1/r.worldZFromAltitude(1,i.center),u=i.cameraToCenterDistance/i.worldSize,d=new c8(c.x-a*u,c.y-o*u,c.z+s*u),{distanceToCenter:f,clampedElevation:p}=FI(d.z*l,n,i.pitch),{centerMercator:m,dMercator:h}=PI(r,d,a,o,f,l),g=r.lngLatFromWorld(m.x,m.y),_=Qh(i.cameraToCenterDistance/h/i.tileSize),v={...e,elevation:p,center:g},y=CI(v,t,_);return y.zoom===v.zoom?fI({...y,unmodified:!1},t):y}function NI(e,t,n,r,i,a){let o=i===void 0?K8(e):i,s=a===void 0?q8(e):a,{distanceToCenter:c,clampedElevation:l}=FI(r,e.elevation,s),{x:u,y:d}=A8(s,o),f=Xb.convert(n),p=t.worldFromLngLat(f.lng,f.lat,r),{centerMercator:m,dMercator:h}=PI(t,p,u,d,c,t.metersPerWorldUnit(p.x,p.y));return{center:t.lngLatFromWorld(m.x,m.y),elevation:l,zoom:Qh(e.height/2/Math.tan(e.fovInRadians/2)/h/e.tileSize)}}function PI(e,t,n,r,i,a){let o=i/a,s=new c8(t.x+n*o,t.y+r*o),c=1/0;for(let l=1;l<10;l++){let l=e.metersPerWorldUnit(s.x,s.y),u=Math.abs(l-a);if(u<=1e-12*a||u>=c)break;c=u,a=l,o=i/a,s=new c8(t.x+n*o,t.y+r*o)}return{centerMercator:s,dMercator:o}}function FI(e,t,n){let r=-Math.cos(hg(n)),i=e-t,a,o=t;return r*i>=0||Math.abs(r)180?-360:r<-180?360:0}function RI(){ig(`Map cannot fit within canvas with the given bounds, padding, and/or offset.`)}function zI(e,t,n,r,i){let a;if(!i)a={roll:E0.number(t.roll,n.roll,r),pitch:E0.number(t.pitch,n.pitch,r),bearing:E0.number(t.bearing,n.bearing,r)};else if(r<1){let e=new Float64Array(4);lh(e,bg(t.roll,t.pitch,t.bearing),bg(n.roll,n.pitch,n.bearing),r),a=vg(e)}else a=n;return yI(bI(xI(e,a.roll),a.pitch),a.bearing)}function BI(e,t){return nx(uI(e,t))}function VI(e,t,n){let r=BI(e,t),i=t.worldCoordinateHelper,a=n&&wx(r,i,n)||Q(r).screenPointToLocation(r,i,r.centerPoint,n),o=n?n.getElevationForLngLat(a,r.tileZoom):0;return r.pitch<90&&o>=Q(r).getCameraAltitude(r)?null:o}var HI=class{setLocationAtPoint(e,t,n,r,i){let a=this.getCameraForLocationAtPoint(e,t,n,r,i);return a?TI(e,a.center,a.zoom):e}getCameraForLocationAtPoint(e,t,n,r,i=e.elevation){let a=BI(e,t),o=Dx(a,r,i-a.elevation),s=Dx(a,a.centerPoint,0),c=t.worldCoordinateHelper,l=c.worldFromLngLat(n.lng,n.lat),u=c.lngLatFromWorld(l.x-(o.x-s.x),l.y-(o.y-s.y)),d=u.lng!==a.center.lng||u.lat!==a.center.lat?pI(e,t,u,a.zoom):null;if(a.renderWorldCopies&&c.wraps){let n=d??{center:a.center,zoom:a.zoom},r=n.center.wrap();r.lng!==n.center.lng&&(d=pI(e,t,r,n.zoom))}return d}recenterOnTerrain(e,t,n){let r=e;for(let e=0;e<3;e++){let e=VI(r,t,n);if(e===null||(r=MI(r,t,e),!n||Math.abs(n.getElevationForLngLat(r.center,uI(r,t).tileZoom)-r.elevation)<=1e-4))return r}return r}calculateCameraOptionsFromTo(e,t,n,r,i,a){let o=BI(e,t),s=t.worldCoordinateHelper,c=Xb.convert(n),l=Xb.convert(i),u=s.worldFromLngLat(c.lng,c.lat,r),d=s.worldFromLngLat(l.lng,l.lat,a),f=d.x-u.x,p=d.y-u.y,m=d.z-u.z,h=Math.hypot(f,p,m);if(h===0)throw Error(`Can't calculate camera options with same From and To`);let g=Math.hypot(f,p),_=Qh(o.cameraToCenterDistance/h/o.tileSize),v=gg(Math.atan2(f,-p)),y=gg(Math.acos(g/h));return y=m<0?90-y:90+y,{center:s.lngLatFromWorld(d.x,d.y),elevation:a,zoom:_,pitch:y,bearing:v}}},UI=1e-12;function WI(e,t){return nx(uI(e,t))}var GI=class{setLocationAtPoint(e,t,n,r){let i=this.getCameraForLocationAtPoint(e,t,n,r);return i?TI(e,i.center,i.zoom):e}getCameraForLocationAtPoint(e,t,n,r){let i=WI(e,t),a=Vx(a5(i,r)),o=Vx(n),s=Th();Ym(s);let c=Th();qm(c,a,s,-i.center.lng*Math.PI/180),Km(c,c,s,i.center.lat*Math.PI/180);let l=o[0]*o[0]+o[2]*o[2],u=c[0]*c[0];if(l=-y&&g<=y,x=v>=-y&&v<=y,S,C;if(b&&x){let e=i.center.lng*Math.PI/180,t=i.center.lat*Math.PI/180,n=Ih(p,e),r=Ih(g,t),a=Ih(m,e),o=Ih(v,t);n+r0?90:-90}function XI(e,t,n,r,i){let a=e.center.lng,o=e.center.lat,s=o>=0?90:-90,c=Q(e).locationToScreenPoint(e,t,new Xb(0,s)),l=n.x-c.x,u=n.y-c.y,d=l*l+u*u,f=G(1-(xg-Math.abs(o))/12,0,1),p=f*f*(3-2*f),m=Lh(i-a+180,360)-180,h=0;if(p>0&&r){let e=(l*r.y-u*r.x)/Math.max(d,400);h=(s>0?1:-1)*e*180/Math.PI}return a+(1-p)*m+p*h}var ZI=new HI,QI=new GI;function $I(e){switch(XF(e)){case`mercator`:return ZI;case`vertical-perspective`:return QI}}function eL(e,t,n,r,i){return e=CI(e,t,n),e=xI(e,r.roll),e=bI(e,r.pitch),e=yI(e,r.bearing),DI(e,t,i)}var tL=class{panInertia(e,t){let n=t.mag(),r=Math.abs(E8(e));return{easingOffset:t.mult(Math.min(r*.75/n,1)),easingCenter:e.center}}rollPitchBearingZoom(e,t,n){let{bearing:r,pitch:i,roll:a}=lI(e,t.worldCoordinateHelper);return n.bearingDelta&&(e=yI(e,r+n.bearingDelta)),n.pitchDelta&&(e=bI(e,i+n.pitchDelta)),n.rollDelta&&(e=xI(e,a+n.rollDelta)),n.zoomDelta&&(e=CI(e,t,e.zoom+n.zoomDelta)),e}pan(e,t,n,r){return n.around.distSqr(W8(e))<.01?e:$I(t).setLocationAtPoint(e,t,r,n.around,n.aroundElevation)}cameraForBoxAndBearing(e,t,n,r,i,a,o){let s=o.worldCoordinateHelper,c=lI(a,s),l=w8(c.worldSize,r.getNorthWest(),s),u=w8(c.worldSize,r.getNorthEast(),s),d=w8(c.worldSize,r.getSouthEast(),s),f=w8(c.worldSize,r.getSouthWest(),s),[p,m]=s.wraps?[G(r.getSouth(),-85.051129,xg),G(r.getNorth(),-85.051129,xg)]:[r.getSouth(),r.getNorth()],{points:h,bulge:g}=j8(s,r.getWest(),p,r.getEast(),m),_=hg(-i),v=1/0,y=1/0,b=-1/0,x=-1/0;for(let e of h){let{x:t,y:n}=e.mult(c.worldSize).rotate(_);tb&&(b=t),n>x&&(x=n)}let S=g*c.worldSize,C=new U(b+S,x+S),w=new U(v-S,y-S),T=C.sub(w),E=c.width-(n.left+n.right+t.left+t.right),D=c.height-(n.top+n.bottom+t.top+t.bottom),O=E/T.x,k=D/T.y;if(k<0||O<0||!Number.isFinite(T.x)||!Number.isFinite(T.y)){RI();return}let A=Math.min(Qh(c.scale*Math.min(O,k)),e.maxZoom),j=U.convert(e.offset),M=new U((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(hg(i)),N=j.add(M).mult(c.scale/Zh(A)),P=g===0&&l.add(d).equals(u.add(f))?l.add(d).div(2):C.add(w).div(2).rotate(-_);return{center:T8(c.worldSize,P.sub(N),s),zoom:A,bearing:i}}jumpToCenterZoom(e,t,n){return n.zoom!==void 0&&e.zoom!==+n.zoom&&(e=CI(e,t,+n.zoom)),n.center!==void 0&&(e=wI(e,t,Xb.convert(n.center))),e}easeTo(e,t,n){let r=lI(e,t.worldCoordinateHelper),i=e.zoom,a=e.padding,o={roll:r.roll,pitch:r.pitch,bearing:r.bearing},s={roll:n.roll??r.roll,pitch:n.pitch??r.pitch,bearing:n.bearing??r.bearing},c=!_g(o,s),l=!U8(e.padding,n.padding),u=n.zoom===void 0?i:+n.zoom,d=uI(e,t),f=Q(d).screenPointToLocation(d,t.worldCoordinateHelper,r.centerPoint.add(n.offsetAsPoint)),{center:p,zoom:m}=QF(e,t,Xb.convert(n.center||f),u);LI(e,t.worldCoordinateHelper,p);let h=t.worldCoordinateHelper,g=w8(r.worldSize,f,h),_=w8(r.worldSize,p,h).sub(g),v=Zh(m-i),y=m!==i,b=(e,t,r)=>{if(y&&(e=CI(e,t,E0.number(i,m,r))),c&&(e=zI(e,o,s,r,o.roll!==s.roll)),l&&(e=OI(e,t,a,n.padding,r)),n.around)return nL(e,t,n.around,n.aroundPoint);let u=Zh(e.zoom-i),d=(m>i?Math.min(2,v):Math.max(.5,v))**(1-r),f=T8(lI(e,h).worldSize,g.add(_.mult(r*d)).mult(u),h);e.renderWorldCopies&&h.wraps&&(f=f.wrap());let p=W8(e).add(n.offsetAsPoint);return nL(e,t,f,p)},x=eL(e,t,m,s,n.padding);return{easeFunc:b,isZooming:y,elevationCenter:(n.around?$I(t).setLocationAtPoint(x,t,n.around,n.aroundPoint):$I(t).setLocationAtPoint(x,t,p,W8(x).add(n.offsetAsPoint))).center}}flyTo(e,t,n){let r=lI(e,t.worldCoordinateHelper),i=e.zoom,a=QF(e,t,Xb.convert(n.center||n.locationAtOffset),n.zoom===void 0?i:+n.zoom),o=a.center,s=a.zoom;LI(e,t.worldCoordinateHelper,o);let c=t.worldCoordinateHelper,l=r.worldSize,u=w8(l,n.locationAtOffset,c),d=w8(l,o,c).sub(u),f=d.mag(),p=Zh(s-i),m=n.minZoom===void 0?e.minZoom:+n.minZoom,h=Math.max(m,e.minZoom),g=Zh(QF(e,t,o,Math.min(h,i,s)).zoom-i),_=(e,t,n,r,a,f)=>{e=CI(e,t,n===1?s:i+Qh(r));let p=n===1?o:T8(l,u.add(d.mult(a)),c);return e.renderWorldCopies&&c.wraps&&(p=p.wrap()),nL(e,t,p,f)},v=eL(e,t,s,{roll:n.roll,pitch:n.pitch,bearing:n.bearing},n.padding);return{easeFunc:_,scaleOfZoom:p,targetCenter:$I(t).setLocationAtPoint(v,t,o,W8(v).add(n.offsetAsPoint)).center,scaleOfMinZoom:g,pixelPathLength:f}}};function nL(e,t,n,r){let i=$I(t).setLocationAtPoint(e,t,n,r);return i.zoom===e.zoom?i:CI(i,t,e.zoom)}function rL(e,t,n,r,i){let a=i,o=r===`x`?[n[0],n[4],n[8],n[12]]:[n[1],n[5],n[9],n[13]],s=[n[3],n[7],n[11],n[15]],c=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],u=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],d=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],f=(u+o[3]-a*d-a*s[3])/(u-c-a*d+a*l);return u+a*l===c+a*d||s[3]*(c-u)+o[3]*(d-l)+c*d===u*l?null:f}function iL(e,t){return t!==null&&t>=0&&t180&&(n.lng=e.center.lng+179.5*Math.sign(n.lng-e.center.lng)),{easingCenter:n,easingOffset:new U(0,0)}}rollPitchBearingZoom(e,t,n){let r=n.around,i=uI(e,t),a=Q(i).screenPointToLocation(i,t.worldCoordinateHelper,r);n.bearingDelta&&(e=yI(e,i.bearing+n.bearingDelta)),n.pitchDelta&&(e=bI(e,i.pitch+n.pitchDelta)),n.rollDelta&&(e=xI(e,i.roll+n.rollDelta));let o=e.zoom;n.zoomDelta&&(e=CI(e,t,e.zoom+n.zoomDelta));let s=e.zoom-o;if(s===0)return e;let c=Fh(e.center.lng,a.lng),l=c/(Math.abs(c/180)+1),u=Fh(e.center.lat,a.lat),d=uI(e,t),f=Q(d).getRayDirectionFromPixel(d,r),p=d.cameraPosition,m=Bm(p,f)*-1,h=Th();Nm(h,p,[f[0]*m,f[1]*m,f[2]*m]);let g=jm(h),_=g-1,v=Math.exp(-Math.max(_-.3,0)*.5),y=Rh(g,.95,.999,0,1),b=Rh(Hx(d.worldSize,e.center.lat)/Math.min(e.width,e.height),.9,.5,1,.25),x=Math.min(v,zh(1,b,y)),S=(1-Zh(-s))*x,C=e.center.lat,w=e.zoom,T=new Xb(e.center.lng+l*S,G(e.center.lat+u*S,-90,90)),E=$I(t).setLocationAtPoint(e,t,a,r),D=E.center,O=Rh(Math.abs(c),45,85,0,1),k=Math.max(O,y)**.25,A=Fh(D.lng,T.lng),j=Fh(D.lat,T.lat),M=wI(E,t,new Xb(D.lng+A*k,G(D.lat+j*k,-90,90)).wrap());return CI(M,t,w+Kx(C,M.center.lat))}pan(e,t,n,r){if(!n.panDelta)return e;let i=uI(e,t);return JI(e,t,r,Q(i).isPointOnMapSurface(i,t.worldCoordinateHelper,n.around)?n.around:W8(e),n.panDelta)}cameraForBoxAndBearing(e,t,n,r,i,a,o){let s=this._mercator.cameraForBoxAndBearing(e,t,n,r,i,a,o);if(!s)return;let{width:c,height:l}=a,u=t.left/c*2-1,d=(c-t.right)/c*2-1,f=t.top/l*-2+1,p=(l-t.bottom)/l*-2+1,m=Fh(r.getWest(),r.getEast())<0,h=m?r.getEast():r.getWest(),g=m?r.getWest():r.getEast(),_=Math.max(r.getNorth(),r.getSouth()),v=Math.min(r.getNorth(),r.getSouth()),y=h+Fh(h,g)*.5,b=_+Fh(_,v)*.5,x=wI(a,o,s.center);x=DI(x,o,n),x=yI(x,s.bearing),x=bI(x,0),x=xI(x,0),x=CI(x,o,s.zoom);let S=uI(x,o).modelViewProjectionMatrix,C=[Vx(r.getNorthWest()),Vx(r.getNorthEast()),Vx(r.getSouthWest()),Vx(r.getSouthEast()),Vx(new Xb(g,b)),Vx(new Xb(h,b)),Vx(new Xb(y,_)),Vx(new Xb(y,v))],w=Vx(s.center),T=1/0;for(let e of C)u<0&&(T=iL(T,rL(e,w,S,`x`,u))),d>0&&(T=iL(T,rL(e,w,S,`x`,d))),f>0&&(T=iL(T,rL(e,w,S,`y`,f))),p<0&&(T=iL(T,rL(e,w,S,`y`,p)));if(!Number.isFinite(T)||T===0)RI();else return s.zoom=Math.min(x.zoom+Qh(T),e.maxZoom),s}jumpToCenterZoom(e,t,n){let r=e.center.lat,i=n.center?Xb.convert(n.center):e.center;e=wI(e,t,QF(e,t,i,e.zoom).center.wrap());let a=n.zoom===void 0?e.zoom+Kx(r,e.center.lat):+n.zoom;return e.zoom===a?e:(e=CI(e,t,a),wI(e,t,QF(e,t,i,e.zoom).center.wrap()))}easeTo(e,t,n){let r=lI(e,t.worldCoordinateHelper),i=e.zoom,a=e.center,o=e.padding,s={roll:r.roll,pitch:r.pitch,bearing:r.bearing},c={roll:n.roll??r.roll,pitch:n.pitch??r.pitch,bearing:n.bearing??r.bearing},l=!_g(s,c),u=n.zoom!==void 0,d=!U8(e.padding,n.padding),f=n.center?Xb.convert(n.center):a,p=QF(e,t,f,u?+n.zoom:i).center;LI(e,t.worldCoordinateHelper,p);let m=wI(e,t,p);m=CI(m,t,u?+n.zoom:i+Kx(a.lat,f.lat)),m=yI(m,n.bearing);let h=new U(G(r.centerPoint.x+n.offsetAsPoint.x,0,e.width),G(r.centerPoint.y+n.offsetAsPoint.y,0,e.height));m=$I(t).setLocationAtPoint(m,t,p,h);let g=(n.offset&&n.offsetAsPoint.mag())>0?m.center:p,_=u?+n.zoom:i+Kx(a.lat,g.lat),v=i+Kx(a.lat,0),y=_+Kx(g.lat,0),b=Fh(a.lng,g.lng),x=Fh(a.lat,g.lat),S=Zh(y-v),C=_!==i;return{easeFunc:(e,t,r)=>{if(l&&(e=zI(e,s,c,r,s.roll!==c.roll)),d&&(e=OI(e,t,o,n.padding,r)),n.around)ig(`Easing around a point is not supported under globe projection.`),e=$I(t).setLocationAtPoint(e,t,n.around,n.aroundPoint);else{let n=r*(y>v?Math.min(2,S):Math.max(.5,S))**(1-r),i=Jx(a,b,x,n);e=wI(e,t,i.wrap())}if(C){let n=E0.number(v,y,r);e=CI(e,t,n+Kx(0,e.center.lat))}return r===1&&!n.around&&(e=wI(e,t,g.wrap())),e},isZooming:C,elevationCenter:g}}flyTo(e,t,n){let r=lI(e,t.worldCoordinateHelper),i=n.zoom!==void 0,a=e.center,o=e.zoom,s=e.padding,c=!U8(e.padding,n.padding),l=QF(e,t,Xb.convert(n.center||n.locationAtOffset),i?+n.zoom:o).center,u=i?+n.zoom:o+Kx(a.lat,l.lat),d=wI(e,t,l);d=CI(d,t,u),d=yI(d,n.bearing);let f=new U(G(r.centerPoint.x+n.offsetAsPoint.x,0,e.width),G(r.centerPoint.y+n.offsetAsPoint.y,0,e.height)),p=$I(t).setLocationAtPoint(d,t,l,f).center;LI(e,t.worldCoordinateHelper,p);let m=Lx(r,a,p),h=o+Kx(a.lat,0),g=u+Kx(p.lat,0),_=Zh(g-h),v=typeof n.minZoom==`number`?+n.minZoom:e.minZoom,y=Math.max(v,e.minZoom)+Kx(p.lat,0),b=Zh(QF(e,t,p,Math.min(y,h,g)+Kx(0,p.lat)).zoom+Kx(p.lat,0)-h),x=Fh(a.lng,p.lng),S=Fh(a.lat,p.lat);return{easeFunc:(e,t,r,i,o,l)=>{let d=Jx(a,x,S,o);c&&(e=OI(e,t,s,n.padding,r));let f=r===1?p:d;e=wI(e,t,f.wrap());let m=h+Qh(i);return e=CI(e,t,r===1?u:m+Kx(0,f.lat)),r===1&&(e=wI(e,t,p.wrap())),e},scaleOfZoom:_,targetCenter:p,scaleOfMinZoom:b,pixelPathLength:m}}},oL=new tL,sL=new aL(oL);function cL(e){return ZF(e)?sL:oL}var lL={linearity:.3,easing:Uh(0,0,.3,1)},uL={deceleration:2500,maxSpeed:1400,...lL},dL={deceleration:20,maxSpeed:1400,...lL},fL={deceleration:1e3,maxSpeed:90,...lL},pL={deceleration:1e3,maxSpeed:360,...lL},mL={halfLife:140,minSpeed:60,maxSpeed:1200,stopSpeed:1},hL=class{constructor(e){this._camera=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Ig(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=Ig();for(;e.length>0&&t-e[0].time>160;)e.shift()}_getVelocityEntries(){let e=this._inertiaBuffer,t=Ig()-60,n=Math.max(0,e.length-2);for(;n>0&&e[n-1].time>=t;)n--;return e.slice(n)}_onMoveEnd(e){this._drainInertiaBuffer();let t=this._getVelocityEntries();if(t.length<2){this.clear();return}let n={zoom:0,bearing:0,pitch:0,roll:0,pan:new U(0,0),pinchAround:void 0,around:void 0};for(let{settings:e}of t)e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);for(let{settings:e}of t.slice(1))n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,n.roll+=e.rollDelta||0,e.panDelta&&n.pan._add(e.panDelta);if(!n.pan.mag()&&!n.zoom&&!n.bearing&&!n.pitch&&!n.roll){this.clear();return}let r=Ig()-t[0].time,i={};if(n.pan.mag()){let t=_L(n.pan.mag(),r,{...uL,...typeof e==`object`?e:{}}),a=n.pan.mult(t.amount/n.pan.mag()),o=cL(this._camera.context).panInertia(this._camera.projectedCamera,a);i.center=o.easingCenter,i.offset=o.easingOffset,gL(i,t)}if(n.zoom){let e=_L(n.zoom,r,dL);i.zoom=$h(this._camera.getZoom()+e.amount,this._camera.getZoomSnap(),e.amount),gL(i,e)}let a=n.bearing?vL(n.bearing,r,mL):void 0;if(a&&(i.bearing=this._camera.getBearing()+G(a.amount,-179,179),gL(i,a)),n.pitch){let e=_L(n.pitch,r,fL);i.pitch=this._camera.getPitch()+e.amount,gL(i,e)}if(n.roll){let e=_L(n.roll,r,pL);i.roll=this._camera.getRoll()+G(e.amount,-179,179),gL(i,e)}if(i.duration===void 0)this.clear();else{if(i.zoom||i.bearing){let e=n.pinchAround===void 0?n.around:n.pinchAround;i.around=e?this._camera.unproject(e):this._camera.getCenter()}return this.clear(),{...i,noMoveStart:!0}}}};function gL(e,t){(!e.duration||e.duration1-2**(-e*s/n),l=c(1);return{easing:e=>c(G(e,0,1))/l,duration:s,amount:n/1e3*o/Math.LN2*l}}var yL=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate,bL=class extends s_{};function xL(e){return e.panDelta?.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}var SL=class extends l_{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(e){super(),this._terrainGesture={inFlight:!1,anchorElevation:null,anchorCenterElevation:null},this._rotationPivot=null,this._timeouts=new Set,this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,t)=>{if(e.type===`blur`){this.stop(!0);return}this._updatingCamera=!0;let n=e.type===`renderFrame`?void 0:e,r={needsRenderFrame:!1},i={},a={};for(let{handlerName:o,handler:s,allowed:c}of this._handlers){if(!s.isEnabled())continue;let l;if(this._blockedByActive(a,c,o))s.reset();else if(s[t||e.type]){if(Tg(e,t||e.type)){let n=Gg.mousePos(this._canvas,e);l=s[t||e.type](e,n)}else if(wg(e,t||e.type)){let n=e.touches,r=this._getMapTouches(n),i=Gg.touchPos(this._canvas,r);l=s[t||e.type](e,i,r)}else Eg(t||e.type)||(l=s[t||e.type](e));r=this.mergeHandlerResult(r,i,l,o,n),l?.needsRenderFrame&&this._triggerRenderFrame(),l?.timeout&&this._startTimeout(s,l.timeout)}(l||s.isActive())&&(a[o]=s)}let o={};for(let e in this._previousActiveHandlers)a[e]||(o[e]=n);this._previousActiveHandlers=a,(Object.keys(o).length||xL(r))&&(this._changes.push([r,i,o]),this._triggerRenderFrame()),(Object.keys(a).length||xL(r))&&this._camera.stop(),this._updatingCamera=!1;let{easeTo:s}=r;s&&(this.stop(!0),this._camera.easeTo(s,{originalEvent:n}))},this._camera=e.camera,this._dragPan=e.dragPan,this._el=e.canvasContainer,this._canvas=e.canvas,this._renderLoop=e.renderLoop,this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new hL(this._camera),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={};for(let{handlerName:t,handler:n,allowed:r}of e.registrations)n instanceof l_&&n.setEventedParent(this),this._add(t,n,r);let t=this._el;this._domListeners=[[t,`touchstart`,{passive:!0}],[t,`touchmove`,{passive:!1}],[t,`touchend`,void 0],[t,`touchcancel`,void 0],[t,`mousedown`,void 0],[t,`mousemove`,void 0],[t,`mouseup`,void 0],[this._ownerDocument,`mousemove`,{capture:!0}],[this._ownerDocument,`mouseup`,void 0],[t,`mouseover`,void 0],[t,`mouseout`,void 0],[t,`dblclick`,void 0],[t,`click`,void 0],[t,`keydown`,{capture:!1}],[t,`keyup`,void 0],[t,`wheel`,{passive:!1}],[t,`contextmenu`,void 0],[this._ownerWindow,`blur`,void 0]];for(let[e,t,n]of this._domListeners)e.addEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,n)}destroy(){this._frameId!==void 0&&this._renderLoop.cancelRenderFrame(this._frameId);for(let e of this._timeouts)clearTimeout(e);for(let[e,t,n]of this._domListeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,n)}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._handlers.some(({handler:e})=>e.isZooming?.())}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!yL(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,n){for(let r in e)if(r!==n&&!t?.includes(r))return!0;return!1}_getMapTouches(e){let t=[];for(let n of e){let e=n.target;this._el.contains(e)&&t.push(n)}return t}mergeHandlerResult(e,t,n,r,i){if(!n)return e;let a={handlerName:r,originalEvent:n.originalEvent||i};return n.zoomDelta!==void 0&&(t.zoom=a),n.panDelta!==void 0&&(t.drag=a),n.rollDelta!==void 0&&(t.roll=a),n.pitchDelta!==void 0&&(t.pitch=a),n.bearingDelta!==void 0&&(t.rotate=a),{...e,...n}}_applyChanges(){let e={},t={},n={};for(let[r,i,a]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new U(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),r.around!==void 0&&(e.around=r.around),r.pinchAround!==void 0&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),t={...t,...i},n={...n,...a};this._updateMapCamera(e,t,n),this._changes=[]}_updateMapCamera(e,t,n){let r=this._camera.terrain;if(!xL(e)){this._fireEvents(t,n,!0);return}this._camera.stop();let i=this._camera.getStateForUpdate();if(this._turnsAroundPivot(e,t)){this._commitFrame(this._orbitRotationPivot(i,e,r),e,t,n);return}let{panDelta:a,zoomDelta:o,bearingDelta:s,pitchDelta:c,rollDelta:l}=e;o>0&&this._terrainGesture.inFlight&&(i=this._camera.moveCenterOntoTerrain(i,o));let u=this._camera._projectState(i),{around:d,aroundOnSurface:f}=this._resolveAround(e,r,u),p=r?this._terrainGestureElevation(r,d,f,u,t):void 0,m={panDelta:a,zoomDelta:o,rollDelta:l,pitchDelta:c,bearingDelta:s,around:d,aroundElevation:p};ZF(this._camera.context)&&!Q(u).isPointOnMapSurface(u,this._camera.context.worldCoordinateHelper,d)&&(d=u.centerPoint);let h=this._computePreZoomAroundLoc(u,d,a,p);i=this._handleMapControls({terrain:r,state:i,deltas:m,preZoomAroundLoc:h,combinedEventsInProgress:t,panDelta:a}),this._commitFrame(i,e,t,n)}_commitFrame(e,t,n,r){this._camera.applyUpdatedState(e),t.noInertia||this._inertia.record(t),this._fireEvents(n,r,!0)}_turnsAroundPivot(e,t){return e.around?!t.drag&&!t.zoom:!1}_orbitRotationPivot(e,t,n){n&&!this._terrainGesture.inFlight&&(this._terrainGesture.inFlight=!0,this._camera.holdElevation(`gesture`));let{panDelta:r,zoomDelta:i,bearingDelta:a,pitchDelta:o,rollDelta:s,around:c}=t;this._rotationPivot??=this._camera.captureRotationPivot(this._camera._projectState(e),c);let l=this._camera.orbitRotationPivot(e,this._rotationPivot,{panDelta:r,zoomDelta:i,bearingDelta:a,pitchDelta:o,rollDelta:s,around:c});return l.held||(this._rotationPivot=null),l.state}_resolveAround(e,t,n){let r=e.pinchAround===void 0?e.around:e.pinchAround;return r||=this._camera.projectedCamera.centerPoint,t&&!Q(n).isPointOnMapSurface(n,this._camera.context.worldCoordinateHelper,r)?{around:n.centerPoint,aroundOnSurface:!1}:{around:r,aroundOnSurface:!0}}_terrainGestureElevation(e,t,n,r,i){if(!n)return;if(this._terrainGesture.anchorCenterElevation!==r.elevation&&(i.drag||i.zoom)){let n=Q(r).screenTerrainPointToMercatorCoordinate(r,this._camera.context.worldCoordinateHelper,t,e);this._terrainGesture.anchorElevation=n?n.z:void 0,this._terrainGesture.anchorCenterElevation=r.elevation}let a=this._terrainGesture.anchorElevation;if(a!=null&&!(t.distSqr(r.centerPoint)<.01)&&!(a-r.elevation>=.9*(Q(r).getCameraAltitude(r)-r.elevation)))return a}_computePreZoomAroundLoc(e,t,n,r){if(t.distSqr(e.centerPoint)<.01)return e.center;let i=n?t.sub(n):t;return r===void 0?Q(e).screenPointToLocation(e,this._camera.context.worldCoordinateHelper,i):Q(e).screenPointToLocationAtElevation(e,this._camera.context.worldCoordinateHelper,i,r)}_handleMapControls({terrain:e,state:t,deltas:n,preZoomAroundLoc:r,combinedEventsInProgress:i,panDelta:a}){let o=this._camera.context;t=cL(o).rollPitchBearingZoom(t,o,n);let s=this._camera._projectState(t);return!e&&!ZF(o)&&!Q(s).isPointOnMapSurface(s,this._camera.context.worldCoordinateHelper,n.around)?a?this._panByPixels(t,s,a):t:e?this._terrainGesture.inFlight?!ZF(o)&&n.aroundElevation===void 0&&i.drag&&a?this._panByPixels(t,s,a):cL(o).pan(t,o,n,r):(this._terrainGesture.inFlight=!0,this._camera.holdElevation(`gesture`),cL(o).pan(t,o,n,r)):cL(o).pan(t,o,n,r)}_panByPixels(e,t,n){return wI(e,this._camera.context,Q(t).screenPointToLocation(t,this._camera.context.worldCoordinateHelper,t.centerPoint.sub(n)))}_fireEvents(e,t,n){let r=yL(this._eventsInProgress),i=yL(e),a={};for(let t in e){let{originalEvent:n}=e[t];this._eventsInProgress[t]||(a[`${t}start`]=n),this._eventsInProgress[t]=e[t]}!r&&i&&this._fireEvent(`movestart`,i.originalEvent);for(let e in a)this._fireEvent(e,a[e]);i&&this._fireEvent(`move`,i.originalEvent);for(let t in e){let{originalEvent:n}=e[t];this._fireEvent(t,n)}let o={},s;for(let e in this._eventsInProgress){let{handlerName:n,originalEvent:r}=this._eventsInProgress[e];this._handlersById[n].isActive()||(delete this._eventsInProgress[e],s=t[n]||r,o[`${e}end`]=s)}for(let e in o)this._fireEvent(e,o[e]);let c=yL(this._eventsInProgress),l=(r||i)&&!c;if(l&&this._terrainGesture.inFlight&&(this._terrainGesture={inFlight:!1,anchorElevation:null,anchorCenterElevation:null},this._camera.releaseElevation()),n&&l){this._updatingCamera=!0;let e=this._inertia._onMoveEnd(this._dragPan._inertiaOptions),t=e=>e!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new bL(`renderFrame`,{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}_startTimeout(e,{delay:t,token:n}){let r=setTimeout(()=>{this._timeouts.delete(r);let t=e.onTimeout?.(n);t&&t.needsRenderFrame&&this._triggerRenderFrame()},t);this._timeouts.add(r)}},CL=class{constructor(e){this._map=e}createMouseEvent(e,t,n){return new Uee(e,this._map,t,n)}createTouchEvent(e,t){return new Wee(e,this._map,t)}createWheelEvent(e){return new Gee(this._map,e)}},wL=class extends l_{constructor(e,t){super(),this._eventFactory=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(this._eventFactory.createWheelEvent(e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(this._eventFactory.createMouseEvent(e.type,e))}mouseup(e){this.fire(this._eventFactory.createMouseEvent(e.type,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this.fire(this._eventFactory.createMouseEvent(e.type,e))}dblclick(e){return this._firePreventable(this._eventFactory.createMouseEvent(e.type,e))}mouseover(e){this.fire(this._eventFactory.createMouseEvent(e.type,e))}mouseout(e){this.fire(this._eventFactory.createMouseEvent(e.type,e))}touchstart(e){return this._firePreventable(this._eventFactory.createTouchEvent(e.type,e))}touchmove(e){this.fire(this._eventFactory.createTouchEvent(e.type,e))}touchend(e){this.fire(this._eventFactory.createTouchEvent(e.type,e))}touchcancel(e){this.fire(this._eventFactory.createTouchEvent(e.type,e))}_firePreventable(e){if(this.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},TL=class extends l_{constructor(e,t){super(),this._eventFactory=e,this._clickTolerance=t.clickTolerance}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent,this._clearLongPress(),this._touchActive=!1}mousemove(e){this.fire(this._eventFactory.createMouseEvent(e.type,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this.fire(this._eventFactory.createMouseEvent(`contextmenu`,this._contextMenuEvent)),delete this._contextMenuEvent)}touchstart(e,t,n){if(this._clearLongPress(),this._touchActive=n.length>0,n.length!==1)return;this._longPressStart=t[0];let r=n[0];this._longPressTimer=setTimeout(()=>{this._longPressTimer=void 0;let e=new MouseEvent(`contextmenu`,{clientX:r.clientX,clientY:r.clientY,button:2,bubbles:!0,cancelable:!0});this.fire(this._eventFactory.createMouseEvent(`contextmenu`,e))},500)}touchmove(e,t,n){this._longPressTimer&&(n.length!==1||!this._longPressStart||t[0].dist(this._longPressStart)>this._clickTolerance)&&this._clearLongPress()}touchend(){this._touchActive=!1,this._clearLongPress()}touchcancel(){this._touchActive=!1,this._clearLongPress()}_clearLongPress(){this._longPressTimer&&=(clearTimeout(this._longPressTimer),void 0),this._longPressStart=void 0}contextmenu(e){this._touchActive?e.preventDefault():(this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this.fire(this._eventFactory.createMouseEvent(e.type,e)),this.listens(`contextmenu`)&&e.preventDefault())}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},EL=class extends l_{constructor(e,t,n,r,i){super(),this._camera=r,this._el=e,this._container=t,this._clickTolerance=n.clickTolerance||1,this._boxZoomEnd=i}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&e.button===0&&(Gg.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let n=t;if(this._lastPos.equals(n)||!this._box&&n.dist(this._startPos)this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),n.length===this.numTouches&&(this.centroid=kL(t),this.touches=DL(n,t)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;let r=DL(n,t);for(let e in this.touches){let t=this.touches[e],n=r[e];(!n||n.dist(t)>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),n.length===0){let e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}},jL=class{constructor(e){this.singleTap=new AL(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){let r=this.singleTap.touchend(e,t,n);if(r){let t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}},ML=class{constructor(e){this._camera=e,this._zoomIn=new jL({numTouches:1,numTaps:2}),this._zoomOut=new jL({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,t,n){let r=this._zoomIn.touchend(e,t,n),i=this._zoomOut.touchend(e,t,n),{zoom:a}=this._camera.proposedProjectedCamera,o=this._camera.getZoomSnap();if(r)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{easeTo:{duration:300,zoom:$h(a+1,o),around:OL(this._camera,r)}};if(i)return this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{easeTo:{duration:300,zoom:$h(a-1,o),around:OL(this._camera,i)}}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},NL=class{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=e.activateOnStart??(()=>!1),e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._startPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._startPoint=Array.isArray(t)?t[0]:t,this._lastPoint=this._startPoint,this._activateOnStart(e)&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let n=this._lastPoint;if(!n)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e)){this.reset(e);return}let r=Array.isArray(t)?t[0]:t;if(!(!this._moved&&r.dist(n)!0}),t=new LL){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,n){if(e instanceof MouseEvent)return t(e);if(typeof TouchEvent<`u`&&e instanceof TouchEvent)return n(e)}startMove(e){this._executeRelevantHandler(e,e=>{this.mouseMoveStateManager.startMove(e)},e=>{this.oneFingerTouchMoveStateManager.startMove(e)})}endMove(e){this._executeRelevantHandler(e,e=>{this.mouseMoveStateManager.endMove(e)},e=>{this.oneFingerTouchMoveStateManager.endMove(e)})}isValidStartEvent(e){return!!this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return!!this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return!!this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}};function zL(e,t,n){return t===`center`||!(e.bearingDelta||e.pitchDelta||e.rollDelta)?e:{...e,around:n}}var BL=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};function VL({enable:e,clickTolerance:t}){return new NL({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:e=>!e.ctrlKey,moveStateManager:new IL({checkCorrectEvent:e=>e.button===0}),enable:e,assignEvents:BL})}function HL({enable:e,clickTolerance:t,minPixelCenterThreshold:n=100,rotateSpeed:r=.8},i,a,o){return new NL({clickTolerance:t,move:(e,t,s)=>{if(a?.()===`pointer`)return zL({bearingDelta:(t.x-e.x)*r},`pointer`,s);let c=i(),l=(o?.()??`circular`)===`circular`;if(l&&Math.abs(c.y-e.y)>n)return{bearingDelta:yg(new U(e.x,t.y),t,c)};let u=(t.x-e.x)*r;return l&&t.ye.button===0&&e.ctrlKey||e.button===2&&!e.ctrlKey}),enable:e,assignEvents:BL})}function UL({enable:e,clickTolerance:t,pitchSpeed:n=-.5},r){return new NL({clickTolerance:t,move:(e,t,i)=>zL({pitchDelta:(t.y-e.y)*n},r?.()??`center`,i),moveStateManager:new IL({checkCorrectEvent:e=>e.button===0&&e.ctrlKey||e.button===2}),enable:e,assignEvents:BL})}function WL({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:n=.3},r,i){return new NL({clickTolerance:t,move:(e,t,a)=>{let o=r(),s=(t.x-e.x)*n;return t.ye.button===2&&e.ctrlKey}),enable:e,assignEvents:BL})}var GL=class{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._cooperativeGestures=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new U(0,0)}_shouldBePrevented(e){return e<(this._cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,n){return this._calculateTransform(t,n)}touchmove(e,t,n){if(!this._active)return;if(this._shouldBePrevented(n.length)){this._cooperativeGestures.notifyGestureBlocked(`touch_pan`,e);return}let r=this._calculateTransform(t,n);return r&&e.preventDefault(),r}touchend(e,t,n){this._calculateTransform(t,n),this._active&&this._shouldBePrevented(n.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t){t.length>0&&(this._active=!0);let n=DL(t,e),r=new U(0,0),i=new U(0,0),a=0;for(let e in n){let t=n[e],o=this._touches[e];o&&(r._add(t),i._add(t.sub(o)),a++,n[e]=t)}if(this._touches=n,this._shouldBePrevented(a)||!i.mag())return;let o=i.div(a);if(this._sum._add(o),!(this._sum.mag()Math.abs(e.x)}var eR=class extends KL{constructor(e){super(),this._currentTouchCount=0,this._cooperativeGestures=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,n){super.touchstart(e,t,n),this._currentTouchCount=n.length}_start(e){this._lastPoints=e,$L(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,n){if(this._cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=e[0].sub(this._lastPoints[0]),i=e[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(r,i,n.timeStamp),this._valid)return this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+i.y)/2*-.5}}gestureBeginsVertically(e,t,n){if(this._valid!==void 0)return this._valid;let r=e.mag()>=2,i=t.mag()>=2;if(!r&&!i)return;if(!r||!i)return this._firstMove===void 0&&(this._firstMove=n),n-this._firstMove<100&&void 0;let a=e.y>0==t.y>0;return $L(e)&&$L(t)&&a}},tR={panStep:100,bearingStep:15,pitchStep:10},nR=class{constructor(e){this._camera=e;let t=tR;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,n=0,r=0,i=0,a=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?n=-1:(e.preventDefault(),i=-1);break;case 39:e.shiftKey?n=1:(e.preventDefault(),i=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),a=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),a=1);break;default:return}this._rotationDisabled&&(n=0,r=0);let{zoom:o,bearing:s,pitch:c,center:l}=this._camera.proposedProjectedCamera;return{easeTo:{duration:300,easeId:`keyboardHandler`,easing:rR,zoom:t?$h(o+t*(e.shiftKey?2:1),this._camera.getZoomSnap()):o,bearing:s+n*this._bearingStep,pitch:c+r*this._pitchStep,offset:[-i*this._panStep,-a*this._panStep],center:{lng:l.lng,lat:l.lat}}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function rR(e){return e*(2-e)}var iR=4.000244140625,aR=class{constructor(e,t,n){this._canvas=e,this._cooperativeGestures=t,this._camera=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishWait!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around===`center`)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return this._cooperativeGestures.isEnabled()?!(e.ctrlKey||this._cooperativeGestures.isBypassed(e)):!1}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e)){this._cooperativeGestures.notifyGestureBlocked(`wheel_zoom`,e);return}let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*40:e.deltaY,n,r=Ig(),i=r-(this._lastWheelEventTime||0);return this._lastWheelEventTime=r,t!==0&&t%iR==0?this._type=`wheel`:t!==0&&Math.abs(t)<4?this._type=`trackpad`:i>400?(this._type=null,this._lastValue=t,this._singleWheelWait={reason:`singleWheel`,event:e},n={timeout:{delay:40,token:this._singleWheelWait}}):this._type||(this._type=Math.abs(i*t)<200?`trackpad`:`wheel`,this._singleWheelWait&&(this._singleWheelWait=void 0,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||(n=this._start(e))),e.preventDefault(),n}onTimeout(e){if(e===this._singleWheelWait||e===this._finishWait)switch(e.reason){case`singleWheel`:return this._singleWheelWait=void 0,this._type=`wheel`,this._delta-=this._lastValue,this._active?void 0:this._start(e.event);case`finish`:return this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishWait,{needsRenderFrame:!0}}}_start(e){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),delete this._finishWait;let t=Gg.mousePos(this._canvas,e);if(this._aroundCenter){let e=this._camera.proposedProjectedCamera;this._aroundPoint=Q(e).locationToScreenPoint(e,this._camera.context.worldCoordinateHelper,e.center)}else this._aroundPoint=t;if(!this._needsRerender)return this._needsRerender=!0,{needsRenderFrame:!0}}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let e=this._camera.proposedProjectedCamera;if(typeof this._lastExpectedZoom==`number`){let t=e.zoom-this._lastExpectedZoom;typeof this._startZoom==`number`&&(this._startZoom+=t),typeof this._targetZoom==`number`&&(this._targetZoom+=t)}if(this._delta!==0){let t=this._type===`wheel`&&Math.abs(this._delta)>iR?this._wheelZoomRate:this._defaultZoomRate,n=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&n!==0&&(n=1/n);let r=typeof this._targetZoom==`number`?Zh(this._targetZoom):e.scale,i=Q(e).getCameraLngLat(e,this._camera.context.worldCoordinateHelper),a=QF(this._camera.renderedState,this._camera.context,i,Qh(r*n)).zoom,o=this._camera.getZoomSnap();if(this._type===`wheel`&&o>0){let t=$h(e.zoom,o);this._targetZoom=$h(a,o,a-t)}else this._targetZoom=a;this._type===`wheel`&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let t=typeof this._targetZoom==`number`?this._targetZoom:e.zoom,n=this._startZoom,r=this._easing,i=!1,a;if(this._type===`wheel`&&n&&r){let e=Ig()-this._lastWheelEventTime,o=Math.min((e+5)/200,1),s=r(o);a=E0.number(n,t,s),o<1?this._needsRerender=!0:i=!0}else a=t,i=!0;return this._active=!0,i&&(this._active=!1,this._finishWait={reason:`finish`}),this._lastExpectedZoom=a,{noInertia:!0,needsRenderFrame:!i,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent,timeout:i?{delay:200,token:this._finishWait}:void 0}}_smoothOutEasing(e){let t=Wh;if(this._prevEase){let e=this._prevEase,n=(Ig()-e.start)/e.duration,r=e.easing(n+.01)-e.easing(n),i=.27/Math.sqrt(r*r+1e-4)*.01;t=Uh(i,Math.sqrt(.0729-i*i),.25,1)}return this._prevEase={start:Ig(),duration:e,easing:t},t}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishWait}},oR=class{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}},sR=class{constructor(e){this._camera=e,this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{easeTo:{duration:300,zoom:$h(this._camera.proposedProjectedCamera.zoom+(e.shiftKey?-1:1),this._camera.getZoomSnap()),around:OL(this._camera,t)}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},cR=class{constructor(){this._tap=new jL({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=e??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,n){if(!this._swipePoint){if(!this._tapTime)this._tap.touchstart(e,t,n);else{let r=t[0],i=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(r)<30;!i||!a?this.reset():n.length>0&&(this._swipePoint=r,this._swipeTouch=n[0].identifier)}}}touchmove(e,t,n){if(!this._tapTime)this._tap.touchmove(e,t,n);else if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;let r=t[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:i/128*this._zoomRate}}}touchend(e,t,n){if(this._tapTime)this._swipePoint&&n.length===0&&this.reset();else{let r=this._tap.touchend(e,t,n);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},lR=class{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add(`maplibregl-touch-drag-pan`)}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove(`maplibregl-touch-drag-pan`)}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}},uR=class{constructor(e,t,n,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=n,this._mouseRoll=r;let{aroundCenter:i=!0}=e;this._defaultMovement=i?`circular`:`linear`,this.around=`center`,this.movement=this._defaultMovement}enable(e){let t=typeof e==`object`?e:{};this.around=t.around??`center`,this.movement=t.around===`pointer`?`linear`:t.movement??this._defaultMovement,this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}},dR=class{constructor(e,t,n,r){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add(`maplibregl-touch-zoom-rotate`)}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove(`maplibregl-touch-zoom-rotate`)}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}setZoomRate(e){this._touchZoom.setZoomRate(e),this._tapDragZoom.setZoomRate(e)}setZoomThreshold(e){this._touchZoom.setZoomThreshold(e)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},fR=class extends l_{constructor(e,t,n){super(),this._bypassKey=navigator.userAgent.includes(`Mac`)?`metaKey`:`ctrlKey`,this._canvasContainer=e,this._locale=t,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._canvasContainer;e.classList.add(`maplibregl-cooperative-gestures`),this._container=Gg.create(`div`,`maplibregl-cooperative-gesture-screen`,e);let t=this._locale[`CooperativeGesturesHandler.WindowsHelpText`];this._bypassKey===`metaKey`&&(t=this._locale[`CooperativeGesturesHandler.MacHelpText`]);let n=this._locale[`CooperativeGesturesHandler.MobileHelpText`],r=document.createElement(`div`);r.className=`maplibregl-desktop-message`,r.textContent=t,this._container.appendChild(r);let i=document.createElement(`div`);i.className=`maplibregl-mobile-message`,i.textContent=n,this._container.appendChild(i),this._container.setAttribute(`aria-hidden`,`true`)}_destroyUI(){this._container&&(this._container.remove(),this._canvasContainer.classList.remove(`maplibregl-cooperative-gestures`)),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,t){this._enabled&&(this.fire(new D4(`cooperativegestureprevented`,{gestureType:e,originalEvent:t})),this._container.classList.add(`maplibregl-show`),setTimeout(()=>{this._container.classList.remove(`maplibregl-show`)},100))}};function pR(e,t){let{camera:n,canvas:r,canvasContainer:i}=e,a=[];function o(e,t,n){a.push({handlerName:e,handler:t,allowed:n})}o(`mapEvent`,new wL(e.eventFactory,t));let s=new EL(i,e.container,t,n,e.boxZoomEnd);o(`boxZoom`,s),t.interactive&&t.boxZoom&&s.enable();let c=new fR(i,e.locale,t.cooperativeGestures);o(`cooperativeGestures`,c),t.cooperativeGestures&&c.enable();let l=new ML(n),u=new sR(n),d=new oR(u,l);o(`tapZoom`,l),o(`clickZoom`,u),t.interactive&&t.doubleClickZoom&&d.enable();let f=new cR;o(`tapDragZoom`,f);let p=new eR(c);o(`touchPitch`,p),t.interactive&&t.touchPitch&&p.enable(t.touchPitch);let m=()=>n.projectedCamera.centerPoint,h=()=>y.around,g=HL(t,m,h,()=>y.movement),_=UL(t,h),v=WL(t,m,h),y=new uR(t,g,_,v);o(`mouseRotate`,g,[`mousePitch`]),o(`mousePitch`,_,[`mouseRotate`,`mouseRoll`]),o(`mouseRoll`,v,[`mousePitch`]),t.interactive&&t.dragRotate&&y.enable(t.dragRotate);let b=VL(t),x=new GL(t,c),S=new lR(i,b,x);o(`mousePan`,b),o(`touchPan`,x,[`touchZoom`,`touchRotate`]),t.interactive&&t.dragPan&&S.enable(t.dragPan);let C=new QL,w=new XL,T=new dR(i,w,C,f);o(`touchRotate`,C,[`touchPan`,`touchZoom`]),o(`touchZoom`,w,[`touchPan`,`touchRotate`]),t.interactive&&t.touchZoomRotate&&T.enable(t.touchZoomRotate),o(`blockableMapEvent`,new TL(e.eventFactory,t),[`touchPan`]);let E=new aR(r,c,n);o(`scrollZoom`,E,[`mousePan`]),t.interactive&&t.scrollZoom&&E.enable(t.scrollZoom);let D=new nR(n);return o(`keyboard`,D),t.interactive&&t.keyboard&&D.enable(),{registrations:a,mapHandlers:{boxZoom:s,cooperativeGestures:c,doubleClickZoom:d,touchPitch:p,dragRotate:y,dragPan:S,touchZoomRotate:T,scrollZoom:E,keyboard:D}}}function mR(e,t,n){if(e.dem!==`awaiting`)return null;let r=n.getDrawnElevationForLngLat(t,!0);if(r!==void 0)return{hold:{...e,dem:`taken`},elevation:r};let i=n.getDrawnElevationForLngLat(t);return i===void 0?null:{hold:e,elevation:i}}var hR={moving:!1,adjustment:null};function gR(e){return{view:e,motion:hR,centerElevation:{rule:`ground`},terrainRevision:0,projection:`mercator`,projectionTransition:1}}function _R(e,t){let n=t(e);return n===e?e:{...e,...n}}function vR(...e){return t=>e.reduce(_R,t)}function yR(e){return t=>e===t.view?t:{view:e}}function bR(e){return t=>e===t.view.elevation?t:{view:{...t.view,elevation:e}}}function xR(e,t,n,r){return i=>({view:kI(i.view,e,t,n,r)})}function SR(e){return t=>yR(fI(t.view,e))(t)}function CR(){return e=>e.motion.moving?e:{motion:{moving:!0,adjustment:null}}}function wR(e){return t=>!t.motion.moving||e===t.motion.adjustment?t:{motion:{moving:!0,adjustment:e}}}function TR(e){return t=>({motion:hR,view:t.centerElevation.rule===`held`?{...e,elevation:t.view.elevation}:e})}function ER(e){return t=>e===t.centerElevation?t:{centerElevation:e}}function DR(){return e=>({terrainRevision:e.terrainRevision+1})}function OR(e){return t=>e===t.projection?t:{projection:e,projectionTransition:1}}function kR(e){return t=>e===t.projectionTransition?t:{projectionTransition:e}}var AR=[`zoom`,`rotate`,`pitch`,`roll`];function jR(){return{zoom:!1,rotate:!1,pitch:!1,roll:!1}}var MR=class extends l_{constructor(e){super(),this._currentSegment=null,this._frameRequestId=null,this._movingAxes=jR(),this._pendingEvents=[],this._deliveringEvents=!1,this._onRenderFrame=()=>{if(this._frameRequestId=null,!this._currentSegment)return;let{startTime:e,options:{duration:t,easing:n}}=this._currentSegment,r=Math.min((Ig()-e)/t,1);this._runSegmentFrame(this._currentSegment,n(r),r===1)},this._renderLoop=e}isMoving(){return this._currentSegment!==null}isMovingAxis(e){return this._movingAxes[e]}isContinuedBy(e){return!!e&&this._currentSegment?.options.easeId===e}scheduleSegment(e,t){let n=this.isContinuedBy(t.easeId);n?this._stopSegment(this._currentSegment):this.interrupt(),this._currentSegment={segment:e,options:t,startTime:Ig()},this._queueStartEvents(t,n),t.duration===0?this._runSegmentFrame(this._currentSegment,1,!0):(this._requestRenderFrame(),this._deliverPendingEvents())}interrupt(){if(!this._currentSegment)return;let{eventData:e}=this._currentSegment.options;this._stopSegment(this._currentSegment),this._queueEndEvents(e),this._deliverPendingEvents()}fireAfterQueued(e){for(let t of e)this._pendingEvents.push({event:t});this._deliverPendingEvents()}_runSegmentFrame(e,t,n){e.segment.onFrame(t),this._queueFrameEvents(e),n||this._requestRenderFrame(),this._deliverPendingEvents(),n&&this._currentSegment===e&&(this._finishSegment(e),this._queueEndEvents(e.options.eventData),this._deliverPendingEvents())}_stopSegment(e){this._cancelRenderFrame(),this._pendingEvents=this._pendingEvents.filter(t=>t.frameSegment!==e),this._finishSegment(e)}_finishSegment(e){this._currentSegment=null,e.segment.onFinish()}_requestRenderFrame(){this._frameRequestId=this._renderLoop.requestRenderFrame(this._onRenderFrame)}_cancelRenderFrame(){this._frameRequestId!==null&&(this._renderLoop.cancelRenderFrame(this._frameRequestId),this._frameRequestId=null)}_queueStartEvents(e,t){!t&&!e.movestartFired&&this._pendingEvents.push({event:new O4(`movestart`,e.eventData)});for(let t of AR)e.axes[t]&&!this._movingAxes[t]&&(this._movingAxes[t]=!0,this._pendingEvents.push({event:new O4(`${t}start`,e.eventData)}))}_queueFrameEvents(e){let{eventData:t}=e.options;this._pendingEvents.push({event:new O4(`move`,t),frameSegment:e});for(let n of AR)this._movingAxes[n]&&this._pendingEvents.push({event:new O4(n,t),frameSegment:e})}_queueEndEvents(e){let t=this._movingAxes;this._movingAxes=jR();for(let n of AR)t[n]&&this._pendingEvents.push({event:new O4(`${n}end`,e)});this._pendingEvents.push({event:new O4(`moveend`,e)})}_deliverPendingEvents(){if(!this._deliveringEvents){this._deliveringEvents=!0;try{for(;this._pendingEvents.length;)this.fire(this._pendingEvents.shift().event)}catch(e){throw this._pendingEvents=[],e}finally{this._deliveringEvents=!1}}}},NR=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},PR=(e=>e?NR(e):NR);function FR(){return PR()(()=>({camera:gR(V8()),style:Bj(),terrain:{demRevision:0},styleLostWithContext:!1}))}function IR(e,t,n){return e.subscribe((e,r)=>{let i=t(e),a=t(r);i!==a&&n(i,a)})}var LR=.01,RR=class extends l_{get renderedState(){let{view:e,motion:t,terrainRevision:n,centerElevation:r}=this._state,i=this.context,a=this.terrain,o=this._centerClampedToGround,s=this._renderedFrom;return(s?.view!==e||s.motion!==t||s.terrainRevision!==n||s.centerElevation!==r||s.context!==i||s.terrain!==a||s.centerClampedToGround!==o)&&(this._renderedFrom={view:e,motion:t,terrainRevision:n,centerElevation:r,context:i,terrain:a,centerClampedToGround:o,rendered:this._renderedFromProposal()}),this._renderedFrom.rendered}get projectedCamera(){return uI(this.renderedState,this.context)}get context(){let{projection:e,projectionTransition:t}=this._state,n=this._context;return(n?.projection!==e||n.projectionTransition!==t||n.worldCoordinateHelper!==this._worldCoordinateHelper||n.constrainOverride!==this._constrainOverride)&&(this._context=YF({projection:e,projectionTransition:t,worldCoordinateHelper:this._worldCoordinateHelper,constrainOverride:this._constrainOverride})),this._context}constructor(e){super(),this._context=null,this._renderedFrom=null,this._batching=0,this._changedInBatch=!1,this._onStateChange=(e,t)=>{(e.view!==t.view||e.centerElevation!==t.centerElevation||e.terrainRevision!==t.terrainRevision)&&(this._changedInBatch=!0)},this._worldCoordinateHelper=l8,this._constrainOverride=e.transformConstrain??null;let t=YF({constrainOverride:this._constrainOverride}),n=V8();e.minZoom!==void 0&&(n=mI(n,t,e.minZoom)),e.maxZoom!==void 0&&(n=hI(n,t,e.maxZoom)),e.minPitch!==void 0&&(n=gI(n,e.minPitch)),e.maxPitch!==void 0&&(n=_I(n,e.maxPitch)),e.renderWorldCopies!==void 0&&(n=vI(n,t.worldCoordinateHelper,e.renderWorldCopies)),this._elevationHandedOut=n.elevation,this._store=e.store,this._store.setState({camera:gR(n)}),IR(this._store,e=>e.camera,this._onStateChange),IR(this._store,e=>e.terrain.demRevision,()=>this._applyTerrainChange()),this._bearingSnap=e.bearingSnap,this._zoomSnap=e.zoomSnap,this.terrain=e.terrain,this._centerClampedToGround=e.centerClampedToGround??!0,this.transformCameraUpdate=e.transformCameraUpdate??null,this._scheduler=new MR(e.renderLoop),this._scheduler.setEventedParent(this),this.on(`moveend`,()=>{this._scheduler.isMoving()||this._dispatch(TR(this.renderedState))})}get _state(){return this._store.getState().camera}_dispatch(e){this._batch(()=>{this._store.setState(t=>{let n=_R(t.camera,e);return n===t.camera?t:{camera:n}})})}_batch(e){this._batching++;try{e()}finally{this._batching--}if(this._batching)return;let t=this._changedInBatch;this._changedInBatch=!1,t&&this._adjustMovement()}get proposedProjectedCamera(){return this._projectState(this._viewAsDrawn())}_projectState(e){return uI(e,this.context)}_metricsOf(e){return lI(e,this.context.worldCoordinateHelper)}setTerrain(e){this.terrain=e,this._batch(()=>{let t=this._state.centerElevation;if(!e||t.rule!==`held`||!this.getCenterClampedToGround())return;let n=this.proposedProjectedCamera;e.getElevationAndDEMStateForLngLat(n.center,n.tileZoom).demState!==`loaded`&&this._dispatch(vR(bR(0),ER({...t,dem:`awaiting`})))}),this._applyTerrainChange()}migrateProjection(e,t){this._worldCoordinateHelper=t,this._batch(()=>{this._dispatch(OR(e)),this._dispatch(SR(this.context))})}setConstrainOverride(e){this._constrainOverride!==e&&(this._constrainOverride=e,this.applyStateChange(fI))}resize(e,t,n){this._dispatch(xR(this.context,e,t,n))}setProjectionTransition(e){this._dispatch(kR(e))}getCenter(){return new Xb(this.renderedState.center.lng,this.renderedState.center.lat)}unproject(e){let t=this.projectedCamera;return Q(t).screenPointToLocation(t,this.context.worldCoordinateHelper,U.convert(e),this.terrain)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.renderedState.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,t,n){return e=U.convert(e).mult(-1),this.panTo(this.renderedState.center,{offset:e,...t},n)}panTo(e,t,n){return this.easeTo({center:e,...t},n)}getZoom(){return this.renderedState.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,n){return this.easeTo({zoom:e,...t},n)}zoomIn(e,t){return this.zoomTo($h(this.getZoom()+1,this._zoomSnap),e,t),this}zoomOut(e,t){return this.zoomTo($h(this.getZoom()-1,this._zoomSnap),e,t),this}getVerticalFieldOfView(){return X8(this.renderedState)}setVerticalFieldOfView(e,t){return e!=this.getVerticalFieldOfView()&&(this.applyStateChange(t=>SI(t,e)),this.fire(new O4(`movestart`,t)).fire(new O4(`move`,t)).fire(new O4(`moveend`,t))),this}getBearing(){return K8(this.renderedState)}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return{...this.renderedState.padding}}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,n){return this.easeTo({bearing:e,...t},n)}resetNorth(e,t){return this.rotateTo(0,{duration:1e3,...e},t),this}resetNorthPitch(e,t){return this.easeTo({bearing:0,pitch:0,roll:0,duration:1e3,...e},t),this}snapToNorth(e,t){return Math.abs(this.getBearing()){let t=p.easeFunc(this._viewForUpdate(),this.context,e);this.applyUpdatedState(m.easeFunc(t,e))},onFinish:()=>this._finishAnimationElevation(e.freezeElevation)},{duration:e.duration,easing:e.easing,axes:{zoom:p.isZooming,rotate:r!==o,pitch:s!==i,roll:c!==a},eventData:t,easeId:e.easeId,movestartFired:e.noMoveStart}),this}_createElevationEase(e,t,n){if(n)return this.terrain&&this.holdElevation(`animation`),{easeFunc:e=>e};let r=this.terrain?this._startElevationEasing(t,e):null;return{easeFunc:(e,t)=>this.terrain?(r??=this._startElevationEasing(e.center,e),r(e,t)):e}}_startElevationEasing(e,t){this._dispatch(ER({rule:`eased`}));let n=this._metricsOf(t).tileZoom,r=this.terrain.getElevationAndDEMStateForLngLat(e,n),i=t.elevation,a=r.demState===`loading`?t.elevation:r.elevation;return(t,r)=>{let{elevation:o,demState:s}=this.terrain.getElevationAndDEMStateForLngLat(e,n);if(r<1&&s!==`loading`&&o!==a){let e=E0.number(i,a,r);i=e-r*((o-e)/(1-r)),a=o}return this.getCenterClampedToGround()?EI(t,this.context,E0.number(i,a,r)):t}}holdElevation(e){let t=this.proposedProjectedCamera,n=!!this.terrain&&this.getCenterClampedToGround()&&this.terrain.getElevationAndDEMStateForLngLat(t.center,t.tileZoom).demState!==`loaded`,r=this.terrain?this._terrainHeightAboveMaxZoomForCenter(t):void 0;this._dispatch(ER({rule:`held`,holder:e,dem:n?`awaiting`:`loaded`,keepsTerrainBelowMaxZoomForCenter:r!==void 0&&r<=LR}))}isHoldingElevation(){return this._state.centerElevation.rule===`held`}releaseElevation(){let e=this._state.centerElevation;e.rule===`held`&&this._batch(()=>{let t=this.getStateForUpdate();this._dispatch(ER({rule:`ground`})),this.getCenterClampedToGround()&&(t=this.terrain?this.putCenterBackOnTerrain(t,this.terrain,e.dem===`taken`):EI(t,this.context,0)),this.applyUpdatedState(this._raiseCameraByPitchAndZoom(t))})}putCenterBackOnTerrain(e,t,n){if(!n||t.getDrawnElevationForLngLat(e.center,!0)!==void 0)return $I(this.context).recenterOnTerrain(e,this.context,t);let r=t.getElevationForLngLat(e.center,this._metricsOf(e).tileZoom);return this._raiseCameraByPitchAndZoom(EI(e,this.context,r))}_applyTerrainChange(){this._batch(()=>{this._dispatch(DR()),this._followTerrainByRule()})}followTerrain(){let e=this.renderedState,t=this._minElevationUnder(e)!==e.minElevationForCurrentTile;this._batch(()=>{t&&this._dispatch(DR()),this._state.motion.moving||this._followTerrainByRule()})}_followTerrainByRule(){if(!this.getCenterClampedToGround())return;let e=this._state.centerElevation;if(e.rule===`eased`)return;if(!this.terrain){e.rule===`ground`&&this._dispatch(bR(0));return}let t=this.proposedProjectedCamera;if(e.rule===`ground`){let{elevation:e,demState:n}=this.terrain.getElevationAndDEMStateForLngLat(t.center,t.tileZoom);n!==`loading`&&this._dispatch(bR(e));return}let n=mR(e,t.center,this.terrain);n&&this._dispatch(vR(ER(n.hold),bR(n.elevation))),this._noteTerrainBelowMaxZoomForCenter()}_noteTerrainBelowMaxZoomForCenter(){let e=this._state.centerElevation;if(e.rule!==`held`||e.keepsTerrainBelowMaxZoomForCenter)return;let t=this.proposedProjectedCamera;if(t.pitch>=90||Q(t).getClippingPlane(t))return;let n=this._terrainHeightAboveMaxZoomForCenter(t);n!==void 0&&n<=LR&&this._dispatch(ER({...e,keepsTerrainBelowMaxZoomForCenter:!0}))}_minElevationUnder(e){return this.terrain?this.terrain.getMinTileElevationForLngLatZoom(e.center,this._metricsOf(e).tileZoom):0}_viewAsDrawn(){let{view:e}=this._state,t=AI(e,this._minElevationUnder(e)),n=this._drawnElevation(t);return n===t.elevation?t:EI(t,this.context,n)}_viewForUpdate(){let e=this._viewAsDrawn();return this._elevationHandedOut=e.elevation,e}_drawnElevation(e){if(!this.getCenterClampedToGround())return e.elevation;if(!this.terrain)return 0;let t=this._state.centerElevation;if(t.rule!==`held`||q8(e)>=90)return e.elevation;let n=this._projectState(e);if(Q(n).getClippingPlane(n))return e.elevation;let r=(t.keepsTerrainBelowMaxZoomForCenter?this._terrainHeightAboveMaxZoomForCenter(n):void 0)??-1/0,i=t.holder===`gesture`?this._terrainHeightAboveCamera(n):-1/0;return e.elevation+Math.max(0,i,r)}_isLiftedByHold(e){let t=this._state.centerElevation;return!!this.terrain&&t.rule===`held`&&t.holder===`gesture`&&this.getCenterClampedToGround()&&q8(e)<90&&!rx(this._projectState(e))}getStateForUpdate(){return this._dispatch(CR()),this._viewForUpdate()}_raiseCameraByPitchAndZoom(e){let t=this._projectState(e);if(!this.terrain&&e.elevation>=0&&t.pitch<=90)return e;let n=Q(t).getCameraLngLat(t,this.context.worldCoordinateHelper),r=this._heightAboveCamera(t);if(r<=0)return e;let i=e;for(let e=0;e<3&&r>0;e++){let e=this._projectState(i),t=Q(e).getCameraAltitude(e),{zoom:a,pitch:o}=$I(this.context).calculateCameraOptionsFromTo(i,this.context,n,t+r,i.center,i.elevation);i=bI(CI(i,this.context,a),o),r=this._heightAboveCamera(this._projectState(i))}return i}_heightAboveCamera(e){return this.terrain?this._terrainHeightAboveCamera(e):-Q(e).getCameraAltitude(e)}_terrainHeightAboveCamera(e){let t=this.terrain.getElevationForLngLat(Q(e).getCameraLngLat(e,this.context.worldCoordinateHelper),e.tileZoom)-Q(e).getCameraAltitude(e),n=Q(e).getClippingPlane(e)?null:this.terrain.getCoverageIndex();if(!n)return t;let[r,i,a,o]=Q(e).getCameraFrustum(e).points;for(let e=0;e<=2;e++){let s=e/2;for(let e=0;e<=2;e++){let c=e/2,l=(1-c)*(1-s),u=c*(1-s),d=c*s,f=(1-c)*s,p=l*r[0]+u*i[0]+d*a[0]+f*o[0],m=l*r[1]+u*i[1]+d*a[1]+f*o[1],h=l*r[2]+u*i[2]+d*a[2]+f*o[2],g=hx(n,this.terrain.exaggeration,p,m,this.context.worldCoordinateHelper.wraps);g.covered&&(t=Math.max(t,g.elevation-h))}}return t}_terrainHeightAboveMaxZoomForCenter(e){let t=this.terrain.getCoverageIndex();if(!t)return;let n=this.context.worldCoordinateHelper,r=Q(e).getCameraLngLat(e,this.context.worldCoordinateHelper),i=n.worldFromLngLat(r.lng,r.lat),a=n.worldFromLngLat(e.center.lng,e.center.lat),o=Zh(e.zoom-e.maxZoom),s=hx(t,this.terrain.exaggeration,zh(i.x,a.x,o),zh(i.y,a.y,o),n.wraps);return s.covered?s.elevation-zh(Q(e).getCameraAltitude(e),e.elevation,o):void 0}moveCenterOntoTerrain(e,t){if(!this.terrain||!this.getCenterClampedToGround()||rx(this._projectState(e)))return e;let n=$I(this.context).recenterOnTerrain(e,this.context,this.terrain);if(!(n.zoom>e.zoom-t&&n.zoom=90||!UR(this._projectState(r),this.context.worldCoordinateHelper,t.point))return null;let i=zR(r,this.context,t);return i&&HR(this._projectState(i),this.context.worldCoordinateHelper,t)?i:null}applyUpdatedState(e){this._batch(()=>{this._dispatch(yR(e.elevation===this._elevationHandedOut?{...e,elevation:this._state.view.elevation}:e)),this._followTerrainByRule()})}applyStateChange(e){let t=this._state.motion.moving;this.applyUpdatedState(e(this.getStateForUpdate(),this.context)),t||this._dispatch(TR(this.renderedState))}_renderedFromProposal(){let e=this._viewAsDrawn(),t=this._state.motion;if(!t.moving)return e;let n=this._correctedForMovement(e),r=t.adjustment;if(!r)return n;let i=this._applyAdjustment(n,r);return AI(i,this._minElevationUnder(i))}_correctedForMovement(e){return this._isLiftedByHold(e)?e:this._raiseCameraByPitchAndZoom(e)}_adjustMovement(){if(!this._state.motion.moving)return;if(!this.transformCameraUpdate){this._dispatch(wR(null));return}let e=this._correctedForMovement(this._viewAsDrawn());this._dispatch(wR(this.transformCameraUpdate(this._metricsOf(e))))}_applyAdjustment(e,{center:t,zoom:n,roll:r,pitch:i,bearing:a,elevation:o}){let s=this.context,c=e;return t&&(c=wI(c,s,t)),o!==void 0&&(c=EI(c,s,o)),n!==void 0&&(c=CI(c,s,n)),r!==void 0&&(c=xI(c,r)),i!==void 0&&(c=bI(c,i)),a!==void 0&&(c=yI(c,a)),o===void 0?c:this._raiseCameraByPitchAndZoom(c)}_finishAnimationElevation(e=!1){let t=this._state.centerElevation;t.rule===`eased`?this._dispatch(ER({rule:`ground`})):t.rule===`held`?(this._followTerrainByRule(),this.releaseElevation()):e&&this.terrain&&this.getCenterClampedToGround()&&this.applyUpdatedState(this.putCenterBackOnTerrain(this.getStateForUpdate(),this.terrain,!1))}flyTo(e,t){if(!e.essential&&Pg.prefersReducedMotion)return this.easeTo(e,t);this._scheduler.interrupt(),e={offset:[0,0],speed:1.2,curve:1.42,easing:Wh,...e},e.zoom!==void 0&&this._zoomSnap&&(e.zoom=$h(e.zoom,this._zoomSnap));let n=this.getStateForUpdate(),r=K8(n),i=q8(n),a=J8(n),o=n.padding,s=e.bearing===void 0?r:this._normalizeBearing(e.bearing,r),c=e.pitch===void 0?i:+e.pitch,l=e.roll===void 0?a:this._normalizeBearing(e.roll,a),u=e.padding===void 0?n.padding:e.padding,d=U.convert(e.offset),f=W8(n).add(d),p=this._projectState(n),m=Q(p).screenPointToLocation(p,this.context.worldCoordinateHelper,f),h=cL(this.context).flyTo(n,this.context,{bearing:s,pitch:c,roll:l,padding:u,locationAtOffset:m,offsetAsPoint:d,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),g=e.curve,_=Math.max(n.width,n.height),v=_/h.scaleOfZoom,y=h.pixelPathLength,b=_/h.scaleOfMinZoom;g=Math.min(g,Math.sqrt(b/y*2));let x=g*g;function S(e){let t=(v*v-_*_+(e?-1:1)*x*x*y*y)/(2*(e?v:_)*x*y);return Math.log(Math.sqrt(t*t+1)-t)}function C(e){return(Math.exp(e)-Math.exp(-e))/2}function w(e){return(Math.exp(e)+Math.exp(-e))/2}function T(e){return C(e)/w(e)}let E=S(!1),D=function(e){return w(E)/w(E+g*e)},O=function(e){return _*((w(E)*T(E+g*e)-C(E))/x)/y},k=(S(!0)-E)/g;if(Math.abs(y)<2e-6||!isFinite(k)){if(Math.abs(_-v)<1e-6)return this.easeTo(e,t);let n=v<_?-1:1;k=Math.abs(Math.log(v/_))/g,O=()=>0,D=e=>Math.exp(n*g*e)}if(e.duration!==void 0)e.duration=+e.duration;else{let t=e.screenSpeed===void 0?+e.speed:+e.screenSpeed/g;e.duration=1e3*k/t}e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0);let A=r!==s,j=c!==i,M=l!==a,N=!U8(n.padding,u),P=this._createElevationEase(n,h.targetCenter,e.freezeElevation);return this._scheduler.scheduleSegment({onFrame:e=>{let t=this.context,n=this._viewForUpdate(),p=e*k,m=1/D(p),g=O(p);A&&(n=yI(n,E0.number(r,s,e))),j&&(n=bI(n,E0.number(i,c,e))),M&&(n=xI(n,E0.number(a,l,e))),N&&(n=OI(n,t,o,u,e),f=W8(n).add(d)),n=h.easeFunc(n,t,e,m,g,f),this.applyUpdatedState(P.easeFunc(n,e))},onFinish:()=>this._finishAnimationElevation(e.freezeElevation)},{duration:e.animate===!1?0:e.duration,easing:e.easing,axes:{zoom:!0,rotate:A,pitch:j,roll:M},eventData:t}),this}stop(){return this._scheduler.interrupt(),this}_normalizeBearing(e,t){e=Gh(e,-180,180);let n=Math.abs(e-t);return Math.abs(e-360-t)MapLibre`},qR=class{constructor(e=KR){this._toggleAttribution=()=>{this._container.classList.contains(`maplibregl-compact`)&&(this._container.classList.contains(`maplibregl-compact-show`)?(this._container.setAttribute(`open`,``),this._container.classList.remove(`maplibregl-compact-show`)):(this._container.classList.add(`maplibregl-compact-show`),this._container.removeAttribute(`open`)))},this._updateData=e=>{e&&(e.type===`terrain`||e.dataType===`style`||e.dataType===`source`&&(e.sourceDataType===`metadata`||e.sourceDataType===`visibility`))&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute(`open`,``):!this._container.classList.contains(`maplibregl-compact`)&&!this._container.classList.contains(`maplibregl-attrib-empty`)&&(this._container.setAttribute(`open`,``),this._container.classList.add(`maplibregl-compact`,`maplibregl-compact-show`)):(this._container.setAttribute(`open`,``),this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.remove(`maplibregl-compact`,`maplibregl-compact-show`))},this._updateCompactMinimize=()=>{this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.contains(`maplibregl-compact-show`)&&this._container.classList.remove(`maplibregl-compact-show`)},this.options=e}getDefaultPosition(){return`bottom-right`}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=Gg.create(`details`,`maplibregl-ctrl maplibregl-ctrl-attrib`),this._compactButton=Gg.create(`summary`,`maplibregl-ctrl-attrib-button`,this._container),this._compactButton.addEventListener(`click`,this._toggleAttribution),this._setElementTitle(this._compactButton,`ToggleAttribution`),this._innerContainer=Gg.create(`div`,`maplibregl-ctrl-attrib-inner`,this._container),this._updateAttributions(),this._updateCompact(),this._map.on(`styledata`,this._updateData),this._map.on(`sourcedata`,this._updateData),this._map.on(`terrain`,this._updateData),this._map.on(`resize`,this._updateCompact),this._map.on(`drag`,this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off(`styledata`,this._updateData),this._map.off(`sourcedata`,this._updateData),this._map.off(`terrain`,this._updateData),this._map.off(`resize`,this._updateCompact),this._map.off(`drag`,this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){let n=this._map._getUIString(`AttributionControl.${t}`);e.title=n,e.setAttribute(`aria-label`,n)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>typeof e==`string`?e:``)):typeof this.options.customAttribution==`string`&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}let t=this._map.style.tileManagers;for(let n in t){let r=t[n];if(r.used||r.usedForTerrain){let t=r.getSource();t.attribution&&!e.includes(t.attribution)&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,n)=>{for(let r=n+1;r{let e=this._container.children;if(e.length){let t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&t.classList.add(`maplibregl-compact`):t.classList.remove(`maplibregl-compact`)}},this.options=e}getDefaultPosition(){return`bottom-left`}onAdd(e){this._map=e,this._compact=this.options?.compact,this._container=Gg.create(`div`,`maplibregl-ctrl`);let t=Gg.create(`a`,`maplibregl-ctrl-logo`);return t.target=`_blank`,t.rel=`noopener nofollow`,t.href=`https://maplibre.org/`,t.setAttribute(`aria-label`,this._map._getUIString(`LogoControl.Title`)),t.setAttribute(`rel`,`noopener nofollow`),this._container.appendChild(t),this._container.style.display=`block`,this._map.on(`resize`,this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off(`resize`,this._updateCompact),this._map=void 0,this._compact=void 0}},YR=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){let t=this._currentlyRunning,n=t?this._queue.concat(t):this._queue;for(let t of n)if(t.id===e){t.cancelled=!0;return}}run(e=0){if(this._currentlyRunning)throw Error(`Attempting to run(), but is already running.`);let t=this._currentlyRunning=this._queue;this._queue=[];let n=!1,r;for(let i of t)if(!i.cancelled){try{i.callback(e)}catch(e){n||(n=!0,r=e)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,n)throw r}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}},XR=I3([{name:`a_pos3d`,type:`Int16`,components:3}]),ZR=class extends l_{constructor(e,t){super(),this._lastTilesetChange=Ig(),this.tileManager=e,this._store=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(e,t,n){this.tileManager.update(e,t,n),this._renderableTilesKeys=[];let r={},i=!1;for(let a of ej(e,t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))r[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.terrainRttPosMatrix32f=new Float32Array(16),Em(a.terrainRttPosMatrix32f,0,8192,8192,0,0,1),this._tiles[a.key]=new LA(a,this.tileSize),this._lastTilesetChange=Ig(),i=!0);for(let e in this._tiles)r[e]||(this._tiles[e].releaseRTT(this.tileManager.map.painter),delete this._tiles[e],i=!0);return i}releaseRTT(e){for(let t in this._tiles){let n=this._tiles[t];(n.tileID.equals(e)||n.tileID.isChildOf(e)||e.isChildOf(n.tileID))&&n.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let e in this._tiles)this._tiles[e].releaseRTT(this.tileManager.map.painter)}onDEMTileLoaded(){this._store.setState(e=>({terrain:{demRevision:e.terrain.demRevision+1}}))}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let t={};for(let n of this._renderableTilesKeys){let r=this._tiles[n].tileID,i=e.clone(),a=Eh();if(r.canonical.equals(e.canonical))Em(a,0,W,W,0,0,1);else if(r.canonical.isChildOf(e.canonical)){let t=r.canonical.z-e.canonical.z,n=r.canonical.x-(r.canonical.x>>t<>t<>t;Em(a,0,o,o,0,0,1),_m(a,a,[-n*o,-i*o,0])}else if(e.canonical.isChildOf(r.canonical)){let t=e.canonical.z-r.canonical.z,n=e.canonical.x-(e.canonical.x>>t<>t<>t;Em(a,0,W,W,0,0,1),_m(a,a,[n*o,i*o,0]),vm(a,a,[1/2**t,1/2**t,0])}else continue;i.terrainRttPosMatrix32f=new Float32Array(a),t[n]=i}return t}_getTerrainCoordsForTileRanges(e,t){let n={};for(let r of this._renderableTilesKeys){let i=this._tiles[r].tileID;if(!this._isWithinTileRanges(i,t))continue;let a=e.clone(),o=Eh();if(i.canonical.z===e.canonical.z){let t=e.canonical.x-i.canonical.x+e.wrap*(1<e.canonical.z){let t=i.canonical.z-e.canonical.z,n=i.canonical.x-(i.canonical.x>>t<>t<>t),s=e.canonical.y-(i.canonical.y>>t),c=W>>t;Em(o,0,c,c,0,0,1),_m(o,o,[-n*c+a*W,-r*c+s*W,0])}else{let t=e.canonical.z-i.canonical.z,n=e.canonical.x-(e.canonical.x>>t<>t<>t)-i.canonical.x,s=(e.canonical.y>>t)-i.canonical.y,c=W<=n.minzoom&&!i?.dem;)i=this.findTileInCaches(e.scaledTo(r--).key);return i}isStillWaitingForDEM(e){let t=this.tileManager._source,n=this._getSourceZoom(e,t);if(n===void 0)return!1;let r=e.scaledTo(n);return t.hasTile&&!t.hasTile(r)?!1:this.findTileInCaches(r.key)?.state!==`errored`}_getSourceZoom(e,t){let n=Math.min(e.overscaledZ-this.deltaZoom,t.maxzoom);return n=e}_isWithinTileRanges(e,t){let n=t[e.canonical.z];return!!n&&(e.wrap>n.minWrap||e.wrap=n.minTileXWrapped&&e.canonical.x<=n.maxTileXWrapped&&e.canonical.y>=n.minTileY&&e.canonical.y<=n.maxTileY)}},QR=class{constructor(e,t,n,r,i=`auto`,a=()=>l8){this._meshCache={},this.painter=e,this._getWorldCoordinateHelper=a,this.tileManager=new ZR(t,r),this.options=n,this.exaggeration=typeof n.exaggeration==`number`?n.exaggeration:1,this._terrainSkirtLength=i,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=new Map,this._minMaxElevationCache=new Map,this.coverage=new mx(this.tileManager,this.exaggeration,()=>this._worldCoordinateHelper)}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._heightMapFbo&&=(this._heightMapFbo.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null);for(let e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,t,n,r=W){let i=e.normalizeCoordinates(t,n,r);if(!i)return 0;let a=this.coverage.getSampler(i.tileID);return a?a(i.x,i.y,r):0}getElevationForLngLatZoom(e,t){let n=this._worldCoordinateHelper;if(!d8(t,n.wraps?e.wrap():e,n))return 0;let{tileID:r,worldX:i,worldY:a}=this._getOverscaledTileIDFromLngLatZoom(e,t);return this.getElevation(r,i%W,a%W,W)}getElevationForLngLat(e,t){let n=this.getDrawnElevationForLngLat(e);return n===void 0?this.getElevationForLngLatZoom(e,this._getFallbackZoom(t)):n}getDrawnElevationForLngLat(e,t=!1){return this.coverage.sample(e,t)}getElevationAndDEMStateForLngLat(e,t){let n=this.getElevationForLngLat(e,t);if(n!==0||this.getDrawnElevationForLngLat(e)!==void 0)return{elevation:n,demState:`loaded`};let r=this._getFallbackZoom(t),i=this._worldCoordinateHelper;if(!d8(r,i.wraps?e.wrap():e,i))return{elevation:n,demState:`none`};let{tileID:a}=this._getOverscaledTileIDFromLngLatZoom(e,r);return this.tileManager.getSourceTile(a,!0)?.dem?{elevation:n,demState:`loaded`}:{elevation:n,demState:this.tileManager.isStillWaitingForDEM(a)?`loading`:`none`}}_getFallbackZoom(e){return Math.min(e,this.tileManager.maxzoom)}getElevation(e,t,n,r=W){return this.getDEMElevation(e,t,n,r)*this.exaggeration}resetElevationCache(){this.coverage.reset(),this._minMaxElevationCache.clear()}getCoverageIndex(){return this.coverage.getIndex()}_getDEMTileMatrix(e,t){let n=`${t.tileID.key}/${e.key}`,r=this._demMatrixCache.get(n);if(r)return r;let i=e.canonical.z-t.tileID.canonical.z,a=e.canonical.x-(e.canonical.x>>i<>i<{let t=this.style?.projection;t&&this._camera.setProjectionTransition(t.getTransitionStateForZoom(e))},this._contextLost=e=>{e.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this.style&&=(this._createStyleSnapshot(),this._store.setState({styleLostWithContext:!0}),this._warnAboutUnrestorableLayers(),this.style.off(`error`,this._onStyleError),this.style.destroy(),null),this.fire(new N4(`webglcontextlost`,{originalEvent:e}))},this._contextRestored=e=>{this._store.getState().styleLostWithContext&&(this._store.setState({styleLostWithContext:!1}),this._restoreStyleSnapshot());try{this._setupPainter()}catch(e){this.fire(new c_(e));return}this.resize(),this._update(),this._resizeInternal(),this.fire(new N4(`webglcontextrestored`,{originalEvent:e}))},this._handleWorkersRestarted=()=>{this.style&&(this.style._loaded?(this._createStyleSnapshot(),this._warnAboutUnrestorableLayers(),this.fire(new N4(`webglcontextlost`,{originalEvent:new globalThis.Event(`webglcontextlost`)})),this._restoreStyleSnapshot(),this._update(),this.fire(new N4(`webglcontextrestored`,{originalEvent:new globalThis.Event(`webglcontextrestored`)}))):(this.style.off(`style.load`,this._handleWorkersRestarted),this.style.once(`style.load`,this._handleWorkersRestarted)))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onStyleError=e=>{e.tile&&this.triggerRepaint()},this._onWindowOnline=()=>{this._update()},C4().on(`restart`,this._handleWorkersRestarted),T4().watchWorkers();let t={...tz,...e,canvasContextAttributes:{...tz.canvasContextAttributes,...e.canvasContextAttributes}};if(t.minZoom!=null&&t.maxZoom!=null&&t.minZoom>t.maxZoom)throw Error(`maxZoom must be greater than or equal to minZoom`);if(t.minPitch!=null&&t.maxPitch!=null&&t.minPitch>t.maxPitch)throw Error(`maxPitch must be greater than or equal to minPitch`);if(t.minPitch!=null&&t.minPitch<0)throw Error(`minPitch must be greater than or equal to 0`);if(t.maxPitch!=null&&t.maxPitch>180)throw Error(`maxPitch must be less than or equal to 180`);let n={requestRenderFrame:e=>this._requestRenderFrame(e),cancelRenderFrame:e=>this._cancelRenderFrame(e)};this._store=FR(),this._camera=new RR({store:this._store,minZoom:t.minZoom,maxZoom:t.maxZoom,minPitch:t.minPitch,maxPitch:t.maxPitch,bearingSnap:t.bearingSnap,zoomSnap:t.zoomSnap,renderWorldCopies:t.renderWorldCopies,centerClampedToGround:t.centerClampedToGround,terrain:this.terrain,transformConstrain:t.transformConstrain,renderLoop:n,transformCameraUpdate:t.transformCameraUpdate}),this._camera.setEventedParent(this),IR(this._store,e=>e.camera.view.zoom,this._updateProjectionTransition),this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._canvasContextAttributes={...t.canvasContextAttributes},this._trackResize=t.trackResize===!0,this._terrainSkirtLength=t.terrainSkirtLength,this._refreshExpiredTiles=t.refreshExpiredTiles===!0,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions===!0,this._collectResourceTiming=t.collectResourceTiming===!0,this._locale={...$R,...t.locale},this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this._zoomLevelsToOverscale=t.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=t.cancelPendingTileRequestsWhileZooming===!0,this.setAnisotropicFilterPitch(t.anisotropicFilterPitch),t.reduceMotion!==void 0&&(Pg.prefersReducedMotion=t.reduceMotion),this._requestManager=new Hee(t.transformRequest),this._container=this._resolveContainer(t.container),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer();try{this._setupPainter()}catch(e){throw this._cleanupContainer(),e}this._imageQueueHandle=E4.addThrottleControl(()=>this.isMoving()),this.on(`move`,()=>this._update(!1)),this.on(`moveend`,()=>this._update(!1)),this.on(`zoom`,()=>this._update(!0)),this.on(`terrain`,()=>{this.painter.markTerrainDepthDirty(),this._update(!0)}),this.once(`idle`,()=>this._idleTriggered=!0),this._eventFactory=new CL(this);let r=typeof t.boxZoom==`object`?t.boxZoom.boxZoomEnd:void 0,{registrations:i,mapHandlers:a}=pR({camera:this._camera,canvas:this._canvas,canvasContainer:this._canvasContainer,container:this._container,locale:this._locale,eventFactory:this._eventFactory,boxZoomEnd:r&&((e,t,n)=>r(this,e,t,n))},t);this.boxZoom=a.boxZoom,this.cooperativeGestures=a.cooperativeGestures,this.doubleClickZoom=a.doubleClickZoom,this.touchPitch=a.touchPitch,this.dragRotate=a.dragRotate,this.dragPan=a.dragPan,this.touchZoomRotate=a.touchZoomRotate,this.scrollZoom=a.scrollZoom,this.keyboard=a.keyboard,this._handlerManager=new SL({camera:this._camera,renderLoop:n,canvas:this._canvas,canvasContainer:this._canvasContainer,bearingSnap:t.bearingSnap,dragPan:a.dragPan,registrations:i}).setEventedParent(this),typeof window<`u`&&(this._ownerWindow.addEventListener(`online`,this._onWindowOnline,!1),this._setupResizeObserver());let o=typeof t.hash==`string`&&t.hash||void 0;this._hash=t.hash?new JF(o).addTo(this):void 0,this._hash?._onHashChange()||(this.jumpTo({center:t.center,elevation:t.elevation,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch,roll:t.roll}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,{...t.fitBoundsOptions,duration:0})));let s=typeof t.style==`string`?void 0:t.style?.projection?.type,c=s!==`globe`&&!ET(s);this.resize(null,c),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,this._initialGlobalState=t.globalState,this._transformStyle=t.transformStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new qR(typeof t.attributionControl==`boolean`?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new JR,t.logoPosition),this.on(`style.load`,()=>{if(c||this._resizeCameraView(),this._camera.renderedState.unmodified){let e=Kh(this.style.stylesheet,[`center`,`zoom`,`bearing`,`pitch`,`roll`]);this.jumpTo(e)}}),this.on(`data`,e=>{this._update(e.dataType===`style`),this.fire(e.dataType===`style`?new A4(`styledata`,e):new j4(`sourcedata`,e))}),this.on(`dataloading`,e=>{this.fire(e.dataType===`style`?new A4(`styledataloading`,e):new j4(`sourcedataloading`,e))}),this.on(`dataabort`,e=>{this.fire(new j4(`sourcedataabort`,e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,t){if(t===void 0&&(t=e.getDefaultPosition?e.getDefaultPosition():`top-right`),!e?.onAdd)return this.fire(new c_(Error(`Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.`)));let n=e.onAdd(this);this._controls.push(e);let r=this._controlPositions[t];return t.includes(`bottom`)?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(e){if(!e?.onRemove)return this.fire(new c_(Error(`Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.`)));let t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.includes(e)}coveringTiles(e){return ej(this._camera.projectedCamera,this._camera.context.worldCoordinateHelper,e)}setTransformCameraUpdate(e){this._camera.transformCameraUpdate=e}getCenter(){return this._camera.getCenter()}setCenter(e,t){return this._camera.setCenter(e,t),this}getCenterElevation(){return this._camera.getCenterElevation()}setCenterElevation(e,t){return this._camera.setCenterElevation(e,t),this}setCenterClampedToGround(e){this._camera.setCenterClampedToGround(e)}panBy(e,t,n){return this._camera.panBy(e,t,n),this}panTo(e,t,n){return this._camera.panTo(e,t,n),this}getZoom(){return this._camera.getZoom()}setZoom(e,t){return this._camera.setZoom(e,t),this}zoomTo(e,t,n){return this._camera.zoomTo(e,t,n),this}zoomIn(e,t){return this._camera.zoomIn(e,t),this}zoomOut(e,t){return this._camera.zoomOut(e,t),this}getVerticalFieldOfView(){return this._camera.getVerticalFieldOfView()}setVerticalFieldOfView(e,t){return this._camera.setVerticalFieldOfView(e,t),this}getBearing(){return this._camera.getBearing()}setBearing(e,t){return this._camera.setBearing(e,t),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(e){return this._camera.setZoomSnap(e),this}getPadding(){return this._camera.getPadding()}setPadding(e,t){return this._camera.setPadding(e,t),this}rotateTo(e,t,n){return this._camera.rotateTo(e,t,n),this}resetNorth(e,t){return this._camera.resetNorth(e,t),this}resetNorthPitch(e,t){return this._camera.resetNorthPitch(e,t),this}snapToNorth(e,t){return this._camera.snapToNorth(e,t),this}getPitch(){return this._camera.getPitch()}setPitch(e,t){return this._camera.setPitch(e,t),this}getRoll(){return this._camera.getRoll()}setRoll(e,t){return this._camera.setRoll(e,t),this}cameraForBounds(e,t){return this._camera.cameraForBounds(e,t)}fitBounds(e,t,n){return this._camera.fitBounds(e,t,n),this}fitScreenCoordinates(e,t,n,r,i){return this._camera.fitScreenCoordinates(e,t,n,r,i),this}jumpTo(e,t){return this._camera.jumpTo(e,t),this}calculateAnchoredCameraOptions(e){return this._camera.calculateAnchoredCameraOptions(e)}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,n,r,i){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(e,t,n,r,i)}easeTo(e,t){return this._camera.easeTo(e,t),this}flyTo(e,t){return this._camera.flyTo(e,t),this}stop(){return this._camera.stop(),this._handlerManager?.stop(!1),this}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(Xb.convert(e),this._camera.projectedCamera.tileZoom):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(e,t,n,r){return r==null&&this.terrain&&(r=this.terrain.getElevationForLngLat(n,this._camera.projectedCamera.tileZoom)),$I(this._camera.context).calculateCameraOptionsFromTo(this._camera.renderedState,this._camera.context,e,t,n,r??0)}resize(e,t=!0){if(this._store.getState().styleLostWithContext)return this;this._resizeInternal(t);let n=!this._camera.isMoving();return n&&(this.stop(),this.fire(new O4(`movestart`,e)).fire(new O4(`move`,e))),this.fire(new D4(`resize`,e)),n&&this.fire(new O4(`moveend`,e)),this}_resizeInternal(e=!0){let[t,n]=this._containerDimensions();this._clampedPixelRatio=this._getClampedPixelRatio(t,n),this._resizeCanvas(t,n,this._clampedPixelRatio),this.painter.resize(t,n,this._clampedPixelRatio);let r=this.painter.context.gl;!r.isContextLost()&&this.painter.overLimit()&&(this._maxCanvasSize=[r.drawingBufferWidth,r.drawingBufferHeight],this._clampedPixelRatio=this._getClampedPixelRatio(t,n),this._resizeCanvas(t,n,this._clampedPixelRatio),this.painter.resize(t,n,this._clampedPixelRatio)),this.style?.resize(),this._resizeCameraView(e)}_resizeCameraView(e=!0){let[t,n]=this._containerDimensions();this._camera.resize(t,n,e)}_getClampedPixelRatio(e,t){let{0:n,1:r}=this._maxCanvasSize,i=this.getPixelRatio(),a=e*i,o=t*i,s=a>n?n/a:1,c=o>r?r/o:1,l=Math.min(s,c);return l<1&&ig(`The canvas is larger than maxCanvasSize and is rendered at a lower pixel ratio to fit. Increase maxCanvasSize, within MAX_TEXTURE_SIZE, to render at full resolution.`),l*i}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return Q(this._camera.projectedCamera).getBounds(this._camera.projectedCamera,this._camera.context.worldCoordinateHelper)}getMaxBounds(){return Y8(this._camera.renderedState)}setMaxBounds(e){let t=this.getCenter(),n=this.getZoom();this._camera.applyStateChange((t,n)=>jI(t,n,y8.convert(e))),this._update();let r=this.getCenter(),i=n!==this.getZoom(),a=t.lat!==r.lat||t.lng!==r.lng;return i&&this.fire(new O4(`zoomstart`)).fire(new O4(`zoom`)).fire(new O4(`zoomend`)),(i||a)&&this.fire(new O4(`movestart`)).fire(new O4(`move`)).fire(new O4(`moveend`)),this}setMinZoom(e){if(e??=-2,e>=-2&&e<=this.getMaxZoom()){let t=this.getZoom();return this._camera.applyStateChange((t,n)=>mI(t,n,e)),this._update(),t!==this.getZoom()&&this.fire(new O4(`zoomstart`)).fire(new O4(`zoom`)).fire(new O4(`zoomend`)).fire(new O4(`movestart`)).fire(new O4(`move`)).fire(new O4(`moveend`)),this}throw Error(`minZoom must be between -2 and the current maxZoom, inclusive`)}getMinZoom(e=!1){let t=this._camera.renderedState;return e?QF(t,this._camera.context,t.center,t.minZoom).zoom:t.minZoom}setMaxZoom(e){if(e??=22,e>=this.getMinZoom()){let t=this.getZoom();return this._camera.applyStateChange((t,n)=>hI(t,n,e)),this._update(),t!==this.getZoom()&&this.fire(new O4(`zoomstart`)).fire(new O4(`zoom`)).fire(new O4(`zoomend`)).fire(new O4(`movestart`)).fire(new O4(`move`)).fire(new O4(`moveend`)),this}throw Error(`maxZoom must be greater than the current minZoom`)}getMaxZoom(){return this._camera.renderedState.maxZoom}setMinPitch(e){if(e??=0,e<0)throw Error(`minPitch must be greater than or equal to 0`);if(e>=0&&e<=this.getMaxPitch()){let t=this.getPitch();return this._camera.applyStateChange(t=>gI(t,e)),this._update(),t!==this.getPitch()&&this.fire(new O4(`pitchstart`)).fire(new O4(`pitch`)).fire(new O4(`pitchend`)).fire(new O4(`movestart`)).fire(new O4(`move`)).fire(new O4(`moveend`)),this}throw Error(`minPitch must be between 0 and the current maxPitch, inclusive`)}getMinPitch(){return this._camera.renderedState.minPitch}setMaxPitch(e){if(e??=60,e>180)throw Error(`maxPitch must be less than or equal to 180`);if(e>=this.getMinPitch()){let t=this.getPitch();return this._camera.applyStateChange(t=>_I(t,e)),this._update(),t!==this.getPitch()&&this.fire(new O4(`pitchstart`)).fire(new O4(`pitch`)).fire(new O4(`pitchend`)).fire(new O4(`movestart`)).fire(new O4(`move`)).fire(new O4(`moveend`)),this}throw Error(`maxPitch must be greater than the current minPitch`)}getMaxPitch(){return this._camera.renderedState.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if(e??=20,e>180)throw Error(`anisotropicFilterPitch must be less than or equal to 180`);if(e<0)throw Error(`anisotropicFilterPitch must be greater than or equal to 0`);return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this._camera.renderedState.renderWorldCopies}setRenderWorldCopies(e){return this._camera.applyStateChange((t,n)=>vI(t,n.worldCoordinateHelper,e)),this._update()}setTransformConstrain(e){return this._camera.setConstrainOverride(e??null),this._update()}project(e){let t=this._camera.projectedCamera;return Q(t).locationToScreenPoint(t,this._camera.context.worldCoordinateHelper,Xb.convert(e),this.style&&this.terrain)}unproject(e){return this._camera.unproject(e)}isMoving(){return this._camera.isMoving()||this._handlerManager?.isMoving()||!1}isZooming(){return this._camera.isZooming()||this._handlerManager?.isZooming()||!1}isRotating(){return this._camera.isRotating()||this._handlerManager?.isRotating()||!1}_createDelegates(e,t,n){if(e===`mouseenter`||e===`mouseover`){let r=!1;return{mousemove:i=>{let a=t.filter(e=>this.getLayer(e)),o=a.length===0?[]:this.queryRenderedFeatures(i.point,{layers:a});o.length?r||(r=!0,n.call(this,this._eventFactory.createMouseEvent(e,i.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}if(e===`mouseleave`||e===`mouseout`){let r=!1;return{mousemove:i=>{let a=t.filter(e=>this.getLayer(e));(a.length===0?[]:this.queryRenderedFeatures(i.point,{layers:a})).length?r=!0:r&&(r=!1,n.call(this,this._eventFactory.createMouseEvent(e,i.originalEvent)))},mouseout:t=>{r&&(r=!1,n.call(this,this._eventFactory.createMouseEvent(e,t.originalEvent)))}}}{let r=e=>{let r=t.filter(e=>this.getLayer(e)),i=r.length===0?[]:this.queryRenderedFeatures(e.point,{layers:r});i.length&&(e.features=i,n.call(this,e),delete e.features)};return{[e]:r}}}_addDelegatedListener(e,t){this._delegatedListeners||={},this._delegatedListeners[e]||=[],this._delegatedListeners[e].push(t);for(let e in t.delegates)this.on(e,t.delegates[e])}_removeDelegatedListener(e,t,n){if(!this._delegatedListeners?.[e])return;let r=this._delegatedListeners[e];for(let e=0;et.includes(e))){for(let e in i.delegates)this.off(e,i.delegates[e]);r.splice(e,1);return}}}on(e,t,n){if(n===void 0)return super.on(e,t);let r=typeof t==`string`?[t]:t,i={layers:r,listener:n,delegates:this._createDelegates(e,r,n)};return this._addDelegatedListener(e,i),{unsubscribe:()=>{this._removeDelegatedListener(e,r,n)}}}once(e,t,n){if(n===void 0)return super.once(e,t);let r=typeof t==`string`?[t]:t,i={layers:r,listener:n,delegates:this._createDelegates(e,r,t=>{this._removeDelegatedListener(e,r,n),n.call(this,t)})};return this._addDelegatedListener(e,i),this}off(e,t,n){if(n===void 0)return super.off(e,t);let r=typeof t==`string`?[t]:t;return this._removeDelegatedListener(e,r,n),this}queryRenderedFeatures(e,t){if(!this.style)return[];let n,r=e instanceof U||Array.isArray(e),i=r?e:[[0,0],[this._camera.renderedState.width,this._camera.renderedState.height]];if(t||=(r?{}:e)||{},i instanceof U||typeof i[0]==`number`)n=[U.convert(i)];else{let e=U.convert(i[0]),t=U.convert(i[1]);n=[e,new U(t.x,e.y),t,new U(e.x,t.y),e]}return this.style.queryRenderedFeatures(n,t,this._camera.projectedCamera,this._camera.context.worldCoordinateHelper)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,t){return t={localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle,globalState:this._initialGlobalState,transformStyle:this._transformStyle,...t},this._styleUrl=typeof e==`string`?e:null,t.diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(e,t))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}getTransformRequest(){return this._requestManager.getTransformRequest()}_getUIString(e){let t=this._locale[e];if(t==null)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this._diffStyleRequest?.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded){this.style.once(`style.load`,()=>this._updateStyle(e,t));return}let n=this.style&&t.transformStyle?this.style.serialize():void 0;if(this.style&&(this.style.off(`error`,this._onStyleError),this.style.setEventedParent(null),this.style._remove(!e)),e)this.style=new Zj(this,this._store,t||{});else return this._frameRequest&&=(this._frameRequest.abort(),null),this.style?.projection?.destroy(),delete this.style,this;return this.style.setEventedParent(this,{style:this.style}),this.style.on(`error`,this._onStyleError),typeof e==`string`?this.style.loadURL(e,t,n):this.style.loadJSON(e,t,n),this}_lazyInitEmptyStyle(){this.style||(this.style=new Zj(this,this._store),this.style.setEventedParent(this,{style:this.style}),this.style.on(`error`,this._onStyleError),this.style.loadEmpty())}async _diffStyle(e,t){if(this._diffStyleRequest?.abort(),typeof e==`string`){let n=e;this._diffStyleRequest=new AbortController;let r=this._diffStyleRequest;try{let e=await this._requestManager.transformRequest(n,`Style`);if(r.signal.aborted){this._diffStyleRequest=null;return}let i=await t_(e,r);this._diffStyleRequest=null,this._updateDiff(i.data,t)}catch(e){this._diffStyleRequest=null,kg(e)||this.fire(new c_(Ch(e)))}}else typeof e==`object`&&(this._diffStyleRequest=null,this._updateDiff(e,t))}_updateDiff(e,t){try{this.style.setState(e,t)&&this._update(!0)}catch(n){ig(`Unable to perform style diff: ${Ch(n).message}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}getStyleUrl(){return this._styleUrl}isStyleLoaded(){if(!this.style)ig(`There is no style added to the map.`);else return this.style.loaded()}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){let t=this.style?.tileManagers[e];if(t===void 0)this.fire(new c_(Error(`There is no tile manager with ID '${e}'`)));else return t.loaded()}setTerrain(e,t={}){if(this.style._checkLoaded(),e&&Rw(this,Nw.terrain,{value:e},t))return this;if(this._terrainDataCallback&&this.style.off(`data`,this._terrainDataCallback),!e)this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this.painter.destroyRTTResources(),this._camera.setTerrain(null);else{let t=this.style.tileManagers[e.source];if(!t)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&t.reload();for(let t in this.style._layers){let n=this.style._layers[t];n.type===`hillshade`&&n.source===e.source&&ig(`You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`),n.type===`color-relief`&&n.source===e.source&&ig(`You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`)}this.terrain&&this.terrain.destroy(),this.terrain=new QR(this.painter,t,e,this._store,this._terrainSkirtLength,()=>this._camera.context.worldCoordinateHelper),this.painter.renderToTexture=new IF(this.painter,this.terrain),this._camera.setTerrain(this.terrain),this._terrainDataCallback=t=>this._handleTerrainDataEvent(t,e.source),this.style.on(`data`,this._terrainDataCallback)}return this.style.triggerSymbolPlacement(),this.fire(new Kee({terrain:e})),this}_handleTerrainDataEvent(e,t){if(e.dataType===`style`){this.terrain.tileManager.releaseAllRTT();return}let n=e.sourceId===t;n&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),n&&e.tile&&(this.painter.markTerrainDepthDirty(),this.terrain.tileManager.onDEMTileLoaded()),e.tile&&(e.source?.type===`image`?this.terrain.tileManager.releaseAllRTT():this.terrain.tileManager.releaseRTT(e.tile.tileID))}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let e=this.style?.tileManagers;for(let t of Object.values(e))if(!t.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style?.getSource(e)}setSourceTileLodParams(e,t,n){if(n){let r=this.getSource(n);if(!r)throw Error(`There is no source with ID "${n}", cannot set LOD parameters`);r.calculateTileZoom=QA(Math.max(1,e),Math.max(1,t))}else for(let n in this.style.tileManagers)this.style.tileManagers[n].getSource().calculateTileZoom=QA(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,t){let n=this.style.tileManagers[e];if(!n)throw Error(`There is no tile manager with ID "${e}", cannot refresh tile`);t===void 0?n.reload(!0):n.refreshTiles(t.map(e=>new f8(e.z,e.x,e.y)))}addImage(e,t,n={}){this._lazyInitEmptyStyle();let r=this._createStyleImage(t,n);return r&&(this.style.addImage(e,r),r.userImage?.onAdd&&r.userImage.onAdd(this,e)),this}setMissingStyleImageResolver(e){return this._missingStyleImageResolver=e,this.style?.setMissingImageResolver(e),this}_createStyleImage(e,t={}){let{pixelRatio:n=1,sdf:r=!1,stretchX:i,stretchY:a,content:o,textFitWidth:s,textFitHeight:c}=t;if(e instanceof HTMLImageElement||fg(e)){let{width:t,height:l,data:u}=Pg.getImageData(e);return{data:new _3({width:t,height:l},u),pixelRatio:n,stretchX:i,stretchY:a,content:o,textFitWidth:s,textFitHeight:c,sdf:r,version:0}}if(e.width===void 0||e.height===void 0)return this.fire(new c_(Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`"))),null;{let{width:t,height:l,data:u}=e,d=e,f=RS(d.data);return{data:f?new _3({width:t,height:l}):new _3({width:t,height:l},new Uint8Array(u)),pixelRatio:n,stretchX:i,stretchY:a,content:o,textFitWidth:s,textFitHeight:c,sdf:r,version:0,isWebGLImage:f,userImage:d}}}updateImage(e,t){let n=this.style.getImage(e);if(!n)return this.fire(new c_(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:r,height:i,data:a}=t instanceof HTMLImageElement||fg(t)?Pg.getImageData(t):t;if(r===void 0||i===void 0)return this.fire(new c_(Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(r!==n.data.width||i!==n.data.height)return this.fire(new c_(Error(`The width and height of the updated image must be that same as the previous version of the image`)));if(n.isWebGLImage=RS(a),n.isWebGLImage)n.userImage=t;else{let e=!(t instanceof HTMLImageElement||fg(t));n.data.replace(a,e)}return this.style.updateImage(e,n),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new c_(Error(`Missing required image id`))),!1)}removeImage(e){this.style.removeImage(e)}async loadImage(e){let t=await E4.getImage(await this._requestManager.transformRequest(e,`Image`),new AbortController);if(!t.data)throw Error(`Could not load image ${e}: the response is empty`);return t}listImages(){return this.style?.listImages()??[]}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style?.getLayer(e)}getLayersOrder(){return this.style?.getLayersOrder()??[]}setLayerZoomRange(e,t,n){return this.style.setLayerZoomRange(e,t,n),this._update(!0)}setFilter(e,t,n={}){return this.style?.setFilter(e,t,n),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,n,r={}){return this.style?.setPaintProperty(e,t,n,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,n,r={}){return this.style.setLayoutProperty(e,t,n,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}setFontFaces(e){return this._lazyInitEmptyStyle(),this.style.setFontFaces(e),this._update(!0)}getFontFaces(){return this.style.getFontFaces()}addSprite(e,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,n,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=Math.floor(this._container.clientWidth)||400,t=Math.floor(this._container.clientHeight)||300),[e,t]}_shouldHandleInitialResize(){if(!this._container?.clientWidth||!this._container.clientHeight)return!1;let[e,t]=this._containerDimensions();return e!==this._camera.renderedState.width||t!==this._camera.renderedState.height}_setupResizeObserver(){let e=!1,t=qF(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50),n=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new n(n=>{!e&&(e=!0,!this._shouldHandleInitialResize())||t(n)}),this._resizeObserver.observe(this._container)}_resolveContainer(e){if(typeof e==`string`){let t=document.getElementById(e);if(!t)throw Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement||e&&typeof e==`object`&&e.nodeType===1)return e;throw Error(`Invalid type: 'container' must be a String or HTMLElement.`)}_setupContainer(){let e=this._containerDimensions(),t=this._getClampedPixelRatio(e[0],e[1]),n=this._container;n.classList.add(`maplibregl-map`);let r=this._canvasContainer=Gg.create(`div`,`maplibregl-canvas-container`,n);this._interactive&&r.classList.add(`maplibregl-interactive`),this._canvas=Gg.create(`canvas`,`maplibregl-canvas`,r),this._canvas.addEventListener(`webglcontextlost`,this._contextLost,!1),this._canvas.addEventListener(`webglcontextrestored`,this._contextRestored,!1),this._canvas.setAttribute(`tabindex`,this._interactive?`0`:`-1`),this._canvas.setAttribute(`aria-label`,this._getUIString(`Map.Title`)),this._canvas.setAttribute(`role`,`region`),this._resizeCanvas(e[0],e[1],t);let i=this._controlContainer=Gg.create(`div`,`maplibregl-control-container`,n),a=this._controlPositions={};for(let e of[`top-left`,`top-right`,`bottom-left`,`bottom-right`])a[e]=Gg.create(`div`,`maplibregl-ctrl-${e} `,i);this._container.addEventListener(`scroll`,this._onMapScroll,!1)}_cleanupContainer(){this._canvas.removeEventListener(`webglcontextrestored`,this._contextRestored,!1),this._canvas.removeEventListener(`webglcontextlost`,this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener(`scroll`,this._onMapScroll,!1),this._container.classList.remove(`maplibregl-map`)}_resizeCanvas(e,t,n){let r=Math.round(n*e),i=Math.round(n*t);this._canvas.width=r,this._canvas.height=i,this._canvas.style.width=`${r/n}px`,this._canvas.style.height=`${i/n}px`}_setupPainter(){let e={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},t=null;this._canvas.addEventListener(`webglcontextcreationerror`,e=>{t=e},{once:!0});let n=this._canvas.getContext(`webgl2`,e);if(!n)throw new KF(e,t);this.painter=new GF(n)}migrateProjection(e,t){this._camera.migrateProjection(e,t),this.fire(new qee({newProjection:this.style.projection.name}))}_warnAboutUnrestorableLayers(){for(let e of Object.values(this.style._layers))if(e.type===`custom`&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(let[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`)}_createStyleSnapshot(){let e=this.style.imageManager.cloneImages(),t=this.style.serialize();this._store.setState(({style:n})=>({style:t?{definition:t,options:{},images:e}:{...n,images:e}}))}_restoreStyleSnapshot(){let{definition:e,options:t,images:n}=this._store.getState().style;if(e&&(this.setStyle(e,{...t,diff:!1}),this.style)){this.style.imageManager.images=n;for(let[e,t]of Object.entries(n))t.isWebGLImage&&this.style.imageManager.updateImage(e,t,!1)}}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?._loaded&&(this._styleDirty||=e,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(e){return this._update(),this.triggerRepaint(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){let t=this._idleTriggered?this._fadeDuration:0,n=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let r=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let e=this._camera.renderedState.zoom,n=Ig();this.style.zoomHistory.update(e,n);let i=new F4(e,{now:n,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),a=i.crossFadingFactor();(a!==1||a!==this._crossFadingFactor)&&(r=!0,this._crossFadingFactor=a),this.style.update(i)}let i=this.style.projection?.transitionState>0!==n;this._camera.setProjectionTransition(this.style.projection?.transitionState),this.style&&(this._sourcesDirty||i)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.projectedCamera,this._camera.context.worldCoordinateHelper)),this.terrain&&this.terrain.tileManager.update(this._camera.projectedCamera,this._camera.context.worldCoordinateHelper,this.terrain)&&this.terrain.resetElevationCache(),this._camera.followTerrain(),this._placementDirty=this.style?._updatePlacement(this._camera.projectedCamera,this._camera.context.worldCoordinateHelper,this.showCollisionBoxes,t,this._crossSourceCollisions,i);let a=this.style.projection,o=a?.transitionState??0;this.painter.render(this.style,this._camera.projectedCamera,this._camera.context.worldCoordinateHelper,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,symbolFadeChange:this.style.placement.symbolFadeChange(Ig()),variableOffsets:this.style.placement.variableOffsets,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch(),projectionTransition:o,isRenderingGlobe:o>0,projectionShaderVariant:a?{name:a.shaderVariantName,define:a.shaderDefine,prelude:a.shaderPreludeCode}:void 0,useSubdivision:a?.useSubdivision??!1,pixelRatio:this._clampedPixelRatio,light:this.style.light?.getEvaluated(),sky:this.style.sky?.getEvaluated()}),this.fire(new D4(`render`)),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new D4(`load`))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let s=this._sourcesDirty||this._styleDirty||this._placementDirty||this.painter.renderToTexture?.needsFollowUpFrame;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new D4(`idle`)),this._loaded&&!this._fullyLoaded&&!s&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(let e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),this._diffStyleRequest?.abort(),this.painter.destroy(),this._handlerManager.destroy(),C4().off(`restart`,this._handleWorkersRestarted),this.setStyle(null),typeof window<`u`&&this._ownerWindow.removeEventListener(`online`,this._onWindowOnline,!1),E4.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let e=this.painter.context.gl.getExtension(`WEBGL_lose_context`);e?.loseContext&&e.loseContext(),this._cleanupContainer(),this._removed=!0,this.fire(new D4(`remove`))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Pg.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(e){if(!kg(e))throw e}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return ez}getCameraTargetElevation(){return this._camera.renderedState.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},rz={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0},iz=class{constructor(e){this._updateZoomButtons=()=>{let e=this._map.getZoom(),t=e===this._map.getMaxZoom(),n=e===this._map.getMinZoom(!0);this._zoomInButton.disabled=t,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute(`aria-disabled`,t.toString()),this._zoomOutButton.setAttribute(`aria-disabled`,n.toString())},this._rotateCompassArrow=()=>{let e=this._map.getPitch(),t=this._map.getRoll(),n=this._map.getBearing(),r=1/Math.cos(hg(e))**.5;this.options.visualizePitch&&this.options.visualizeRoll?this._compassIcon.style.transform=`scale(${r}) rotateZ(${-t}deg) rotateX(${e}deg) rotateZ(${-n}deg)`:this.options.visualizePitch?this._compassIcon.style.transform=`scale(${r}) rotateX(${e}deg) rotateZ(${-n}deg)`:this.options.visualizeRoll?this._compassIcon.style.transform=`rotate(${-n-t}deg)`:this._compassIcon.style.transform=`rotate(${-n}deg)`},this._setButtonTitle=(e,t)=>{let n=this._map._getUIString(`NavigationControl.${t}`);e.title=n,e.setAttribute(`aria-label`,n)},this.options={...rz,...e},this._subscriptions=[],this._container=Gg.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._container.addEventListener(`contextmenu`,e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton(`maplibregl-ctrl-zoom-in`,e=>this._map.zoomIn({},{originalEvent:e})),Gg.create(`span`,`maplibregl-ctrl-icon`,this._zoomInButton).setAttribute(`aria-hidden`,`true`),this._zoomOutButton=this._createButton(`maplibregl-ctrl-zoom-out`,e=>this._map.zoomOut({},{originalEvent:e})),Gg.create(`span`,`maplibregl-ctrl-icon`,this._zoomOutButton).setAttribute(`aria-hidden`,`true`)),this.options.showCompass&&(this._compass=this._createButton(`maplibregl-ctrl-compass`,e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=Gg.create(`span`,`maplibregl-ctrl-icon`,this._compass),this._compassIcon.setAttribute(`aria-hidden`,`true`))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,`ZoomIn`),this._setButtonTitle(this._zoomOutButton,`ZoomOut`),this._map.on(`move`,this._updateZoomButtons),this._subscriptions.push(IR(e._store,e=>e.camera.view.minZoom,this._updateZoomButtons),IR(e._store,e=>e.camera.view.maxZoom,this._updateZoomButtons)),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,`ResetBearing`),this.options.visualizePitch&&this._map.on(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on(`roll`,this._rotateCompassArrow),this._map.on(`rotate`,this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new az(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off(`move`,this._updateZoomButtons);for(let e of this._subscriptions)e();this._subscriptions=[],this.options.showCompass&&(this.options.visualizePitch&&this._map.off(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off(`roll`,this._rotateCompassArrow),this._map.off(`rotate`,this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){let n=Gg.create(`button`,e,this._container);return n.type=`button`,n.addEventListener(`click`,t),n}},az=class{constructor(e,t,n=!1){this.mousedown=e=>{this.startMove(e,Gg.mousePos(this.element,e)),window.addEventListener(`mousemove`,this.mousemove),window.addEventListener(`mouseup`,this.mouseup)},this.mousemove=e=>{this.move(e,Gg.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{e.targetTouches.length===1?(this._startPos=this._lastPos=Gg.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),window.addEventListener(`touchmove`,this.touchmove,{passive:!1}),window.addEventListener(`touchend`,this.touchend)):this.reset()},this.touchmove=e=>{e.targetTouches.length===1?(this._lastPos=Gg.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos)):this.reset()},this.touchend=e=>{e.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=t;let r=new RL;this._rotatePitchHandler=new NL({clickTolerance:3,move:(e,r)=>{let i=t.getBoundingClientRect(),a=new U((i.bottom-i.top)/2,(i.right-i.left)/2);return{bearingDelta:yg(new U(e.x,r.y),r,a),pitchDelta:n?(r.y-e.y)*-.5:void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,t.addEventListener(`mousedown`,this.mousedown),t.addEventListener(`touchstart`,this.touchstart,{passive:!1}),t.addEventListener(`touchcancel`,this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),Gg.disableDrag()}move(e,t){let n=this.map,{bearingDelta:r,pitchDelta:i}=this._rotatePitchHandler.dragMove(e,t)||{};r&&n.setBearing(n.getBearing()+r),i&&n.setPitch(n.getPitch()+i)}off(){let e=this.element;e.removeEventListener(`mousedown`,this.mousedown),e.removeEventListener(`touchstart`,this.touchstart),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend),e.removeEventListener(`touchcancel`,this.reset),this.offTemp()}offTemp(){Gg.enableDrag(),window.removeEventListener(`mousemove`,this.mousemove),window.removeEventListener(`mouseup`,this.mouseup),window.removeEventListener(`touchmove`,this.touchmove),window.removeEventListener(`touchend`,this.touchend)}};function oz(e,t,n,r,i=!1){if(i||!XA(n).allowWorldCopies())return e?.wrap();if(!r.wraps)return e;if(!n.renderWorldCopies)return Math.abs(e?.lng)<=180?e:e?.wrap();let a=new Xb(e.lng,e.lat);if(e=new Xb(e.lng,e.lat),t){let i=new Xb(e.lng-360,e.lat),a=new Xb(e.lng+360,e.lat),o=Q(n).locationToScreenPoint(n,r,e).distSqr(t);Q(n).locationToScreenPoint(n,r,i).distSqr(t)180;){let t=Q(n).locationToScreenPoint(n,r,e);if(t.x>=0&&t.y>=0&&t.x<=n.width&&t.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e.lng!==a.lng&&Q(n).isPointOnMapSurface(n,r,Q(n).locationToScreenPoint(n,r,e))?e:a}var sz={center:`translate(-50%,-50%)`,top:`translate(-50%,0)`,"top-left":`translate(0,0)`,"top-right":`translate(-100%,0)`,bottom:`translate(-50%,-100%)`,"bottom-left":`translate(0,-100%)`,"bottom-right":`translate(-100%,-100%)`,left:`translate(0,-50%)`,right:`translate(-100%,-50%)`};function cz(e,t,n){let r=e.classList;for(let e in sz)r.remove(`maplibregl-${n}-anchor-${e}`);r.add(`maplibregl-${n}-anchor-${t}`)}var lz={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},uz=`#3FB1CE`;function dz(e,t,n=[]){let r=Gg.createNS(`http://www.w3.org/2000/svg`,e);for(let e in t)r.setAttributeNS(null,e,t[e]);for(let e of n)r.appendChild(e);return r}var fz;function pz(){return fz||(fz=dz(`svg`,{display:`block`,height:`41px`,width:`27px`,viewBox:`0 0 27 41`},[dz(`g`,{"fill-rule":`nonzero`},[dz(`g`,{transform:`translate(3.0, 29.0)`,fill:`#000000`},[[`10.5`,`5.25002273`],[`10.5`,`5.25002273`],[`9.5`,`4.77275007`],[`8.5`,`4.29549936`],[`7.5`,`3.81822308`],[`6.5`,`3.34094679`],[`5.5`,`2.86367051`],[`4.5`,`2.38636864`]].map(([e,t])=>dz(`ellipse`,{opacity:`0.04`,cx:`10.5`,cy:`5.80029008`,rx:e,ry:t}))),dz(`g`,{fill:uz},[dz(`path`,{d:`M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z`})]),dz(`g`,{opacity:`0.25`,fill:`#000000`},[dz(`path`,{d:`M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z`})]),dz(`g`,{transform:`translate(6.0, 7.0)`,fill:`#FFFFFF`}),dz(`g`,{transform:`translate(8.0, 8.0)`},[dz(`circle`,{fill:`#000000`,opacity:`0.25`,cx:`5.5`,cy:`5.5`,r:`5.4999962`}),dz(`circle`,{fill:`#FFFFFF`,cx:`5.5`,cy:`5.5`,r:`5.4999962`})])])]),fz)}function mz(e){return e.firstElementChild.children[1]}var hz=class extends s_{},gz=class extends s_{},_z=class extends l_{constructor(e){if(super(),this._onClick=e=>{this.fire(new gz(`click`,{originalEvent:e}))},this._onKeyPress=e=>{(e.code===`Space`||e.code===`Enter`)&&this.togglePopup()},this._onKeyDown=e=>{if(!this._defaultMarker||!this._draggable||!this._map||!this._lngLat||e.composedPath()[0]!==this._element||e.altKey||e.ctrlKey||e.metaKey)return;let t=lz[e.key];if(!t)return;e.preventDefault(),e.stopPropagation();let n=e.shiftKey?10:1,r=this._map.project(this._lngLat);this.setLngLat(this._map.unproject(new U(r.x+t[0]*n,r.y+t[1]*n))),this._keyboardDragActive||(this._keyboardDragActive=!0,this.fire(new hz(`dragstart`))),this.fire(new hz(`drag`))},this._onKeyUp=e=>{lz[e.key]&&this._endKeyboardDrag()},this._onBlur=()=>{this._endKeyboardDrag()},this._onMapClick=e=>{let t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.contains(t))&&this.togglePopup()},this._updateCoveredUnthrottled=()=>{let e=this._map?.terrain;if(!e||!this._isInViewport())return;let t=this._isCovered(e);t&&this._popup?.isOpen()&&this._popup.remove(),this._element.style.opacity=t?this._opacityWhenCovered:this._opacity,this._element.classList.toggle(`maplibregl-marker-covered`,t)},this._updateCovered=qF(this._updateCoveredUnthrottled,100),this._update=e=>{if(!this._map)return;this._lngLat=oz(this._lngLat,this._flatPos,this._map._camera.projectedCamera,this._map._camera.context.worldCoordinateHelper),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=Q(this._map._camera.projectedCamera).locationToScreenPoint(this._map._camera.projectedCamera,this._map._camera.context.worldCoordinateHelper,this._lngLat)._add(this._offset));let t=``;this._rotationAlignment===`viewport`||this._rotationAlignment===`auto`?t=`rotateZ(${this._rotation}deg)`:this._rotationAlignment===`map`&&(t=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let n=``;this._pitchAlignment===`viewport`||this._pitchAlignment===`auto`?n=`rotateX(0deg)`:this._pitchAlignment===`map`&&(n=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&e?.type!==`move`&&(this._pos=this._pos.round()),this._element.style.transform=`${sz[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${n} ${t}`,this._updateOpacity()},this._onMove=e=>{if(!this._isDragging){let t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents=`none`,this._state===`pending`&&(this._state=`active`,this.fire(new hz(`dragstart`))),this.fire(new hz(`drag`)))},this._onUp=()=>{this._element.style.pointerEvents=`auto`,this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off(`mousemove`,this._onMove),this._map.off(`touchmove`,this._onMove),this._state===`active`&&this.fire(new hz(`dragend`)),this._state=`inactive`},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state=`pending`,this._map.on(`mousemove`,this._onMove),this._map.on(`touchmove`,this._onMove),this._map.once(`mouseup`,this._onUp),this._map.once(`touchend`,this._onUp))},this._anchor=e?.anchor||`center`,this._color=e?.color||uz,this._scale=e?.scale||1,this._draggable=e?.draggable||!1,this._clickTolerance=e?.clickTolerance||0,this._subpixelPositioning=e?.subpixelPositioning||!1,this._isDragging=!1,this._roleManaged=!1,this._tabIndexManaged=!1,this._keyboardDragActive=!1,this._state=`inactive`,this._rotation=e?.rotation||0,this._rotationAlignment=e?.rotationAlignment||`auto`,this._pitchAlignment=e?.pitchAlignment&&e.pitchAlignment!==`auto`?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e?.opacity,e?.opacityWhenCovered),e?.element)this._element=e.element,this._offset=U.convert(e?.offset||[0,0]);else{this._defaultMarker=!0,this._element=Gg.create(`div`);let t=pz().cloneNode(!0);t.setAttributeNS(null,`height`,`${41*this._scale}px`),t.setAttributeNS(null,`width`,`${27*this._scale}px`),mz(t).setAttributeNS(null,`fill`,this._color),this._element.appendChild(t),this._offset=U.convert(e?.offset||[0,-14])}if(this._element.classList.add(`maplibregl-marker`),this._element.addEventListener(`dragstart`,e=>{e.preventDefault()}),this._element.addEventListener(`mousedown`,e=>{e.preventDefault()}),cz(this._element,this._anchor,`marker`),e?.className)for(let t of e.className.split(` `))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._defaultMarker&&!this._element.hasAttribute(`aria-label`)&&this._element.setAttribute(`aria-label`,e._getUIString(`Marker.Title`)),this._updateAccessibilityRole(),e.getCanvasContainer().appendChild(this._element),e.on(`move`,this._update),e.on(`moveend`,this._update),e.on(`terrain`,this._update),e.on(`projectiontransition`,this._update),e.on(`idle`,this._update),this._element.addEventListener(`click`,this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on(`click`,this._onMapClick),this}remove(){return this._map&&(this._map.off(`click`,this._onMapClick),this._map.off(`move`,this._update),this._map.off(`moveend`,this._update),this._map.off(`terrain`,this._update),this._map.off(`projectiontransition`,this._update),this._map.off(`idle`,this._update),this._map.off(`mousedown`,this._addDragHandler),this._map.off(`touchstart`,this._addDragHandler),this._map.off(`mouseup`,this._onUp),this._map.off(`touchend`,this._onUp),this._map.off(`mousemove`,this._onMove),this._map.off(`touchmove`,this._onMove),delete this._map),this._element.removeEventListener(`click`,this._onClick),this._element.removeEventListener(`keydown`,this._onKeyDown),this._element.removeEventListener(`keyup`,this._onKeyUp),this._element.removeEventListener(`blur`,this._onBlur),this._element.removeEventListener(`keypress`,this._onKeyPress),this._keyboardDragActive=!1,this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=Xb.convert(e),this._pos=null,this._update(),this._popup&&this._popup.setLngLat(this._lngLat),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener(`keypress`,this._onKeyPress)),e){if(!(`offset`in e.options)){let t=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[t,(24.6+t)*-1],"bottom-right":[-t,(24.6+t)*-1],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=e,this._element.addEventListener(`keypress`,this._onKeyPress)}return this._updateTabIndex(),this._updateAccessibilityRole(),this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}_endKeyboardDrag(){this._keyboardDragActive&&(this._keyboardDragActive=!1,this.fire(new hz(`dragend`)))}getPopup(){return this._popup}togglePopup(){let e=this._popup;if(this._element.style.opacity===this._opacityWhenCovered)return this;if(e)e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map));else return this;return this}_updateOpacity(){if(!this._isInViewport())return;let e=this._map?.terrain,t=Q(this._map._camera.projectedCamera).isLocationOccluded(this._map._camera.projectedCamera,this._map._camera.context.worldCoordinateHelper,this._lngLat);if(!e||t){let e=t?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==e&&(this._element.style.opacity=e,this._element.classList.toggle(`maplibregl-marker-covered`,t))}else this._updateCovered()}_isInViewport(){let{width:e,height:t}=this._map._camera.renderedState;return!!this._pos&&this._pos.x>=0&&this._pos.y>=0&&this._pos.x<=e&&this._pos.y<=t}_isCovered(e){let t=this._map._camera.projectedCamera,n=e.getElevationForLngLat(this._lngLat,t.tileZoom),r=Math.max(0,-this._offset.y)/t.pixelsPerMeter,i=Math.sin(this._map.getPitch()*Math.PI/180)*r;return Q(t).isLocationOccluded(t,this._map._camera.context.worldCoordinateHelper,this._lngLat,e,n+i)}getOffset(){return this._offset}setOffset(e){return this._offset=U.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._element.classList.toggle(`maplibregl-marker-draggable`,this._draggable),this._map&&(e?(this._map.on(`mousedown`,this._addDragHandler),this._map.on(`touchstart`,this._addDragHandler)):(this._map.off(`mousedown`,this._addDragHandler),this._map.off(`touchstart`,this._addDragHandler))),this._defaultMarker&&(this._draggable?(this._element.addEventListener(`keydown`,this._onKeyDown),this._element.addEventListener(`keyup`,this._onKeyUp),this._element.addEventListener(`blur`,this._onBlur)):(this._element.removeEventListener(`keydown`,this._onKeyDown),this._element.removeEventListener(`keyup`,this._onKeyUp),this._element.removeEventListener(`blur`,this._onBlur),this._endKeyboardDrag())),this._updateTabIndex(),this._updateAccessibilityRole(),this}isDraggable(){return this._draggable}_updateTabIndex(){this._popup||this._defaultMarker&&this._draggable?this._element.hasAttribute(`tabindex`)||(this._element.setAttribute(`tabindex`,`0`),this._tabIndexManaged=!0):this._tabIndexManaged&&=(this._element.getAttribute(`tabindex`)===`0`&&this._element.removeAttribute(`tabindex`),!1)}_updateAccessibilityRole(){if(!this._defaultMarker||this._element.hasAttribute(`role`)&&!this._roleManaged)return;let e=this._draggable||this._popup?`button`:`img`;this._element.setAttribute(`role`,e),this._roleManaged=!0}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||`auto`,this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!==`auto`?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(this._opacity===void 0||e===void 0&&t===void 0)&&(this._opacity=`1`,this._opacityWhenCovered=`0.2`),e!==void 0&&(this._opacity=String(e)),t!==void 0&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(),this}},vz={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:``,maxWidth:`240px`,subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},yz=class extends s_{},bz=class extends l_{constructor(e){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(Q(this._map._camera.projectedCamera).isLocationOccluded(this._map._camera.projectedCamera,this._map._camera.context.worldCoordinateHelper,this.getLngLat())?this._container.style.opacity=`${this.options.locationOccludedOpacity}`:this._container.style.opacity=``)},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off(`move`,this._update),this._map.off(`move`,this._onClose),this._map.off(`click`,this._onClose),this._map.off(`remove`,this.remove),this._map.off(`terrain`,this._update),this._map.off(`projectiontransition`,this._update),this._map.off(`idle`,this._update),this._map.off(`mousemove`,this._update),this._map.off(`mouseup`,this._update),this._map.off(`drag`,this._update),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`),delete this._map,this.fire(new yz(`close`))),this),this._update=e=>{let t=this._lngLat||this._trackPointer;if(!this._map||!t||!this._content)return;if(!this._container){if(this._container=Gg.create(`div`,`maplibregl-popup`,this._map.getContainer()),this._tip=Gg.create(`div`,`maplibregl-popup-tip`,this._container),this._container.appendChild(this._content),this.options.className)for(let e of this.options.className.split(` `))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute(`aria-label`,this._map._getUIString(`Popup.Close`)),this._trackPointer&&this._container.classList.add(`maplibregl-popup-track-pointer`)}this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=oz(this._lngLat,this._flatPos,this._map._camera.projectedCamera,this._map._camera.context.worldCoordinateHelper,this._trackPointer);let n;if(e&&`point`in e&&e.point&&(n=e.point),this._trackPointer&&!n)return;let r=this._flatPos=this._pos=this._trackPointer&&n?n:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&n?n:Q(this._map._camera.projectedCamera).locationToScreenPoint(this._map._camera.projectedCamera,this._map._camera.context.worldCoordinateHelper,this._lngLat));let i=this.options.anchor,a=xz(this.options.offset);if(!i){let e=this._container.offsetWidth,t=this._container.offsetHeight,n=Sz(this.options.padding),o;o=r.y+a.bottom.ythis._map._camera.renderedState.height-t-n.bottom?[`bottom`]:[],r.xthis._map._camera.renderedState.width-e/2-n.right&&o.push(`right`),i=o.length===0?`bottom`:o.join(`-`)}let o=r.add(a[i]);this.options.subpixelPositioning||(o=o.round()),this._container.style.transform=`${sz[i]} translate(${o.x}px,${o.y}px)`,cz(this._container,i,`popup`),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options={...vz,...e}}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on(`click`,this._onClose),this.options.closeOnMove&&this._map.on(`move`,this._onClose),this._map.on(`remove`,this.remove),this._map.on(`terrain`,this._update),this._map.on(`projectiontransition`,this._update),this._map.on(`idle`,this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on(`mousemove`,this._update),this._map.on(`mouseup`,this._update),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)):this._map.on(`move`,this._update),this.fire(new yz(`open`)),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=Xb.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on(`move`,this._update),this._map.off(`mousemove`,this._update),this._container&&this._container.classList.remove(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`)),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off(`move`,this._update),this._map.on(`mousemove`,this._update),this._map.on(`drag`,this._update),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let t=document.createDocumentFragment(),n=document.createElement(`body`),r;for(n.innerHTML=e;r=n.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=Gg.create(`div`,`maplibregl-popup-content`,this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=Gg.create(`button`,`maplibregl-popup-close-button`,this._content),this._closeButton.type=`button`,this._closeButton.textContent=`×`,this._closeButton.addEventListener(`click`,this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(`a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])`);e&&e.focus()}};function xz(e){if(!e)return xz(new U(0,0));if(typeof e==`number`){let t=Math.round(Math.abs(e)/Math.SQRT2);return{center:new U(0,0),top:new U(0,e),"top-left":new U(t,t),"top-right":new U(-t,t),bottom:new U(0,-e),"bottom-left":new U(t,-t),"bottom-right":new U(-t,-t),left:new U(e,0),right:new U(-e,0)}}if(e instanceof U||Array.isArray(e)){let t=U.convert(e);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:U.convert(e.center||[0,0]),top:U.convert(e.top||[0,0]),"top-left":U.convert(e[`top-left`]||[0,0]),"top-right":U.convert(e[`top-right`]||[0,0]),bottom:U.convert(e.bottom||[0,0]),"bottom-left":U.convert(e[`bottom-left`]||[0,0]),"bottom-right":U.convert(e[`bottom-right`]||[0,0]),left:U.convert(e.left||[0,0]),right:U.convert(e.right||[0,0])}}function Sz(e){return e?{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}:{top:0,right:0,bottom:0,left:0}}var Cz={id:`baltic-shadow`,title:`BALTIC SHADOW`,tagline:`Signals in the Northern Flank`,description:`A fictional crisis involving unusual naval activity, infrastructure concerns, and information operations in the Baltic region. All entities and incidents are synthetic.`,startDate:`2026-11-15`,resourceBudget:100,events:[{id:`e1`,t:`T+0h`,title:`AIS Gaps Near Gotland`,description:`Multiple commercial vessels show prolonged AIS gaps in a corridor east of Gotland. Pattern is anomalous but not unique.`,lat:57.5,lng:18.5,confidence:`Moderate`,color:`#ffb300`},{id:`e2`,t:`T+6h`,title:`Official Denial Issued`,description:`Fictional State A issues a statement denying any unusual naval activity and attributing gaps to weather.`,lat:59.9,lng:24.7,confidence:`High`,color:`#00e5ff`},{id:`e3`,t:`T+12h`,title:`Infrastructure Alert`,description:`Unconfirmed report of unusual activity near a fictional undersea cable landing point.`,lat:56.95,lng:24.1,confidence:`Low`,color:`#f43f5e`},{id:`e4`,t:`T+18h`,title:`Social Media Amplification`,description:`Coordinated accounts begin circulating unverified claims of 'invasion preparations'.`,confidence:`Moderate`,color:`#a78bfa`},{id:`e5`,t:`T+24h`,title:`Satellite Request Logged`,description:`Analyst team initiates commercial satellite tasking over the corridor.`,confidence:`High`,color:`#22d3ee`}],evidence:[{id:`ev1`,source:`AIS Aggregator (synthetic)`,sourceType:`AIS`,pubDate:`2026-11-15T08:00Z`,eventDate:`2026-11-15T04:00Z`,reliability:4,credibility:3,confidence:`Moderate`,summary:`Three vessels with AIS gaps lasting 4–6 hours in the eastern Gotland corridor.`,notes:`Gaps alone are not conclusive. Weather was moderate.`,tags:[`naval`,`ais`]},{id:`ev2`,source:`Fictional State A MFA`,sourceType:`Official`,pubDate:`2026-11-15T14:00Z`,eventDate:`2026-11-15T14:00Z`,reliability:5,credibility:4,confidence:`High`,summary:`Official denial of unusual activity. Attributes gaps to weather and routine exercises.`,notes:`High reliability source. Statement does not address all reported gaps.`,tags:[`diplomatic`]},{id:`ev3`,source:`Regional Media Outlet B`,sourceType:`Media`,pubDate:`2026-11-15T20:00Z`,eventDate:`2026-11-15T18:00Z`,reliability:2,credibility:2,confidence:`Low`,summary:`Claims of 'military preparations' near cable infrastructure. Single anonymous source.`,notes:`Low credibility. No corroboration. Possible amplification of unverified claim.`,tags:[`infrastructure`,`disinfo`]},{id:`ev4`,source:`Social Monitoring (synthetic)`,sourceType:`Social`,pubDate:`2026-11-16T02:00Z`,eventDate:`2026-11-15T22:00Z`,reliability:3,credibility:2,confidence:`Moderate`,summary:`Coordinated hashtag activity repeating the media claim within 4 hours of publication.`,notes:`Pattern consistent with amplification, not organic discussion.`,tags:[`disinfo`,`social`]}],decisions:[{id:`d1`,title:`Allocate Satellite Tasking`,cost:30,description:`Task commercial satellite over the corridor. Reduces uncertainty on naval presence.`,consequence:`High confidence update on vessel activity. Reveals routine exercise, not hostile concentration.`},{id:`d2`,title:`Diplomatic Inquiry`,cost:15,description:`Request clarification from State A on exercise schedule.`,consequence:`Official confirmation of routine exercise. Reduces escalation risk.`},{id:`d3`,title:`Public Clarification`,cost:10,description:`Issue measured statement on available evidence and uncertainty.`,consequence:`Slows disinformation spread. Maintains analytical credibility.`},{id:`d4`,title:`Hold Resources`,cost:0,description:`Continue monitoring without new collection.`,consequence:`Uncertainty persists. Disinformation continues to circulate.`}]};function wz(){let e=(0,_.useRef)(null),t=(0,_.useRef)(null),n=Cz;return(0,_.useEffect)(()=>{if(e.current&&!t.current)return t.current=new nz({container:e.current,style:{version:8,sources:{osm:{type:`raster`,tiles:[`https://tile.openstreetmap.org/{z}/{x}/{y}.png`],tileSize:256,attribution:`© OpenStreetMap`}},layers:[{id:`osm`,type:`raster`,source:`osm`}]},center:[22,57],zoom:5.2,attributionControl:!1}),t.current.addControl(new iz({showCompass:!1}),`top-right`),n.events.forEach(e=>{if(!e.lat||!e.lng)return;let n=document.createElement(`div`);n.style.cssText=` width: 16px; height: 16px; border-radius: 50%; background: ${e.color}; border: 2px solid white; box-shadow: 0 0 12px ${e.color}; cursor: pointer; `,new _z(n).setLngLat([e.lng,e.lat]).setPopup(new bz({offset:20}).setHTML(`
${e.title}
${e.t} • ${e.confidence}
${e.description}
`)).addTo(t.current)}),()=>{t.current?.remove(),t.current=null}},[n]),(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl p-5`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold text-cyan-400`,children:n.title}),(0,H.jsx)(`p`,{className:`text-sm text-slate-400 mt-1`,children:n.tagline})]}),(0,H.jsxs)(`div`,{className:`text-right text-xs`,children:[(0,H.jsxs)(`div`,{className:`text-amber-400 font-mono`,children:[`RES `,n.resourceBudget]}),(0,H.jsxs)(`div`,{className:`text-slate-500`,children:[`Started `,n.startDate]})]})]}),(0,H.jsx)(`p`,{className:`text-sm text-slate-300 mt-3`,children:n.description})]}),(0,H.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-4`,children:[{label:`Events`,value:n.events.length.toString()},{label:`Evidence Items`,value:n.evidence.length.toString()},{label:`Avg Confidence`,value:`Moderate`},{label:`Resource Budget`,value:n.resourceBudget.toString()}].map(e=>(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl p-4`,children:[(0,H.jsx)(`div`,{className:`text-xs text-slate-500 uppercase tracking-wider`,children:e.label}),(0,H.jsx)(`div`,{className:`text-2xl font-semibold mt-1`,children:e.value})]},e.label))}),(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl overflow-hidden h-[480px] relative`,children:[(0,H.jsx)(`div`,{ref:e,className:`w-full h-full`}),(0,H.jsx)(`div`,{className:`absolute top-4 left-4 bg-navy-900/80 backdrop-blur px-3 py-1.5 rounded text-xs border border-navy-700`,children:`Baltic Theatre • Simulated Layer`})]}),(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl p-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-cyan-400 mb-4`,children:`Crisis Timeline`}),(0,H.jsx)(`div`,{className:`space-y-3`,children:n.events.map(e=>(0,H.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,H.jsx)(`div`,{className:`text-amber-400 font-mono text-xs w-16 flex-shrink-0 pt-0.5`,children:e.t}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-medium`,children:e.title}),(0,H.jsx)(`div`,{className:`text-slate-400 text-xs mt-0.5`,children:e.description})]})]},e.id))})]})]})}var Tz={"Very High":`text-emerald-400`,High:`text-cyan-400`,Moderate:`text-amber-400`,Low:`text-orange-400`,Unknown:`text-slate-500`};function Ez(){let e=Cz.evidence;return(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold text-cyan-400`,children:`OSINT Intelligence Desk`}),(0,H.jsx)(`p`,{className:`text-sm text-slate-400 mt-1`,children:`Evidence repository for BALTIC SHADOW. All sources are synthetic.`})]}),(0,H.jsx)(`div`,{className:`grid gap-4`,children:e.map(e=>(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl p-5`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-mono text-slate-500`,children:e.id}),(0,H.jsx)(`span`,{className:`text-xs font-medium ${Tz[e.confidence]}`,children:e.confidence}),(0,H.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-navy-700 text-slate-300`,children:e.sourceType})]}),(0,H.jsx)(`h3`,{className:`font-medium`,children:e.summary}),(0,H.jsx)(`p`,{className:`text-sm text-slate-400 mt-2`,children:e.notes}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-3`,children:e.tags.map(e=>(0,H.jsx)(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-cyan-500/10 text-cyan-400 border border-cyan-500/20`,children:e},e))})]}),(0,H.jsxs)(`div`,{className:`text-right text-xs text-slate-500 flex-shrink-0`,children:[(0,H.jsxs)(`div`,{children:[`Rel `,e.reliability,`/5`]}),(0,H.jsxs)(`div`,{children:[`Cred `,e.credibility,`/5`]}),(0,H.jsx)(`div`,{className:`mt-2`,children:e.pubDate.slice(0,10)})]})]}),(0,H.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-navy-700 text-xs text-slate-500`,children:[`Source: `,e.source]})]},e.id))})]})}function Dz(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function Pz(e,t,n){return(t=Hz(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Fz(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Iz(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Lz(){throw TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rz(){throw TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zz(e,t){return Oz(e)||Iz(e,t)||Wz(e,t)||Lz()}function Bz(e){return kz(e)||Fz(e)||Wz(e)||Rz()}function Vz(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}function Hz(e){var t=Vz(e,`string`);return typeof t==`symbol`?t:t+``}function Uz(e){"@babel/helpers - typeof";return Uz=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Uz(e)}function Wz(e,t){if(e){if(typeof e==`string`)return Dz(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Dz(e,t):void 0}}var Gz=typeof window>`u`?null:window,Kz=Gz?Gz.navigator:null;Gz&&Gz.document;var qz=Uz(``),Jz=Uz({}),Yz=Uz(function(){}),Xz=typeof HTMLElement>`u`?`undefined`:Uz(HTMLElement),Zz=function(e){return e&&e.instanceString&&$z(e.instanceString)?e.instanceString():null},Qz=function(e){return e!=null&&Uz(e)==qz},$z=function(e){return e!=null&&Uz(e)===Yz},eB=function(e){return!aB(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},tB=function(e){return e!=null&&Uz(e)===Jz&&!eB(e)&&e.constructor===Object},nB=function(e){return e!=null&&Uz(e)===Jz},$=function(e){return e!=null&&Uz(e)===Uz(1)&&!isNaN(e)},rB=function(e){return $(e)&&Math.floor(e)===e},iB=function(e){if(Xz!==`undefined`)return e!=null&&e instanceof HTMLElement},aB=function(e){return oB(e)||sB(e)},oB=function(e){return Zz(e)===`collection`&&e._private.single},sB=function(e){return Zz(e)===`collection`&&!e._private.single},cB=function(e){return Zz(e)===`core`},lB=function(e){return Zz(e)===`stylesheet`},uB=function(e){return Zz(e)===`event`},dB=function(e){return!!(e==null||e===``||e.match(/^\s+$/))},fB=function(e){return typeof HTMLElement>`u`?!1:e instanceof HTMLElement},pB=function(e){return tB(e)&&$(e.x1)&&$(e.x2)&&$(e.y1)&&$(e.y2)},mB=function(e){return nB(e)&&$z(e.then)},hB=function(){return Kz&&Kz.userAgent.match(/msie|trident|edge/i)},gB=function(e,t){t||=function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return`undefined`;for(var e=[],t=0;tt)},AB=function(e,t){return-1*kB(e,t)},jB=Object.assign==null?function(e){for(var t=arguments,n=1;n1&&--n,n<1/6?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var u=RegExp(`^`+TB+`$`).exec(e);if(u){if(n=parseInt(u[1]),n<0?n=(360- -1*n%360)%360:n>360&&(n%=360),n/=360,r=parseFloat(u[2]),r<0||r>100||(r/=100,i=parseFloat(u[3]),i<0||i>100)||(i/=100,a=u[4],a!==void 0&&(a=parseFloat(a),a<0||a>1)))return;if(r===0)o=s=c=Math.round(i*255);else{var d=i<.5?i*(1+r):i+r-i*r,f=2*i-d;o=Math.round(255*l(f,d,n+1/3)),s=Math.round(255*l(f,d,n)),c=Math.round(255*l(f,d,n-1/3))}t=[o,s,c,a]}return t},PB=function(e){var t,n=RegExp(`^`+CB+`$`).exec(e);if(n){t=[];for(var r=[],i=1;i<=3;i++){var a=n[i];if(a[a.length-1]===`%`&&(r[i]=!0),a=parseFloat(a),r[i]&&(a=a/100*255),a<0||a>255)return;t.push(Math.floor(a))}var o=r[1]||r[2]||r[3],s=r[1]&&r[2]&&r[3];if(o&&!s)return;var c=n[4];if(c!==void 0){if(c=parseFloat(c),c<0||c>1)return;t.push(c)}}return t},FB=function(e){return LB[e.toLowerCase()]},IB=function(e){return(eB(e)?e:null)||FB(e)||MB(e)||PB(e)||NB(e)},LB={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},RB=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i=s||t<0||_&&n>=d}function C(){var e=t();if(S(e))return w(e);p=setTimeout(C,x(e))}function w(e){return p=void 0,v&&l?y(e):(l=u=void 0,f)}function T(){var e=t(),n=S(e);if(l=arguments,u=this,m=e,n){if(p===void 0)return b(m);if(_)return clearTimeout(p),p=setTimeout(C,s),y(m)}return p===void 0&&(p=setTimeout(C,s)),f}return T.cancel=function(){p!==void 0&&clearTimeout(p),h=0,l=m=u=p=void 0},T.flush=function(){return p===void 0?f:w(t())},T},DV}var AV=VB(kV()),jV=Gz?Gz.performance:null,MV=jV&&jV.now?function(){return jV.now()}:function(){return Date.now()},NV=function(){if(Gz){if(Gz.requestAnimationFrame)return function(e){Gz.requestAnimationFrame(e)};if(Gz.mozRequestAnimationFrame)return function(e){Gz.mozRequestAnimationFrame(e)};if(Gz.webkitRequestAnimationFrame)return function(e){Gz.webkitRequestAnimationFrame(e)};if(Gz.msRequestAnimationFrame)return function(e){Gz.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout(function(){e(MV())},1e3/60)}}(),PV=function(e){return NV(e)},FV=MV,IV=9261,LV=65599,RV=5381,zV=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:IV,n;n=e.next(),!n.done;)t=t*LV+n.value|0;return t},BV=function(e){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:IV)*LV+e|0},VV=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:RV;return(t<<5)+t+e|0},HV=function(e,t){return e*2097152+t},UV=function(e){return e[0]*2097152+e[1]},WV=function(e,t){return[BV(e[0],t[0]),VV(e[1],t[1])]},GV=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return zV({next:function(){return r=0;r--)e[r]===t&&e.splice(r,1)},_H=function(e){e.splice(0,e.length)},vH=function(e,t){for(var n=0;n`u`?`undefined`:Uz(Set))===SH?CH:Set,TH=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(e===void 0||t===void 0||!cB(e))oH(`An element must have a core reference and parameters set`);else{var r=t.group;if(r??=t.data&&t.data.source!=null&&t.data.target!=null?`edges`:`nodes`,r!==`nodes`&&r!==`edges`)oH("An element must be of type `nodes` or `edges`; you specified `"+r+"`");else{this.length=1,this[0]=this;var i=this._private={cy:e,single:!0,data:t.data||{},position:t.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:r,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!t.selected,selectable:t.selectable===void 0||!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:t.grabbable===void 0||!!t.grabbable,pannable:t.pannable===void 0?r===`edges`:!!t.pannable,active:!1,classes:new wH,animation:{current:[],queue:[]},rscratch:{},scratch:t.scratch||{},edges:[],children:[],parent:t.parent&&t.parent.isNode()?t.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(i.position.x??(i.position.x=0),i.position.y??(i.position.y=0),t.renderedPosition){var a=t.renderedPosition,o=e.pan(),s=e.zoom();i.position={x:(a.x-o.x)/s,y:(a.y-o.y)/s}}var c=[];eB(t.classes)?c=t.classes:Qz(t.classes)&&(c=t.classes.split(/\s+/));for(var l=0,u=c.length;lt)},l=function(e,t,i,a,o){var s;if(i??=0,o??=n,i<0)throw Error(`lo must be non-negative`);for(a??=e.length;in;0<=n?t++:t--)l.push(t);return l}).apply(this).reverse(),c=[],a=0,o=s.length;ah;0<=h?++f:--f)g.push(a(e,r));return g},m=function(e,t,r,i){var a,o,s;for(i??=n,a=e[r];r>t&&(s=r-1>>1,o=e[s],i(a,o)<0);)e[r]=o,r=s;return e[r]=a},h=function(e,t,r){var i,a,o,s,c;for(r??=n,a=e.length,c=t,o=e[t],i=2*t+1;i0;){var x=_.pop(),S=h(x),C=x.id();if(d[C]=S,S!==1/0)for(var w=x.neighborhood().intersect(p),T=0;T0)for(n.unshift(t);u[i];){var a=u[i];n.unshift(a.edge),n.unshift(a.node),r=a.node,i=r.id()}return o.spawn(n)}}}},RH={kruskal:function(e){e||=function(e){return 1};for(var t=this.byGroup(),n=t.nodes,r=t.edges,i=n.length,a=Array(i),o=n,s=function(e){for(var t=0;t0;){if(b(),S++,y===l){for(var C=[],w=i,T=l,E=g[T];C.unshift(w),E!=null&&C.unshift(E),w=h[T],w!=null;)T=w.id(),E=g[T];return{found:!0,distance:u[y],path:this.spawn(C),steps:S}}f[y]=!0;for(var D=v._private.edges,O=0;OT&&(p[w]=T,g[w]=C,_[w]=y),!i){var E=C*l+S;!i&&p[E]>T&&(p[E]=T,g[E]=S,_[E]=y)}}}for(var D=0;D1&&arguments[1]!==void 0?arguments[1]:a,r=v(e),i=[],o=r;;){if(o==null)return t.spawn();var c=_(o),l=c.edge,u=c.pred;if(i.unshift(o[0]),o.same(n)&&i.length>0)break;l!=null&&i.unshift(l),o=u}return s.spawn(i)},x=0;x=0;l--){var u=c[l],d=u[1],f=u[2];(t[d]===o&&t[f]===s||t[d]===s&&t[f]===o)&&c.splice(l,1)}for(var p=0;pr;)t=KH(Math.floor(Math.random()*t.length),e,t),n--;return t},JH={kargerStein:function(){var e=this,t=this.byGroup(),n=t.nodes,r=t.edges;r.unmergeBy(function(e){return e.isLoop()});var i=n.length,a=r.length,o=Math.ceil((Math.log(i)/Math.LN2)**2),s=Math.floor(i/GH);if(i<2)oH(`At least 2 nodes are required for Karger-Stein algorithm`);else{for(var c=[],l=0;l1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,r=1/0,i=t;i1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,r=-1/0,i=t;i1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,r=0,i=0,a=t;a1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0;r?e=e.slice(t,n):(n0&&e.splice(0,t));for(var o=0,s=e.length-1;s>=0;s--){var c=e[s];a?isFinite(c)||(e[s]=-1/0,o++):e.splice(s,1)}i&&e.sort(function(e,t){return e-t});var l=e.length,u=Math.floor(l/2);return l%2==0?(e[u-1+o]+e[u+o])/2:e[u+1+o]},rU=function(e,t){return t===0?e:rU(t,e%t)},iU=function(e){for(var t=e[0],n=0;n0&&(t=rU(t,e[n]));else return 0;return t},aU=function(e,t){var n=e/t,r=Math.round(n);return r>=1&&Math.abs(n-r)<1e-6},oU=function(e){return Math.PI*e/180},sU=function(e,t){return Math.atan2(t,e)-Math.PI/2},cU=Math.log2||function(e){return Math.log(e)/Math.log(2)},lU=function(e){return e>0?1:e<0?-1:0},uU=function(e,t){return Math.sqrt(dU(e,t))},dU=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},fU=function(e){for(var t=e.length,n=0,r=0;r=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(e.w!=null&&e.h!=null&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},vU=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},yU=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},bU=function(e,t){e.x1=Math.min(e.x1,t.x1),e.x2=Math.max(e.x2,t.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,t.y1),e.y2=Math.max(e.y2,t.y2),e.h=e.y2-e.y1},xU=function(e,t,n){e.x1=Math.min(e.x1,t),e.x2=Math.max(e.x2,t),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,n),e.y2=Math.max(e.y2,n),e.h=e.y2-e.y1},SU=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},CU=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0],n,r,i,a;if(t.length===1)n=r=i=a=t[0];else if(t.length===2)n=i=t[0],a=r=t[1];else if(t.length===4){var o=zz(t,4);n=o[0],r=o[1],i=o[2],a=o[3]}return e.x1-=a,e.x2+=r,e.y1-=n,e.y2+=i,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},wU=function(e,t){e.x1=t.x1,e.y1=t.y1,e.x2=t.x2,e.y2=t.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},TU=function(e,t){return!(e.x1>t.x2||t.x1>e.x2||e.x2t.y2||t.y1>e.y2)},EU=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},DU=function(e,t){return EU(e,t.x,t.y)},OU=function(e,t){return EU(e,t.x1,t.y1)&&EU(e,t.x2,t.y2)},kU=Math.hypot??function(e,t){return Math.sqrt(e*e+t*t)};function AU(e,t){if(e.length<3)throw Error(`Need at least 3 vertices`);var n=function(e,t){return{x:e.x+t.x,y:e.y+t.y}},r=function(e,t){return{x:e.x-t.x,y:e.y-t.y}},i=function(e,t){return{x:e.x*t,y:e.y*t}},a=function(e,t){return e.x*t.y-e.y*t.x},o=function(e){var t=kU(e.x,e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},s=function(e){for(var t=0,n=0;n7&&arguments[7]!==void 0?arguments[7]:`auto`,c=s===`auto`?nW(i,a):s,l=i/2,u=a/2;c=Math.min(c,l,u);var d=c!==l,f=c!==u,p;if(d){var m=n-l+c-o,h=r-u-o;if(p=JU(e,t,n,r,m,h,n+l-c+o,h,!1),p.length>0)return p}if(f){var g=n+l+o;if(p=JU(e,t,n,r,g,r-u+c-o,g,r+u-c+o,!1),p.length>0)return p}if(d){var _=n-l+c-o,v=r+u+o;if(p=JU(e,t,n,r,_,v,n+l-c+o,v,!1),p.length>0)return p}if(f){var y=n-l-o;if(p=JU(e,t,n,r,y,r-u+c-o,y,r+u-c+o,!1),p.length>0)return p}var b,x=n-l+c,S=r-u+c;if(b=KU(e,t,n,r,x,S,c+o),b.length>0&&b[0]<=x&&b[1]<=S)return[b[0],b[1]];var C=n+l-c,w=r-u+c;if(b=KU(e,t,n,r,C,w,c+o),b.length>0&&b[0]>=C&&b[1]<=w)return[b[0],b[1]];var T=n+l-c,E=r+u-c;if(b=KU(e,t,n,r,T,E,c+o),b.length>0&&b[0]>=T&&b[1]>=E)return[b[0],b[1]];var D=n-l+c,O=r+u-c;return b=KU(e,t,n,r,D,O,c+o),b.length>0&&b[0]<=D&&b[1]>=O?[b[0],b[1]]:[]},NU=function(e,t,n,r,i,a,o){var s=o,c=Math.min(n,i),l=Math.max(n,i),u=Math.min(r,a),d=Math.max(r,a);return c-s<=e&&e<=l+s&&u-s<=t&&t<=d+s},PU=function(e,t,n,r,i,a,o,s,c){var l={x1:Math.min(n,o,i)-c,x2:Math.max(n,o,i)+c,y1:Math.min(r,s,a)-c,y2:Math.max(r,s,a)+c};return!(el.x2||tl.y2)},FU=function(e,t,n,r){n-=r;var i=t*t-4*e*n;if(i<0)return[];var a=Math.sqrt(i),o=2*e;return[(-t+a)/o,(-t-a)/o]},IU=function(e,t,n,r,i){e===0&&(e=1e-5),t/=e,n/=e,r/=e;var a,o=(3*n-t*t)/9,s=-(27*r)+t*(9*n-t*t*2),c,l,u,d,f;s/=54,a=o*o*o+s*s,i[1]=0,d=t/3,a>0?(l=s+Math.sqrt(a),l=l<0?-((-l)**(1/3)):l**(1/3),u=s-Math.sqrt(a),u=u<0?-((-u)**(1/3)):u**(1/3),i[0]=-d+l+u,d+=(l+u)/2,i[4]=i[2]=-d,d=Math.sqrt(3)*(-u+l)/2,i[3]=d,i[5]=-d):(i[5]=i[3]=0,a===0?(f=s<0?-((-s)**(1/3)):s**(1/3),i[0]=-d+2*f,i[4]=i[2]=-(f+d)):(o=-o,c=o*o*o,c=Math.acos(s/Math.sqrt(c)),f=2*Math.sqrt(o),i[0]=-d+f*Math.cos(c/3),i[2]=-d+f*Math.cos((c+2*Math.PI)/3),i[4]=-d+f*Math.cos((c+4*Math.PI)/3)))},LU=function(e,t,n,r,i,a,o,s){var c=+n*n-4*n*i+2*n*o+4*i*i-4*i*o+o*o+r*r-4*r*a+2*r*s+4*a*a-4*a*s+s*s,l=9*n*i-3*n*n-3*n*o-6*i*i+3*i*o+9*r*a-3*r*r-3*r*s-6*a*a+3*a*s,u=3*n*n-6*n*i+n*o-n*e+2*i*i+2*i*e-o*e+3*r*r-6*r*a+r*s-r*t+2*a*a+2*a*t-s*t,d=+n*i-n*n+n*e-i*e+r*a-r*r+r*t-a*t,f=[];IU(c,l,u,d,f);for(var p=1e-7,m=[],h=0;h<6;h+=2)Math.abs(f[h+1])=0&&f[h]<=1&&m.push(f[h]);m.push(1),m.push(0);for(var g=-1,_,v,y,b=0;b=0?yc?(e-i)*(e-i)+(t-a)*(t-a):l-d},zU=function(e,t,n){for(var r,i,a,o,s,c=0,l=0;l=e&&e>=a||r<=e&&e<=a)s=(e-r)/(a-r)*(o-i)+i,s>t&&c++;else continue}return c%2!=0},BU=function(e,t,n,r,i,a,o,s,c){var l=Array(n.length),u;s[0]==null?u=s:(u=Math.atan(s[1]/s[0]),s[0]<0?u+=Math.PI/2:u=-u-Math.PI/2);for(var d=Math.cos(-u),f=Math.sin(-u),p=0;p0?HU(UU(l,-c)):l)},VU=function(e,t,n,r,i,a,o,s){for(var c=Array(n.length*2),l=0;l=0&&h<=1&&_.push(h),g>=0&&g<=1&&_.push(g),_.length===0)return[];var v=_[0]*s[0]+e,y=_[0]*s[1]+t;return _.length>1?_[0]==_[1]?[v,y]:[v,y,_[1]*s[0]+e,_[1]*s[1]+t]:[v,y]},qU=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},JU=function(e,t,n,r,i,a,o,s,c){var l=e-i,u=n-e,d=o-i,f=t-a,p=r-t,m=s-a,h=d*f-m*l,g=u*f-p*l,_=m*u-d*p;if(_!==0){var v=h/_,y=g/_,b=.001,x=0-b,S=1+b;return x<=v&&v<=S&&x<=y&&y<=S||c?[e+v*u,t+v*p]:[]}return h===0||g===0?qU(e,n,o)===o?[o,s]:qU(e,n,i)===i?[i,a]:qU(i,o,n)===n?[n,r]:[]:[]},YU=function(e,t,n,r,i){var a=[],o=r/2,s=i/2,c=t,l=n;a.push({x:c+o*e[0],y:l+s*e[1]});for(var u=1;u0?HU(UU(u,-s)):u}else f=n;for(var m,h,g,_,v=0;v2){for(var p=[l[0],l[1]],m=(p[0]-e)**2+(p[1]-t)**2,h=1;h(t.y-e.y)*(n.x-e.x)}return i(e,n,r)!==i(t,n,r)&&i(e,t,n)!==i(e,t,r)}function uW(e,t){for(var n=!1,r=0,i=t.length-1;re.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}function dW(e,t,n){if(uW(e,n))return!0;for(var r=0;rl&&(l=t)},get:function(e){return c[e]}},d=0;d0?v.edgesTo(_)[0]:_.edgesTo(v)[0];var b=r(y);_=_.id(),l[_]>l[m]+b&&(l[_]=l[m]+b,d.nodes.indexOf(_)<0?d.push(_):d.updateItem(_),c[_]=0,n[_]=[]),l[_]==l[m]+b&&(c[_]=c[_]+c[m],n[_].push(m))}else for(var x=0;x0;){for(var T=t.pop(),E=0;E0&&o.push(n[s]);o.length!==0&&i.push(r.collection(o))}return i},AW=function(e,t){for(var n=0;n5&&arguments[5]!==void 0?arguments[5]:PW,o=r,s,c,l=0;l=2?BW(e,t,n,0,LW,RW):BW(e,t,n,0,IW)},squaredEuclidean:function(e,t,n){return BW(e,t,n,0,LW)},manhattan:function(e,t,n){return BW(e,t,n,0,IW)},max:function(e,t,n){return BW(e,t,n,-1/0,zW)}};VW[`squared-euclidean`]=VW.squaredEuclidean,VW.squaredeuclidean=VW.squaredEuclidean;function HW(e,t,n,r,i,a){var o=$z(e)?e:VW[e]||VW.euclidean;return t===0&&$z(e)?o(i,a):o(t,n,r,i,a)}var UW=hH({k:2,m:2,sensitivityThreshold:1e-4,distance:`euclidean`,maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),WW=function(e){return UW(e)},GW=function(e,t,n,r,i){var a=i===`kMedoids`?function(e){return r[e](n)}:function(e){return n[e]},o=function(e){return r[e](t)},s=n,c=t;return HW(e,r.length,a,o,s,c)},KW=function(e,t,n){for(var r=n.length,i=Array(r),a=Array(r),o=Array(t),s=null,c=0;cn)return!1;return!0},ZW=function(e,t,n){for(var r=0;rn.length&&oH(`kMedoids: k (${i.k}) cannot exceed the number of nodes (${n.length}).`);var a=Array(i.k),o,s={},c,l=Array(i.k);i.testMode?typeof i.testCentroids==`number`||(o=Uz(i.testCentroids)===`object`?i.testCentroids:QW(n,i.k)):o=QW(n,i.k);for(var u=!0,d=0;u&&do&&(o=t[c][l],s=l);i[s].push(e[c])}for(var u=0;u=i.threshold||i.mode===`dendrogram`&&e.length===1)return!1;var p=t[a],m=t[r[a]],h=i.mode===`dendrogram`?{left:p,right:m,key:p.key,size:p.size+m.size}:{value:p.value.concat(m.value),key:p.key,size:p.size+m.size};e[p.index]=h,e.splice(m.index,1),t[p.key]=h;for(var g=0;gn[m.key][_.key]&&(s=n[m.key][_.key])):i.linkage===`max`?(s=n[p.key][_.key],n[p.key][_.key]0&&r.push(i);return r},xG=function(e,t,n){for(var r=[],i=0;io&&(a=c,o=t[i*e+c])}a>0&&r.push(a)}for(var l=0;lc&&(s=l,c=u)}n[i]=a[s]}return r=xG(e,t,n),r},CG=function(e){for(var t=this.cy(),n=this.nodes(),r=_G(e),i={},a=0;a=E?(D=E,E=k,O=A):k>D&&(D=k);for(var j=0;j0);S[w%r.minIterations*o+L]=ee,I+=ee}if(I>0&&(w>=r.minIterations-1||w==r.maxIterations-1)){for(var R=0,z=0;z1||l>1)&&(o=!0),u[t]=[],r.forEach(function(e){return u[t].push(e.id())})}else d[t]=[void 0,e.target().id()]}):a.forEach(function(e){var t=e.id();if(e.isNode()){var n=e.connectedEdges().intersection(f);(n.length+n.filter(function(e){return e.isLoop()}).length)%2&&(s?c?o=!0:c=t:s=t),u[t]=[],n.forEach(function(e){return u[t].push(e.id())})}else d[t]=[e.source().id(),e.target().id()]});var p={found:!1,trail:void 0};if(o)return p;if(c&&s){if(i){if(l&&c!=l)return p;l=c}else if(l&&c!=l&&s!=l)return p;else l||=c}else l||=a[0].id();var m=function(e){for(var t=e,n=[e],r,a,o;u[t].length;)r=u[t].shift(),a=d[r][0],o=d[r][1],t==o?!i&&t!=a&&(u[a]=u[a].filter(function(e){return e!=r}),t=a):(u[o]=u[o].filter(function(e){return e!=r}),t=o),n.unshift(r),n.unshift(t);return n},h=[],g=[];for(g=m(l);g.length!=1;)u[g[0]].length==0?(h.unshift(a.getElementById(g.shift())),h.unshift(a.getElementById(g.shift()))):g=m(g.shift()).concat(g);for(var _ in h.unshift(a.getElementById(g.shift())),u)if(u[_].length)return p;return p.found=!0,p.trail=this.spawn(h,!0),p}},DG=function(){var e=this,t={},n=0,r=0,i=[],a=[],o={},s=function(n,r){for(var o=a.length-1,s=[],c=e.spawn();a[o].x!=n||a[o].y!=r;)s.push(a.pop().edge),o--;s.push(a.pop().edge),s.forEach(function(n){var r=n.connectedNodes().intersection(e);c.merge(n),r.forEach(function(n){var r=n.id(),i=n.connectedEdges().intersection(e);c.merge(n),t[r].cutVertex?c.merge(i.filter(function(e){return e.isLoop()})):c.merge(i)})}),i.push(c)},c=function(l,u,d){l===d&&(r+=1),t[u]={id:n,low:n++,cutVertex:!1};var f=e.getElementById(u).connectedEdges().intersection(e);if(f.size()===0)i.push(e.spawn(e.getElementById(u)));else{var p,m,h,g;f.forEach(function(e){p=e.source().id(),m=e.target().id(),h=p===u?m:p,h!==d&&(g=e.id(),o[g]||(o[g]=!0,a.push({x:u,y:h,edge:e})),h in t?t[u].low=Math.min(t[u].low,t[h].id):(c(l,h,u),t[u].low=Math.min(t[u].low,t[h].low),t[u].id<=t[h].low&&(t[u].cutVertex=!0,s(u,h))))})}};e.forEach(function(e){if(e.isNode()){var n=e.id();n in t||(r=0,c(n,n),t[n].cutVertex=r>1)}});var l=Object.keys(t).filter(function(e){return t[e].cutVertex}).map(function(t){return e.getElementById(t)});return{cut:e.spawn(l),components:i}},OG={hopcroftTarjanBiconnected:DG,htbc:DG,htb:DG,hopcroftTarjanBiconnectedComponents:DG},kG=function(){var e=this,t={},n=0,r=[],i=[],a=e.spawn(e),o=function(s){if(i.push(s),t[s]={index:n,low:n++,explored:!1},e.getElementById(s).connectedEdges().intersection(e).forEach(function(e){var n=e.target().id();n!==s&&(n in t||o(n),t[n].explored||(t[s].low=Math.min(t[s].low,t[n].low)))}),t[s].index===t[s].low){for(var c=e.spawn();;){var l=i.pop();if(c.merge(e.getElementById(l)),t[l].low=t[s].index,t[l].explored=!0,l===s)break}var u=c.edgesWith(c),d=c.merge(u);r.push(d),a=a.difference(d)}};return e.forEach(function(e){if(e.isNode()){var n=e.id();n in t||o(n)}}),{cut:a,components:r}},AG={tarjanStronglyConnected:kG,tsc:kG,tscc:kG,tarjanStronglyConnectedComponents:kG},jG={};[DH,LH,RH,BH,HH,WH,JH,pW,hW,_W,yW,NW,oG,hG,wG,EG,OG,AG].forEach(function(e){jB(jG,e)});var MG=0,NG=1,PG=2,FG=function(e){if(!(this instanceof FG))return new FG(e);this.id=`Thenable/1.0.7`,this.state=MG,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},typeof e==`function`&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};FG.prototype={fulfill:function(e){return IG(this,NG,`fulfillValue`,e)},reject:function(e){return IG(this,PG,`rejectReason`,e)},then:function(e,t){var n=this,r=new FG;return n.onFulfilled.push(zG(e,r,`fulfill`)),n.onRejected.push(zG(t,r,`reject`)),LG(n),r.proxy}};var IG=function(e,t,n,r){return e.state===MG&&(e.state=t,e[n]=r,LG(e)),e},LG=function(e){e.state===NG?RG(e,`onFulfilled`,e.fulfillValue):e.state===PG&&RG(e,`onRejected`,e.rejectReason)},RG=function(e,t,n){if(e[t].length!==0){var r=e[t];e[t]=[];var i=function(){for(var e=0;e0}},clearQueue:function(){return function(){var e=this,t=e.length===void 0?[e]:e;if(!(this._private.cy||this).styleEnabled())return this;for(var n=0;n-1},$K}var nq,rq;function iq(){if(rq)return nq;rq=1;var e=KK();return nq=function(t,n){var r=this.__data__,i=e(r,t);return i<0?(++this.size,r.push([t,n])):r[i][1]=n,this},nq}var aq,oq;function sq(){if(oq)return aq;oq=1;var e=BK(),t=YK(),n=QK(),r=tq(),i=iq();function a(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t-1&&n%1==0&&n0&&this.spawn(r).updateStyle().emit(`class`),t},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return t!=null&&t._private.classes.has(e)},toggleClass:function(e,t){eB(e)||(e=e.match(/\S+/g)||[]);for(var n=this,r=t===void 0,i=[],a=0,o=n.length;a0&&this.spawn(i).updateStyle().emit(`class`),n},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var n=this;if(t==null)t=250;else if(t===0)return n;return n.addClass(e),setTimeout(function(){n.removeClass(e)},t),n}};HJ.className=HJ.classNames=HJ.classes;var UJ={metaChar:`[\\!\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\\`\\{\\|\\}\\~]`,comparatorOp:`=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=`,boolOp:`\\?|\\!|\\^`,string:`"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,number:SB,meta:`degree|indegree|outdegree`,separator:`\\s*,\\s*`,descendant:`\\s+`,child:`\\s+>\\s+`,subject:`\\$`,group:`node|edge|\\*`,directedEdge:`\\s+->\\s+`,undirectedEdge:`\\s+<->\\s+`};UJ.variable=`(?:[\\w-.]|(?:\\\\`+UJ.metaChar+`))+`,UJ.className=`(?:[\\w-]|(?:\\\\`+UJ.metaChar+`))+`,UJ.value=UJ.string+`|`+UJ.number,UJ.id=UJ.variable,(function(){for(var e=UJ.comparatorOp.split(`|`),t,n=0;n=0||t!==`=`&&(UJ.comparatorOp+=`|\\!`+t)})();var WJ=function(){return{checks:[]}},GJ={GROUP:0,COLLECTION:1,FILTER:2,DATA_COMPARE:3,DATA_EXIST:4,DATA_BOOL:5,META_COMPARE:6,STATE:7,ID:8,CLASS:9,UNDIRECTED_EDGE:10,DIRECTED_EDGE:11,NODE_SOURCE:12,NODE_TARGET:13,NODE_NEIGHBOR:14,CHILD:15,DESCENDANT:16,PARENT:17,ANCESTOR:18,COMPOUND_SPLIT:19,TRUE:20},KJ=[{selector:`:selected`,matches:function(e){return e.selected()}},{selector:`:unselected`,matches:function(e){return!e.selected()}},{selector:`:selectable`,matches:function(e){return e.selectable()}},{selector:`:unselectable`,matches:function(e){return!e.selectable()}},{selector:`:locked`,matches:function(e){return e.locked()}},{selector:`:unlocked`,matches:function(e){return!e.locked()}},{selector:`:visible`,matches:function(e){return e.visible()}},{selector:`:hidden`,matches:function(e){return!e.visible()}},{selector:`:transparent`,matches:function(e){return e.transparent()}},{selector:`:grabbed`,matches:function(e){return e.grabbed()}},{selector:`:free`,matches:function(e){return!e.grabbed()}},{selector:`:removed`,matches:function(e){return e.removed()}},{selector:`:inside`,matches:function(e){return!e.removed()}},{selector:`:grabbable`,matches:function(e){return e.grabbable()}},{selector:`:ungrabbable`,matches:function(e){return!e.grabbable()}},{selector:`:animated`,matches:function(e){return e.animated()}},{selector:`:unanimated`,matches:function(e){return!e.animated()}},{selector:`:parent`,matches:function(e){return e.isParent()}},{selector:`:childless`,matches:function(e){return e.isChildless()}},{selector:`:child`,matches:function(e){return e.isChild()}},{selector:`:orphan`,matches:function(e){return e.isOrphan()}},{selector:`:nonorphan`,matches:function(e){return e.isChild()}},{selector:`:compound`,matches:function(e){return e.isNode()?e.isParent():e.source().isParent()||e.target().isParent()}},{selector:`:loop`,matches:function(e){return e.isLoop()}},{selector:`:simple`,matches:function(e){return e.isSimple()}},{selector:`:active`,matches:function(e){return e.active()}},{selector:`:inactive`,matches:function(e){return!e.active()}},{selector:`:backgrounding`,matches:function(e){return e.backgrounding()}},{selector:`:nonbackgrounding`,matches:function(e){return!e.backgrounding()}}].sort(function(e,t){return AB(e.selector,t.selector)}),qJ=function(){for(var e={},t,n=0;n0&&l.edgeCount>0)return cH("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(l.edgeCount>1)return cH("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;l.edgeCount===1&&cH("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},toString:function(){if(this.toStringCache!=null)return this.toStringCache;for(var e=function(e){return e??``},t=function(t){return Qz(t)?`"`+t+`"`:e(t)},n=function(e){return` `+e+` `},r=function(r,a){var o=r.type,s=r.value;switch(o){case GJ.GROUP:var c=e(s);return c.substring(0,c.length-1);case GJ.DATA_COMPARE:var l=r.field,u=r.operator;return`[`+l+n(e(u))+t(s)+`]`;case GJ.DATA_BOOL:var d=r.operator,f=r.field;return`[`+e(d)+f+`]`;case GJ.DATA_EXIST:return`[`+r.field+`]`;case GJ.META_COMPARE:var p=r.operator;return`[[`+r.field+n(e(p))+t(s)+`]]`;case GJ.STATE:return s;case GJ.ID:return`#`+s;case GJ.CLASS:return`.`+s;case GJ.PARENT:case GJ.CHILD:return i(r.parent,a)+n(`>`)+i(r.child,a);case GJ.ANCESTOR:case GJ.DESCENDANT:return i(r.ancestor,a)+` `+i(r.descendant,a);case GJ.COMPOUND_SPLIT:var m=i(r.left,a),h=i(r.subject,a),g=i(r.right,a);return m+(m.length>0?` `:``)+h+g;case GJ.TRUE:return``}},i=function(e,t){return e.checks.reduce(function(n,i,a){return n+(t===e&&a===0?`$`:``)+r(i,t)},``)},a=``,o=0;o1&&o=0&&(t=t.replace(`!`,``),u=!0),t.indexOf(`@`)>=0&&(t=t.replace(`@`,``),l=!0),(i||o||l||t===`*=`||t===`^=`||t===`$=`)&&(s=!i&&!a?``:``+e,c=``+n),l&&(e=s=s.toLowerCase(),n=c=c.toLowerCase()),t){case`*=`:r=s.indexOf(c)>=0;break;case`$=`:r=s.indexOf(c,s.length-c.length)>=0;break;case`^=`:r=s.indexOf(c)===0;break;case`=`:r=e===n;break;case`>`:d=!0,r=e>n;break;case`>=`:d=!0,r=e>=n;break;case`<`:d=!0,r=e0;){var l=i.shift();t(l),a.add(l.id()),o&&r(i,a,l)}return e}function gY(e,t,n){if(n.isParent())for(var r=n._private.children,i=0;i1&&arguments[1]!==void 0?arguments[1]:!0;return hY(this,e,t,gY)};function _Y(e,t,n){if(n.isChild()){var r=n._private.parent;t.has(r.id())||e.push(r)}}mY.forEachUp=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return hY(this,e,t,_Y)};function vY(e,t,n){_Y(e,t,n),gY(e,t,n)}mY.forEachUpAndDown=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return hY(this,e,t,vY)},mY.ancestors=mY.parents;var yY=bY={data:BJ.data({field:`data`,bindingEvent:`data`,allowBinding:!0,allowSetting:!0,settingEvent:`data`,settingTriggersEvent:!0,triggerFnName:`trigger`,allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:BJ.removeData({field:`data`,event:`data`,triggerFnName:`trigger`,triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:BJ.data({field:`scratch`,bindingEvent:`scratch`,allowBinding:!0,allowSetting:!0,settingEvent:`scratch`,settingTriggersEvent:!0,triggerFnName:`trigger`,allowGetting:!0,updateStyle:!0}),removeScratch:BJ.removeData({field:`scratch`,event:`scratch`,triggerFnName:`trigger`,triggerEvent:!0,updateStyle:!0}),rscratch:BJ.data({field:`rscratch`,allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:BJ.removeData({field:`rscratch`,triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}},bY;yY.attr=yY.data,yY.removeAttr=yY.removeData;var xY=bY,SY={};function CY(e){return function(t){var n=this;if(t===void 0&&(t=!0),n.length!==0&&n.isNode()&&!n.removed()){for(var r=0,i=n[0],a=i._private.edges,o=0;ot}),minIndegree:wY(`indegree`,function(e,t){return et}),minOutdegree:wY(`outdegree`,function(e,t){return et})}),jB(SY,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r0,d=u;u&&(l=l[0]);var f=d?l.position():{x:0,y:0};t===void 0?i!==void 0&&c.position({x:i.x+f.x,y:i.y+f.y}):c.position(e,t+f[e])}else{var p=n.position(),m=o?n.parent():null,h=m&&m.length>0,g=h;h&&(m=m[0]);var _=g?m.position():{x:0,y:0};return i={x:p.x-_.x,y:p.y-_.y},e===void 0?i:i[e]}}else if(!a)return;return this}},TY.modelPosition=TY.point=TY.position,TY.modelPositions=TY.points=TY.positions,TY.renderedPoint=TY.renderedPosition,TY.relativePoint=TY.relativePosition;var kY=EY,AY=function(e){switch(e){case`left`:case`right-inside`:return`left`;case`right`:case`left-inside`:return`right`;default:return`center`}},jY=function(e){switch(e){case`top`:case`bottom-inside`:return`top`;case`bottom`:case`top-inside`:return`bottom`;default:return`center`}},MY=function(e){switch(e){case`left`:return`right`;case`right`:case`left-inside`:return`left`;case`right-inside`:return`right`;default:return`center`}},NY=PY={},PY;PY.renderedBoundingBox=function(e){var t=this.boundingBox(e),n=this.cy(),r=n.zoom(),i=n.pan(),a=t.x1*r+i.x,o=t.x2*r+i.x,s=t.y1*r+i.y,c=t.y2*r+i.y;return{x1:a,x2:o,y1:s,y2:c,w:o-a,h:c-s}};var xie=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`main`;if(!e||!e.cy().styleEnabled())return null;var n=t===`main`?void 0:t,r=e._private,i=r.labelPolygonCache,a=KY(e);if(!(i==null||i[t]==null||r.styleDirty||r.labelPolygonPosKey!==a))return i[t];e.recalculateRenderedStyle(),a=KY(e),(r.labelPolygonCache==null||r.labelPolygonPosKey!==a)&&(r.labelPolygonCache={},r.labelPolygonPosKey=a);var o=Sie(e,n);return r.labelPolygonCache[t]=o,o};PY.dirtyCompoundBoundsCache=function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],t=this.cy();return!t.styleEnabled()||!t.hasCompoundNodes()||this.forEachUp(function(t){if(t.isParent()){var n=t._private;n.compoundBoundsClean=!1,n.bbCache=null,e||t.emitAndNotify(`bounds`)}}),this},PY.updateCompoundBounds=function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],t=this.cy();if(!t.styleEnabled()||!t.hasCompoundNodes()||!e&&t.batching())return this;function n(e){if(!e.isParent())return;var t=e._private,n=e.children(),r=e.pstyle(`compound-sizing-wrt-labels`).value===`include`,i={width:{val:e.pstyle(`min-width`).pfValue,left:e.pstyle(`min-width-bias-left`),right:e.pstyle(`min-width-bias-right`)},height:{val:e.pstyle(`min-height`).pfValue,top:e.pstyle(`min-height-bias-top`),bottom:e.pstyle(`min-height-bias-bottom`)}},a=n.boundingBox({includeLabels:r,includeOverlays:!1,useCache:!1}),o=t.position;(a.w===0||a.h===0)&&(a={w:e.pstyle(`width`).pfValue,h:e.pstyle(`height`).pfValue},a.x1=o.x-a.w/2,a.x2=o.x+a.w/2,a.y1=o.y-a.h/2,a.y2=o.y+a.h/2);function s(e,t,n){var r=0,i=0,a=t+n;return e>0&&a>0&&(r=t/a*e,i=n/a*e),{biasDiff:r,biasComplementDiff:i}}function c(e,t,n,r){if(n.units===`%`)switch(r){case`width`:return e>0?n.pfValue*e:0;case`height`:return t>0?n.pfValue*t:0;case`average`:return e>0&&t>0?n.pfValue*(e+t)/2:0;case`min`:return e>0&&t>0?e>t?n.pfValue*t:n.pfValue*e:0;case`max`:return e>0&&t>0?e>t?n.pfValue*e:n.pfValue*t:0;default:return 0}else if(n.units===`px`)return n.pfValue;else return 0}var l=i.width.left.value;i.width.left.units===`px`&&i.width.val>0&&(l=l*100/i.width.val);var u=i.width.right.value;i.width.right.units===`px`&&i.width.val>0&&(u=u*100/i.width.val);var d=i.height.top.value;i.height.top.units===`px`&&i.height.val>0&&(d=d*100/i.height.val);var f=i.height.bottom.value;i.height.bottom.units===`px`&&i.height.val>0&&(f=f*100/i.height.val);var p=s(i.width.val-a.w,l,u),m=p.biasDiff,h=p.biasComplementDiff,g=s(i.height.val-a.h,d,f),_=g.biasDiff,v=g.biasComplementDiff;t.autoPadding=c(a.w,a.h,e.pstyle(`padding`),e.pstyle(`padding-relative-to`).value),t.autoWidth=Math.max(a.w,i.width.val),o.x=(-m+a.x1+a.x2+h)/2,t.autoHeight=Math.max(a.h,i.height.val),o.y=(-_+a.y1+a.y2+v)/2}for(var r=0;re.x2?r:e.x2,e.y1=ne.y2?i:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},LY=function(e,t){return t==null?e:IY(e,t.x1,t.y1,t.x2,t.y2)},RY=function(e,t,n){return yH(e,t,n)},Sie=function(e,t){if(!e.cy().headless()){var n=e._private,r=t?t+`-`:``;if(!e.pstyle(r+`label`).strValue)return null;e.boundingBox({includeLabels:!0});var i=t||`main`,a=n.labelBounds[i];return a?sW(a,RY(n.rscratch,`labelX`,t),RY(n.rscratch,`labelY`,t),RY(n.rscratch,`labelAngle`,t),e.pstyle(r+`text-margin-x`).pfValue,e.pstyle(r+`text-margin-y`).pfValue,0):null}},zY=function(e,t,n){if(!t.cy().headless()){var r=t._private,i=r.rstyle,a=(i.arrowWidths!=null&&i.arrowWidths[n]!=null?i.arrowWidths[n]:i.arrowWidth)/2,o=t.pstyle(n+`-arrow-shape`).value,s,c;if(o!==`none`){n===`source`?(s=i.srcX,c=i.srcY):n===`target`?(s=i.tgtX,c=i.tgtY):(s=i.midX,c=i.midY);var l=r.arrowBounds=r.arrowBounds||{},u=l[n]=l[n]||{};u.x1=s-a,u.y1=c-a,u.x2=s+a,u.y2=c+a,u.w=u.x2-u.x1,u.h=u.y2-u.y1,SU(u,1),IY(e,u.x1,u.y1,u.x2,u.y2)}}},BY=function(e,t,n){if(!t.cy().headless()){var r=n?n+`-`:``,i=t._private,a=i.rstyle;if(t.pstyle(r+`label`).strValue){var o=t.pstyle(`text-halign`),s=t.pstyle(`text-valign`),c=RY(a,`labelWidth`,n),l=RY(a,`labelHeight`,n),u=RY(a,`labelX`,n),d=RY(a,`labelY`,n),f=t.pstyle(r+`text-margin-x`).pfValue,p=t.pstyle(r+`text-margin-y`).pfValue,m=t.isEdge(),h=t.pstyle(r+`text-rotation`),g=t.pstyle(`text-outline-width`).pfValue,_=t.pstyle(`text-border-width`).pfValue/2,v=t.pstyle(`text-background-padding`).pfValue,y=2,b=l,x=c,S=x/2,C=b/2,w,T,E,D;if(m)w=u-S,T=u+S,E=d-C,D=d+C;else{switch(AY(o.value)){case`left`:w=u-x,T=u;break;case`center`:w=u-S,T=u+S;break;case`right`:w=u,T=u+x}switch(jY(s.value)){case`top`:E=d-b,D=d;break;case`center`:E=d-C,D=d+C;break;case`bottom`:E=d,D=d+b}}var O=f-Math.max(g,_)-v-y,k=f+Math.max(g,_)+v+y,A=p-Math.max(g,_)-v-y,j=p+Math.max(g,_)+v+y;w+=O,T+=k,E+=A,D+=j;var M=n||`main`,N=i.labelBounds,P=N[M]=N[M]||{};P.x1=w,P.y1=E,P.x2=T,P.y2=D,P.w=T-w,P.h=D-E,P.leftPad=O,P.rightPad=k,P.topPad=A,P.botPad=j;var F=m&&h.strValue===`autorotate`,I=h.pfValue!=null&&h.pfValue!==0;if(F||I){var L=F?RY(i.rstyle,`labelAngle`,n):h.pfValue,ee=Math.cos(L),R=Math.sin(L),z=(w+T)/2,B=(E+D)/2;if(!m){switch(AY(o.value)){case`left`:z=T;break;case`right`:z=w}switch(jY(s.value)){case`top`:B=D;break;case`bottom`:B=E}}var te=function(e,t){return e-=z,t-=B,{x:e*ee-t*R+z,y:e*R+t*ee+B}},ne=te(w,E),re=te(w,D),ie=te(T,E),ae=te(T,D);w=Math.min(ne.x,re.x,ie.x,ae.x),T=Math.max(ne.x,re.x,ie.x,ae.x),E=Math.min(ne.y,re.y,ie.y,ae.y),D=Math.max(ne.y,re.y,ie.y,ae.y)}var oe=M+`Rot`,se=N[oe]=N[oe]||{};se.x1=w,se.y1=E,se.x2=T,se.y2=D,se.w=T-w,se.h=D-E,IY(e,w,E,T,D),IY(i.labelBounds.all,w,E,T,D)}return e}},VY=function(e,t){if(!t.cy().headless()){var n=t.pstyle(`outline-opacity`).value,r=t.pstyle(`outline-width`).value+t.pstyle(`outline-offset`).value;HY(e,t,n,r,`outside`,r/2)}},HY=function(e,t,n,r,i,a){if(!(n===0||r<=0||i===`inside`)){var o=t.cy().renderer(),s=o.nodeShapes[o.getNodeShape(t)];if(s){var c=t.position(),l=c.x,u=c.y,d=t.width(),f=t.height();s.hasMiterBounds?(i===`center`&&(r/=2),LY(e,s.miterBounds(l,u,d,f,r))):a!=null&&a>0&&CU(e,[a,a,a,a])}}},Cie=function(e,t){t.cy().headless()||HY(e,t,t.pstyle(`border-opacity`).value,t.pstyle(`border-width`).pfValue,t.pstyle(`border-position`).value)},wie=function(e,t){var n=e._private.cy,r=n.styleEnabled(),i=n.headless(),a=_U(),o=e._private,s=e.isNode(),c=e.isEdge(),l,u,d,f,p,m,h=o.rstyle,g=s&&r?e.pstyle(`bounds-expansion`).pfValue:[0],_=function(e){return e.pstyle(`display`).value!==`none`},v=!r||_(e)&&(!c||_(e.source())&&_(e.target()));if(v){var y=0,b=0;r&&t.includeOverlays&&(y=e.pstyle(`overlay-opacity`).value,y!==0&&(b=e.pstyle(`overlay-padding`).value));var x=0,S=0;r&&t.includeUnderlays&&(x=e.pstyle(`underlay-opacity`).value,x!==0&&(S=e.pstyle(`underlay-padding`).value));var C=Math.max(b,S),w=0,T=0;if(r&&(w=e.pstyle(`width`).pfValue,T=w/2),s&&t.includeNodes){var E=e.position();p=E.x,m=E.y;var D=e.outerWidth()/2,O=e.outerHeight()/2;l=p-D,u=p+D,d=m-O,f=m+O,IY(a,l,d,u,f),r&&VY(a,e),r&&t.includeOutlines&&!i&&VY(a,e),r&&Cie(a,e)}else if(c&&t.includeEdges){if(r&&!i){var k=e.pstyle(`curve-style`).strValue;if(l=Math.min(h.srcX,h.midX,h.tgtX),u=Math.max(h.srcX,h.midX,h.tgtX),d=Math.min(h.srcY,h.midY,h.tgtY),f=Math.max(h.srcY,h.midY,h.tgtY),l-=T,u+=T,d-=T,f+=T,IY(a,l,d,u,f),k===`haystack`){var A=h.haystackPts;if(A&&A.length===2){if(l=A[0].x,d=A[0].y,u=A[1].x,f=A[1].y,l>u){var j=l;l=u,u=j}if(d>f){var M=d;d=f,f=M}IY(a,l-T,d-T,u+T,f+T)}}else if(k===`bezier`||k===`unbundled-bezier`||xB(k,`segments`)||xB(k,`taxi`)){var N;switch(k){case`bezier`:case`unbundled-bezier`:N=h.bezierPts;break;case`segments`:case`taxi`:case`round-segments`:case`round-taxi`:N=h.linePts}if(N!=null)for(var P=0;Pu){var ee=l;l=u,u=ee}if(d>f){var R=d;d=f,f=R}l-=T,u+=T,d-=T,f+=T,IY(a,l,d,u,f)}}if(r&&t.includeEdges&&c&&(zY(a,e,`mid-source`),zY(a,e,`mid-target`),zY(a,e,`source`),zY(a,e,`target`)),r&&e.pstyle(`ghost`).value===`yes`){var z=e.pstyle(`ghost-offset-x`).pfValue,B=e.pstyle(`ghost-offset-y`).pfValue;IY(a,a.x1+z,a.y1+B,a.x2+z,a.y2+B)}var te=o.bodyBounds=o.bodyBounds||{};wU(te,a),CU(te,g),SU(te,1),r&&(l=a.x1,u=a.x2,d=a.y1,f=a.y2,IY(a,l-C,d-C,u+C,f+C));var ne=o.overlayBounds=o.overlayBounds||{};wU(ne,a),CU(ne,g),SU(ne,1);var re=o.labelBounds=o.labelBounds||{};re.all==null?re.all=_U():yU(re.all),r&&t.includeLabels&&(t.includeMainLabels&&BY(a,e,null),c&&(t.includeSourceLabels&&BY(a,e,`source`),t.includeTargetLabels&&BY(a,e,`target`)))}return a.x1=FY(a.x1),a.y1=FY(a.y1),a.x2=FY(a.x2),a.y2=FY(a.y2),a.w=FY(a.x2-a.x1),a.h=FY(a.y2-a.y1),a.w>0&&a.h>0&&v&&(CU(a,g),SU(a,1)),a},UY=function(e){var t=0,n=function(e){return+!!e<0&&arguments[0]!==void 0?arguments[0]:Nie,t=arguments.length>1?arguments[1]:void 0,n=0;n=0;s--)o(s);return this},sX.removeAllListeners=function(){return this.removeListener(`*`)},sX.emit=sX.trigger=function(e,t,n){var r=this.listeners,i=r.length;return this.emitting++,eB(t)||(t=[t]),Pie(this,function(e,a){n!=null&&(r=[{event:a.event,type:a.type,namespace:a.namespace,callback:n}],i=r.length);for(var o=function(){var n=r[s];if(n.type===a.type&&(!n.namespace||n.namespace===a.namespace||n.namespace===Mie)&&e.eventMatches(e.context,n,a)){var i=[a];t!=null&&vH(i,t),e.beforeEmit(e.context,n,a),n.conf&&n.conf.one&&(e.listeners=e.listeners.filter(function(e){return e!==n}));var o=e.callbackContext(e.context,n,a),c=n.callback.apply(o,i);e.afterEmit(e.context,n,a),c===!1&&(a.stopPropagation(),a.preventDefault())}},s=0;s1&&!r){var i=this.length-1,a=this[i],o=a._private.data.id;this[i]=void 0,this[e]=a,n.set(o,{ele:a,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var t=this._private,n=e._private.data.id,r=t.map.get(n);if(!r)return this;var i=r.index;return this.unmergeAt(i),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&Qz(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=0;r=0;t--)e(this[t])&&this.unmergeAt(t);return this},map:function(e,t){for(var n=[],r=this,i=0;in&&(n=s,r=o)}return{value:n,ele:r}},min:function(e,t){for(var n=1/0,r,i=this,a=0;a=6){var c=(a.allpts.length-2)/4,l=o.bezierPts.length/c;s=[{x:a.allpts[0],y:a.allpts[1]}];for(var u=0;u1){for(var f=!1,p=0;p=0&&i`u`?`undefined`:Uz(Symbol))!=e&&Uz(Symbol.iterator)!=e&&(hX[Symbol.iterator]=function(){var e=this,t={value:void 0,done:!1},n=0,r=this.length;return Pz({next:function(){return n1&&arguments[1]!==void 0?arguments[1]:!0,n=this[0],r=n.cy();if(r.styleEnabled()&&n)return n._private.styleDirty&&(n._private.styleDirty=!1,r.style().apply(n)),n._private.style[e]??(t?r.style().getDefaultProperty(e):null)},numericStyle:function(e){var t=this[0];if(t.cy().styleEnabled()&&t){var n=t.pstyle(e);return n.pfValue===void 0?n.value:n.pfValue}},numericStyleUnits:function(e){var t=this[0];if(t.cy().styleEnabled()&&t)return t.pstyle(e).units},renderedStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=this[0];if(n)return t.style().getRenderedStyle(n,e)},style:function(e,t){var n=this.cy();if(!n.styleEnabled())return this;var r=!1,i=n.style();if(tB(e)){var a=e;i.applyBypass(this,a,r),this.emitAndNotify(`style`)}else if(Qz(e)){if(t===void 0){var o=this[0];return o?i.getStylePropertyValue(o,e):void 0}i.applyBypass(this,e,t,r),this.emitAndNotify(`style`)}else if(e===void 0){var s=this[0];return s?i.getRawStyle(s):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=!1,r=t.style(),i=this;if(e===void 0)for(var a=0;a0&&t.push(u[0]),t.push(s[0])}return this.spawn(t,!0).filter(e)},`neighborhood`),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),DX.neighbourhood=DX.neighborhood,DX.closedNeighbourhood=DX.closedNeighborhood,DX.openNeighbourhood=DX.openNeighborhood,jB(DX,{source:pY(function(e){var t=this[0],n;return t&&(n=t._private.source||t.cy().collection()),n&&e?n.filter(e):n},`source`),target:pY(function(e){var t=this[0],n;return t&&(n=t._private.target||t.cy().collection()),n&&e?n.filter(e):n},`target`),sources:jX({attr:`source`}),targets:jX({attr:`target`})});function jX(e){return function(t){for(var n=[],r=0;r0);return a},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),DX.componentsOf=DX.components;var PX=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e===void 0)oH(`A collection must have a reference to the core`);else{var i=new xH,a=!1;if(!t)t=[];else if(t.length>0&&tB(t[0])&&!oB(t[0])){a=!0;for(var o=[],s=new wH,c=0,l=t.length;c0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=this,r=n.cy(),i=r._private,a=[],o=[],s,c=0,l=n.length;c0){for(var P=s.length===n.length?n:new PX(r,s),F=0;F0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=this,r=[],i=new wH,a=n._private.cy;function o(e){for(var t=e._private.edges,n=0;n0&&(e?T.emitAndNotify(`remove`):t&&T.emit(`remove`));for(var E=0;E1e-12*u*u){var p=-zie(u<0?u-Math.sqrt(d):u+Math.sqrt(d));f=p+l/p||0}else{var m=Math.sqrt(l);f=2*m*Math.cos(Math.acos(Math.max(-1,Math.min(1,-u/(l*m))))/3)}return Math.min(1,a/(f+s))}function Vie(e,t,n,r){if(arguments.length!==4)return!1;for(var i=0;i<4;++i)if(typeof arguments[i]!=`number`||isNaN(arguments[i])||!isFinite(arguments[i]))return!1;e=Math.min(e,1),n=Math.min(n,1),e=Math.max(e,0),n=Math.max(n,0);var a=e===t&&n===r,o=(3*e-3*n+1)/2,s=n-2*e,c=e,l=3*t-3*r+1,u=3*(r-2*t),d=3*t,f=function(e){if(a)return e;if(e<=0)return 0;if(e>=1)return 1;var t=Bie(e,o,s,c);return((l*t+u)*t+d)*t};f.getControlPoints=function(){return[{x:e,y:t},{x:n,y:r}]};var p=`generateBezier(`+[e,t,n,r]+`)`;return f.toString=function(){return p},f}var Hie=function(){function e(e){return-e.tension*e.x-e.friction*e.v}function t(t,n,r){var i={x:t.x+r.dx*n,v:t.v+r.dv*n,tension:t.tension,friction:t.friction};return{dx:i.v,dv:e(i)}}function n(n,r){var i={dx:n.v,dv:e(n)},a=t(n,r*.5,i),o=t(n,r*.5,a),s=t(n,r,o),c=1/6*(i.dx+2*(a.dx+o.dx)+s.dx),l=1/6*(i.dv+2*(a.dv+o.dv)+s.dv);return n.x+=c*r,n.v+=l*r,n}return function e(t,r,i){var a={x:-1,v:0,tension:null,friction:null},o=[0],s=0,c=1e-4,l=.016,u,d,f;for(t=parseFloat(t)||500,r=parseFloat(r)||20,i||=null,a.tension=t,a.friction=r,u=i!==null,u?(s=e(t,r),d=s/i*l):d=l;f=n(f||a,d),o.push(1+f.x),s+=16,Math.abs(f.x)>c&&Math.abs(f.v)>c;);return u?function(e){return o[e*(o.length-1)|0]}:s}}(),IX=function(e,t,n,r){var i=Vie(e,t,n,r);return function(e,t,n){return e+(t-e)*i(n)}},LX={linear:function(e,t,n){return e+(t-e)*n},ease:IX(.25,.1,.25,1),"ease-in":IX(.42,0,1,1),"ease-out":IX(0,0,.58,1),"ease-in-out":IX(.42,0,.58,1),"ease-in-sine":IX(.47,0,.745,.715),"ease-out-sine":IX(.39,.575,.565,1),"ease-in-out-sine":IX(.445,.05,.55,.95),"ease-in-quad":IX(.55,.085,.68,.53),"ease-out-quad":IX(.25,.46,.45,.94),"ease-in-out-quad":IX(.455,.03,.515,.955),"ease-in-cubic":IX(.55,.055,.675,.19),"ease-out-cubic":IX(.215,.61,.355,1),"ease-in-out-cubic":IX(.645,.045,.355,1),"ease-in-quart":IX(.895,.03,.685,.22),"ease-out-quart":IX(.165,.84,.44,1),"ease-in-out-quart":IX(.77,0,.175,1),"ease-in-quint":IX(.755,.05,.855,.06),"ease-out-quint":IX(.23,1,.32,1),"ease-in-out-quint":IX(.86,0,.07,1),"ease-in-expo":IX(.95,.05,.795,.035),"ease-out-expo":IX(.19,1,.22,1),"ease-in-out-expo":IX(1,0,0,1),"ease-in-circ":IX(.6,.04,.98,.335),"ease-out-circ":IX(.075,.82,.165,1),"ease-in-out-circ":IX(.785,.135,.15,.86),spring:function(e,t,n){if(n===0)return LX.linear;var r=Hie(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":IX};function RX(e,t,n,r,i){if(r===1||t===n)return n;var a=i(t,n,r);return e==null||((e.roundValue||e.color)&&(a=Math.round(a)),e.min!==void 0&&(a=Math.max(a,e.min)),e.max!==void 0&&(a=Math.min(a,e.max))),a}function zX(e,t){return e.pfValue!=null||e.value!=null?e.pfValue!=null&&(t==null||t.type.units!==`%`)?e.pfValue:e.value:e}function BX(e,t,n,r,i){var a=i==null?null:i.type;n<0?n=0:n>1&&(n=1);var o=zX(e,i),s=zX(t,i);if($(o)&&$(s))return RX(a,o,s,n,r);if(eB(o)&&eB(s)){for(var c=[],l=0;l0?(d===`spring`&&f.push(o.duration),o.easingImpl=LX[d].apply(null,f)):o.easingImpl=LX[d]}}var p=o.easingImpl,m=o.duration===0?1:(n-c)/o.duration;if(o.applying&&(m=o.progress),m<0?m=0:m>1&&(m=1),o.delay==null){var h=o.startPosition,g=o.position;if(g&&i&&!e.locked()){var _={};VX(h.x,g.x)&&(_.x=BX(h.x,g.x,m,p)),VX(h.y,g.y)&&(_.y=BX(h.y,g.y,m,p)),e.position(_)}var v=o.startPan,y=o.pan,b=a.pan,x=y!=null&&r;x&&(VX(v.x,y.x)&&(b.x=BX(v.x,y.x,m,p)),VX(v.y,y.y)&&(b.y=BX(v.y,y.y,m,p)),e.emit(`pan`));var S=o.startZoom,C=o.zoom,w=C!=null&&r;w&&(VX(S,C)&&(a.zoom=gU(a.minZoom,BX(S,C,m,p),a.maxZoom)),e.emit(`zoom`)),(x||w)&&e.emit(`viewport`);var T=o.style;if(T&&T.length>0&&i){for(var E=0;E=0;t--)(0,e[t])();e.splice(0,e.length)},u=a.length-1;u>=0;u--){var d=a[u],f=d._private;f.stopped?(a.splice(u,1),f.hooked=!1,f.playing=!1,f.started=!1,l(f.frames)):(f.playing||f.applying)&&(f.playing&&f.applying&&(f.applying=!1),f.started||Wie(t,d,e),Uie(t,d,e,n),f.applying&&=!1,l(f.frames),f.step!=null&&f.step(e),d.completed()&&(a.splice(u,1),f.hooked=!1,f.playing=!1,f.started=!1,l(f.completes)),s=!0)}return!n&&a.length===0&&o.length===0&&r.push(t),s}for(var a=!1,o=0;o0?t.notify(`draw`,n):t.notify(`draw`)),n.unmerge(r),t.emit(`step`)}var Gie={animate:BJ.animate(),animation:BJ.animation(),animated:BJ.animated(),clearQueue:BJ.clearQueue(),delay:BJ.delay(),delayAnimation:BJ.delayAnimation(),stop:BJ.stop(),addToAnimationPool:function(e){var t=this;t.styleEnabled()&&t._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,!e.styleEnabled())return;function t(){e._private.animationsRunning&&PV(function(n){HX(n,e),t()})}var n=e.renderer();n&&n.beforeRender?n.beforeRender(function(t,n){HX(n,e)},n.beforeRenderPriorities.animations):t()}},Kie={qualifierCompare:function(e,t){return e==null||t==null?e==null&&t==null:e.sameText(t)},eventMatches:function(e,t,n){var r=t.qualifier;return r==null||e!==n.target&&oB(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e,t.target=e},callbackContext:function(e,t,n){return t.qualifier==null?e:n.target}},UX=function(e){return Qz(e)?new uY(e):e},WX={createEmitter:function(){var e=this._private;return e.emitter||=new oX(Kie,this),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,UX(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,UX(t),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,n){return this.emitter().one(e,UX(t),n),this},once:function(e,t,n){return this.emitter().one(e,UX(t),n),this},emit:function(e,t){return this.emitter().emit(e,t),this},emitAndNotify:function(e,t){return this.emit(e),this.notify(e,t),this}};BJ.eventAliasesOn(WX);var GX={png:function(e){var t=this._private.renderer;return e||={},t.png(e)},jpg:function(e){var t=this._private.renderer;return e||={},e.bg=e.bg||`#fff`,t.jpg(e)}};GX.jpeg=GX.jpg;var KX={layout:function(e){var t=this;if(e==null)oH(`Layout options must be specified to make a layout`);else if(e.name==null)oH("A `name` must be specified to make a layout");else{var n=e.name,r=t.extension(`layout`,n);if(r==null)oH("No such layout `"+n+"` found. Did you forget to import it and `cytoscape.use()` it?");else return new r(jB({},e,{cy:t,eles:Qz(e.eles)?t.$(e.eles):e.eles==null?t.$():e.eles}))}}};KX.createLayout=KX.makeLayout=KX.layout;var qie={notify:function(e,t){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var r=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();t!=null&&r.merge(t)}else if(n.notificationsEnabled){var i=this.renderer();!this.destroyed()&&i&&i.notify(e,t)}},notifications:function(e){var t=this._private;return e===void 0?t.notificationsEnabled:(t.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var e=this._private;return e.batchCount??=0,e.batchCount===0&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var e=this._private;if(e.batchCount===0)return this;if(e.batchCount--,e.batchCount===0){e.batchStyleEles.updateStyle();var t=this.renderer();Object.keys(e.batchNotifications).forEach(function(n){var r=e.batchNotifications[n];r.empty()?t.notify(n):t.notify(n,r)})}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var t=this;return this.batch(function(){for(var n=Object.keys(e),r=0;r0;)t.removeChild(t.childNodes[0]);e._private.renderer=null,e.mutableElements().forEach(function(e){var t=e._private;t.rscratch={},t.rstyle={},t.animation.current=[],t.animation.queue=[]})},onRender:function(e){return this.on(`render`,e)},offRender:function(e){return this.off(`render`,e)}};qX.invalidateDimensions=qX.resize;var JX={collection:function(e,t){return Qz(e)?this.$(e):aB(e)?e.collection():eB(e)?(t||={},new PX(this,e,t.unique,t.removed)):new PX(this)},nodes:function(e){var t=this.$(function(e){return e.isNode()});return e?t.filter(e):t},edges:function(e){var t=this.$(function(e){return e.isEdge()});return e?t.filter(e):t},$:function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},mutableElements:function(){return this._private.elements}};JX.elements=JX.filter=JX.$;var YX={},XX=`t`,Yie=`f`;YX.apply=function(e){for(var t=this,n=t._private.cy.collection(),r=0;r0;if(f||d&&p){var m=void 0;f&&p||f?m=l.properties:p&&(m=l.mappedProperties);for(var h=0;h1&&(b=1),s.color){var S=r.valueMin[0],C=r.valueMax[0],w=r.valueMin[1],T=r.valueMax[1],E=r.valueMin[2],D=r.valueMax[2],O=r.valueMin[3]==null?1:r.valueMin[3],k=r.valueMax[3]==null?1:r.valueMax[3],A=[Math.round(S+(C-S)*b),Math.round(w+(T-w)*b),Math.round(E+(D-E)*b),O+(k-O)*b];a={bypass:r.bypass,name:r.name,value:A,strValue:`rgba(`+A[0]+`, `+A[1]+`, `+A[2]+`, `+A[3]+`)`}}else if(s.number){var j=r.valueMin+(r.valueMax-r.valueMin)*b;a=this.parse(r.name,j,r.bypass,f)}else return!1;if(!a)return h(),!1;a.mapping=r,r=a;break;case o.data:for(var M=r.field.split(`.`),N=d.data,P=0;P0&&a>0){for(var s={},c=!1,l=0;l0?e.delayAnimation(o).play().promise().then(t):t()}).then(function(){return e.animation({style:s,duration:a,easing:e.pstyle(`transition-timing-function`).value,queue:!1}).play().promise()}).then(function(){n.removeBypasses(e,i),e.emitAndNotify(`style`),r.transitioning=!1})}else r.transitioning&&=(this.removeBypasses(e,i),e.emitAndNotify(`style`),!1)},YX.checkTrigger=function(e,t,n,r,i,a){var o=this.properties[t],s=i(o);e.removed()||s!=null&&s(n,r,e)&&a(o)},YX.checkZOrderTrigger=function(e,t,n,r){var i=this;this.checkTrigger(e,t,n,r,function(e){return e.triggersZOrder},function(){i._private.cy.notify(`zorder`,e)})},YX.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBounds},function(t){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache()})},YX.checkConnectedEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBoundsOfConnectedEdges},function(t){e.connectedEdges().forEach(function(e){e.dirtyBoundingBoxCache()})})},YX.checkParallelEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBoundsOfParallelEdges},function(t){e.parallelEdges().forEach(function(e){e.dirtyBoundingBoxCache()})})},YX.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r),this.checkConnectedEdgesBoundsTrigger(e,t,n,r),this.checkParallelEdgesBoundsTrigger(e,t,n,r)};var ZX={};ZX.applyBypass=function(e,t,n,r){var i=this,a=[],o=!0;if(t===`*`||t===`**`){if(n!==void 0)for(var s=0;si.length?r.substr(i.length):``}function c(){a=a.length>o.length?a.substr(o.length):``}for(;!r.match(/^\s*$/);){var l=r.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!l){cH(`Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: `+r);break}i=l[0];var u=l[1];if(u!==`core`&&new uY(u).invalid)cH(`Skipping parsing of block: Invalid selector found in string stylesheet: `+u),s();else{var d=l[2],f=!1;a=d;for(var p=[];!a.match(/^\s*$/);){var m=a.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!m){cH(`Skipping parsing of block: Invalid formatting of style property and value definitions found in:`+d),f=!0;break}o=m[0];var h=m[1],g=m[2];t.properties[h]?n.parse(h,g)?(p.push({name:h,val:g}),c()):(cH(`Skipping property: Invalid property definition in: `+o),c()):(cH(`Skipping property: Invalid property name in: `+o),c())}if(f){s();break}n.selector(u);for(var _=0;_=7&&t[0]===`d`&&(u=new RegExp(s.data.regex).exec(t))){if(n)return!1;var f=s.data;return{name:e,value:u,strValue:``+t,mapped:f,field:u[1],bypass:n}}if(t.length>=10&&t[0]===`m`&&(d=new RegExp(s.mapData.regex).exec(t))){if(n||l.multiple)return!1;var p=s.mapData;if(!(l.color||l.number))return!1;var m=this.parse(e,d[4]);if(!m||m.mapped)return!1;var h=this.parse(e,d[5]);if(!h||h.mapped)return!1;if(m.pfValue===h.pfValue||m.strValue===h.strValue)return cH("`"+e+`: `+t+"` is not a valid mapper because the output range is zero; converting to `"+e+`: `+m.strValue+"`"),this.parse(e,m.strValue);if(l.color){var g=m.value,_=h.value;if(g[0]===_[0]&&g[1]===_[1]&&g[2]===_[2]&&(g[3]===_[3]||(g[3]==null||g[3]===1)&&(_[3]==null||_[3]===1)))return!1}return{name:e,value:d,strValue:``+t,mapped:p,field:d[1],fieldMin:parseFloat(d[2]),fieldMax:parseFloat(d[3]),valueMin:m.value,valueMax:h.value,bypass:n}}}if(l.multiple&&r!==`multiple`){var v=c?t.split(/\s+/):eB(t)?t:[t];if(l.evenMultiple&&v.length%2!=0)return null;for(var y=[],b=[],x=[],S=``,C=!1,w=0;w0?` `:``)+T.strValue}return l.validate&&!l.validate(y,b)?null:l.singleEnum&&C?y.length===1&&Qz(y[0])?{name:e,value:y[0],strValue:y[0],bypass:n}:null:{name:e,value:y,pfValue:x,strValue:S,bypass:n,units:b}}var E=function(){for(var r=0;rl.max||l.strictMax&&t===l.max))return null;var j={name:e,value:t,strValue:``+t+(D||``),units:D,bypass:n};return j.pfValue=l.unitless||D!==`px`&&D!==`em`||D===`px`||!D?t:this.getEmSizeInPixels()*t,(D===`ms`||D===`s`)&&(j.pfValue=D===`ms`?t:1e3*t),(D===`deg`||D===`rad`)&&(j.pfValue=D===`rad`?t:oU(t)),D===`%`&&(j.pfValue=t/100),j}if(l.propList){var M=[],N=``+t;if(N!==`none`){for(var P=N.split(/\s*,\s*|\s+/),F=0;F0&&o>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0){s=Math.min((a-2*t)/n.w,(o-2*t)/n.h),s=s>this._private.maxZoom?this._private.maxZoom:s,s=s=n.minZoom&&(n.maxZoom=t),this},minZoom:function(e){return e===void 0?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return e===void 0?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var t=this._private,n=t.pan,r=t.zoom,i,a,o=!1;if(t.zoomingEnabled||(o=!0),$(e)?a=e:tB(e)&&(a=e.level,e.position==null?e.renderedPosition!=null&&(i=e.renderedPosition):i=XH(e.position,r,n),i!=null&&!t.panningEnabled&&(o=!0)),a=a>t.maxZoom?t.maxZoom:a,a=at.maxZoom||!t.zoomingEnabled?a=!0:(t.zoom=s,i.push(`zoom`))}if(r&&(!a||!e.cancelOnFailedZoom)&&t.panningEnabled){var c=e.pan;$(c.x)&&(t.pan.x=c.x,o=!1),$(c.y)&&(t.pan.y=c.y,o=!1),o||i.push(`pan`)}return i.length>0&&(i.push(`viewport`),this.emit(i.join(` `)),this.notify(`viewport`)),this},center:function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.emit(`pan viewport`),this.notify(`viewport`)),this},getCenterPan:function(e,t){if(this._private.panningEnabled){if(Qz(e)){var n=e;e=this.mutableElements().filter(n)}else aB(e)||(e=this.mutableElements());if(e.length!==0){var r=e.boundingBox(),i=this.width(),a=this.height();return t=t===void 0?this._private.zoom:t,{x:(i-t*(r.x1+r.x2))/2,y:(a-t*(r.y1+r.y2))/2}}}},reset:function(){return!this._private.panningEnabled||!this._private.zoomingEnabled||this.viewport({pan:{x:0,y:0},zoom:1}),this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e=this._private,t=e.container,n=this;return e.sizeCache=e.sizeCache||(t?function(){var e=n.window().getComputedStyle(t),r=function(t){return parseFloat(e.getPropertyValue(t))};return{width:t.clientWidth-r(`padding-left`)-r(`padding-right`),height:t.clientHeight-r(`padding-top`)-r(`padding-bottom`)}}():{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,t=this._private.zoom,n=this.renderedExtent(),r={x1:(n.x1-e.x)/t,x2:(n.x2-e.x)/t,y1:(n.y1-e.y)/t,y2:(n.y2-e.y)/t};return r.w=r.x2-r.x1,r.h=r.y2-r.y1,r},renderedExtent:function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}},multiClickDebounceTime:function(e){if(e)this._private.multiClickDebounceTime=e;else return this._private.multiClickDebounceTime;return this}};cZ.centre=cZ.center,cZ.autolockNodes=cZ.autolock,cZ.autoungrabifyNodes=cZ.autoungrabify;var lZ={data:BJ.data({field:`data`,bindingEvent:`data`,allowBinding:!0,allowSetting:!0,settingEvent:`data`,settingTriggersEvent:!0,triggerFnName:`trigger`,allowGetting:!0,updateStyle:!0}),removeData:BJ.removeData({field:`data`,event:`data`,triggerFnName:`trigger`,triggerEvent:!0,updateStyle:!0}),scratch:BJ.data({field:`scratch`,bindingEvent:`scratch`,allowBinding:!0,allowSetting:!0,settingEvent:`scratch`,settingTriggersEvent:!0,triggerFnName:`trigger`,allowGetting:!0,updateStyle:!0}),removeScratch:BJ.removeData({field:`scratch`,event:`scratch`,triggerFnName:`trigger`,triggerEvent:!0,updateStyle:!0})};lZ.attr=lZ.data,lZ.removeAttr=lZ.removeData;var uZ=function(e){var t=this;e=jB({},e);var n=e.container;n&&!iB(n)&&iB(n[0])&&(n=n[0]);var r=n?n._cyreg:null;r||={},r&&r.cy&&(r.cy.destroy(),r={});var i=r.readies=r.readies||[];n&&(n._cyreg=r),r.cy=t;var a=Gz!==void 0&&n!==void 0&&!e.headless,o=e;o.layout=jB({name:a?`grid`:`null`},o.layout),o.renderer=jB({name:a?`canvas`:`null`},o.renderer);var s=function(e,t,n){return t===void 0?n===void 0?e:n:t},c=this._private={container:n,ready:!1,options:o,elements:new PX(this),listeners:[],aniEles:new PX(this),data:o.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:s(!0,o.zoomingEnabled),userZoomingEnabled:s(!0,o.userZoomingEnabled),panningEnabled:s(!0,o.panningEnabled),userPanningEnabled:s(!0,o.userPanningEnabled),boxSelectionEnabled:s(!0,o.boxSelectionEnabled),autolock:s(!1,o.autolock,o.autolockNodes),autoungrabify:s(!1,o.autoungrabify,o.autoungrabifyNodes),autounselectify:s(!1,o.autounselectify),styleEnabled:o.styleEnabled===void 0?a:o.styleEnabled,zoom:$(o.zoom)?o.zoom:1,pan:{x:tB(o.pan)&&$(o.pan.x)?o.pan.x:0,y:tB(o.pan)&&$(o.pan.y)?o.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:s(250,o.multiClickDebounceTime)};this.createEmitter(),this.selectionType(o.selectionType),this.zoomRange({min:o.minZoom,max:o.maxZoom});var l=function(e,t){if(e.some(mB))return VG.all(e).then(t);t(e)};c.styleEnabled&&t.setStyle([]);var u=jB({},o,o.renderer);t.initRenderer(u);var d=function(e,n,r){t.notifications(!1);var i=t.mutableElements();i.length>0&&i.remove(),e!=null&&(tB(e)||eB(e))&&t.add(e),t.one(`layoutready`,function(e){t.notifications(!0),t.emit(e),t.one(`load`,n),t.emitAndNotify(`load`)}).one(`layoutstop`,function(){t.one(`done`,r),t.emit(`done`)});var a=jB({},t._private.options.layout);a.eles=t.elements(),t.layout(a).run()};l([o.style,o.elements],function(e){var n=e[0],a=e[1];c.styleEnabled&&t.style().append(n),d(a,function(){t.startAnimationLoop(),c.ready=!0,$z(o.ready)&&t.on(`ready`,o.ready);for(var e=0;e0,s=!!e.boundingBox,c=_U(s?e.boundingBox:structuredClone(t.extent())),l;if(aB(e.roots))l=e.roots;else if(eB(e.roots)){for(var u=[],d=0;d0;){var A=k(),j=T(A,D);if(j)A.outgoers().filter(function(e){return e.isNode()&&n.has(e)}).forEach(O);else if(j===null){cH("Detected double maximal shift for node `"+A.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}var M=0;if(e.avoidOverlap)for(var N=0;N0&&_[0].length<=3?a/2:0),l=2*Math.PI/_[r].length*i;return r===0&&_[0].length===1&&(o=1),{x:ae.x+o*Math.cos(l),y:ae.y+o*Math.sin(l)}}var u=_[r].length,d=Math.max(u===1?0:s?(c.w-e.padding*2-oe.w)/((e.grid?ce:u)-1):(c.w-e.padding*2-oe.w)/((e.grid?ce:u)+1),M);return{x:ae.x+(i+1-(u+1)/2)*d,y:ae.y+(r+1-(z+1)/2)*se}},V={downward:0,leftward:90,upward:180,rightward:-90};return Object.keys(V).indexOf(e.direction)===-1&&oH(`Invalid direction '${e.direction}' specified for breadthfirst layout. Valid values are: ${Object.keys(V).join(`, `)}`),n.nodes().layoutPositions(this,e,function(t){return ZV(le(t),c,V[e.direction])}),this};var eae={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function hZ(e){this.options=jB({},eae,e)}hZ.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,i=t.counterclockwise===void 0?t.clockwise:!t.counterclockwise,a=r.nodes().not(`:parent`);t.sort&&(a=a.sort(t.sort));for(var o=_U(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},c=(t.sweep===void 0?2*Math.PI-2*Math.PI/a.length:t.sweep)/Math.max(1,a.length-1),l,u=0,d=0;d1&&t.avoidOverlap){u*=1.75;var h=Math.cos(c)-Math.cos(0),g=Math.sin(c)-Math.sin(0),_=Math.sqrt(u*u/(h*h+g*g));l=Math.max(_,l)}return r.nodes().layoutPositions(this,t,function(e,n){var r=t.startAngle+n*c*(i?1:-1),a=l*Math.cos(r),o=l*Math.sin(r);return{x:s.x+a,y:s.y+o}}),this};var tae={fit:!0,padding:30,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function gZ(e){this.options=jB({},tae,e)}gZ.prototype.run=function(){for(var e=this.options,t=e,n=t.counterclockwise===void 0?t.clockwise:!t.counterclockwise,r=e.cy,i=t.eles,a=i.nodes().not(`:parent`),o=_U(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},c=[],l=0,u=0;u0&&Math.abs(_[0].value-y.value)>=h&&(_=[],g.push(_)),_.push(y)}var b=l+t.minNodeSpacing;if(!t.avoidOverlap){var x=g.length>0&&g[0].length>1,S=(Math.min(o.w,o.h)/2-b)/(g.length+x?1:0);b=Math.min(b,S)}for(var C=0,w=0;w1&&t.avoidOverlap){var D=Math.cos(E)-Math.cos(0),O=Math.sin(E)-Math.sin(0),k=Math.sqrt(b*b/(D*D+O*O));C=Math.max(k,C)}T.r=C,C+=b}if(t.equidistant){for(var A=0,j=0,M=0;M=e.numIter||(cae(r,e),r.temperature*=e.coolingFactor,r.temperature=e.animationThreshold&&a(),PV(u)):(wZ(r,e),s())};u()}else{for(;l;)l=o(c),c++;wZ(r,e),s()}return this},vZ.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit(`layoutstop`),this},vZ.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var rae=function(e,t,n){for(var r=n.eles.edges(),i=n.eles.nodes(),a=_U(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),o={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:r.size(),temperature:n.initialTemp,clientWidth:a.w,clientHeight:a.h,boundingBox:a},s=n.eles.components(),c={},l=0;l0){o.graphSet.push(C);for(var l=0;lr.count?0:r.graph},yZ=function(e,t,n,r){var i=r.graphSet[n];if(-10)var c=r.nodeOverlap*s,l=Math.sqrt(i*i+a*a),u=c*i/l,d=c*a/l;else var f=SZ(e,i,a),p=SZ(t,-1*i,-1*a),m=p.x-f.x,h=p.y-f.y,g=m*m+h*h,l=Math.sqrt(g),c=(e.nodeRepulsion+t.nodeRepulsion)/g,u=c*m/l,d=c*h/l;e.isLocked||(e.offsetX-=u,e.offsetY-=d),t.isLocked||(t.offsetX+=u,t.offsetY+=d)}},dae=function(e,t,n,r){if(n>0)var i=e.maxX-t.minX;else var i=t.maxX-e.minX;if(r>0)var a=e.maxY-t.minY;else var a=t.maxY-e.minY;return i>=0&&a>=0?Math.sqrt(i*i+a*a):0},SZ=function(e,t,n){var r=e.positionX,i=e.positionY,a=e.height||1,o=e.width||1,s=n/t,c=a/o,l={};return t===0&&0n?(l.x=r,l.y=i+a/2,l):0t&&-1*c<=s&&s<=c?(l.x=r-o/2,l.y=i-o*n/2/t,l):0=c)?(l.x=r+a*t/2/n,l.y=i+a/2,l):(0>n&&(s<=-1*c||s>=c)&&(l.x=r-a*t/2/n,l.y=i-a/2),l)},fae=function(e,t){for(var n=0;nn){var h=t.gravity*f/m,g=t.gravity*p/m;d.offsetX+=h,d.offsetY+=g}}}}},mae=function(e,t){var n=[],r=0,i=-1;for(n.push.apply(n,e.graphSet[0]),i+=e.graphSet[0].length;r<=i;){var a=n[r++],o=e.idToIndex[a],s=e.layoutNodes[o],c=s.children;if(0n)var i={x:n*e/r,y:n*t/r};else var i={x:e,y:t};return i},CZ=function(e,t){var n=e.parentId;if(n!=null){var r=t.layoutNodes[t.idToIndex[n]],i=!1;if((r.maxX==null||e.maxX+r.padRight>r.maxX)&&(r.maxX=e.maxX+r.padRight,i=!0),(r.minX==null||e.minX-r.padLeftr.maxY)&&(r.maxY=e.maxY+r.padBottom,i=!0),(r.minY==null||e.minY-r.padToph&&(f+=m+t.componentSpacing,d=0,p=0,m=0)}}},_ae={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function TZ(e){this.options=jB({},_ae,e)}TZ.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,i=r.nodes().not(`:parent`);t.sort&&(i=i.sort(t.sort));var a=_U(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()});if(a.h===0||a.w===0)r.nodes().layoutPositions(this,t,function(e){return{x:a.x1,y:a.y1}});else{var o=i.size(),s=Math.sqrt(o*a.h/a.w),c=Math.round(s),l=Math.round(a.w/a.h*s),u=function(e){if(e==null)return Math.min(c,l);Math.min(c,l)==c?c=e:l=e},d=function(e){if(e==null)return Math.max(c,l);Math.max(c,l)==c?c=e:l=e},f=t.rows,p=t.cols==null?t.columns:t.cols;if(f!=null&&p!=null)c=f,l=p;else if(f!=null&&p==null)c=f,l=Math.ceil(o/c);else if(f==null&&p!=null)l=p,c=Math.ceil(o/l);else if(l*c>o){var m=u(),h=d();(m-1)*h>=o?u(m-1):(h-1)*m>=o&&d(h-1)}else for(;l*c=o?d(_+1):u(g+1)}var v=a.w/l,y=a.h/c;if(t.condense&&(v=0,y=0),t.avoidOverlap)for(var b=0;b=l&&(j=0,A++)},N={},P=0;P(u=RU(t,n,d[f],d[f+1],d[f+2],d[f+3])))return{sqDist:u}}else if(a.edgeType===`bezier`||a.edgeType===`multibezier`||a.edgeType===`self`||a.edgeType===`compound`){for(var p=a.allpts,m=0;m+5(u=LU(t,n,p[m],p[m+1],p[m+2],p[m+3],p[m+4],p[m+5])))return{sqDist:u}}for(var h=[{name:`source`,x:a.arrowStartX,y:a.arrowStartY,angle:a.srcArrowAngle},{name:`target`,x:a.arrowEndX,y:a.arrowEndY,angle:a.tgtArrowAngle},{name:`mid-source`,x:a.midX,y:a.midY,angle:a.midsrcArrowAngle},{name:`mid-target`,x:a.midX,y:a.midY,angle:a.midtgtArrowAngle}],g=0;g=0;y--){var b=_[y];if(h.has(b._private.data.id)){var x=!1;b.isNode()?(c&&(x=i.checkNodeHitAt(b,e,t,f)),!x&&l&&(x=i.checkLabelHitAt(b,e,t,null,p))):(c&&(x=i.checkEdgeHitAt(b,e,t,m)!=null),!x&&l&&(x=i.checkLabelHitAt(b,e,t,null,p)),!x&&u&&(x=i.checkLabelHitAt(b,e,t,`source`,p)),!x&&d&&(x=i.checkLabelHitAt(b,e,t,`target`,p))),x&&v.push(b)}}return v},NZ.findNearestElement=function(e,t,n,r){return this.findNearestElements(e,t,n,r)[0]},NZ.findNearestElements=function(e,t,n,r){var i=this,a=this,o=a.getCachedZSortedEles(),s=[],c=a.cy.zoom(),l=a.cy.hasCompoundNodes(),u=(r?24:8)/c,d=(r?8:2)/c,f=(r?8:2)/c,p=1/0,m,h;n&&(o=o.interactive);function g(e,t){if(e.isNode()){if(h)return;h=e,s.push(e)}if(e.isEdge()&&(t==null||t(v=RU(e,t,y[b],y[b+1],y[b+2],y[b+3])))return g(n,v),!0}else if(o.edgeType===`bezier`||o.edgeType===`multibezier`||o.edgeType===`self`||o.edgeType===`compound`){for(var y=o.allpts,b=0;b+5(v=LU(e,t,y[b],y[b+1],y[b+2],y[b+3],y[b+4],y[b+5])))return g(n,v),!0}for(var m=m||r.source,h=h||r.target,x=[{name:`source`,x:o.arrowStartX,y:o.arrowStartY,angle:o.srcArrowAngle},{name:`target`,x:o.arrowEndX,y:o.arrowEndY,angle:o.tgtArrowAngle},{name:`mid-source`,x:o.midX,y:o.midY,angle:o.midsrcArrowAngle},{name:`mid-target`,x:o.midX,y:o.midY,angle:o.midtgtArrowAngle}],b=0;b0&&(_(m),_(h))}function y(n,r){if(i.checkLabelHitAt(n,e,t,r,f))return g(n),!0}for(var b=o.length-1;b>=0;b--){var x=o[b];x.isNode()?_(x)||y(x):v(x)||y(x)||y(x,`source`)||y(x,`target`)}return s},NZ.getAllInBox=function(e,t,n,r){var i=this,a=this.getCachedZSortedEles().interactive,o=2/this.cy.zoom(),s=[],c=Math.min(e,n),l=Math.max(e,n),u=Math.min(t,r),d=Math.max(t,r);e=c,n=l,t=u,r=d;var f=_U({x1:e,y1:t,x2:n,y2:r}),p=[{x:f.x1,y:f.y1},{x:f.x2,y:f.y1},{x:f.x2,y:f.y2},{x:f.x1,y:f.y2}],m=[[p[0],p[1]],[p[1],p[2]],[p[2],p[3]],[p[3],p[0]]];function h(e,t){return i.getLabelHitPolygon(e,t,o)}function g(e,t,n,r){function i(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return i(e,n,r)!==i(t,n,r)&&i(e,t,n)!==i(e,t,r)}for(var _=0;_0?-(Math.PI-e.ang):Math.PI+e.ang},Cae=function(e,t,n,r,i){e===$Z?Sae(RZ,LZ):eQ(t,e,LZ),eQ(t,n,RZ),zZ=LZ.nx*RZ.ny-LZ.ny*RZ.nx,BZ=LZ.nx*RZ.nx-LZ.ny*-RZ.ny,UZ=Math.asin(Math.max(-1,Math.min(1,zZ))),Math.abs(UZ)<1e-6?(FZ=t.x,IZ=t.y,GZ=qZ=0):(VZ=1,HZ=!1,BZ<0?UZ<0?UZ=Math.PI+UZ:(UZ=Math.PI-UZ,VZ=-1,HZ=!0):UZ>0&&(VZ=-1,HZ=!0),qZ=t.radius===void 0?r:t.radius,WZ=UZ/2,JZ=Math.min(LZ.len/2,RZ.len/2),i?(KZ=Math.abs(Math.cos(WZ)*qZ/Math.sin(WZ)),KZ>JZ?(KZ=JZ,GZ=Math.abs(KZ*Math.sin(WZ)/Math.cos(WZ))):GZ=qZ):(KZ=Math.min(JZ,qZ),GZ=Math.abs(KZ*Math.sin(WZ)/Math.cos(WZ))),ZZ=t.x+RZ.nx*KZ,QZ=t.y+RZ.ny*KZ,FZ=ZZ-RZ.ny*GZ*VZ,IZ=QZ+RZ.nx*GZ*VZ,YZ=t.x+LZ.nx*KZ,XZ=t.y+LZ.ny*KZ,$Z=t)};function tQ(e,t){t.radius===0?e.lineTo(t.cx,t.cy):e.arc(t.cx,t.cy,t.radius,t.startAngle,t.endAngle,t.counterClockwise)}function nQ(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0;return r===0||t.radius===0?{cx:t.x,cy:t.y,radius:0,startX:t.x,startY:t.y,stopX:t.x,stopY:t.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:(Cae(e,t,n,r,i),{cx:FZ,cy:IZ,radius:GZ,startX:YZ,startY:XZ,stopX:ZZ,stopY:QZ,startAngle:LZ.ang+Math.PI/2*VZ,endAngle:RZ.ang-Math.PI/2*VZ,counterClockwise:HZ})}var rQ=.01,wae=Math.sqrt(2*rQ),iQ={};iQ.findMidptPtsEtc=function(e,t){var n=t.posPts,r=t.intersectionPts,i=t.vectorNormInverse,a,o=e.pstyle(`source-endpoint`),s=e.pstyle(`target-endpoint`),c=o.units!=null&&s.units!=null,l=function(e,t,n,r){var i=r-t,a=n-e,o=Math.sqrt(a*a+i*i);return{x:-i/o,y:a/o}};switch(e.pstyle(`edge-distances`).value){case`node-position`:a=n;break;case`intersection`:a=r;break;case`endpoints`:if(c){var u=zz(this.manualEndptToPx(e.source()[0],o),2),d=u[0],f=u[1],p=zz(this.manualEndptToPx(e.target()[0],s),2),m=p[0],h=p[1],g={x1:d,y1:f,x2:m,y2:h};i=l(d,f,m,h),a=g}else cH(`Edge ${e.id()} has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).`),a=r}return{midptPts:a,vectorNormInverse:i}},iQ.findHaystackPoints=function(e){for(var t=0;t0?Math.max(e-t,0):Math.min(e+t,0)},O=D(T,C),k=D(E,w),A=function(e,t,n,r){if(!h)return(e+t)/2;var i=lU(t-e),a=e+i*n/2,o=t-i*r/2;return i*(o-a)>=0?(a+o)/2:(e+t)/2},j=!1;_===l?g=Math.abs(O)>Math.abs(k)?i:r:_===c||_===s?(g=r,j=!0):(_===a||_===o)&&(g=i,j=!0);var M=g===r,N=M?k:O,P=M?E:T,F=lU(P),I=!1;!(j&&(y||x))&&(_===s&&P<0||_===c&&P>0||_===a&&P>0||_===o&&P<0)&&(F*=-1,N=F*Math.abs(N),I=!0);var L=y?(b<0?1+b:b)*N:(b<0?N:0)+b*F,ee=function(e){return Math.abs(e)=Math.abs(N)},R=ee(L),z=ee(Math.abs(N)-Math.abs(L));if((R||z)&&!I){if(M){var B=Math.abs(P)<=f/2,te=Math.abs(T)<=p/2;if(B){var ne=A(u.x1,u.x2,d,p);n.segpts=[ne,u.y1,ne,u.y2]}else if(te){var re=A(u.y1,u.y2,f,m);n.segpts=[u.x1,re,u.x2,re]}else n.segpts=[u.x1,u.y2]}else{var ie=Math.abs(P)<=d/2,ae=Math.abs(E)<=m/2;if(ie){var oe=A(u.y1,u.y2,f,m);n.segpts=[u.x1,oe,u.x2,oe]}else if(ae){var se=A(u.x1,u.x2,d,p);n.segpts=[se,u.y1,se,u.y2]}else n.segpts=[u.x2,u.y1]}}else if(M){var ce=u.y1+L+(h?f/2*F:0);n.segpts=[u.x1,ce,u.x2,ce]}else{var le=u.x1+L+(h?d/2*F:0);n.segpts=[le,u.y1,le,u.y2]}if(n.isRound){var V=e.pstyle(`taxi-radius`).value,ue=e.pstyle(`radius-type`).value[0]===`arc-radius`;n.radii=Array(n.segpts.length/2).fill(V),n.isArcRadius=Array(n.segpts.length/2).fill(ue)}},iQ.tryToCorrectInvalidPoints=function(e,t){var n=e._private.rscratch;if(n.edgeType===`bezier`){var r=t.srcPos,i=t.tgtPos,a=t.srcW,o=t.srcH,s=t.tgtW,c=t.tgtH,l=t.srcShape,u=t.tgtShape,d=t.srcCornerRadius,f=t.tgtCornerRadius,p=t.srcRs,m=t.tgtRs,h=!$(n.startX)||!$(n.startY),g=!$(n.arrowStartX)||!$(n.arrowStartY),_=!$(n.endX)||!$(n.endY),v=!$(n.arrowEndX)||!$(n.arrowEndY),y=3,b=e.pstyle(`width`).pfValue,x=y*this.getArrowWidth(b,rZ(e,`source`))*this.arrowShapeWidth,S=y*this.getArrowWidth(b,rZ(e,`target`))*this.arrowShapeWidth,C=uU({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.startX,y:n.startY}),w=Cp.poolIndex()){var m=f;f=p,p=m}var h=c.srcPos=f.position(),g=c.tgtPos=p.position(),_=c.srcW=f.outerWidth(),v=c.srcH=f.outerHeight(),y=c.tgtW=p.outerWidth(),x=c.tgtH=p.outerHeight(),S=c.srcShape=n.nodeShapes[t.getNodeShape(f)],C=c.tgtShape=n.nodeShapes[t.getNodeShape(p)],w=c.srcCornerRadius=f.pstyle(`corner-radius`).value===`auto`?`auto`:f.pstyle(`corner-radius`).pfValue,T=c.tgtCornerRadius=p.pstyle(`corner-radius`).value===`auto`?`auto`:p.pstyle(`corner-radius`).pfValue,E=c.tgtRs=p._private.rscratch,D=c.srcRs=f._private.rscratch;c.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var O=0;O=wae||(te=Math.sqrt(Math.max(B*B,rQ)+Math.max(z*z,rQ)));var ne=c.vector={x:B,y:z},re=c.vectorNorm={x:ne.x/te,y:ne.y/te},ie={x:-re.y,y:re.x};c.nodesOverlap=!$(te)||C.checkPoint(P[0],P[1],0,y,x,g.x,g.y,T,E)||S.checkPoint(I[0],I[1],0,_,v,h.x,h.y,w,D),c.vectorNormInverse=ie,l={nodesOverlap:c.nodesOverlap,dirCounts:c.dirCounts,calculatedIntersection:!0,hasBezier:c.hasBezier,hasUnbundled:c.hasUnbundled,eles:c.eles,srcPos:g,srcRs:E,tgtPos:h,tgtRs:D,srcW:y,srcH:x,tgtW:_,tgtH:v,srcIntn:L,tgtIntn:F,srcShape:C,tgtShape:S,posPts:{x1:R.x2,y1:R.y2,x2:R.x1,y2:R.y1},intersectionPts:{x1:ee.x2,y1:ee.y2,x2:ee.x1,y2:ee.y1},vector:{x:-ne.x,y:-ne.y},vectorNorm:{x:-re.x,y:-re.y},vectorNormInverse:{x:-ie.x,y:-ie.y}}}var ae=N?l:c;A.nodesOverlap=ae.nodesOverlap,A.srcIntn=ae.srcIntn,A.tgtIntn=ae.tgtIntn,A.isRound=j.startsWith(`round`),r&&(f.isParent()||f.isChild()||p.isParent()||p.isChild())&&(f.parents().anySame(p)||p.parents().anySame(f)||f.same(p)&&f.isParent())?t.findCompoundLoopPoints(k,ae,O,M):f===p?t.findLoopPoints(k,ae,O,M):j.endsWith(`segments`)?t.findSegmentsPoints(k,ae):j.endsWith(`taxi`)?t.findTaxiPoints(k,ae):j===`straight`||!M&&c.eles.length%2==1&&O===Math.floor(c.eles.length/2)?t.findStraightEdgePoints(k):t.findBezierPoints(k,ae,O,M,N),t.findEndpoints(k),t.tryToCorrectInvalidPoints(k,ae),t.checkForInvalidEdgeWarning(k),t.storeAllpts(k),t.storeEdgeProjections(k),t.calculateArrowAngles(k),t.recalculateEdgeLabelProjections(k),t.calculateLabelAngles(k)}},b=0;b0){var le=s,V=dU(le,QH(i)),ue=dU(le,QH(ce)),de=V;ue2&&dU(le,{x:ce[2],y:ce[3]})0){var we=c,Te=dU(we,QH(i)),Ee=dU(we,QH(Ce)),De=Te;Ee2&&dU(we,{x:Ce[2],y:Ce[3]})l&&(l=f)}t.rstyle.arrowWidth=this.getArrowWidth(s,l)*this.arrowShapeWidth},sQ.recalculateEdgeProjections=function(e){this.findEdgeControlPoints(e)};var cQ={};cQ.recalculateNodeLabelProjection=function(e){if(!dB(e.pstyle(`label`).strValue)){var t,n,r=e._private,i=e.width(),a=e.height(),o=e.padding(),s=e.position(),c=e.pstyle(`text-halign`).strValue,l=e.pstyle(`text-valign`).strValue,u=r.rscratch,d=r.rstyle;switch(c){case`left`:t=s.x-i/2-o;break;case`left-inside`:t=s.x-i/2+o;break;case`right`:t=s.x+i/2+o;break;case`right-inside`:t=s.x+i/2-o;break;default:t=s.x}switch(l){case`top`:n=s.y-a/2-o;break;case`top-inside`:n=s.y-a/2+o;break;case`bottom`:n=s.y+a/2+o;break;case`bottom-inside`:n=s.y+a/2-o;break;default:n=s.y}u.labelX=t,u.labelY=n,d.labelX=t,d.labelY=n,this.calculateLabelAngles(e),this.applyLabelDimensions(e)}};var lQ=function(e,t){var n=Math.atan(t/e);return e===0&&n<0&&(n*=-1),n},uQ=function(e,t){return lQ(t.x-e.x,t.y-e.y)},Eae=function(e,t,n,r){var i=gU(0,r-.001,1),a=gU(0,r+.001,1);return uQ(mU(e,t,n,i),mU(e,t,n,a))};cQ.recalculateEdgeLabelProjections=function(e){var t,n=e._private,r=n.rscratch,i=this,a={mid:e.pstyle(`label`).strValue,source:e.pstyle(`source-label`).strValue,target:e.pstyle(`target-label`).strValue};if(a.mid||a.source||a.target){t={x:r.midX,y:r.midY};var o=function(e,t,r){bH(n.rscratch,e,t,r),bH(n.rstyle,e,t,r)};o(`labelX`,null,t.x),o(`labelY`,null,t.y),o(`labelAutoAngle`,null,lQ(r.midDispX,r.midDispY));var s=function(){if(s.cache)return s.cache;for(var e=[],t=0;t+5=l||v){d={cp:h,segment:_};break}}if(d)break}var y=d.cp,b=d.segment,x=(l-f)/b.length,S=b.t1-b.t0,C=c?b.t0+S*x:b.t1-S*x;C=gU(0,C,1),t=mU(y.p0,y.p1,y.p2,C),i=Eae(y.p0,y.p1,y.p2,C);break;case`straight`:case`segments`:case`haystack`:for(var w=0,T,E,D,O,k=r.allpts.length,A=0;A+3=l));A+=2);var j=(l-E)/T;j=gU(0,j,1),t=hU(D,O,j),i=uQ(D,O)}o(`labelX`,n,t.x),o(`labelY`,n,t.y),o(`labelAutoAngle`,n,i)}};c(`source`),c(`target`),this.applyLabelDimensions(e)}},cQ.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,`source`),this.applyPrefixedLabelDimensions(e,`target`))},cQ.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),i=KV(r,e._private.labelDimsKey);if(yH(n.rscratch,`prefixedLabelDimsKey`,t)!==i){bH(n.rscratch,`prefixedLabelDimsKey`,t,i);var a=this.calculateLabelDimensions(e,r),o=e.pstyle(`line-height`).pfValue,s=e.pstyle(`font-size`).pfValue,c=e.pstyle(`text-wrap`).strValue,l=yH(n.rscratch,`labelWrapCachedLines`,t)||[],u=c===`wrap`?Math.max(l.length,1):1,d=s*o,f=a.width,p=a.height+(u-1)*(o-1)*s;bH(n.rstyle,`labelWidth`,t,f),bH(n.rscratch,`labelWidth`,t,f),bH(n.rstyle,`labelHeight`,t,p),bH(n.rscratch,`labelHeight`,t,p),bH(n.rscratch,`labelLineHeight`,t,d),bH(n.rscratch,`labelActualDescent`,t,a.labelActualDescent)}},cQ.getLabelText=function(e,t){var n=e._private,r=t?t+`-`:``,i=e.pstyle(r+`label`).strValue,a=e.pstyle(`text-transform`).value,o=function(e,r){return r?(bH(n.rscratch,e,t,r),r):yH(n.rscratch,e,t)};if(!i)return``;a==`none`||(a==`uppercase`?i=i.toUpperCase():a==`lowercase`&&(i=i.toLowerCase()));var s=e.pstyle(`text-wrap`).value;if(s===`wrap`){var c=o(`labelKey`);if(c!=null&&o(`labelWrapKey`)===c)return o(`labelWrapCachedText`);for(var l=`​`,u=i.split(` `),d=e.pstyle(`text-max-width`).pfValue,f=e.pstyle(`text-overflow-wrap`).value===`anywhere`,p=[],m=/[\s\u200b]+|$/g,h=0;hd){var v=g.matchAll(m),y=``,b=0,x=Nz(v),S;try{for(x.s();!(S=x.n()).done;){var C=S.value,w=C[0],T=g.substring(b,C.index);b=C.index+w.length;var E=y.length===0?T:y+T+w;this.calculateLabelDimensions(e,E).width<=d?y+=T+w:(y&&p.push(y),y=T+w)}}catch(e){x.e(e)}finally{x.f()}y.match(/^[\s\u200b]+$/)||p.push(y)}else p.push(g)}o(`labelWrapCachedLines`,p),i=o(`labelWrapCachedText`,p.join(` `)),o(`labelWrapKey`,c)}else if(s===`ellipsis`){var D=e.pstyle(`text-max-width`).pfValue,O=``,k=`…`,A=!1;if(this.calculateLabelDimensions(e,i).widthD);j++)O+=i[j],j===i.length-1&&(A=!0);return A||(O+=k),O}return i},cQ.getLabelJustification=function(e){var t=e.pstyle(`text-justification`).strValue,n=e.pstyle(`text-halign`).strValue;return t===`auto`?e.isNode()?MY(n):`center`:t},cQ.calculateLabelDimensions=function(e,t){var n=this.cy.window().document,r=0,i=e.pstyle(`font-style`).strValue,a=e.pstyle(`font-size`).pfValue,o=e.pstyle(`font-family`).strValue,s=e.pstyle(`font-weight`).strValue,c=e.pstyle(`text-metrics`).strValue||`font`,l=this.labelCalcCanvas,u=this.labelCalcCanvasContext;if(!l){l=this.labelCalcCanvas=n.createElement(`canvas`),u=this.labelCalcCanvasContext=l.getContext(`2d`);var d=l.style;d.position=`absolute`,d.left=`-9999px`,d.top=`-9999px`,d.zIndex=`-1`,d.visibility=`hidden`,d.pointerEvents=`none`}u.font=`${i} ${s} ${a}px ${o}`;for(var f=0,p=0,m=t.split(` `),h=m.length,g=0,_=0,v=0;v1&&arguments[1]!==void 0?arguments[1]:!0;if(t.merge(e),n)for(var r=0;r=e.desktopTapThreshold2}var E=a(t);b&&(e.hoverData.tapholdCancelled=!0);var D=function(){var t=e.hoverData.dragDelta=e.hoverData.dragDelta||[];t.length===0?(t.push(v[0]),t.push(v[1])):(t[0]+=v[0],t[1]+=v[1])};n=!0,i(m,[`mousemove`,`vmousemove`,`tapdrag`],t,{x:l[0],y:l[1]});var O=function(e){return{originalEvent:t,type:e,position:{x:l[0],y:l[1]}}},k=function(){e.data.bgActivePosistion=void 0,e.hoverData.selecting||r.emit(O(`boxstart`)),f[4]=1,e.hoverData.selecting=!0,e.redrawHint(`select`,!0),e.redraw()};if(e.hoverData.which===3){if(b){var A=O(`cxtdrag`);_?_.emit(A):r.emit(A),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&m===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.emit(O(`cxtdragout`)),e.hoverData.cxtOver=m,m&&m.emit(O(`cxtdragover`)))}}else if(e.hoverData.dragging){if(n=!0,r.panningEnabled()&&r.userPanningEnabled()){var j;if(e.hoverData.justStartedPan){var M=e.hoverData.mdownPos;j={x:(l[0]-M[0])*s,y:(l[1]-M[1])*s},e.hoverData.justStartedPan=!1}else j={x:v[0]*s,y:v[1]*s};r.panBy(j),r.emit(O(`dragpan`)),e.hoverData.dragged=!0}l=e.projectIntoViewport(t.clientX,t.clientY)}else if(f[4]==1&&(_==null||_.pannable()))b&&(!e.hoverData.dragging&&r.boxSelectionEnabled()&&(E||!r.panningEnabled()||!r.userPanningEnabled())?k():!e.hoverData.selecting&&r.panningEnabled()&&r.userPanningEnabled()&&o(_,e.hoverData.downs)&&(e.hoverData.dragging=!0,e.hoverData.justStartedPan=!0,f[4]=0,e.data.bgActivePosistion=QH(u),e.redrawHint(`select`,!0),e.redraw()),_&&_.pannable()&&_.active()&&_.unactivate());else{if(_&&_.pannable()&&_.active()&&_.unactivate(),_&&_.grabbed()||m==g||(g&&i(g,[`mouseout`,`tapdragout`],t,{x:l[0],y:l[1]}),m&&i(m,[`mouseover`,`tapdragover`],t,{x:l[0],y:l[1]}),e.hoverData.last=m),_){if(b){if(r.boxSelectionEnabled()&&E)_&&_.grabbed()&&(h(y),_.emit(O(`freeon`)),y.emit(O(`free`)),e.dragData.didDrag&&(_.emit(O(`dragfreeon`)),y.emit(O(`dragfree`)))),k();else if(_&&_.grabbed()&&e.nodeIsDraggable(_)){var N=!e.dragData.didDrag;N&&e.redrawHint(`eles`,!0),e.dragData.didDrag=!0,e.hoverData.draggingEles||p(y,{inDragLayer:!0});var P={x:0,y:0};if($(v[0])&&$(v[1])&&(P.x+=v[0],P.y+=v[1],N)){var F=e.hoverData.dragDelta;F&&$(F[0])&&$(F[1])&&(P.x+=F[0],P.y+=F[1])}e.hoverData.draggingEles=!0,y.silentShift(P).emit(O(`position`)).emit(O(`drag`)),e.redrawHint(`drag`,!0),e.redraw()}}else D()}n=!0}if(f[2]=l[0],f[3]=l[1],n)return t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),!1}},!1);var E,D,O;e.registerBinding(t,`mouseup`,function(t){if(!(e.hoverData.which===1&&t.which!==1&&e.hoverData.capture)&&e.hoverData.capture){e.hoverData.capture=!1;var r=e.cy,o=e.projectIntoViewport(t.clientX,t.clientY),s=e.selection,c=e.findNearestElement(o[0],o[1],!0,!1),l=e.dragData.possibleDragElements,u=e.hoverData.down,d=a(t);e.data.bgActivePosistion&&(e.redrawHint(`select`,!0),e.redraw()),e.hoverData.tapholdCancelled=!0,e.data.bgActivePosistion=void 0,u&&u.unactivate();var f=function(e){return{originalEvent:t,type:e,position:{x:o[0],y:o[1]}}};if(e.hoverData.which===3){var p=f(`cxttapend`);if(u?u.emit(p):r.emit(p),!e.hoverData.cxtDragged){var m=f(`cxttap`);u?u.emit(m):r.emit(m)}e.hoverData.cxtDragged=!1,e.hoverData.which=null}else if(e.hoverData.which===1){if(i(c,[`mouseup`,`tapend`,`vmouseup`],t,{x:o[0],y:o[1]}),e.dragData.didDrag||e.hoverData.dragged||e.hoverData.selecting||e.hoverData.isOverThresholdDrag||(i(u,[`click`,`tap`,`vclick`],t,{x:o[0],y:o[1]}),D=!1,t.timeStamp-O<=r.multiClickDebounceTime()?(E&&clearTimeout(E),D=!0,O=null,i(u,[`dblclick`,`dbltap`,`vdblclick`],t,{x:o[0],y:o[1]})):(E=setTimeout(function(){D||i(u,[`oneclick`,`onetap`,`voneclick`],t,{x:o[0],y:o[1]})},r.multiClickDebounceTime()),O=t.timeStamp)),u!=null||e.dragData.didDrag||e.hoverData.selecting||e.hoverData.dragged||a(t)||(r.$(n).unselect([`tapunselect`]),l.length>0&&e.redrawHint(`eles`,!0),e.dragData.possibleDragElements=l=r.collection()),c==u&&!e.dragData.didDrag&&!e.hoverData.selecting&&c!=null&&c._private.selectable&&(e.hoverData.dragging||(r.selectionType()===`additive`||d?c.selected()?c.unselect([`tapunselect`]):c.select([`tapselect`]):d||(r.$(n).unmerge(c).unselect([`tapunselect`]),c.select([`tapselect`]))),e.redrawHint(`eles`,!0)),e.hoverData.selecting){var g=r.collection(e.getAllInBox(s[0],s[1],s[2],s[3]));e.redrawHint(`select`,!0),g.length>0&&e.redrawHint(`eles`,!0),r.emit(f(`boxend`)),r.selectionType()===`additive`||d||r.$(n).unmerge(g).unselect(),g.emit(f(`box`)).stdFilter(function(e){return e.selectable()&&!e.selected()}).select().emit(f(`boxselect`)),e.redraw()}if(e.hoverData.dragging&&(e.hoverData.dragging=!1,e.redrawHint(`select`,!0),e.redrawHint(`eles`,!0),e.redraw()),!s[4]){e.redrawHint(`drag`,!0),e.redrawHint(`eles`,!0);var _=u&&u.grabbed();h(l),_&&(u.emit(f(`freeon`)),l.emit(f(`free`)),e.dragData.didDrag&&(u.emit(f(`dragfreeon`)),l.emit(f(`dragfree`))))}}s[4]=0,e.hoverData.down=null,e.hoverData.cxtStarted=!1,e.hoverData.draggingEles=!1,e.hoverData.selecting=!1,e.hoverData.isOverThresholdDrag=!1,e.dragData.didDrag=!1,e.hoverData.dragged=!1,e.hoverData.dragDelta=[],e.hoverData.mdownPos=null,e.hoverData.mdownGPos=null,e.hoverData.which=null}},!1);var k=[],A=4,j,M=1e5,N,P=4,F=8,I=15,L=null,ee=function(e){for(var t=Math.abs(e[0]),n=1;n=A){j=!1;var i=k;if(i[0]>=5){var a=ee(i)?i[0]:iU(i);a>1&&(j=!0,M=a,N=a)}}else k.push(Math.abs(r)),n=!0}var o=!1;if(j){var s=Math.abs(r);if(o=aU(s,M),!o){if(s=N?c:s,L=null,o=!0}else L=s,n=rB(s)||s>M}}if(!e.scrollingPage){var l=e.cy,u=l.zoom(),d=l.pan(),f=e.projectIntoViewport(t.clientX,t.clientY),p=[f[0]*u+d.x,f[1]*u+d.y];if(e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||C())t.preventDefault();else if(l.panningEnabled()&&l.userPanningEnabled()&&l.zoomingEnabled()&&l.userZoomingEnabled()){t.preventDefault(),e.data.wheelZooming=!0,clearTimeout(e.data.wheelTimeout),e.data.wheelTimeout=setTimeout(function(){e.data.wheelZooming=!1,e.redrawHint(`eles`,!0),e.redraw()},150);var m;n&&Math.abs(r)>5&&(r=lU(r)*5),m=r/-250,o&&(m/=M,m*=3),m*=e.wheelSensitivity,t.deltaMode===1&&(m*=33);var h=l.zoom()*10**m;t.type===`gesturechange`&&(h=e.gestureStartZoom*t.scale),l.zoom({level:h,renderedPosition:{x:p[0],y:p[1]}}),l.emit({type:t.type===`gesturechange`?`pinchzoom`:`scrollzoom`,originalEvent:t,position:{x:f[0],y:f[1]}})}}}};e.registerBinding(e.container,`wheel`,R,!0),e.registerBinding(t,`scroll`,function(t){e.scrollingPage=!0,clearTimeout(e.scrollingPageTimeout),e.scrollingPageTimeout=setTimeout(function(){e.scrollingPage=!1},250)},!0),e.registerBinding(e.container,`gesturestart`,function(t){e.gestureStartZoom=e.cy.zoom(),e.hasTouchStarted||t.preventDefault()},!0),e.registerBinding(e.container,`gesturechange`,function(t){e.hasTouchStarted||R(t)},!0),e.registerBinding(e.container,`mouseout`,function(t){var n=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:`mouseout`,position:{x:n[0],y:n[1]}})},!1),e.registerBinding(e.container,`mouseover`,function(t){var n=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:`mouseover`,position:{x:n[0],y:n[1]}})},!1);var z,B,te,ne,re,ie,ae,oe,se,ce,le,V,ue,de=function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},fe=function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)},pe;e.registerBinding(e.container,`touchstart`,pe=function(t){if(e.hasTouchStarted=!0,w(t)){_(),e.touchData.capture=!0,e.data.bgActivePosistion=void 0;var n=e.cy,r=e.touchData.now,a=e.touchData.earlier;if(t.touches[0]){var o=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);r[0]=o[0],r[1]=o[1]}if(t.touches[1]){var o=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);r[2]=o[0],r[3]=o[1]}if(t.touches[2]){var o=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);r[4]=o[0],r[5]=o[1]}var s=function(e){return{originalEvent:t,type:e,position:{x:r[0],y:r[1]}}};if(t.touches[1]){e.touchData.singleTouchMoved=!0,h(e.dragData.touchDragEles);var c=e.findContainerClientCoords();se=c[0],ce=c[1],le=c[2],V=c[3],z=t.touches[0].clientX-se,B=t.touches[0].clientY-ce,te=t.touches[1].clientX-se,ne=t.touches[1].clientY-ce,ue=0<=z&&z<=le&&0<=te&&te<=le&&0<=B&&B<=V&&0<=ne&&ne<=V;var u=n.pan(),d=n.zoom();re=de(z,B,te,ne),ie=fe(z,B,te,ne),ae=[(z+te)/2,(B+ne)/2],oe=[(ae[0]-u.x)/d,(ae[1]-u.y)/d];var f=200,g=f*f;if(ie=1){for(var T=e.touchData.startPosition=[null,null,null,null,null,null],E=0;E=e.touchTapThreshold2}if(n&&e.touchData.cxt){t.preventDefault();var x=t.touches[0].clientX-se,S=t.touches[0].clientY-ce,C=t.touches[1].clientX-se,T=t.touches[1].clientY-ce,E=fe(x,S,C,T),D=E/ie,O=150,k=O*O,A=1.5;if(D>=A*A||E>=k){e.touchData.cxt=!1,e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0);var j=d(`cxttapend`);e.touchData.start?(e.touchData.start.unactivate().emit(j),e.touchData.start=null):a.emit(j)}}if(n&&e.touchData.cxt){var j=d(`cxtdrag`);e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0),e.touchData.start?e.touchData.start.emit(j):a.emit(j),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxtDragged=!0;var M=e.findNearestElement(s[0],s[1],!0,!0);e.touchData.cxtOver&&M===e.touchData.cxtOver||(e.touchData.cxtOver&&e.touchData.cxtOver.emit(d(`cxtdragout`)),e.touchData.cxtOver=M,M&&M.emit(d(`cxtdragover`)))}else if(n&&t.touches[2]&&a.boxSelectionEnabled())t.preventDefault(),e.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,e.touchData.selecting||a.emit(d(`boxstart`)),e.touchData.selecting=!0,e.touchData.didSelect=!0,r[4]=1,!r||r.length===0||r[0]===void 0?(r[0]=(s[0]+s[2]+s[4])/3,r[1]=(s[1]+s[3]+s[5])/3,r[2]=(s[0]+s[2]+s[4])/3+1,r[3]=(s[1]+s[3]+s[5])/3+1):(r[2]=(s[0]+s[2]+s[4])/3,r[3]=(s[1]+s[3]+s[5])/3),e.redrawHint(`select`,!0),e.redraw();else if(n&&t.touches[1]&&!e.touchData.didSelect&&a.zoomingEnabled()&&a.panningEnabled()&&a.userZoomingEnabled()&&a.userPanningEnabled()){t.preventDefault(),e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0);var N=e.dragData.touchDragEles;if(N){e.redrawHint(`drag`,!0);for(var P=0;P0&&!e.hoverData.draggingEles&&!e.swipePanning&&e.data.bgActivePosistion!=null&&(e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0),e.redraw())}},!1);var he;e.registerBinding(t,`touchcancel`,he=function(t){var n=e.touchData.start;e.touchData.capture=!1,n&&n.unactivate()});var ge,_e,ve,ye;if(e.registerBinding(t,`touchend`,ge=function(t){var r=e.touchData.start;if(e.touchData.capture)t.touches.length===0&&(e.touchData.capture=!1),t.preventDefault();else return;var a=e.selection;e.swipePanning=!1,e.hoverData.draggingEles=!1;var o=e.cy,s=o.zoom(),c=e.touchData.now,l=e.touchData.earlier;if(t.touches[0]){var u=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);c[0]=u[0],c[1]=u[1]}if(t.touches[1]){var u=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);c[2]=u[0],c[3]=u[1]}if(t.touches[2]){var u=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);c[4]=u[0],c[5]=u[1]}var d=function(e){return{originalEvent:t,type:e,position:{x:c[0],y:c[1]}}};r&&r.unactivate();var f;if(e.touchData.cxt){if(f=d(`cxttapend`),r?r.emit(f):o.emit(f),!e.touchData.cxtDragged){var p=d(`cxttap`);r?r.emit(p):o.emit(p)}e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!1,e.touchData.start=null,e.redraw()}else{if(!t.touches[2]&&o.boxSelectionEnabled()&&e.touchData.selecting){e.touchData.selecting=!1;var m=o.collection(e.getAllInBox(a[0],a[1],a[2],a[3]));a[0]=void 0,a[1]=void 0,a[2]=void 0,a[3]=void 0,a[4]=0,e.redrawHint(`select`,!0),o.emit(d(`boxend`)),m.emit(d(`box`)).stdFilter(function(e){return e.selectable()&&!e.selected()}).select().emit(d(`boxselect`)),m.nonempty()&&e.redrawHint(`eles`,!0),e.redraw()}if(r?.unactivate(),t.touches[2])e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0);else if(!t.touches[1]&&!t.touches[0]&&!t.touches[0]){e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0);var g=e.dragData.touchDragEles;if(r!=null){var _=r._private.grabbed;h(g),e.redrawHint(`drag`,!0),e.redrawHint(`eles`,!0),_&&(r.emit(d(`freeon`)),g.emit(d(`free`)),e.dragData.didDrag&&(r.emit(d(`dragfreeon`)),g.emit(d(`dragfree`)))),i(r,[`touchend`,`tapend`,`vmouseup`,`tapdragout`],t,{x:c[0],y:c[1]}),r.unactivate(),e.touchData.start=null}else i(e.findNearestElement(c[0],c[1],!0,!0),[`touchend`,`tapend`,`vmouseup`,`tapdragout`],t,{x:c[0],y:c[1]});var v=e.touchData.startPosition[0]-c[0],y=v*v,b=e.touchData.startPosition[1]-c[1],x=(y+b*b)*s*s;e.touchData.singleTouchMoved||(r||o.$(`:selected`).unselect([`tapunselect`]),i(r,[`tap`,`vclick`],t,{x:c[0],y:c[1]}),_e=!1,t.timeStamp-ye<=o.multiClickDebounceTime()?(ve&&clearTimeout(ve),_e=!0,ye=null,i(r,[`dbltap`,`vdblclick`],t,{x:c[0],y:c[1]})):(ve=setTimeout(function(){_e||i(r,[`onetap`,`voneclick`],t,{x:c[0],y:c[1]})},o.multiClickDebounceTime()),ye=t.timeStamp)),r!=null&&!e.dragData.didDrag&&r._private.selectable&&x`u`){var be=[],xe=function(e){return{clientX:e.clientX,clientY:e.clientY,force:1,identifier:e.pointerId,pageX:e.pageX,pageY:e.pageY,radiusX:e.width/2,radiusY:e.height/2,screenX:e.screenX,screenY:e.screenY,target:e.target}},Se=function(e){return{event:e,touch:xe(e)}},Ce=function(e){be.push(Se(e))},we=function(e){for(var t=0;t0)return l[0]}return null},p=Object.keys(d),m=0;m0?d:MU(i,a,e,t,n,r,o,s)},checkPoint:function(e,t,n,r,i,a,o,s){s=s===`auto`?nW(r,i):s;var c=2*s;if(BU(e,t,this.points,a,o,r,i-c,[0,-1],n)||BU(e,t,this.points,a,o,r-c,i,[0,-1],n))return!0;var l=r/2+2*n,u=i/2+2*n;return!!(zU(e,t,[a-l,o-u,a-l,o,a+l,o,a+l,o-u])||GU(e,t,c,c,a+r/2-s,o+i/2-s,n)||GU(e,t,c,c,a-r/2+s,o+i/2-s,n))}}},yQ.registerNodeShapes=function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon(`triangle`,$U(3,0)),this.generateRoundPolygon(`round-triangle`,$U(3,0)),this.generatePolygon(`rectangle`,$U(4,0)),e.square=e.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();var n=[0,1,1,0,0,-1,-1,0];this.generatePolygon(`diamond`,n),this.generateRoundPolygon(`round-diamond`,n),this.generatePolygon(`pentagon`,$U(5,0)),this.generateRoundPolygon(`round-pentagon`,$U(5,0)),this.generatePolygon(`hexagon`,$U(6,0)),this.generateRoundPolygon(`round-hexagon`,$U(6,0)),this.generatePolygon(`heptagon`,$U(7,0)),this.generateRoundPolygon(`round-heptagon`,$U(7,0)),this.generatePolygon(`octagon`,$U(8,0)),this.generateRoundPolygon(`round-octagon`,$U(8,0));var r=Array(20),i=tW(5,0),a=tW(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s=e.deqFastCost*h)break}else if(i){if(p>=e.deqCost*c||p>=e.deqAvgCost*s)break}else if(m>=e.deqNoDrawCost*wQ)break;var g=e.deq(t,d,u);if(g.length>0)for(var _=0;_0&&(e.onDeqd(t,l),!i&&e.shouldRedraw(t,l,d,u)&&r())},a=e.priority||aH;n.beforeRender(i,a(t))}}}},Aae=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:rH;Az(this,e),this.idsByKey=new xH,this.keyForId=new xH,this.cachesByLvl=new xH,this.lvls=[],this.getKey=t,this.doesEleInvalidateKey=n}return Mz(e,[{key:`getIdsFor`,value:function(e){e??oH(`Can not get id list for null key`);var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new wH,t.set(e,n)),n}},{key:`addIdForKey`,value:function(e,t){e!=null&&this.getIdsFor(e).add(t)}},{key:`deleteIdForKey`,value:function(e,t){e!=null&&this.getIdsFor(e).delete(t)}},{key:`getNumberOfIdsForKey`,value:function(e){return e==null?0:this.getIdsFor(e).size}},{key:`updateKeyMappingFor`,value:function(e){var t=e.id(),n=this.keyForId.get(t),r=this.getKey(e);this.deleteIdForKey(n,t),this.addIdForKey(r,t),this.keyForId.set(t,r)}},{key:`deleteKeyMappingFor`,value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteIdForKey(n,t),this.keyForId.delete(t)}},{key:`keyHasChangedFor`,value:function(e){var t=e.id();return this.keyForId.get(t)!==this.getKey(e)}},{key:`isInvalid`,value:function(e){return this.keyHasChangedFor(e)||this.doesEleInvalidateKey(e)}},{key:`getCachesAt`,value:function(e){var t=this.cachesByLvl,n=this.lvls,r=t.get(e);return r||(r=new xH,t.set(e,r),n.push(e)),r}},{key:`getCache`,value:function(e,t){return this.getCachesAt(t).get(e)}},{key:`get`,value:function(e,t){var n=this.getKey(e),r=this.getCache(n,t);return r!=null&&this.updateKeyMappingFor(e),r}},{key:`getForCachedKey`,value:function(e,t){var n=this.keyForId.get(e.id());return this.getCache(n,t)}},{key:`hasCache`,value:function(e,t){return this.getCachesAt(t).has(e)}},{key:`has`,value:function(e,t){var n=this.getKey(e);return this.hasCache(n,t)}},{key:`setCache`,value:function(e,t,n){n.key=e,this.getCachesAt(t).set(e,n)}},{key:`set`,value:function(e,t,n){var r=this.getKey(e);this.setCache(r,t,n),this.updateKeyMappingFor(e)}},{key:`deleteCache`,value:function(e,t){this.getCachesAt(t).delete(e)}},{key:`delete`,value:function(e,t){var n=this.getKey(e);this.deleteCache(n,t)}},{key:`invalidateKey`,value:function(e){var t=this;this.lvls.forEach(function(n){return t.deleteCache(e,n)})}},{key:`invalidate`,value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteKeyMappingFor(e);var r=this.doesEleInvalidateKey(e);return r&&this.invalidateKey(n),r||this.getNumberOfIdsForKey(n)===0}}])}(),EQ=25,DQ=50,OQ=-4,kQ=3,AQ=7.99,jae=8,Mae=1024,Nae=1024,Pae=1024,Fae=.2,Iae=.8,Lae=10,Rae=.15,zae=.1,Bae=.9,Vae=.9,Hae=100,Uae=1,jQ={dequeue:`dequeue`,downscale:`downscale`,highQuality:`highQuality`},Wae=hH({getKey:null,doesEleInvalidateKey:rH,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:nH,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),MQ=function(e,t){var n=this;n.renderer=e,n.onDequeues=[];var r=Wae(t);jB(n,r),n.lookup=new Aae(r.getKey,r.doesEleInvalidateKey),n.setupDequeueing()},NQ=MQ.prototype;NQ.reasons=jQ,NQ.getTextureQueue=function(e){var t=this;return t.eleImgCaches=t.eleImgCaches||{},t.eleImgCaches[e]=t.eleImgCaches[e]||[]},NQ.getRetiredTextureQueue=function(e){var t=this,n=t.eleImgCaches.retired=t.eleImgCaches.retired||{};return n[e]=n[e]||[]},NQ.getElementQueue=function(){var e=this;return e.eleCacheQueue=e.eleCacheQueue||new FH(function(e,t){return t.reqs-e.reqs})},NQ.getElementKeyToQueue=function(){var e=this;return e.eleKeyToCacheQueue=e.eleKeyToCacheQueue||{}},NQ.getElement=function(e,t,n,r,i){var a=this,o=this.renderer,s=o.cy.zoom(),c=this.lookup;if(!t||t.w===0||t.h===0||isNaN(t.w)||isNaN(t.h)||!e.visible()||e.removed()||!a.allowEdgeTxrCaching&&e.isEdge()||!a.allowParentTxrCaching&&e.isParent())return null;if(r??=Math.ceil(cU(s*n)),r=AQ||r>kQ)return null;var l=2**r,u=t.h*l,d=t.w*l,f=o.eleTextBiggerThanMin(e,l);if(!this.isVisible(e,f))return null;var p=c.get(e,r);if(p&&p.invalidated&&(p.invalidated=!1,p.texture.invalidatedWidth-=p.width),p)return p;var m=u<=EQ?EQ:u<=DQ?DQ:Math.ceil(u/DQ)*DQ;if(u>Pae||d>Nae)return null;var h=a.getTextureQueue(m),g=h[h.length-2],_=function(){return a.recycleTexture(m,d)||a.addTexture(m,d)};g||=h[h.length-1],g||=_(),g.width-g.usedWidthr;D--)T=a.getElement(e,t,n,D,jQ.downscale);E()}else return a.queueElement(e,S.level-1),S}else{var O;if(!y&&!b&&!x)for(var k=r-1;k>=OQ;k--){var A=c.get(e,k);if(A){O=A;break}}if(v(O))return a.queueElement(e,r),O;g.context.translate(g.usedWidth,0),g.context.scale(l,l),this.drawElement(g.context,e,t,f,!1),g.context.scale(1/l,1/l),g.context.translate(-g.usedWidth,0)}return p={x:g.usedWidth,texture:g,level:r,scale:l,width:d,height:u,scaledLabelShown:f},g.usedWidth+=Math.ceil(d+jae),g.eleCaches.push(p),c.set(e,r,p),a.checkTextureFullness(g),p},NQ.invalidateElements=function(e){for(var t=0;t=Fae*e.width&&this.retireTexture(e)},NQ.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>Iae&&e.fullnessChecks>=Lae?gH(t,e):e.fullnessChecks++},NQ.retireTexture=function(e){var t=this,n=e.height,r=t.getTextureQueue(n),i=this.lookup;gH(r,e),e.retired=!0;for(var a=e.eleCaches,o=0;o=t)return o.retired=!1,o.usedWidth=0,o.invalidatedWidth=0,o.fullnessChecks=0,_H(o.eleCaches),o.context.setTransform(1,0,0,1,0,0),o.context.clearRect(0,0,o.width,o.height),gH(i,o),r.push(o),o}},NQ.queueElement=function(e,t){var n=this,r=n.getElementQueue(),i=n.getElementKeyToQueue(),a=this.getKey(e),o=i[a];if(o)o.level=Math.max(o.level,t),o.eles.merge(e),o.reqs++,r.updateItem(o);else{var s={eles:e.spawn().merge(e),level:t,reqs:1,key:a};r.push(s),i[a]=s}},NQ.dequeue=function(e){for(var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),i=[],a=t.lookup,o=0;o0;o++){var s=n.pop(),c=s.key,l=s.eles[0],u=a.hasCache(l,s.level);if(r[c]=null,!u){i.push(s);var d=t.getBoundingBox(l);t.getElement(l,d,e,s.level,jQ.dequeue)}}return i},NQ.removeFromQueue=function(e){var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),i=this.getKey(e),a=r[i];a!=null&&(a.eles.length===1?(a.reqs=tH,n.updateItem(a),n.pop(),r[i]=null):a.eles.unmerge(e))},NQ.onDequeue=function(e){this.onDequeues.push(e)},NQ.offDequeue=function(e){gH(this.onDequeues,e)},NQ.setupDequeueing=TQ.setupDequeueing({deqRedrawThreshold:Hae,deqCost:Rae,deqAvgCost:zae,deqNoDrawCost:Bae,deqFastCost:Vae,deq:function(e,t,n){return e.dequeue(t,n)},onDeqd:function(e,t){for(var n=0;n=Kae||n>FQ)return null}r.validateLayersElesOrdering(n,e);var o=r.layersByLevel,s=2**n,c=o[n]=o[n]||[],l,u=r.levelIsComplete(n,e),d,f=function(){var t=function(t){if(r.validateLayersElesOrdering(t,e),r.levelIsComplete(t,e))return d=o[t],!0},i=function(e){if(!d)for(var r=n+e;PQ<=r&&r<=FQ&&!t(r);r+=e);};i(1),i(-1);for(var a=c.length-1;a>=0;a--){var s=c[a];s.invalid&&gH(c,s)}};if(!u)f();else return c;var p=function(){if(!l){l=_U();for(var t=0;tLQ||a>LQ||i*a>eoe)return null;var o=r.makeLayer(l,n);if(t!=null){var u=c.indexOf(t)+1;c.splice(u,0,o)}else(e.insert===void 0||e.insert)&&c.unshift(o);return o};if(r.skipping&&!a)return null;for(var h=null,g=e.length/Gae,_=!a,v=0;v=g||!OU(h.bb,y.boundingBox()))&&(h=m({insert:!0,after:h}),!h))return null;d||_?r.queueLayer(h,y):r.drawEleInLayer(h,y,n,t),h.eles.push(y),x[n]=h}}return d||(_?null:c)},zQ.getEleLevelForLayerLevel=function(e,t){return e},zQ.drawEleInLayer=function(e,t,n,r){var i=this,a=this.renderer,o=e.context,s=t.boundingBox();s.w!==0&&s.h!==0&&t.visible()&&(n=i.getEleLevelForLayerLevel(n,r),a.setImgSmoothing(o,!1),a.drawCachedElement(o,t,null,null,n,toe),a.setImgSmoothing(o,!0))},zQ.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||n.length===0)return!1;for(var r=0,i=0;i0||a.invalid)return!1;r+=a.eles.length}return r===t.length},zQ.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r0){t=!0;break}}return t},zQ.invalidateElements=function(e){var t=this;e.length!==0&&(t.lastInvalidationTime=FV(),e.length!==0&&t.haveLayers()&&t.updateElementsInLayers(e,function(e,n,r){t.invalidateLayer(e)}))},zQ.invalidateLayer=function(e){if(this.lastInvalidationTime=FV(),!e.invalid){var t=e.level,n=e.eles;gH(this.layersByLevel[t],e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var r=0;r3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,o=this,s=t._private.rscratch;if((!a||t.visible())&&!(s.badLine||s.allpts==null||isNaN(s.allpts[0]))){var c;n&&(c=n,e.translate(-c.x1,-c.y1));var l=a?t.pstyle(`opacity`).value:1,u=a?t.pstyle(`line-opacity`).value:1,d=t.pstyle(`curve-style`).value,f=t.pstyle(`line-style`).value,p=t.pstyle(`width`).pfValue,m=t.pstyle(`line-cap`).value,h=t.pstyle(`line-outline-width`).value,g=t.pstyle(`line-outline-color`).value,_=l*u,v=l*u,y=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_;d===`straight-triangle`?(o.eleStrokeStyle(e,t,n),o.drawEdgeTrianglePath(t,e,s.allpts)):(e.lineWidth=p,e.lineCap=m,o.eleStrokeStyle(e,t,n),o.drawEdgePath(t,e,s.allpts,f),e.lineCap=`butt`)},b=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_;if(e.lineWidth=p+h,e.lineCap=m,h>0)o.colorStrokeStyle(e,g,n);else{e.lineCap=`butt`;return}d===`straight-triangle`?o.drawEdgeTrianglePath(t,e,s.allpts):(o.drawEdgePath(t,e,s.allpts,f),e.lineCap=`butt`)},x=function(){i&&o.drawEdgeOverlay(e,t)},S=function(){i&&o.drawEdgeUnderlay(e,t)},C=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:v;o.drawArrowheads(e,t,n)},w=function(){o.drawElementText(e,t,null,r)};if(e.lineJoin=`round`,t.pstyle(`ghost`).value===`yes`){var T=t.pstyle(`ghost-offset-x`).pfValue,E=t.pstyle(`ghost-offset-y`).pfValue,D=_*t.pstyle(`ghost-opacity`).value;e.translate(T,E),y(D),C(D),e.translate(-T,-E)}else b();S(),y(),C(),x(),w(),n&&e.translate(c.x1,c.y1)}};var qQ=function(e){if(![`overlay`,`underlay`].includes(e))throw Error(`Invalid state`);return function(t,n){if(n.visible()){var r=n.pstyle(`${e}-opacity`).value;if(r!==0){var i=this,a=i.usePaths(),o=n._private.rscratch;t.lineWidth=2*n.pstyle(`${e}-padding`).pfValue,t.lineCap=o.edgeType===`self`&&!a?`butt`:`round`;var s=n.pstyle(`${e}-fill`)?.value;if(s===`linear-gradient`||s===`radial-gradient`){var c=i.createGradientStyleFor(t,e,n,s,r);if(c)t.strokeStyle=c;else{var l=n.pstyle(`${e}-color`).value;i.colorStrokeStyle(t,l,r)}}else{var u=n.pstyle(`${e}-color`).value;i.colorStrokeStyle(t,u,r)}i.drawEdgePath(n,t,o.allpts,`solid`)}}}};KQ.drawEdgeOverlay=qQ(`overlay`),KQ.drawEdgeUnderlay=qQ(`underlay`),KQ.drawEdgePath=function(e,t,n,r){var i=e._private.rscratch,a=t,o,s=!1,c=this.usePaths(),l=e.pstyle(`line-dash-pattern`).pfValue,u=e.pstyle(`line-dash-offset`).pfValue;if(c){var d=n.join(`$`);i.pathCacheKey&&i.pathCacheKey===d?(o=t=i.pathCache,s=!0):(o=t=new Path2D,i.pathCacheKey=d,i.pathCache=o)}if(a.setLineDash)switch(r){case`dotted`:a.setLineDash([1,1]);break;case`dashed`:a.setLineDash(l),a.lineDashOffset=u;break;case`solid`:a.setLineDash([])}if(!s&&!i.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(n[0],n[1]),i.edgeType){case`bezier`:case`self`:case`compound`:case`multibezier`:for(var f=2;f+35&&arguments[5]!==void 0?arguments[5]:!0,o=this;if(r==null){if(a&&!o.eleTextBiggerThanMin(t))return}else if(r===!1)return;if(t.isNode()){var s=t.pstyle(`label`);if(!s||!s.value)return;var c=o.getLabelJustification(t),l=t.pstyle(`text-metrics`).strValue===`glyph`;e.textAlign=c,e.textBaseline=l?`alphabetic`:`bottom`}else{var u=t.element()._private.rscratch.badLine,d=t.pstyle(`label`),f=t.pstyle(`source-label`),p=t.pstyle(`target-label`);if(u||(!d||!d.value)&&(!f||!f.value)&&(!p||!p.value))return;e.textAlign=`center`,e.textBaseline=`bottom`}var m=!n,h;n&&(h=n,e.translate(-h.x1,-h.y1)),i==null?(o.drawText(e,t,null,m,a),t.isEdge()&&(o.drawText(e,t,`source`,m,a),o.drawText(e,t,`target`,m,a))):o.drawText(e,t,i,m,a),n&&e.translate(h.x1,h.y1)},YQ.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n2&&arguments[2]!==void 0?arguments[2]:!0,r=t.pstyle(`font-style`).strValue,i=t.pstyle(`font-size`).pfValue+`px`,a=t.pstyle(`font-family`).strValue,o=t.pstyle(`font-weight`).strValue,s=n?t.effectiveOpacity()*t.pstyle(`text-opacity`).value:1,c=t.pstyle(`text-outline-opacity`).value*s,l=t.pstyle(`color`).value,u=t.pstyle(`text-outline-color`).value;e.font=r+` `+o+` `+i+` `+a,e.lineJoin=`round`,this.colorFillStyle(e,l,s),this.colorStrokeStyle(e,u,c)};function foe(e,t,n,r,i){var a=Math.min(r,i)/2,o=t+r/2,s=n+i/2;e.beginPath(),e.arc(o,s,a,0,Math.PI*2),e.closePath()}function XQ(e,t,n,r,i){var a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:5,o=Math.min(a,r/2,i/2);e.beginPath(),e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+i-o),e.quadraticCurveTo(t+r,n+i,t+r-o,n+i),e.lineTo(t+o,n+i),e.quadraticCurveTo(t,n+i,t,n+i-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()}YQ.getTextAngle=function(e,t){var n,r=e._private.rscratch,i=t?t+`-`:``,a=e.pstyle(i+`text-rotation`);if(a.strValue===`autorotate`){var o=yH(r,`labelAngle`,t);n=e.isEdge()?o:0}else n=a.strValue===`none`?0:a.pfValue;return n},YQ.drawText=function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=t._private.rscratch,o=i?t.effectiveOpacity():1;if(!i||o!==0&&t.pstyle(`text-opacity`).value!==0){n===`main`&&(n=null);var s=yH(a,`labelX`,n),c=yH(a,`labelY`,n),l,u,d=this.getLabelText(t,n);if(d!=null&&d!==``&&!isNaN(s)&&!isNaN(c)){this.setupTextStyle(e,t,i);var f=n?n+`-`:``,p=yH(a,`labelWidth`,n),m=yH(a,`labelHeight`,n),h=yH(a,`labelActualDescent`,n),g=t.pstyle(f+`text-margin-x`).pfValue,_=t.pstyle(f+`text-margin-y`).pfValue,v=t.isEdge(),y=t.pstyle(`text-halign`).value,b=t.pstyle(`text-valign`).value;v&&(y=`center`,b=`center`),s+=g,c+=_;var x=r?this.getTextAngle(t,n):0;x!==0&&(l=s,u=c,e.translate(l,u),e.rotate(x),s=0,c=0);var S=AY(y),C=jY(b);switch(C){case`top`:break;case`center`:c+=m/2;break;case`bottom`:c+=m}var w=t.pstyle(`text-background-opacity`).value,T=t.pstyle(`text-border-opacity`).value,E=t.pstyle(`text-border-width`).pfValue,D=t.pstyle(`text-background-padding`).pfValue,O=t.pstyle(`text-background-shape`).strValue,k=O===`round-rectangle`||O===`roundrectangle`,A=O===`circle`,j=2;if(w>0||E>0&&T>0){var M=e.fillStyle,N=e.strokeStyle,P=e.lineWidth,F=t.pstyle(`text-background-color`).value,I=t.pstyle(`text-border-color`).value,L=t.pstyle(`text-border-style`).value,ee=w>0,R=E>0&&T>0,z=s-D;switch(S){case`left`:z-=p;break;case`center`:z-=p/2}var B=c-m-D,te=p+2*D,ne=m+2*D;if(ee&&this.colorFillStyle(e,F,w*o),R&&(this.colorStrokeStyle(e,I,T*o),e.lineWidth=E,e.setLineDash))switch(L){case`dotted`:e.setLineDash([1,1]);break;case`dashed`:e.setLineDash([4,2]);break;case`double`:e.lineWidth=E/4,e.setLineDash([]);break;default:e.setLineDash([])}if(k?(e.beginPath(),XQ(e,z,B,te,ne,j)):A?(e.beginPath(),foe(e,z,B,te,ne)):(e.beginPath(),e.rect(z,B,te,ne)),ee&&e.fill(),R&&e.stroke(),R&&L===`double`){var re=E/2;e.beginPath(),k?XQ(e,z+re,B+re,te-2*re,ne-2*re,j):e.rect(z+re,B+re,te-2*re,ne-2*re),e.stroke()}e.fillStyle=M,e.strokeStyle=N,e.lineWidth=P,e.setLineDash&&e.setLineDash([])}var ie=2*t.pstyle(`text-outline-width`).pfValue;if(ie>0&&(e.lineWidth=ie),c-=h,t.pstyle(`text-wrap`).value===`wrap`){var ae=yH(a,`labelWrapCachedLines`,n),oe=yH(a,`labelLineHeight`,n),se=p/2,ce=this.getLabelJustification(t);switch(ce===`auto`||(S===`left`?ce===`left`?s+=-p:ce===`center`&&(s+=-se):S===`center`?ce===`left`?s+=-se:ce===`right`&&(s+=se):S===`right`&&(ce===`center`?s+=se:ce===`right`&&(s+=p))),C){case`top`:case`center`:case`bottom`:c-=(ae.length-1)*oe}for(var le=0;le0&&e.strokeText(ae[le],s,c),e.fillText(ae[le],s,c),c+=oe}else ie>0&&e.strokeText(d,s,c),e.fillText(d,s,c);x!==0&&(e.rotate(-x),e.translate(-l,-u))}}};var ZQ={};ZQ.drawNode=function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,o=this,s,c,l=t._private,u=l.rscratch,d=t.position();if($(d.x)&&$(d.y)&&(!a||t.visible())){var f=a?t.effectiveOpacity():1,p=o.usePaths(),m,h=!1,g=t.padding();s=t.width()+2*g,c=t.height()+2*g;var _;n&&(_=n,e.translate(-_.x1,-_.y1));for(var v=t.pstyle(`background-image`).value,y=Array(v.length),b=Array(v.length),x=0,S=0;S0&&arguments[0]!==void 0?arguments[0]:D;o.eleFillStyle(e,t,n)},ne=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:F;o.colorStrokeStyle(e,O,t)},re=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:R;o.colorStrokeStyle(e,L,t)},ie=function(e,t,n,r){var i=o.nodePathCache=o.nodePathCache||[],a=qV(n===`polygon`?n+`,`+r.join(`,`):n,``+t,``+e,``+B),s=i[a],c,l=!1;return s==null?(c=new Path2D,i[a]=u.pathCache=c):(c=s,l=!0,u.pathCache=c),{path:c,cacheHit:l}},ae=t.pstyle(`shape`).strValue,oe=t.pstyle(`shape-polygon-points`).pfValue;if(p){e.translate(d.x,d.y);var se=ie(s,c,ae,oe);m=se.path,h=se.cacheHit}var ce=function(){if(!h){var n=d;p&&(n={x:0,y:0}),o.nodeShapes[o.getNodeShape(t)].draw(m||e,n.x,n.y,s,c,B,u)}p?e.fill(m):e.fill()},le=function(){for(var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:f,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,i=l.backgrounding,a=0,s=0;s0&&arguments[0]!==void 0&&arguments[0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;o.hasPie(t)&&(o.drawPie(e,t,r),n&&(p||o.nodeShapes[o.getNodeShape(t)].draw(e,d.x,d.y,s,c,B,u)))},ue=function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;o.hasStripe(t)&&(e.save(),p?e.clip(u.pathCache):(o.nodeShapes[o.getNodeShape(t)].draw(e,d.x,d.y,s,c,B,u),e.clip()),o.drawStripe(e,t,r),e.restore(),n&&(p||o.nodeShapes[o.getNodeShape(t)].draw(e,d.x,d.y,s,c,B,u)))},de=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:f,n=(T>0?T:-T)*t,r=T>0?0:255;T!==0&&(o.colorFillStyle(e,[r,r,r],n),p?e.fill(m):e.fill())},fe=function(){if(E>0){if(e.lineWidth=E,e.lineCap=j,e.lineJoin=A,e.setLineDash)switch(k){case`dotted`:e.setLineDash([1,1]);break;case`dashed`:e.setLineDash(N),e.lineDashOffset=P;break;case`solid`:case`double`:e.setLineDash([])}if(M!==`center`){if(e.save(),e.lineWidth*=2,M===`inside`)p?e.clip(m):e.clip();else{var t=new Path2D;t.rect(-s/2-E,-c/2-E,s+2*E,c+2*E),t.addPath(m),e.clip(t,`evenodd`)}p?e.stroke(m):e.stroke(),e.restore()}else p?e.stroke(m):e.stroke();if(k===`double`){e.lineWidth=E/3;var n=e.globalCompositeOperation;e.globalCompositeOperation=`destination-out`,p?e.stroke(m):e.stroke(),e.globalCompositeOperation=n}e.setLineDash&&e.setLineDash([])}},pe=function(){if(I>0){if(e.lineWidth=I,e.lineCap=`butt`,e.setLineDash)switch(ee){case`dotted`:e.setLineDash([1,1]);break;case`dashed`:e.setLineDash([4,2]);break;case`solid`:case`double`:e.setLineDash([])}var n=d;p&&(n={x:0,y:0});var r=o.getNodeShape(t),i=E;M===`inside`&&(i=0),M===`outside`&&(i*=2);var a=(s+i+(I+z))/s,l=(c+i+(I+z))/c,u=s*a,f=c*l,m=o.nodeShapes[r].points,h;if(p&&(h=ie(u,f,r,m).path),r===`ellipse`)o.drawEllipsePath(h||e,n.x,n.y,u,f);else if([`round-diamond`,`round-heptagon`,`round-hexagon`,`round-octagon`,`round-pentagon`,`round-polygon`,`round-triangle`,`round-tag`].includes(r)){var g=0,_=0,v=0;r===`round-diamond`?g=(i+z+I)*1.4:r===`round-heptagon`?(g=(i+z+I)*1.075,v=-(i/2+z+I)/35):r===`round-hexagon`?g=(i+z+I)*1.12:r===`round-pentagon`?(g=(i+z+I)*1.13,v=-(i/2+z+I)/15):r===`round-tag`?(g=(i+z+I)*1.12,_=(i/2+I+z)*.07):r===`round-triangle`&&(g=(i+z+I)*(Math.PI/2),v=-(i+z/2+I)/Math.PI),g!==0&&(a=(s+g)/s,u=s*a,[`round-hexagon`,`round-tag`].includes(r)||(l=(c+g)/c,f=c*l)),B=B===`auto`?rW(u,f):B;for(var y=u/2,b=f/2,x=B+(i+I+z)/2,S=Array(m.length/2),C=Array(m.length/2),w=0;w0){if(r||=n.position(),i==null||a==null){var d=n.padding();i=n.width()+2*d,a=n.height()+2*d}var f=n.pstyle(`${e}-fill`)?.value;if(f===`linear-gradient`||f===`radial-gradient`){var p=o.createGradientStyleFor(t,e,n,f,c);if(p)t.fillStyle=p;else{var m=n.pstyle(`${e}-color`).value;o.colorFillStyle(t,m,c)}}else{var h=n.pstyle(`${e}-color`).value;o.colorFillStyle(t,h,c)}o.nodeShapes[l].draw(t,r.x,r.y,i+s*2,a+s*2,u),t.fill()}}}};ZQ.drawNodeOverlay=QQ(`overlay`),ZQ.drawNodeUnderlay=QQ(`underlay`),ZQ.hasPie=function(e){return e=e[0],e._private.hasPie},ZQ.hasStripe=function(e){return e=e[0],e._private.hasStripe},ZQ.drawPie=function(e,t,n,r){t=t[0],r||=t.position();var i=t.cy().style(),a=t.pstyle(`pie-size`),o=t.pstyle(`pie-hole`),s=t.pstyle(`pie-start-angle`).pfValue,c=r.x,l=r.y,u=t.width(),d=t.height(),f=Math.min(u,d)/2,p,m=0;if(this.usePaths()&&(c=0,l=0),a.units===`%`?f*=a.pfValue:a.pfValue!==void 0&&(f=a.pfValue/2),o.units===`%`?p=f*o.pfValue:o.pfValue!==void 0&&(p=o.pfValue/2),!(p>=f))for(var h=1;h<=i.pieBackgroundN;h++){var g=t.pstyle(`pie-`+h+`-background-size`).value,_=t.pstyle(`pie-`+h+`-background-color`).value,v=t.pstyle(`pie-`+h+`-background-opacity`).value*n,y=g/100;y+m>1&&(y=1-m);var b=1.5*Math.PI+2*Math.PI*m;b+=s;var x=2*Math.PI*y,S=b+x;g===0||m>=1||m+y>1||(p===0?(e.beginPath(),e.moveTo(c,l),e.arc(c,l,f,b,S),e.closePath()):(e.beginPath(),e.arc(c,l,f,b,S),e.arc(c,l,p,S,b,!0),e.closePath()),this.colorFillStyle(e,_,v),e.fill(),m+=y)}},ZQ.drawStripe=function(e,t,n,r){t=t[0],r||=t.position();var i=t.cy().style(),a=r.x,o=r.y,s=t.width(),c=t.height(),l=0,u=this.usePaths();e.save();var d=t.pstyle(`stripe-direction`).value,f=t.pstyle(`stripe-size`);switch(d){case`vertical`:break;case`righward`:e.rotate(-Math.PI/2)}var p=s,m=c;f.units===`%`?(p*=f.pfValue,m*=f.pfValue):f.pfValue!==void 0&&(p=f.pfValue,m=f.pfValue),u&&(a=0,o=0),o-=p/2,a-=m/2;for(var h=1;h<=i.stripeBackgroundN;h++){var g=t.pstyle(`stripe-`+h+`-background-size`).value,_=t.pstyle(`stripe-`+h+`-background-color`).value,v=t.pstyle(`stripe-`+h+`-background-opacity`).value*n,y=g/100;y+l>1&&(y=1-l),g===0||l>=1||l+y>1||(e.beginPath(),e.rect(a,o+m*l,p,m*y),e.closePath(),this.colorFillStyle(e,_,v),e.fill(),l+=y)}e.restore()};var $Q={},poe=100,moe=function(e){return e[3]==null?1:e[3]},e$=function(e,t){return moe(e)*t};$Q.getPixelRatio=function(){var e=this.data.contexts[0];if(this.forcedPixelRatio!=null)return this.forcedPixelRatio;var t=this.cy.window(),n=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(t.devicePixelRatio||1)/n},$Q.paintCache=function(e){for(var t=this.paintCaches=this.paintCaches||[],n=!0,r,i=0;it.minMbLowQualFrames&&(t.motionBlurPxRatio=t.mbPxRBlurry)),t.clearingMotionBlur&&(t.motionBlurPxRatio=1),t.textureDrawLastFrame&&!d&&(u[t.NODE]=!0,u[t.SELECT_BOX]=!0);var v=n.style(),y=n.zoom(),b=o===void 0?y:o,x=n.pan(),S={x:x.x,y:x.y},C={zoom:y,pan:{x:x.x,y:x.y}},w=t.prevViewport;w!==void 0&&C.zoom===w.zoom&&C.pan.x===w.pan.x&&C.pan.y===w.pan.y&&(!h||m)&&(t.motionBlurPxRatio=1),s&&(S=s),b*=c,S.x*=c,S.y*=c;var T=t.getCachedZSortedEles();function E(e,n,r,i,a){var o=e.globalCompositeOperation;e.globalCompositeOperation=`destination-out`,t.colorFillStyle(e,[255,255,255],t.motionBlurTransparency),e.fillRect(n,r,i,a),e.globalCompositeOperation=o}function D(e,n){var a,c,u,d;!t.clearingMotionBlur&&(e===l.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]||e===l.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG])?(a={x:x.x*p,y:x.y*p},c=y*p,u=t.canvasWidth*p,d=t.canvasHeight*p):(a=S,c=b,u=t.canvasWidth,d=t.canvasHeight),e.setTransform(1,0,0,1,0,0),n===`motionBlur`?E(e,0,0,u,d):!r&&(n===void 0||n)&&e.clearRect(0,0,u,d),i||(e.translate(a.x,a.y),e.scale(c,c)),s&&e.translate(s.x,s.y),o&&e.scale(o,o)}if(d||(t.textureDrawLastFrame=!1),d){if(t.textureDrawLastFrame=!0,!t.textureCache){t.textureCache={},t.textureCache.bb=n.mutableElements().boundingBox(),t.textureCache.texture=t.data.bufferCanvases[t.TEXTURE_BUFFER];var O=t.data.bufferContexts[t.TEXTURE_BUFFER];O.setTransform(1,0,0,1,0,0),O.clearRect(0,0,t.canvasWidth*t.textureMult,t.canvasHeight*t.textureMult),t.render({forcedContext:O,drawOnlyNodeLayer:!0,forcedPxRatio:c*t.textureMult});var C=t.textureCache.viewport={zoom:n.zoom(),pan:n.pan(),width:t.canvasWidth,height:t.canvasHeight};C.mpan={x:(0-C.pan.x)/C.zoom,y:(0-C.pan.y)/C.zoom}}u[t.DRAG]=!1,u[t.NODE]=!1;var k=l.contexts[t.NODE],A=t.textureCache.texture,C=t.textureCache.viewport;k.setTransform(1,0,0,1,0,0),f?E(k,0,0,C.width,C.height):k.clearRect(0,0,C.width,C.height);var j=v.core(`outside-texture-bg-color`).value,M=v.core(`outside-texture-bg-opacity`).value;t.colorFillStyle(k,j,M),k.fillRect(0,0,C.width,C.height);var y=n.zoom();D(k,!1),k.clearRect(C.mpan.x,C.mpan.y,C.width/C.zoom/c,C.height/C.zoom/c),k.drawImage(A,C.mpan.x,C.mpan.y,C.width/C.zoom/c,C.height/C.zoom/c)}else t.textureOnViewport&&!r&&(t.textureCache=null);var N=n.extent(),P=t.pinching||t.hoverData.dragging||t.swipePanning||t.data.wheelZooming||t.hoverData.draggingEles||t.cy.animated(),F=t.hideEdgesOnViewport&&P,I=[];if(I[t.NODE]=!u[t.NODE]&&f&&!t.clearedForMotionBlur[t.NODE]||t.clearingMotionBlur,I[t.NODE]&&(t.clearedForMotionBlur[t.NODE]=!0),I[t.DRAG]=!u[t.DRAG]&&f&&!t.clearedForMotionBlur[t.DRAG]||t.clearingMotionBlur,I[t.DRAG]&&(t.clearedForMotionBlur[t.DRAG]=!0),u[t.NODE]||i||a||I[t.NODE]){var L=f&&!I[t.NODE]&&p!==1,k=r||(L?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]:l.contexts[t.NODE]);D(k,f&&!L?`motionBlur`:void 0),F?t.drawCachedNodes(k,T.nondrag,c,N):t.drawLayeredElements(k,T.nondrag,c,N),t.debug&&t.drawDebugPoints(k,T.nondrag),!i&&!f&&(u[t.NODE]=!1)}if(!a&&(u[t.DRAG]||i||I[t.DRAG])){var L=f&&!I[t.DRAG]&&p!==1,k=r||(L?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG]:l.contexts[t.DRAG]);D(k,f&&!L?`motionBlur`:void 0),F?t.drawCachedNodes(k,T.drag,c,N):t.drawCachedElements(k,T.drag,c,N),t.debug&&t.drawDebugPoints(k,T.drag),!i&&!f&&(u[t.DRAG]=!1)}if(this.drawSelectionRectangle(e,D),f&&p!==1){var ee=l.contexts[t.NODE],R=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE],z=l.contexts[t.DRAG],B=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG],te=function(e,n,r){e.setTransform(1,0,0,1,0,0),r||!_?e.clearRect(0,0,t.canvasWidth,t.canvasHeight):E(e,0,0,t.canvasWidth,t.canvasHeight);var i=p;e.drawImage(n,0,0,t.canvasWidth*i,t.canvasHeight*i,0,0,t.canvasWidth,t.canvasHeight)};(u[t.NODE]||I[t.NODE])&&(te(ee,R,I[t.NODE]),u[t.NODE]=!1),(u[t.DRAG]||I[t.DRAG])&&(te(z,B,I[t.DRAG]),u[t.DRAG]=!1)}t.prevViewport=C,t.clearingMotionBlur&&(t.clearingMotionBlur=!1,t.motionBlurCleared=!0,t.motionBlur=!0),f&&(t.motionBlurTimeout=setTimeout(function(){t.motionBlurTimeout=null,t.clearedForMotionBlur[t.NODE]=!1,t.clearedForMotionBlur[t.DRAG]=!1,t.motionBlur=!1,t.clearingMotionBlur=!d,t.mbFrames=0,u[t.NODE]=!0,u[t.DRAG]=!0,t.redraw()},poe)),r||n.emit(`render`)};var t$;$Q.drawSelectionRectangle=function(e,t){var n=this,r=n.cy,i=n.data,a=r.style(),o=e.drawOnlyNodeLayer,s=e.drawAllLayers,c=i.canvasNeedsRedraw,l=e.forcedContext;if(n.showFps||!o&&c[n.SELECT_BOX]&&!s){var u=l||i.contexts[n.SELECT_BOX];if(t(u),n.selection[4]==1&&(n.hoverData.selecting||n.touchData.selecting)){var d=n.cy.zoom(),f=a.core(`selection-box-border-width`).value/d;u.lineWidth=f,u.fillStyle=`rgba(`+a.core(`selection-box-color`).value[0]+`,`+a.core(`selection-box-color`).value[1]+`,`+a.core(`selection-box-color`).value[2]+`,`+a.core(`selection-box-opacity`).value+`)`,u.fillRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]),f>0&&(u.strokeStyle=`rgba(`+a.core(`selection-box-border-color`).value[0]+`,`+a.core(`selection-box-border-color`).value[1]+`,`+a.core(`selection-box-border-color`).value[2]+`,`+a.core(`selection-box-opacity`).value+`)`,u.strokeRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]))}if(i.bgActivePosistion&&!n.hoverData.selecting){var d=n.cy.zoom(),p=i.bgActivePosistion;u.fillStyle=`rgba(`+a.core(`active-bg-color`).value[0]+`,`+a.core(`active-bg-color`).value[1]+`,`+a.core(`active-bg-color`).value[2]+`,`+a.core(`active-bg-opacity`).value+`)`,u.beginPath(),u.arc(p.x,p.y,a.core(`active-bg-size`).pfValue/d,0,2*Math.PI),u.fill()}var m=n.lastRedrawTime;if(n.showFps&&m){m=Math.round(m);var h=Math.round(1e3/m),g=`1 frame = `+m+` ms = `+h+` fps`;u.setTransform(1,0,0,1,0,0),u.fillStyle=`rgba(255, 0, 0, 0.75)`,u.strokeStyle=`rgba(255, 0, 0, 0.75)`,u.font=`30px Arial`,t$||=u.measureText(g).actualBoundingBoxAscent,u.fillText(g,0,t$),u.strokeRect(0,t$+10,250,20),u.fillRect(0,t$+10,250*Math.min(h/60,1),20)}s||(c[n.SELECT_BOX]=!1)}};function n$(e,t,n){var r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw Error(e.getShaderInfoLog(r));return r}function hoe(e,t,n){var r=n$(e,e.VERTEX_SHADER,t),i=n$(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(e.attachShader(a,r),e.attachShader(a,i),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS))throw Error(`Could not initialize shaders`);return a}function goe(e,t,n){n===void 0&&(n=t);var r=e.makeOffscreenCanvas(t,n),i=r.context=r.getContext(`2d`);return r.clear=function(){return i.clearRect(0,0,r.width,r.height)},r.clear(),r}function r$(e){var t=e.pixelRatio,n=e.cy.zoom(),r=e.cy.pan();return{zoom:n*t,pan:{x:r.x*t,y:r.y*t}}}function _oe(e){var t=e.pixelRatio;return e.cy.zoom()*t}function voe(e,t,n,r,i){var a=r*n+t.x,o=i*n+t.y;return o=Math.round(e.canvasHeight-o),[a,o]}function yoe(e,t){return t.picking?!0:e.pstyle(`background-fill`).value!==`solid`||e.pstyle(`background-image`).strValue!==`none`?!1:e.pstyle(`border-width`).value===0||e.pstyle(`border-opacity`).value===0||e.pstyle(`border-style`).value===`solid`}function boe(e,t){if(e.length!==t.length)return!1;for(var n=0;n>8&255)/255,n[2]=(e>>16&255)/255,n[3]=(e>>24&255)/255,n}function xoe(e){return e[0]+(e[1]<<8)+(e[2]<<16)+(e[3]<<24)}function Soe(e,t){var n=e.createTexture();return n.buffer=function(t){e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_NEAREST),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)},n.deleteTexture=function(){e.deleteTexture(n)},n}function o$(e,t){switch(t){case`float`:return[1,e.FLOAT,4];case`vec2`:return[2,e.FLOAT,4];case`vec3`:return[3,e.FLOAT,4];case`vec4`:return[4,e.FLOAT,4];case`int`:return[1,e.INT,4];case`ivec2`:return[2,e.INT,4]}}function s$(e,t,n){switch(t){case e.FLOAT:return new Float32Array(n);case e.INT:return new Int32Array(n)}}function Coe(e,t,n,r,i,a){switch(t){case e.FLOAT:return new Float32Array(n.buffer,a*r,i);case e.INT:return new Int32Array(n.buffer,a*r,i)}}function woe(e,t,n,r){var i=zz(o$(e,t),2),a=i[0],o=i[1],s=s$(e,o,r),c=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,s,e.STATIC_DRAW),o===e.FLOAT?e.vertexAttribPointer(n,a,o,!1,0,0):o===e.INT&&e.vertexAttribIPointer(n,a,o,0,0),e.enableVertexAttribArray(n),e.bindBuffer(e.ARRAY_BUFFER,null),c}function c$(e,t,n,r){var i=zz(o$(e,n),3),a=i[0],o=i[1],s=i[2],c=s$(e,o,t*a),l=a*s,u=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,t*l,e.DYNAMIC_DRAW),e.enableVertexAttribArray(r),o===e.FLOAT?e.vertexAttribPointer(r,a,o,!1,l,0):o===e.INT&&e.vertexAttribIPointer(r,a,o,l,0),e.vertexAttribDivisor(r,1),e.bindBuffer(e.ARRAY_BUFFER,null);for(var d=Array(t),f=0;fi&&(a=i/t,o=t*a,s=n*a),{scale:a,texW:o,texH:s}}},{key:`draw`,value:function(e,t,n){var r=this;if(this.locked)throw Error(`can't draw, atlas is locked`);var i=this.texSize,a=this.texRows,o=this.texHeight,s=this.getScale(t),c=s.scale,l=s.texW,u=s.texH,d=function(e,r){if(n&&r){var i=r.context,a=e.x,s=e.row,l=a,u=o*s;i.save(),i.translate(l,u),i.scale(c,c),n(i,t),i.restore()}},f=[null,null],p=function(){d(r.freePointer,r.canvas),f[0]={x:r.freePointer.x,y:r.freePointer.row*o,w:l,h:u},f[1]={x:r.freePointer.x+l,y:r.freePointer.row*o,w:0,h:u},r.freePointer.x+=l,r.freePointer.x==i&&(r.freePointer.x=0,r.freePointer.row++)},m=function(){var e=r.scratch,t=r.canvas;e.clear(),d({x:0,row:0},e);var n=i-r.freePointer.x,a=l-n,s=o,c=r.freePointer.x,p=r.freePointer.row*o,m=n;t.context.drawImage(e,0,0,m,s,c,p,m,s),f[0]={x:c,y:p,w:m,h:u};var h=n,g=(r.freePointer.row+1)*o,_=a;t&&t.context.drawImage(e,h,0,_,s,0,g,_,s),f[1]={x:0,y:g,w:_,h:u},r.freePointer.x=a,r.freePointer.row++},h=function(){r.freePointer.x=0,r.freePointer.row++};if(this.freePointer.x+l<=i)p();else if(this.freePointer.row>=a-1)return!1;else this.freePointer.x===i?(h(),p()):this.enableWrapping?m():(h(),p());return this.keyToLocation.set(e,f),this.needsBuffer=!0,f}},{key:`getOffsets`,value:function(e){return this.keyToLocation.get(e)}},{key:`isEmpty`,value:function(){return this.freePointer.x===0&&this.freePointer.row===0}},{key:`canFit`,value:function(e){if(this.locked)return!1;var t=this.texSize,n=this.texRows,r=this.getScale(e).texW;return this.freePointer.x+r>t?this.freePointer.row1&&arguments[1]!==void 0?arguments[1]:{},r=n.forceRedraw,i=r!==void 0&&r,a=n.filterEle,o=a===void 0?function(){return!0}:a,s=n.filterType,c=s===void 0?function(){return!0}:s,l=!1,u=!1,d=Nz(e),f;try{for(d.s();!(f=d.n()).done;){var p=f.value;if(o(p)){var m=Nz(this.renderTypes.values()),h;try{var g=function(){var e=h.value,n=e.type;if(c(n)){var r=t.collections.get(e.collection),a=e.getKey(p),o=Array.isArray(a)?a:[a];if(i)o.forEach(function(e){return r.markKeyForGC(e)}),u=!0;else{var s=e.getID?e.getID(p):p.id(),d=t._key(n,s),f=t.typeAndIdToKey.get(d);f!==void 0&&!boe(o,f)&&(l=!0,t.typeAndIdToKey.delete(d),f.forEach(function(e){return r.markKeyForGC(e)}))}}};for(m.s();!(h=m.n()).done;)g()}catch(e){m.e(e)}finally{m.f()}}}}catch(e){d.e(e)}finally{d.f()}return u&&(this.gc(),l=!1),l}},{key:`gc`,value:function(){var e=Nz(this.collections.values()),t;try{for(e.s();!(t=e.n()).done;)t.value.gc()}catch(t){e.e(t)}finally{e.f()}}},{key:`getOrCreateAtlas`,value:function(e,t,n,r){var i=this.renderTypes.get(t),a=this.collections.get(i.collection),o=!1,s=a.draw(r,n,function(t){i.drawClipped?(t.save(),t.beginPath(),t.rect(0,0,n.w,n.h),t.clip(),i.drawElement(t,e,n,!0,!0),t.restore()):i.drawElement(t,e,n,!0,!0),o=!0});if(o){var c=i.getID?i.getID(e):e.id(),l=this._key(t,c);this.typeAndIdToKey.has(l)?this.typeAndIdToKey.get(l).push(r):this.typeAndIdToKey.set(l,[r])}return s}},{key:`getAtlasInfo`,value:function(e,t){var n=this,r=this.renderTypes.get(t),i=r.getKey(e);return(Array.isArray(i)?i:[i]).map(function(i){var a=r.getBoundingBox(e,i),o=n.getOrCreateAtlas(e,t,a,i),s=zz(o.getOffsets(i),2),c=s[0];return{atlas:o,tex:c,tex1:c,tex2:s[1],bb:a}})}},{key:`getDebugInfo`,value:function(){var e=[],t=Nz(this.collections),n;try{for(t.s();!(n=t.n()).done;){var r=zz(n.value,2),i=r[0],a=r[1].getCounts(),o=a.keyCount,s=a.atlasCount;e.push({type:i,keyCount:o,atlasCount:s})}}catch(e){t.e(e)}finally{t.f()}return e}}])}(),Noe=function(){function e(t){Az(this,e),this.globalOptions=t,this.atlasSize=t.webglTexSize,this.maxAtlasesPerBatch=t.webglTexPerBatch,this.batchAtlases=[]}return Mz(e,[{key:`getMaxAtlasesPerBatch`,value:function(){return this.maxAtlasesPerBatch}},{key:`getAtlasSize`,value:function(){return this.atlasSize}},{key:`getIndexArray`,value:function(){return Array.from({length:this.maxAtlasesPerBatch},function(e,t){return t})}},{key:`startBatch`,value:function(){this.batchAtlases=[]}},{key:`getAtlasCount`,value:function(){return this.batchAtlases.length}},{key:`getAtlases`,value:function(){return this.batchAtlases}},{key:`canAddToCurrentBatch`,value:function(e){return this.batchAtlases.length!==this.maxAtlasesPerBatch||this.batchAtlases.includes(e)}},{key:`getAtlasIndexForBatch`,value:function(e){var t=this.batchAtlases.indexOf(e);if(t<0){if(this.batchAtlases.length===this.maxAtlasesPerBatch)throw Error(`cannot add more atlases to batch`);this.batchAtlases.push(e),t=this.batchAtlases.length-1}return t}}])}(),Poe=` float circleSD(vec2 p, float r) { return distance(vec2(0), p) - r; // signed distance } `,Foe=` float rectangleSD(vec2 p, vec2 b) { vec2 d = abs(p)-b; return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0); } `,Ioe=` float roundRectangleSD(vec2 p, vec2 b, vec4 cr) { cr.xy = (p.x > 0.0) ? cr.xy : cr.zw; cr.x = (p.y > 0.0) ? cr.x : cr.y; vec2 q = abs(p) - b + cr.x; return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x; } `,Loe=` float ellipseSD(vec2 p, vec2 ab) { p = abs( p ); // symmetry // find root with Newton solver vec2 q = ab*(p-ab); float w = (q.x1.0) ? d : -d; } `,h$={SCREEN:{name:`screen`,screen:!0},PICKING:{name:`picking`,picking:!0}},g$={IGNORE:1,USE_BB:2},_$=0,v$=1,y$=2,b$=3,x$=4,S$=5,C$=6,w$=7,Roe=function(){function e(t,n,r){Az(this,e),this.r=t,this.gl=n,this.maxInstances=r.webglBatchSize,this.atlasSize=r.webglTexSize,this.bgColor=r.bgColor,this.debug=r.webglDebug,this.batchDebugInfo=[],r.enableWrapping=!0,r.createTextureCanvas=goe,this.atlasManager=new Moe(t,r),this.batchManager=new Noe(r),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(h$.SCREEN),this.pickingProgram=this._createShaderProgram(h$.PICKING),this.vao=this._createVAO()}return Mz(e,[{key:`addAtlasCollection`,value:function(e,t){this.atlasManager.addAtlasCollection(e,t)}},{key:`addTextureAtlasRenderType`,value:function(e,t){this.atlasManager.addRenderType(e,t)}},{key:`addSimpleShapeRenderType`,value:function(e,t){this.simpleShapeOptions.set(e,t)}},{key:`invalidate`,value:function(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).type,n=this.atlasManager;return t?n.invalidate(e,{filterType:function(e){return e===t},forceRedraw:!0}):n.invalidate(e)}},{key:`gc`,value:function(){this.atlasManager.gc()}},{key:`_createShaderProgram`,value:function(e){var t=this.gl,n=`#version 300 es precision highp float; uniform mat3 uPanZoomMatrix; uniform int uAtlasSize; // instanced in vec2 aPosition; // a vertex from the unit square in mat3 aTransform; // used to transform verticies, eg into a bounding box in int aVertType; // the type of thing we are rendering // the z-index that is output when using picking mode in vec4 aIndex; // For textures in int aAtlasId; // which shader unit/atlas to use in vec4 aTex; // x/y/w/h of texture in atlas // for edges in vec4 aPointAPointB; in vec4 aPointCPointD; in vec2 aLineWidth; // also used for node border width // simple shapes in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left] in vec4 aColor; // also used for edges in vec4 aBorderColor; // aLineWidth is used for border width // output values passed to the fragment shader out vec2 vTexCoord; out vec4 vColor; out vec2 vPosition; // flat values are not interpolated flat out int vAtlasId; flat out int vVertType; flat out vec2 vTopRight; flat out vec2 vBotLeft; flat out vec4 vCornerRadius; flat out vec4 vBorderColor; flat out vec2 vBorderWidth; flat out vec4 vIndex; void main(void) { int vid = gl_VertexID; vec2 position = aPosition; // TODO make this a vec3, simplifies some code below if(aVertType == ${_$}) { float texX = aTex.x; // texture coordinates float texY = aTex.y; float texW = aTex.z; float texH = aTex.w; if(vid == 1 || vid == 2 || vid == 4) { texX += texW; } if(vid == 2 || vid == 4 || vid == 5) { texY += texH; } float d = float(uAtlasSize); vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1 gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0); } else if(aVertType == ${x$} || aVertType == ${w$} || aVertType == ${S$} || aVertType == ${C$}) { // simple shapes // the bounding box is needed by the fragment shader vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated // calculations are done in the fragment shader, just pass these along vColor = aColor; vCornerRadius = aCornerRadius; vBorderColor = aBorderColor; vBorderWidth = aLineWidth; gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0); } else if(aVertType == ${v$}) { vec2 source = aPointAPointB.xy; vec2 target = aPointAPointB.zw; // adjust the geometry so that the line is centered on the edge position.y = position.y - 0.5; // stretch the unit square into a long skinny rectangle vec2 xBasis = target - source; vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y; gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0); vColor = aColor; } else if(aVertType == ${y$}) { vec2 pointA = aPointAPointB.xy; vec2 pointB = aPointAPointB.zw; vec2 pointC = aPointCPointD.xy; vec2 pointD = aPointCPointD.zw; // adjust the geometry so that the line is centered on the edge position.y = position.y - 0.5; vec2 p0, p1, p2, pos; if(position.x == 0.0) { // The left side of the unit square p0 = pointA; p1 = pointB; p2 = pointC; pos = position; } else { // The right side of the unit square, use same approach but flip the geometry upside down p0 = pointD; p1 = pointC; p2 = pointB; pos = vec2(0.0, -position.y); } vec2 p01 = p1 - p0; vec2 p12 = p2 - p1; vec2 p21 = p1 - p2; // Find the normal vector. vec2 tangent = normalize(normalize(p12) + normalize(p01)); vec2 normal = vec2(-tangent.y, tangent.x); // Find the vector perpendicular to p0 -> p1. vec2 p01Norm = normalize(vec2(-p01.y, p01.x)); // Determine the bend direction. float sigma = sign(dot(p01 + p21, normal)); float width = aLineWidth[0]; if(sign(pos.y) == -sigma) { // This is an intersecting vertex. Adjust the position so that there's no overlap. vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm); gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0); } else { // This is a non-intersecting vertex. Treat it like a mitre join. vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm); gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0); } vColor = aColor; } else if(aVertType == ${b$} && vid < 3) { // massage the first triangle into an edge arrow if(vid == 0) position = vec2(-0.15, -0.3); if(vid == 1) position = vec2( 0.0, 0.0); if(vid == 2) position = vec2( 0.15, -0.3); gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0); vColor = aColor; } else { gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space } vAtlasId = aAtlasId; vVertType = aVertType; vIndex = aIndex; } `,r=this.batchManager.getIndexArray(),i=hoe(t,n,`#version 300 es precision highp float; // declare texture unit for each texture atlas in the batch ${r.map(function(e){return`uniform sampler2D uTexture${e};`}).join(` `)} uniform vec4 uBGColor; uniform float uZoom; in vec2 vTexCoord; in vec4 vColor; in vec2 vPosition; // model coordinates flat in int vAtlasId; flat in vec4 vIndex; flat in int vVertType; flat in vec2 vTopRight; flat in vec2 vBotLeft; flat in vec4 vCornerRadius; flat in vec4 vBorderColor; flat in vec2 vBorderWidth; out vec4 outColor; ${Poe} ${Foe} ${Ioe} ${Loe} vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha return vec4( top.rgb + (bot.rgb * (1.0 - top.a)), top.a + (bot.a * (1.0 - top.a)) ); } vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance // scale to the zoom level so that borders don't look blurry when zoomed in // note 1.5 is an aribitrary value chosen because it looks good return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d))); } void main(void) { if(vVertType == ${_$}) { // look up the texel from the texture unit ${r.map(function(e){return`if(vAtlasId == ${e}) outColor = texture(uTexture${e}, vTexCoord);`}).join(` else `)} } else if(vVertType == ${b$}) { // mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out'; outColor = blend(vColor, uBGColor); outColor.a = 1.0; // make opaque, masks out line under arrow } else if(vVertType == ${x$} && vBorderWidth == vec2(0.0)) { // simple rectangle with no border outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done } else if(vVertType == ${x$} || vVertType == ${w$} || vVertType == ${S$} || vVertType == ${C$}) { // use SDF float outerBorder = vBorderWidth[0]; float innerBorder = vBorderWidth[1]; float borderPadding = outerBorder * 2.0; float w = vTopRight.x - vBotLeft.x - borderPadding; float h = vTopRight.y - vBotLeft.y - borderPadding; vec2 b = vec2(w/2.0, h/2.0); // half width, half height vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center float d; // signed distance if(vVertType == ${x$}) { d = rectangleSD(p, b); } else if(vVertType == ${w$} && w == h) { d = circleSD(p, b.x); // faster than ellipse } else if(vVertType == ${w$}) { d = ellipseSD(p, b); } else { d = roundRectangleSD(p, b, vCornerRadius.wzyx); } // use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling // we must smooth colors inwards, because we can't change pixels outside the shape's bounding box if(d > 0.0) { if(d > outerBorder) { discard; } else { outColor = distInterp(vBorderColor, vec4(0), d - outerBorder); } } else { if(d > innerBorder) { vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor; vec4 innerBorderColor = blend(vBorderColor, vColor); outColor = distInterp(innerBorderColor, outerColor, d); } else { vec4 outerColor; if(innerBorder == 0.0 && outerBorder == 0.0) { outerColor = vec4(0); } else if(innerBorder == 0.0) { outerColor = vBorderColor; } else { outerColor = blend(vBorderColor, vColor); } outColor = distInterp(vColor, outerColor, d - innerBorder); } } } else { outColor = vColor; } ${e.picking?`if(outColor.a == 0.0) discard; else outColor = vIndex;`:``} } `);i.aPosition=t.getAttribLocation(i,`aPosition`),i.aIndex=t.getAttribLocation(i,`aIndex`),i.aVertType=t.getAttribLocation(i,`aVertType`),i.aTransform=t.getAttribLocation(i,`aTransform`),i.aAtlasId=t.getAttribLocation(i,`aAtlasId`),i.aTex=t.getAttribLocation(i,`aTex`),i.aPointAPointB=t.getAttribLocation(i,`aPointAPointB`),i.aPointCPointD=t.getAttribLocation(i,`aPointCPointD`),i.aLineWidth=t.getAttribLocation(i,`aLineWidth`),i.aColor=t.getAttribLocation(i,`aColor`),i.aCornerRadius=t.getAttribLocation(i,`aCornerRadius`),i.aBorderColor=t.getAttribLocation(i,`aBorderColor`),i.uPanZoomMatrix=t.getUniformLocation(i,`uPanZoomMatrix`),i.uAtlasSize=t.getUniformLocation(i,`uAtlasSize`),i.uBGColor=t.getUniformLocation(i,`uBGColor`),i.uZoom=t.getUniformLocation(i,`uZoom`),i.uTextures=[];for(var a=0;a1&&arguments[1]!==void 0?arguments[1]:h$.SCREEN;this.panZoomMatrix=e,this.renderTarget=t,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:`startBatch`,value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:`endFrame`,value:function(){this.endBatch()}},{key:`_isVisible`,value:function(e,t){return e.visible()?t&&t.isVisible?t.isVisible(e):!0:!1}},{key:`drawTexture`,value:function(e,t,n){var r=this.atlasManager,i=this.batchManager,a=r.getRenderTypeOpts(n);if(this._isVisible(e,a)&&(!e.isEdge()||this._isValidEdge(e))){if(this.renderTarget.picking&&a.getTexPickingMode){var o=a.getTexPickingMode(e);if(o===g$.IGNORE)return;if(o==g$.USE_BB){this.drawPickingRectangle(e,t,n);return}}var s=Nz(r.getAtlasInfo(e,n)),c;try{for(s.s();!(c=s.n()).done;){var l=c.value,u=l.atlas,d=l.tex1,f=l.tex2;i.canAddToCurrentBatch(u)||this.endBatch();for(var p=i.getAtlasIndexForBatch(u),m=0,h=[[d,!0],[f,!1]];m=this.maxInstances&&this.endBatch()}}}}catch(e){s.e(e)}finally{s.f()}}}},{key:`setTransformMatrix`,value:function(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=0;if(n.shapeProps&&n.shapeProps.padding&&(a=e.pstyle(n.shapeProps.padding).pfValue),r){var o=r.bb,s=r.tex1,c=r.tex2,l=s.w/(s.w+c.w);i||(l=1-l);var u=this._getAdjustedBB(o,a,i,l);this._applyTransformMatrix(t,u,n,e)}else{var d=n.getBoundingBox(e),f=this._getAdjustedBB(d,a,!0,1);this._applyTransformMatrix(t,f,n,e)}}},{key:`_applyTransformMatrix`,value:function(e,t,n,r){var i,a;d$(e);var o=n.getRotation?n.getRotation(r):0;if(o!==0){var s=n.getRotationPoint(r);f$(e,e,[s.x,s.y]),p$(e,e,o);var c=n.getRotationOffset(r);i=c.x+(t.xOffset||0),a=c.y+(t.yOffset||0)}else i=t.x1,a=t.y1;f$(e,e,[i,a]),m$(e,e,[t.w,t.h])}},{key:`_getAdjustedBB`,value:function(e,t,n,r){var i=e.x1,a=e.y1,o=e.w,s=e.h,c=e.yOffset;t&&(i-=t,a-=t,o+=2*t,s+=2*t);var l=0,u=o*r;return n&&r<1?o=u:!n&&r<1&&(l=o-u,i+=l,o=u),{x1:i,y1:a,w:o,h:s,xOffset:l,yOffset:c}}},{key:`drawPickingRectangle`,value:function(e,t,n){var r=this.atlasManager.getRenderTypeOpts(n),i=this.instanceCount;this.vertTypeBuffer.getView(i)[0]=x$,a$(t,this.indexBuffer.getView(i)),i$([0,0,0],1,this.colorBuffer.getView(i));var a=this.transformBuffer.getMatrixView(i);this.setTransformMatrix(e,a,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:`drawNode`,value:function(e,t,n){var r=this.simpleShapeOptions.get(n);if(this._isVisible(e,r)){var i=r.shapeProps,a=this._getVertTypeForShape(e,i.shape);if(a===void 0||r.isSimple&&!r.isSimple(e,this.renderTarget))this.drawTexture(e,t,n);else{var o=this.instanceCount;if(this.vertTypeBuffer.getView(o)[0]=a,a===S$||a===C$){var s=r.getBoundingBox(e),c=this._getCornerRadius(e,i.radius,s),l=this.cornerRadiusBuffer.getView(o);l[0]=c,l[1]=c,l[2]=c,l[3]=c,a===C$&&(l[0]=0,l[2]=0)}a$(t,this.indexBuffer.getView(o));var u=this.renderTarget.picking?1:n===`node-body`?e.effectiveOpacity():1,d=this.renderTarget.picking?1:e.pstyle(i.opacity).value*u;i$(e.pstyle(i.color).value,d,this.colorBuffer.getView(o));var f=this.lineWidthBuffer.getView(o);if(f[0]=0,f[1]=0,i.border){var p=e.pstyle(`border-width`).value;if(p>0){i$(e.pstyle(`border-color`).value,u*e.pstyle(`border-opacity`).value,this.borderColorBuffer.getView(o));var m=e.pstyle(`border-position`).value;if(m===`inside`)f[0]=0,f[1]=-p;else if(m===`outside`)f[0]=p,f[1]=0;else{var h=p/2;f[0]=h,f[1]=-h}}}var g=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(e,g,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:`_getVertTypeForShape`,value:function(e,t){switch(e.pstyle(t).value){case`rectangle`:return x$;case`ellipse`:return w$;case`roundrectangle`:case`round-rectangle`:return S$;case`bottom-round-rectangle`:return C$;default:return}}},{key:`_getCornerRadius`,value:function(e,t,n){var r=n.w,i=n.h;if(e.pstyle(t).value===`auto`)return nW(r,i);var a=e.pstyle(t).pfValue,o=r/2,s=i/2;return Math.min(a,s,o)}},{key:`drawEdgeArrow`,value:function(e,t,n){if(e.visible()){var r=e._private.rscratch,i,a,o;if(n===`source`?(i=r.arrowStartX,a=r.arrowStartY,o=r.srcArrowAngle):(i=r.arrowEndX,a=r.arrowEndY,o=r.tgtArrowAngle),!(isNaN(i)||i==null||isNaN(a)||a==null||isNaN(o)||o==null)&&e.pstyle(n+`-arrow-shape`).value!==`none`){var s=e.pstyle(n+`-arrow-color`).value,c=e.pstyle(`opacity`).value*e.pstyle(`line-opacity`).value,l=e.pstyle(`width`).pfValue,u=rZ(e,n),d=this.r.getArrowWidth(l,u),f=this.instanceCount,p=this.transformBuffer.getMatrixView(f);d$(p),f$(p,p,[i,a]),m$(p,p,[d,d]),p$(p,p,o),this.vertTypeBuffer.getView(f)[0]=b$,a$(t,this.indexBuffer.getView(f)),i$(s,c,this.colorBuffer.getView(f)),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:`drawEdgeLine`,value:function(e,t){if(e.visible()){var n=this._getEdgePoints(e);if(n){var r=e.pstyle(`opacity`).value,i=e.pstyle(`line-opacity`).value,a=e.pstyle(`width`).pfValue,o=e.pstyle(`line-color`).value,s=r*i;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),n.length==4){var c=this.instanceCount;this.vertTypeBuffer.getView(c)[0]=v$,a$(t,this.indexBuffer.getView(c)),i$(o,s,this.colorBuffer.getView(c));var l=this.lineWidthBuffer.getView(c);l[0]=a;var u=this.pointAPointBBuffer.getView(c);u[0]=n[0],u[1]=n[1],u[2]=n[2],u[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var d=0;d=this.maxInstances&&this.endBatch()}}}}},{key:`_isValidEdge`,value:function(e){var t=e._private.rscratch;return!(t.badLine||t.allpts==null||isNaN(t.allpts[0]))}},{key:`_getEdgePoints`,value:function(e){var t=e._private.rscratch;if(this._isValidEdge(e)){var n=t.allpts;if(n.length==4)return n;var r=this._getNumSegments(e);return this._getCurveSegmentPoints(n,r)}}},{key:`_getNumSegments`,value:function(e){return Math.min(15,this.maxInstances)}},{key:`_getCurveSegmentPoints`,value:function(e,t){if(e.length==4)return e;for(var n=Array((t+1)*2),r=0;r<=t;r++)if(r==0)n[0]=e[0],n[1]=e[1];else if(r==t)n[r*2]=e[e.length-2],n[r*2+1]=e[e.length-1];else{var i=r/t;this._setCurvePoint(e,i,n,r*2)}return n}},{key:`_setCurvePoint`,value:function(e,t,n,r){if(e.length<=2)n[r]=e[0],n[r+1]=e[1];else{for(var i=Array(e.length-2),a=0;a0}},s=function(e){return e.pstyle(`text-events`).strValue===`yes`?g$.USE_BB:g$.IGNORE},c=function(e){var t=e.position(),n=t.x,r=t.y,i=e.outerWidth(),a=e.outerHeight();return{w:i,h:a,x1:n-i/2,y1:r-a/2}};n.drawing.addAtlasCollection(`node`,{texRows:e.webglTexRowsNodes}),n.drawing.addAtlasCollection(`label`,{texRows:e.webglTexRows}),n.drawing.addTextureAtlasRenderType(`node-body`,{collection:`node`,getKey:t.getStyleKey,getBoundingBox:t.getElementBox,drawElement:t.drawElement}),n.drawing.addSimpleShapeRenderType(`node-body`,{getBoundingBox:c,isSimple:yoe,shapeProps:{shape:`shape`,color:`background-color`,opacity:`background-opacity`,radius:`corner-radius`,border:!0}}),n.drawing.addSimpleShapeRenderType(`node-overlay`,{getBoundingBox:c,isVisible:o(`overlay`),shapeProps:{shape:`overlay-shape`,color:`overlay-color`,opacity:`overlay-opacity`,padding:`overlay-padding`,radius:`overlay-corner-radius`}}),n.drawing.addSimpleShapeRenderType(`node-underlay`,{getBoundingBox:c,isVisible:o(`underlay`),shapeProps:{shape:`underlay-shape`,color:`underlay-color`,opacity:`underlay-opacity`,padding:`underlay-padding`,radius:`underlay-corner-radius`}}),n.drawing.addTextureAtlasRenderType(`label`,{collection:`label`,getTexPickingMode:s,getKey:D$(t.getLabelKey,null),getBoundingBox:O$(t.getLabelBox,null),drawClipped:!0,drawElement:t.drawLabel,getRotation:i(null),getRotationPoint:t.getLabelRotationPoint,getRotationOffset:t.getLabelRotationOffset,isVisible:a(`label`)}),n.drawing.addTextureAtlasRenderType(`edge-source-label`,{collection:`label`,getTexPickingMode:s,getKey:D$(t.getSourceLabelKey,`source`),getBoundingBox:O$(t.getSourceLabelBox,`source`),drawClipped:!0,drawElement:t.drawSourceLabel,getRotation:i(`source`),getRotationPoint:t.getSourceLabelRotationPoint,getRotationOffset:t.getSourceLabelRotationOffset,isVisible:a(`source-label`)}),n.drawing.addTextureAtlasRenderType(`edge-target-label`,{collection:`label`,getTexPickingMode:s,getKey:D$(t.getTargetLabelKey,`target`),getBoundingBox:O$(t.getTargetLabelBox,`target`),drawClipped:!0,drawElement:t.drawTargetLabel,getRotation:i(`target`),getRotationPoint:t.getTargetLabelRotationPoint,getRotationOffset:t.getTargetLabelRotationOffset,isVisible:a(`target-label`)});var l=AV(function(){console.log(`garbage collect flag set`),n.data.gc=!0},1e4);n.onUpdateEleCalcs(function(e,t){var r=!1;t&&t.length>0&&(r|=n.drawing.invalidate(t)),r&&l()}),Boe(n)};function zoe(e){var t=e.cy.container();return IB(t&&t.style&&t.style.backgroundColor||`white`)}function E$(e,t){return yH(e._private.rscratch,`labelWrapCachedLines`,t)||[]}var D$=function(e,t){return function(n){var r=e(n),i=E$(n,t);return i.length>1?i.map(function(e,t){return`${r}_${t}`}):r}},O$=function(e,t){return function(n,r){var i=e(n);if(typeof r==`string`){var a=r.indexOf(`_`);if(a>0){var o=Number(r.substring(a+1)),s=E$(n,t),c=i.h/s.length,l=c*o,u=i.y1+l;return{x1:i.x1,w:i.w,y1:u,h:c,yOffset:l}}}return i}};function Boe(e){var t=e.render;e.render=function(n){n||={};var r=e.cy;e.webgl&&(r.zoom()>AQ?(Voe(e),t.call(e,n)):(Hoe(e),j$(e,n,h$.SCREEN)))};var n=e.matchCanvasSize;e.matchCanvasSize=function(t){n.call(e,t),e.pickingFrameBuffer.setFramebufferAttachmentSizes(e.canvasWidth,e.canvasHeight),e.pickingFrameBuffer.needsDraw=!0},e.findNearestElements=function(t,n,r,i){return Joe(e,t,n)};var r=e.invalidateCachedZSortedEles;e.invalidateCachedZSortedEles=function(){r.call(e),e.pickingFrameBuffer.needsDraw=!0};var i=e.notify;e.notify=function(t,n){i.call(e,t,n),t===`viewport`||t===`bounds`?e.pickingFrameBuffer.needsDraw=!0:t===`background`&&e.drawing.invalidate(n,{type:`node-body`})}}function Voe(e){var t=e.data.contexts[e.WEBGL];t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)}function Hoe(e){var t=function(t){t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.canvasWidth,e.canvasHeight),t.restore()};t(e.data.contexts[e.NODE]),t(e.data.contexts[e.DRAG])}function Uoe(e){var t=e.canvasWidth,n=e.canvasHeight,r=r$(e),i=r.pan,a=r.zoom,o=u$();f$(o,o,[i.x,i.y]),m$(o,o,[a,a]);var s=u$();Ooe(s,t,n);var c=u$();return Doe(c,s,o),c}function k$(e,t){var n=e.canvasWidth,r=e.canvasHeight,i=r$(e),a=i.pan,o=i.zoom;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,n,r),t.translate(a.x,a.y),t.scale(o,o)}function Woe(e,t){e.drawSelectionRectangle(t,function(t){return k$(e,t)})}function Goe(e){var t=e.data.contexts[e.NODE];t.save(),k$(e,t),t.strokeStyle=`rgba(0, 0, 0, 0.3)`,t.beginPath(),t.moveTo(-1e3,0),t.lineTo(1e3,0),t.stroke(),t.beginPath(),t.moveTo(0,-1e3),t.lineTo(0,1e3),t.stroke(),t.restore()}function Koe(e){var t=function(t,n,r){for(var i=t.atlasManager.getAtlasCollection(n),a=e.data.contexts[e.NODE],o=i.atlases,s=0;s=0&&_.add(y)}return _}function Joe(e,t,n){var r=qoe(e,t,n),i=e.getCachedZSortedEles(),a,o,s=Nz(r),c;try{for(s.s();!(c=s.n()).done;){var l=i[c.value];if(!a&&l.isNode()&&(a=l),!o&&l.isEdge()&&(o=l),a&&o)break}}catch(e){s.e(e)}finally{s.f()}return[a,o].filter(Boolean)}function A$(e,t,n){var r=e.drawing;t+=1,n.isNode()?(r.drawNode(n,t,`node-underlay`),r.drawNode(n,t,`node-body`),r.drawTexture(n,t,`label`),r.drawNode(n,t,`node-overlay`)):(r.drawEdgeLine(n,t),r.drawEdgeArrow(n,t,`source`),r.drawEdgeArrow(n,t,`target`),r.drawTexture(n,t,`label`),r.drawTexture(n,t,`edge-source-label`),r.drawTexture(n,t,`edge-target-label`))}function j$(e,t,n){var r;e.webglDebug&&(r=performance.now());var i=e.drawing,a=0;if(n.screen&&e.data.canvasNeedsRedraw[e.SELECT_BOX]&&Woe(e,t),e.data.canvasNeedsRedraw[e.NODE]||n.picking){var o=e.data.contexts[e.WEBGL];n.screen?(o.clearColor(0,0,0,0),o.enable(o.BLEND),o.blendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA)):o.disable(o.BLEND),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),o.viewport(0,0,o.canvas.width,o.canvas.height);var s=Uoe(e),c=e.getCachedZSortedEles();if(a=c.length,i.startFrame(s,n),n.screen){for(var l=0;l0&&a>0){f.clearRect(0,0,i,a),f.globalCompositeOperation=`source-over`;var p=this.getCachedZSortedEles();if(e.full)f.translate(-n.x1*c,-n.y1*c),f.scale(c,c),this.drawElements(f,p);else{var m=t.pan(),h={x:m.x*c,y:m.y*c};c*=t.zoom(),f.translate(h.x,h.y),f.scale(c,c),this.drawElements(f,p)}f.setTransform(1,0,0,1,0,0),e.bg&&(f.globalCompositeOperation=`destination-over`,f.fillStyle=e.bg,f.fillRect(0,0,i,a))}return d};function Yoe(e,t){for(var n=atob(e),r=new ArrayBuffer(n.length),i=new Uint8Array(r),a=0;a`u`?`undefined`:Uz(OffscreenCanvas))===`undefined`?(n=this.cy.window().document.createElement(`canvas`),n.width=e,n.height=t):n=new OffscreenCanvas(e,t),n},[VQ,WQ,KQ,JQ,YQ,ZQ,$Q,T$,M$,z$,H$].forEach(function(e){jB(U$,e)});var Qoe=[{type:`layout`,extensions:xae},{type:`renderer`,extensions:[{name:`null`,impl:kZ},{name:`base`,impl:SQ},{name:`canvas`,impl:Xoe}]}],G$={},K$={};function q$(e,t,n){var r=n,i=function(n){cH("Can not register `"+t+"` for `"+e+"` since `"+n+"` already exists in the prototype and can not be overridden")};if(e===`core`){if(uZ.prototype[t])return i(t);uZ.prototype[t]=n}else if(e===`collection`){if(PX.prototype[t])return i(t);PX.prototype[t]=n}else if(e===`layout`){for(var a=function(e){this.options=e,n.call(this,e),tB(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},o=a.prototype=Object.create(n.prototype),s=[],c=0;c{if(!e.current)return;let n=[{data:{id:`stateA`,label:`State A`,type:`entity`,color:`#00e5ff`}},{data:{id:`ais`,label:`AIS Aggregator`,type:`entity`,color:`#22d3ee`}},{data:{id:`mediaB`,label:`Media Outlet B`,type:`entity`,color:`#f43f5e`}},{data:{id:`cable`,label:`Cable Landing`,type:`entity`,color:`#fbbf24`}},{data:{id:`social`,label:`Social Cluster`,type:`entity`,color:`#a78bfa`}},...Cz.evidence.map(e=>({data:{id:e.id,label:e.id.toUpperCase(),type:`evidence`,color:e.confidence===`High`?`#22d3ee`:e.confidence===`Moderate`?`#fbbf24`:`#f43f5e`,summary:e.summary}})),{data:{source:`ais`,target:`ev1`,label:`reports`}},{data:{source:`stateA`,target:`ev2`,label:`issues`}},{data:{source:`mediaB`,target:`ev3`,label:`publishes`}},{data:{source:`social`,target:`ev4`,label:`amplifies`}},{data:{source:`mediaB`,target:`social`,label:`feeds`}},{data:{source:`ev3`,target:`cable`,label:`claims`}},{data:{source:`ev1`,target:`stateA`,label:`related`}}];return t.current=Q$({container:e.current,elements:n,style:[{selector:`node`,style:{"background-color":`data(color)`,label:`data(label)`,color:`#e2e8f0`,"font-size":11,"font-family":`Inter, system-ui, sans-serif`,"text-valign":`bottom`,"text-margin-y":6,width:36,height:36,"border-width":2,"border-color":`#1e293b`}},{selector:`node[type='evidence']`,style:{shape:`round-rectangle`,width:48,height:28,"font-size":10}},{selector:`edge`,style:{width:1.5,"line-color":`#475569`,"target-arrow-color":`#475569`,"target-arrow-shape":`triangle`,"curve-style":`bezier`,label:`data(label)`,"font-size":9,color:`#94a3b8`,"text-rotation":`autorotate`,"text-margin-y":-8}},{selector:`node:selected`,style:{"border-color":`#00e5ff`,"border-width":3}}],layout:{name:`cose`,animate:!1,randomize:!1,idealEdgeLength:120,nodeOverlap:20,padding:30},userZoomingEnabled:!0,userPanningEnabled:!0,boxSelectionEnabled:!1}),t.current.on(`tap`,`node`,e=>{let t=e.target.data();if(t.type===`evidence`){let e=Cz.evidence.find(e=>e.id===t.id);e&&alert(`${e.id}: ${e.summary}\n\nConfidence: ${e.confidence}\n${e.notes}`)}}),()=>{t.current?.destroy(),t.current=null}},[]),(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold text-cyan-400`,children:`Investigation & Link Analysis`}),(0,H.jsx)(`p`,{className:`text-sm text-slate-400 mt-1`,children:`Relationship graph for BALTIC SHADOW. Tap evidence nodes for details. All data is synthetic.`})]}),(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl overflow-hidden h-[520px] relative`,children:[(0,H.jsx)(`div`,{ref:e,className:`w-full h-full`}),(0,H.jsx)(`div`,{className:`absolute top-4 left-4 bg-navy-900/80 backdrop-blur px-3 py-1.5 rounded text-xs border border-navy-700`,children:`Entities • Evidence • Links`})]}),(0,H.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl p-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-cyan-400 mb-3`,children:`Competing Hypotheses`}),(0,H.jsxs)(`ul`,{className:`space-y-2 text-sm text-slate-300`,children:[(0,H.jsx)(`li`,{children:`• H1: Routine naval exercise with weather-related AIS gaps.`}),(0,H.jsx)(`li`,{children:`• H2: Hostile preparation against infrastructure (low support).`}),(0,H.jsx)(`li`,{children:`• H3: Information operation amplifying an unverified claim.`})]})]}),(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl p-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-cyan-400 mb-3`,children:`Graph Legend`}),(0,H.jsxs)(`div`,{className:`space-y-2 text-sm text-slate-300`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`w-3 h-3 rounded-full bg-cyan-400`}),` Entity`]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`w-4 h-2.5 rounded bg-amber-400`}),` Evidence (color = confidence)`]}),(0,H.jsx)(`div`,{className:`text-xs text-slate-500 mt-2`,children:`Drag nodes • Scroll to zoom • Tap evidence for summary`})]})]})]})]})}function rse(){return(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold text-cyan-400`,children:`Threat Intelligence`}),(0,H.jsx)(`p`,{className:`text-sm text-slate-400 mt-1`,children:`BALTIC SHADOW — Current threat picture (fictional)`})]}),(0,H.jsx)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[{title:`Maritime`,level:`Moderate`,note:`Anomalous AIS activity. No confirmed hostile naval concentration.`},{title:`Infrastructure`,level:`Low`,note:`Single unverified report near cable landing. No corroboration.`},{title:`Information`,level:`Moderate`,note:`Coordinated amplification of low-credibility claim observed.`},{title:`Diplomatic`,level:`Low`,note:`Official denial issued. No escalation indicators.`}].map(e=>(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl p-5`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,H.jsx)(`h3`,{className:`font-medium`,children:e.title}),(0,H.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-amber-500/10 text-amber-400`,children:e.level})]}),(0,H.jsx)(`p`,{className:`text-sm text-slate-400`,children:e.note})]},e.title))})]})}function ise(){let[e,t]=(0,_.useState)(Cz.resourceBudget),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),o=n=>{e{let r=e>=t.cost,a=n===t.id;return(0,H.jsxs)(`button`,{onClick:()=>o(t),disabled:!r||n!==null,className:`text-left bg-navy-800 border rounded-xl p-5 transition-all ${a?`border-cyan-500/50 bg-cyan-500/5`:r?`border-navy-700 hover:border-cyan-500/30`:`border-navy-700 opacity-50 cursor-not-allowed`}`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`font-medium`,children:t.title}),(0,H.jsx)(`p`,{className:`text-sm text-slate-400 mt-1`,children:t.description})]}),(0,H.jsxs)(`div`,{className:`text-amber-400 font-mono text-sm ml-4`,children:[`-`,t.cost]})]}),a&&i&&(0,H.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-navy-700 text-sm text-cyan-300`,children:[`Outcome: `,i]})]},t.id)})}),n&&(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-amber-500/30 rounded-xl p-5 text-sm`,children:[(0,H.jsx)(`div`,{className:`text-amber-400 font-medium mb-1`,children:`Decision recorded`}),(0,H.jsx)(`p`,{className:`text-slate-300`,children:`Resources spent. Proceed to Assessment for scoring and after-action review.`})]})]})}function ase(){return(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold text-cyan-400`,children:`Intelligence Assessment`}),(0,H.jsx)(`p`,{className:`text-sm text-slate-400 mt-1`,children:`BALTIC SHADOW — After-Action Review`})]}),(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl p-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-cyan-400 mb-3`,children:`Key Judgments`}),(0,H.jsxs)(`ul`,{className:`space-y-2 text-sm text-slate-300`,children:[(0,H.jsx)(`li`,{children:`• Naval activity was real and consistent with a routine exercise by State A.`}),(0,H.jsx)(`li`,{children:`• AIS gaps were anomalous but not indicative of hostile intent.`}),(0,H.jsx)(`li`,{children:`• The infrastructure claim originated from a low-credibility source and was amplified.`}),(0,H.jsx)(`li`,{children:`• No evidence of imminent hostile action against undersea infrastructure.`})]})]}),(0,H.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl p-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-cyan-400 mb-3`,children:`Evidence Quality`}),(0,H.jsx)(`div`,{className:`space-y-2 text-sm`,children:Cz.evidence.map(e=>(0,H.jsxs)(`div`,{className:`flex justify-between`,children:[(0,H.jsx)(`span`,{className:`text-slate-300`,children:e.id}),(0,H.jsx)(`span`,{className:`text-amber-400`,children:e.confidence})]},e.id))})]}),(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-navy-700 rounded-xl p-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-cyan-400 mb-3`,children:`Analytical Notes`}),(0,H.jsxs)(`ul`,{className:`space-y-2 text-sm text-slate-300`,children:[(0,H.jsx)(`li`,{children:`• Corroboration was limited until satellite tasking or diplomatic inquiry.`}),(0,H.jsx)(`li`,{children:`• Early low-confidence media reporting was correctly treated as unverified.`}),(0,H.jsx)(`li`,{children:`• Resource allocation to collection reduced residual uncertainty.`})]})]})]}),(0,H.jsxs)(`div`,{className:`bg-navy-800 border border-emerald-500/30 rounded-xl p-5`,children:[(0,H.jsx)(`div`,{className:`text-emerald-400 font-medium mb-2`,children:`Mission Score (illustrative)`}),(0,H.jsx)(`div`,{className:`text-3xl font-mono`,children:`78 / 100`}),(0,H.jsx)(`p`,{className:`text-sm text-slate-400 mt-2`,children:`Rewards analytical caution, corroboration, and recognition of uncertainty. Exact scoring will incorporate player decisions and hypothesis accuracy.`})]})]})}var $$=[{id:`situation`,name:`Situation Room`,icon:Op,component:wz},{id:`osint`,name:`OSINT Desk`,icon:Pp,component:Ez},{id:`links`,name:`Investigation`,icon:Ap,component:nse},{id:`threats`,name:`Threat Intel`,icon:Ip,component:rse},{id:`decisions`,name:`Decision Room`,icon:Rp,component:ise},{id:`assessment`,name:`Assessment`,icon:Ep,component:ase}];function ose(){let[e,t]=(0,_.useState)(`situation`),[n,r]=(0,_.useState)(!1),i=$$.find(t=>t.id===e)?.component||wz;return(0,H.jsxs)(`div`,{className:`min-h-screen bg-navy-900 flex`,children:[(0,H.jsxs)(up.aside,{initial:!1,animate:{width:n?256:72},className:`fixed inset-y-0 left-0 z-50 bg-navy-800 border-r border-navy-700 flex flex-col md:relative`,children:[(0,H.jsxs)(`div`,{className:`p-4 flex items-center justify-between border-b border-navy-700`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3 ${!n&&`justify-center w-full`}`,children:[(0,H.jsx)(`div`,{className:`w-8 h-8 rounded bg-gradient-to-br from-cyan-500 to-amber-500 flex items-center justify-center text-navy-950 font-bold text-sm`,children:`SF`}),n&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-semibold text-sm tracking-wide`,children:`SHADOW FRONT`}),(0,H.jsx)(`div`,{className:`text-[10px] text-cyan-400 uppercase tracking-widest`,children:`VERLUX`})]})]}),(0,H.jsx)(`button`,{onClick:()=>r(!n),className:`md:hidden text-slate-400`,children:n?(0,H.jsx)(Bp,{size:18}):(0,H.jsx)(Mp,{size:18})})]}),(0,H.jsx)(`nav`,{className:`flex-1 p-2 space-y-1`,children:$$.map(i=>{let a=i.icon,o=e===i.id;return(0,H.jsxs)(`button`,{onClick:()=>{t(i.id),r(!1)},className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm transition-colors ${o?`bg-cyan-500/10 text-cyan-400 border border-cyan-500/30`:`text-slate-400 hover:text-slate-200 hover:bg-navy-700`}`,children:[(0,H.jsx)(a,{size:18,className:o?`text-cyan-400`:``}),n&&(0,H.jsx)(`span`,{children:i.name})]},i.id)})}),(0,H.jsx)(`div`,{className:`p-4 border-t border-navy-700 text-[10px] text-slate-500`,children:n&&`Director of Intelligence`})]}),(0,H.jsxs)(`main`,{className:`flex-1 ml-0 md:ml-[72px] min-h-screen`,children:[(0,H.jsxs)(`header`,{className:`sticky top-0 z-40 bg-navy-900/80 backdrop-blur border-b border-navy-700 px-6 py-4 flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:$$.find(t=>t.id===e)?.name}),(0,H.jsx)(`p`,{className:`text-xs text-slate-500`,children:`BALTIC SHADOW • Campaign 1 of 5`})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-4 text-xs`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-cyan-500 animate-pulse`}),(0,H.jsx)(`span`,{className:`text-cyan-400`,children:`LIVE`})]}),(0,H.jsx)(`div`,{className:`text-amber-400 font-mono`,children:`RES: 100`})]})]}),(0,H.jsx)(`div`,{className:`p-6`,children:(0,H.jsx)(af,{mode:`wait`,children:(0,H.jsx)(up.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.2},children:(0,H.jsx)(i,{})},e)})})]})]})}(0,v.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(_.StrictMode,{children:(0,H.jsx)(ose,{})}));