Files
boc/backups/2026-07-12-1023/landvex-prod/assets/index-oAPVDf-r.js
T

3720 lines
2.6 MiB
JavaScript
Raw Normal View History

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Index-B5xg3G3P.js","assets/refresh-cw-DEBvxUr1.js","assets/clock-DRtqJZUo.js","assets/chevron-right-B9rMgght.js","assets/index-DGH-oZ97.js","assets/circle-alert-C1Hs9zwh.js","assets/video-D6Sip5Dx.js","assets/Auth-Gib-waoR.js","assets/mail-BT0S3dBU.js","assets/eye-G89nJUb2.js","assets/MissionDetail-C7kUviJC.js","assets/useMissionExamples-B0el-PHm.js","assets/useIdentityVerification-CD3mPBIt.js","assets/circle-check-D3hjqUcb.js","assets/SecureCamera-mAkOb0O2.js","assets/index-B-MEeiYV.js","assets/shield-BWGzcrms.js","assets/check-CG8zylH4.js","assets/award-By-NEFpe.js","assets/triangle-alert-B87swlNS.js","assets/gift-lxeNwCUB.js","assets/ticket-D1bxyCST.js","assets/external-link-C86N9iPS.js","assets/arrow-left-m6EiMbb-.js","assets/image-DuU1QaV8.js","assets/timer-C5oB41EC.js","assets/Profile-C4xYBVXU.js","assets/dropdown-menu-CBJEO_Gg.js","assets/circle-030W8joh.js","assets/badge-Qwi4CUXx.js","assets/progress-Cql_vZKU.js","assets/trending-up-Be0ZnpBQ.js","assets/leaf-DHbwTQEy.js","assets/zap-RaPdKGJZ.js","assets/select-Bi-TzF3J.js","assets/chevron-down-QDDHZwZg.js","assets/building-2-w77rCUKE.js","assets/credit-card-CfUVKCDe.js","assets/palette-xHAcW495.js","assets/save-BwjzM02b.js","assets/Wallet-DDpmfw68.js","assets/differenceInDays-CJS5VaxB.js","assets/sv-BZPVJm6C.js","assets/star-C6FiGbGr.js","assets/qr-code-BIBWO21n.js","assets/heart-BjLemQnU.js","assets/graduation-cap-Bk5l1TQx.js","assets/scroll-area-B0CEXZGH.js","assets/info-BT66tWy0.js","assets/file-text-CyDVAB5w.js","assets/download-B0vydl5E.js","assets/send-DsElwFaU.js","assets/calendar-Bof-SGwp.js","assets/Notifications-B8XGepdj.js","assets/VerifyIdentity-Ro09dKVe.js","assets/OrdererRegistration-BOhnJl4W.js","assets/radio-group-CcrlZGTP.js","assets/landmark-BYZTTZdl.js","assets/CreateMission-8331plbz.js","assets/upload-LLBu8Q_P.js","assets/repeat-wK6OxTxo.js","assets/megaphone-CztbyYca.js","assets/CreateCampaign-DUvMysdJ.js","assets/waves-DiawweIQ.js","assets/trash-2-A3LTadZ7.js","assets/radio-G_rzhIIH.js","assets/settings-BTJAoFnf.js","assets/search-K36NSOaV.js","assets/OrdererDashboard-5y9XrRsn.js","assets/tabs-CYk3p-Aj.js","assets/useQuery-BxfmyRLz.js","assets/ROICalculator-DVEYTdny.js","assets/layers-DZd3aBRI.js","assets/activity-B0zyNqjw.js","assets/server-BrxxSdWs.js","assets/key-BAzZqC6d.js","assets/RealChangeMission-MIGek0JF.js","assets/blocks-CUUl6oOU.js","assets/OrdererMissionDetail-BnWG6WKo.js","assets/OperationsPopout-BuyROwwG.js","assets/AnalyticsPopout-C0wfA38E.js","assets/AdsPopout-DKNQbVOB.js","assets/Principles-C209eajW.js","assets/network-DAH-TQsi.js","assets/Policy-rMsjW2x7.js","assets/PhotoMarketplace-CAR9gpra.js","assets/taj-mahal-CpmP2aQk.js","assets/PhotoDetail-CGO3w_xn.js","assets/PhotoContest-Dt4wePeS.js","assets/IdentityDisclaimer-BQti7r70.js","assets/RedeemVoucher-NVDK1D_N.js"])))=>i.map(i=>d[i]);
var BD=t=>{throw TypeError(t)};var y2=(t,e,s)=>e.has(t)||BD("Cannot "+s);var Gt=(t,e,s)=>(y2(t,e,"read from private field"),s?s.call(t):e.get(t)),wi=(t,e,s)=>e.has(t)?BD("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),Bn=(t,e,s,u)=>(y2(t,e,"write to private field"),u?u.call(t,s):e.set(t,s),s),Bo=(t,e,s)=>(y2(t,e,"access private method"),s);var zw=(t,e,s,u)=>({set _(h){Bn(t,e,h,s)},get _(){return Gt(t,e,u)}});function lG(t,e){for(var s=0;s<e.length;s++){const u=e[s];if(typeof u!="string"&&!Array.isArray(u)){for(const h in u)if(h!=="default"&&!(h in t)){const _=Object.getOwnPropertyDescriptor(u,h);_&&Object.defineProperty(t,h,_.get?_:{enumerable:!0,get:()=>u[h]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const h of document.querySelectorAll('link[rel="modulepreload"]'))u(h);new MutationObserver(h=>{for(const _ of h)if(_.type==="childList")for(const w of _.addedNodes)w.tagName==="LINK"&&w.rel==="modulepreload"&&u(w)}).observe(document,{childList:!0,subtree:!0});function s(h){const _={};return h.integrity&&(_.integrity=h.integrity),h.referrerPolicy&&(_.referrerPolicy=h.referrerPolicy),h.crossOrigin==="use-credentials"?_.credentials="include":h.crossOrigin==="anonymous"?_.credentials="omit":_.credentials="same-origin",_}function u(h){if(h.ep)return;h.ep=!0;const _=s(h);fetch(h.href,_)}})();var cG=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function FA(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var lF={exports:{}},O1={},cF={exports:{}},ti={};/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var k0=Symbol.for("react.element"),uG=Symbol.for("react.portal"),dG=Symbol.for("react.fragment"),hG=Symbol.for("react.strict_mode"),fG=Symbol.for("react.profiler"),pG=Symbol.for("react.provider"),mG=Symbol.for("react.context"),gG=Symbol.for("react.forward_ref"),_G=Symbol.for("react.suspense"),yG=Symbol.for("react.memo"),vG=Symbol.for("react.lazy"),ND=Symbol.iterator;function xG(t){return t===null||typeof t!="object"?null:(t=ND&&t[ND]||t["@@iterator"],typeof t=="function"?t:null)}var uF={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},dF=Object.assign,hF={};function Wg(t,e,s){this.props=t,this.context=e,this.refs=hF,this.updater=s||uF}Wg.prototype.isReactComponent={};Wg.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Wg.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function fF(){}fF.prototype=Wg.prototype;function BA(t,e,s){this.props=t,this.context=e,this.refs=hF,this.updater=s||uF}var NA=BA.prototype=new fF;NA.constructor=BA;dF(NA,Wg.prototype);NA.isPureReactComponent=!0;var jD=Array.isArray,pF=Object.prototype.hasOwnProperty,jA={current:null},mF={key:!0,ref:!0,__self:!0,__source:!0};function gF(t,e,s){var u,h={},_=null,w=null;if(e!=null)for(u in e.ref!==void 0&&(w=e.ref),e.key!==void 0&&(_=""+e.key),e)pF.call(e,u)&&!mF.hasOwnProperty(u)&&(h[u]=e[u]);var o=arguments.length-2;if(o===1)h.children=s;else if(1<o){for(var k=Array(o),P=0;P<o;P++)k[P]=arguments[P+2];h.children=k}if(t&&t.defaultProps)for(u in o=t.defaultProps,o)h[u]===void 0&&(h[u]=o[u]);return{$$typeof:k0,type:t,key:_,ref:w,props:h,_owner:jA.current}}function wG(t,e){return{$$typeof:k0,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function VA(t){return typeof t=="object"&&t!==null&&t.$$typeof===k0}function bG(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(s){return e[s]})}var VD=/\/+/g;function v2(t,e){return typeof t=="object"&&t!==null&&t.key!=null?bG(""+t.key):e.toString(36)}function xb(t,e,s,u,h){var _=typeof t;(_==="undefined"||_==="boolean")&&(t=null);var w=!1;if(t===null)w=!0;else switch(_){case"string":case"number":w=!0;break;case"object":switch(t.$$typeof){case k0:case uG:w=!0}}if(w)return w=t,h=h(w),t=u===""?"."+v2(w,0):u,jD(h)?(s="",t!=null&&(s=t.replace(VD,"$&/")+"/"),xb(h,e,s,"",function(P){return P})):h!=null&&(VA(h)&&(h=wG(h,s+(!h.key||w&&w.key===h.key?"":(""+h.key).replace(VD,"$&/")+"/")+t)),e.push(h)),1;if(w=0,u=u===""?".":u+":",jD(t))for(var o=0;o<t.length;o++){_=t[o];var k=u+v2(_,o);w+=xb(_,e,s,k,h)}else if(k=xG(t),typeof k=="function")for(t=k.call(t),o=0;!(_=t.next()).done;)_=_.value,k=u+v2(_,o++),w+=xb(_,e,s,k,h);else if(_==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return w}function Fw(t,e,s){if(t==null)return t;var u=[],h=0;return xb(t,u,"","",function(_){return e.call(s,_,h++)}),u}function SG(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(s){(t._status===0||t._status===-1)&&(t._status=1,t._result=s)},function(s){(t._status===0||t._status===-1)&&(t._status=2,t._result=s)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var la={current:null},wb={transition:null},TG={ReactCurrentDispatcher:la,ReactCurrentBatchConfig:wb,ReactCurrentOwner:jA};function _F(){throw Error("act(...) is not supported in production builds of React.")}ti.Children={map:Fw,forEach:function(t,e,s){Fw(t,function(){e.apply(this,arguments)},s)},count:function(t){var e=0;return Fw(t,function(){e++}),e},toArray:function(t){return Fw(t,function(e){return e})||[]},only:function(t){if(!VA(t))throw Error("React.Children.only expected to receive a sin
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var EG=X,kG=Symbol.for("react.element"),AG=Symbol.for("react.fragment"),CG=Object.prototype.hasOwnProperty,IG=EG.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,PG={key:!0,ref:!0,__self:!0,__source:!0};function yF(t,e,s){var u,h={},_=null,w=null;s!==void 0&&(_=""+s),e.key!==void 0&&(_=""+e.key),e.ref!==void 0&&(w=e.ref);for(u in e)CG.call(e,u)&&!PG.hasOwnProperty(u)&&(h[u]=e[u]);if(t&&t.defaultProps)for(u in e=t.defaultProps,e)h[u]===void 0&&(h[u]=e[u]);return{$$typeof:kG,type:t,key:_,ref:w,props:h,_owner:IG.current}}O1.Fragment=AG;O1.jsx=yF;O1.jsxs=yF;lF.exports=O1;var le=lF.exports,vF={exports:{}},Ya={},xF={exports:{}},wF={};/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(t){function e(st,Pt){var qt=st.length;st.push(Pt);e:for(;0<qt;){var _r=qt-1>>>1,yr=st[_r];if(0<h(yr,Pt))st[_r]=Pt,st[qt]=yr,qt=_r;else break e}}function s(st){return st.length===0?null:st[0]}function u(st){if(st.length===0)return null;var Pt=st[0],qt=st.pop();if(qt!==Pt){st[0]=qt;e:for(var _r=0,yr=st.length,hr=yr>>>1;_r<hr;){var Gr=2*(_r+1)-1,mi=st[Gr],Oi=Gr+1,xn=st[Oi];if(0>h(mi,qt))Oi<yr&&0>h(xn,mi)?(st[_r]=xn,st[Oi]=qt,_r=Oi):(st[_r]=mi,st[Gr]=qt,_r=Gr);else if(Oi<yr&&0>h(xn,qt))st[_r]=xn,st[Oi]=qt,_r=Oi;else break e}}return Pt}function h(st,Pt){var qt=st.sortIndex-Pt.sortIndex;return qt!==0?qt:st.id-Pt.id}if(typeof performance=="object"&&typeof performance.now=="function"){var _=performance;t.unstable_now=function(){return _.now()}}else{var w=Date,o=w.now();t.unstable_now=function(){return w.now()-o}}var k=[],P=[],O=1,F=null,V=3,$=!1,Y=!1,Z=!1,se=typeof setTimeout=="function"?setTimeout:null,te=typeof clearTimeout=="function"?clearTimeout:null,ee=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function oe(st){for(var Pt=s(P);Pt!==null;){if(Pt.callback===null)u(P);else if(Pt.startTime<=st)u(P),Pt.sortIndex=Pt.expirationTime,e(k,Pt);else break;Pt=s(P)}}function he(st){if(Z=!1,oe(st),!Y)if(s(k)!==null)Y=!0,Ot(Ie);else{var Pt=s(P);Pt!==null&&Et(he,Pt.startTime-st)}}function Ie(st,Pt){Y=!1,Z&&(Z=!1,te(Je),Je=-1),$=!0;var qt=V;try{for(oe(Pt),F=s(k);F!==null&&(!(F.expirationTime>Pt)||st&&!tr());){var _r=F.callback;if(typeof _r=="function"){F.callback=null,V=F.priorityLevel;var yr=_r(F.expirationTime<=Pt);Pt=t.unstable_now(),typeof yr=="function"?F.callback=yr:F===s(k)&&u(k),oe(Pt)}else u(k);F=s(k)}if(F!==null)var hr=!0;else{var Gr=s(P);Gr!==null&&Et(he,Gr.startTime-Pt),hr=!1}return hr}finally{F=null,V=qt,$=!1}}var Be=!1,je=null,Je=-1,ft=5,kt=-1;function tr(){return!(t.unstable_now()-kt<ft)}function jt(){if(je!==null){var st=t.unstable_now();kt=st;var Pt=!0;try{Pt=je(!0,st)}finally{Pt?Qe():(Be=!1,je=null)}}else Be=!1}var Qe;if(typeof ee=="function")Qe=function(){ee(jt)};else if(typeof MessageChannel<"u"){var xt=new MessageChannel,It=xt.port2;xt.port1.onmessage=jt,Qe=function(){It.postMessage(null)}}else Qe=function(){se(jt,0)};function Ot(st){je=st,Be||(Be=!0,Qe())}function Et(st,Pt){Je=se(function(){st(t.unstable_now())},Pt)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(st){st.callback=null},t.unstable_continueExecution=function(){Y||$||(Y=!0,Ot(Ie))},t.unstable_forceFrameRate=function(st){0>st||125<st?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ft=0<st?Math.floor(1e3/st):5},t.unstable_getCurrentPriorityLevel=function(){return V},t.unstable_getFirstCallbackNode=function(){return s(k)},t.unstable_next=function(st){switch(V){case 1:case 2:case 3:var Pt=3;break;default:Pt=V}var qt=V;V=Pt;try{return st()}finally{V=qt}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(st,Pt){switch(st){case 1:case 2:case 3:case 4:case 5:break;default:st=3}var qt=V;V=st;try{return Pt()}finally{V=qt}},t.unstable_scheduleCallback=function(st,Pt,qt){var _r=t.unstable_now();switch(typeof qt=="object"&&qt!==null?(qt=qt.delay,qt=typeof qt=="number"&&0<qt?_r+qt:_r):qt=_r,st){case 1:var yr=-1;break;case 2:yr=250;break;case 5:yr=1073741823;break;case 4:yr=1e4;break;default:yr=5e3}return yr=qt+yr,st={id:O++,callback:Pt,priorityLevel:st,startTime:qt,expirationTime:yr,sortIndex:-1},qt>_r?(st.sortIndex=qt,e(P,st),s(k)===null&&st===s(P)&&(Z?(te(Je),Je=-1):Z=!0,Et(he,qt-_r))):(st.sortIndex=yr,e(k,st),Y||$||(Y=!0,Ot(Ie))),st},t.unstable_shouldYield=tr,t.unstable_wrapCallback=function(st){var Pt=V;return function(){var qt=V;V=Pt;try{return st.apply(this,arguments)}finally{V=qt}}}})(wF);xF.export
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var RG=X,Xa=MG;function ir(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,s=1;s<arguments.length;s++)e+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var bF=new Set,jv={};function Gf(t,e){Lg(t,e),Lg(t+"Capture",e)}function Lg(t,e){for(jv[t]=e,t=0;t<e.length;t++)bF.add(e[t])}var Lu=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),zE=Object.prototype.hasOwnProperty,DG=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,UD={},$D={};function LG(t){return zE.call($D,t)?!0:zE.call(UD,t)?!1:DG.test(t)?$D[t]=!0:(UD[t]=!0,!1)}function OG(t,e,s,u){if(s!==null&&s.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return u?!1:s!==null?!s.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function zG(t,e,s,u){if(e===null||typeof e>"u"||OG(t,e,s,u))return!0;if(u)return!1;if(s!==null)switch(s.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ca(t,e,s,u,h,_,w){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=u,this.attributeNamespace=h,this.mustUseProperty=s,this.propertyName=t,this.type=e,this.sanitizeURL=_,this.removeEmptyString=w}var Ro={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ro[t]=new ca(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Ro[e]=new ca(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ro[t]=new ca(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ro[t]=new ca(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Ro[t]=new ca(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Ro[t]=new ca(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Ro[t]=new ca(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Ro[t]=new ca(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Ro[t]=new ca(t,5,!1,t.toLowerCase(),null,!1,!1)});var $A=/[\-:]([a-z])/g;function GA(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin
`+x2+t}var w2=!1;function b2(t,e){if(!t||w2)return"";w2=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(P){var u=P}Reflect.construct(t,[],e)}else{try{e.call()}catch(P){u=P}t.call(e.prototype)}else{try{throw Error()}catch(P){u=P}t()}}catch(P){if(P&&u&&typeof P.stack=="string"){for(var h=P.stack.split(`
`),_=u.stack.split(`
`),w=h.length-1,o=_.length-1;1<=w&&0<=o&&h[w]!==_[o];)o--;for(;1<=w&&0<=o;w--,o--)if(h[w]!==_[o]){if(w!==1||o!==1)do if(w--,o--,0>o||h[w]!==_[o]){var k=`
`+h[w].replace(" at new "," at ");return t.displayName&&k.includes("<anonymous>")&&(k=k.replace("<anonymous>",t.displayName)),k}while(1<=w&&0<=o);break}}}finally{w2=!1,Error.prepareStackTrace=s}return(t=t?t.displayName||t.name:"")?gv(t):""}function FG(t){switch(t.tag){case 5:return gv(t.type);case 16:return gv("Lazy");case 13:return gv("Suspense");case 19:return gv("SuspenseList");case 0:case 2:case 15:return t=b2(t.type,!1),t;case 11:return t=b2(t.type.render,!1),t;case 1:return t=b2(t.type,!0),t;default:return""}}function jE(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Jm:return"Fragment";case Ym:return"Portal";case FE:return"Profiler";case WA:return"StrictMode";case BE:return"Suspense";case NE:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case TF:return(t.displayName||"Context")+".Consumer";case SF:return(t._context.displayName||"Context")+".Provider";case qA:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case KA:return e=t.displayName||null,e!==null?e:jE(t.type)||"Memo";case Dd:e=t._payload,t=t._init;try{return jE(t(e))}catch{}}return null}function BG(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return jE(e);case 8:return e===WA?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function nh(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function kF(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function NG(t){var e=kF(t)?"checked":"value",s=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),u=""+t[e];if(!t.hasOwnProperty(e)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var h=s.get,_=s.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return h.call(this)},set:function(w){u=""+w,_.call(this,w)}}),Object.defineProperty(t,e,{enumerable:s.enumerable}),{getValue:function(){return u},setValue:function(w){u=""+w},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Nw(t){t._valueTracker||(t._valueTracker=NG(t))}function AF(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var s=e.getValue(),u="";return t&&(u=kF(t)?t.checked?"true":"false":t.value),t=u,t!==s?(e.setValue(t),!0):!1}function Gb(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function VE(t,e){var s=e.checked;return ws({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??t._wrapperState.initialChecked})}function HD(t,e){var s=e.defaultValue==null?"":e.defaultValue,u=e.checked!=null?e.checked:e.defaultChecked;s=nh(e.value!=null?e.value:s),t._wrapperState={initialChecked:u,initialValue:s,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function CF(t,e){e=e.checked,e!=null&&HA(t,"checked",e,!1)}function UE(t,e){CF(t,e);var s=nh(e.value),u=e.type;if(s!=null)u==="number"?(s===0&&t.value===""||t.value!=s)&&(t.value=""+s):t.value!==""+s&&(t.value=""+s);else if(u==="submit"||u==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?$E(t,e.type,s):e.hasOwnProperty("defaultValue")&&$E(t,e.type,nh(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function WD(t,e,s){if(e.hasOwnProperty("val
`).replace(ZH,"")}function qw(t,e,s){if(e=mL(e),mL(t)!==e&&s)throw Error(ir(425))}function Jb(){}var nk=null,ik=null;function sk(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var ok=typeof setTimeout=="function"?setTimeout:void 0,XH=typeof clearTimeout=="function"?clearTimeout:void 0,gL=typeof Promise=="function"?Promise:void 0,YH=typeof queueMicrotask=="function"?queueMicrotask:typeof gL<"u"?function(t){return gL.resolve(null).then(t).catch(JH)}:ok;function JH(t){setTimeout(function(){throw t})}function O2(t,e){var s=e,u=0;do{var h=s.nextSibling;if(t.removeChild(s),h&&h.nodeType===8)if(s=h.data,s==="/$"){if(u===0){t.removeChild(h),Hv(e);return}u--}else s!=="$"&&s!=="$?"&&s!=="$!"||u++;s=h}while(s);Hv(e)}function Yd(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function _L(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var s=t.data;if(s==="$"||s==="$!"||s==="$?"){if(e===0)return t;e--}else s==="/$"&&e++}t=t.previousSibling}return null}var Kg=Math.random().toString(36).slice(2),Vc="__reactFiber$"+Kg,Xv="__reactProps$"+Kg,Ou="__reactContainer$"+Kg,ak="__reactEvents$"+Kg,QH="__reactListeners$"+Kg,eW="__reactHandles$"+Kg;function vf(t){var e=t[Vc];if(e)return e;for(var s=t.parentNode;s;){if(e=s[Ou]||s[Vc]){if(s=e.alternate,e.child!==null||s!==null&&s.child!==null)for(t=_L(t);t!==null;){if(s=t[Vc])return s;t=_L(t)}return e}t=s,s=t.parentNode}return null}function I0(t){return t=t[Vc]||t[Ou],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function rg(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(ir(33))}function j1(t){return t[Xv]||null}var lk=[],ng=-1;function uh(t){return{current:t}}function ts(t){0>ng||(t.current=lk[ng],lk[ng]=null,ng--)}function Wi(t,e){ng++,lk[ng]=t.current,t.current=e}var ih={},Go=uh(ih),Aa=uh(!1),zf=ih;function Og(t,e){var s=t.type.contextTypes;if(!s)return ih;var u=t.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===e)return u.__reactInternalMemoizedMaskedChildContext;var h={},_;for(_ in s)h[_]=e[_];return u&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=h),h}function Ca(t){return t=t.childContextTypes,t!=null}function Qb(){ts(Aa),ts(Go)}function yL(t,e,s){if(Go.current!==ih)throw Error(ir(168));Wi(Go,e),Wi(Aa,s)}function g5(t,e,s){var u=t.stateNode;if(e=e.childContextTypes,typeof u.getChildContext!="function")return s;u=u.getChildContext();for(var h in u)if(!(h in e))throw Error(ir(108,BG(t)||"Unknown",h));return ws({},s,u)}function e1(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||ih,zf=Go.current,Wi(Go,t),Wi(Aa,Aa.current),!0}function vL(t,e,s){var u=t.stateNode;if(!u)throw Error(ir(169));s?(t=g5(t,e,zf),u.__reactInternalMemoizedMergedChildContext=t,ts(Aa),ts(Go),Wi(Go,t)):ts(Aa),Wi(Aa,s)}var Iu=null,V1=!1,z2=!1;function _5(t){Iu===null?Iu=[t]:Iu.push(t)}function tW(t){V1=!0,_5(t)}function dh(){if(!z2&&Iu!==null){z2=!0;var t=0,e=Ii;try{var s=Iu;for(Ii=1;t<s.length;t++){var u=s[t];do u=u(!0);while(u!==null)}Iu=null,V1=!1}catch(h){throw Iu!==null&&(Iu=Iu.slice(t+1)),UF(XA,dh),h}finally{Ii=e,z2=!1}}return null}var ig=[],sg=0,t1=null,r1=0,_l=[],yl=0,Ff=null,Mu=1,Ru="";function hf(t,e){ig[sg++]=r1,ig[sg++]=t1,t1=t,r1=e}function y5(t,e,s){_l[yl++]=Mu,_l[yl++]=Ru,_l[yl++]=Ff,Ff=t;var u=Mu;t=Ru;var h=32-lc(u)-1;u&=~(1<<h),s+=1;var _=32-lc(e)+h;if(30<_){var w=h-h%5;_=(u&(1<<w)-1).toString(32),u>>=w,h-=w,Mu=1<<32-lc(e)+h|s<<h|u,Ru=_+t}else Mu=1<<_|s<<h|u,Ru=t}function sC(t){t.return!==null&&(hf(t,1),y5(t,1,0))}function oC(t){for(;t===t1;)t1=ig[--sg],ig[sg]=null,r1=ig[--sg],ig[sg]=null;for(;t===Ff;)Ff=_l[--yl],_l[yl]=null,Ru=_l[--yl],_l[yl]=null,Mu=_l[--yl],_l[yl]=null}var Ka=null,qa=null,as=!1,ac=null;function v5(t,e){var s=vl(5,null,null,0);s.elementType="DELETED",s.stateNode=e,s.return=t,e=t.de
Error generating stack: `+_.message+`
`+_.stack}return{value:t,source:e,stack:h,digest:null}}function V2(t,e,s){return{value:t,source:null,stack:s??null,digest:e??null}}function pk(t,e){try{console.error(e.value)}catch(s){setTimeout(function(){throw s})}}var uW=typeof WeakMap=="function"?WeakMap:Map;function W5(t,e,s){s=Du(-1,s),s.tag=3,s.payload={element:null};var u=e.value;return s.callback=function(){u1||(u1=!0,Tk=u),pk(t,e)},s}function q5(t,e,s){s=Du(-1,s),s.tag=3;var u=t.type.getDerivedStateFromError;if(typeof u=="function"){var h=e.value;s.payload=function(){return u(h)},s.callback=function(){pk(t,e)}}var _=t.stateNode;return _!==null&&typeof _.componentDidCatch=="function"&&(s.callback=function(){pk(t,e),typeof u!="function"&&(Qd===null?Qd=new Set([this]):Qd.add(this));var w=e.stack;this.componentDidCatch(e.value,{componentStack:w!==null?w:""})}),s}function IL(t,e,s){var u=t.pingCache;if(u===null){u=t.pingCache=new uW;var h=new Set;u.set(e,h)}else h=u.get(e),h===void 0&&(h=new Set,u.set(e,h));h.has(s)||(h.add(s),t=TW.bind(null,t,e,s),e.then(t,t))}function PL(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function ML(t,e,s,u,h){return t.mode&1?(t.flags|=65536,t.lanes=h,t):(t===e?t.flags|=65536:(t.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(e=Du(-1,1),e.tag=2,Jd(s,e,1))),s.lanes|=1),t)}var dW=$u.ReactCurrentOwner,Ea=!1;function ia(t,e,s,u){e.child=t===null?b5(e,null,s,u):Fg(e,t.child,s,u)}function RL(t,e,s,u,h){s=s.render;var _=e.ref;return vg(e,h),u=_C(t,e,s,u,_,h),s=yC(),t!==null&&!Ea?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~h,Fu(t,e,h)):(as&&s&&sC(e),e.flags|=1,ia(t,e,u,h),e.child)}function DL(t,e,s,u,h){if(t===null){var _=s.type;return typeof _=="function"&&!CC(_)&&_.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(e.tag=15,e.type=_,K5(t,e,_,u,h)):(t=Mb(s.type,null,u,e,e.mode,h),t.ref=e.ref,t.return=e,e.child=t)}if(_=t.child,!(t.lanes&h)){var w=_.memoizedProps;if(s=s.compare,s=s!==null?s:qv,s(w,u)&&t.ref===e.ref)return Fu(t,e,h)}return e.flags|=1,t=th(_,u),t.ref=e.ref,t.return=e,e.child=t}function K5(t,e,s,u,h){if(t!==null){var _=t.memoizedProps;if(qv(_,u)&&t.ref===e.ref)if(Ea=!1,e.pendingProps=u=_,(t.lanes&h)!==0)t.flags&131072&&(Ea=!0);else return e.lanes=t.lanes,Fu(t,e,h)}return mk(t,e,s,u,h)}function Z5(t,e,s){var u=e.pendingProps,h=u.children,_=t!==null?t.memoizedState:null;if(u.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wi(lg,Ua),Ua|=s;else{if(!(s&1073741824))return t=_!==null?_.baseLanes|s:s,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,Wi(lg,Ua),Ua|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=_!==null?_.baseLanes:s,Wi(lg,Ua),Ua|=u}else _!==null?(u=_.baseLanes|s,e.memoizedState=null):u=s,Wi(lg,Ua),Ua|=u;return ia(t,e,h,s),e.child}function X5(t,e){var s=e.ref;(t===null&&s!==null||t!==null&&t.ref!==s)&&(e.flags|=512,e.flags|=2097152)}function mk(t,e,s,u,h){var _=Ca(s)?zf:Go.current;return _=Og(e,_),vg(e,h),s=_C(t,e,s,u,_,h),u=yC(),t!==null&&!Ea?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~h,Fu(t,e,h)):(as&&u&&sC(e),e.flags|=1,ia(t,e,s,h),e.child)}function LL(t,e,s,u,h){if(Ca(s)){var _=!0;e1(e)}else _=!1;if(vg(e,h),e.stateNode===null)Cb(t,e),H5(e,s,u),fk(e,s,u,h),u=!0;else if(t===null){var w=e.stateNode,o=e.memoizedProps;w.props=o;var k=w.context,P=s.contextType;typeof P=="object"&&P!==null?P=Sl(P):(P=Ca(s)?zf:Go.current,P=Og(e,P));var O=s.getDerivedStateFromProps,F=typeof O=="function"||typeof w.getSnapshotBeforeUpdate=="function";F||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(o!==u||k!==P)&&CL(e,w,u,P),Ld=!1;var V=e.memoizedState;w.state=V,s1(e,u,w,h),k=e.memoizedState,o!==u||V!==k||Aa.current||Ld?(typeof O=="function"&&(hk(e,s,O,u),k=e.memoizedState),(o=Ld||AL(e,s,o,u,V,k,P))?(F||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Oq=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),XB=(...t)=>t.filter((e,s,u)=>!!e&&e.trim()!==""&&u.indexOf(e)===s).join(" ").trim();/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var zq={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Fq=X.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:u,className:h="",children:_,iconNode:w,...o},k)=>X.createElement("svg",{ref:k,...zq,width:e,height:e,stroke:t,strokeWidth:u?Number(s)*24/Number(e):s,className:XB("lucide",h),...o},[...w.map(([P,O])=>X.createElement(P,O)),...Array.isArray(_)?_:[_]]));/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ui=(t,e)=>{const s=X.forwardRef(({className:u,...h},_)=>X.createElement(Fq,{ref:_,iconNode:e,className:XB(`lucide-${Oq(t)}`,u),...h}));return s.displayName=`${t}`,s};/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Bq=ui("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rO=ui("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const YB=ui("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const nO=ui("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Nq=ui("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const jq=ui("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Vq=ui("CloudFog",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 17H7",key:"pygtm1"}],["path",{d:"M17 21H9",key:"1u2q02"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Om=ui("CloudRain",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v6",key:"1j4efv"}],["path",{d:"M8 14v6",key:"17c4r9"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const iO=ui("CloudSnow",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M8 19h.01",key:"puxtts"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M12 21h.01",key:"h35vbk"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M16 19h.01",key:"1vcnzz"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Uq=ui("CloudSun",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Rk=ui("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const JB=ui("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $q=ui("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Gq=ui("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Hq=ui("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sO=ui("Footprints",[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Wq=ui("Globe",[["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"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qq=ui("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const p1=ui("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Kq=ui("Locate",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Zq=ui("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const QB=ui("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Xq=ui("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const m1=ui("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Dk=ui("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Lk=ui("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Yq=ui("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Jq=ui("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const eN=ui("Target",[["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"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Qq=ui("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const oO=ui("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const e9=ui("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const t9=ui("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const r9=ui("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Df=ui("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),BC="-",n9=t=>{const e=s9(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:u}=t;return{getClassGroupId:w=>{const o=w.split(BC);return o[0]===""&&o.length!==1&&o.shift(),tN(o,e)||i9(w)},getConflictingClassGroupIds:(w,o)=>{const k=s[w]||[];return o&&u[w]?[...k,...u[w]]:k}}},tN=(t,e)=>{var w;if(t.length===0)return e.classGroupId;const s=t[0],u=e.nextPart.get(s),h=u?tN(t.slice(1),u):void 0;if(h)return h;if(e.validators.length===0)return;const _=t.join(BC);return(w=e.validators.find(({validator:o})=>o(_)))==null?void 0:w.classGroupId},aO=/^\[(.+)\]$/,i9=t=>{if(aO.test(t)){const e=aO.exec(t)[1],s=e==null?void 0:e.substring(0,e.indexOf(":"));if(s)return"arbitrary.."+s}},s9=t=>{const{theme:e,prefix:s}=t,u={nextPart:new Map,validators:[]};return a9(Object.entries(t.classGroups),s).forEach(([_,w])=>{Ok(w,u,_,e)}),u},Ok=(t,e,s,u)=>{t.forEach(h=>{if(typeof h=="string"){const _=h===""?e:lO(e,h);_.classGroupId=s;return}if(typeof h=="function"){if(o9(h)){Ok(h(u),e,s,u);return}e.validators.push({validator:h,classGroupId:s});return}Object.entries(h).forEach(([_,w])=>{Ok(w,lO(e,_),s,u)})})},lO=(t,e)=>{let s=t;return e.split(BC).forEach(u=>{s.nextPart.has(u)||s.nextPart.set(u,{nextPart:new Map,validators:[]}),s=s.nextPart.get(u)}),s},o9=t=>t.isThemeGetter,a9=(t,e)=>e?t.map(([s,u])=>{const h=u.map(_=>typeof _=="string"?e+_:typeof _=="object"?Object.fromEntries(Object.entries(_).map(([w,o])=>[e+w,o])):_);return[s,h]}):t,l9=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,s=new Map,u=new Map;const h=(_,w)=>{s.set(_,w),e++,e>t&&(e=0,u=s,s=new Map)};return{get(_){let w=s.get(_);if(w!==void 0)return w;if((w=u.get(_))!==void 0)return h(_,w),w},set(_,w){s.has(_)?s.set(_,w):h(_,w)}}},rN="!",c9=t=>{const{separator:e,experimentalParseClassName:s}=t,u=e.length===1,h=e[0],_=e.length,w=o=>{const k=[];let P=0,O=0,F;for(let se=0;se<o.length;se++){let te=o[se];if(P===0){if(te===h&&(u||o.slice(se,se+_)===e)){k.push(o.slice(O,se)),O=se+_;continue}if(te==="/"){F=se;continue}}te==="["?P++:te==="]"&&P--}const V=k.length===0?o:o.substring(O),$=V.startsWith(rN),Y=$?V.substring(1):V,Z=F&&F>O?F-O:void 0;return{modifiers:k,hasImportantModifier:$,baseClassName:Y,maybePostfixModifierPosition:Z}};return s?o=>s({className:o,parseClassName:w}):w},u9=t=>{if(t.length<=1)return t;const e=[];let s=[];return t.forEach(u=>{u[0]==="["?(e.push(...s.sort(),u),s=[]):s.push(u)}),e.push(...s.sort()),e},d9=t=>({cache:l9(t.cacheSize),parseClassName:c9(t),...n9(t)}),h9=/\s+/,f9=(t,e)=>{const{parseClassName:s,getClassGroupId:u,getConflictingClassGroupIds:h}=e,_=[],w=t.trim().split(h9);let o="";for(let k=w.length-1;k>=0;k-=1){const P=w[k],{modifiers:O,hasImportantModifier:F,baseClassName:V,maybePostfixModifierPosition:$}=s(P);let Y=!!$,Z=u(Y?V.substring(0,$):V);if(!Z){if(!Y){o=P+(o.length>0?" "+o:o);continue}if(Z=u(V),!Z){o=P+(o.length>0?" "+o:o);continue}Y=!1}const se=u9(O).join(":"),te=F?se+rN:se,ee=te+Z;if(_.includes(ee))continue;_.push(ee);const oe=h(Z,Y);for(let he=0;he<oe.length;++he){const Ie=oe[he];_.push(te+Ie)}o=P+(o.length>0?" "+o:o)}return o};function p9(){let t=0,e,s,u="";for(;t<arguments.length;)(e=arguments[t++])&&(s=nN(e))&&(u&&(u+=" "),u+=s);return u}const nN=t=>{if(typeof t=="string")return t;let e,s="";for(let u=0;u<t.length;u++)t[u]&&(e=nN(t[u]))&&(s&&(s+=" "),s+=e);return s};function m9(t,...e){let s,u,h,_=w;function w(k){const P=e.reduce((O,F)=>F(O),t());return s=d9(P),u=s.cache.get,h=s.cache.set,_=o,o(k)}function o(k){const P=u(k);if(P)return P;const O=f9(k,s);return h(k,O),O}return function(){return _(p9.apply(null,arguments))}}const Qi=t=>{const e=s=>s[t]||[];return e.isThemeGetter=!0,e},iN=/^\[(?:([a-z-]+):)?(.+)\]$/i,g9=/^\d+\/\d+$/,_9=new Set(["px","full","screen"]),y9=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,v9=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,x9=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,w9=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,b9=/^(url|
`);function rb(t){return t.label!==void 0}var s7=3,o7="32px",a7="16px",uO=4e3,l7=356,c7=14,u7=20,d7=200;function Xl(...t){return t.filter(Boolean).join(" ")}function h7(t){let[e,s]=t.split("-"),u=[];return e&&u.push(e),s&&u.push(s),u}var f7=t=>{var e,s,u,h,_,w,o,k,P,O,F;let{invert:V,toast:$,unstyled:Y,interacting:Z,setHeights:se,visibleToasts:te,heights:ee,index:oe,toasts:he,expanded:Ie,removeToast:Be,defaultRichColors:je,closeButton:Je,style:ft,cancelButtonStyle:kt,actionButtonStyle:tr,className:jt="",descriptionClassName:Qe="",duration:xt,position:It,gap:Ot,loadingIcon:Et,expandByDefault:st,classNames:Pt,icons:qt,closeButtonAriaLabel:_r="Close toast",pauseWhenPageIsHidden:yr}=t,[hr,Gr]=dr.useState(null),[mi,Oi]=dr.useState(null),[xn,zs]=dr.useState(!1),[un,Nn]=dr.useState(!1),[gi,Ks]=dr.useState(!1),[Un,io]=dr.useState(!1),[so,Ki]=dr.useState(!1),[Zi,Zn]=dr.useState(0),[Is,ua]=dr.useState(0),Ai=dr.useRef($.duration||xt||uO),us=dr.useRef(null),Fs=dr.useRef(null),rs=oe===0,Ho=oe+1<=te,ds=$.type,bs=$.dismissible!==!1,Wo=$.className||"",At=$.descriptionClassName||"",sr=dr.useMemo(()=>ee.findIndex(on=>on.toastId===$.id)||0,[ee,$.id]),Lr=dr.useMemo(()=>{var on;return(on=$.closeButton)!=null?on:Je},[$.closeButton,Je]),Zr=dr.useMemo(()=>$.duration||xt||uO,[$.duration,xt]),tn=dr.useRef(0),Wr=dr.useRef(0),On=dr.useRef(0),Zs=dr.useRef(null),[qo,yo]=It.split("-"),Do=dr.useMemo(()=>ee.reduce((on,Wn,qn)=>qn>=sr?on:on+Wn.height,0),[ee,sr]),oo=Y9(),vo=$.invert||V,Lo=ds==="loading";Wr.current=dr.useMemo(()=>sr*Ot+Do,[sr,Do]),dr.useEffect(()=>{Ai.current=Zr},[Zr]),dr.useEffect(()=>{zs(!0)},[]),dr.useEffect(()=>{let on=Fs.current;if(on){let Wn=on.getBoundingClientRect().height;return ua(Wn),se(qn=>[{toastId:$.id,height:Wn,position:$.position},...qn]),()=>se(qn=>qn.filter(Bs=>Bs.toastId!==$.id))}},[se,$.id]),dr.useLayoutEffect(()=>{if(!xn)return;let on=Fs.current,Wn=on.style.height;on.style.height="auto";let qn=on.getBoundingClientRect().height;on.style.height=Wn,ua(qn),se(Bs=>Bs.find(it=>it.toastId===$.id)?Bs.map(it=>it.toastId===$.id?{...it,height:qn}:it):[{toastId:$.id,height:qn,position:$.position},...Bs])},[xn,$.title,$.description,se,$.id]);let En=dr.useCallback(()=>{Nn(!0),Zn(Wr.current),se(on=>on.filter(Wn=>Wn.toastId!==$.id)),setTimeout(()=>{Be($)},d7)},[$,Be,se,Wr]);dr.useEffect(()=>{if($.promise&&ds==="loading"||$.duration===1/0||$.type==="loading")return;let on;return Ie||Z||yr&&oo?(()=>{if(On.current<tn.current){let Wn=new Date().getTime()-tn.current;Ai.current=Ai.current-Wn}On.current=new Date().getTime()})():Ai.current!==1/0&&(tn.current=new Date().getTime(),on=setTimeout(()=>{var Wn;(Wn=$.onAutoClose)==null||Wn.call($,$),En()},Ai.current)),()=>clearTimeout(on)},[Ie,Z,$,ds,yr,oo,En]),dr.useEffect(()=>{$.delete&&En()},[En,$.delete]);function zi(){var on,Wn,qn;return qt!=null&&qt.loading?dr.createElement("div",{className:Xl(Pt==null?void 0:Pt.loader,(on=$==null?void 0:$.classNames)==null?void 0:on.loader,"sonner-loader"),"data-visible":ds==="loading"},qt.loading):Et?dr.createElement("div",{className:Xl(Pt==null?void 0:Pt.loader,(Wn=$==null?void 0:$.classNames)==null?void 0:Wn.loader,"sonner-loader"),"data-visible":ds==="loading"},Et):dr.createElement(H9,{className:Xl(Pt==null?void 0:Pt.loader,(qn=$==null?void 0:$.classNames)==null?void 0:qn.loader),visible:ds==="loading"})}return dr.createElement("li",{tabIndex:0,ref:Fs,className:Xl(jt,Wo,Pt==null?void 0:Pt.toast,(e=$==null?void 0:$.classNames)==null?void 0:e.toast,Pt==null?void 0:Pt.default,Pt==null?void 0:Pt[ds],(s=$==null?void 0:$.classNames)==null?void 0:s[ds]),"data-sonner-toast":"","data-rich-colors":(u=$.richColors)!=null?u:je,"data-styled":!($.jsx||$.unstyled||Y),"data-mounted":xn,"data-promise":!!$.promise,"data-swiped":so,"data-removed":un,"data-visible":Ho,"data-y-position":qo,"data-x-position":yo,"data-index":oe,"data-front":rs,"data-swiping":gi,"data-dismissible":bs,"data-type":ds,"data-invert":vo,"data-swipe-out":Un,"data-swipe-direction":mi,"data-expanded":!!(Ie||st&&xn),style:{"--index":oe,"--toasts-before":oe,"--z-index":he.length-oe,"--offset":`${un?Zi:Wr.c
* @remix-run/router v1.23.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function c0(){return c0=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(t[u]=s[u])}return t},c0.apply(this,arguments)}var Wd;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(Wd||(Wd={}));const CO="popstate";function RZ(t){t===void 0&&(t={});function e(u,h){let{pathname:_,search:w,hash:o}=u.location;return Gk("",{pathname:_,search:w,hash:o},h.state&&h.state.usr||null,h.state&&h.state.key||"default")}function s(u,h){return typeof h=="string"?h:w1(h)}return LZ(e,s,null,t)}function Ls(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function XN(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function DZ(){return Math.random().toString(36).substr(2,8)}function IO(t,e){return{usr:t.state,key:t.key,idx:e}}function Gk(t,e,s,u){return s===void 0&&(s=null),c0({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?e_(e):e,{state:s,key:e&&e.key||u||DZ()})}function w1(t){let{pathname:e="/",search:s="",hash:u=""}=t;return s&&s!=="?"&&(e+=s.charAt(0)==="?"?s:"?"+s),u&&u!=="#"&&(e+=u.charAt(0)==="#"?u:"#"+u),e}function e_(t){let e={};if(t){let s=t.indexOf("#");s>=0&&(e.hash=t.substr(s),t=t.substr(0,s));let u=t.indexOf("?");u>=0&&(e.search=t.substr(u),t=t.substr(0,u)),t&&(e.pathname=t)}return e}function LZ(t,e,s,u){u===void 0&&(u={});let{window:h=document.defaultView,v5Compat:_=!1}=u,w=h.history,o=Wd.Pop,k=null,P=O();P==null&&(P=0,w.replaceState(c0({},w.state,{idx:P}),""));function O(){return(w.state||{idx:null}).idx}function F(){o=Wd.Pop;let se=O(),te=se==null?null:se-P;P=se,k&&k({action:o,location:Z.location,delta:te})}function V(se,te){o=Wd.Push;let ee=Gk(Z.location,se,te);P=O()+1;let oe=IO(ee,P),he=Z.createHref(ee);try{w.pushState(oe,"",he)}catch(Ie){if(Ie instanceof DOMException&&Ie.name==="DataCloneError")throw Ie;h.location.assign(he)}_&&k&&k({action:o,location:Z.location,delta:1})}function $(se,te){o=Wd.Replace;let ee=Gk(Z.location,se,te);P=O();let oe=IO(ee,P),he=Z.createHref(ee);w.replaceState(oe,"",he),_&&k&&k({action:o,location:Z.location,delta:0})}function Y(se){let te=h.location.origin!=="null"?h.location.origin:h.location.href,ee=typeof se=="string"?se:w1(se);return ee=ee.replace(/ $/,"%20"),Ls(te,"No window.location.(origin|href) available to create URL for href: "+ee),new URL(ee,te)}let Z={get action(){return o},get location(){return t(h,w)},listen(se){if(k)throw new Error("A history only accepts one active listener");return h.addEventListener(CO,F),k=se,()=>{h.removeEventListener(CO,F),k=null}},createHref(se){return e(h,se)},createURL:Y,encodeLocation(se){let te=Y(se);return{pathname:te.pathname,search:te.search,hash:te.hash}},push:V,replace:$,go(se){return w.go(se)}};return Z}var PO;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(PO||(PO={}));function OZ(t,e,s){return s===void 0&&(s="/"),zZ(t,e,s)}function zZ(t,e,s,u){let h=typeof e=="string"?e_(e):e,_=YC(h.pathname||"/",s);if(_==null)return null;let w=YN(t);FZ(w);let o=null;for(let k=0;o==null&&k<w.length;++k){let P=ZZ(_);o=WZ(w[k],P)}return o}function YN(t,e,s,u){e===void 0&&(e=[]),s===void 0&&(s=[]),u===void 0&&(u="");let h=(_,w,o)=>{let k={relativePath:o===void 0?_.path||"":o,caseSensitive:_.caseSensitive===!0,childrenIndex:w,route:_};k.relativePath.startsWith("/")&&(Ls(k.relativePath.startsWith(u),'Absolute route path "'+k.relativePath+'" nested under path '+('"'+u+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),k.relativePath=k.relativePath.slice(u.length));let P=rh([u,k.relativePath]),O=s.concat(k);_.children&&_.children.length>0&&(Ls(_.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+P+'".')),YN(_.children,e,O,P)),!(_.path==null&&!_.index)&&e.push({path:P,score:GZ(P,_.index),routesMeta:O})};return t.forEach((_,w)=>{var o;if(_.path===""||!((o=_.path)!=null&&o.includes("?")))h(_,w);else for(let k of JN(_.path))h(
* React Router v6.30.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function u0(){return u0=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(t[u]=s[u])}return t},u0.apply(this,arguments)}const eI=X.createContext(null),iX=X.createContext(null),hh=X.createContext(null),cS=X.createContext(null),Gu=X.createContext({outlet:null,matches:[],isDataRoute:!1}),e4=X.createContext(null);function sX(t,e){let{relative:s}=e===void 0?{}:e;t_()||Ls(!1);let{basename:u,navigator:h}=X.useContext(hh),{hash:_,pathname:w,search:o}=r4(t,{relative:s}),k=w;return u!=="/"&&(k=w==="/"?u:rh([u,w])),h.createHref({pathname:k,search:o,hash:_})}function t_(){return X.useContext(cS)!=null}function Wf(){return t_()||Ls(!1),X.useContext(cS).location}function t4(t){X.useContext(hh).static||X.useLayoutEffect(t)}function r_(){let{isDataRoute:t}=X.useContext(Gu);return t?yX():oX()}function oX(){t_()||Ls(!1);let t=X.useContext(eI),{basename:e,future:s,navigator:u}=X.useContext(hh),{matches:h}=X.useContext(Gu),{pathname:_}=Wf(),w=JSON.stringify(JC(h,s.v7_relativeSplatPath)),o=X.useRef(!1);return t4(()=>{o.current=!0}),X.useCallback(function(P,O){if(O===void 0&&(O={}),!o.current)return;if(typeof P=="number"){u.go(P);return}let F=QC(P,JSON.parse(w),_,O.relative==="path");t==null&&e!=="/"&&(F.pathname=F.pathname==="/"?e:rh([e,F.pathname])),(O.replace?u.replace:u.push)(F,O.state,O)},[e,u,w,_,t])}function Nue(){let{matches:t}=X.useContext(Gu),e=t[t.length-1];return e?e.params:{}}function r4(t,e){let{relative:s}=e===void 0?{}:e,{future:u}=X.useContext(hh),{matches:h}=X.useContext(Gu),{pathname:_}=Wf(),w=JSON.stringify(JC(h,u.v7_relativeSplatPath));return X.useMemo(()=>QC(t,JSON.parse(w),_,s==="path"),[t,w,_,s])}function aX(t,e){return lX(t,e)}function lX(t,e,s,u){t_()||Ls(!1);let{navigator:h}=X.useContext(hh),{matches:_}=X.useContext(Gu),w=_[_.length-1],o=w?w.params:{};w&&w.pathname;let k=w?w.pathnameBase:"/";w&&w.route;let P=Wf(),O;if(e){var F;let se=typeof e=="string"?e_(e):e;k==="/"||(F=se.pathname)!=null&&F.startsWith(k)||Ls(!1),O=se}else O=P;let V=O.pathname||"/",$=V;if(k!=="/"){let se=k.replace(/^\//,"").split("/");$="/"+V.replace(/^\//,"").split("/").slice(se.length).join("/")}let Y=OZ(t,{pathname:$}),Z=fX(Y&&Y.map(se=>Object.assign({},se,{params:Object.assign({},o,se.params),pathname:rh([k,h.encodeLocation?h.encodeLocation(se.pathname).pathname:se.pathname]),pathnameBase:se.pathnameBase==="/"?k:rh([k,h.encodeLocation?h.encodeLocation(se.pathnameBase).pathname:se.pathnameBase])})),_,s,u);return e&&Z?X.createElement(cS.Provider,{value:{location:u0({pathname:"/",search:"",hash:"",state:null,key:"default"},O),navigationType:Wd.Pop}},Z):Z}function cX(){let t=_X(),e=rX(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,h={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return X.createElement(X.Fragment,null,X.createElement("h2",null,"Unexpected Application Error!"),X.createElement("h3",{style:{fontStyle:"italic"}},e),s?X.createElement("pre",{style:h},s):null,null)}const uX=X.createElement(cX,null);class dX extends X.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,s){return s.location!==e.location||s.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:s.error,location:s.location,revalidation:e.revalidation||s.revalidation}}componentDidCatch(e,s){console.error("React Router caught the following error during render",e,s)}render(){return this.state.error!==void 0?X.createElement(Gu.Provider,{value:this.props.routeContext},X.createElement(e4.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function hX(t){let{routeContext:e,match:s,children:u}=t,h=X.useContext(eI);return h&&h.static&&h.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(h.staticContext._deepestRenderedBoundar
* React Router DOM v6.30.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function Wk(){return Wk=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(t[u]=s[u])}return t},Wk.apply(this,arguments)}function SX(t,e){if(t==null)return{};var s={},u=Object.keys(t),h,_;for(_=0;_<u.length;_++)h=u[_],!(e.indexOf(h)>=0)&&(s[h]=t[h]);return s}function TX(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function EX(t,e){return t.button===0&&(!e||e==="_self")&&!TX(t)}function qk(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,s)=>{let u=t[s];return e.concat(Array.isArray(u)?u.map(h=>[s,h]):[[s,u]])},[]))}function kX(t,e){let s=qk(t);return e&&e.forEach((u,h)=>{s.has(h)||e.getAll(h).forEach(_=>{s.append(h,_)})}),s}const AX=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],CX="6";try{window.__reactRouterVersion=CX}catch{}const IX="startTransition",DO=UA[IX];function PX(t){let{basename:e,children:s,future:u,window:h}=t,_=X.useRef();_.current==null&&(_.current=RZ({window:h,v5Compat:!0}));let w=_.current,[o,k]=X.useState({action:w.action,location:w.location}),{v7_startTransition:P}=u||{},O=X.useCallback(F=>{P&&DO?DO(()=>k(F)):k(F)},[k,P]);return X.useLayoutEffect(()=>w.listen(O),[w,O]),X.useEffect(()=>xX(u),[u]),X.createElement(wX,{basename:e,children:s,location:o.location,navigationType:o.action,navigator:w,future:u})}const MX=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",RX=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Vue=X.forwardRef(function(e,s){let{onClick:u,relative:h,reloadDocument:_,replace:w,state:o,target:k,to:P,preventScrollReset:O,viewTransition:F}=e,V=SX(e,AX),{basename:$}=X.useContext(hh),Y,Z=!1;if(typeof P=="string"&&RX.test(P)&&(Y=P,MX))try{let oe=new URL(window.location.href),he=P.startsWith("//")?new URL(oe.protocol+P):new URL(P),Ie=YC(he.pathname,$);he.origin===oe.origin&&Ie!=null?P=Ie+he.search+he.hash:Z=!0}catch{}let se=sX(P,{relative:h}),te=DX(P,{replace:w,state:o,target:k,preventScrollReset:O,relative:h,viewTransition:F});function ee(oe){u&&u(oe),oe.defaultPrevented||te(oe)}return X.createElement("a",Wk({},V,{href:Y||se,onClick:Z||_?u:ee,ref:s,target:k}))});var LO;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(LO||(LO={}));var OO;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(OO||(OO={}));function DX(t,e){let{target:s,replace:u,state:h,preventScrollReset:_,relative:w,viewTransition:o}=e===void 0?{}:e,k=r_(),P=Wf(),O=r4(t,{relative:w});return X.useCallback(F=>{if(EX(F,s)){F.preventDefault();let V=u!==void 0?u:w1(P)===w1(O);k(t,{replace:V,state:h,preventScrollReset:_,relative:w,viewTransition:o})}},[P,k,O,u,h,s,t,_,w,o])}function LX(t){let e=X.useRef(qk(t)),s=X.useRef(!1),u=Wf(),h=X.useMemo(()=>kX(u.search,s.current?null:e.current),[u.search]),_=r_(),w=X.useCallback((o,k)=>{const P=qk(typeof o=="function"?o(h):o);s.current=!0,_("?"+P,k)},[_,h]);return[h,w]}const sb="https://api.quixzoom.com/api/qz",Id="qz_token",Sa={signUp:async(t,e,s)=>{try{const h=await(await fetch(`${sb}/auth/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,password:e,name:s,role:"zoomer"})})).json();return h.token&&localStorage.setItem(Id,h.token),h}catch{return{error:"Network error",code:"NETWORK_ERROR"}}},signIn:async(t,e)=>{try{const u=await(await fetch(`${sb}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,password:e})})).json();return u.token&&localStorage.setItem(Id,u.token),u}catch{return{error:"Network error",code:"NETWORK_ERROR"}}},signOut:async()=>{const t=localStorage.getItem(Id);if(t){try{await fetch(`${sb}/auth/logout`,{method:"POST",headers:{Authorization:`Bearer ${t}`}})}catch{}localStorage.
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var $g=X;function EY(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var kY=typeof Object.is=="function"?Object.is:EY,AY=$g.useState,CY=$g.useEffect,IY=$g.useLayoutEffect,PY=$g.useDebugValue;function MY(t,e){var s=e(),u=AY({inst:{value:s,getSnapshot:e}}),h=u[0].inst,_=u[1];return IY(function(){h.value=s,h.getSnapshot=e,rE(h)&&_({inst:h})},[t,s,e]),CY(function(){return rE(h)&&_({inst:h}),t(function(){rE(h)&&_({inst:h})})},[t]),PY(s),s}function rE(t){var e=t.getSnapshot;t=t.value;try{var s=e();return!kY(t,s)}catch{return!0}}function RY(t,e){return e()}var DY=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?RY:MY;g4.useSyncExternalStore=$g.useSyncExternalStore!==void 0?$g.useSyncExternalStore:DY;m4.exports=g4;var LY=m4.exports;const OY=(t,e)=>Uf(e)?e:fY(e)&&Uf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,zY={t:OY,ready:!1},FY=()=>()=>{},Kf=(t,e={})=>{var ft,kt,tr;const{i18n:s}=e,{i18n:u,defaultNS:h}=X.useContext(SY)||{},_=s||u||wY();_&&!_.reportNamespaces&&(_.reportNamespaces=new TY),_||h4(_,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const w=X.useMemo(()=>{var jt;return{...vY(),...(jt=_==null?void 0:_.options)==null?void 0:jt.react,...e}},[_,e]),{useSuspense:o,keyPrefix:k}=w,P=h||((ft=_==null?void 0:_.options)==null?void 0:ft.defaultNS),O=Uf(P)?[P]:P||["translation"],F=X.useMemo(()=>O,O);(tr=(kt=_==null?void 0:_.reportNamespaces)==null?void 0:kt.addUsedNamespaces)==null||tr.call(kt,F);const V=X.useRef(0),$=X.useCallback(jt=>{if(!_)return FY;const{bindI18n:Qe,bindI18nStore:xt}=w,It=()=>{V.current+=1,jt()};return Qe&&_.on(Qe,It),xt&&_.store.on(xt,It),()=>{Qe&&Qe.split(" ").forEach(Ot=>_.off(Ot,It)),xt&&xt.split(" ").forEach(Ot=>_.store.off(Ot,It))}},[_,w]),Y=X.useRef(),Z=X.useCallback(()=>{if(!_)return zY;const jt=!!(_.isInitialized||_.initializedStoreOnce)&&F.every(st=>hY(st,_,w)),Qe=e.lng||_.language,xt=V.current,It=Y.current;if(It&&It.ready===jt&&It.lng===Qe&&It.keyPrefix===k&&It.revision===xt)return It;const Et={t:_.getFixedT(Qe,w.nsMode==="fallback"?F:F[0],k),ready:jt,lng:Qe,keyPrefix:k,revision:xt};return Y.current=Et,Et},[_,F,k,w,e.lng]),[se,te]=X.useState(0),{t:ee,ready:oe}=LY.useSyncExternalStore($,Z,Z);X.useEffect(()=>{if(_&&!oe&&!o){const jt=()=>te(Qe=>Qe+1);e.lng?YO(_,e.lng,F,jt):Xk(_,F,jt)}},[_,e.lng,F,oe,o,se]);const he=_||{},Ie=X.useRef(null),Be=X.useRef(),je=jt=>{const Qe=Object.getOwnPropertyDescriptors(jt);Qe.__original&&delete Qe.__original;const xt=Object.create(Object.getPrototypeOf(jt),Qe);if(!Object.prototype.hasOwnProperty.call(xt,"__original"))try{Object.defineProperty(xt,"__original",{value:jt,writable:!1,enumerable:!1,configurable:!1})}catch{}return xt},Je=X.useMemo(()=>{const jt=he,Qe=jt==null?void 0:jt.language;let xt=jt;jt&&(Ie.current&&Ie.current.__original===jt?Be.current!==Qe?(xt=je(jt),Ie.current=xt,Be.current=Qe):xt=Ie.current:(xt=je(jt),Ie.current=xt,Be.current=Qe));const It=[ee,xt,oe];return It.t=ee,It.i18n=xt,It.ready=oe,It},[ee,he,oe,he.resolvedLanguage,he.language,he.languages]);if(_&&o&&!oe)throw new Promise(jt=>{const Qe=()=>jt();e.lng?YO(_,e.lng,F,Qe):Xk(_,F,Qe)});return Je};var _4={exports:{}};(function(t,e){(function(s,u){t.exports=u()})(cG,function(){var s,u,h;function _(o,k){if(!s)s=k;else if(!u)u=k;else{var P="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+s+")(sharedChunk); ("+u+")(sharedChunk); self.onerror = null;",O={};s(O),h=k(O),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(h.workerUrl=window.URL.createObjectURL(new Blob([P],{type:"text/javascript"})))}}_(["exports"],function(o){var k=1e-6,P=typeof Float32Array<"u"?Float32Array:Array;function O(a,r){var i=r[0],c=r[1],d=r[2],m=r[3],g=i*m-d*c;return g?(a[0]=m*(g=1/g),a[1]=-c*g,a[2]=-d*g,a[3]=i*g,a):null}function F(){var a=new P(9);return P!=Float32Array&&(a[
This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
and paste the contents of this message in the report.
Thank you!
Filter Expression:
${JSON.stringify(d,null,2)}
`)}let g=null,v=null;if(c!=="background"&&c!=="sky"&&c!=="slot"){v=ze[`filter_${c}`];const C=kc(m,v,r,i);if(C.result==="error")throw new Error(C.value.map(I=>`${I.key}: ${I.message}`).join(", "));g=(I,R,L)=>C.value.evaluate(I,R,{},L)}let S=null,E=null;if(m!==d){const C=kc(d,v,r,i);if(C.result==="error")throw new Error(C.value.map(I=>`${I.key}: ${I.message}`).join(", "));S=(I,R,L,z,U)=>C.value.evaluate(I,R,{},L,void 0,void 0,z,U),E=!Qu(C.value.expression)}return{filter:g,dynamicFilter:S||void 0,needGeometry:Ix(m),needFeature:!!E}}function mu(a){if(!Array.isArray(a))return a;const r=function(i){if(NS.has(i[0])){for(let c=1;c<i.length;c++)if(cd(i[c]))return!0}return i}(a);return r===!0?r:r.map(i=>mu(i))}function Cx(a){let r=!1;const i=[];if(a[0]==="case"){for(let c=1;c<a.length-1;c+=2)r=r||cd(a[c]),i.push(a[c+1]);i.push(a[a.length-1])}else if(a[0]==="match"){r=r||cd(a[1]);for(let c=2;c<a.length-1;c+=2)i.push(a[c+1]);i.push(a[a.length-1])}else if(a[0]==="step"){r=r||cd(a[1]);for(let c=1;c<a.length-1;c+=2)i.push(a[c+1])}r&&(a.length=0,a.push("any",...i));for(let c=1;c<a.length;c++)Cx(a[c])}function cd(a){if(!Array.isArray(a))return!1;if((r=a[0])==="pitch"||r==="distance-from-center")return!0;var r;for(let i=1;i<a.length;i++)if(cd(a[i]))return!0;return!1}const NS=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function jS(a,r){return a<r?-1:a>r?1:0}function Ix(a){if(!Array.isArray(a))return!1;if(a[0]==="within"||a[0]==="distance")return!0;for(let r=1;r<a.length;r++)if(Ix(a[r]))return!0;return!1}function Gp(a){if(!a)return!0;const r=a[0];return a.length<=1?r!=="any":r==="=="?Hp(a[1],a[2],"=="):r==="!="?Uh(Hp(a[1],a[2],"==")):r==="<"||r===">"||r==="<="||r===">="?Hp(a[1],a[2],r):r==="any"?(i=a.slice(1),["any"].concat(i.map(Gp))):r==="all"?["all"].concat(a.slice(1).map(Gp)):r==="none"?["all"].concat(a.slice(1).map(Gp).map(Uh)):r==="in"?Wp(a[1],a.slice(2)):r==="!in"?Uh(Wp(a[1],a.slice(2))):r==="has"?qp(a[1]):r!=="!has"||Uh(qp(a[1]));var i}function Hp(a,r,i){switch(a){case"$type":return[`filter-type-${i}`,r];case"$id":return[`filter-id-${i}`,r];default:return[`filter-${i}`,a,r]}}function Wp(a,r){if(r.length===0)return!1;switch(a){case"$type":return["filter-type-in",["literal",r]];case"$id":return["filter-id-in",["literal",r]];default:return r.length>200&&!r.some(i=>typeof i!=typeof r[0])?["filter-in-large",a,["literal",r.sort(jS)]]:["filter-in-small",a,["literal",r]]}}function qp(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function Uh(a){return["!",a]}const gu="";function za(a,r){return r?`${a}${gu}${r}`:a}let Px;const Mx=()=>Px||(Px=new hi({"icon-size":new Ct(ze.layout_symbol["icon-size"]),"icon-image":new Ct(ze.layout_symbol["icon-image"]),"icon-rotate":new Ct(ze.layout_symbol["icon-rotate"]),"icon-offset":new Ct(ze.layout_symbol["icon-offset"]),"text-size":new Ct(ze.layout_symbol["text-size"]),"text-rotate":new Ct(ze.layout_symbol["text-rotate"]),"text-offset":new Ct(ze.layout_symbol["text-offset"])}));class Rx{constructor(r,i,c,d,m,g){const v=kc(r,ze.appearance.condition);if(v.result==="success"&&(this.condition=v.value),this.name=i,c){this.properties=new fu(Mx()),this.unevaluatedLayout=new kx(Mx(),d,m,g);for(const S in c)this.unevaluatedLayout.setValue(S,c[S])}}isActive(r){return!(this.condition||!r.isHidden||this.name!=="hidden")||this.condition.evaluate(r.globals,r.feature,r.featureState,r.canonical)}getCondition(){return this.condition}getName(){return this.name}getProperty(r){return this.properties.get(r)}getUnevaluatedProperties(){return this.unevaluatedLayout}getUnevaluatedProperty(r){return this.unevaluatedLayout._values[r]}recalculate(r,i,c){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(r,void 0,i,c))}serialize(){const r={};return r.condition=this.condition.expression.serialize(),this.name&&(r.name=this.name),this.unevaluatedLayout&&(r.properties=this.unevaluatedLayout.serialize()),r}hasIconProperties(){const r=this.hasProperty("icon-image"),i=this.hasProperty("icon-size"),c=this.hasProperty("icon-offset"),d=thi
* martinez v0.7.4
* Martinez polygon clipping algorithm, does boolean operation on polygons (multipolygons, polygons with holes etc): intersection, union, difference, xor
*
* @author Alex Milevski <info@w8r.name>
* @license MIT
* @preserve
*/function Kx(a,r,i,c){const d=[],m=c===0?(g,v,S,E,C,I)=>{g.push(new it(I,S+(I-v)/(E-v)*(C-S)))}:(g,v,S,E,C,I)=>{g.push(new it(v+(I-S)/(C-S)*(E-v),I))};for(const g of a){const v=[];for(const S of g){if(S.length<=2)continue;const E=[];for(let R=0;R<S.length-1;R++){const L=S[R].x,z=S[R].y,U=S[R+1].x,q=S[R+1].y,W=c===0?L:z,re=c===0?U:q;W<r?re>r&&m(E,L,z,U,q,r):W>i?re<i&&m(E,L,z,U,q,i):E.push(S[R]),re<r&&W>=r&&m(E,L,z,U,q,r),re>i&&W<=i&&m(E,L,z,U,q,i)}let C=S[S.length-1];const I=c===0?C.x:C.y;I>=r&&I<=i&&E.push(C),E.length&&(C=E[E.length-1],E[0].x===C.x&&E[0].y===C.y||E.push(E[0]),v.push(E))}v.length&&d.push(v)}return d}function HU(a,r){const i=lT(a),c=lT([r]),d=mP.intersection(i,c);return d==null?[]:gP(d)}function WU(a,r){let c=lT(a,65536);const d=[];for(;r.valid();r.next()){const[m,g]=r.get(),v=m.x*65536,S=m.y*65536,E=g.x*65536,C=g.y*65536,I=E-v,R=C-S,L=Math.hypot(I,R);if(L===0)continue;const z=Math.trunc(R/L*3),U=-Math.trunc(I/L*3);d.push([[[v,S],[E,C],[E+z,C+U],[v+z,S+U],[v,S]]])}return d.length>0&&(c=mP.diff(c,d)),gP(c,1/65536)}function lT(a,r=1){return[a.map(i=>i.map(c=>[c.x*r,c.y*r]))]}function gP(a,r=1){return a.map(i=>i.map((c,d)=>{const m=c.map(g=>new it(g[0]*r,g[1]*r).round());return d>0&&m.reverse(),m}))}class cT{constructor(r,i){this.layoutVertexArray=new Cc,this.indexArray=new Ni,this.lineIndexArray=new Jo,this.triangleSegments=new ri,this.lineSegments=new ri,this.programConfigurations=new Fa(r.layers,{zoom:r.zoom,lut:r.lut}),this.uploaded=!1,i&&(this.elevatedLayoutVertexArray=new Ll)}update(r,i,c,d,m,g,v,S){this.programConfigurations.updatePaintArrays(r,i,m,c,d,g,v,S)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(r){this.uploaded||(this.layoutVertexBuffer=r.createVertexBuffer(this.layoutVertexArray,PU.members),this.indexBuffer=r.createIndexBuffer(this.indexArray),this.lineIndexBuffer=r.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=r.createVertexBuffer(this.elevatedLayoutVertexArray,MU.members))),this.programConfigurations.upload(r),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(r,i,c,d,m,g,v){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,r,i,c,d,m,g,void 0,v)}}class uT{constructor(r){this.zoom=r.zoom,this.pixelRatio=r.pixelRatio,this.overscaling=r.overscaling,this.layers=r.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=r.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=r.lut,this.bufferData=new cT(r,!1),this.elevationBufferData=new cT(r,!0),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=r.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=r.sourceLayerIndex,this.worldview=r.worldview,this.hasAppearances=null}updateFootprints(r,i){}updateAppearances(r,i,c,d){}populate(r,i,c,d){this.hasPattern=oT("fill",this.layers,this.pixelRatio,i);const m=this.layers[0].layout.get("fill-sort-key"),g=[];for(const{feature:v,id:S,index:E,sourceLayerIndex:C}of r){const I=this.layers[0]._featureFilter.needGeometry,R=De(v,I);if(!this.layers[0]._featureFilter.filter(new $n(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),R,c))continue;const L=m?m.evaluate(R,{},c,i.availableImages):void 0,z={id:S,properties:v.properties,type:v.type,sourceLayerIndex:C,index:E,geometry:I?R.geometry:Te(v,c,d),patterns:{},sortKey:L};g.push(z)}m&&g.sort((v,S)=>v.sortKey-S.sortKey);for(const v of g){const{geometry:S,index:E,sourceLayerIndex:C}=v;if(this.hasPattern){const I=aT("fill",this.layers,v,this.zoom,this.pixelRatio,i);this.patternFeatures.push(I)}else this.addFeature(v,S,E,c,{},i.availableImages,i.brightness,i.elevation
Use an identity property function instead: ${H}.`)]}const j=[];if(f.layerType==="symbol")T!=="text-field"||!p||p.glyphs||p.imports||j.push(new o.V(l,b,'use of "text-field" requires a style "glyphs" property')),T==="text-font"&&o.a4(o.S(b))&&o.J(b.type)==="identity"&&j.push(new o.V(l,b,'"text-font" does not support identity functions'));else if(f.layerType==="model"&&n==="paint"&&y&&y.layout&&y.layout.hasOwnProperty("model-id")&&o.N(N)&&(o.a5(N)||o.O(N))){const H=o.W(o.S(b),N).value,G="expression"in H&&H.expression||"_styleExpression"in H&&H._styleExpression&&H._styleExpression.expression;G&&!o.X(G,["measure-light"])&&(T==="model-emissive-strength"&&o.Y(G)&&o.Z(G)||j.push(new o.V(l,b,`${T} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return j.concat(En({key:f.key,value:b,valueSpec:N,style:p,styleSpec:x,expressionContext:"property",propertyType:n,propertyKey:T}))}function Lr(f){return sr(f,"paint")}function Zr(f){return sr(f,"layout")}function tn(f){let n=[];const l=f.value,p=f.key,y=f.style,x=f.styleSpec;if(!o.H(l))return[new o.V(p,l,"object expected")];l.type||l.ref||n.push(new o.V(p,l,'either "type" or "ref" is required'));let b=o.J(l.type);const T=o.J(l.ref);if(l.id){const A=o.J(l.id);for(let M=0;M<f.arrayIndex;M++){const D=y.layers[M];o.J(D.id)===A&&n.push(new o.V(p,l.id,`duplicate layer id "${A}", previously used at line ${D.id.__line__}`))}}if("ref"in l){let A;["type","source","source-layer","filter","layout"].forEach(M=>{M in l&&n.push(new o.V(p,l[M],`"${M}" is prohibited for ref layers`))}),y.layers.forEach(M=>{o.J(M.id)===T&&(A=M)}),A?A.ref?n.push(new o.V(p,l.ref,"ref cannot reference another ref layer")):b=o.J(A.type):typeof T=="string"&&n.push(new o.V(p,l.ref,`ref layer "${T}" not found`))}else if(b!=="background"&&b!=="sky"&&b!=="slot")if(l.source)if(o.a0(l.source)){const A=y.sources&&y.sources[l.source],M=A&&o.J(A.type);A?M==="vector"&&b==="raster"?n.push(new o.V(p,l.source,`layer "${l.id}" requires a raster source`)):M==="raster"&&b!=="raster"?n.push(new o.V(p,l.source,`layer "${l.id}" requires a vector source`)):M!=="vector"||l["source-layer"]?M==="raster-dem"&&b!=="hillshade"?n.push(new o.V(p,l.source,"raster-dem source can only be used with layer type 'hillshade'.")):M!=="raster-array"||["raster","raster-particle"].includes(b)?b==="line"&&l.paint&&(l.paint["line-gradient"]||l.paint["line-trim-offset"])&&M==="geojson"&&!A.lineMetrics?n.push(new o.V(p,l,`layer "${l.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):b==="raster-particle"&&M!=="raster-array"&&n.push(new o.V(p,l.source,`layer "${l.id}" requires a 'raster-array' source.`)):n.push(new o.V(p,l.source,"raster-array source can only be used with layer type 'raster'.")):n.push(new o.V(p,l,`layer "${l.id}" must specify a "source-layer"`)):n.push(new o.V(p,l.source,`source "${l.source}" not found`))}else n.push(new o.V(`${p}.source`,l.source,'"source" must be a string'));else n.push(new o.V(p,l,'missing required property "source"'));return n=n.concat(zi({key:p,value:l,valueSpec:x.layer,style:f.style,styleSpec:f.styleSpec,objectElementValidators:{"*":()=>[],type:()=>En({key:`${p}.type`,value:l.type,valueSpec:x.layer.type,style:f.style,styleSpec:f.styleSpec,object:l,objectKey:"type"}),filter:A=>Wo(Object.assign({layerType:b},A)),layout:A=>zi({layer:l,key:A.key,value:A.value,valueSpec:{},style:A.style,styleSpec:A.styleSpec,objectElementValidators:{"*":M=>Zr(Object.assign({layerType:b},M))}}),paint:A=>zi({layer:l,key:A.key,value:A.value,valueSpec:{},style:A.style,styleSpec:A.styleSpec,objectElementValidators:{"*":M=>Lr(Object.assign({layerType:b,layer:l},M))}}),appearances(A){const M=Ai({key:A.key,value:A.value,valueSpec:A.valueSpec,style:A.style,styleSpec:A.styleSpec,arrayElementValidator:B=>function(j){const{key:H,layer:G,layerType:Q}=j,J=o.J(j.value),ae=o.J(J.name),de=o.J(J.condition),ce=zi({key:H,value:J,valueSpec:j.styleSpec.appearance,style:j.style,styleSpec:j.styleSpec,objectElementValidators:{condition:Se=>function(ye){const we=[];return we.
#define EPSILON 0.0000001
#define PI 3.141592653589793
#ifdef RENDER_CUTOFF
float cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}
#endif`,Ju=`
#ifdef DUAL_SOURCE_BLENDING
layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;
#else
layout(location=0) out vec4 glFragColor;
#endif
#ifdef USE_MRT1
layout(location=1) out vec4 out_Target1;
#endif
highp float unpack_depth(highp vec4 rgba_depth)
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}
#ifdef INDICATOR_CUTOUT
uniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;
#endif
vec4 applyCutout(vec4 color,float height) {
#ifdef INDICATOR_CUTOUT
float verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);
#else
return color;
#endif
}
#ifdef DEBUG_WIREFRAME
#define HANDLE_WIREFRAME_DEBUG \\
glFragColor=vec4(0.7,0.0,0.0,0.7); \\
gl_FragDepth=gl_FragCoord.z-0.0001;
#else
#define HANDLE_WIREFRAME_DEBUG
#endif
#ifdef RENDER_CUTOFF
uniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;
#endif
vec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}`,v_=`
#define EXTENT 8192.0
#define RAD_TO_DEG 180.0/PI
#define DEG_TO_RAD PI/180.0
#define GLOBE_RADIUS EXTENT/PI/2.0
float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}
#ifdef PROJECTION_GLOBE_VIEW
vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
#ifndef PROJECTED_POS_ON_VIEWPORT
float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
#else
return vec3(0.0);
#endif
}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
#endif
vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}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 vec2 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 (units_to_pixels*pos+offset)/pattern_size;}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) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}
#ifdef RENDER_CUTOFF
uniform vec4 u_cutoff_params;out float v_cutoff_opacity;
#endif
const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)
{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}
#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer
#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib
#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib
#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib
#define DECLARE_MATERIAL_TABLE_INFO
#endif`,fp="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",Zo=`
#define ELEVATION_SCALE 7.0
#define ELEVATION_OFFSET 450.0
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}
#else
vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
#endif
#ifdef TERRAIN
uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;
#else
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
#endif
}float prevElevation(vec2 apos) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;
#else
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
#endif
}
#ifdef TERRAIN_VERTEX_MORPHING
float elevation(vec2 apos) {
#ifdef ZERO_EXAGGERATION
return 0.0;
#endif
float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
#else
float elevation(vec2 apos) {
#ifdef ZERO_EXAGGERATION
return 0.0;
#endif
return currentElevation(apos);}
#endif
vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}
#else
float elevation(vec2 pos) { return 0.0; }
#endif
#ifdef DEPTH_OCCLUSION
uniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;
#ifdef DEPTH_D24
float unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}
#else
highp float unpack_depth_rgba(vec4 rgba_depth)
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}
#endif
bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;
#ifdef CLIP_ZERO_TO_ONE
coord.z=-1.0+2.0*coord.z;
#endif
#ifdef DEPTH_D24
float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);
#else
float depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));
#endif
return coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;
#ifdef DEPTH_D24
highp vec4 depth=vec4(
texture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r
);depth=unpack_depth4(depth);
#else
highp vec4 depth=vec4(
unpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))
);
#endif
return depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;
#ifdef CLIP_ZERO_TO_ONE
coord.z=-1.0+2.0*coord.z;
#endif
int NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {
#ifdef DEPTH_D24
highp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);
#else
highp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));
#endif
res+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;
#ifdef CLIP_ZERO_TO_ONE
coord.z=-1.0+2.0*coord.z;
#endif
highp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}
#else
bool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }
#endif`,pp=`#ifdef FOG
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}
#endif`,bt=`#ifdef FOG
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;
#ifdef FLIP_Y
uv.y=1.0-uv.y;
#endif
highp vec3 ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
#endif`,x_=`#ifdef RASTER_ARRAY
uniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)
);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)
);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}
#endif`,mp=`#ifdef RASTER_ARRAY
uniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}
#endif
uniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}`,gp=`#ifdef RENDER_SHADOWS
uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}
#endif`,w_=`#ifdef RENDER_SHADOWS
precision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {
#ifdef CLIP_ZERO_TO_ONE
highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);
#else
highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias);
#endif
return texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;
#ifdef SHADOWS_SINGLE_CASCADE
vec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);
#else
light_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);
#endif
}highp float calculate_shadow_bias(float NDotL) {
#ifdef NORMAL_OFFSET
return 0.5*u_shadow_bias.x;
#else
return 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));
#endif
}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)
{highp vec2 biasUV=vec2(
pos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}
#endif`;const Ih=/#include\s+"([^"]+)"/g,ol=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,b_=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,ou=new Set(["ifdef","ifndef","elif","if","defined"]),au=new Set;Sc(Yu,au),Sc(v_,au),Sc(Ju,au);const bc={"_prelude_fog.vertex.glsl":pp,"_prelude_terrain.vertex.glsl":Zo,"_prelude_shadow.vertex.glsl":gp,"_prelude_material_table.vertex.glsl":`#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer
#define MATERIAL_TABLE_DEBUG 0
uniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;
#if MATERIAL_TABLE_DEBUG
vec4 colorDebug;
#endif
};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) {
if (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u;
}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else {
iRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;
#if MATERIAL_TABLE_DEBUG
const vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;
#endif
uint offset=0u;
#if MATERIAL_TABLE_DEBUG
bool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}
#endif
offset++;
#if MATERIAL_TABLE_DEBUG
uint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}
#endif
offset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);
#if MATERIAL_TABLE_DEBUG
if(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}
#endif
uint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);
#if MATERIAL_TABLE_DEBUG
if(keepFinding)
{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}
#endif
offset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;
#if MATERIAL_TABLE_DEBUG
if(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}
#endif
info.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)
{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}
#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)
#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)
#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)
#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));
#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;
#endif`,"_prelude_fog.fragment.glsl":bt,"_prelude_shadow.fragment.glsl":w_,"_prelude_lighting.glsl":`
#ifdef LIGHTING_3D_MODE
uniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}
#endif`,"_prelude_raster_array.glsl":x_,"_prelude_raster_particle.glsl":mp},_p={};Jr("",Zo),Jr(bt,pp),Jr(w_,gp),Jr(x_,""),Jr(mp,"");const Y0=Jr(Ju,v_),yp=Yu,TS=[`
#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)
#extension GL_EXT_blend_func_extended : require
#endif`,"precision mediump float;",yp,Y0.fragmentSource].join(`
`),J0=["precision highp float;",yp,Y0.vertexSource].join(`
`);var S_={background:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;
#ifdef LIGHTING_3D_MODE
in vec4 v_color;
#endif
void main() {vec4 out_color;
#ifdef LIGHTING_3D_MODE
out_color=v_color;
#else
out_color=u_color;
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
glFragColor=out_color*u_opacity;
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_lighting.glsl"
in vec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;
#ifdef LIGHTING_3D_MODE
uniform mediump vec4 u_color;out vec4 v_color;
#endif
void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
#ifdef LIGHTING_3D_MODE
v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);
#endif
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),backgroundPattern:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
glFragColor=out_color*u_opacity;
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in vec2 a_pos;out highp vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,a_pos);
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),building:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_shadow.fragment.glsl"
#include "_prelude_lighting.glsl"
const float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;
#ifdef BUILDING_FAUX_FACADE
in lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;
#endif
#ifdef RENDER_SHADOWS
in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
#endif
#ifdef FLOOD_LIGHT
in highp float v_flood_radius;in float v_has_flood_light;
#endif
uniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}
#ifdef BUILDING_FAUX_FACADE
float hash12(in vec2 p) {vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}vec2 get_uv_mask_id(in vec2 q,out float mask,out vec2 id) {vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;vec2 uv=modf(p/v_faux_facade_floor,id);vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;vec4 edge=d/v_faux_facade_floor.xyxy;vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}float ray_unit_box(in vec3 ray_o,in vec3 ray_d,in vec3 bmin,in vec3 bmax) {vec3 planes=mix(bmin,bmax,step(0.0,ray_d));vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in vec3 v,in vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;
#if 0
if (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;
#else
if (x_major) {out_normal=sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;
#endif
return out_color;}
#endif
vec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;
#ifdef BUILDING_FAUX_FACADE
if (v_faux_facade > 0.0) {mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;vec3 view_tangent=transpose(tbn)*v;vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;vec3 bmin=vec3(0.0,0.0,-window_depth);vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);vec3 ray_o=vec3(uv,0.0);vec3 ray_d=normalize(view_tangent);float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);vec3 hit=ray_o+t_min*ray_d;vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}
#endif
vec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;
#ifdef RENDER_SHADOWS
#ifdef RENDER_CUTOFF
shadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}
#else
shadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);
#endif
#else
shadowed_lighting_factor=dot(xy_flipped_normal,u_lighting_directional_dir);
#endif
color.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);
#ifdef FLOOD_LIGHT
float flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);
#endif
color.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));
#endif
color*=u_opacity;
#ifdef INDICATOR_CUTOUT
color=applyCutout(color,v_pos.z);
#endif
#ifdef FEATURE_CUTOUT
color=apply_feature_cutout(color,gl_FragCoord);
#endif
glFragColor=color;
#ifdef DEBUG_SHOW_NORMALS
color.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
in vec3 a_pos_3f;in vec3 a_normal_3;in vec3 a_centroid_3;in float a_flood_light_wall_radius_1i16;in vec4 a_faux_facade_data;in vec2 a_faux_facade_vertical_range;uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;
#ifdef BUILDING_FAUX_FACADE
out lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;
#endif
#ifdef FLOOD_LIGHT
out highp float v_flood_radius;out float v_has_flood_light;
#endif
const float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
#ifdef BUILDING_FAUX_FACADE
mat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}
#endif
#pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive
#pragma mapbox: define-attribute-vertex-shader-only highp vec2 faux_facade_color_emissive
void main() {
#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive
#pragma mapbox: initialize-attribute-custom highp vec2 faux_facade_color_emissive
#ifdef FLOOD_LIGHT
v_flood_radius=(a_flood_light_wall_radius_1i16/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);
#endif
vec4 color_emissive=decode_color(part_color_emissive);v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=a_normal_3/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;
#ifdef BUILDING_FAUX_FACADE
v_faux_facade=a_faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=a_faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(a_faux_facade_data.y/TWO_POW_8);float window_y_perc=a_faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(a_faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(a_faux_facade_vertical_range/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(faux_facade_color_emissive);v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);float height=a_centroid_3.z;depth_offset=min(1000.0,height)*0.0000002;}
#endif
v_pos=a_pos_3f;
#ifdef RENDER_CUTOFF
vec4 ground=u_matrix*vec4(a_centroid_3,1.0);v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;
#endif
#ifdef RENDER_SHADOWS
vec3 shadow_pos=v_pos;
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);
#endif
#ifdef FOG
v_fog_pos=fog_position(v_pos);
#endif
gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;}`),buildingBloom:Jr(`in vec4 v_color_emissive;
#pragma mapbox: define-attribute highp vec4 bloom_attenuation
#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation
float saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;
#ifdef HAS_ATTRIBUTE_a_bloom_attenuation
float distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);
#endif
#ifdef RENDER_CUTOFF
opacity*=v_cutoff_opacity;
#endif
glFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}`,`in vec3 a_pos_3f;
#pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive
#pragma mapbox: define-attribute highp vec4 bloom_attenuation
out vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {
#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive
#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation
#ifdef HAS_ATTRIBUTE_a_part_color_emissive
vec4 color_emissive=decode_color(part_color_emissive);float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);
#else
v_color_emissive=vec4(1.0);
#endif
gl_Position=u_matrix*vec4(a_pos_3f,1.0);
#ifdef RENDER_CUTOFF
v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
#endif
}`),buildingDepth:Jr(`in highp float v_depth;void main() {
#ifndef DEPTH_TEXTURE
glFragColor=pack_depth(v_depth);
#endif
}`,"in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);v_depth=gl_Position.z/gl_Position.w;}"),circle:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
in vec3 v_data;in float v_visibility;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump float radius
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp vec4 stroke_color
#pragma mapbox: define mediump float stroke_width
#pragma mapbox: define lowp float stroke_opacity
uniform float u_emissive_strength;void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump float radius
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp vec4 stroke_color
#pragma mapbox: initialize mediump float stroke_width
#pragma mapbox: initialize lowp float stroke_opacity
vec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ?
smoothstep(0.0,-antialiased_blur,1.0-extrude_length) :
smoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#endif
#ifdef FOG
out_color=fog_apply_premultiplied(out_color,v_fog_pos);
#endif
glFragColor=out_color*(v_visibility*opacity_t);
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
#define NUM_VISIBILITY_RINGS 2
#define INV_SQRT2 0.70710678
#define ELEVATION_BIAS 0.0001
#define NUM_SAMPLES_PER_RING 16
uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
#endif
#ifdef ELEVATED_ROADS
in float a_circle_z_offset;
#endif
out vec3 v_data;out float v_visibility;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump float radius
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp vec4 stroke_color
#pragma mapbox: define mediump float stroke_width
#pragma mapbox: define lowp float stroke_opacity
vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
#if defined(TERRAIN)
return elevation(pos)+ELEVATION_BIAS;
#else
return 0.0;
#endif
}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
#ifdef PITCH_WITH_MAP
#ifdef PROJECTION_GLOBE_VIEW
return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
#else
return u_matrix*( world_center+vec4(sample_offset,0,0) );
#endif
#else
return projected_center+vec4(sample_offset,0,0);
#endif
}float get_sample_step() {
#ifdef PITCH_WITH_MAP
return 2.0*PI/float(NUM_SAMPLES_PER_RING);
#else
return PI/float(NUM_SAMPLES_PER_RING);
#endif
}void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump float radius
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp vec4 stroke_color
#pragma mapbox: initialize mediump float stroke_width
#pragma mapbox: initialize lowp float stroke_opacity
vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;
#ifdef PROJECTION_GLOBE_VIEW
vec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);
#else
surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);
#endif
#ifdef ELEVATED_ROADS
world_center.z+=a_circle_z_offset+ELEVATION_BIAS;
#endif
vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
#ifdef PITCH_WITH_MAP
#ifdef SCALE_WITH_MAP
view_scale=1.0;
#else
view_scale=projected_center.w/u_camera_to_center_distance;
#endif
#else
#ifdef SCALE_WITH_MAP
view_scale=u_camera_to_center_distance;
#else
view_scale=projected_center.w;
#endif
#endif
gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
#ifdef TERRAIN
float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;
#ifdef PITCH_WITH_MAP
float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;
#else
occlusion_world_center=world_center;occlusion_projected_center=projected_center;
#endif
for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
#else
visibility=1.0;
#endif
#ifdef PROJECTION_GLOBE_VIEW
visibility=1.0;
#endif
v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
#ifdef FOG
v_fog_pos=fog_position(world_center.xyz);
#endif
}`),clippingMask:Jr("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Jr(`#include "_prelude_fog.fragment.glsl"
uniform highp float u_intensity;in vec2 v_extrude;
#pragma mapbox: define highp float weight
#define GAUSS_COEF 0.3989422804014327
void main() {
#pragma mapbox: 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);glFragColor=vec4(val,1.0,1.0,1.0);
#ifdef FOG
if (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl"
#include "_prelude_fog.vertex.glsl"
uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
#endif
out vec2 v_extrude;
#pragma mapbox: define highp float weight
#pragma mapbox: define mediump float radius
const highp float ZERO=1.0/255.0/16.0;
#define GAUSS_COEF 0.3989422804014327
void main() {
#pragma mapbox: initialize highp float weight
#pragma mapbox: initialize mediump float radius
vec2 unscaled_extrude=vec2(mod(a_pos,2.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 tilePos=floor(a_pos*0.5);vec3 pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#else
pos=vec3(tilePos+extrude,elevation(tilePos));
#endif
gl_Position=u_matrix*vec4(pos,1);
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),heatmapTexture:Jr(`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));glFragColor=color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(0.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,"in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Jr("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`#include "_prelude_terrain.vertex.glsl"
in vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;
#endif
out float v_placed;out float v_notUsed;void main() {float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(a_anchor_pos));vec3 proj_pos=a_pos+elevationVector(a_anchor_pos)*(feature_elevation+terrain_elevation);
#ifdef PROJECTION_GLOBE_VIEW
#ifndef PROJECTED_POS_ON_VIEWPORT
vec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,a_anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);
#endif
#endif
vec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Jr("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);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);glFragColor=color*alpha*opacity_t;}",`in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;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;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Jr("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",`#include "_prelude_terrain.vertex.glsl"
in vec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
in vec3 a_pos_3;
#endif
out vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;
#ifdef PROJECTION_GLOBE_VIEW
gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);
#else
gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);
#endif
}`),elevatedStructuresDepth:Jr(`void main() {
#ifndef DEPTH_TEXTURE
glFragColor=vec4(0.);
#endif
}`,"in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:Jr(`#ifdef DEPTH_RECONSTRUCTION
in float v_height;
#endif
void main() {
#ifdef DEPTH_RECONSTRUCTION
if (v_height >=0.0)
discard;
#else
#ifdef FEATURE_CUTOUT
apply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord);
#endif
#endif
glFragColor=vec4(1.0,0.0,0.0,1.0);}`,`in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;
#ifdef DEPTH_RECONSTRUCTION
out float v_height;
#endif
void main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);
#ifdef DEPTH_RECONSTRUCTION
if (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;
#endif
gl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}`),elevatedStructures:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
in vec3 v_normal;in float v_height;
#ifdef RENDER_SHADOWS
in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;
#endif
vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)
{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;
#pragma mapbox: define highp vec4 structure_color
void main() {
#pragma mapbox: initialize highp vec4 structure_color
vec3 color=structure_color.xyz;
#ifdef LIGHTING_3D_MODE
vec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);
#ifdef RENDER_SHADOWS
float shadowed_lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,transformed_normal,shadowed_lighting_factor);
#else
color=apply_lighting(color,transformed_normal);
#endif
color=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}
#endif
#ifdef FOG
color=fog_apply(color,v_fog_pos);
#endif
vec4 out_color=vec4(color,1.0);
#ifdef INDICATOR_CUTOUT
out_color=applyCutout(out_color,v_height);
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord);
#endif
glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
in vec2 a_pos;in float a_height;in vec3 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;
#endif
#pragma mapbox: define highp vec4 structure_color
void main() {
#pragma mapbox: initialize highp vec4 structure_color
v_normal=a_pos_normal_3/16384.0;v_height=a_height;vec3 pos=vec3(a_pos,a_height);gl_Position=u_matrix*vec4(pos,1);
#ifdef RENDER_SHADOWS
vec3 shd_pos0=pos;vec3 shd_pos1=pos;
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
#endif
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fill:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float opacity
uniform float u_emissive_strength;
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
#ifdef ELEVATED_ROADS
in highp float v_road_z_offset;
#endif
#ifdef INDICATOR_CUTOUT
in highp float v_z_offset;
#endif
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float opacity
vec4 out_color=color;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
out_color*=opacity;
#ifdef INDICATOR_CUTOUT
if (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord);
#endif
glFragColor=out_color;
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
in vec2 a_pos;
#ifdef ELEVATED_ROADS
in float a_road_z_offset;out highp float v_road_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
#endif
#ifdef INDICATOR_CUTOUT
out highp float v_z_offset;
#endif
uniform mat4 u_matrix;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp float z_offset
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp float z_offset
#ifdef ELEVATED_ROADS
z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
#endif
float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);
#ifdef RENDER_SHADOWS
vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
#endif
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
#ifdef INDICATOR_CUTOUT
v_z_offset=z_offset;
#endif
}`),fillOutline:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
in highp vec2 v_pos;uniform float u_emissive_strength;
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
#pragma mapbox: define highp vec4 outline_color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 outline_color
#pragma mapbox: initialize lowp float opacity
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord);
#endif
glFragColor=out_color*(alpha*opacity);
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
in vec2 a_pos;
#ifdef ELEVATED_ROADS
in float a_road_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
#endif
uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;
#pragma mapbox: define highp vec4 outline_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp float z_offset
void main() {
#pragma mapbox: initialize highp vec4 outline_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp float z_offset
#ifdef ELEVATED_ROADS
z_offset+=a_road_z_offset;
#endif
float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);
#ifdef FLIP_Y
v_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;
#else
v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
#endif
#ifdef RENDER_SHADOWS
vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
#endif
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillOutlinePattern:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
uniform vec2 u_texsize;uniform sampler2D u_image;
#ifdef FILL_PATTERN_TRANSITION
uniform float u_pattern_transition;
#endif
uniform float u_emissive_strength;
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
in highp vec2 v_pos;in highp vec2 v_pos_world;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: define mediump vec4 pattern_b
#endif
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: initialize mediump vec4 pattern_b
#endif
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
#ifdef APPLY_LUT_ON_GPU
out_color=applyLUT(u_lutTexture,out_color);
#endif
#ifdef FILL_PATTERN_TRANSITION
vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
glFragColor=out_color*(alpha*opacity);
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;
#ifdef ELEVATED_ROADS
in float a_road_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
#endif
out highp vec2 v_pos;out highp vec2 v_pos_world;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: define mediump vec4 pattern_b
#endif
#pragma mapbox: define lowp float pixel_ratio
#pragma mapbox: define highp float z_offset
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: initialize mediump vec4 pattern_b
#endif
#pragma mapbox: initialize lowp float pixel_ratio
#pragma mapbox: initialize highp float z_offset
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;
#ifdef ELEVATED_ROADS
z_offset+=a_road_z_offset;
#endif
float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);
#ifdef FLIP_Y
v_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;
#else
v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
#endif
#ifdef RENDER_SHADOWS
vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
#endif
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillPattern:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
uniform vec2 u_texsize;uniform sampler2D u_image;
#ifdef FILL_PATTERN_TRANSITION
uniform float u_pattern_transition;
#endif
in highp vec2 v_pos;uniform float u_emissive_strength;
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
#ifdef ELEVATED_ROADS
in highp float v_road_z_offset;
#endif
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: define mediump vec4 pattern_b
#endif
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: initialize mediump vec4 pattern_b
#endif
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
#ifdef APPLY_LUT_ON_GPU
out_color=applyLUT(u_lutTexture,out_color);
#endif
#ifdef FILL_PATTERN_TRANSITION
vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);
#ifdef ELEVATED_ROADS
out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
#else
out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
glFragColor=out_color*opacity;
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;
#ifdef ELEVATED_ROADS
in float a_road_z_offset;out highp float v_road_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
#endif
out highp vec2 v_pos;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: define mediump vec4 pattern_b
#endif
#pragma mapbox: define lowp float pixel_ratio
#pragma mapbox: define highp float z_offset
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
#pragma mapbox: initialize highp float z_offset
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: initialize mediump vec4 pattern_b
#endif
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;
#ifdef ELEVATED_ROADS
z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
#endif
float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);
#ifdef RENDER_SHADOWS
vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
#endif
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillExtrusion:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_shadow.fragment.glsl"
#include "_prelude_lighting.glsl"
in vec4 v_color;in vec4 v_flat;
#ifdef RENDER_SHADOWS
in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
#endif
uniform lowp float u_opacity;
#ifdef FAUX_AO
uniform lowp vec2 u_ao;in vec2 v_ao;
#endif
#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
in vec4 v_roof_color;
#endif
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
in highp vec3 v_normal;
#endif
uniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;
#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
in float v_flood_radius;in float v_has_floodlight;
#endif
in float v_height;
#pragma mapbox: define highp float emissive_strength
void main() {
#pragma mapbox: initialize highp float emissive_strength
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
vec3 normal=normalize(v_normal);
#endif
float z;vec4 color=v_color;
#ifdef ZERO_ROOF_RADIUS
z=float(normal.z > 0.00001);
#ifdef LIGHTING_3D_MODE
normal=mix(normal,vec3(0.0,0.0,1.0),z);
#else
color=mix(v_color,v_roof_color,z);
#endif
#endif
float h=max(0.0,v_height);float ao_shade=1.0;
#ifdef FAUX_AO
float intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;
#ifdef ZERO_ROOF_RADIUS
concave*=(1.0-z);
#endif
float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);
#ifdef LIGHTING_3D_MODE
#ifdef FLOOD_LIGHT
color.rgb*=mix(ao_shade,1.0,v_has_floodlight);
#else
color.rgb*=ao_shade;
#endif
#else
color.rgb*=ao_shade;
#endif
#endif
#ifdef LIGHTING_3D_MODE
float flood_radiance=0.0;
#ifdef FLOOD_LIGHT
flood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;
#endif
#ifdef RENDER_SHADOWS
#ifdef FLOOD_LIGHT
float ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);
#else
float shadowed_lighting_factor;
#ifdef RENDER_CUTOFF
shadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}
#else
shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);
#endif
color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);
#endif
#else
color.rgb=apply_lighting(color.rgb,normal);
#ifdef FLOOD_LIGHT
color.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);
#endif
#endif
color.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));
#endif
#ifdef INDICATOR_CUTOUT
color=applyCutout(color,h);
#endif
#ifdef FEATURE_CUTOUT
color=apply_feature_cutout(color,gl_FragCoord);
#endif
glFragColor=color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_material_table.vertex.glsl"
uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;
#ifdef RENDER_WALL_MODE
in vec3 a_join_normal_inside;
#endif
#ifdef PROJECTION_GLOBE_VIEW
in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
#endif
#ifdef TERRAIN
uniform int u_height_type;uniform int u_base_type;
#endif
uniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;
#endif
#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
out vec4 v_roof_color;
#endif
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
out highp vec3 v_normal;
#endif
#ifdef FAUX_AO
uniform lowp vec2 u_ao;out vec2 v_ao;
#endif
#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
out float v_flood_radius;out float v_has_floodlight;
#endif
out float v_height;vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define highp vec4 color
#pragma mapbox: define highp float flood_light_wall_radius
#pragma mapbox: define highp float line_width
#pragma mapbox: define highp float emissive_strength
void main() {DECLARE_MATERIAL_TABLE_INFO
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize highp float flood_light_wall_radius
#pragma mapbox: initialize highp float line_width
#pragma mapbox: initialize highp float emissive_strength
base*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
v_normal=normal;
#endif
base=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
#if defined(HAS_CENTROID) || defined(TERRAIN)
centroid_pos=a_centroid_pos;
#endif
float ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;
#ifdef TERRAIN
bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);
#else
h=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);
#endif
#ifdef PROJECTION_GLOBE_VIEW
float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#endif
float cutoff=1.0;vec3 scaled_pos=pos;
#ifdef RENDER_CUTOFF
vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);
#ifdef CLIP_ZERO_TO_ONE
cutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);
#else
cutoff=cutoff_opacity(u_cutoff_params,ground.z);
#endif
if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);
#endif
float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));
#ifdef RENDER_WALL_MODE
vec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_join_normal_inside.z*wall_offset*0.5;
#endif
gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;
#ifdef RENDER_SHADOWS
vec3 shd_pos0=pos;vec3 shd_pos1=pos;
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);
#endif
float NdotL=0.0;float colorvalue=0.0;
#ifndef LIGHTING_3D_MODE
colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
#endif
#ifdef FAUX_AO
float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
#ifdef TERRAIN
top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
#endif
v_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);
#ifdef PROJECTION_GLOBE_VIEW
top_height+=u_height_lift;
#endif
gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
#endif
#ifdef LIGHTING_3D_MODE
#ifdef FLOOD_LIGHT
float is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;
#endif
v_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);
#else
v_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;
#endif
#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;
#endif
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),fillExtrusionDepth:Jr(`in highp float v_depth;void main() {
#ifndef DEPTH_TEXTURE
glFragColor=pack_depth(v_depth);
#endif
}`,`#include "_prelude_terrain.vertex.glsl"
#include "_prelude_material_table.vertex.glsl"
uniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;
#ifdef TERRAIN
uniform int u_height_type;uniform int u_base_type;
#endif
in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;
#ifdef RENDER_WALL_MODE
in vec3 a_join_normal_inside;
#endif
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define highp float line_width
#pragma mapbox: define highp vec4 color
out highp float v_depth;void main() {DECLARE_MATERIAL_TABLE_INFO
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize highp float line_width
#pragma mapbox: initialize highp vec4 color
base*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
#if defined(HAS_CENTROID) || defined(TERRAIN)
centroid_pos=a_centroid_pos;
#endif
vec3 pos;
#ifdef TERRAIN
bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);float c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);
#else
pos=vec3(pos_nx.xy,t > 0.0 ? height : base);
#endif
#ifdef RENDER_WALL_MODE
vec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_join_normal_inside.z*wall_offset*0.5;
#endif
float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}`),fillExtrusionPattern:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform vec2 u_texsize;uniform sampler2D u_image;
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
uniform float u_pattern_transition;
#endif
#ifdef FAUX_AO
uniform lowp vec2 u_ao;in vec3 v_ao;
#endif
#ifdef LIGHTING_3D_MODE
in vec3 v_normal;
#endif
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
in highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define mediump vec4 pattern
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
#pragma mapbox: define mediump vec4 pattern_b
#endif
#pragma mapbox: define highp float pixel_ratio
void main() {
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize mediump vec4 pattern
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
#pragma mapbox: initialize mediump vec4 pattern_b
#endif
#pragma mapbox: initialize highp float pixel_ratio
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
#ifdef APPLY_LUT_ON_GPU
out_color=applyLUT(u_lutTexture,out_color);
#endif
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;
#else
out_color=out_color*v_lighting;
#endif
#ifdef FAUX_AO
float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
#ifdef INDICATOR_CUTOUT
out_color=applyCutout(out_color,height);
#endif
glFragColor=out_color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_material_table.vertex.glsl"
uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;
#ifdef RENDER_WALL_MODE
in vec3 a_join_normal_inside;
#endif
#ifdef PROJECTION_GLOBE_VIEW
in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
#endif
#ifdef TERRAIN
uniform int u_height_type;uniform int u_base_type;
#endif
out highp vec2 v_pos;out vec4 v_lighting;
#ifdef FAUX_AO
uniform lowp vec2 u_ao;out vec3 v_ao;
#endif
#ifdef LIGHTING_3D_MODE
out vec3 v_normal;
#endif
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump vec4 pattern
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
#pragma mapbox: define mediump vec4 pattern_b
#endif
#pragma mapbox: define highp float pixel_ratio
#pragma mapbox: define highp float line_width
void main() {DECLARE_MATERIAL_TABLE_INFO
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump vec4 pattern
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
#pragma mapbox: initialize mediump vec4 pattern_b
#endif
#pragma mapbox: initialize highp float pixel_ratio
#pragma mapbox: initialize highp float line_width
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
#if defined(HAS_CENTROID) || defined(TERRAIN)
centroid_pos=a_centroid_pos;
#endif
float ele=0.0;float h=z;vec3 p;float c_ele;
#ifdef TERRAIN
bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);
#else
p=vec3(pos_nx.xy,z);
#endif
#ifdef PROJECTION_GLOBE_VIEW
float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#endif
#ifdef RENDER_WALL_MODE
vec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_join_normal_inside.z*wall_offset*0.5;
#endif
float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
? pos_nx.xy
: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;
#ifdef LIGHTING_3D_MODE
NdotL=calculate_NdotL(normal);
#else
NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);
#endif
if (normal.y !=0.0) {float r=0.84;
#ifndef LIGHTING_3D_MODE
r=mix(0.7,0.98,1.0-u_lightintensity);
#endif
NdotL*=(
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
#ifdef FAUX_AO
float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
#ifdef TERRAIN
top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
#endif
v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);
#ifdef PROJECTION_GLOBE_VIEW
top_height+=u_height_lift;
#endif
gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
#endif
#ifdef LIGHTING_3D_MODE
v_normal=normal;
#else
v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
#endif
#ifdef FOG
v_fog_pos=fog_position(p);
#endif
}`),groundShadow:Jr(`#include "_prelude_shadow.fragment.glsl"
precision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;
#ifdef FOG
in float v_fog_opacity;
#endif
void main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);
#ifdef RENDER_CUTOFF
shadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));
#endif
#ifdef FOG
shadow=mix(shadow,vec3(1.0),v_fog_opacity);
#endif
#ifdef INDICATOR_CUTOUT
shadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);
#endif
glFragColor=vec4(shadow,1.0);}`,`#include "_prelude_fog.vertex.glsl"
uniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;
#ifdef FOG
out float v_fog_opacity;
#endif
void main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);
#ifdef FOG
v_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);
#endif
}`),fillExtrusionGroundEffect:Jr(`uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;
#ifdef SDF_SUBPASS
in highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}
#ifdef FOG
in highp float v_fog;
#endif
#endif
void main() {
#ifdef CLEAR_SUBPASS
vec4 color=vec4(1.0);
#ifdef CLEAR_FROM_TEXTURE
color=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));
#endif
glFragColor=color;
#else
#ifdef SDF_SUBPASS
highp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;
#ifdef FOG
fog=v_fog;
#endif
#ifdef RENDER_CUTOFF
fog*=v_cutoff_opacity;
#endif
glFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));
#else
#ifdef USE_MRT1
out_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);
#else
vec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);
#ifdef OVERDRAW_INSPECTOR
color=vec4(1.0);
#endif
glFragColor=color;
#endif
#endif
HANDLE_WIREFRAME_DEBUG;
#endif
}`,`#include "_prelude_fog.vertex.glsl"
in highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;
#ifdef SDF_SUBPASS
out highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;
#ifdef FOG
out highp float v_fog;
#endif
#endif
uniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao;
#pragma mapbox: define highp float flood_light_ground_radius
const float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {
#pragma mapbox: initialize highp float flood_light_ground_radius
vec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;
#ifdef SDF_SUBPASS
v_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);
#ifdef FOG
v_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);
#endif
#endif
float hidden_by_landmark=0.0;
#ifdef HAS_CENTROID
hidden_by_landmark=a_hidden_by_landmark;
#endif
float isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));
#ifdef RENDER_CUTOFF
v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
#endif
}`),hillshadePrepare:Jr(`precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));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+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)
)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(
deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;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:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;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_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;
#ifdef LIGHTING_3D_MODE
glFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);
#endif
#ifdef FOG
glFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));
#endif
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
uniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),line:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
uniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;
#ifdef ELEVATED_ROADS
in highp float v_road_z_offset;
#endif
#ifdef RENDER_LINE_DASH
uniform sampler2D u_dash_image;in vec2 v_tex;
#endif
#ifdef RENDER_LINE_GRADIENT
uniform sampler2D u_gradient_image;
#endif
#ifdef INDICATOR_CUTOUT
in highp float v_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define lowp vec4 dash
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define mediump float side_z_offset
#pragma mapbox: define lowp float border_width
#pragma mapbox: define lowp vec4 border_color
#pragma mapbox: define lowp float emissive_strength
float linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize lowp vec4 dash
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float side_z_offset
#pragma mapbox: initialize lowp float border_width
#pragma mapbox: initialize lowp vec4 border_color
#pragma mapbox: initialize lowp float emissive_strength
float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);alpha=side_z_offset > 0.0 ? 1.0-alpha : alpha;
#ifdef RENDER_LINE_DASH
float sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);
#endif
highp vec4 out_color;
#ifdef RENDER_LINE_GRADIENT
out_color=texture(u_gradient_image,v_uv.xy);
#ifdef MULTIPLY_LINE_GRADIENT_COLOR
out_color*=color;
#endif
#else
out_color=color;
#endif
float trim_alpha=1.0;
#ifdef RENDER_LINE_TRIM_OFFSET
highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);out_color=mix(out_color,u_trim_color,transition_factor);trim_alpha=1.0-transition_factor;}
#endif
if (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}
#ifdef RENDER_LINE_BORDER
float edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}}
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);
#ifdef ELEVATED_ROADS
out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
#else
out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
out_color*=(alpha*opacity);
#ifdef INDICATOR_CUTOUT
out_color=applyCutout(out_color,v_z_offset);
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord);
#endif
glFragColor=out_color;
#ifdef DUAL_SOURCE_BLENDING
glFragColorSrc1=vec4(vec3(0.0),emissive_strength);
#else
#ifdef USE_MRT1
out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
#define EXTRUDE_SCALE 0.015873016
in vec2 a_pos_normal;in vec4 a_data;
#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)
in vec3 a_z_offset_width;
#endif
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
in highp vec3 a_packed;
#endif
#ifdef RENDER_LINE_DASH
in float a_linesofar;
#endif
uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;uniform float u_width_scale;uniform highp float u_floor_width_scale;
#ifdef ELEVATED
uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {
#ifdef ELEVATION_REFERENCE_SEA
return 0.0;
#else
return elevation(apos);
#endif
}
#endif
out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec3 v_uv;
#ifdef ELEVATED_ROADS
out highp float v_road_z_offset;
#endif
#ifdef RENDER_LINE_DASH
uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;
#endif
#ifdef RENDER_LINE_GRADIENT
uniform float u_image_height;
#endif
#ifdef INDICATOR_CUTOUT
out highp float v_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
#endif
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define lowp vec4 dash
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define lowp float offset
#pragma mapbox: define mediump float width
#pragma mapbox: define mediump float side_z_offset
#pragma mapbox: define lowp float border_width
#pragma mapbox: define lowp vec4 border_color
#pragma mapbox: define lowp float emissive_strength
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize lowp vec4 dash
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize mediump float side_z_offset
#pragma mapbox: initialize lowp float border_width
#pragma mapbox: initialize lowp vec4 border_color
#pragma mapbox: initialize lowp float emissive_strength
float a_z_offset;
#if defined(ELEVATED) || defined(ELEVATED_ROADS)
a_z_offset=a_z_offset_width.x;
#endif
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth;
#ifdef VARIABLE_LINE_WIDTH
bool left=normal.y==1.0;halfwidth=(u_width_scale*(left ? a_z_offset_width.y : a_z_offset_width.z))/2.0;a_z_offset+=left ? side_z_offset : 0.0;v_normal=side_z_offset > 0.0 && left ? vec2(0.0) : v_normal;
#else
halfwidth=(u_width_scale*width)/2.0;
#endif
offset=-1.0*offset*u_width_scale;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*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;
#ifdef ELEVATED_ROADS
v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;
#else
#ifdef ELEVATED
vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;
#ifdef CROSS_SLOPE_VERTICAL
float top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);
#else
#ifdef CROSS_SLOPE_HORIZONTAL
float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset;
#else
float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset;
#endif
#endif
gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);
#else
gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);
#endif
#endif
#ifdef ELEVATED_ROADS
#ifdef RENDER_SHADOWS
vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;
#ifdef NORMAL_OFFSET
vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
#endif
#endif
#ifndef RENDER_TO_TEXTURE
float epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));
#else
v_gamma_scale=1.0;
#endif
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
highp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float line_progress=a_packed[2];
#ifdef RENDER_LINE_GRADIENT
highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);
#else
v_uv=vec3(a_uv_x,0.0,line_progress);
#endif
#endif
#ifdef RENDER_LINE_DASH
float scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*height+dash.x+0.5)/u_texsize.y);
#endif
v_width2=vec2(outset,inset);
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
#ifdef INDICATOR_CUTOUT
v_z_offset=a_z_offset;
#endif
}`),linePattern:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
uniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
#ifdef LINE_PATTERN_TRANSITION
uniform float u_pattern_transition;
#endif
in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;
#ifdef RENDER_LINE_TRIM_OFFSET
in highp vec3 v_uv;
#endif
#ifdef ELEVATED_ROADS
in highp float v_road_z_offset;
#endif
#ifdef LINE_JOIN_NONE
in vec2 v_pattern_data;
#endif
#ifdef INDICATOR_CUTOUT
in highp float v_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
#pragma mapbox: define mediump vec4 pattern
#ifdef LINE_PATTERN_TRANSITION
#pragma mapbox: define mediump vec4 pattern_b
#endif
#pragma mapbox: define mediump float pixel_ratio
#pragma mapbox: define mediump float blur
#pragma mapbox: define mediump float opacity
#pragma mapbox: define lowp float emissive_strength
void main() {
#pragma mapbox: initialize mediump vec4 pattern
#ifdef LINE_PATTERN_TRANSITION
#pragma mapbox: initialize mediump vec4 pattern_b
#endif
#pragma mapbox: initialize mediump float pixel_ratio
#pragma mapbox: initialize mediump float blur
#pragma mapbox: initialize mediump float opacity
#pragma mapbox: initialize lowp float emissive_strength
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);
#ifdef APPLY_LUT_ON_GPU
color=applyLUT(u_lutTexture,color);
#endif
#ifdef LINE_PATTERN_TRANSITION
vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
#endif
#ifdef RENDER_LINE_TRIM_OFFSET
highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}
#endif
#ifdef LINE_JOIN_NONE
highp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}
#endif
#ifdef LIGHTING_3D_MODE
color=apply_lighting_with_emission_ground(color,emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);
#ifdef ELEVATED_ROADS
color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
#else
color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#endif
color*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}
#ifdef INDICATOR_CUTOUT
color=applyCutout(color,v_z_offset);
#endif
glFragColor=color;
#ifdef DUAL_SOURCE_BLENDING
glFragColorSrc1=vec4(vec3(0.0),emissive_strength);
#else
#ifdef USE_MRT1
out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
#define scale 0.015873016
in vec2 a_pos_normal;in vec4 a_data;
#if defined(ELEVATED) || defined(ELEVATED_ROADS)
in vec3 a_z_offset_width;
#endif
#ifdef RENDER_LINE_TRIM_OFFSET
in highp vec3 a_packed;
#endif
in highp float a_linesofar;
#ifdef LINE_JOIN_NONE
in highp vec3 a_pattern_data;out vec2 v_pattern_data;
#endif
#ifdef INDICATOR_CUTOUT
out highp float v_z_offset;
#endif
uniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;
#ifdef ELEVATED
uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {
#ifdef ELEVATION_REFERENCE_SEA
return 0.0;
#else
return elevation(apos);
#endif
}
#endif
out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;
#ifdef RENDER_LINE_TRIM_OFFSET
out highp vec3 v_uv;
#endif
#ifdef ELEVATED_ROADS
out highp float v_road_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
#endif
#pragma mapbox: define mediump float blur
#pragma mapbox: define mediump float opacity
#pragma mapbox: define mediump float offset
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define mediump float width
#pragma mapbox: define mediump float floorwidth
#pragma mapbox: define mediump vec4 pattern
#ifdef LINE_PATTERN_TRANSITION
#pragma mapbox: define mediump vec4 pattern_b
#endif
#pragma mapbox: define mediump float pixel_ratio
#pragma mapbox: define lowp float emissive_strength
void main() {
#pragma mapbox: initialize mediump float blur
#pragma mapbox: initialize mediump float opacity
#pragma mapbox: initialize mediump float offset
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize mediump float floorwidth
#pragma mapbox: initialize mediump vec4 pattern
#ifdef LINE_PATTERN_TRANSITION
#pragma mapbox: initialize mediump vec4 pattern_b
#endif
#pragma mapbox: initialize mediump float pixel_ratio
#pragma mapbox: initialize lowp float emissive_strength
float a_z_offset;
#if defined(ELEVATED) || defined(ELEVATED_ROADS)
a_z_offset=a_z_offset_width.x;
#endif
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;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);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;
#ifdef ELEVATED_ROADS
v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;
#else
#ifdef ELEVATED
vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;
#ifdef CROSS_SLOPE_VERTICAL
float top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);
#else
#ifdef CROSS_SLOPE_HORIZONTAL
float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset;
#else
float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset;
#endif
#endif
gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);
#else
gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);
#endif
#endif
#ifdef ELEVATED_ROADS
#ifdef RENDER_SHADOWS
vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;
#ifdef NORMAL_OFFSET
vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
#endif
#endif
#ifndef RENDER_TO_TEXTURE
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));
#else
v_gamma_scale=1.0;
#endif
#ifdef RENDER_LINE_TRIM_OFFSET
highp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);
#endif
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);
#ifdef LINE_JOIN_NONE
v_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);
#endif
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
#ifdef INDICATOR_CUTOUT
v_z_offset=a_z_offset;
#endif
}`),raster:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_raster_array.glsl"
uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;
#ifdef PROJECTION_GLOBE_VIEW
in float v_split_fade;
#endif
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;uniform float u_emissive_strength;
#ifndef RASTER_ARRAY
uniform highp sampler2D u_image0;uniform sampler2D u_image1;
#endif
#ifdef RASTER_COLOR
uniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;
#endif
void main() {vec4 color0,color1,color;vec2 value;
#ifdef RASTER_COLOR
#ifdef RASTER_ARRAY
#ifdef RASTER_ARRAY_LINEAR
value=mix(
raTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t
);
#else
value=mix(
raTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t
);
#endif
if (value.y > 0.0) value.x/=value.y;
#else
color=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);
#endif
color=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;
#else
color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);
#endif
color.a*=u_opacity;
#ifdef GLOBE_POLES
color.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);
#endif
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);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;
#endif
#ifdef FOG
highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));
#endif
glFragColor=vec4(out_color*color.a,color.a);
#ifdef PROJECTION_GLOBE_VIEW
glFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));
#endif
#ifdef RENDER_CUTOFF
glFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;
#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8
#ifdef GLOBE_POLES
in vec3 a_globe_pos;in vec2 a_uv;
#else
in vec2 a_pos;in vec2 a_texture_pos;
#endif
out vec2 v_pos0;out vec2 v_pos1;out float v_depth;
#ifdef PROJECTION_GLOBE_VIEW
out float v_split_fade;
#endif
void main() {vec2 uv;
#ifdef GLOBE_POLES
vec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;
#ifdef FOG
v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);
#endif
#else
float w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;
#ifdef PROJECTION_GLOBE_VIEW
vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);
v_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;
#ifdef FOG
v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
#endif
#else
gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
#endif
#endif
v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;
#ifdef RENDER_CUTOFF
v_depth=gl_Position.z;
#endif
}`),rasterParticle:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;
#endif
#ifdef FOG
highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));
#endif
glFragColor=vec4(out_color*color.a,color.a);
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;
#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8
in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;
#ifdef PROJECTION_GLOBE_VIEW
vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;
#ifdef FOG
v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
#endif
#else
uv=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
#endif
v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:Jr("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",`#include "_prelude_raster_particle.glsl"
in float a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(
mod(a_index,u_particle_texture_side_len),a_index/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}`),rasterParticleTexture:Jr("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in vec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*a_pos+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Jr(`#include "_prelude_raster_particle.glsl"
uniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(
linearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)
);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}`,"in vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:Jr(`#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
#define SDF_PX 8.0
#define SDF 1.0
#define ICON 0.0
uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;
#ifdef ICON_TRANSITION
uniform float u_icon_transition;
#endif
#ifdef COLOR_ADJUSTMENT
uniform mat4 u_color_adj_mat;
#endif
#ifdef INDICATOR_CUTOUT
in highp float v_z_offset;
#else
#ifdef RENDER_SHADOWS
in highp float v_z_offset;
#endif
#endif
in vec2 v_tex_a;
#ifdef ICON_TRANSITION
in vec2 v_tex_b;
#endif
in float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;
#ifdef RENDER_TEXT_AND_SYMBOL
in float is_sdf;in vec2 v_tex_a_icon;
#endif
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
#pragma mapbox: define lowp float emissive_strength
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
#pragma mapbox: initialize lowp float emissive_strength
vec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];
#ifdef RENDER_TEXT_AND_SYMBOL
if (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
return;}
#endif
#ifdef RENDER_SDF
float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;
#else
#ifdef ICON_TRANSITION
vec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);
#else
out_color=texture(u_texture,v_tex_a);
#endif
#ifdef APPLY_LUT_ON_GPU
out_color=applyLUT(u_lutTexture,out_color);
#endif
#ifdef COLOR_ADJUSTMENT
out_color=u_color_adj_mat*out_color;
#endif
#endif
out_color*=opacity*fade_opacity;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);
#ifdef TERRAIN
out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#else
out_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
#endif
#endif
#endif
#ifdef INDICATOR_CUTOUT
out_color=applyCutout(out_color,v_z_offset);
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord);
#endif
glFragColor=out_color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
#define APPEARANCE_ICON 1.0
in vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;
#ifdef Z_OFFSET
in float a_auto_z_offset;
#endif
#ifdef PROJECTION_GLOBE_VIEW
in vec3 a_globe_anchor;in vec3 a_globe_normal;
#endif
#ifdef ICON_TRANSITION
in vec2 a_texb;
#endif
#ifdef OCCLUSION_QUERIES
in float a_occlusion_query_opacity;
#endif
#ifdef ELEVATED_ROADS
in vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;
#endif
#ifdef INDICATOR_CUTOUT
out highp float v_z_offset;
#else
#ifdef RENDER_SHADOWS
out highp float v_z_offset;
#endif
#endif
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_matrix;uniform mat4 u_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
#endif
out vec2 v_tex_a;
#ifdef ICON_TRANSITION
out vec2 v_tex_b;
#endif
out float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;
#ifdef RENDER_TEXT_AND_SYMBOL
out float is_sdf;out vec2 v_tex_a_icon;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
#endif
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
#pragma mapbox: define lowp float emissive_strength
#pragma mapbox: define lowp float occlusion_opacity
#pragma mapbox: define lowp float z_offset
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
#pragma mapbox: initialize lowp float emissive_strength
#pragma mapbox: initialize lowp float occlusion_opacity
#pragma mapbox: initialize lowp float z_offset
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance_icon=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance_icon==APPEARANCE_ICON) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,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 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);
#ifdef Z_OFFSET
e+=a_auto_z_offset;
#endif
vec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;
#ifdef PROJECTION_GLOBE_VIEW
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=a_globe_anchor+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
#else
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
#endif
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a;
#ifdef PROJECTION_GLOBE_VIEW
vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;
#else
offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;
#endif
vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
#ifdef PROJECTION_GLOBE_VIEW
#ifdef PROJECTED_POS_ON_VIEWPORT
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);
#else
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
#endif
#else
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
#endif
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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);
#ifdef TERRAIN
#ifdef PITCH_WITH_MAP_TERRAIN
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
#endif
#endif
#ifdef Z_OFFSET
z+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;
#else
z+=u_pitch_with_map ? z_offset : 0.0;
#endif
float occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));
#ifdef DEPTH_OCCLUSION
float depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;
#endif
#ifdef OCCLUSION_QUERIES
float occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;
#endif
#ifdef Z_TEST_OCCLUSION
out_fade_opacity*=occlusion_opacity;
#endif
float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;
#else
#ifdef ELEVATED_ROADS
vec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;
#else
pos=vec3(projected_pos.xy/projected_pos.w+offset,z);
#endif
#endif
gl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;
#ifdef RENDER_TEXT_AND_SYMBOL
is_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;
#endif
#ifdef ICON_TRANSITION
v_tex_b=a_texb/u_texsize;
#endif
#ifdef RENDER_SHADOWS
vec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;
#ifdef NORMAL_OFFSET
vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
#endif
#ifdef INDICATOR_CUTOUT
v_z_offset=e;
#else
#ifdef RENDER_SHADOWS
v_z_offset=e;
#endif
#endif
}`),terrainRaster:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_shadow.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform sampler2D u_image0;
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
uniform sampler2D u_image1;uniform float u_emissive_texture_available;
#endif
in vec2 v_pos0;
#ifdef FOG
in float v_fog_opacity;
#endif
#ifdef RENDER_SHADOWS
in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;
#endif
uniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;
#ifdef LIGHTING_3D_MODE
const vec3 normal=vec3(0.0,0.0,1.0);
#ifdef RENDER_SHADOWS
float cutoffOpacity=1.0;
#ifdef RENDER_CUTOFF
cutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);
#endif
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;
#else
float lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));
#endif
#else
float lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0;
#endif
#endif
#else
color=image_color;
#endif
#ifdef FOG
#ifdef ZERO_EXAGGERATION
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#else
color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
#endif
#endif
glFragColor=color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
uniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0;
#ifdef FOG
out float v_fog_opacity;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;
#endif
void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
#ifdef FOG
#ifdef ZERO_EXAGGERATION
v_fog_pos=fog_position(decodedPos);
#else
v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
#endif
#endif
#ifdef RENDER_SHADOWS
vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);
#endif
}`),terrainDepth:Jr("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl"
uniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}`),skybox:Jr(`#include "_prelude_fog.fragment.glsl"
in lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb;
#ifdef FOG
sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
#endif
sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
}`,fp),skyboxGradient:Jr(`#include "_prelude_fog.fragment.glsl"
in highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5));
#ifdef FOG
color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
#endif
color*=u_opacity;glFragColor=color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
}`,fp),skyboxCapture:Jr(`
in highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float;
#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)
#define BETA_M vec3(21e-6,21e-6,21e-6)
#define MIE_G 0.76
#define DENSITY_HEIGHT_SCALE_R 8000.0
#define DENSITY_HEIGHT_SCALE_M 1200.0
#define PLANET_RADIUS 6360e3
#define ATMOSPHERE_RADIUS 6420e3
#define SAMPLE_STEPS 10
#define DENSITY_STEPS 4
float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}`,"in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform sampler2D u_image0;
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
uniform sampler2D u_image1;uniform float u_emissive_texture_available;
#endif
uniform float u_far_z_cutoff;in vec2 v_pos0;
#ifndef FOG
uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;
#endif
void main() {vec4 color;
#ifdef CUSTOM_ANTIALIASING
highp vec2 uv=gl_FragCoord.xy/u_viewport;
#ifdef FLIP_Y
uv.y=1.0-uv.y;
#endif
highp vec3 ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);
#ifdef LIGHTING_3D_MODE
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias);
#else
raster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);
#endif
#else
color=vec4(raster.rgb*antialias,raster.a*antialias);
#endif
#else
color=texture(u_image0,v_pos0);
#ifdef LIGHTING_3D_MODE
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0;
#else
color=apply_lighting_ground(color);
#endif
#endif
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#endif
color*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;
#ifdef GLOBE_POLES
in vec3 a_globe_pos;in vec2 a_uv;
#else
in vec2 a_pos;
#endif
out vec2 v_pos0;void main() {
#ifdef GLOBE_POLES
vec3 globe_pos=a_globe_pos;vec2 uv=a_uv;
#else
float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
#endif
v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;
#ifdef GLOBE_POLES
vec3 up_vector=globe_derived_up_vector;
#else
vec3 up_vector=elevationVector(tile_pos);
#endif
float height=elevation(tile_pos);globe_pos+=up_vector*height;
#ifndef GLOBE_POLES
globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;
#endif
#ifdef GLOBE_POLES
vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);
#else
vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
#endif
gl_Position=u_proj_matrix*interpolated_pos;
#ifdef FOG
v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
#endif
}`),globeAtmosphere:Jr(`#include "_prelude_fog.fragment.glsl"
uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;
#ifdef PROJECTION_GLOBE_VIEW
globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {
#ifdef ALPHA_PASS
glFragColor=vec4(0,0,0,0);return;
#else
#ifdef NATIVE
glFragColor=vec4(1,1,1,1);
#else
glFragColor=vec4(0,0,0,1);
#endif
return;
#endif
}
#endif
highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?
0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;
#ifdef PROJECTION_GLOBE_VIEW
highp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?
PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);
#else
horizon_angle=horizon_angle_mercator;
#endif
horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;
#ifdef ALPHA_PASS
float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);
#else
vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t);
#endif
}`,`in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(
mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`),model:Jr(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_shadow.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;
#ifdef RENDER_SHADOWS
in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;
#endif
#ifdef OCCLUSION_TEXTURE_TRANSFORM
uniform vec4 u_occlusionTextureTransform;
#endif
#pragma mapbox: define-attribute highp vec3 normal_3f
#pragma mapbox: define-attribute highp vec3 color_3f
#pragma mapbox: define-attribute highp vec4 color_4f
#pragma mapbox: define-attribute highp vec2 uv_2f
#pragma mapbox: initialize-attribute highp vec3 normal_3f
#pragma mapbox: initialize-attribute highp vec3 color_3f
#pragma mapbox: initialize-attribute highp vec4 color_4f
#pragma mapbox: initialize-attribute highp vec2 uv_2f
#ifdef HAS_ATTRIBUTE_a_pbr
in lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;
#endif
#ifdef HAS_TEXTURE_u_baseColorTexture
uniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;
#endif
#ifdef HAS_TEXTURE_u_metallicRoughnessTexture
uniform sampler2D u_metallicRoughnessTexture;
#endif
#ifdef HAS_TEXTURE_u_occlusionTexture
uniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;
#endif
#ifdef HAS_TEXTURE_u_normalTexture
uniform sampler2D u_normalTexture;
#endif
#ifdef HAS_TEXTURE_u_emissionTexture
uniform sampler2D u_emissionTexture;
#endif
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
#ifdef TERRAIN_FRAGMENT_OCCLUSION
in highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;
#ifdef DEPTH_D24
highp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}
#else
highp float unpack_depth_rgba(highp vec4 rgba_depth)
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}
#endif
bool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;
#ifdef FLIP_Y
coord.y=1.0-coord.y;
#endif
#ifdef DEPTH_D24
highp float depth=unpack_depth(texture(u_depthTexture,coord).r);
#else
highp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));
#endif
return v_depth > depth+0.0005;}
#endif
#define saturate(_x) clamp(_x,0.,1.)
vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)
{
#ifdef LIGHTING_3D_MODE
vec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;
#ifdef RENDER_SHADOWS
lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);
#else
lighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));
#endif
return apply_lighting(albedo,transformed_normal,lighting_factor);
#else
vec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;
#endif
}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;
#ifdef HAS_ATTRIBUTE_a_color_3f
albedo*=vec4(color_3f,1.0);
#endif
#ifdef HAS_ATTRIBUTE_a_pbr
#else
#ifdef HAS_ATTRIBUTE_a_color_4f
albedo*=color_4f;
#endif
#endif
#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)
vec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}
#ifdef UNPREMULT_TEXTURE_IN_SHADER
if(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;
#endif
if(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}
#endif
vec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);
#ifdef APPLY_LUT_ON_GPU
color=applyLUT(u_lutTexture,color);
#endif
return color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {
#ifdef HAS_TEXTURE_u_normalTexture
highp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;
#ifdef FLIP_Y
T=-T;B=-B;
#endif
highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;
#else
return mat3(1.0);
#endif
}highp vec3 getNormal(){highp vec3 n;
#ifdef HAS_ATTRIBUTE_a_normal_3f
n=normalize(normal_3f);
#else
highp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));
#ifdef FLIP_Y
n=normalize(cross(fdx,fdy));
#else
n=normalize(cross(fdx,fdy))*-1.0;
#endif
#endif
#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
vec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);
#endif
return n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;
#ifdef HAS_ATTRIBUTE_a_pbr
mat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;
#endif
#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
vec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;
#endif
const float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)
{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)
{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)
{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)
{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)
{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)
{
#ifdef LIGHTING_3D_MODE
return mat.diffuseColor;
#else
return mat.diffuseColor/PI;
#endif
}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)
{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)
{vec3 env_light=vec3(0.65,0.65,0.65);
#ifdef LIGHTING_3D_MODE
float ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;
#endif
vec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)
{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;
#ifdef RENDER_SHADOWS
lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);
#else
lighting_factor=NdotL;
#endif
vec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;
#if !defined(LIGHTING_3D_MODE)
const vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);
#endif
color*=intensityFactor;return color;}void main() {
#ifdef TERRAIN_FRAGMENT_OCCLUSION
if (isOccluded()) {discard;}
#endif
vec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;
#ifdef LIGHTING_3D_MODE
lightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;
#endif
vec4 finalColor;
#ifdef DIFFUSE_SHADED
vec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);
#ifdef HAS_TEXTURE_u_occlusionTexture
float ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;
#endif
finalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;
#else
Material mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;
#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
#ifdef OCCLUSION_TEXTURE_TRANSFORM
vec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;
#else
vec2 uv=uv_2f;
#endif
ao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;
#endif
vec4 emissive=u_emissiveFactor;
#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
emissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);
#endif
#ifdef APPLY_LUT_ON_GPU
float emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;
#endif
color+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;
#ifdef HAS_ATTRIBUTE_a_pbr
float resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb;
#ifdef APPLY_LUT_ON_GPU
color_mix=applyLUT(u_lutTexture,color_mix);
#endif
color=mix(color,color_mix,min(1.0,resEmission));
#ifdef HAS_ATTRIBUTE_a_color_4f
float distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);
#endif
#endif
vec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);
#endif
#ifdef FOG
finalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));
#endif
#ifdef RENDER_CUTOFF
finalColor*=v_cutoff_opacity;
#endif
#ifdef INDICATOR_CUTOUT
finalColor=applyCutout(finalColor,v_position_height.w);
#endif
#ifdef FEATURE_CUTOUT
finalColor=apply_feature_cutout(finalColor,gl_FragCoord);
#endif
glFragColor=finalColor;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
in vec3 a_pos_3f;
#pragma mapbox: define-attribute highp vec3 normal_3f
#pragma mapbox: define-attribute highp vec2 uv_2f
#pragma mapbox: define-attribute highp vec3 color_3f
#pragma mapbox: define-attribute highp vec4 color_4f
#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr
#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength
uniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;
#ifdef INSTANCED_ARRAYS
in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;
#else
uniform highp mat4 u_normal_matrix;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows;
#endif
out vec4 v_position_height;out lowp vec4 v_color_mix;
#ifdef TERRAIN_FRAGMENT_OCCLUSION
out highp float v_depth;
#endif
#ifdef HAS_ATTRIBUTE_a_pbr
out lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;
#endif
vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {
#pragma mapbox: initialize-attribute highp vec3 normal_3f
#pragma mapbox: initialize-attribute highp vec2 uv_2f
#pragma mapbox: initialize-attribute highp vec3 color_3f
#pragma mapbox: initialize-attribute highp vec4 color_4f
#pragma mapbox: initialize-attribute-custom highp vec4 pbr
#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength
highp mat4 normal_matrix;
#ifdef INSTANCED_ARRAYS
normal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);
#else
normal_matrix=u_normal_matrix;
#endif
vec3 local_pos;mat3 rs;
#ifdef MODEL_POSITION_ON_GPU
vec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;
#else
local_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);
#endif
v_position_height.w=a_pos_3f.z;
#ifdef HAS_ATTRIBUTE_a_pbr
vec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;
#endif
#ifdef FOG
v_fog_pos=fog_position(local_pos);
#endif
#ifdef RENDER_CUTOFF
v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
#endif
#ifdef TERRAIN_FRAGMENT_OCCLUSION
v_depth=gl_Position.z/gl_Position.w;
#ifdef CLIP_ZERO_TO_ONE
v_depth=-1.0+2.0*v_depth;
#endif
#endif
#ifdef HAS_ATTRIBUTE_a_normal_3f
#ifdef MODEL_POSITION_ON_GPU
float x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);
#else
normal_3f=vec3(normal_matrix*vec4(normal_3f,0));
#endif
#endif
#ifdef HAS_ATTRIBUTE_a_pbr
#ifdef HAS_ATTRIBUTE_a_color_4f
v_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);
#endif
#endif
#ifdef RENDER_SHADOWS
vec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);
#ifdef NORMAL_OFFSET
#ifdef HAS_ATTRIBUTE_a_normal_3f
#ifdef MODEL_POSITION_ON_GPU
vec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();
#else
vec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();
#endif
#endif
#endif
v_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;
#endif
}`),modelDepth:Jr(`in highp float v_depth;void main() {
#ifndef DEPTH_TEXTURE
glFragColor=pack_depth(v_depth);
#endif
}`,`in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;
#ifdef MODEL_POSITION_ON_GPU
#ifdef INSTANCED_ARRAYS
in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;
#else
uniform highp mat4 u_instance;
#endif
uniform highp mat4 u_node_matrix;
#endif
void main() {
#ifdef MODEL_POSITION_ON_GPU
highp mat4 instance;
#ifdef INSTANCED_ARRAYS
instance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);
#else
instance=u_instance;
#endif
vec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden);
#else
gl_Position=u_matrix*vec4(a_pos_3f,1);
#endif
v_depth=gl_Position.z/gl_Position.w;}`),stars:Jr(`in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)
{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}`,`
in vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}`),snowParticle:Jr("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}",`
in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture;
uniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius;
uniform float u_horizontalOscillationRate;
uniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+
localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}`),rainParticle:Jr("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}",`
in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture;
uniform float u_velocity;
uniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize;
pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+
localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}`),vignette:Jr("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:Jr("uniform vec4 u_color;void main() {glFragColor=u_color;}",`#include "_prelude_terrain.vertex.glsl"
in highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;
#ifdef TERRAIN
float e=elevation(world_pos.xy);world_pos.z+=e;
#endif
vec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}`)};function Sc(f,n){const l=f.split(`
`);for(let p of l){if(p=p.trimStart(),p[0]!=="#"||!p.includes("if")||p.startsWith("#endif"))continue;const y=p.match(b_);if(y)for(const x of y)ou.has(x)||n.add(x)}}function Jr(f,n){const l=new Set,p=[],y=[];f=f.replace(Ih,(b,T)=>(y.push(T),"")),n=n.replace(Ih,(b,T)=>(p.push(T),""));let x=new Set(au);Sc(f,x),Sc(n,x);for(const b of[...p,...y])_p[b]||(_p[b]=new Set,Sc(bc[b],_p[b])),x=new Set([...x,..._p[b]]);return{fragmentSource:f=f.replace(ol,(b,T,A,M,D)=>(l.add(D),T==="define"?`
#ifndef HAS_UNIFORM_u_${D}
in ${A} ${M} ${D};
#else
uniform ${A} ${M} u_${D};
#endif
`:T==="initialize"?`
#ifdef HAS_UNIFORM_u_${D}
${A} ${M} ${D} = u_${D};
#endif
`:T==="define-attribute"?`
#ifdef HAS_ATTRIBUTE_a_${D}
in ${A} ${M} ${D};
#endif
`:T==="initialize-attribute"?"":void 0)),vertexSource:n=n.replace(ol,(b,T,A,M,D)=>{const N=`MATERIAL_ATTRIBUTE_OFFSET_${D}`,B=M==="float"?"vec2":M,j=`GET_ATTRIBUTE_${B}(a_${D}, materialInfo, ${N})`,H=D.match(/color/)?"color":B;return T==="define-attribute-vertex-shader-only"?`
#ifdef HAS_ATTRIBUTE_a_${D}
in ${A} ${M} a_${D};
#endif
`:l.has(D)?T==="define"?`
#ifndef HAS_UNIFORM_u_${D}
uniform lowp float u_${D}_t;
#if !defined(${N})
in ${A} ${B} a_${D};
#endif
out ${A} ${M} ${D};
#else
uniform ${A} ${M} u_${D};
#endif
`:T==="initialize"?H==="vec4"?`
#ifndef HAS_UNIFORM_u_${D}
${D} = a_${D};
#else
${A} ${M} ${D} = u_${D};
#endif
`:`
#if !defined(HAS_UNIFORM_u_${D})
#ifdef ${N}
${D} = unpack_mix_${H}(${j}, u_${D}_t);
#else
${D} = unpack_mix_${H}(a_${D}, u_${D}_t);
#endif
#else
${A} ${M} ${D} = u_${D};
#endif
`:T==="define-attribute"?`
#ifdef HAS_ATTRIBUTE_a_${D}
in ${A} ${M} a_${D};
out ${A} ${M} ${D};
#endif
`:T==="initialize-attribute"?`
#ifdef HAS_ATTRIBUTE_a_${D}
${D} = a_${D};
#endif
`:void 0:T==="define"?`
#ifndef HAS_UNIFORM_u_${D}
uniform lowp float u_${D}_t;
#if !defined(${N})
in ${A} ${B} a_${D};
#endif
#else
uniform ${A} ${M} u_${D};
#endif
`:T==="define-instanced"?H==="mat4"?`
#ifdef INSTANCED_ARRAYS
in vec4 a_${D}0;
in vec4 a_${D}1;
in vec4 a_${D}2;
in vec4 a_${D}3;
#else
uniform ${A} ${M} u_${D};
#endif
`:`
#ifdef INSTANCED_ARRAYS
in ${A} ${B} a_${D};
#else
uniform ${A} ${M} u_${D};
#endif
`:T==="initialize-attribute-custom"?`
#ifdef HAS_ATTRIBUTE_a_${D}
${A} ${M} ${D} = a_${D};
#endif
`:H==="vec4"?`
#ifndef HAS_UNIFORM_u_${D}
#ifdef ${N}
${A} ${M} ${D} = ${j};
#else
${A} ${M} ${D} = a_${D};
#endif
#else
${A} ${M} ${D} = u_${D};
#endif
`:`
#ifndef HAS_UNIFORM_u_${D}
#ifdef ${N}
${A} ${M} ${D} = unpack_mix_${H}(${j}, u_${D}_t);
#else
${A} ${M} ${D} = unpack_mix_${H}(a_${D}, u_${D}_t);
#endif
#else
${A} ${M} ${D} = u_${D};
#endif
`}),usedDefines:x,vertexIncludes:p,fragmentIncludes:y}}class ES{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(n,l,p,y,x,b,T,A){this.context=n;let M=this.boundPaintVertexBuffers.length!==y.length;for(let N=0;!M&&N<y.length;N++)this.boundPaintVertexBuffers[N]!==y[N]&&(M=!0);let D=this.boundDynamicVertexBuffers.length!==T.length;for(let N=0;!D&&N<T.length;N++)this.boundDynamicVertexBuffers[N]!==T[N]&&(D=!0);if(!this.vao||this.boundProgram!==l||this.boundLayoutVertexBuffer!==p||M||D||this.boundIndexBuffer!==x||this.boundVertexOffset!==b)this.freshBind(l,p,y,x,b,T,A);else{n.bindVertexArrayOES.set(this.vao);for(const N of T)N&&(N.bind(),A&&N.instanceCount&&N.setVertexAttribDivisor(n.gl,l,A));x&&x.dynamicDraw&&x.bind()}}freshBind(n,l,p,y,x,b,T){const A=this.context,M=A.gl;this.vao&&this.destroy(),this.vao=A.gl.createVertexArray(),A.bindVertexArrayOES.set(this.vao),this.boundProgram=n,this.boundLayoutVertexBuffer=l,this.boundPaintVertexBuffers=p,this.boundIndexBuffer=y,this.boundVertexOffset=x,this.boundDynamicVertexBuffers=b,l.enableAttributes(M,n),l.bind(),l.setVertexAttribPointers(M,n,x);for(const D of p)D.enableAttributes(M,n),D.bind(),D.setVertexAttribPointers(M,n,x);for(const D of b)D&&(D.enableAttributes(M,n),D.bind(),D.setVertexAttribPointers(M,n,x),T&&D.instanceCount&&D.setVertexAttribDivisor(M,n,T));y&&y.bind()}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function kS(f,n){const l=Math.pow(2,n.canonical.z),p=n.canonical.y;return[new o.ae(0,p/l).toLngLat().lat,new o.ae(0,(p+1)/l).toLngLat().lat]}function AS(f,n,l,p,y,x,b){const T=f.context,A=T.gl,M=l.hillshadeFBO;if(!M)return;f.prepareDrawTile();const D=f.isTileAffectedByFog(n),N=[];f.terrain&&f.terrain.renderingToTexture&&f.emissiveMode==="mrt-fallback"&&N.push("USE_MRT1");const B=f.getOrCreateProgram("hillshade",{overrideFog:D,defines:N});T.activeTexture.set(A.TEXTURE0),A.bindTexture(A.TEXTURE_2D,M.colorAttachment0.get());const j=((J,ae,de,ce)=>{const Se=de.paint.get("hillshade-shadow-color"),ye=de.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",we=de.paint.get("hillshade-highlight-color"),_e=de.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",pe=de.paint.get("hillshade-accent-color"),Te=de.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",De=de.paint.get("hillshade-emissive-strength");let Me=o.an(de.paint.get("hillshade-illumination-direction"));if(de.paint.get("hillshade-illumination-anchor")==="viewport")Me-=J.transform.angle;else if(J.style&&J.style.enable3dLights()&&J.style.directionalLight){const He=J.style.directionalLight.properties.get("direction"),et=o.d4(He.x,He.y,He.z);Me=o.an(et[1])}const Ge=!J.options.moving;return{u_matrix:ce||J.transform.calculateProjMatrix(ae.tileID.toUnwrapped(),Ge),u_image:0,u_latrange:kS(0,ae.tileID),u_light:[de.paint.get("hillshade-exaggeration"),Me],u_shadow:Se.toPremultipliedRenderColor(ye?null:de.lut),u_highlight:we.toPremultipliedRenderColor(_e?null:de.lut),u_emissive_strength:De,u_accent:pe.toPremultipliedRenderColor(Te?null:de.lut)}})(f,l,p,f.terrain?n.projMatrix:null);f.uploadCommonUniforms(T,B,n.toUnwrapped());const{tileBoundsBuffer:H,tileBoundsIndexBuffer:G,tileBoundsSegments:Q}=f.getTileBoundsBuffers(l);B.draw(f,A.TRIANGLES,y,x,b,fr.disabled,j,p.id,H,G,Q)}function T_(f,n,l){if(!n.needsDEMTextureUpload)return;const p=f.context,y=p.gl;p.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||f.getTileTexture(l.stride);const x=l.getPixels();n.demTexture?n.demTexture.update(x,{premultiply:!1}):n.demTexture=new o.T(p,x,y.R32F,{premultiply:!1}),n.needsDEMTextureUpload=!1}function CS(f,n,l){const p=f.context,y=p.gl;if(!n.dem)return;const x=n.dem;if(p.activeTexture.set(y.TEXTURE1),T_(f,n,x),!n.demTexture)return;n.demTexture.bind(y.NEAREST,y.CLAMP_TO_EDGE);const b=x.dim;p.activeTexture.set(y.TEXTURE0);let T=n.hillshadeFBO;if(!T){const
This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const N=this.getScaledDemTileSize();this.sourceCache.update(l,N,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,D(),this._initializing=!0),D(),l.updateElevation(!0,p),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(l),this._emptyDEMTextureDirty=!0,this._previousZoom=l.zoom}else this._disable()}calculateExaggeration(n){if(this._attenuationRange&&n.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(n.zoom);const l=this._previousCameraAltitude,p=n.getFreeCameraOptions().position.z/n.pixelsPerMeter*n.worldSize;this._previousCameraAltitude=p;const y=l!=null?p-l:Number.MAX_VALUE;if(Math.abs(y)<2)return this._exaggeration;const x=n.zoom,b=this._style.terrain;if(!this._previousUpdateTimestamp)return b.getExaggeration(x);let T=x-this._previousZoom;const A=this._previousUpdateTimestamp;let M=x;this._evaluationZoom!=null&&(M=this._evaluationZoom,Math.abs(x-M)>.5&&(T=.5*(x-M+T)),T*y<0&&(M+=T)),this._evaluationZoom=M;const D=b.getExaggeration(M),N=D===b.getExaggeration(Math.max(0,M-.1));if(N&&Math.abs(D-this._exaggeration)<.01)return D;let B=Math.min(.1,.00375*(this._updateTimestamp-A));return(N||D<.1||Math.abs(T)<1e-4)&&(B=Math.min(.2,4*B)),o.ak(this._exaggeration,D,B)}resetTileLookupCache(n){this._findCoveringTileCache[n]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(n){n.dataType==="source"&&n.coord?this._clearRenderCacheForTile(n.sourceCacheId,n.coord):n.dataType==="style"&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const n in this._style._mergedSourceCaches)this._style._mergedSourceCaches[n].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(n=>n.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const n=2*this.proxySourceCache.getSource().tileSize;return[n,n]}set useVertexMorphing(n){this._useVertexMorphing=n}updateTileBinding(n){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const l=this.proxySourceCache,p=this.painter.transform;this._initializing&&(this._initializing=p._centerAltitude===0&&this.getAtPointOrZero(o.ae.fromLngLat(p.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const y=this.proxyCoords=l.getIds().map(A=>{const M=l.getTileByID(A).tileID;return M.projMatrix=p.calculateProjMatrix(M.toUnwrapped()),M});(function(A,M){const D=M.transform.pointCoordinate(M.transform.getCameraPoint()),N=new o.P(D.x,D.y);A.sort((B,j)=>{if(j.overscaledZ-B.overscaledZ)return j.overscaledZ-B.overscaledZ;const H=new o.P(B.canonical.x+(1<<B.canonical.z)*B.wrap,B.canonical.y),G=new o.P(j.canonical.x+(1<<j.canonical.z)*j.wrap,j.canonical.y),Q=N.mult(1<<B.canonical.z);return Q.x-=.5,Q.y-=.5,Q.distSqr(H)-Q.distSqr(G)})})(y,this.painter);const x=this.proxyToSource||{};this.proxyToSource={},y.forEach(A=>{this.proxyToSource[A.key]={}}),this.terrainTileForTile={};const b=this._style._mergedSourceCaches;for(const A in b){const M=b[A];if(!M.used||(M!==this.sourceCache&&this.resetTileLookupCache(M.id),this._set
${(y?y.defines():[]).concat(b.map(G=>`#define ${G}`)).join(`
`)}`,M=[A,TS];for(const G of p.fragmentIncludes)M.push(bc[G]);M.push(p.fragmentSource);const D=M.join(`
`),N=[A,J0];for(const G of p.vertexIncludes)N.push(bc[G]);this.forceManualRenderingForInstanceIDShaders=n.forceManualRenderingForInstanceIDShaders&&p.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&N.push("uniform int u_instanceID;"),N.push(p.vertexSource);let B=N.join(`
`);this.forceManualRenderingForInstanceIDShaders&&(B=B.replaceAll("gl_InstanceID","u_instanceID"));const j=T.createShader(T.FRAGMENT_SHADER);if(T.isContextLost())return void(this.failedToCreate=!0);T.shaderSource(j,D),T.compileShader(j),T.attachShader(this.program,j);const H=T.createShader(T.VERTEX_SHADER);T.isContextLost()?this.failedToCreate=!0:(T.shaderSource(H,B),T.compileShader(H),T.attachShader(this.program,H),this.attributes={},T.linkProgram(this.program),T.deleteShader(H),T.deleteShader(j),this.fixedUniforms=x(n),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=y?y.getUniforms(n):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(G=>({u_instanceID:new o.ch(G)}))(n)),(b.includes("TERRAIN")||l.includes("symbol")||l.includes("circle"))&&(this.terrainUniforms=(G=>({u_dem:new o.ch(G),u_dem_prev:new o.ch(G),u_dem_tl:new o.ck(G),u_dem_scale:new o.cj(G),u_dem_tl_prev:new o.ck(G),u_dem_scale_prev:new o.cj(G),u_dem_size:new o.cj(G),u_dem_lerp:new o.cj(G),u_exaggeration:new o.cj(G),u_depth:new o.ch(G),u_depth_size_inv:new o.ck(G),u_depth_range_unpack:new o.ck(G),u_occluder_half_size:new o.cj(G),u_occlusion_depth_offset:new o.cj(G),u_meter_to_dem:new o.cj(G),u_label_plane_matrix_inv:new o.cl(G)}))(n)),b.includes("GLOBE")&&(this.globeUniforms=(G=>({u_tile_tl_up:new o.ci(G),u_tile_tr_up:new o.ci(G),u_tile_br_up:new o.ci(G),u_tile_bl_up:new o.ci(G),u_tile_up_scale:new o.cj(G)}))(n)),b.includes("FOG")&&(this.fogUniforms=(G=>({u_fog_matrix:new o.cl(G),u_fog_range:new o.ck(G),u_fog_color:new o.d3(G),u_fog_horizon_blend:new o.cj(G),u_fog_vertical_limit:new o.ck(G),u_fog_temporal_offset:new o.cj(G),u_frustum_tl:new o.ci(G),u_frustum_tr:new o.ci(G),u_frustum_br:new o.ci(G),u_frustum_bl:new o.ci(G),u_globe_pos:new o.ci(G),u_globe_radius:new o.cj(G),u_globe_transition:new o.cj(G),u_is_globe:new o.ch(G),u_viewport:new o.ck(G)}))(n)),b.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(G=>({u_cutoff_params:new o.d3(G)}))(n)),b.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(G=>({u_lighting_ambient_color:new o.ci(G),u_lighting_directional_dir:new o.ci(G),u_lighting_directional_color:new o.ci(G),u_ground_radiance:new o.ci(G)}))(n)),b.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(G=>({u_light_matrix_0:new o.cl(G),u_light_matrix_1:new o.cl(G),u_fade_range:new o.ck(G),u_shadow_normal_offset:new o.ci(G),u_shadow_intensity:new o.cj(G),u_shadow_texel_size:new o.cj(G),u_shadow_map_resolution:new o.cj(G),u_shadow_direction:new o.ci(G),u_shadow_bias:new o.ci(G),u_shadowmap_0:new o.ch(G),u_shadowmap_1:new o.ch(G)}))(n)))}getAttributeLocation(n,l){let p=this.attributes[l];return p===void 0&&(p=this.attributes[l]=n.getAttribLocation(this.program,l)),p}setTerrainUniformValues(n,l){if(!this.terrainUniforms)return;const p=this.terrainUniforms;if(!this.failedToCreate){n.program.set(this.program);for(const y in l)p[y]&&p[y].set(this.program,y,l[y])}}setGlobeUniformValues(n,l){if(!this.globeUniforms)return;const p=this.globeUniforms;if(!this.failedToCreate){n.program.set(this.program);for(const y in l)p[y]&&p[y].set(this.program,y,l[y])}}setFogUniformValues(n,l){if(!this.fogUniforms)return;const p=this.fogUniforms;if(!this.failedToCreate){n.program.set(this.program);for(const y in l)p[y].set(this.program,y,l[y])}}setCutoffUniformValues(n,l){if(!this.cutoffUniforms)return;const p=this.cutoffUniforms;if(!this.failedToCreate){n.program.set(this.program);for(const y in l)p[y].set(this.program,y,l[y])}}setLightsUniformValues(n,l){if(!this.lightsUniforms)return;const p=this.lightsUniforms;if(!this.failedToCreate){n.program.set(this.program);for(const y in l)p[y].set(this.program,y,l[y])}}setShadowUniformValues(n,l){if(this.failedToCreate||!this.shadowUniforms)return;const p=this.shadowUniforms;n.program.set(this.program);for(const y in l)p[y].set(this.program,y,l[y])}_drawDebugWireframe(n,l,p,y,x,b,T,A,M,D){const N=n.options.wireframe;if(N.terrain===!1&&N.layers2D===!1&&N.layers3D===!1)return;const B=n.context;if(!(!(!N.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!N.layers2D||
translate(${n.x}px,${n.y}px)
${Vs[this._anchor]}
${this._calculateXYTransform()} ${this._calculateZTransform()}
translate(${l.x}px,${l.y}px)
`}_calculateXYTransform(){const n=this._pos,l=this._map,p=this.getPitchAlignment();if(!l||!n||p!=="map")return"";if(!l._showingGlobe()){const A=l.getPitch();return A?`rotateX(${A}deg)`:""}const y=o.cX(o.f6(l.transform,this._lngLat)),x=n.sub(o.f7(l.transform)),b=Math.abs(x.x)+Math.abs(x.y);if(b===0)return"";const T=y/b;return`rotateX(${-x.y*T}deg) rotateY(${x.x*T}deg)`}_calculateZTransform(){const n=this._pos,l=this._map;if(!l||!n)return"";let p=0;const y=this.getRotationAlignment();if(y==="map")if(l._showingGlobe()){const x=l.project(new o.aT(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),b=l.project(new o.aT(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(x);p=o.cX(Math.atan2(b.y,b.x))-90}else p=-l.getBearing();else if(y==="horizon"){const x=o.ah(4,6,l.getZoom()),b=o.f7(l.transform);b.y+=x*l.transform.height;const T=n.sub(b),A=o.cX(Math.atan2(T.y,T.x));p=(A>90?A-270:A+90)*(1-x)}return p+=this._rotation,p?`rotateZ(${p}deg)`:""}_update(n){cancelAnimationFrame(this._updateFrameId);const l=this._map;l&&(l.transform.renderWorldCopies&&(this._lngLat=hy(this._lngLat,this._pos,l.transform)),this._pos=l.project(this._lngLat,this._altitude),n===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),l._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(l._showingGlobe()||l.getTerrain()||l.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(n){return this._offset=o.P.convert(n),this._update(),this}addClassName(n){return this._element.classList.add(n),this}removeClassName(n){return this._element.classList.remove(n),this}toggleClassName(n){return this._element.classList.toggle(n)}_onMove(n){const l=this._map;if(!l)return;const p=this._pointerdownPos,y=this._positionDelta;if(p&&y){if(!this._isDragging){const x=this._clickTolerance||l._clickTolerance;if(n.point.dist(p)<x)return;this._isDragging=!0}this._pos=n.point.sub(y),this._lngLat=l.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new o.z("dragstart"))),this.fire(new o.z("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const n=this._map;n&&(n.off("mousemove",this._onMove),n.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new o.z("dragend")),this._state="inactive"}_addDragHandler(n){const l=this._map,p=this._pos;l&&p&&this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(p),this._pointerdownPos=n.point,this._state="pending",l.on("mousemove",this._onMove),l.on("touchmove",this._onMove),l.once("mouseup",this._onUp),l.once("touchend",this._onUp))}setDraggable(n){this._draggable=!!n;const l=this._map;return l&&(n?(l.on("mousedown",this._addDragHandler),l.on("touchstart",this._addDragHandler)):(l.off("mousedown",this._addDragHandler),l.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(n){return this._rotation=n||_a.rotation,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(n){return this._rotationAlignment=n||_a.rotationAlignment,this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(n){return this._pitchAlignment=n||_a.pitchAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(n){return this._occludedOpacity=n||_a.occludedOpacity,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const JS={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyC
must be that same as the previous version of the image
(${p.data.width}, ${p.data.height})`)));const A=!(n instanceof HTMLImageElement||ImageBitmap&&n instanceof ImageBitmap);let M=!1;p.usvg?(p.data=new o.q({width:x,height:b},new Uint8Array(T)),p.usvg=!1,p.icon=void 0,M=!0):p.data.replace(T,A),this.style.updateImage(l,p,M)}hasImage(f){return f?!!this.style&&!!this.style.getImage(o.I.from(f)):(this.fire(new o.y(new Error("Missing required image id"))),!1)}removeImage(f){this.style.removeImage(o.I.from(f))}loadImage(f,n){o.n(this._requestManager.transformRequest(f,o.R.Image),(l,p)=>{n(l,p instanceof HTMLImageElement?o.o.getImageData(p):p)})}listImages(){return this.style.listImages().map(f=>f.name)}addModel(f,n){this._lazyInitEmptyStyle(),this.style.addModel(f,n)}hasModel(f){return f?this.style.hasModel(f):(this.fire(new o.y(new Error("Missing required model id"))),!1)}removeModel(f){this.style.removeModel(f)}listModels(){return this.style.listModels()}addLayer(f,n){return this._isValidId(f.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(f,n),this._update(!0)):this}getSlot(f){const n=this.getLayer(f);return n&&n.slot||null}setSlot(f,n){return this.style.setSlot(f,n),this.style.mergeLayers(),this._update(!0)}addImport(f,n){return this.style.addImport(f,n).catch(l=>this.fire(new o.y(new Error("Failed to add import",l)))),this}updateImport(f,n){return typeof n!="string"&&n.id!==f?(this.removeImport(f),this.addImport(n)):(this.style.updateImport(f,n),this._update(!0))}removeImport(f){return this.style.removeImport(f),this}moveImport(f,n){return this.style.moveImport(f,n),this._update(!0)}moveLayer(f,n){return this._isValidId(f)?(this.style.moveLayer(f,n),this._update(!0)):this}removeLayer(f){return this._isValidId(f)?(this.style.removeLayer(f),this._update(!0)):this}getLayer(f){if(!this._isValidId(f))return null;const n=this.style.getOwnLayer(f);return n?n.type==="custom"?n.implementation:n.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(f,n,l){return this._isValidId(f)?(this.style.setLayerZoomRange(f,n,l),this._update(!0)):this}setFilter(f,n,l={}){return this._isValidId(f)?(this.style.setFilter(f,n,l),this._update(!0)):this}getFilter(f){return this._isValidId(f)?this.style.getFilter(f):null}setPaintProperty(f,n,l,p={}){return this._isValidId(f)?(this.style.setPaintProperty(f,n,l,p),this._update(!0)):this}getPaintProperty(f,n){return this._isValidId(f)?this.style.getPaintProperty(f,n):null}setLayoutProperty(f,n,l,p={}){return this._isValidId(f)?(this.style.setLayoutProperty(f,n,l,p),this._update(!0)):this}getLayoutProperty(f,n){return this._isValidId(f)?this.style.getLayoutProperty(f,n):null}setLayerProperty(f,n,l,p={}){return this._isValidId(f)?(n==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(f,n,l,p),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(f){return this.style.setGlyphsUrl(f),this._update(!0)}getSchema(f){return this.style.getSchema(f)}setSchema(f,n){return this.style.setSchema(f,n),this._update(!0)}getConfig(f){return this.style.getConfig(f)}setConfig(f,n){return this.style.setConfig(f,n),this._update(!0)}getConfigProperty(f,n){return this.style.getConfigProperty(f,n)}setConfigProperty(f,n,l){return this.style.setConfigProperty(f,n,l),this._update(!0)}getFeaturesetDescriptors(f){return this.style.getFeaturesetDescriptors(f)}setLights(f){if(this._lazyInitEmptyStyle(),f&&f.length===1&&f[0].type==="flat"){const n=f[0];n.properties?this.style.setFlatLight(n.properties,n.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(f),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const f=this.style.getLights()||[];return f.length===0&&f.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),f}setLight(f,n={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:f}])}getLight(){return console.log("The `map.getLight` function is deprecated, p
Caused by: ${(V=k==null?void 0:k.name)!==null&&V!==void 0?V:"Error"}: ${Y}`,Z&&(o+=` (${Z})`),k!=null&&k.stack&&(o+=`
${k.stack}`)}else{var $;o=($=_==null?void 0:_.stack)!==null&&$!==void 0?$:""}return{error:{message:`${(w=_==null?void 0:_.name)!==null&&w!==void 0?w:"FetchError"}: ${_==null?void 0:_.message}`,details:o,hint:"",code:""},data:null,count:null,status:0,statusText:""}})),h.then(t,e)}returns(){return this}overrideTypes(){return this}},zre=class extends Ore{select(t){let e=!1;const s=(t??"*").split("").map(u=>/\s/.test(u)&&!e?"":(u==='"'&&(e=!e),u)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:s,foreignTable:u,referencedTable:h=u}={}){const _=h?`${h}.order`:"order",w=this.url.searchParams.get(_);return this.url.searchParams.set(_,`${w?`${w},`:""}${t}.${e?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:s=e}={}){const u=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(u,`${t}`),this}range(t,e,{foreignTable:s,referencedTable:u=s}={}){const h=typeof u>"u"?"offset":`${u}.offset`,_=typeof u>"u"?"limit":`${u}.limit`;return this.url.searchParams.set(h,`${t}`),this.url.searchParams.set(_,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:t=!1,verbose:e=!1,settings:s=!1,buffers:u=!1,wal:h=!1,format:_="text"}={}){var w;const o=[t?"analyze":null,e?"verbose":null,s?"settings":null,u?"buffers":null,h?"wal":null].filter(Boolean).join("|"),k=(w=this.headers.get("Accept"))!==null&&w!==void 0?w:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${_}; for="${k}"; options=${o};`),_==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const h3=new RegExp("[,()]");var Km=class extends zre{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const s=Array.from(new Set(e)).map(u=>typeof u=="string"&&h3.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(t,`in.(${s})`),this}notIn(t,e){const s=Array.from(new Set(e)).map(u=>typeof u=="string"&&h3.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(t,`not.in.(${s})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.
import ws from "ws"
new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let s=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(s+=`
Suggested solution: ${e.workaround}`),new Error(s)}static createWebSocket(e,s){const u=this.getWebSocketConstructor();return new u(e,s)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const jre="2.89.0",Vre=`realtime-js/${jre}`,eV="1.0.0",Ure="2.0.0",f3=eV,bA=1e4,$re=1e3,Gre=100;var Od;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(Od||(Od={}));var Qs;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Qs||(Qs={}));var oc;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(oc||(oc={}));var SA;(function(t){t.websocket="websocket"})(SA||(SA={}));var _f;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(_f||(_f={}));class Hre{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,s){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return s(this._binaryEncodeUserBroadcastPush(e));let u=[e.join_ref,e.ref,e.topic,e.event,e.payload];return s(JSON.stringify(u))}_binaryEncodeUserBroadcastPush(e){var s;return this._isArrayBuffer((s=e.payload)===null||s===void 0?void 0:s.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var s,u;const h=(u=(s=e.payload)===null||s===void 0?void 0:s.payload)!==null&&u!==void 0?u:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,h)}_encodeJsonUserBroadcastPush(e){var s,u;const h=(u=(s=e.payload)===null||s===void 0?void 0:s.payload)!==null&&u!==void 0?u:{},w=new TextEncoder().encode(JSON.stringify(h)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,w)}_encodeUserBroadcastPush(e,s,u){var h,_;const w=e.topic,o=(h=e.ref)!==null&&h!==void 0?h:"",k=(_=e.join_ref)!==null&&_!==void 0?_:"",P=e.payload.event,O=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},F=Object.keys(O).length===0?"":JSON.stringify(O);if(k.length>255)throw new Error(`joinRef length ${k.length} exceeds maximum of 255`);if(o.length>255)throw new Error(`ref length ${o.length} exceeds maximum of 255`);if(w.length>255)throw new Error(`topic length ${w.length} exceeds maximum of 255`);if(P.length>255)throw new Error(`userEvent length ${P.length} exceeds maximum of 255`);if(F.length>255)throw new Error(`metadata length ${F.length} exceeds maximum of 255`);const V=this.USER_BROADCAST_PUSH_META_LENGTH+k.length+o.length+w.length+P.length+F.length,$=new ArrayBuffer(this.HEADER_LENGTH+V);let Y=new DataView($),Z=0;Y.setUint8(Z++,this.KINDS.userBroadcastPush),Y.setUint8(Z++,k.length),Y.setUint8(Z++,o.length),Y.setUint8(Z++,w.length),Y.setUint8(Z++,P.length),Y.setUint8(Z++,F.length),Y.setUint8(Z++,s),Array.from(k,te=>Y.setUint8(Z++,te.charCodeAt(0))),Array.from(o,te=>Y.setUint8(Z++,te.charCodeAt(0))),Array.from(w,te=>Y.setUint8(Z++,te.charCodeAt(0))),Array.from(P,te=>Y.setUint8(Z++,te.charCodeAt(0))),Array.from(F,te=>Y.setUint8(Z++,te.charCodeAt(0)));var se=new Uint8Array($.byteLength+u.byteLength);return se.set(new Uint8Array($),0),se.set(new Uint8Array(u),$.byteLength),se.buffer}decode(e,s){if(this._isArrayBuffer(e)){let u=this._binaryDecode(e);return s(u)}if(typeof e=="string"){const u=JSON.parse(e),[h,_,w,o,k]=u;return s({join_ref:h,ref:_,topic:w,event:o,payload:k})}return s({})}_binaryDecode(e){const s=new DataView(e),u=s.getUint8(0),h=new TextDecoder;switch(u){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,s,h)}}_decodeUserBroadcast(e,s,u){const h=s.getUint8(1),_=s.getUint8(2),w=s.getUint8(3),o=s.getUint8(4);let k=this.HEADER_LENGTH+4;const P=u.decode(e.slice(k,k+h));k=k+h;const O=u.decode(e.slice(k,
addEventListener("message", (e) => {
if (e.data.event === "start") {
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
}
});`;class tne{constructor(e,s){var u;if(this.accessTokenValue=null,this.apiKey=null,this._manuallySetToken=!1,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=bA,this.transport=null,this.heartbeatIntervalMs=hb.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=vE,this.ref=0,this.reconnectTimer=null,this.vsn=f3,this.logger=vE,this.conn=null,this.sendBuffer=[],this.serializer=new Hre,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=h=>h?(..._)=>h(..._):(..._)=>fetch(..._),!(!((u=s==null?void 0:s.params)===null||u===void 0)&&u.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=s.params.apikey,this.endPoint=`${e}/${SA.websocket}`,this.httpEndpoint=nV(e),this._initializeOptions(s),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(s==null?void 0:s.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=Nre.createWebSocket(this.endpointURL())}catch(e){this._setConnectionState("disconnected");const s=e.message;throw s.includes("Node.js")?new Error(`${s}
To use Realtime in Node.js, you need to provide a WebSocket implementation:
Option 1: Use Node.js 22+ which has native WebSocket support
Option 2: Install and provide the "ws" package:
npm install ws
import ws from "ws"
const client = new RealtimeClient(url, {
...options,
transport: ws
})`):new Error(`WebSocket not available: ${s}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:this.vsn}))}disconnect(e,s){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const u=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(u),this._setConnectionState("disconnected")},typeof this.conn.close=="function"&&(e?this.conn.close(e,s??""):this.conn.close()),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const s=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),s}async removeAllChannels(){const e=await Promise.all(this.channels.map(s=>s.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,s,u){this.logger(e,s,u)}connectionState(){switch(this.conn&&this.conn.readyState){case Od.connecting:return _f.Connecting;case Od.open:return _f.Open;case Od.closing:return _f.Closing;default:return _f.Closed}}isConnected(){return this.connectionState()===_f.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,s={config:{}}){const u=`realtime:${e}`,h=this.getChannels().find(_=>_.topic===u);if(h)return h;{const _=new pg(`realtime:${e}`,s,this);return this.channels.push(_),_}}push(e){const{topic:s,event:u,payload:h,ref:_}=e,w=()=>{this.encode(e,o=>{var k;(k=this.conn)===null||k===void 0||k.send(o)})};this.log("push",`${s} ${u} (${_})`,h),this.isConnected()?w():this.sendBuffer.push(w)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(s){this.log("error","error in heartbeat callback",s)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(s){this.log("error","error in heartbeat callback",s)}this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close($re,"heartbeat timeout"),setTimeout(()=>{var s;this.isConnected()||(s=this.reconnectTimer)===null||s===void 0||s.scheduleTimeout()},hb.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(s){this.log("error","error in heartbeat callback",s)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let s=this.channels.find(u=>u.topic===e&&(u._isJoined()||u._isJoining()));s&&(this.log("transport",`leaving duplicate topic "${e}"`),s.unsubscribe())}_remove(e){this.channels=this.channels.filter(s=>s.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,s=>{if(s.topic==="phoenix"&&s.event==="phx_reply")try{this.heartbeatCallback(s.payload.status==="ok"?"ok":"error")}catch(P){this.log("error","error in heartbeat callback",P)}s.ref&&s.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:u,event:h,payload:_,ref:w}=s,o=w?`(${w})`:"",k=_.status||"";this.log("receive",`${k} ${u} ${h} ${o}`.trim(),_),this.channels.filter(P=>P._isMember(u)).forEach(P=>P._trigger(h,_,w)),this._triggerStateCallbacks("message",s)})}_clearTimer(e){var s;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((s=this.reconnectTimer)===null||s===void 0||s.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),th
\r=`.split(""),Wne=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<b3.length;e+=1)t[b3[e].charCodeAt(0)]=-2;for(let e=0;e<M1.length;e+=1)t[M1[e].charCodeAt(0)]=e;return t})();function S3(t,e,s){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const u=e.queue>>e.queuedBits-6&63;s(M1[u]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const u=e.queue>>e.queuedBits-6&63;s(M1[u]),e.queuedBits-=6}}function uV(t,e,s){const u=Wne[t];if(u>-1)for(e.queue=e.queue<<6|u,e.queuedBits+=6;e.queuedBits>=8;)s(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(u===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function T3(t){const e=[],s=w=>{e.push(String.fromCodePoint(w))},u={utf8seq:0,codepoint:0},h={queue:0,queuedBits:0},_=w=>{Zne(w,u,s)};for(let w=0;w<t.length;w+=1)uV(t.charCodeAt(w),h,_);return e.join("")}function qne(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function Kne(t,e){for(let s=0;s<t.length;s+=1){let u=t.charCodeAt(s);if(u>55295&&u<=56319){const h=(u-55296)*1024&65535;u=(t.charCodeAt(s+1)-56320&65535|h)+65536,s+=1}qne(u,e)}}function Zne(t,e,s){if(e.utf8seq===0){if(t<=127){s(t);return}for(let u=1;u<6;u+=1)if(!(t>>7-u&1)){e.utf8seq=u;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&s(e.codepoint)}}function Tg(t){const e=[],s={queue:0,queuedBits:0},u=h=>{e.push(h)};for(let h=0;h<t.length;h+=1)uV(t.charCodeAt(h),s,u);return new Uint8Array(e)}function Xne(t){const e=[];return Kne(t,s=>e.push(s)),new Uint8Array(e)}function Tf(t){const e=[],s={queue:0,queuedBits:0},u=h=>{e.push(h)};return t.forEach(h=>S3(h,s,u)),S3(null,s,u),e.join("")}function Yne(t){return Math.round(Date.now()/1e3)+t}function Jne(){return Symbol("auth-callback")}const Co=()=>typeof window<"u"&&typeof document<"u",uf={tested:!1,writable:!1},dV=()=>{if(!Co())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(uf.tested)return uf.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),uf.tested=!0,uf.writable=!0}catch{uf.tested=!0,uf.writable=!1}return uf.writable};function Qne(t){const e={},s=new URL(t);if(s.hash&&s.hash[0]==="#")try{new URLSearchParams(s.hash.substring(1)).forEach((h,_)=>{e[_]=h})}catch{}return s.searchParams.forEach((u,h)=>{e[h]=u}),e}const hV=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),eie=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Xm=async(t,e,s)=>{await t.setItem(e,JSON.stringify(s))},df=async(t,e)=>{const s=await t.getItem(e);if(!s)return null;try{return JSON.parse(s)}catch{return s}},Ao=async(t,e)=>{await t.removeItem(e)};class mS{constructor(){this.promise=new mS.promiseConstructor((e,s)=>{this.resolve=e,this.reject=s})}}mS.promiseConstructor=Promise;function TE(t){const e=t.split(".");if(e.length!==3)throw new MA("Invalid JWT structure");for(let u=0;u<e.length;u++)if(!Nne.test(e[u]))throw new MA("JWT not in base64url format");return{header:JSON.parse(T3(e[0])),payload:JSON.parse(T3(e[1])),signature:Tg(e[2]),raw:{header:e[0],payload:e[1]}}}async function tie(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function rie(t,e){return new Promise((u,h)=>{(async()=>{for(let _=0;_<1/0;_++)try{const w=await t(_);if(!e(_,null,w)){u(w);return}}catch(w){if(!e(_,w)){h(w);return}}})()})}function nie(t){return("0"+t.toString(16)).substr(-2)}function iie(){const e=new Uint32Array(56);if(typeof crypto>"u"){const s="ABCDEFGHIJKLMNO
`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const $=pV(t.address),Y=O?`${O}://${u}`:u,Z=t.statement?`${t.statement}
`:"",se=`${Y} wants you to sign in with your Ethereum account:
${$}
${Z}`;let te=`URI: ${F}
Version: ${V}
Chain ID: ${s}${w?`
Nonce: ${w}`:""}
Issued At: ${_.toISOString()}`;if(h&&(te+=`
Expiration Time: ${h.toISOString()}`),o&&(te+=`
Not Before: ${o.toISOString()}`),k&&(te+=`
Request ID: ${k}`),P){let ee=`
Resources:`;for(const oe of P){if(!oe||typeof oe!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${oe}`);ee+=`
- ${oe}`}te+=ee}return`${se}
${te}`}class Hs extends Error{constructor({message:e,code:s,cause:u,name:h}){var _;super(e,{cause:u}),this.__isWebAuthnError=!0,this.name=(_=h??(u instanceof Error?u.name:void 0))!==null&&_!==void 0?_:"Unknown Error",this.code=s}}class R1 extends Hs{constructor(e,s){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s,message:e}),this.name="WebAuthnUnknownError",this.originalError=s}}function kie({error:t,options:e}){var s,u,h;const{publicKey:_}=e;if(!_)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Hs({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((s=_.authenticatorSelection)===null||s===void 0?void 0:s.requireResidentKey)===!0)return new Hs({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((u=_.authenticatorSelection)===null||u===void 0?void 0:u.userVerification)==="required")return new Hs({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((h=_.authenticatorSelection)===null||h===void 0?void 0:h.userVerification)==="required")return new Hs({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new Hs({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Hs({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return _.pubKeyCredParams.filter(o=>o.type==="public-key").length===0?new Hs({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Hs({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const w=window.location.hostname;if(mV(w)){if(_.rp.id!==w)return new Hs({message:`The RP ID "${_.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Hs({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(_.user.id.byteLength<1||_.user.id.byteLength>64)return new Hs({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new Hs({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Hs({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Aie({error:t,options:e}){const{publicKey:s}=e;if(!s)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Hs({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Hs({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const u=window.location.hostname;if(mV(u)){if(s.rpId!==u)return new Hs({message:`The RP ID "${s.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Hs({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Hs({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Hs({message:"a Non-Webauthn related erro
`);const Be=await he.signMessage(new TextEncoder().encode(Y),"utf8");if(!Be||!(Be instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");Z=Be}}try{const{data:se,error:te}=await _n(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:Y,signature:Tf(Z)},!((V=e.options)===null||V===void 0)&&V.captchaToken?{gotrue_meta_security:{captcha_token:($=e.options)===null||$===void 0?void 0:$.captchaToken}}:null),xform:Jl});if(te)throw te;if(!se||!se.session||!se.user){const ee=new Bm;return this._returnResult({data:{user:null,session:null},error:ee})}return se.session&&(await this._saveSession(se.session),await this._notifyAllSubscribers("SIGNED_IN",se.session)),this._returnResult({data:Object.assign({},se),error:te})}catch(se){if(Kr(se))return this._returnResult({data:{user:null,session:null},error:se});throw se}}async _exchangeCodeForSession(e){const s=await df(this.storage,`${this.storageKey}-code-verifier`),[u,h]=(s??"").split("/");try{if(!u&&this.flowType==="pkce")throw new Hne;const{data:_,error:w}=await _n(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:u},xform:Jl});if(await Ao(this.storage,`${this.storageKey}-code-verifier`),w)throw w;if(!_||!_.session||!_.user){const o=new Bm;return this._returnResult({data:{user:null,session:null,redirectType:null},error:o})}return _.session&&(await this._saveSession(_.session),await this._notifyAllSubscribers("SIGNED_IN",_.session)),this._returnResult({data:Object.assign(Object.assign({},_),{redirectType:h??null}),error:w})}catch(_){if(await Ao(this.storage,`${this.storageKey}-code-verifier`),Kr(_))return this._returnResult({data:{user:null,session:null,redirectType:null},error:_});throw _}}async signInWithIdToken(e){try{const{options:s,provider:u,token:h,access_token:_,nonce:w}=e,o=await _n(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:u,id_token:h,access_token:_,nonce:w,gotrue_meta_security:{captcha_token:s==null?void 0:s.captchaToken}},xform:Jl}),{data:k,error:P}=o;if(P)return this._returnResult({data:{user:null,session:null},error:P});if(!k||!k.session||!k.user){const O=new Bm;return this._returnResult({data:{user:null,session:null},error:O})}return k.session&&(await this._saveSession(k.session),await this._notifyAllSubscribers("SIGNED_IN",k.session)),this._returnResult({data:k,error:P})}catch(s){if(Kr(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOtp(e){var s,u,h,_,w;try{if("email"in e){const{email:o,options:k}=e;let P=null,O=null;this.flowType==="pkce"&&([P,O]=await Nm(this.storage,this.storageKey));const{error:F}=await _n(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:o,data:(s=k==null?void 0:k.data)!==null&&s!==void 0?s:{},create_user:(u=k==null?void 0:k.shouldCreateUser)!==null&&u!==void 0?u:!0,gotrue_meta_security:{captcha_token:k==null?void 0:k.captchaToken},code_challenge:P,code_challenge_method:O},redirectTo:k==null?void 0:k.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:F})}if("phone"in e){const{phone:o,options:k}=e,{data:P,error:O}=await _n(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:o,data:(h=k==null?void 0:k.data)!==null&&h!==void 0?h:{},create_user:(_=k==null?void 0:k.shouldCreateUser)!==null&&_!==void 0?_:!0,gotrue_meta_security:{captcha_token:k==null?void 0:k.captchaToken},channel:(w=k==null?void 0:k.channel)!==null&&w!==void 0?w:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:P==null?void 0:P.message_id},error:O})}throw new pb("You must provide either an email or phone number.")}catch(o){if(await Ao(this.storage,`${this.storageKey}-code-verifier`),Kr(o))return this._returnResult({data:{user:null,session:null},error:o});throw o}}async verifyOtp(e){var s,u;try{let h,_;"options"in e&&(h=(s=e.options)===null||s===void 0?void 0:s.redirectTo,_=(u=e.options)===null||u===void 0?void 0:u.
<circle cx="12" cy="12" r="10" fill="rgba(255,255,255,0.15)"/>
<circle cx="12" cy="12" r="4" fill="rgba(255,100,100,0.3)"/>
<path d="m4.93 4.93 4.24 4.24" stroke-width="2.5"/>
<path d="m14.83 14.83 4.24 4.24" stroke-width="2.5"/>
<path d="m14.83 9.17 4.24-4.24" stroke-width="2.5"/>
<path d="m4.93 19.07 4.24-4.24" stroke-width="2.5"/>
</svg>`,gradient:"hsl(4 85% 55%)",gradientDark:"hsl(4 85% 42%)"}:e.includes("räddningsstation")||e.includes("rescue station")||e.includes("livräddning")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M8 2h8l4 10H4L8 2Z" fill="rgba(255,255,255,0.2)"/>
<path d="M12 12v10"/>
<path d="M4 22h16"/>
<path d="M12 2v2"/>
<circle cx="12" cy="7" r="2" fill="rgba(255,255,255,0.3)"/>
</svg>`,gradient:"hsl(350 75% 52%)",gradientDark:"hsl(350 75% 40%)"}:e.includes("nödtelefon")||e.includes("emergency phone")||e.includes("sos")||e.includes("larmtelefon")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="5" y="2" width="14" height="20" rx="2" fill="rgba(255,255,255,0.2)"/>
<path d="M12 18h.01"/>
<path d="M9 6h6"/>
<path d="M9 10h6"/>
<path d="M8 14l2 2 4-4" stroke-width="2.5"/>
</svg>`,gradient:"hsl(0 85% 50%)",gradientDark:"hsl(0 85% 38%)"}:e.includes("brygga")||e.includes("pier")||e.includes("kaj")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M2 17c6.667-6 13.333 0 20-6" stroke-width="2.5" opacity="0.6"/>
<path d="M2 21c6.667-6 13.333 0 20-6" stroke-width="2"/>
<rect x="8" y="4" width="8" height="10" rx="1" fill="rgba(255,255,255,0.2)"/>
<path d="M10 4v10"/>
<path d="M14 4v10"/>
</svg>`,gradient:"hsl(200 75% 48%)",gradientDark:"hsl(200 75% 38%)"}:e.includes("strand")||e.includes("beach")||e.includes("bad")||e.includes("vatten")||e.includes("sjö")||e.includes("lake")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1" stroke-width="2.5"/>
<path d="M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/>
<path d="M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/>
</svg>`,gradient:"hsl(195 85% 48%)",gradientDark:"hsl(195 85% 38%)"}:e.includes("stege")||e.includes("ladder")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M8 3v18"/>
<path d="M16 3v18"/>
<path d="M8 6h8"/>
<path d="M8 10h8"/>
<path d="M8 14h8"/>
<path d="M8 18h8"/>
</svg>`,gradient:"hsl(35 75% 52%)",gradientDark:"hsl(35 75% 40%)"}:e.includes("utegym")||e.includes("outdoor gym")||e.includes("gym")||e.includes("träning")||e.includes("fitness")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M6.5 6.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z" fill="rgba(255,255,255,0.2)"/>
<path d="M2 22v-5l4-1v-5l4 2 4-2v5l4 1v5"/>
<path d="M6 11V6.5"/>
<path d="M18 11V6.5"/>
<rect x="15.5" y="2" width="5" height="4" rx="1" fill="rgba(255,255,255,0.2)"/>
</svg>`,gradient:"hsl(145 70% 42%)",gradientDark:"hsl(145 70% 32%)"}:e.includes("fotboll")||e.includes("football")||e.includes("soccer")||e.includes("fotbollsplan")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<circle cx="12" cy="12" r="10" fill="rgba(255,255,255,0.15)"/>
<path d="M12 2a10 10 0 0 0-7.07 2.93"/>
<path d="M12 2a10 10 0 0 1 7.07 2.93"/>
<path d="M2 12a10 10 0 0 0 2.93 7.07"/>
<path d="M22 12a10 10 0 0 1-2.93 7.07"/>
<path d="M12 22a10 10 0 0 1-7.07-2.93"/>
<path d="M12 22a10 10 0 0 0 7.07-2.93"/>
<polygon points="12,7 15,10 14,14 10,14 9,10" fill="rgba(0,0,0,0.3)" stroke="white"/>
</svg>`,gradient:"hsl(120 60% 38%)",gradientDark:"hsl(120 60% 28%)"}:e.includes("tennis")||e.includes("padel")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<circle cx="10" cy="10" r="7" fill="rgba(200,255,0,0.25)"/>
<path d="M10 3a7 7 0 0 0 0 14"/>
<path d="M3 10a7 7 0 0 0 14 0"/>
<path d="m18 18 3 3"/>
<path d="m15 15 2 2"/>
</svg>`,gradient:"hsl(75 85% 45%)",gradientDark:"hsl(75 85% 35%)"}:e.includes("basket")||e.includes("basketball")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<circle cx="12" cy="12" r="10" fill="rgba(255,120,0,0.25)"/>
<path d="M12 2v20"/>
<path d="M2 12h20"/>
<path d="M4.93 4.93c4.08 4.08 10.06 4.08 14.14 0"/>
<path d="M4.93 19.07c4.08-4.08 10.06-4.08 14.14 0"/>
</svg>`,gradient:"hsl(25 90% 52%)",gradientDark:"hsl(25 90% 40%)"}:e.includes("golf")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M12 18V2l7 4-7 4"/>
<path d="M8 22c2.2 0 4-1.8 4-4"/>
<circle cx="6" cy="20" r="2" fill="rgba(255,255,255,0.3)"/>
</svg>`,gradient:"hsl(140 50% 40%)",gradientDark:"hsl(140 50% 30%)"}:e.includes("lekplats")||e.includes("playground")||e.includes("lek")||e.includes("gungor")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M4 22V6l8-4 8 4v16"/>
<path d="M4 12h16"/>
<path d="M8 12v6"/>
<path d="M16 12v6"/>
<circle cx="8" cy="20" r="2" fill="rgba(255,255,255,0.3)"/>
<circle cx="16" cy="20" r="2" fill="rgba(255,255,255,0.3)"/>
</svg>`,gradient:"hsl(45 90% 52%)",gradientDark:"hsl(45 90% 42%)"}:e.includes("löpar")||e.includes("running")||e.includes("track")||e.includes("bana")||e.includes("sprint")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<circle cx="17" cy="5" r="3" fill="rgba(255,255,255,0.2)"/>
<path d="m4 17 4-4 3 3 5-7 4 4"/>
<path d="M22 21H2"/>
</svg>`,gradient:"hsl(10 80% 55%)",gradientDark:"hsl(10 80% 42%)"}:e.includes("skate")||e.includes("skridskor")||e.includes("skridsko")||e.includes("rink")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M5 20a1 1 0 1 0 2 0 1 1 0 1 0-2 0"/>
<path d="M17 20a1 1 0 1 0 2 0 1 1 0 1 0-2 0"/>
<path d="M6 20h12"/>
<path d="m6 16 2-10h8l2 10"/>
<path d="M10 6v4"/>
<path d="M14 6v4"/>
</svg>`,gradient:"hsl(210 80% 55%)",gradientDark:"hsl(210 80% 42%)"}:e.includes("staty")||e.includes("statue")||e.includes("monument")||e.includes("skulptur")||e.includes("sculpture")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<circle cx="12" cy="5" r="3" fill="rgba(255,255,255,0.25)"/>
<path d="M12 8v6"/>
<path d="M8 10l4 4 4-4"/>
<path d="M9 14l-2 8"/>
<path d="M15 14l2 8"/>
<path d="M6 22h12"/>
</svg>`,gradient:"hsl(280 50% 55%)",gradientDark:"hsl(280 50% 42%)"}:e.includes("mural")||e.includes("väggmålning")||e.includes("graffiti")||e.includes("gatukonst")||e.includes("street art")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="3" y="3" width="18" height="18" rx="2" fill="rgba(255,255,255,0.15)"/>
<path d="M9 3v18"/>
<path d="M15 3v18"/>
<path d="M3 9h18"/>
<path d="M3 15h18"/>
<circle cx="12" cy="12" r="2" fill="rgba(255,100,255,0.4)"/>
</svg>`,gradient:"hsl(330 70% 55%)",gradientDark:"hsl(330 70% 42%)"}:e.includes("museum")||e.includes("galleri")||e.includes("gallery")||e.includes("utställning")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M3 22h18"/>
<path d="M6 22V8l6-4 6 4v14"/>
<path d="M12 4v4"/>
<path d="M9 10h6"/>
<rect x="9" y="14" width="6" height="4" fill="rgba(255,255,255,0.2)"/>
</svg>`,gradient:"hsl(35 60% 50%)",gradientDark:"hsl(35 60% 38%)"}:e.includes("kyrka")||e.includes("church")||e.includes("katedral")||e.includes("cathedral")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M12 2v4"/>
<path d="M9 4h6"/>
<path d="M4 22V10l8-4 8 4v12"/>
<path d="M10 22v-6h4v6"/>
<circle cx="12" cy="12" r="2" fill="rgba(255,255,255,0.3)"/>
</svg>`,gradient:"hsl(260 45% 50%)",gradientDark:"hsl(260 45% 38%)"}:e.includes("fontän")||e.includes("fountain")||e.includes("springbrunn")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M12 3v3"/>
<path d="M8 6c0-2 4-2 4-2s4 0 4 2"/>
<path d="M6 14c0 4 6 6 6 6s6-2 6-6"/>
<path d="M12 6c-2 2-2 4-2 6"/>
<path d="M12 6c2 2 2 4 2 6"/>
<ellipse cx="12" cy="20" rx="8" ry="2" fill="rgba(100,200,255,0.3)"/>
</svg>`,gradient:"hsl(200 85% 52%)",gradientDark:"hsl(200 85% 40%)"}:e.includes("skylt")||e.includes("sign")||e.includes("tavla")||e.includes("information")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="3" y="4" width="18" height="10" rx="2" fill="rgba(255,255,255,0.2)"/>
<path d="M12 14v8"/>
<path d="M8 22h8"/>
<path d="M7 8h10"/>
<path d="M7 11h6"/>
</svg>`,gradient:"hsl(220 75% 52%)",gradientDark:"hsl(220 75% 40%)"}:e.includes("byggnad")||e.includes("building")||e.includes("fasad")||e.includes("facade")||e.includes("hus")||e.includes("house")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="4" y="2" width="16" height="20" rx="2" fill="rgba(255,255,255,0.15)"/>
<path d="M9 22v-4h6v4"/>
<rect x="7" y="5" width="3" height="3" fill="rgba(255,220,100,0.4)"/>
<rect x="14" y="5" width="3" height="3" fill="rgba(255,220,100,0.4)"/>
<rect x="7" y="11" width="3" height="3" fill="rgba(255,220,100,0.4)"/>
<rect x="14" y="11" width="3" height="3" fill="rgba(255,220,100,0.4)"/>
</svg>`,gradient:"hsl(220 40% 50%)",gradientDark:"hsl(220 40% 38%)"}:e.includes("butik")||e.includes("store")||e.includes("shop")||e.includes("affär")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M3 9h18v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9Z" fill="rgba(255,255,255,0.15)"/>
<path d="m3 9 2.45-4.9A2 2 0 0 1 7.24 3h9.52a2 2 0 0 1 1.8 1.1L21 9"/>
<path d="M12 3v6"/>
<rect x="8" y="13" width="8" height="6" rx="1" fill="rgba(100,200,255,0.3)"/>
</svg>`,gradient:"hsl(280 55% 52%)",gradientDark:"hsl(280 55% 40%)"}:e.includes("restaurang")||e.includes("restaurant")||e.includes("mat")||e.includes("food")||e.includes("cafe")||e.includes("kafé")||e.includes("meny")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2"/>
<path d="M7 2v20"/>
<path d="M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7"/>
<circle cx="7" cy="17" r="2" fill="rgba(255,255,255,0.2)"/>
</svg>`,gradient:"hsl(25 85% 52%)",gradientDark:"hsl(25 85% 40%)"}:e.includes("parkering")||e.includes("parking")||e.includes("garage")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="4" y="4" width="16" height="16" rx="2" fill="rgba(255,255,255,0.15)"/>
<path d="M9 17V7h4a3 3 0 0 1 0 6H9"/>
</svg>`,gradient:"hsl(210 75% 52%)",gradientDark:"hsl(210 75% 40%)"}:e.includes("bil")||e.includes("car")||e.includes("fordon")||e.includes("vehicle")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.5 2.8C1.4 11.3 1 12.1 1 13v3c0 .6.4 1 1 1h2" fill="rgba(255,255,255,0.15)"/>
<circle cx="7" cy="17" r="2" fill="rgba(255,255,255,0.3)"/>
<path d="M9 17h6"/>
<circle cx="17" cy="17" r="2" fill="rgba(255,255,255,0.3)"/>
</svg>`,gradient:"hsl(215 70% 52%)",gradientDark:"hsl(215 70% 40%)"}:e.includes("träd")||e.includes("tree")||e.includes("park")||e.includes("natur")||e.includes("nature")||e.includes("skog")||e.includes("forest")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="m17 14-5-8-5 8h3v6h4v-6h3Z" fill="rgba(100,200,100,0.3)"/>
<path d="M12 22v-4"/>
<path d="m17 8-5-6-5 6"/>
</svg>`,gradient:"hsl(140 65% 40%)",gradientDark:"hsl(140 65% 30%)"}:e.includes("blomma")||e.includes("flower")||e.includes("trädgård")||e.includes("garden")||e.includes("rabatt")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M12 7.5a4.5 4.5 0 1 1 4.5 4.5M12 7.5A4.5 4.5 0 1 0 7.5 12M12 7.5V9m-4.5 3a4.5 4.5 0 1 0 4.5 4.5M7.5 12H9m7.5 0a4.5 4.5 0 1 1-4.5 4.5m4.5-4.5H15m-3 4.5V15"/>
<circle cx="12" cy="12" r="3" fill="rgba(255,200,100,0.4)"/>
<path d="M12 22v-6"/>
</svg>`,gradient:"hsl(340 70% 55%)",gradientDark:"hsl(340 70% 42%)"}:e.includes("fågel")||e.includes("bird")||e.includes("djur")||e.includes("animal")||e.includes("wildlife")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M16 7h.01"/>
<path d="M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20"/>
<path d="m20 7 2 .5-2 .5"/>
<path d="M10 18v3"/>
<path d="M14 17.75V21"/>
<path d="M7 18a6 6 0 0 0 3.84-10.61"/>
</svg>`,gradient:"hsl(30 70% 50%)",gradientDark:"hsl(30 70% 38%)"}:e.includes("event")||e.includes("händelse")||e.includes("festival")||e.includes("konsert")||e.includes("marknad")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="3" y="4" width="18" height="18" rx="2" fill="rgba(255,255,255,0.15)"/>
<path d="M16 2v4"/>
<path d="M8 2v4"/>
<path d="M3 10h18"/>
<path d="m9 16 2 2 4-4"/>
</svg>`,gradient:"hsl(320 75% 52%)",gradientDark:"hsl(320 75% 40%)"}:e.includes("utrymningsväg")||e.includes("emergency exit")||e.includes("nödutgång")||e.includes("utrymning")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="3" y="3" width="18" height="18" rx="2" fill="rgba(0,200,0,0.25)"/>
<path d="M9 3v18"/>
<path d="m16 8-4 4 4 4"/>
<path d="M12 12h6"/>
<circle cx="6" cy="8" r="1.5" fill="rgba(255,255,255,0.4)"/>
<path d="M5 10v6l2 2"/>
<path d="M7 10v4"/>
</svg>`,gradient:"hsl(145 80% 38%)",gradientDark:"hsl(145 80% 28%)"}:e.includes("räcke")||e.includes("railing")||e.includes("ledstång")||e.includes("handledare")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M4 6h16"/>
<path d="M4 6v12"/>
<path d="M10 6v12"/>
<path d="M16 6v12"/>
<path d="M22 6v12"/>
<path d="M4 18h18"/>
</svg>`,gradient:"hsl(220 30% 50%)",gradientDark:"hsl(220 30% 38%)"}:e.includes("bro")||e.includes("bridge")||e.includes("viadukt")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M4 10c0-4 4-6 8-6s8 2 8 6" stroke-width="2.5"/>
<path d="M4 10v8"/>
<path d="M20 10v8"/>
<path d="M2 18h20"/>
<path d="M8 10v8"/>
<path d="M12 10v8"/>
<path d="M16 10v8"/>
</svg>`,gradient:"hsl(35 50% 45%)",gradientDark:"hsl(35 50% 35%)"}:e.includes("kaj")||e.includes("quay")||e.includes("hamn")||e.includes("harbor")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="2" y="8" width="20" height="6" fill="rgba(255,255,255,0.2)"/>
<path d="M2 14h20"/>
<path d="M6 8V4"/>
<path d="M18 8V4"/>
<circle cx="6" cy="3" r="1" fill="rgba(255,255,255,0.4)"/>
<circle cx="18" cy="3" r="1" fill="rgba(255,255,255,0.4)"/>
<path d="M2 18c2-2 4-2 6 0s4 2 6 0 4-2 6 0"/>
</svg>`,gradient:"hsl(210 60% 45%)",gradientDark:"hsl(210 60% 35%)"}:e.includes("cykelställ")||e.includes("bicycle rack")||e.includes("bike rack")||e.includes("cykelparkering")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<circle cx="5.5" cy="17.5" r="3.5" fill="rgba(255,255,255,0.15)"/>
<circle cx="18.5" cy="17.5" r="3.5" fill="rgba(255,255,255,0.15)"/>
<circle cx="15" cy="5" r="1"/>
<path d="M12 17.5V14l-3-3 4-3 2 3h3"/>
<path d="m5.5 17.5 5-7"/>
<path d="m18.5 17.5-3-8"/>
</svg>`,gradient:"hsl(180 60% 42%)",gradientDark:"hsl(180 60% 32%)"}:e.includes("elskåp")||e.includes("teknikskåp")||e.includes("electrical cabinet")||e.includes("kopplingsskåp")||e.includes("transformator")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="4" y="2" width="16" height="20" rx="2" fill="rgba(255,255,255,0.15)"/>
<path d="M4 10h16"/>
<path d="M12 10v12"/>
<circle cx="8" cy="6" r="1.5" fill="rgba(255,200,0,0.5)"/>
<circle cx="16" cy="6" r="1.5" fill="rgba(100,255,100,0.5)"/>
<path d="M9 14l2 3-2 3"/>
<path d="M15 14l-2 3 2 3"/>
</svg>`,gradient:"hsl(45 80% 45%)",gradientDark:"hsl(45 80% 35%)"}:e.includes("handikappramp")||e.includes("ramp")||e.includes("handicap")||e.includes("tillgänglighet")||e.includes("accessibility")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<circle cx="12" cy="5" r="2" fill="rgba(255,255,255,0.3)"/>
<path d="M12 7v5"/>
<circle cx="9" cy="19" r="2" fill="rgba(255,255,255,0.2)"/>
<circle cx="17" cy="19" r="2" fill="rgba(255,255,255,0.2)"/>
<path d="M9 17h5l3 2"/>
<path d="M9 12h6"/>
<path d="M2 20l6-8"/>
<path d="M22 20H20"/>
</svg>`,gradient:"hsl(210 80% 50%)",gradientDark:"hsl(210 80% 38%)"}:e.includes("brandpost")||e.includes("fire hydrant")||e.includes("hydrant")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="7" y="8" width="10" height="14" rx="2" fill="rgba(255,50,50,0.3)"/>
<path d="M9 8V6a3 3 0 0 1 6 0v2"/>
<path d="M5 13h2"/>
<path d="M17 13h2"/>
<circle cx="12" cy="14" r="2" fill="rgba(255,255,255,0.3)"/>
<path d="M10 22h4"/>
</svg>`,gradient:"hsl(0 80% 50%)",gradientDark:"hsl(0 80% 38%)"}:e.includes("bänk")||e.includes("bench")||e.includes("sittplats")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<rect x="3" y="10" width="18" height="3" rx="1" fill="rgba(255,255,255,0.2)"/>
<path d="M5 13v6"/>
<path d="M19 13v6"/>
<path d="M3 10V8c0-1 1-2 3-2h12c2 0 3 1 3 2v2"/>
<path d="M3 19h18"/>
</svg>`,gradient:"hsl(25 50% 45%)",gradientDark:"hsl(25 50% 35%)"}:e.includes("papperskorg")||e.includes("soptunna")||e.includes("trash")||e.includes("bin")||e.includes("avfall")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M3 6h18"/>
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/>
<path d="M10 11v6"/>
<path d="M14 11v6"/>
</svg>`,gradient:"hsl(100 40% 40%)",gradientDark:"hsl(100 40% 30%)"}:e.includes("belysning")||e.includes("lyktstolpe")||e.includes("street light")||e.includes("lampa")||e.includes("lantern")?{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M12 2v4"/>
<path d="M12 22v-6"/>
<path d="M8 6h8l-1 8H9L8 6Z" fill="rgba(255,220,100,0.4)"/>
<path d="M9 14h6"/>
<path d="M5 4l2 2"/>
<path d="M19 4l-2 2"/>
</svg>`,gradient:"hsl(45 90% 50%)",gradientDark:"hsl(45 90% 38%)"}:{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));">
<path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z" fill="rgba(255,255,255,0.15)"/>
<circle cx="12" cy="13" r="3" fill="rgba(255,255,255,0.2)"/>
</svg>`,gradient:"hsl(168 55% 45%)",gradientDark:"hsl(168 55% 35%)"}}function pse(t={}){const{enabled:e=!0,autoNavigate:s=!0}=t,[u,h]=X.useState(!1),[_,w]=X.useState(!1),[o,k]=X.useState("idle"),[P,O]=X.useState(null),[F,V]=X.useState(null),$=X.useRef(null),Y=X.useRef(null),Z=X.useCallback(()=>{$.current&&($.current.pause(),$.current=null,w(!1))},[]),se=X.useCallback(async(Ie,Be,je)=>{if(!(!e||Ie==="idle")){Z(),h(!0),k(Ie);try{const Je=await fetch("https://tmmrlsaixtghdicmmpmp.supabase.co/functions/v1/voice-guide",{method:"POST",headers:{"Content-Type":"application/json",apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InRtbXJsc2FpeHRnaGRpY21tcG1wIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njc2Njk4ODQsImV4cCI6MjA4MzI0NTg4NH0.lKID0Mt0B-uyYWi57xldQJ56stbG7YopeOEy4ObKoMU",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InRtbXJsc2FpeHRnaGRpY21tcG1wIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njc2Njk4ODQsImV4cCI6MjA4MzI0NTg4NH0.lKID0Mt0B-uyYWi57xldQJ56stbG7YopeOEy4ObKoMU"},body:JSON.stringify({state:Ie,missionTitle:Be.missionTitle,distanceMeters:Be.distanceMeters,targetDescription:Be.targetDescription,instructions:Be.instructions,criticalElements:Be.criticalElements,sponsorReward:Be.sponsorReward,sponsorBrand:Be.sponsorBrand,camera:Be.camera,position:Be.position,voiceId:je})});if(!Je.ok){if(Je.status===429){ro.error("Röstguide tillfälligt otillgänglig, försök igen om en stund");return}if(Je.status===402){ro.error("AI-krediter slut");return}throw new Error(`Voice guide request failed: ${Je.status}`)}const ft=decodeURIComponent(Je.headers.get("X-Generated-Text")||"");V(ft);const kt=await Je.blob(),tr=URL.createObjectURL(kt),jt=new Audio(tr);$.current=jt,jt.onplay=()=>w(!0),jt.onended=()=>{w(!1),O(Ie),URL.revokeObjectURL(tr),$.current=null},jt.onerror=()=>{w(!1),URL.revokeObjectURL(tr),$.current=null},await jt.play()}catch(Je){console.error("Voice guide error:",Je),ro.error("Kunde inte spela röstguide")}finally{h(!1)}}},[e,Z]),te=X.useCallback((Ie,Be)=>{if(!s||!e)return;const je=Y.current;Y.current=Ie;let Je="navigation";Ie<=10?Je="photo":Ie<=50&&(Je="positioning");const ft=Je!==o,kt=je!==null&&o==="navigation"&&Math.abs(Ie-je)>100;(ft||kt)&&(Je!==P||kt)&&se(Je,{...Be,distanceMeters:Ie})},[s,e,o,P,se]),ee=X.useCallback(Ie=>{se("completion",Ie)},[se]),oe=X.useCallback(Ie=>{Ie.sponsorReward&&Ie.sponsorBrand&&se("sponsor",Ie)},[se]),he=X.useCallback((Ie,Be)=>{se(Ie,Be)},[se]);return X.useEffect(()=>()=>{Z()},[Z]),{speak:se,stop:Z,updateNavigation:te,speakCompletion:ee,speakSponsorReward:oe,triggerState:he,isLoading:u,isPlaying:_,currentState:o,lastSpokenText:F,enabled:e}}const mse={idle:"Starta röstguide",navigation:"Navigerar...",positioning:"Positionering...",photo:"Fotoinstruktion...",completion:"Slutför...",sponsor:"Belöning..."};function gse({isLoading:t,isPlaying:e,currentState:s,onPlay:u,onStop:h,className:_,showLabel:w=!1}){const o=()=>{e?h():u()};return le.jsxs($a,{variant:e?"default":"outline",size:w?"sm":"icon",onClick:o,disabled:t,className:ki("transition-all gap-2",e&&"bg-primary animate-pulse",_),children:[t?le.jsx(p1,{className:"h-4 w-4 animate-spin"}):e?le.jsx(t9,{className:"h-4 w-4"}):le.jsx(e9,{className:"h-4 w-4"}),w&&le.jsx("span",{className:"text-xs",children:t?"Laddar...":e?mse[s]:"Röstguide"})]})}function _se(){const{t}=Kf(),[e,s]=X.useState({heading:null,accuracy:null,error:null,supported:!1,permissionGranted:!1}),u=X.useCallback(async()=>{if(typeof DeviceOrientationEvent.requestPermission=="function")try{return await DeviceOrientationEvent.requestPermission()==="granted"?(s(_=>({..._,permissionGranted:!0,error:null})),!0):(s(_=>({..._,error:t("compass.permissionDenied"),permissionGranted:!1})),!1)}catch{return s(_=>({..._,error:t("compass.couldNotRequest")})),!1}return s(h=>({...h,permissionGranted:!0})),!0},[t]);return X.useEffect(()=>{const h="DeviceOrientationEvent"in window;if(s(o=>({...o,supported:h})),!h){s(o=>({...o,error:t("compass.notSupported")}));return}const _=o=>{let k=null;"webkitCompassHeading"in o&&typeof o.webkitCompassHeading=="n
<div class="relative cursor-pointer transform transition-all duration-200 hover:scale-110 hover:-translate-y-0.5">
<div class="w-14 h-14 rounded-2xl flex items-center justify-center shadow-[0_6px_24px_rgba(0,0,0,0.5)] border-[3px] border-white overflow-hidden" style="background: white;">
<img
src="${At.sponsor.logoUrl}"
alt="${At.sponsor.brandName}"
class="w-full h-full object-contain p-1.5"
onerror="this.style.display='none'; this.parentElement.style.background='linear-gradient(145deg, ${On}, ${On}dd)'; this.parentElement.innerHTML='<span style=\\'font-size:20px;font-weight:bold;color:white;\\'>${At.sponsor.brandName.charAt(0)}</span>';"
/>
</div>
<div class="absolute -bottom-2.5 left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-[8px] border-r-[8px] border-t-[11px] border-l-transparent border-r-transparent border-t-white" style="filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));"></div>
<div class="absolute -top-1.5 -right-1.5 text-white text-[10px] font-bold rounded-lg px-2 h-[22px] flex items-center justify-center shadow-[0_2px_8px_rgba(0,0,0,0.35)] whitespace-nowrap" style="background: linear-gradient(145deg, ${On}, ${On}cc); border: 1.5px solid rgba(255,255,255,0.3);">
${At.reward_credits}kr
</div>
<div class="absolute -bottom-6 left-1/2 transform -translate-x-1/2 text-[9px] font-semibold text-white bg-black/60 px-2 py-0.5 rounded-full whitespace-nowrap backdrop-blur-sm">
${At.sponsor.brandName}
</div>
</div>
`}else{const On=fse(At.title);sr.innerHTML=`
<div class="relative cursor-pointer transform transition-all duration-200 hover:scale-110 hover:-translate-y-0.5">
<div class="w-12 h-12 rounded-xl flex items-center justify-center shadow-[0_4px_20px_rgba(0,0,0,0.4)] border-[2.5px] border-white/90" style="background: linear-gradient(145deg, ${On.gradient} 0%, ${On.gradientDark} 100%);">
${On.svg}
</div>
<div class="absolute -bottom-2 left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-[7px] border-r-[7px] border-t-[10px] border-l-transparent border-r-transparent" style="border-top-color: ${On.gradientDark}; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));"></div>
<div class="absolute -top-1.5 -right-1.5 text-white text-[10px] font-bold rounded-lg px-2 h-[22px] flex items-center justify-center shadow-[0_2px_8px_rgba(0,0,0,0.35)] whitespace-nowrap" style="background: linear-gradient(145deg, hsl(18 55% 55%) 0%, hsl(18 55% 45%) 100%); border: 1.5px solid rgba(255,255,255,0.3);">
${At.reward_credits}kr
</div>
</div>
`}if(sr.addEventListener("click",()=>{var On;ft.current&&(xt(At),(On=he.current)==null||On.flyTo({center:[At.longitude,At.latitude],zoom:15,pitch:60}))}),!he.current||!ft.current)return;const Zr=new Eu.Marker(sr).setLngLat([At.longitude,At.latitude]).addTo(he.current);Ie.current.push(Zr)}),t.length>1&&!Qe&&!h&&!un.current&&!Nn.current&&he.current&&ft.current)try{Nn.current=!0;const At=new Eu.LngLatBounds;t.forEach(sr=>At.extend([sr.longitude,sr.latitude])),e&&At.extend([e.longitude,e.latitude]),he.current.fitBounds(At,{padding:80,maxZoom:14,pitch:pv})}catch{}}},[t,Et]),X.useEffect(()=>{if(!he.current||!Et||!ft.current||!e)return;je.current&&(je.current.remove(),je.current=null);const At=document.createElement("div");At.className="user-location-marker",At.innerHTML=`
<div class="relative flex items-center justify-center">
<!-- Outer pulsing glow ring (like Google Maps accuracy circle) -->
<div class="absolute w-24 h-24 rounded-full animate-ping" style="background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(59, 130, 246, 0) 70%); animation-duration: 2s;"></div>
<!-- Medium spotlight ring -->
<div class="absolute w-16 h-16 rounded-full" style="background: radial-gradient(circle, rgba(59, 130, 246, 0.25) 0%, rgba(59, 130, 246, 0) 70%); animation: user-pulse 3s ease-in-out infinite;"></div>
<!-- Inner glow -->
<div class="absolute w-10 h-10 rounded-full" style="background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(59, 130, 246, 0.1) 50%, transparent 70%);"></div>
<!-- User dot with sharp border -->
<div class="relative w-5 h-5 rounded-full shadow-[0_0_12px_rgba(59,130,246,0.8),0_2px_6px_rgba(0,0,0,0.4)]" style="background: linear-gradient(145deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%); border: 3px solid white;">
<!-- Inner bright spot for 3D effect -->
<div class="absolute top-0.5 left-0.5 w-1.5 h-1.5 rounded-full bg-white/60"></div>
</div>
<!-- Direction indicator arrow (optional - shows heading) -->
<div class="absolute -top-3 w-0 h-0 border-l-[5px] border-r-[5px] border-b-[8px] border-l-transparent border-r-transparent border-b-blue-500" style="filter: drop-shadow(0 -1px 2px rgba(0,0,0,0.3)); opacity: 0.9;"></div>
</div>
`,je.current=new Eu.Marker({element:At,anchor:"center"}).setLngLat([e.longitude,e.latitude]).addTo(he.current)},[e,Et]),X.useEffect(()=>{if(!(!he.current||!Et||!ft.current)){try{Be.current.forEach(At=>At.remove())}catch{}Be.current=[],ee.forEach(At=>{const sr=document.createElement("div");sr.className="beauty-mission-marker";const Lr=At.type==="sponsored",Zr=Lr&&At.sponsorEmoji?`<span style="font-size: 16px;">${At.sponsorEmoji}</span>`:`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/>
</svg>`,tn=At.themeColor;if(sr.innerHTML=`
<div class="relative cursor-pointer transform transition-all duration-200 hover:scale-110 hover:-translate-y-0.5">
<div class="w-12 h-12 rounded-xl flex items-center justify-center shadow-[0_4px_20px_rgba(0,0,0,0.4)] border-[2.5px] border-white/90" style="background: linear-gradient(145deg, ${tn}, ${tn}dd);">
${Zr}
</div>
<div class="absolute -bottom-2 left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-[7px] border-r-[7px] border-t-[10px] border-l-transparent border-r-transparent" style="border-top-color: ${tn}; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));"></div>
<div class="absolute -top-1.5 -right-1.5 text-white text-[10px] font-bold rounded-lg px-2 h-[22px] flex items-center justify-center shadow-[0_2px_8px_rgba(0,0,0,0.35)] whitespace-nowrap" style="background: linear-gradient(145deg, ${tn}, ${tn}cc); border: 1.5px solid rgba(255,255,255,0.3);">
${At.reward}kr
</div>
${Lr&&At.sponsor?`
<div class="absolute -bottom-6 left-1/2 transform -translate-x-1/2 text-[9px] font-semibold text-white px-2 py-0.5 rounded-md whitespace-nowrap shadow-[0_2px_8px_rgba(0,0,0,0.3)]" style="background: ${tn}; border: 1px solid rgba(255,255,255,0.2);">
${At.sponsor}
</div>
`:""}
</div>
`,sr.addEventListener("click",()=>{var On;ft.current&&(Ot(At),xt(null),(On=he.current)==null||On.flyTo({center:[At.longitude,At.latitude],zoom:15,pitch:60}))}),!he.current||!ft.current)return;const Wr=new Eu.Marker(sr).setLngLat([At.longitude,At.latitude]).addTo(he.current);Be.current.push(Wr)})}},[ee,Et]);const Wo=()=>{var At,sr,Lr;try{Ie.current.forEach(Zr=>Zr.remove()),Ie.current=[],Be.current.forEach(Zr=>Zr.remove()),Be.current=[],(At=je.current)==null||At.remove(),je.current=null,(sr=Je.current)==null||sr.disconnect(),Je.current=null,(Lr=he.current)==null||Lr.remove(),he.current=null}catch{}qt(null),st(!1),xt(null),Ot(null),yr(Zr=>Zr+1)};return le.jsxs("div",{ref:$,className:"relative w-full h-full",children:[le.jsx("div",{ref:oe,className:"absolute inset-0"}),mi&&le.jsx("div",{className:"absolute inset-0 pointer-events-none z-10 flex items-center justify-center",children:le.jsxs("div",{className:"relative",children:[le.jsx("div",{className:"absolute inset-0 w-32 h-32 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary/20 animate-ping"}),le.jsx("div",{className:"absolute w-24 h-24 -translate-x-1/2 -translate-y-1/2 rounded-full border-4 border-primary/50",style:{animation:"pulse 1.5s ease-in-out infinite"}}),le.jsx("div",{className:"absolute w-12 h-12 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary/30 backdrop-blur-sm flex items-center justify-center",children:le.jsx(oO,{className:"w-6 h-6 text-primary animate-bounce"})})]})}),!Et&&!Pt&&le.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/40 backdrop-blur-sm",children:le.jsx("div",{className:"text-sm text-muted-foreground",children:Y("map.loadingMap")})}),Pt&&le.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-background/40 backdrop-blur-sm p-6",children:le.jsxs("div",{className:"text-center text-muted-foreground max-w-sm bg-card/90 border border-border rounded-lg p-4 shadow-lg",children:[le.jsx(m1,{className:"w-10 h-10 mx-auto mb-2 opacity-60"}),le.jsx("p",{className:"text-sm leading-relaxed",children:Pt}),le.jsx($a,{onClick:Wo,className:"mt-3",variant:"outline",children:Y("map.reloadMap")})]})}),le.jsxs("div",{className:"absolute left-3 z-20 flex items-center gap-2",style:{top:"calc(env(safe-area-inset-top, 0px) + 12px)"},children:[le.jsx("div",{className:"bg-background/80 backdrop-blur-sm rounded-lg p-1.5 shadow-md border border-border/50",children:le.jsx(Jj,{})}),le.jsxs("button",{onClick:()=>{const At=he.current;!At||!Et||(Ks?(F3(At),Un(!1)):(z3(At)?(so(!1),At.easeTo({pitch:pv,bearing:mv,duration:800})):so(!0),Un(!0)))},disabled:!Et,className:"bg-background/80 backdrop-blur-sm rounded-lg px-3 py-1.5 shadow-md border border-border/50 text-xs font-medium text-foreground hover:bg-accent transition-colors disabled:opacity-50",children:[ua?"3D":"2D",io&&le.jsx("span",{className:"ml-1 text-muted-foreground",children:"(auto)"})]}),_&&e&&le.jsxs("button",{onClick:()=>{var Zr;const At=_.geometry.coordinates,sr=At.length>1?At[1]:At[0],Lr=AE(e.latitude,e.longitude,sr[1],sr[0]);(Zr=he.current)==null||Zr.flyTo({center:[e.longitude,e.latitude],zoom:17,pitch:52,bearing:Lr,duration:700})},className:"bg-primary text-primary-foreground rounded-lg px-3 py-1.5 shadow-md text-xs font-medium hover:bg-primary/90 transition-colors flex items-center gap-1.5",children:[le.jsx(Gq,{className:"w-4 h-4"}),Y("map.centerOnMe")]})]}),P&&le.jsxs("div",{className:"absolute bottom-32 left-4 right-4 z-40 space-y-3 animate-fade-in",children:[le.jsxs("div",{className:"flex justify-center gap-2",children:[le.jsx("button",{onClick:()=>Gr("walking"),className:`w-14 h-14 rounded-2xl flex items-center justify-center shadow-lg transition-all duration-200 ${hr==="walking"?"bg-primary text-primary-foreground scale-110":"bg-card/95 text-muted-foreground hover:bg-card border border-border"}`,children:le.jsx(sO,{className:"w-6 h-6"})}),le.jsx("button",{onClick:()=>Gr("cycling"),className:`w-14 h-14 rounded-2xl flex items-center justify-center shadow-lg transition-all duration-200 ${hr==="cycling"?"bg-primary text-prim
.mission-marker,
.beauty-mission-marker,
.user-location-marker {
cursor: pointer;
}
/* User location pulse animation */
@keyframes user-pulse {
0%, 100% {
transform: scale(1);
opacity: 0.6;
}
50% {
transform: scale(1.15);
opacity: 0.3;
}
}
/* User location outer glow animation */
@keyframes user-glow {
0%, 100% {
opacity: 0.4;
transform: scale(0.95);
}
50% {
opacity: 0.2;
transform: scale(1.1);
}
}
.user-location-marker > div > div:first-child {
animation: user-glow 2.5s ease-in-out infinite !important;
}
.mapboxgl-ctrl-group {
background: hsl(var(--card)) !important;
border: 1px solid hsl(var(--border)) !important;
}
.mapboxgl-ctrl-group button {
background-color: transparent !important;
}
.mapboxgl-ctrl-group button:hover {
background-color: hsl(var(--muted)) !important;
}
.mapboxgl-ctrl-group button span {
filter: invert(1);
}
.mapboxgl-ctrl-logo {
display: none !important;
}
.mapboxgl-ctrl-attrib {
display: none !important;
}
.mapboxgl-ctrl-scale {
display: none !important;
}
`})]})});_V.displayName="MissionMap";const CE="https://api.quixzoom.com/api/qz",Ase=3e4;function Cse(){const{user:t}=qf(),[e,s]=X.useState([]),[u,h]=X.useState(0),[_,w]=X.useState(!0),o=X.useRef(null),k=X.useCallback(async()=>{if(!t){w(!1);return}const F=Sa.getToken();if(!F){w(!1);return}try{const V=await fetch(`${CE}/notifications?limit=50`,{headers:{Authorization:`Bearer ${F}`}});if(V.ok){const $=await V.json();s($.notifications||[]),h($.unread??0)}else V.status===404?(s([]),h(0)):console.error("[useNotifications] fetch error:",V.status)}catch(V){console.error("[useNotifications] network error:",V)}finally{w(!1)}},[t]);return X.useEffect(()=>(k(),o.current=setInterval(k,Ase),()=>{o.current&&clearInterval(o.current)}),[k]),{notifications:e,unreadCount:u,isLoading:_,markAsRead:async F=>{const V=Sa.getToken();if(V)try{(await fetch(`${CE}/notifications/${encodeURIComponent(F)}`,{method:"PATCH",headers:{Authorization:`Bearer ${V}`}})).ok&&(s(Y=>Y.map(Z=>Z.id===F?{...Z,read:!0}:Z)),h(Y=>Math.max(0,Y-1)))}catch($){console.error("[useNotifications] markAsRead error:",$)}},markAllAsRead:async()=>{if(!t)return;const F=Sa.getToken();if(F)try{(await fetch(`${CE}/notifications/read-all`,{method:"PATCH",headers:{Authorization:`Bearer ${F}`}})).ok&&(s($=>$.map(Y=>({...Y,read:!0}))),h(0))}catch(V){console.error("[useNotifications] markAllAsRead error:",V)}}}}const Ise=()=>{const{user:t}=qf(),[e,s]=X.useState(null),[u,h]=X.useState(!0),[_,w]=X.useState(null),o=async()=>{if(!t){s(null),h(!1);return}try{h(!0);const{data:$,error:Y}=await qd.from("orderer_profiles").select("*").eq("user_id",t.id).maybeSingle();if(Y)throw Y;s($),w(null)}catch($){console.error("Error fetching orderer profile:",$),w("Kunde inte hämta beställarprofil")}finally{h(!1)}};X.useEffect(()=>{o()},[t]);const k=async $=>{if(!t)return{error:"Inte inloggad"};try{const{data:Y,error:Z}=await qd.from("orderer_profiles").insert({user_id:t.id,...$}).select().single();if(Z)throw Z;return s(Y),{data:Y,error:null}}catch(Y){return console.error("Error creating orderer profile:",Y),Y.code==="23505"?{error:"En beställarprofil finns redan för detta konto eller organisationsnummer"}:{error:"Kunde inte skapa beställarprofil"}}},P=async $=>{if(!t||!e)return{error:"Ingen beställarprofil att uppdatera"};try{const{data:Y,error:Z}=await qd.from("orderer_profiles").update($).eq("user_id",t.id).select().single();if(Z)throw Z;return s(Y),{data:Y,error:null}}catch(Y){return console.error("Error updating orderer profile:",Y),{error:"Kunde inte uppdatera beställarprofil"}}},O=(e==null?void 0:e.status)==="active",F=(e==null?void 0:e.status)==="pending",V=O&&(e.payment_method==="stripe"||e.credit_approved);return{ordererProfile:e,isLoading:u,error:_,isActiveOrderer:O,isPendingOrderer:F,canOrder:V,createOrdererProfile:k,updateOrdererProfile:P,refetch:o}},yV=X.forwardRef(({className:t},e)=>le.jsxs("div",{ref:e,className:`relative ${t}`,children:[le.jsx(YB,{className:"w-6 h-6"}),le.jsx(Hq,{className:"absolute -top-1 -left-1.5 w-3.5 h-3.5 stroke-[3]"})]}));yV.displayName="CameraDollarIcon";const vV=X.forwardRef((t,e)=>{const s=r_(),u=Wf(),{t:h}=Kf(),{user:_}=qf(),{unreadCount:w}=Cse();Ise();const o=!!_,P=[{id:"home",icon:yV,labelKey:"missions.title",path:"/"},{id:"map",icon:Wq,labelKey:"nav.map",path:"/map"},{id:"notifications",icon:Bq,labelKey:"nav.notifications",path:"/notifications"},{id:"wallet",icon:r9,labelKey:"nav.wallet",path:"/wallet"}],F=(()=>{const Y=u.pathname;if(Y==="/profile")return"profile";if(Y==="/auth")return"auth";if(Y.startsWith("/orderer/"))return"dashboard";const Z=P.find(se=>se.path===Y);return Z?Z.id:"home"})(),V=Y=>{if(Y.requiresAuth&&!o){ro.info(h("auth.loginRequired","Logga in för att använda denna funktion")),s("/auth");return}s(Y.path)},$=()=>{s(o?"/profile":"/auth")};return le.jsxs("nav",{ref:e,className:"fixed bottom-0 left-0 right-0 z-40 safe-area-x",children:[le.jsx("div",{className:"absolute inset-0 bg-background/95 backdrop-blur-xl border-t border-border/50"}),le.jsxs("div",{className:"relative flex items-center justify-around px-1 pt-3 pb-3 safe-area
.`.concat(Gse,` {
overflow: hidden `).concat(u,`;
padding-right: `).concat(o,"px ").concat(u,`;
}
body[`).concat(Eg,`] {
overflow: hidden `).concat(u,`;
overscroll-behavior: contain;
`).concat([e&&"position: relative ".concat(u,";"),s==="margin"&&`
padding-left: `.concat(h,`px;
padding-top: `).concat(_,`px;
padding-right: `).concat(w,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(o,"px ").concat(u,`;
`),s==="padding"&&"padding-right: ".concat(o,"px ").concat(u,";")].filter(Boolean).join(""),`
}
.`).concat(Vb,` {
right: `).concat(o,"px ").concat(u,`;
}
.`).concat(Ub,` {
margin-right: `).concat(o,"px ").concat(u,`;
}
.`).concat(Vb," .").concat(Vb,` {
right: 0 `).concat(u,`;
}
.`).concat(Ub," .").concat(Ub,` {
margin-right: 0 `).concat(u,`;
}
body[`).concat(Eg,`] {
`).concat(Hse,": ").concat(o,`px;
}
`)},W3=function(){var t=parseInt(document.body.getAttribute(Eg)||"0",10);return isFinite(t)?t:0},uoe=function(){X.useEffect(function(){return document.body.setAttribute(Eg,(W3()+1).toString()),function(){var t=W3()-1;t<=0?document.body.removeAttribute(Eg):document.body.setAttribute(Eg,t.toString())}},[])},doe=function(t){var e=t.noRelative,s=t.noImportant,u=t.gapMode,h=u===void 0?"margin":u;uoe();var _=X.useMemo(function(){return aoe(h)},[h]);return X.createElement(loe,{styles:coe(_,!e,h,s?"":"!important")})},DA=!1;if(typeof window<"u")try{var gb=Object.defineProperty({},"passive",{get:function(){return DA=!0,!0}});window.addEventListener("test",gb,gb),window.removeEventListener("test",gb,gb)}catch{DA=!1}var $m=DA?{passive:!1}:!1,hoe=function(t){return t.tagName==="TEXTAREA"},EV=function(t,e){if(!(t instanceof Element))return!1;var s=window.getComputedStyle(t);return s[e]!=="hidden"&&!(s.overflowY===s.overflowX&&!hoe(t)&&s[e]==="visible")},foe=function(t){return EV(t,"overflowY")},poe=function(t){return EV(t,"overflowX")},q3=function(t,e){var s=e.ownerDocument,u=e;do{typeof ShadowRoot<"u"&&u instanceof ShadowRoot&&(u=u.host);var h=kV(t,u);if(h){var _=AV(t,u),w=_[1],o=_[2];if(w>o)return!0}u=u.parentNode}while(u&&u!==s.body);return!1},moe=function(t){var e=t.scrollTop,s=t.scrollHeight,u=t.clientHeight;return[e,s,u]},goe=function(t){var e=t.scrollLeft,s=t.scrollWidth,u=t.clientWidth;return[e,s,u]},kV=function(t,e){return t==="v"?foe(e):poe(e)},AV=function(t,e){return t==="v"?moe(e):goe(e)},_oe=function(t,e){return t==="h"&&e==="rtl"?-1:1},yoe=function(t,e,s,u,h){var _=_oe(t,window.getComputedStyle(e).direction),w=_*u,o=s.target,k=e.contains(o),P=!1,O=w>0,F=0,V=0;do{if(!o)break;var $=AV(t,o),Y=$[0],Z=$[1],se=$[2],te=Z-se-_*Y;(Y||te)&&kV(t,o)&&(F+=te,V+=Y);var ee=o.parentNode;o=ee&&ee.nodeType===Node.DOCUMENT_FRAGMENT_NODE?ee.host:ee}while(!k&&o!==document.body||k&&(e.contains(o)||e===o));return(O&&Math.abs(F)<1||!O&&Math.abs(V)<1)&&(P=!0),P},_b=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},K3=function(t){return[t.deltaX,t.deltaY]},Z3=function(t){return t&&"current"in t?t.current:t},voe=function(t,e){return t[0]===e[0]&&t[1]===e[1]},xoe=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
`)},woe=0,Gm=[];function boe(t){var e=X.useRef([]),s=X.useRef([0,0]),u=X.useRef(),h=X.useState(woe++)[0],_=X.useState(TV)[0],w=X.useRef(t);X.useEffect(function(){w.current=t},[t]),X.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(h));var Z=Pre([t.lockRef.current],(t.shards||[]).map(Z3),!0).filter(Boolean);return Z.forEach(function(se){return se.classList.add("allow-interactivity-".concat(h))}),function(){document.body.classList.remove("block-interactivity-".concat(h)),Z.forEach(function(se){return se.classList.remove("allow-interactivity-".concat(h))})}}},[t.inert,t.lockRef.current,t.shards]);var o=X.useCallback(function(Z,se){if("touches"in Z&&Z.touches.length===2||Z.type==="wheel"&&Z.ctrlKey)return!w.current.allowPinchZoom;var te=_b(Z),ee=s.current,oe="deltaX"in Z?Z.deltaX:ee[0]-te[0],he="deltaY"in Z?Z.deltaY:ee[1]-te[1],Ie,Be=Z.target,je=Math.abs(oe)>Math.abs(he)?"h":"v";if("touches"in Z&&je==="h"&&Be.type==="range")return!1;var Je=q3(je,Be);if(!Je)return!0;if(Je?Ie=je:(Ie=je==="v"?"h":"v",Je=q3(je,Be)),!Je)return!1;if(!u.current&&"changedTouches"in Z&&(oe||he)&&(u.current=Ie),!Ie)return!0;var ft=u.current||Ie;return yoe(ft,se,Z,ft==="h"?oe:he)},[]),k=X.useCallback(function(Z){var se=Z;if(!(!Gm.length||Gm[Gm.length-1]!==_)){var te="deltaY"in se?K3(se):_b(se),ee=e.current.filter(function(Ie){return Ie.name===se.type&&(Ie.target===se.target||se.target===Ie.shadowParent)&&voe(Ie.delta,te)})[0];if(ee&&ee.should){se.cancelable&&se.preventDefault();return}if(!ee){var oe=(w.current.shards||[]).map(Z3).filter(Boolean).filter(function(Ie){return Ie.contains(se.target)}),he=oe.length>0?o(se,oe[0]):!w.current.noIsolation;he&&se.cancelable&&se.preventDefault()}}},[]),P=X.useCallback(function(Z,se,te,ee){var oe={name:Z,delta:se,target:te,should:ee,shadowParent:Soe(te)};e.current.push(oe),setTimeout(function(){e.current=e.current.filter(function(he){return he!==oe})},1)},[]),O=X.useCallback(function(Z){s.current=_b(Z),u.current=void 0},[]),F=X.useCallback(function(Z){P(Z.type,K3(Z),Z.target,o(Z,t.lockRef.current))},[]),V=X.useCallback(function(Z){P(Z.type,_b(Z),Z.target,o(Z,t.lockRef.current))},[]);X.useEffect(function(){return Gm.push(_),t.setCallbacks({onScrollCapture:F,onWheelCapture:F,onTouchMoveCapture:V}),document.addEventListener("wheel",k,$m),document.addEventListener("touchmove",k,$m),document.addEventListener("touchstart",O,$m),function(){Gm=Gm.filter(function(Z){return Z!==_}),document.removeEventListener("wheel",k,$m),document.removeEventListener("touchmove",k,$m),document.removeEventListener("touchstart",O,$m)}},[]);var $=t.removeScrollBar,Y=t.inert;return X.createElement(X.Fragment,null,Y?X.createElement(_,{styles:xoe(h)}):null,$?X.createElement(doe,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function Soe(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const Toe=Jse(SV,boe);var CV=X.forwardRef(function(t,e){return X.createElement(gS,Uc({},t,{ref:e,sideCar:Toe}))});CV.classNames=gS.classNames;var Eoe=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Hm=new WeakMap,yb=new WeakMap,vb={},OE=0,IV=function(t){return t&&(t.host||IV(t.parentNode))},koe=function(t,e){return e.map(function(s){if(t.contains(s))return s;var u=IV(s);return u&&t.contains(u)?u:(console.error("aria-hidden",s,"in not contained inside",t,". Doing nothing"),null)}).filter(function(s){return!!s})},Aoe=function(t,e,s,u){var h=koe(e,Array.isArray(t)?t:[t]);vb[s]||(vb[s]=new WeakMap);var _=vb[s],w=[],o=new Set,k=new Set(h),P=function(F){!F||o.has(F)||(o.add(F),P(F.parentNode))};h.forEach(P);var O=function(F){!F||k.has(F)||Array.prototype.forEach.call(F.children,function(V){if(o.has(V))O(V);else try{var $=V.getAttribute(u),Y=$!==null&&$!=="false",Z=(Hm.get(V)||0)+1,se=(_.get(V)||0)+1;Hm.set(V,Z),_.set(V,se),w.push(V),Z===1&&Y&&yb.set(V,!0),se===1&&V.setAttribute(s,"true"),Y||V.setAttribute(u,"true")}catch(te){console.error("aria-hidden: cannot operate on ",V,te)}})};return O(e),o.clear(),OE++,function(){w
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return X.useEffect(()=>{t&&(document.getElementById(t)||console.error(s))},[s,t]),null},zoe="DialogDescriptionWarning",Foe=({contentRef:t,descriptionId:e})=>{const u=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${HV(zoe).contentName}}.`;return X.useEffect(()=>{var _;const h=(_=t.current)==null?void 0:_.getAttribute("aria-describedby");e&&h&&(document.getElementById(e)||console.warn(u))},[u,t,e]),null},Boe=MV,Noe=DV,joe=OV,WV=zV,qV=FV,KV=NV,ZV=VV,Voe=$V;const Uoe=Boe,Wue=Noe,$oe=joe,XV=X.forwardRef(({className:t,...e},s)=>le.jsx(WV,{ref:s,className:ki("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));XV.displayName=WV.displayName;const YV=X.forwardRef(({className:t,children:e,...s},u)=>le.jsxs($oe,{children:[le.jsx(XV,{}),le.jsxs(qV,{ref:u,className:ki("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s,children:[e,le.jsxs(Voe,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[le.jsx(Df,{className:"h-4 w-4"}),le.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));YV.displayName=qV.displayName;const JV=({className:t,...e})=>le.jsx("div",{className:ki("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});JV.displayName="DialogHeader";const QV=X.forwardRef(({className:t,...e},s)=>le.jsx(KV,{ref:s,className:ki("text-lg font-semibold leading-none tracking-tight",t),...e}));QV.displayName=KV.displayName;const eU=X.forwardRef(({className:t,...e},s)=>le.jsx(ZV,{ref:s,className:ki("text-sm text-muted-foreground",t),...e}));eU.displayName=ZV.displayName;const tU=X.forwardRef(({className:t,type:e,...s},u)=>le.jsx("input",{type:e,className:ki("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:u,...s}));tU.displayName="Input";const rU=X.forwardRef(({className:t,...e},s)=>le.jsx("textarea",{className:ki("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...e}));rU.displayName="Textarea";var Goe="Label",nU=X.forwardRef((t,e)=>le.jsx(qi.label,{...t,ref:e,onMouseDown:s=>{var h;s.target.closest("button, input, select, textarea")||((h=t.onMouseDown)==null||h.call(t,s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));nU.displayName=Goe;var iU=nU;const Hoe=FC("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),gf=X.forwardRef(({className:t,...e},s)=>le.jsx(iU,{ref:s,className:ki(Hoe(),t),...e}));gf.displayName=iU.displayName;function sU(t,[e,s]){return Math.min(s,Math.max(e,t))}var Woe=X.createContext(void 0);function qoe(t){const e=X.useContext(Woe);return t||e||"ltr"}function Koe(t){const e=X.useRef({value:t,previous:t});return X.useMemo(()=>(e.current.value!==t&&(e.c